Source for file DBMS_FIELD_TREESELECT.phpclass
Documentation is available at DBMS_FIELD_TREESELECT.phpclass
-   * Class file DBMS_FIELD_TREESELECT.phpclass 
-   * @project    Open CSP-Management 
-   * @author     Peter Krebs <pitlinz@users.sourceforge.net> 
-   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License 
-   * @version $Id: DBMS_FIELD_TREESELECT.phpclass,v 1.9 2008/09/26 15:00:21 pitlinz Exp $ 
-   * Class DBMS_FIELD_TREESELECT 
-   * @project    Open CSP-Management 
-   * @author     Peter Krebs <pitlinz@users.sourceforge.net> 
-   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License 
-   * @version $Id: DBMS_FIELD_TREESELECT.phpclass,v 1.9 2008/09/26 15:00:21 pitlinz Exp $ 
-   * @todo avoid enless loop if input data are wrog 
-     // --------------------------------------------------------------------------- 
-     // --------------------------------------------------------------------------- 
-      * @constant string CLASS_SRC_FILE 
-     // --------------------------------------------------------------------------- 
-     // --------------------------------------------------------------------------- 
-     /*** class vars ------------------------------------------------------ */ 
-     /*** class methods --------------------------------------------------- */     
-     // --------------------------------------------------------------------------- 
-     // --------------------------------------------------------------------------- 
-     /*** compostion --------------------------------------------------- */ 
-     /*** attributes  -------------------------------------------------- */     
-      * parent column in the table 
-      * @var string $parentField  
-       * @var string $treeROOTShowVal  
-       * @var boolean $rootCheckOff  
-      * @var boolean $disableROOTSelect  
-     /*** layout attributes ----------------------------------- */ 
-      * show full tree (multi selects) 
-      * @var boolean $showFullTree  
-      * show path (parents) in RO mode 
-      * @var boolean $showPathRO  
-      * number of levels to go down from the root 
-       * @var string $intendString  
-     // --------------------------------------------------------------------------- 
-     // --------------------------------------------------------------------------- 
-     // --------------------------------------------------------------------------- 
-     // ---------------------------------------------------------------------------     
-         //echoDebugLine(__FILE__,__LINE__,"Class Key values " . $str_key . "<br />" . md5($str_key)); 
-     // --------------------------------------------------------------------------- 
-     // OBJECT SETTINGS METHODS 
-     // --------------------------------------------------------------------------- 
-       * returns an array of field to bie shown in the edit form 
-       * by using editTbl_echoForm 
-       * the array is in the form: 
-       *         [FLDLAB]  (complete html code with <td></td>) 
-       *         [FLDVAL] (complete html code with <td></td>) 
-         $a_ret['DBLOOKUP']['FLD_LSTADDVALUES']- = Null;
 
-         $a_ret['DBLOOKUP']['TREEROOTKEY']- = array(
 
-             'FLDLAB'- => "TREE ROOT KEY/SHOW Value:",
 
-                         <input name=\"TREEROOTKEY\" value=\""- . $this->treeROOTKey- . "\" size=\"10\" />
 
-                         <input name=\"treeROOTShowVal\" value=\""- . $this->treeROOTShowVal- . "\" size=\"20\" /><br />
 
-                         <input name=\"rootCheckOff\" type=\"checkbox\" "- . ($this->rootCheckOff-  ?  "checked=\"checked\""- :  "")- . " value=\"1\" /> Root nicht in DB
 
-                         <input name=\"disableROOTSelect\" type=\"checkbox\" "- . ($this->disableROOTSelect-  ?  "checked=\"checked\""- :  "")- .  " value=\"1\" />Root <strong>nicht</strong> wählbar
 
-         $a_ret['DBLOOKUP']['PARENTFIELD']- = array(
 
-             'FLDLAB'- => "PARENT Field:",
 
-             'FLDVAL'- => "<input name=\"PARENTFIELD\" value=\""- . $this->parentField- . "\" size=\"40\" />"
 
-         $a_ret['LAYOUT']['showFullTree']- = array(
 
-             'FLDLAB'- => "Vollständiger Baum:",
 
-             'FLDVAL'- => "<input name=\"showFullTree\" type=\"checkbox\" "- . ($this->showFullTree-  ?  "checked=\"checked\""- :  "")- . " value=\"1\" /> ALLE Werte anzeigen"
 
-         $a_ret['LAYOUT']['NOFLEVELS']- = array(
 
-             'FLDLAB'- => "Max Anzahl Ebenen:",
 
-         $a_ret['LAYOUT']['showPathRO']- = array(
 
-             'FLDLAB'- => "Pfad bei ReadOnly:",
 
-                     <select name="showPathRO" size="1"> 
-                         <option value="0" '- . (($this->showPathRO- == 0)- ?  "selected"- :  "")- . ' >nein nur gewählte Werte</option>
 
-                         <option value="1" '- . (($this->showPathRO- == 1)- ?  "selected"- :  "")- . ' >ja in einer Zeile</option>
 
-                         <option value="2" '- . (($this->showPathRO- == 2)- ?  "selected"- :  "")- . ' >ja eine Zeile/Ebene</option>
 
-       * saves the field definition 
-       * @version pk-07-09-26 E_ALL 
-         if (- isset ($this->treeTbl))- unset ($this->treeTbl);
 
-         // save the parent first to be sure to have the table in DBcheckEditInput 
-         $this->treeROOTKey-           = (- isset ($_POST['TREEROOTKEY'])- ?  $_POST['TREEROOTKEY']- :  $this->treeROOTKey);               // pk-05-06-26 templates allowed
 
-         $this->showFullTree-          = ((- isset ($_POST['showFullTree'])- &&  intval($_POST['showFullTree']))- ?  TRUE- :  False );
 
-         $this->rootCheckOff-          = ((- isset ($_POST['rootCheckOff'])- &&  intval($_POST['rootCheckOff']))- ?  TRUE- :  False);
 
-         $this->disableROOTSelect-     = ((- isset ($_POST['disableROOTSelect'])- &&  intval($_POST['disableROOTSelect']))- ?  TRUE- :  False);
 
-     // ----------------------------------------------------------- 
-     // ----------------------------------------------------------- 
-       * returns the database query 
-         $str_query - = "SELECT "- . $this->lookupField-  .  " AS KEYFIELD";
 
-         $str_query- .= ","- . $this->parentField-  .  " AS PARENTFIELD";
 
-         if ($debug) echoDebugLine(- __FILE__ ,- __LINE__ ,"getMyValueQuery: <br/>"- . $str_query);
 
-       * sets populates $this->myValues array from the database 
-       * @return int size of $this->myValues 
-             !- isset (self::$classValPopulateTs[$str_cacheId] )- ||  
 
-             self::$classValPopulateTs[$str_cacheId] - <  (time()- -  ini_get('max_execution_time'))
 
-             // load the values from the db 
-             if ($debug) echoDebugLine(- __FILE__ ,- __LINE__ ,"query: "- .  $str_query);
 
-                 while($arr_row - =  $obj_cursor->fetchArrayFld())
 
-                     self::$classCache[$str_cacheId]['ROWS'][$arr_row['KEYFIELD']] - =  $arr_row;
 
-                     $mix_parentKey - =  (empty($arr_row['PARENTFIELD'])- ?  0- :  $arr_row['PARENTFIELD']);
 
-                     self::$classCache[$str_cacheId]['CHILDREN'][$mix_parentKey][] - =  $arr_row['KEYFIELD'];
 
-                 self::$classValPopulateTs- = time();
 
-         if (- isset (self::$classCache[$str_cacheId]['ROWS'][$this->treeROOTKey]))
 
-         if (is_array(self::$classCache[$str_cacheId]['CHILDREN'][$this->treeROOTKey])) 
-             foreach(self::$classCache[$str_cacheId]['CHILDREN'][$this->treeROOTKey] as $mix_childKey) 
-                 if (!- isset ($this->myValues[$mix_childKey])) // to avoid miss configured tree errors
 
-                     if (- isset (self::$classCache[$str_cacheId]['ROWS'][$mix_childKey]))
 
-                         $this->myValues[$mix_childKey] - =  $this->intendString-  .  self::$classCache[$str_cacheId]['ROWS'][$mix_childKey]['SHOWFIELD'];
 
-      * adds children of $key to $this->myValues 
-     protected function setMyChildValues($cacheId,$key,$intend,$level- = 0,$debug- = False)
 
-         if ($debug) echoDebugMethod(- __FILE__ ,get_class($this),"DBMS_FIELD_TREESELECT::setMyChildValues({$cacheId},{$key}, ,{$level})");
 
-             if (- isset (self::$classCache[$cacheId]['CHILDREN'][$key])- &&  is_array(self::$classCache[$cacheId]['CHILDREN'][$key]))
 
-                 foreach(self::$classCache[$cacheId]['CHILDREN'][$key] as $mix_childKey) 
-                     if (!- isset ($this->myValues[$mix_childKey]))
 
-                         if (- isset (self::$classCache[$cacheId]['ROWS'][$mix_childKey]))
 
-                             $this->myValues[$mix_childKey] - =  $intend- .  $this->intendString-  .  self::$classCache[$cacheId]['ROWS'][$mix_childKey]['SHOWFIELD'];
 
-                             echoDebugLine(- __FILE__ ,- __LINE__ ,$mix_childKey- .  " has no row set");
 
-             if ($debug) echoDebugLine(- __FILE__ ,- __LINE__ ,"Max levels reached");
 
-       * returns the html-code for a level select 
-       * @param int $countSelects  
-     function getLevelSelect($childArr,$countSelects,$level,$aValue,$arrName- = "DBVAL",$debug- = False) {
 
-         if ($debug) - echo  "<p><b>DBMS_FIELD_TREESELECT::getLevelSelect(\$childArr ("- . sizeof($childArr)- . "),$countSelects,$level,$aValue,$arrName,..</b> ("- . get_class($this)- . ")</p>";
 
-         $selName- = $arrName- . "_"- . $this->myName- . "_"- . $level;
 
-         $ret - = "\n\t<select name=\""- . $selName- . "\" onChange=\"\n";
 
-         $ret- .= "\n\t         setElemValByName($df,'"- . $arrName- . "["- . $this->myName- . "]',$df.$selName.options[$df.$selName.selectedIndex].value);";
 
-         $ret- .= "\n\t         $df.action='"- . $_SERVER['REQUEST_URI']- . "#"- . $this->myName- . "';";
 
-         $ret- .= "\n\t         $df.submit();";
 
-         $ret- .= "\n\t     \" size=\"1\">\n";
 
-             if ($this->allowNullSelect) { 
-             $ret- .= "\t\t<option value=\""- . $childArr[0]['PARENTFIELD']- . "\">--- ??? ---</option>\n";
 
-             while(- list ($key,$row)- = each($childArr)) {
 
-                 $ret- .= $this->getNotIntendedOption($row,$aValue);
 
-       * returns the html code for level select fields 
-         if ($debug) - echo  "<p><b>DBMS_FIELD_TREESELECT::getLevelSelectFields($aValue,$arrName,...)</b> ("- . get_class($this)- . ")</p>";
 
-         if (($treeDesc- = $this->getPCF_TreeDesc($arrName,$debug))- &&  ($treePath- = pcf_getTreePath($treeDesc,$aValue,$debug))) {
 
-             $countSelects- = sizeof($treePath);
 
-             while($level - <  $countSelects) {
 
-                     $ret- .= $this->getLevelSelect($childArr,$countSelects,$level,$treePath[$level]['KEYFIELD'],$arrName,$debug);
 
-                 $m_key- = (- isset ($treePath[($level- - 1)]['KEYFIELD'])- ?  $treePath[($level- - 1)]['KEYFIELD']- :  NULL); // <pk-06-08-03 /> E_ALL
 
-                 $ret- .= $this->getLevelSelect($childArr,$countSelects,$level- ++ ,$m_key,$arrName,$debug);
 
-             $ret- .= $this->getLevelSelect($childArr,$countSelects,$level- ++ ,$aValue,$arrName,$debug);
 
-         } else if ($this->allowNullSelect) { 
-         } else if (empty($this->newUrl)) { 
-             $ret- .=  "ERROR NO VALUES IN TREE";
 
-             $ret- .=  "Sie mssen eine Datensatz einfügen";
 
-         $ret- .=  "<input type='hidden' name='"- . $arrName- . "["- . $this->myName- . "]' value=\""- . htmlspecialchars($aValue)- . "\">";
 
-         $ret- .=  $this->getAddButton($arrName);
 
-       * @version pk-04-08-31 $debug added 
-     function getInputTag($aValue,$arrName- = "DBVAL",$debug- = False)
 
-         $debug- = ($debug- ||  $this->fldDebug); // <pk-04-08-31>
 
-             $str_ret - .=  "TODO levelselect";
 
-             $str_ret = $this->getLevelSelectFields($aValue,$this->myDataArrName,$debug); 
-             $str_ret.= $this->getAddTag($this->myDataArrName); 
-       * returns the field value if the referenzed row exists 
-       * @param  string  $aValue     the value 
-       * @param  array   $err        error array 
-       * @param  string  $arrName    name of the array to access fieldsarray  gloabl ${$arrName} 
-     function getValue($aValue,&$err,$arrName- = "DBVAL",$debug- = False) {
 
-         if ($debug) - echo  "<hr><p><b>DBMS_FIELD_TREESELECT::getValue($aValue,$err,$arrName,$debug)</b> ("- . get_class($this)- . " | "- . $this->myName- . ")</p>";
 
-                 return parent::getValue(Null,$err,$arrName,$debug); 
-         return parent::getValue($aValue,$err,$arrName,$debug); 
-       * returns the screen value 
-       * @todo DBMS_FIELD_TREESELECT::getScreenValue showPathRO 
-             if ($treePath=pcf_getTreePath($this->getPCF_TreeDesc($arrName),$aValue,$debug)) { 
-                 while(list($key,$row)=each($treePath)) { 
-                     switch ($this->showPathRO) { 
-                             $ret.= $sep.$row['SHOWFIELD']; 
-                             $sep = htmlspecialchars(" -> "); 
-                             $intend=htmlspecialchars($row['_INTEND']); 
-                             $intend=str_replace(" "," ",$intend); 
-                             $ret.= $sep.$intend.$row['SHOWFIELD']; 
-                             $ret.= $row['SHOWFIELD']." "; 
-       * returns a html select with all values (distinct) where $aValue 
-       * NOTE only works on database fields 
-       * @param string $selTagAdd added into <select ...> 
-       * @param string $whereCond added to query ($s_query="SELECT ... FROM TABLE ".$whereCond) 
-       * @todo object value tables 
-     function getTableValSelect(&$aValue,$arrName- = "",$selTagAdd- = "",$whereCond- = "",$nullLabel- = "",$debug- = False) {
 
-         if ($debug) - echo  "<p><b>DBMS_FIELD::getTableValSelect(aValue="- . $aValue- . ",arrName="- . $arrName- . ")</b> ("- . get_class($this)- . ")</p>\n";
 
-         $a_treeDesc- = $this->getPCF_TreeDesc($arrName);
 
-             if ($debug) - echo  "<pre>"- . print_r($a_treeArr,TRUE)- . "</pre>";
 
-                 $s_selName- = $arrName- . "["- . $this->myName- . "]";
 
-             $ret- = "\n<select name=\""- . $s_selName- . "\" "- . $selTagAdd- . ">\n";
 
-             if (!empty($nullLabel)) { 
-                 $ret- .= "\t<option value=\"\">"- . $nullLabel- . "</option>\n";
 
-                 $ret- .= "\t<option value=\"\">--- ??? ---</option>\n";
 
-             foreach($a_treeArr as $a_treeNode) { 
-                 if ($debug) - echo  "<p>Value: $aValue Row: "- . $a_treeNode['KEYFIELD'];
 
-                 $s_query - = "SELECT COUNT(*) FROM "- . $this->myTable;
 
-                 if (!empty($whereCond)) { 
-                     $s_query- .= " AND "- . $this->myName- . "="- . $GLOBALS['USRDB']->qs_getSlashedValue($a_treeNode['KEYFIELD']);
 
-                     $s_query- .= " WHERE "- . $this->myName- . "="- . $GLOBALS['USRDB']->qs_getSlashedValue($a_treeNode['KEYFIELD']);
 
-                 if ($debug) - echo  "<p>"- . $s_query- . "</p>";
 
-                 $i_nofEntries- = intval($GLOBALS['USRDB']->quickQuery($s_query,0));
 
-                 $ret- .=  "\t<option value=\""- . $a_treeNode['KEYFIELD']- . "\"";
 
-                     // no null Label -> we have to set the $aValue called by ref 
-                     $aValue- = $a_treeNode['KEYFIELD'];
 
-                 if (strval($aValue)- === ($a_treeNode['KEYFIELD'])) {
 
-                     if ($debug) - echo  " <b>SELECTED</b>";
 
-                 } else if (!$i_nofEntries) { 
-                 $ret- .=  ">  "- . $a_treeNode['_INTEND']- . $a_treeNode['SHOWFIELD']- . " ("- . $i_nofEntries- . ")</option>\n";
 
 
	
		Documentation generated on Thu, 08 Jan 2009 17:43:12 +0100 by phpDocumentor 1.4.0a2