Source for file DBMS_FIELD_DBLOOKUPMULTISELECTLIST.phpclass

Documentation is available at DBMS_FIELD_DBLOOKUPMULTISELECTLIST.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_DBLOOKUPMULTISELECTLIST.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   any
  8.   *
  9.   * @author     Peter Krebs <p.krebs@lvus.at>
  10.   * @copyright  &copy; 2002-2005 by Peter Krebs and Landesverlag Unternehmensservice
  11.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  12.   *
  13.   ***/
  14.  
  15. if (!class_exists("DBMS_FIELD_DBLOOKUPSELECTLIST")) {
  16.     require_once dirname(__FILE___OCSP_DIRSEP_ "DBMS_FIELD_DBLOOKUPSELECTLIST.phpclass";
  17. }
  18.  
  19. /**
  20.   * Class DBMS_FIELD_DBLOOKUPMULTISELECTLIST
  21.   *
  22.   * handels multi select lists form a database
  23.   * where the input is done
  24.   *
  25.   *
  26.   *
  27.   * @project    Open CSP-Management
  28.   * @package    dbms_field
  29.   * @category   any
  30.   *
  31.   * @author     Peter Krebs <p.krebs@wpus.at>
  32.   * @copyright  &copy; 2002-2005 by Peter Krebs and Landesverlag Unternehmensservice
  33.   * @copyright  &copy; 2005-2006 by Peter Krebs and WURM & Partner Unternehmensservice
  34.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  35.   *
  36.   * @since pk-06-02-10
  37.   * @version pk-06-03-07 (bugfix,debug)
  38.   *
  39.   ***/
  40.  
  41.  
  42.     // ###########################################################
  43.     // OBJECT (CONST) VAR DECLARATION
  44.     // ###########################################################
  45.  
  46.     /**
  47.       * overwrite variables:
  48.       **/
  49.  
  50.      protected $className         ="DB MultiSelectList";
  51.      
  52.      protected $classSrcFile      =__FILE__;
  53.      
  54.      protected $mySeperator       =",";
  55.  
  56.     // ###########################################################
  57.     // OBJECT SETTINGS METHODS
  58.     // ###########################################################
  59.  
  60.     /**
  61.       * returns an array of field to bie shown in the edit form
  62.       * by using editTbl_echoForm
  63.       *
  64.       * the array is in the form:
  65.       *
  66.       * <code>
  67.       * [_sectionName_]
  68.       *      [TITLE] -> string
  69.       *      [_rowName_]
  70.       *         [FLDLAB]  (complete html code with <td></td>)
  71.       *         [FLDVAL] (complete html code with <td></td>)
  72.       * </code>
  73.       *
  74.       * @param boolean $debug 
  75.       *
  76.       * @returns array
  77.       *
  78.       * @since pk-06-04-26
  79.       *
  80.       *  /
  81.     function editTbl_getFieldEditArr($debug=FALSE) {
  82.         if ($debug) echoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DBSELECTLIST::editTbl_getFieldEditArr","",0);
  83.         $a_ret=parent::editTbl_getFieldEditArr($debug);
  84.  
  85.  
  86.         $a_ret['SELECT']['FLD_VALSEPERATOR']=array(
  87.             'FLDLAB'=>"Wert Trennzeichen:",
  88.             'FLDVAL'=>"<input name=\"mySeperator\" type=\"text\" value=\"".$this->mySeperator."\" size=\"2\" maxLength=\"1\">"
  89.         );
  90.  
  91.         return $a_ret;
  92.     }
  93.  
  94.     /**
  95.       *  save the filed definition form
  96.       *
  97.       * @returns boolean
  98.       *
  99.       ***/
  100.     function save({
  101.         $ret=parent::save();
  102.         if (isset($_POST['mySeperator']&& !empty($_POST['mySeperator']))
  103.         {
  104.             $this->mySeperator=$_POST['mySeperator'];
  105.         else {
  106.             $this->mySeperator=",";
  107.         }
  108.         return $ret;
  109.     }
  110.  
  111.     // ###########################################################
  112.     // OBJECT DATA METHODS
  113.     // ###########################################################
  114.  
  115.  
  116.     // ###########################################################
  117.     // OBJECT HTML FORM METHODS
  118.     // ###########################################################
  119.  
  120.  
  121.  
  122.     /**
  123.       * returns the html option list of all elements in $aValArr
  124.       *
  125.       * @param array $aValArr 
  126.       * @param boolean $debug 
  127.       *
  128.       * @returns string
  129.       *
  130.       ***/
  131.     protected function getOptionListIn($aValArr,$debug=FALSE{
  132.         $debug=($debug $this->fldDebug);
  133.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DBLOOKUPMULTISELECTLIST::getOptionListIn()","",0);
  134.  
  135.         $s_ret="";
  136.         $b_IsEmpty=TRUE;
  137.         if (is_array($aValArr)) {
  138.             foreach($aValArr as $m_key{
  139.                 if (!empty($m_key)) {
  140.                     $s_ret.="\t<option value=\"".$m_key."\">".htmlspecialchars($this->getDBValue($m_key,$debug))."</option>\n";
  141.                     $b_IsEmpty=FALSE;
  142.                 }
  143.             }
  144.         }
  145.         if ($b_IsEmpty{
  146.             $s_ret.="\t<option value\"\" disabled>--- keine Werte ---</option>\n";
  147.         }
  148.         return $s_ret;
  149.     }
  150.  
  151.     /**
  152.       * returns the html option list of all elements in $aValArr
  153.       *
  154.       * @param array $aValArr 
  155.       * @param boolean $debug 
  156.       *
  157.       * @returns string
  158.       *
  159.       * @version pk-06-03-07 (bugfix)
  160.       *
  161.       ***/
  162.     protected function getOptionListOut($aValArr,$debug=FALSE{
  163.         $debug=($debug $this->fldDebug);
  164.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DBLOOKUPMULTISELECTLIST::getOptionListIn()","",0);
  165.  
  166.         $this->setMyValues($this->myDataArrName,$debug)// <pk-06-03-07 />
  167.  
  168.         $s_ret="";
  169.         $b_IsEmpty=TRUE;
  170.         $a_allValues=$this->myValues;
  171.         if (is_array($a_allValues)) {
  172.             if (is_array($aValArr)) {
  173.                 foreach($aValArr as $m_key{
  174.                     // remove selected form list
  175.                     unset($a_allValues[$m_key]);
  176.                 }
  177.             }
  178.             foreach($a_allValues as $m_key => $s_label{
  179.                 if (!empty($m_key)) {
  180.                     $s_ret.="\t<option value=\"".$m_key."\">".htmlspecialchars($s_label)."</option>\n";
  181.                     $b_IsEmpty=FALSE;
  182.                 }
  183.             }
  184.         }
  185.         if ($b_IsEmpty{
  186.             $s_ret.="\t<option value\"\" disabled>--- keine Werte ---</option>\n";
  187.         }
  188.         return $s_ret;
  189.     }
  190.  
  191.  
  192.     /**
  193.       * returns the html code for the select
  194.       *
  195.       * @param string $aValue 
  196.       * @param array $arrName 
  197.       * @param boolean $debug 
  198.       *
  199.       * @returns string
  200.       *
  201.       * @version pk-05-12-01
  202.       * @version pk-06-02-06 popUp_frmId
  203.       * @version pk-08-05-19
  204.       */
  205.     function getInputTag($aValue,$arrName="DBVAL",$debug=FALSE{
  206.  
  207.         if (!empty($arrName)) $this->myDataArrName=$arrName;
  208.         global ${$this->myDataArrName};
  209.  
  210.         if ($debugechoDebugMethod(__FILE__,get_class($this)."DBMS_FIELD_DBLOOKUPMULTISELECTLIST::getInputTag()","",0);
  211.  
  212.         $this->setMyValues($arrName,$debug);
  213.  
  214.         if (is_array($aValue)) {
  215.             $s_valStr=implode($this->mySeperator,$aValue);
  216.             $a_valArr=$aValue;
  217.         else {
  218.             $s_valStr=$aValue;
  219.             $a_valArr=explode($this->mySeperator,$aValue);
  220.         }
  221.         if (!is_array($a_valArr)) {
  222.             // set empty array to avoid errors
  223.             $a_valArr=array();
  224.         }
  225.  
  226.         if ($this->selectsize < 6$this->selectsize=6;
  227.         
  228.         $str_ret ="
  229.             <input type=\"hidden\" id=\"" $this->getDOMId(."\" name=\"".$arrName."[".$this->myName."]\" value=\"$s_valStr\">
  230.             <table align=\"center\" border=\"0\" class=\"frmSelInOut\">
  231.                 <tr>
  232.                     <td width=\"45%\" align=\"center\">gew&auml;hlt</td>
  233.                     <td width=\"10%\">
  234.                     <td width=\"45%\" align=\"center\">verf&uuml;gbar</td>
  235.                 </tr>
  236.                 <tr>
  237.                     <td width=\"45%\" align=\"center\">
  238.                         <select 
  239.                             id=\"$this->getDOMId(."_inList\" 
  240.                             name=\"".$arrName."[".$this->myName."_inList]\" 
  241.                             size=\"".intval($this->selectsize)."\" 
  242.                             ondblclick=\"document.getElementById('" $this->getDOMId("').jOCSPFldObj.removeValue(this.value);\" 
  243.                             multiple>
  244.                             " $this->getOptionListIn($a_valArr,$debug"
  245.                         </select>
  246.                     </td>
  247.                     <td valign=\"middle\" width=\"10%\" align=\"center\">
  248.                         <img 
  249.                             src=\"" OCSP_OBJ::getConf('SYSIMGURL'"icons-16x16/2leftarrow.gif\"
  250.                             border=\"0\" alt=\"alle Eif&uuml;gen\" align=\"middle\" class=\"button\"
  251.                             onclick=\"
  252.                                 document.getElementById('" $this->getDOMId("').jOCSPFldObj.addAll();
  253.                             \"
  254.                         /><br />
  255.                         <img 
  256.                             src=\"" OCSP_OBJ::getConf('SYSIMGURL'"icons-16x16/1leftarrow.gif\"
  257.                             border=\"0\" alt=\"gew&auml;hlte Eif&uuml;gen\" align=\"middle\" class=\"button\"
  258.                             onclick=\"
  259.                                 document.getElementById('" $this->getDOMId("').jOCSPFldObj.addSelected();
  260.                             \"
  261.                         /><br />
  262.                         <img 
  263.                             src=\"" OCSP_OBJ::getConf('SYSIMGURL'"icons-16x16/1rightarrow.gif\"
  264.                             border=\"0\" alt=\"gew&auml;hlte Entfernen\" align=\"middle\" class=\"button\"
  265.                             onclick=\"
  266.                                 document.getElementById('" $this->getDOMId("').jOCSPFldObj.removeSelected();
  267.                             \"
  268.                         /><br />
  269.                         <img 
  270.                             src=\"" OCSP_OBJ::getConf('SYSIMGURL'"icons-16x16/2rightarrow.gif\"
  271.                             border=\"0\" alt=\"alle Entfernen\" align=\"middle\" class=\"button\"
  272.                             onclick=\"
  273.                                 document.getElementById('" $this->getDOMId("').jOCSPFldObj.removeAll();
  274.                             \"
  275.                         />
  276.                     </td>
  277.                     <td width=\"45%\" align=\"center\">
  278.                         <select id=\"" $this->getDOMId(."_outList\" 
  279.                              name=\"".$arrName."[".$this->myName."_outList]\" 
  280.                              size=\"".intval($this->selectsize)."\" 
  281.                             ondblclick=\"document.getElementById('" $this->getDOMId("').jOCSPFldObj.addValue(this.value);\" 
  282.                             multiple>
  283.                             " $this->getOptionListOut($a_valArr,$debug."
  284.                         </select>
  285.                     </td>
  286.                 </tr>
  287.             </table>
  288.         ";
  289.  
  290.  
  291.         /**
  292.           * @todo populink
  293.           *
  294.         if (($this->allowAddValues) && (intval($this->popUp_frmId))) { // <pk-06-02-06>
  295.             $ret.="<!--\n\t\t _______ ADD VALUES BUTTON _______ \n";
  296.             $ret.="\t\t--> <a name=\"".$this->getMyFormName()."_".$this->myName."\" href=\"javascript:{";
  297.             $ret.=$this->getPopupLinkJs(FRM_MODE_NEW,$this->myName."_inList","nOpt_".$arrName."_".$this->myName,$debug);
  298.             $ret.="}\n";
  299.             $ret.="\t\t \"><img src=\"".$GLOBALS['PROJECT']['SYSIMGURL']."icons-16x16/filenew.gif\" border=\"0\" alt=\"neuer Eintrag\" align=\"middle\" class=\"button\">";
  300.             $ret.="</a><!--\n";
  301.             $ret.="\t\t _______ ADD VALUES BUTTON _______ \n-->";
  302.         }
  303.           *
  304.           **/
  305.  
  306.  
  307.         return $str_ret;
  308.     }
  309.  
  310.     // ###########################################################
  311.     // SEARCH FORM METHODS
  312.     // ###########################################################
  313.  
  314.     // ###########################################################
  315.     // OBJECT HTML FORM METHODS
  316.     // ###########################################################
  317.  
  318.     // ###########################################################
  319.     // OBJECT VALUE CHECK/RETURN METHODS
  320.     // ###########################################################
  321.  
  322.     /**
  323.       * returns the field value checks for empty values
  324.       *
  325.       * @param  string $aValue the value
  326.       * @param  array $err error array
  327.       * @param  string $arrName name of the array to access fieldsarray  gloabl ${$arrName}
  328.       * @param  boolean $debug 
  329.       *
  330.       * @returns string
  331.       *
  332.       * @since   pk-06-03-07
  333.       *
  334.       ***/
  335.     function getValue($aValue,&$err,$arrName="DBVAL",$debug=FALSE{
  336.         $debug=($debug || $this->fldDebug);
  337.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_DBLOOKUPMULTISELECTLIST::getValue()|".$this->myName,print_r($aValue,TRUE),0);
  338.         if ((!is_array($aValue)) && (strstr($aValue,$this->mySeperator))) {
  339.             // remove empty values
  340.             $a_valArr=explode($this->mySeperator,$aValue);
  341.             $s_sep="";
  342.             if (is_array($a_valArr)) {
  343.                 $aValue="";
  344.                 foreach($a_valArr as $s_val{
  345.                     $s_val=trim($s_val);
  346.                     if ((!empty($s_val|| ($s_val==="0"))) // "0" is empty -> check with ===
  347.                         $aValue.=$s_sep.$s_val;
  348.                         $s_sep=$this->mySeperator;
  349.                     }
  350.                 }
  351.             }
  352.         }
  353.         return parent::getValue($aValue,$err,$arrName,$debug);
  354.  
  355.     }
  356.     
  357.     // --------------------------------------------------------
  358.     // jOCSP
  359.     // --------------------------------------------------------
  360.  
  361.     /**
  362.      * returns an array of jOCSP/jQuery Modules which are required
  363.      * 
  364.      * $arr_ret[]="script url";
  365.      *
  366.      * @param boolean $debug 
  367.      * 
  368.      * @global array $OCSP_CONF 
  369.      * 
  370.      * @return string 
  371.      */
  372.     public function jOCSP_getRequiredModules($debug=FALSE)
  373.     {        
  374.         if ($debugechoDebugMethod(__FILE__,get_classe($this),"DBMS_FIELD::jOCSP_getRequiredModules()");
  375.         
  376.         $arr_ret parent::jOCSP_getRequiredModules($debug);
  377.         
  378.         $arr_ret[array(
  379.             'CLASS' => 'jOCSP.FLDOBJ_DBMultiSelectList',
  380.             'SRC'     => OCSP_OBJ::getConf('SYSTEMURL')."jOCSP/formFields/jOCSP_FLDOBJ_DBMultiSelectList.js"
  381.         );
  382.                
  383.         return $arr_ret;
  384.     }
  385.  
  386.    /**
  387.      * returns additional object elements of the field object
  388.      * 
  389.      * array definition: [elemName] = value
  390.      * 
  391.      * NOTE: do not js_escapte value this is done when building the json object
  392.      *
  393.      * @param boolean $debug 
  394.      * 
  395.      * @return array 
  396.      * 
  397.      * @since pk-08-02-06
  398.      */
  399.     protected function jOCSP_getAdditonalFieldObjElems($debug=False)
  400.     {  
  401.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_FILESELECT::jOCSP_getAdditonalFieldObjElems()");
  402.         $arr_ret parent::jOCSP_getAdditonalFieldObjElems($debug);        
  403.         $arr_ret['fldClass'"'FLDOBJ_DBMultiSelectList'";    
  404.         $arr_ret['valSep']"'" $this->mySeperator . "'";
  405.         //$arr_ret['debug'] = True;
  406.         return $arr_ret;          
  407.     }    
  408.  
  409. // end class DBMS_FIELD_DBLOOKUPMULTISELECTLIST
  410. ?>

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