Source for file DBMS_FIELD_SELINOUT.phpclass

Documentation is available at DBMS_FIELD_SELINOUT.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_SELINOUT.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   mixed
  8.   *
  9.   * @author     Peter Krebs <p.krebs@wpus.at>
  10.   * @copyright  (c) 2002-2004 by Peter Krebs and Landesverlag Unternehmensservice
  11.   * @copyright  (c) 2004 by WURM & Partner Unternehmensservice GmbH
  12.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  13.   *
  14.   * @version pk-05-10-25
  15.   *
  16.   ***/
  17.  
  18. require_once dirname(__FILE__)."/DBMS_FIELD_SELECTLIST.phpclass"// <pk-05-10-25 />
  19.  
  20. /**
  21.   * Class DBMS_FIELD_SELINOUT
  22.   *
  23.   * handels to &lt;SELECT&gt; elements
  24.   * one with the selected list and the other with the not selected elements
  25.   *
  26.   * @project    Open CSP-Management
  27.   * @package    dbms_field
  28.   * @category   mixed
  29.   *
  30.   * @author     Peter Krebs <p.krebs@wpus.at>
  31.   * @copyright  (c) 2002-2004 by Peter Krebs and Landesverlag Unternehmensservice
  32.   * @copyright  (c) 2004 by WURM & Partner Unternehmensservice GmbH
  33.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  34.   *
  35.   * @since pk-04-09-30
  36.   * @version pk-05-10-25
  37.   *
  38.   ***/
  39.  
  40.     // ###########################################################
  41.     // OBJECT (CONST) VAR DECLARATION
  42.     // ###########################################################
  43.  
  44.     /**
  45.       * var boolean $asJSCode
  46.       **/
  47.  
  48.     var $asJSCode = TRUE;
  49.  
  50.     /**
  51.       * source file of the class
  52.       *
  53.       * @var string $classSrcFile 
  54.       ***/
  55.     var $classSrcFile=__FILE__;
  56.     
  57.  
  58.     // ###########################################################
  59.     // OBJECT SETTINGS METHODS
  60.     // ###########################################################
  61.  
  62.     /**
  63.       * returns an array of field to bie shown in the edit form
  64.       * by using editTbl_echoForm
  65.       *
  66.       * the array is in the form:
  67.       *
  68.       * <code>
  69.       * [_sectionName_]
  70.       *      [TITLE] -> string
  71.       *      [_rowName_]
  72.       *         [FLDLAB]  (complete html code with <td></td>)
  73.       *         [FLDVAL] (complete html code with <td></td>)
  74.       * </code>
  75.       *
  76.       * @param boolean $debug 
  77.       *
  78.       * @returns array
  79.       *
  80.       * @since pk-06-04-26
  81.       *
  82.       ***/
  83.     function editTbl_getFieldEditArr($debug=FALSE{
  84.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DBSELECTLIST::editTbl_getFieldEditArr","",0);
  85.         $a_ret=parent::editTbl_getFieldEditArr($debug);
  86.  
  87.         unset($a_ret['COMMON']['FLD_SHOWNULLOPT']);
  88.  
  89.         $a_ret['SELECT']['FLD_asJSCode'=array(
  90.             'FLDLAB'=>"JavaScript",
  91.             'FLDVAL'=>"<input name=\"asJSCode\" type=\"checkbox\" value=\"1\">".($this->asJSCode ? "checked" "")." Ausgabe als Javascript und normales select im &lt;NOSCRIPT&gt; Bereich "
  92.         );
  93.  
  94.         return $a_ret;
  95.     }
  96.  
  97.     /**
  98.       * echos the filed definition form
  99.       *
  100.       * @param boolean $showSize 
  101.       * @param boolean $showDBFields 
  102.       *
  103.       * @version pk-04-10-11
  104.       * @version pk-05-12-05 $showDBFields added
  105.       * @version pk-05-12-08 allowAddValues outside if($showDBFields)
  106.       * @version pk-06-02-06 popUp_frmId
  107.       *
  108.       * @deprecated since pk-06-04-26
  109.       *
  110.       ***/
  111.      function editTblForm($debug=FALSE{
  112.         $a_FieldEditArr=$this->editTbl_getFieldEditArr($debug);
  113.  
  114.         $this->editTbl_echoForm($a_FieldEditArr,$debug);
  115.     }
  116.  
  117.     function save({
  118.         $ret=parent::save();
  119.  
  120.         $this->showNullOption   = FALSE;
  121.         $this->asJSCode         = (intval($_POST['asJSCode']TRUE FALSE);
  122.         if (intval($_POST['SELECTSIZE'])>1{
  123.             $this->selectsize = intval($_POST['SELECTSIZE']);
  124.         else {
  125.             $this->selectsize=2;
  126.         }
  127.         return $ret;
  128.     }
  129.  
  130.  
  131.     // ###########################################################
  132.     // OBJECT DATA METHODS
  133.     // ###########################################################
  134.  
  135.  
  136.     // ###########################################################
  137.     // OBJECT HTML FORM METHODS
  138.     // ###########################################################
  139.  
  140.  
  141.     /**
  142.       * returns the javascript code to relaod the form
  143.       *
  144.       * @param string $arrName 
  145.       *
  146.       * @returns string
  147.       *
  148.       * @since pk-04-08-18
  149.       *
  150.       ***/
  151.     function getReloadJSCode($arrName="DBVAL"{
  152.         $tag .= " document.forms[".$this->getJSDocFormId()."].action='".$this->getReloadURL()."#".$this->myName."';";
  153.         $tag .= " document.forms[".$this->getJSDocFormId()."].submit();";
  154.         return $tag;
  155.     }
  156.  
  157.  
  158.     /**
  159.       * returns the html select tag onChange statement to reload the form
  160.       *
  161.       * @param array $arrName 
  162.       *
  163.       * @since pk-04-08-18
  164.       *
  165.       ***/
  166.     function getOnChangeRelaod($arrName="DBVAL"{
  167.         global $frmDocumentFormId;
  168.         $tag .= " onChange=\"".$this->getReloadJSCode($arrName)."\"";
  169.         return $tag;
  170.     }
  171.  
  172.     /**
  173.       * returns the html code for a button to reload the form
  174.       *
  175.       * @param array $arrName 
  176.       *
  177.       * @since pk-04-08-18
  178.       *
  179.       ***/
  180.     function getReloadButton($arrName="DBVAL"{
  181.         global $frmDocumentFormId;
  182.  
  183.         $ret ="<span class=\"button\">";
  184.         $ret.="<a href=\"javascript:{".$this->getReloadJSCode($arrName)."}\">";
  185.         $ret.="<img src=\"".$GLOBALS['PROJECT']['SYSIMGURL']."icons-22x22/reload.png\" border=\"0\" alt=\"refresh form\"  width=\"18\" height=\"18\">";
  186.         $ret.="</a></span>";
  187.  
  188.         return $ret;
  189.     }
  190.  
  191.     /**
  192.       * returns a string with the selected option values ($aValArr)
  193.       *
  194.       * calls setMyValues to be sure $this->myValues is set correkt
  195.       *
  196.       * @param array $aValArr           array of selected values
  197.       * @param boolean $showNotInVal    show values not in $this->myValues;
  198.       * @param boolean $asJavaCode      the output is in a javascript
  199.       * @param boolean $debug 
  200.       *
  201.       * @return string 
  202.       *
  203.       ***/
  204.     function getOptionListIn($aValArr,$showNotInVal=TRUE,$asJavaCode=TRUE,$debug=FALSE{
  205.         $debug=($debug || $this->fldDebug)// <pk-04-08-31>
  206.         if ($debug{
  207.             echo "<p><b>DBMS_FIELD_SELINOUT::getOptionListIn(\$aValArr,$showNotInVal,$asJavaCode,...)</b> (".get_class($this).")</p>";
  208.             echo "<blockquote><p>\$aValArr</p><pre>".print_r($aValArr,TRUE)."</pre></blockquote>";
  209.         }
  210.  
  211.         $ret="\n";
  212.  
  213.         if (!is_array($aValArr)) {
  214.             return $ret;
  215.         }
  216.         $this->setMyValues($arrName,$debug);
  217.         foreach($aValArr as $key{
  218.             $show=TRUE;
  219.             if (!isset($this->myValues[$key])) {
  220.                 if ($showNotInVal$val=$key;
  221.                 else $show=FALSE;
  222.             else {
  223.                 $val=$this->myValues[$key];
  224.             }
  225.             if ($asJavaCode{
  226.                 $val=str_replace("'","\\'",$val);
  227.                 $ret.="\tdocument.writeln('";
  228.             }
  229.             $ret.="<option value=\"$key\">$val</option>";
  230.             if ($asJavaCode$ret.="');";
  231.             $ret.="\n";
  232.         }
  233.         return $ret;
  234.     }
  235.  
  236.     /**
  237.       * returns a string with the not selected option values (!in $aValArr)
  238.       *
  239.       * calls setMyValues to be sure $this->myValues is set correkt
  240.       *
  241.       * @param array $aValArr           array of selected values
  242.       * @param boolean $showNotInVal    show values not in $this->myValues;
  243.       * @param boolean $asJavaCode      the output is in a javascript
  244.       * @param boolean $debug 
  245.       *
  246.       * @return string 
  247.       *
  248.       ***/
  249.     function getOptionListOut($aValArr,$asJavaCode=TRUE,$debug=FALSE{
  250.         $debug=($debug || $this->fldDebug)// <pk-04-08-31>
  251.         if ($debug{
  252.             echo "<p><b>DBMS_FIELD_SELINOUT::getOptionListOut(\$aValArr,$asJavaCode,...)</b> (".get_class($this).")</p>";
  253.             echo "<blockquote><p>\$aValArr</p><pre>".print_r($aValArr,TRUE)."</pre></blockquote>";
  254.         }
  255.  
  256.         $ret="\n";
  257.  
  258.         $this->setMyValues($arrName,$debug);
  259.         $values=$this->myValues;
  260.         if (is_array($aValArr)) {
  261.             foreach($aValArr as $key{
  262.                 unset($values[$key]);
  263.             }
  264.         }
  265.  
  266.         foreach($values as $key => $val{
  267.             if ($asJavaCode{
  268.                 $val=str_replace("'","\\'",$val);
  269.                 $ret.="\tdocument.writeln('";
  270.             }
  271.             $ret.="<option value=\"$key\">$val</option>";
  272.             if ($asJavaCode$ret.="');";
  273.             $ret.="\n";
  274.         }
  275.         return $ret;
  276.     }
  277.  
  278.     /**
  279.       * returns the html code for the select
  280.       *
  281.       * @param string $aValue 
  282.       * @param array $arrName 
  283.       * @param boolean $debug 
  284.       *
  285.       * @returns string
  286.       *
  287.       * @version pk-04-08-31 $debug added
  288.       *
  289.       ***/
  290.     function getInputTag($aValue,$arrName="DBVAL",$debug=FALSE{
  291.         $debug=($debug || $this->fldDebug);
  292.         if ($debugecho "<p><b>DBMS_FIELD_SELINOUT::getInputTag($aValue,$arrName,...)</b> (".get_class($this).")</p>";
  293.  
  294.         // prepare the value array
  295.         $aValue=str_replace("\r","",$aValue);
  296.         if (!($valArr=explode("\n",$aValue))) {
  297.             $valArr=array();
  298.             $valArr[]=$aValue;
  299.         }
  300.  
  301.  
  302.         $tag ="<input type=\"hidden\" name=\"".$arrName."[".$this->myName."]\" value=\"$aValue\">";
  303.         $tag.="<table align=\"center\" border=\"0\" class=\"frmSelInOut\">";
  304.         $tag.="<tr><td width=\"45%\">";
  305.         $tag.="<select name=\"".$arrName."[".$this->myName."_inList]\" size=\"".intval($this->selectsize)."\">\n";
  306.         $tag.=$this->getOptionListIn($aValArr,TRUE,FALSE,$debug);;
  307.         $tag.="</select></td>\n";
  308.  
  309.         //
  310.         // middle (buttons) ---------------------------------------------
  311.         //
  312.         $tag.="<td width=\"10%\" align=\"center\" class=\"frmSelInOutBtn\" valign=\"middle\">";
  313.  
  314.         // todo
  315.         $btype="submit";
  316.  
  317.  
  318.         if ($btype=="submit"{
  319.             $tag.="<input type=\"submit\" name=\"".$arrName."[".$this->myName."_btnadd]\" value=\"&lt;--\">";
  320.             $tag.="<input type=\"submit\" name=\"".$arrName."[".$this->myName."_btndel]\" value=\"--&gt;\">";
  321.         }
  322.  
  323.         //
  324.         // right-side (out list) ----------------------------------------
  325.         //
  326.         $tag.="<td width=\"45%\" align=\"center\">";
  327.         $tag.="<select name=\"".$arrName."[".$this->myName."_outList]\" size=\"".intval($this->selectsize)."\">\n";
  328.         $tag.=$this->getOptionListOut($aValArr,FALSE,$debug);
  329.         $tag.="</select></td>";
  330.         $tag.="</tr></table>";
  331.  
  332.         // echo "<pre>".htmlspecialchars($tag)."</pre>";
  333.  
  334.         return $tag;
  335.     }
  336.  
  337.  
  338.  
  339.     // ################################################
  340.     // SEARCH FORM METHODS
  341.     // ################################################
  342.  
  343.  
  344.  
  345.     // ###########################################################
  346.     // OBJECT VALUE CHECK/RETURN METHODS
  347.     // ###########################################################
  348.  
  349.  
  350. // end class DBMS_FIELD_SELINOUT
  351. ?>

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