Source for file DBMS_FIELD_IDENTIFLDTREESEL.phpclass

Documentation is available at DBMS_FIELD_IDENTIFLDTREESEL.phpclass

  1. <?php
  2. /**
  3.   * Class file DBMS_FIELD_IDENTIFLDTREESEL.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    dbms_field
  7.   * @category   any
  8.   *
  9.   * @author     Peter Krebs (pk)<pitlinz@users.sourceforge.net>
  10.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  11.   *
  12.   * @since pk-05-02-19 IDENTIFIEDTREESELECT -> IDENTIFIE<b>L</b>DTREESELECT
  13.   * @version $Id: DBMS_FIELD_IDENTIFLDTREESEL.phpclass,v 1.4 2008/08/12 08:22:38 pitlinz Exp $
  14.   */
  15.  
  16.     // --------------------------------------------------------
  17.     // requirements
  18.     // --------------------------------------------------------
  19.  
  20.     pcf_require_class("DBMS_FIELD_TREESELECT",dirname(__FILE__"/");
  21.  
  22. /**
  23.   * Handles foreign keys with a identifier field
  24.   *
  25.   * @project    Open CSP-Management
  26.   * @package    dbms_field
  27.   * @category   any
  28.   *
  29.   * @author     Peter Krebs (pk)<pitlinz@users.sourceforge.net>
  30.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  31.   *
  32.   * @since pk-05-02-19 IDENTIFIEDTREESELECT -> IDENTIFLDTREESEL
  33.   * @version $Id: DBMS_FIELD_IDENTIFLDTREESEL.phpclass,v 1.4 2008/08/12 08:22:38 pitlinz Exp $
  34.   */
  35.     var $className          = "IDENTIFLDTREESEL";
  36.     protected $identField         = "";
  37.  
  38.     /**
  39.       * source file of the class
  40.       *
  41.       * @var string $classSrcFile 
  42.       * @since pk-05-02-19
  43.       ***/
  44.     protected $classSrcFile=__FILE__;
  45.  
  46.     /**
  47.       * @var string $sortAdd sorting of sublings
  48.       * @since pk-07-01-07
  49.       ***/
  50.     protected $sortAdd="";
  51.  
  52.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  53.     // methods
  54.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  55.  
  56.     /**
  57.       * returns an array of field to bie shown in the edit form
  58.       * by using editTbl_echoForm
  59.       *
  60.       * the array is in the form:
  61.       *
  62.       * <code>
  63.       * [_sectionName_]
  64.       *      [TITLE] -> string
  65.       *      [_rowName_]
  66.       *         [FLDLAB]  (complete html code with <td></td>)
  67.       *         [FLDVAL] (complete html code with <td></td>)
  68.       * </code>
  69.       *
  70.       * @param boolean $debug 
  71.       *
  72.       * @returns array
  73.       *
  74.       * @since pk-06-07-04
  75.       *
  76.       ***/
  77.     function editTbl_getFieldEditArr($debug=FALSE{
  78.         if ($debugechoDebugMethod(__FILE__,get_class($this),"DBMS_FIELD_IDENTIFLDTREESEL::editTbl_getFieldEditArr()","",0);
  79.         $a_ret=parent::editTbl_getFieldEditArr($debug);
  80.  
  81.         $a_ret['DBLOOKUP']['FLD_SHOWLSTSORT']['FLDVAL']="ORDER BY [IDENTFIELD],<input name=\"sortAdd\" value=\"".htmlspecialchars($this->sortAdd)."\" size=\"40\">";
  82.         $a_ret['DBLOOKUP']['IDENTFIELD']=array(
  83.             'FLDLAB'=>"IDENTIFIER Field:",
  84.             'FLDVAL'=>"<input name=\"identField\" value=\"".$this->identField."\" size=\"40\">"
  85.         );
  86.  
  87.         return $a_ret;
  88.     }
  89.  
  90.  
  91.  
  92.     /**
  93.       * saves the post values from the field definition input form
  94.       */
  95.     function save({
  96.         $ret =parent::save();
  97.  
  98.         if (isset($_POST['identField']))
  99.         {
  100.             $this->identField            =$_POST['identField'];
  101.             $this->sortField             =$this->identField;
  102.         }
  103.         $this->sortAdd               =((isset($_POST['sortAdd']&& (!empty($_POST['sortAdd']))) $_POST['sortAdd'"");
  104.         if (!empty($this->sortAdd)) $this->sortField.=",".$this->sortAdd;
  105.  
  106.         return $ret;
  107.     }
  108.  
  109.     // ###########################################
  110.  
  111.     /**
  112.       * returns the select statement for the tree nodes
  113.       *
  114.       * @returns string
  115.       *
  116.       ***/
  117.     function getSelectStmt($debug=FALSE{
  118.         
  119.         return "";
  120.         
  121.         $debug=($debug || $this->fldDebug);
  122.         if ($debugecho "<p><b>DBMS_FIELD_IDENTIFLDTREESEL::getSelectStmt(...)</b> (".get_class($this).")</p><blockquote>";
  123.  
  124.         $ret "SELECT ".$this->showField." AS SHOWFIELD";
  125.         $ret.= ",".$this->keyField." AS KEYFIELD";
  126.         $ret.= ",".$this->parentField." AS PARENTFIELD";
  127.         $ret.= ",".$this->identField." AS IDENTFIELD";
  128.         $ret.= " FROM ".$this->foreignTbl;
  129.  
  130.         if ($debugecho "<p>$ret</p></blockquote>";
  131.         return $ret;
  132.     }
  133.  
  134.     // ###########################################
  135.  
  136.     /**
  137.       * returns the treedesc array
  138.       *
  139.       * @param string $arrName 
  140.       * @param boolean $debug 
  141.       *
  142.       *  returns array
  143.       *
  144.       ***/
  145.     function getPCF_TreeDesc($arrName="DBVAL",$debug=FALSE{
  146.         $debug=($debug || $this->fldDebug)// <pk-04-08-31 />
  147.         if ($debugecho "<p><b>DBMS_FIELD_IDENTIFLDTREESEL::getPCF_TreeDesc($arrName,...)</b> (".get_class($this).")</p><blockquote>";
  148.  
  149.         $dbDesc=parent::getPCF_TreeDesc($arrName);
  150.         $dbDesc['ADDFIELDS'].=(!empty($dbDesc['ADDFIELDS']"," "".$this->identField." AS IDENTFIELD";
  151.         if ($debugecho "<pre>".print_r($dbDesc,TRUE),"<pre></blockquote>";
  152.         return $dbDesc;
  153.     }
  154.  
  155.     // ###########################################
  156.  
  157.     function echoIntededOption($row,$aValue=""{
  158.         echo "\t<option value=\"".$row['KEYFIELD']."\"";
  159.         if ($aValue==$row['KEYFIELD']echo " selected";
  160.         echo ">".$row['IDENTFIELD'].": ".$row['SHOWFIELD']."</option>\n";
  161.     }
  162.  
  163.     function echoNotIntededOption($row,$aValue=""{
  164.         echo "\t<option value=\"".$row['KEYFIELD']."\"";
  165.         if ($aValue==$row['KEYFIELD']echo " selected";
  166.         echo ">".$row['SHOWFIELD']." (".$row['IDENTFIELD'].")</option>\n";
  167.     }
  168.  
  169.     
  170.     function getScreenValue($aValue,$arrName="DBVAL",$debug=FALSE
  171.     {
  172.         /*
  173.          * @todo
  174.          */ 
  175.         return $aValue;
  176.                 
  177.         $str_query=$this->getSelectStmt();        
  178.         if (!empty($this->lookupWhere))  // <pk-08-01-08>
  179.         {
  180.             require_once __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";
  181.             $str_query.=" WHERE ".pcf_tmpl_parse($this->lookupWhere,${$this->myDataArrName});
  182.         }
  183.         
  184.         $obj_myDB=$this->myForm->getDBObj();
  185.         
  186.         if ($row=$obj_myDB->quickQuery($query)) return $row['IDENTFIELD']." - ".$row['SHOWFIELD'];
  187.         else if (!empty($aValue)) return $aValue;
  188.         return "";
  189.     }
  190.  
  191. }
  192. ?>

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