Source for file DBMS_FIELD_INPUTFORM.phpclass

Documentation is available at DBMS_FIELD_INPUTFORM.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_INPUTFORM.phpclass
  4.   *
  5.   * @package    dbms_field
  6.   * @category   blob
  7.   *
  8.   * @author     Peter Krebs (pk)<p.krebs@lvus.at>
  9.   * @copyright  (c) 2002-2005 by LVUS <http://opencsp.lvu.at>
  10.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11.   *
  12.   ***/
  13.  
  14. if (empty($GLOBALS['OCSP']['PHPFORMPATH'])) $GLOBALS['OCSP']['PHPFORMPATH']=dirname(__FILE__)."/";
  15.   
  16. if (!class_exists("DBMS_FIELD")) {
  17.     require_once dirname(__FILE__)."/DBMS_FIELD.phpclass";
  18. }  
  19.  
  20. /**
  21.   * Class DBMS_FIELD_INPUTFORM
  22.   *
  23.   * @project    Open CSP-Management
  24.   * @package    dbms_field
  25.   * @category   blob
  26.   *
  27.   * @author     Peter Krebs (pk)<p.krebs@lvus.at>
  28.   * @copyright  (c) 2002-2005 by LVUS <http://opencsp.lvu.at>
  29.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  30.   *
  31.   ***/
  32. class DBMS_FIELD_INPUTFORM extends DBMS_FIELD {
  33.     var $className     = "INPUTFORM";
  34.  
  35.     /**
  36.       * Value Array Name
  37.       * @var string $valArrName 
  38.       ***/
  39.     var $valArrName     = "";
  40.  
  41.     /**
  42.       * Value Array Name
  43.       * @var string $valArrName 
  44.       ***/
  45.     var $valTblName     = "NOTABLE";
  46.  
  47.  
  48.     /**
  49.       * @var    string  $editorUrl      which editor url to start with edit button
  50.       */
  51.     var $editorUrl     = "";
  52.  
  53.     /**
  54.         * source file of the class
  55.         *
  56.         * @var string $classSrcFile 
  57.         * @since pk-05-02-19
  58.         ***/
  59.     var $classSrcFile=__FILE__;
  60.  
  61.     /**
  62.       * echos input form for field definition
  63.       *
  64.       **/
  65.  
  66.     function editTblForm({
  67.         parent::editTblForm(FALSE,FALSE);
  68.         if (empty($this->editorUrl)) {
  69.             $this->editorUrl = $GLOBALS['PROJECT']['SYSTEMURL']."editors/inputform/index.php";
  70.         }
  71.         ?>
  72.             <tr>
  73.                 <td class="fldName">Editor:</td>
  74.                 <td class="fldValue">
  75.                     <input name="editorUrl" size="40" value="<?php echo $this->editorUrl?>">
  76.                 </td>
  77.             </tr>
  78.             <tr>
  79.                 <td class="fldName">Value Array Name</td>
  80.                 <td class="fldValue">
  81.                     <input type="text" name="valArrName" value="<?php echo htmlspecialchars($this->valArrName)?>">
  82.                 </td>
  83.             </tr>
  84.         <?php
  85.     }
  86.  
  87.     /**
  88.       * saves the field definition from $_POST array
  89.       **/
  90.  
  91.     function save({
  92.         $ret=parent::save();
  93.         $this->editorUrl    =$_POST['editorUrl'];
  94.         $this->valArrName   =$_POST['valArrName'];
  95.         $this->allowNull    =TRUE;
  96.         return $ret;
  97.     }
  98.  
  99.     /**
  100.       * returns a string with the HTML input-tag for the field
  101.       *
  102.       * @param  string  $aValue     the value to show
  103.       * @param  string  $arrName    name of the form array used in name=
  104.       *
  105.       * @return string 
  106.       *
  107.       ***/
  108.     function getInputTag($aValue,$arrName="DBVAL"{
  109.         $tag ="<div name=\"DIV$arrName_".$this->myName."\">\n";
  110.         $tag.="<table border=\"1\">\n";
  111.         $tag.="\t<tr><th align=\"center\">Field</th><th align=\"center\">Label</th><th align=\"center\">Input-Type</th><th align=\"center\">ShowClass</th></tr>\n";
  112.         if ((!empty($aValue)) && ($valArr=unserialize(base64_decode($aValue))) && (is_array($valArr))) {
  113.             foreach($valArr as $key => $fld{
  114.                 $tag.="\t<tr>";
  115.                 $tag.="<td>".$fld->myName."</td>";
  116.                 $tag.="<td>".$fld->label."</td>";
  117.                 $tag.="<td>".$GLOBALS['DBFLDTYPES_DESC'][$fld->dbDesc['TYPE']]."</td>";
  118.                 $tag.="<td>".str_replace("DBMS_FIELD_","",strtoupper(get_class($fld)))."</td>";
  119.                 $tag.="</tr>\n";
  120.             }
  121.         }
  122.         $tag .="</table>\n";
  123.         $tag .= "</div>\n";
  124.         if ($debug{
  125.             $tag .= "<input name=\"".$arrName."[".$this->myName."]\" value=\"".$aValue."\">";
  126.         else {
  127.             $tag .= "<input type=\"hidden\" name=\"".$arrName."[".$this->myName."]\" value=\"".$aValue."\">";
  128.         }            
  129.         $tag .= "<br /><a href=\"#\" onClick=";
  130.         $tag .= "wnd=openWindow('formEditor','".$this->editorUrl;
  131.         $tag .= "?".$_SERVER['QUERY_STRING'];
  132.         $tag .= "&frmfield=".urlencode($arrName."[".$this->myName."]")."'";
  133.         $tag .= ",800,600);\"><img src=\"".$GLOBALS[PROJECT]['SYSIMGURL']."icons-22x22/configure.png\" border=\"0\" alt=\"bearbeiten\"></a>";
  134.  
  135.         return $tag;
  136.     }
  137.  
  138.     /**
  139.       * @param int $mode 
  140.       * @param mixed $aValue 
  141.       * @param string $arrName 
  142.       *
  143.       * @version pk-05-09-05
  144.       *
  145.       ***/
  146.     function writeField($mode,$aValue="",$arrName="DBVAL"{
  147.         switch($mode{
  148.             case FRM_MODE_READONLY:
  149.                 echo $this->getScreenValue($aValue,$arrName);
  150.                 echo $this->getAddTag($arrName);
  151.                 return FALSE;
  152.             case FRM_MODE_HIDDEN:
  153.                  return parent::writeField($mode,$aValue,$arrName);
  154.             case FRM_MODE_NEW:
  155.                  if ($this->enableNew{
  156.                     echo $this->getInputTag($aValue,$arrName);
  157.                     echo $this->getAddTag($arrName);
  158.                     return TRUE;
  159.                  }
  160.                  return FALSE;
  161.             case FRM_MODE_COPY// <pk-05-09-05>
  162.                  if ($this->enableCopy{
  163.                     echo $this->getInputTag($aValue,$arrName);
  164.                     echo $this->getAddTag($arrName);
  165.                     return TRUE;
  166.                  }
  167.                  return FALSE;
  168.             case FRM_MODE_EDIT:
  169.                  if ($this->enableEdit// <pk-05-09-05 /> bugfix
  170.                     echo $this->getInputTag($aValue,$arrName);
  171.                     echo $this->getAddTag($arrName);
  172.                     return TRUE;
  173.                  }
  174.                  return FALSE;
  175.             default:
  176.                  echo $this->getScreenValue($aValue,$arrName);
  177.                  return FALSE;
  178.         }
  179.     }
  180.  
  181.     /**
  182.       * returns the value
  183.       * - no check nl2br
  184.       *
  185.       * @param  string  $aValue     the value
  186.       * @param  string  $arrName    name of the array
  187.       * @param  bool    $debug      show debug info
  188.       *
  189.       * @return string 
  190.       *
  191.       ***/
  192.     function getScreenValue($aValue=NULL,$arrName="DBVAL",$debug=FALSE{
  193.         if ($this->fldDebug$debug=TRUE;
  194.         if ($debugecho "<p><b>DBMS_FIELD_INPUTFORM::getScreenValue($aValue,$arrName,$debug)</b> (".get_class($this).")</p>";}
  195.         if ((!empty($aValue)) && ($valArr=unserialize(base64_decode($aValue))) && (is_array($valArr))) {
  196.             $ret="<table border=\"1\">\n";
  197.             $ret.="\t<tr><th align=\"center\">Field</th><th align=\"center\">Label</th><th align=\"center\">Input-Type</th><th align=\"center\">ShowClass</th></tr>\n";
  198.             foreach($valArr as $key => $fld{
  199.                 $ret.="\t<tr>";
  200.                 $ret.="<td>".$fld->myName."</td>";
  201.                 $ret.="<td>".$fld->label."</td>";
  202.                 $ret.="<td>".$fld->dbDesc['TYPE']."</td>";
  203.                 $ret.="<td>".str_replace("DBMS_FIELD_","",strtoupper(get_class($fld)))."</td>";
  204.                 $ret.="</tr>\n";
  205.             }
  206.             $ret.="</table>";
  207.             return $ret;
  208.         }
  209.         return $aValue;
  210.     }
  211.  
  212.  
  213.     /**
  214.       * returns the value with slashes create use in a db statement
  215.       * do some textreplaces before - because the editors always adds the
  216.       * url - to avoid jumping into a test system
  217.       *
  218.       * calls parent::slashedValue()
  219.       *
  220.       * @param  string  $aValue     the value
  221.       * @param  array   $err        error array
  222.       * @param  string  $arrName    DBVAL
  223.       *
  224.       * @return string 
  225.       *
  226.       * @version pk-03-11-27    DB-Object used instead of DB_.. function
  227.       *
  228.       ***/
  229.     function getValue($aValue,&$err,$arrName="DBVAL",$debug=FALSE{
  230.         if ($debugecho "<hr><p><b>DBMS_FIELD_INPUTFORM::getValue($aValue,$err,$arrName,$debug)</b> (".get_class($this)." | ".$this->myName.")</p>";
  231.         return parent::getValue($aValue,$err,$arrName,$debug);
  232.     }
  233.  
  234.     /**
  235.       * returns the value with slashes create use in a db statement
  236.       * do some textreplaces before - because the editors always adds the
  237.       * url - to avoid jumping into a test system
  238.       *
  239.       * calls parent::slashedValue()
  240.       *
  241.       * @param  string  $aValue     the value
  242.       * @param  array   $err        error array
  243.       * @param  string  $arrName    DBVAL
  244.       *
  245.       * @return string 
  246.       *
  247.       * @version pk-03-11-27    DB-Object used instead of DB_.. function
  248.       *
  249.       ***/
  250.     function slashedValue($aValue,&$err,$arrName="DBVAL",$debug=FALSE{
  251.         if ($debugecho "<hr><p><b>DBMS_FIELD_INPUTFORM::slashedValue($aValue,$err,$arrName,$debug)</b> (".get_class($this)."|".$this->myName.")</p>";
  252.         return $GLOBALS[$this->getGlobalDBObjIdx()]->qs_getSlashedValue($this->getValue($aValue,$err,$arrName,$debug));
  253.     }
  254.  
  255.  
  256. // end class DBMS_FIELD_INPUTFORM
  257. ?>

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