Source for file DBMS_FIELD_SER_OBJ.phpclass

Documentation is available at DBMS_FIELD_SER_OBJ.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_SER_OBJ.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   any
  8.   *
  9.   * @author     Peter Krebs (pk)<p.krebs@lvus.at>
  10.   * @copyright  (c) 2002-2005 by LVUS <http://opencsp.lvu.at>
  11.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  12.   *
  13.   ***/
  14.  
  15.  
  16. if (empty($GLOBALS['OCSP']['PHPFORMPATH'])) $GLOBALS['OCSP']['PHPFORMPATH']=dirname(__FILE__)."/";
  17.   
  18. if (!class_exists("DBMS_FIELD")) {
  19.     require_once dirname(__FILE__)."/DBMS_FIELD.phpclass";
  20. /**
  21.   * handle show readonly serilaized data in a table field
  22.   *
  23.   * this class can only be used for readonly fields
  24.   *
  25.   * @project    Open CSP-Management
  26.   * @package    dbms_field
  27.   * @category   any
  28.   *
  29.   * @author     Peter Krebs (pk)<p.krebs@lvus.at>
  30.   * @copyright  (c) 2002-2005 by LVUS <http://opencsp.lvu.at>
  31.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  32.   *
  33.   * @version pk-03-10-22
  34.   *
  35.   ***/
  36. class DBMS_FIELD_SER_OBJ extends DBMS_FIELD {
  37.     /**
  38.       * @staticvar string $className 
  39.       ***/
  40.     var $className       = "SerializedObject";
  41.     /**
  42.       * @var int $myValShowMode show mode (html-tag) of the value
  43.       * @version pk-03-10-10
  44.       ***/
  45.     var $myValShowMode=0;
  46.     /**
  47.       * @staticvar array $static_ValShowmodes values of show value mode
  48.       * @version pk-03-10-10
  49.       ***/
  50.     var $static_ValShowmodes=array(
  51.         0=>'asis',
  52.         1=>'pre',
  53.         2=>'textarea'
  54.     );
  55.  
  56.     /**
  57.         * source file of the class
  58.         *
  59.         * @var string $classSrcFile 
  60.         * @since pk-05-02-19
  61.         ***/
  62.     var $classSrcFile=__FILE__;
  63.     
  64.     /**
  65.       * echos input form for field definition
  66.       *
  67.       * @version pk-03-10-10
  68.       *
  69.       * @todo input rows and cols for textarea mode
  70.       ***/
  71.     function editTblForm({
  72.         ?>
  73.             <tr>
  74.                 <td colspan="2" align="center" style="color:red"><b>ACHTUNG NUR READONLY VERWENDUNG</b></td>
  75.             </tr>
  76.         <?php
  77.         parent::editTblForm(FALSE,FALSE);
  78.         ?>
  79.             <tr>
  80.                 <td class="fldName">Value Anzeigemodus:</td>
  81.                 <td class="fldValue"><select name="myValShowMode" size="1">
  82.                     <?php
  83.                         foreach($this->static_ValShowmodes as $mode => $name{
  84.                             echo "<option value=\"".$mode."\" ";
  85.                             if ($this->myValShowMode == $modeecho " selected ";
  86.                             echo ">".$name."</option>";
  87.                         }
  88.                     ?>
  89.                 </select></td>
  90.             </tr>
  91.         <?php
  92.     }
  93.  
  94.     /**
  95.       * saves the field definition from $_POST array
  96.       *
  97.       * @version pk-03-10-10
  98.       ***/
  99.     function save({
  100.         $ret parent::save();
  101.  
  102.         $this->myValShowMode = intval($_POST['myValShowMode']);
  103.  
  104.         return $ret;
  105.     }
  106.  
  107.     // ###################################
  108.  
  109.     /**
  110.       * echos the input html tag for the field
  111.       *
  112.       * the modes FRM_MODE_NEW and FRM_MODE_EDIT only returns FALSE
  113.       * no output is generated
  114.       *
  115.       * @param int $mode show mode of the field
  116.       * @param mixed $aValue value to show as field value
  117.       * @param string $arrName of the post array ($_POST[$arrName][$this->myName])
  118.       * @param bool $debug show debug info
  119.       *
  120.       * @return bool TRUE if a form field is echoed FALSE if there is no input to store
  121.       *
  122.       ***/
  123.     function writeField($mode,$aValue="",$arrName="DBVAL",$debug=FALSE{
  124.         switch($mode{
  125.             case FRM_MODE_READONLY:
  126.             case FRM_MODE_LIST:
  127.                 echo $this->getScreenValue($aValue,$arrName,$debug);
  128.                 return FALSE;
  129.             case FRM_MODE_NEW:      // no output
  130.             case FRM_MODE_EDIT:     // no output
  131.                 return FALSE;
  132.             default:
  133.                 return parent::writeField($mode,htmlspecialchars($val),$arrName);
  134.         }
  135.     }
  136.  
  137.     /**
  138.       * returns the html-code representation of $aValue
  139.       *
  140.       * if $aValue is an array a table code is returned
  141.       *
  142.       * @param mixed $aValue value of the field
  143.       * @param string $arrName name of the post array - not used
  144.       * @param bool $debug show debug information
  145.       *
  146.       * @return string html-code
  147.       *
  148.       * @todo   how to present an object in HTML code ???
  149.       ***/
  150.     function getScreenValue($aValue,$arrName="DBVAL",$debug=FALSE{
  151.        return "[OBJECT]";
  152.        /* 
  153.         if (!empty($aValue)) {
  154.             $arr=@unserialize($aValue);
  155.             if (is_array($arr)) {
  156.  
  157.                 $ret="<table border='1' width='100%'>";
  158.  
  159.                 foreach($arr as $key => $val) {
  160.                     $ret.="<tr>";
  161.                     if ($this->showArrKeys) {
  162.                         $ret.="<td width='15%'><b>$key</b></td>";
  163.                     }
  164.                     $ret.="<td>";
  165.                     switch(intval($this->myValShowMode)) {
  166.                         case 1: // pre
  167.                             $ret.="<pre>".htmlspecialchars($val)."</pre>";
  168.                             break;
  169.                         case 2: // textarea
  170.                             $cols=25;
  171.                             $rows=ceil(strlen($val)/$cols);
  172.                             if ($rows > 6) $rows=6;
  173.                             $ret.="<textarea rows=\"".$rows."\" cols=\"".$cols."\" readonly class=\"pre\">";
  174.                             $ret.=htmlspecialchars($val);
  175.                             $ret.="</textarea>";
  176.                             break;
  177.                         default:
  178.                             $ret.=htmlspecialchars($val);
  179.                     }
  180.                     $ret.="</td>";
  181.                 }
  182.                 $ret.="</table>";
  183.                 return $ret;
  184.             } else {
  185.                 return "";
  186.             }
  187.         } else {
  188.             return "";
  189.         }
  190.         */
  191.     }
  192.  
  193. // end class DBMS_FIELD_ARRSELECTLIST
  194. ?>

Documentation generated on Thu, 08 Jan 2009 17:42:53 +0100 by phpDocumentor 1.4.0a2