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

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