Source for file PRO_GROUP_NODE.phpclass

Documentation is available at PRO_GROUP_NODE.phpclass

  1. <?php
  2. /**
  3.   * Class file PRO_GROUP_NODE.phpclass
  4.   *
  5.   * @project    Open CSP-Management
  6.   * @package    products
  7.   *
  8.   * @author     Peter Krebs (pk) <p.krebs@wpus.at>
  9.   * @copyright  (c) 2002-2004 by Peter Krebs and Landesverlag Unternehmensservice
  10.   * @copyright  (c) 2005 by WURM & Partner Unternehmensservice GmbH
  11.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  12.   *
  13.   * @since pk-05-06-19
  14.   *
  15.   ***/
  16.  
  17. require_once $GLOBALS['OCSP']['PHPINCPATH'].'db/DBMS_TREE_NODE.phpclass';
  18.  
  19. /**
  20.   * Class PRO_GROUP_NODE
  21.   *
  22.   * @project    Open CSP-Management
  23.   * @package    products
  24.   *
  25.   * @author     Peter Krebs (pk) <p.krebs@wpus.at>
  26.   * @copyright  (c) 2002-2004 by Peter Krebs and Landesverlag Unternehmensservice
  27.   * @copyright  (c) 2005 by WURM & Partner Unternehmensservice GmbH
  28.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  29.   *
  30.   * @since pk-05-06-19
  31.   *
  32.   ***/
  33. class PRO_GROUP_NODE extends DBMS_TREE_NODE {
  34.     /**
  35.       * @var  string  $myGlobalTreeKey      index in $GLOABLS['DBMS_TREE'][]
  36.       ***/
  37.     var $myGlobalTreeKey = "T_PRO_GROUP";
  38.  
  39.     /**
  40.       * @staticvar string $myTable 
  41.       */
  42.     var $myTable="T_PRO_GROUP";
  43.  
  44.     /**
  45.       * @staticvar  string  $myIdFld        id column = root
  46.       ***/
  47.     var $myIdFld        ="PGP_ID";
  48.  
  49.     /**
  50.       * @staticvar  string  $myParentFld    name of the parent column
  51.       ***/
  52.     var $myParentFld    ="PGP_PARENT";
  53.  
  54.     /**
  55.       * @staticvar  string  $mySortFld      name of the sort field
  56.       ***/
  57.     var $mySortFld      ="PGP_SORTORDER";
  58.  
  59.     /**
  60.       * @var  string  $myChildClass 
  61.       ***/
  62.     var $myChildClass = "PRO_GROUP_NODE";
  63.  
  64.     /**
  65.       * @var array $myGrpTypeArr row of T_PRO_GRPTYPE
  66.       ***/
  67.     var $myGrpTypeArr = NULL;
  68.  
  69.     /**
  70.       * @staticvar $myClassSrcFile 
  71.       ***/
  72.     var $myClassSrcFile = __FILE__;
  73.  
  74.     /**
  75.       * @var string $prodWhere 
  76.       * @since pk-05-08-25
  77.       ***/
  78.     var $prodWhere="";
  79.  
  80.  
  81.     /**
  82.       * @var string $prodFilter 
  83.       * @since pk-06-02-08
  84.       ***/
  85.     var $prodFilter="";
  86.     /**
  87.       * @var double $prodPopulateTS 
  88.       * @since pk-06-02-08
  89.       ***/
  90.     var $prodPopulateTS=0;
  91.  
  92.  
  93.     // ######################################
  94.  
  95.  
  96.     /**
  97.       * inserts a new row to the table
  98.       *
  99.       * @param string $gDBIDX Index of $GLOBALS to the db object
  100.       * @param bool   $debug  show debug info
  101.       *
  102.       * @return int   returns the autoIncFld ID if exists or 1 on success
  103.       *
  104.       * @since pk-04-08-25
  105.       *
  106.       ***/
  107.     function dbInsert($gDBIDX="USRDB",$debug=FALSE{
  108.         if ($debugecho "<hr><p><b>PRO_GROUP_NODE::dbInsert($gDBIDX,$debug)</b> (".get_class($this).")</p>";
  109.  
  110.         $query ="SELECT IFNULL(MAX(".$this->mySortFld."),1) FROM ".$this->myTable;
  111.         $query.=" WHERE ".$this->myParentFld."=".intval($this->{$this->myParentFld});
  112.         $query.=" AND PROJ_ID=".$this->getProjId();
  113.  
  114.  
  115.         $this->{$this->mySortFld$GLOBALS[$gDBIDX]->quickQuery($query,0,0);
  116.         $this->PGP_CREATION="CURRENT_TIMESTAMP";
  117.  
  118.         return parent::dbInsert($gDBIDX,$debug);
  119.     }
  120.  
  121.     /**
  122.       * replaces a row in the table
  123.       *
  124.       * if the object has not been populated (!$this->populateTS)
  125.       * FALSE is returned
  126.       *
  127.       * @param string $gDBIDX Index of $GLOBALS to the db object
  128.       * @param boolean   $debug  show debug info
  129.       *
  130.       * @returns bool
  131.       *
  132.       * @since pk-06-02-07
  133.       *
  134.       ***/
  135.     function dbReplace($gDBIDX="USRDB",$debug=FALSE{
  136.         if ($debugechoDebug(__FILE__,"<p><b>PRO_GROUP_NODE::dbReplace(...)</b> (".get_class($this).")</p>",0);
  137.  
  138.         $this->PGP_LASTCHANGE="CURRENT_TIMESTAMP";
  139.         return parent::dbReplace($gDBIDX,$debug);
  140.     }
  141.  
  142.  
  143.     /**
  144.       * adds a node to childArray($key)
  145.       *
  146.       * @param DBMS_TREE_NODE $aNode 
  147.       * @param boolean $debug 
  148.       *
  149.       * @returns int
  150.       *
  151.       ***/
  152.     function addChildNode(&$aNode,$debug=FALSE{
  153.         $aNode->PROJ_ID =$this->getProjId();
  154.         return parent::addChildNode($aNode,$debug);
  155.     }
  156.  
  157.     /**
  158.       * returns the Title or the name if title is null
  159.       * @return string 
  160.       ***/
  161.     function getTitle({
  162.         if ($title=$this->getDBField('PGP_TITLE'))
  163.             return $title;
  164.         return $this->getDBField('PGP_NAME');
  165.  
  166.     }
  167.  
  168.     /**
  169.       * sets the title
  170.       *
  171.       * @param string $aTitle 
  172.       *
  173.       * @since pk-06-01-26
  174.       *
  175.       ***/
  176.     function setTitle($aTitle{
  177.         $this->setDBField('PGP_TITLE',$aTitle);
  178.     }
  179.  
  180.     /**
  181.       * returns the project id
  182.       * @return int 
  183.       ***/
  184.     function getProjId({
  185.         return intval($this->PROJ_ID);
  186.     }
  187.  
  188.     /**
  189.       * returns the language id
  190.       * @return int 
  191.       ***/
  192.     function getLangId({
  193.         return intval($this->getDBField('LANG_ID'));
  194.     }
  195.  
  196.     /**
  197.       * returns the menu id
  198.       * @return int 
  199.       * @since pk-04-12-14
  200.       ***/
  201.     function getId({
  202.         return intval($this->getDBField('PGP_ID'));
  203.     }
  204.  
  205.     // ###########################################################################
  206.     //  TYPE methods
  207.     // ###########################################################################
  208.  
  209.  
  210.     /**
  211.       * returns the product group type ID
  212.       *
  213.       * @returns int
  214.       *
  215.       * @since pk-07-02-14
  216.       *
  217.       ***/
  218.     function getTypeId({
  219.         return intval($this->getDBField('PGT_ID'));
  220.     }
  221.  
  222.     /**
  223.       * sets the product group type ID
  224.       *
  225.       * @param int $aId 
  226.       * @param boolean $debug 
  227.       *
  228.       * @since pk-07-02-14
  229.       *
  230.       ***/
  231.     function setTypeId($aId,$debug=FALSE{
  232.         if ($debugechoDebugMethod(__FILE__,get_class($this),"PRO_GROUP_NODE::setTypeId()","\$aId=$aId");
  233.         $this->setDBField('PGT_ID',intval($aId));
  234.         $this->populateType($debug);
  235.     }
  236.  
  237.     /**
  238.       * selects the type row form T_PRO_GRPTYPE
  239.       *
  240.       * @param boolean $debug 
  241.       *
  242.       * @return boolean 
  243.       *
  244.       * @version pk-07-02-14
  245.       *
  246.       ***/
  247.     function populateType($debug=FALSE{
  248.         if ($debugechoDebugMethod(__FILE__,get_class($this),"PRO_GROUP_NODE::populateType()");
  249.  
  250.         // <pk-07-02-14 />
  251.         if ((isset($this->myGrpTypeArr['PGT_ID'])) && (intval($this->getDBField('PGT_ID')) == intval($this->myGrpTypeArr['PGT_ID']))) {
  252.             return TRUE;
  253.         }
  254.  
  255.         if (intval($this->getDBField('PGT_ID'))==0// the default type
  256.             $this->myGrpTypeArr=array(
  257.                 'PGT_ID'            => 0,
  258.                 'PGT_NAME'          => "[default]",
  259.                 'PGT_PROLST_FRM_ID' => 0,
  260.             );
  261.             return TRUE;
  262.         }
  263.  
  264.  
  265.         $query="SELECT * FROM T_PRO_GRPTYPE WHERE PGT_ID=".intval($this->getDBField('PGT_ID'));
  266.         if ($debugecho "<blockquote><p style=\"font-size:75%\">Query$query</p></blockquote>";
  267.  
  268.  
  269.         if ($this->myGrpTypeArr=$GLOBALS[$this->get_gDBIDX()]->quickQuery($query)) {
  270.             return TRUE;
  271.         else {
  272.             return FALSE;
  273.         }
  274.     }
  275.  
  276.     /**
  277.       * returns a form for table T_PRO_GROUP
  278.       *
  279.       * if $frmName isset this form is returned
  280.       * if $frmName is empty the form assigned to the type is returned
  281.       *
  282.       * @param int $mode 
  283.       * @param string $frmName 
  284.       * @param boolean $debug 
  285.       *
  286.       * @return DBMS_FORM 
  287.       *
  288.       ***/
  289.     function &dbGetForm($mode,$frmName="",$debug=FALSE{
  290.         if ($debugechoDebugMethod(__FILE__,get_class($this),"PRO_GROUP_NODE::dbGetForm(...)");
  291.  
  292.         $frmObj=NULL;
  293.         if (empty($frmName)) {
  294.             if ((!(is_array($this->myGrpTypeArr))) || ($this->PGT_ID != $this->myGrpTypeArr['PGT_ID'])) {
  295.                 $this->populateType($debug);
  296.             }
  297.  
  298.             if ($debugechoDebug(__FILE__,"<pre>".print_r($this->myGrpTypeArr,TRUE)."</pre>");
  299.  
  300.             if (intval($this->myGrpTypeArr['FRM_ID'])) {
  301.                 if ($debugecho "<p>Loading Form ID : ".$this->myGrpTypeArr['FRM_ID']."</p><blockquote style=\"font-size: 75%\">";
  302.                 if ($frmObj=&DBMS_form_loadId($this->myGrpTypeArr['FRM_ID'],$debug)) {
  303.                     if ($debugecho "<p>myClassSrcFile=".$this->myClassSrcFile."</p>";
  304.                     $frmObj->myDBMS_TABLEOBJ_include=$this->myClassSrcFile;
  305.                     $frmObj->myDBMS_TABLEOBJ_class  =get_class($this);
  306.                     if ($debugecho "</blockquote>";
  307.                     return $frmObj;
  308.                 }
  309.                 if ($debugecho "</blockquote>";
  310.             }
  311.         }
  312.  
  313.         if ($debugecho "<p>Loading Default Form or named Form!!!</p>";
  314.         return parent::dbGetForm($mode,$frmName,FALSE);
  315.  
  316.     }
  317.  
  318.  
  319.     /**
  320.       * checks if the node is on
  321.       *
  322.       * @param boolean $checkDate 
  323.       * @param boolean $checkGroup 
  324.       * @param boolean $debug 
  325.       * @param boolean $checkShow 
  326.       *
  327.       * @return boolean 
  328.       *
  329.       * @version pk-05-01-11
  330.       * @version pk-06-01-30
  331.       *
  332.       ***/
  333.     function isToShow($checkDate=TRUE,$checkGroup=TRUE,$debug=FALSE,$checkShow=TRUE,$checkProducts=TRUE,$checkParts=FALSE){
  334.         if (!$this->PGP_SHOW && ($checkShow)) {
  335.             return FALSE;
  336.         }
  337.         if (($checkDate&& ($this->checkShowDate($debug!= 1)) {
  338.             return FALSE;
  339.         }
  340.  
  341.         if ($checkGroup{
  342.             if (!is_object($GLOBALS['USER'])) return FALSE;
  343.             if ((intval($this->PGP_GROUP)) && (!($GLOBALS['USER']->isGroupMember($this->PGP_GROUP)))) {
  344.                 return FALSE;
  345.             }
  346.         }
  347.  
  348.         if (!empty($this->PGP_SHOWQUERY)) {
  349.             require_once $GLOBALS['PROJECT']['PHPINCPATH']."common/pcf_templates.phpinc";
  350.             $cmd=pcf_tmpl_parse($this->PGP_SHOWQUERY,$this->getDBVAL(),$debug);
  351.             $query "SELECT ".$cmd;
  352.             // $debug=TRUE; echo "<tr><td>"; foreach($_SESSION as $key => $val) echo "<li>$key = $val</li>"; echo "</td></tr>";
  353.             if ($debugecho "<tr><td><pre>checkShowNode(".$node['PGP_ID']."SHOWQUERY: \n$query</pre></td></tr>";
  354.  
  355.             if (!(intval($GLOBALS[$this->gDBIDX]->quickQuery($query,0)))) return FALSE;
  356.         }
  357.  
  358.         if ($checkProducts{
  359.             if ($this->hasProductsToShow($checkShow,$checkDate,$checkGroup,$checkParts,$debug)) {
  360.                 return TRUE;
  361.             else {
  362.                 return FALSE;
  363.             }
  364.         }
  365.  
  366.         return TRUE;
  367.  
  368.     }
  369.  
  370.     /**
  371.       * checks if the node has children which are on
  372.       *
  373.       * @param bool $filtered use filter
  374.       * @param bool $checkDate 
  375.       * @param bool $checkGroup 
  376.       * @param bool $debug 
  377.       *
  378.       * @return bool 
  379.       *
  380.       * @version pk-05-06-14
  381.       *
  382.       ***/
  383.     function hasChildrenToShow($filtered=FALSE,$checkDate=TRUE,$checkGroup=TRUE,$debug=FALSE){
  384.         if ($debugecho "<p><b>PRO_GROUP_NODE::hasChildrenToShow($checkDate,$checkGroup,...)</b> (".get_class($this).")</p>";
  385.  
  386.         if ($childArr=$this->getChildrenList($debug,$filtered)) {
  387.             foreach($childArr as $child{
  388.                 if ($child->isToShow($checkDate,$checkGroup,$debug)) return TRUE;
  389.             }
  390.         }
  391.         return FALSE;
  392.     }
  393.  
  394.     /**
  395.       * checks if the menu is to show from date
  396.       *
  397.       * return values are:
  398.       *
  399.       * - 1: yes
  400.       * - 0: showtill is outdate
  401.       * - -2: showfrom is not reached
  402.       *
  403.       * @returns int
  404.       *
  405.       * @since pk-04-07-23
  406.       *
  407.       ***/
  408.     function checkShowDate($debug=FALSE{
  409.         require_once $GLOBALS['PROJECT']['PHPINCPATH']."common/pcf_Date.phpclass";
  410.  
  411.         $now=new pcf_Date(time());
  412.         $aDate=new pcf_Date();
  413.         $aDate->setDateStr($this->PGP_SHOWFROM);
  414.         if ($aDate->getLinuxTime($now->getLinuxTime()) return -2;
  415.  
  416.         $aDate->setDateStr($this->PGP_SHOWTILL);
  417.         if ($aDate->getLinuxTime($now->getLinuxTime()) return 0;
  418.  
  419.         return 1;
  420.     }
  421.  
  422.  
  423.     // #####################################################################################
  424.     //  product methods
  425.     // #####################################################################################
  426.  
  427.     /**
  428.       * returns if produkts are allowed in the group
  429.       *
  430.       * @param boolean $debug 
  431.       *
  432.       * @returns boolean
  433.       *
  434.       * @since pk-07-02-14 (Tableversion 15)
  435.       *
  436.       ***/
  437.     function productsAllowed($debug=FALSE{
  438.         if ($debugechoDebugMethod(__FILE__,get_class($this),"PRO_GROUP_NODE::productsAllowed()","PGP_DISABLEPRODUCTS=".$this->getDBField('PGP_DISABLEPRODUCTS'));
  439.         if (intval($this->getDBField('PGP_DISABLEPRODUCTS'))) {
  440.             return FALSE;
  441.         }
  442.         return TRUE// the default value
  443.     }
  444.  
  445.     /**
  446.       * returns the default product type for products in this group
  447.       * if the current value is 0 ([default]) the tree is searched upwords
  448.       *
  449.       * @param boolean $debug 
  450.       *
  451.       * @returns int
  452.       *
  453.       * @since pk-07-02-15
  454.       *
  455.       ***/
  456.     function getDefaultProdTypeId($debug=FALSE{
  457.         if ($debugechoDebugMethod(__FILE__,get_class($this),"PRO_GROUP_NODE::getDefaultProdTypeId()","PGP: ".$this->getDBField('PGP_NAME')." (".$this->getId().")");
  458.  
  459.         if (intval($this->getDBField('PGP_DEFAULT_PRT_ID'))) return intval($this->getDBField('PGP_DEFAULT_PRT_ID'));
  460.         if ($o_node=$this->getParentObj()) {
  461.             return $o_node->getDefaultProdTypeId($debug);
  462.         else {
  463.             return 0;
  464.         }
  465.     }
  466.  
  467.  
  468.     /**
  469.       * sets a where clause for products
  470.       * if this is set it PRO_GROUP_NODE::getProductWhere returnes
  471.       * it without modification
  472.       *
  473.       * @param string $where 
  474.       * @since pk-05-08-25
  475.       ***/
  476.     function setProductWhere($where{
  477.         $this->prodWhere=$where;
  478.     }
  479.  
  480.     /**
  481.       * returns a query to select all products
  482.       *
  483.       * @param boolean $showAll 
  484.       * @param string $whereAdd 
  485.       * @param boolean $debug 
  486.       *
  487.       * @return string 
  488.       *
  489.       * @since pk-05-06-20
  490.       * @version pk-05-08-25
  491.       ***/
  492.     function getProductWhere($showAll=FALSE,$whereAdd="",$debug=FALSE{
  493.         if ($debugecho "<p><b>PRO_GROUP_NODE::getProductWhere($showAll,$whereAdd ..)</b> (".get_class($this).")</p>";
  494.         if (!empty($this->prodWhere)) {
  495.             if ($debugecho "<p>RETURNING FIXED WHERE</p>";
  496.             return $this->prodWhere;
  497.         }
  498.  
  499.         $query =" WHERE PGP_ID =".$this->getId();
  500.         if (!$showAll{
  501.             $query.=" AND PRO_SHOW > 0";
  502.             $query.=" AND PRO_SHOWFROM <= NOW()";
  503.             $query.=" AND PRO_SHOWTILL >= NOW()";
  504.         }
  505.         $query.= $whereAdd;
  506.         if (!empty($this->prodFilter)) {
  507.             $query.=" AND (".$this->prodFilter.")";
  508.         }
  509.         $query.= " ORDER BY PRO_SORTORDER ";
  510.  
  511.         return $query;
  512.     }
  513.  
  514.  
  515.  
  516.     /**
  517.       * returns an array of PRODUCT objects
  518.       *
  519.       * @param boolean $showAll 
  520.       * @param string $whereAdd 
  521.       * @param boolean $debug 
  522.       * @param boolean $forceReload 
  523.       *
  524.       * @return array 
  525.       *
  526.       * @since pk-05-06-20
  527.       * @version pk-05-08-24
  528.       * @version pk-06-02-08 cache added
  529.       *
  530.       ***/
  531.     function getProducts($showAll=FALSE,$whereAdd="",$debug=FALSE,$forceReload=FALSE{
  532.         if ($debugechoDebug(__FILE__,"<p><b>PRO_GROUP_NODE::getProducts(...)</b> (".get_class($this).")</p>",0);
  533.  
  534.         $a_cache=$GLOBALS['OCSP']['CACHE']['PGP_PRODUCTS'][$this->getId()];
  535.  
  536.         if (!$forceReload && ($this->prodPopulateTS > time($GLOBALS['PROJECT']['OBJCACHELIFETIME']&& (is_array($a_cache))) {
  537.             // we have a valid cache return it
  538.             return $a_cache;
  539.         }
  540.  
  541.         require_once $GLOBALS['PRODUCTS']['PHPINCPATH']."PRO_PRODUCT.phpclass";
  542.         // <pk-05-08-24>
  543.         $query="SELECT * FROM T_PRO_PRODUCT ".$this->getProductWhere($showAll,$whereAdd,$debug);
  544.  
  545.         if ($debugechoDebug(__FILE__,"<p>Query$query</p>",1);
  546.         $a_cache=array();
  547.         if ($cursor=$GLOBALS[$this->get_gDBIDX()]->query($query)) {
  548.             $idx=0;
  549.             while($row=$cursor->fetchArrayFld()) {
  550.                 $a_cache[$idx]=new PRO_PRODUCT();
  551.                 $a_cache[$idx]->setDBRow($row,TRUE,$debug);
  552.                 $a_cache[$idx]->setMyProGrp($this,$debug);
  553.                 $idx++;
  554.             }
  555.         }
  556.         $GLOBALS['OCSP']['CACHE']['PGP_PRODUCTS'][$this->getId()]=$a_cache;
  557.         return $a_cache;
  558.     }
  559.  
  560.     /**
  561.       * returns if the group has products to show
  562.       *
  563.       * @param boolean $checkShow 
  564.       * @param boolean $checkDate 
  565.       * @param boolean $checkGroup 
  566.       * @param boolean $checkParts 
  567.       * @param boolean $debug 
  568.       * @param boolean $checkChildren 
  569.       * @param boolean $forceReload 
  570.       *
  571.       * @returns boolean
  572.       *
  573.       * @todo check group children
  574.       *
  575.       ***/
  576.     function hasProductsToShow($checkShow=TRUE,$checkDate=TRUE,$checkGroup=TRUE,$checkParts=FALSE,$debug=FALSE,$checkChildren=TRUE,$forceReload=FALSE{
  577.         if ($debugechoDebug(__FILE__,"<p><b>PRO_GROUP_NODE::hasProductsToShow(...)</b> (".get_class($this).")</p>",0);
  578.  
  579.         $b_showAll=(($checkShow && $checkDateFALSE TRUE);
  580.         $a_prods=$this->getProducts($b_showAll,"",$debug,$forceReload);
  581.  
  582.         foreach($a_prods as $i_sortOrder => $o_prod{
  583.             if ($o_prod->isToShow($checkDate,$checkGroup,$debug,$checkShow,$checkParts)) return TRUE;
  584.         }
  585.  
  586.         // @todo check children
  587.         return FALSE;
  588.     }
  589.  
  590.  
  591.     /**
  592.       * returns the list form for the products under this group
  593.       *
  594.       * NOTE: if you have a common produkt structure under this group you can use this
  595.       * if not it would be better to use getHTMLProductList and define templates for the product types
  596.       *
  597.       * @param int $mode 
  598.       * @param boolean $debug 
  599.       *
  600.       * @returns DBMS_FORM
  601.       *
  602.       * @since pk-07-02-14
  603.       *
  604.       ***/
  605.     function &dbGetProLstForm($debug=FALSE{
  606.         if ($debugechoDebugMethod(__FILE__,get_class($this),"PRO_GROUP_NODE::dbGetProLstForm()");
  607.  
  608.         $this->populateType($debug);
  609.         if ($debugechoDebug(__FILE__,"<blockquote>myGrpTypeArr:<pre>".print_r($this->myGrpTypeArr,TRUE)."</pre></blockquote>");
  610.         $o_frmObj=NULL;
  611.         if (isset($this->myGrpTypeArr['PGT_PROLST_FRM_ID']&& (intval($this->myGrpTypeArr['PGT_PROLST_FRM_ID']))) {
  612.             $o_frmObj=DBMS_form_loadId(intval($this->myGrpTypeArr['PGT_PROLST_FRM_ID']));
  613.         }
  614.  
  615.         if (!pcf_is_instance_of($o_frmObj,'DBMS_FORM')) {
  616.             $o_frmObj=DBMS_form_loadName('T_PRO_PRODUCT');
  617.         }
  618.  
  619.         return $o_frmObj;
  620.     }
  621.  
  622.  
  623.  
  624.  
  625.     // #####################################################################################
  626.     //  public methods
  627.     // #####################################################################################
  628.  
  629.     /**
  630.       * returns the link url
  631.       *
  632.       * @param bool $debug 
  633.       *
  634.       * @return string 
  635.       *
  636.       * @since pk-05-01-20
  637.       *
  638.       ***/
  639.     function getLinkUrl($valArr=NULL,$debug=FALSE{
  640.         if ($debugecho "<p><b>PRO_GROUP_NODE::getLinkUrl(...)</b> (".get_class($this).")</p>";
  641.  
  642.         echo "<h1>NOT IMPLEMENTED</h1>";
  643.         echo "<p><b>PRO_GROUP_NODE::getLinkUrl(...)</b> (".get_class($this).")</p>";
  644.  
  645.     }
  646.  
  647.     /**
  648.       * returns the <a ... </a> tag for the menu link
  649.       *
  650.       * @param array $valArr 
  651.       * @param string $aAddTag 
  652.       * @param bool $debug 
  653.       *
  654.       * @return string 
  655.       *
  656.       * @version pk-05-01-21
  657.       *
  658.       * @todo
  659.       ***/
  660.     function getHTMLLink($valArr=NULL,$aAddTag="",$debug=FALSE{
  661.         if ($debugecho "<p><b>PRO_GROUP_NODE::getHTMLLink($valArr,...)</b> (".get_class($this).")</p>";
  662.  
  663.         $uri=$_SERVER['REQUEST_URI'];
  664.         if ((strstr($uri,"PGP_ID=")) && (intval($_GET['PGP_ID']))) {
  665.             $uri=str_replace("PGP_ID=".$_GET['PGP_ID'],"PGP_ID=".$this->getId(),$uri);
  666.         else {
  667.             $uri.="&PGP_ID=".$this->getId();
  668.         }
  669.         return "<a href=\"$uri\"".$aAddTag.">".$this->PGP_NAME."</a>";
  670.     }
  671.  
  672.     // ################################################################
  673.     // layout methods
  674.     // ################################################################
  675.  
  676.     /**
  677.       * returns the html code for the product list
  678.       *
  679.       * @param boolean $checkDate 
  680.       * @param boolean $debug 
  681.       *
  682.       * @return string 
  683.       *
  684.       * @version pk-05-08-25
  685.       * @version pk-06-11-27
  686.       ***/
  687.     function getHTMLProductList($checkDate=TRUE,$checkGroup=TRUE,$debug=FALSE{
  688.         if ($debugecho "<p><b>PRO_GROUP_NODE::getHTMLProductList(...)</b> (".get_class($this).")</p>";
  689.  
  690.         $ret="";
  691.         if ($productLst=$this->getProducts(TRUE,"",$debug)) {
  692.             foreach($productLst as $product{
  693.                 if (!empty($this->prodWhere|| ($product->isToShow($checkDate,$checkGroup,$debug))) {
  694.                     // <pk-05-08-25>
  695.                     // if a product where clause is set we asume the
  696.                     // developer using this knows what he wants therefor we do not need
  697.                     // to check if the product is to show
  698.                     $proTag =$product->getHTMLListRow($checkDate,$checkGroup,$debug);
  699.                     if (!empty($proTag)) {
  700.                         //$ret.="<div class=\"".$this->LAYOUT_ProductListClass."\" style=\"display:block\">\n";
  701.                         $ret.=$proTag."\n";
  702.                         //$ret.="</div>";
  703.                     }
  704.                 }
  705.             }
  706.         }
  707.         return $ret;
  708.     }
  709.  
  710.  
  711.     /**
  712.       * returns the html code for the detail page
  713.       * $#PRODUCTLIST$ is replaced by a list of all products to show
  714.       *
  715.       * @param boolean $checkDate 
  716.       * @param boolean $checkGroup 
  717.       * @param string $loginUrl 
  718.       * @param boolean $debug 
  719.       *
  720.       * @return string 
  721.       *
  722.       * @since pk-05-06-20
  723.       ***/
  724.     function getHTMLDetail($checkDate=TRUE,$checkGroup=TRUE,$loginUrl=NULL,$debug=FALSE{
  725.         if (intval($_GET['PGPDEBUG'])) $debug=TRUE;
  726.         if ($debugecho "<p><b>PRO_GROUP_NODE::getHTMLDetail(...)</b> (".get_class($this).")</p>";
  727.  
  728.         $this->populateType($debug);
  729.         $tmpl=$this->myGrpTypeArr['PGT_DETAILTMPL'];
  730.         if (strstr($tmpl,"$#PRODUCTLIST$")) {
  731.  
  732.             $tmpl=str_replace("$#PRODUCTLIST$",$this->getHTMLProductList($checkDate,$checkGroup,$debug),$tmpl);
  733.         }
  734.  
  735.         require_once $GLOBALS['OCSP']['PHPINCPATH']."common/pcf_templates.phpinc";
  736.         return pcf_tmpl_parse($tmpl,$this->getDBVAL());
  737.     }
  738.  
  739.  
  740.     // #####################################################################################
  741.     //  methods used by admin
  742.     // #####################################################################################
  743.  
  744.     /**
  745.       * echos a the row in a table  OVERRIDE IN SUB CLASS to change layout
  746.       *
  747.       * @param  bool    $debug 
  748.       *
  749.       ***/
  750.     function writeTableRowThis($debug{
  751.         echo "<tr><td>";
  752.         if ($debugecho "ID: ".$this->getId();
  753.         echo "<a href='".$this->getLinkUrl($debug)."'>";
  754.         echo $this->getDBField('PGP_TITLE');
  755.         echo "</a></td></tr>\n";
  756.     }
  757.  
  758.     /**
  759.       * echos a tree intend called by write children
  760.       *
  761.       * @param  int     $expandLevel 
  762.       * @param  bool    $useChace 
  763.       * @param  bool    $debug 
  764.       *
  765.       ***/
  766.     function writeTableRowChildren($expandLevel=0,$useCache=TRUE,$debug=FALSE{
  767.         if ((!$useCache|| ((time($this->myChildrenPopulateTS$this->myChildCacheTTL)) {
  768.             $this->populateChildren($useCache,$debug);
  769.         }
  770.         if (sizeof($this->myChildren)) {
  771.             echo "<tr><td><table width='90%' align='right' border='0'>";
  772.             foreach($this->myChildren as $orderNr => $id{
  773.                 $GLOBALS['DBMS_TREE'][$this->getGlobalTreeKey()][$id]->writeTableRowThis($debug);
  774.                 if ($expandLevel 0{
  775.                     $GLOBALS['DBMS_TREE'][$this->getGlobalTreeKey()][$id]->writeTableRowChildren($expandLevel-1,$useCache,$debug);
  776.                 }
  777.             }
  778.             echo "</table></td></tr>\n";
  779.         }
  780.     }
  781.  
  782.  
  783.     // #####################################################################################
  784.     //  sidemenu methods
  785.     // #####################################################################################
  786.  
  787.     /**
  788.       * returns the html-code for the sidemenu link
  789.       * @param string $class 
  790.       * @param bool $debug 
  791.       *
  792.       * @return string 
  793.       *
  794.       * @todo change to progroup
  795.       *
  796.       ***/
  797.     function getSideMenuLink($class="",$debug=FALSE{
  798.         if ($debugecho "<p><b>PRO_GROUP_NODE::getSideMenuLink($class,...)</b> (".get_class($this)."/".$this->getId().")";
  799.         return "Link To ".$this->PGP_TITLE." not implemented (PRO_GROUP_NODE::getSideMenuLink())";
  800.     }
  801.  
  802.     /**
  803.       * writes a sidemneu row
  804.       *
  805.       * @param string $class css-style class to use for <a>
  806.       * @param bool $debug 
  807.       ***/
  808.     function writeSideMenuRow($class="",$debug{
  809.         if ($debugecho "<p><b>PRO_GROUP_NODE::writeSideMenuRow($class,$debug)</b> (".get_class($this).")</p>";
  810.         echo $this->trTag;
  811.         echo $this->tdTag;
  812.         echo $this->getSideMenuLink($class,$debug);
  813.         echo "</td></tr>\n";
  814.     }
  815.  
  816.     /**
  817.       * writes a sidemneu row on Path to the selected node
  818.       *
  819.       * @param string $class css-style class to use for <a>
  820.       * @param bool $debug 
  821.       ***/
  822.     function writeSideMenuRowOnPath($treePath,$class="",$debug=FALSE{
  823.         if ($debugecho "<tr><td><b>PRO_GROUP_NODE::writeSideMenuRowOnPath($path,$class,$debug)</b> (".get_class($this).")</td></tr>";
  824.         echo $this->writeSideMenuRow($class,$debug);
  825.  
  826.         if (sizeof($this->myChildren)) {
  827.             echo "<tr><td align=\"right\">";
  828.  
  829.             echo $this->subtblTag."\n";
  830.             array_shift($treePath)// remove the first id (points to $this)
  831.             foreach($this->myChildren as $orderNr => $id{
  832.                 $node=$GLOBALS['DBMS_TREE'][$this->getGlobalTreeKey()][$id];
  833.                 $node->subtblTag=$this->subtblTag;
  834.                 $node->trTag    ="\t".$this->trTag;
  835.                 $node->tdTag    =$this->tdTag;
  836.                 $node->pageUrl  =$this->pageUrl;
  837.                 if ((!is_object($treePath[0])) || ($id != $treePath[0]->getId())) {
  838.                     if ($node->isToShow(TRUE,TRUE,$debug)) {
  839.                         $node->writeSideMenuRow("",$debug);
  840.                     }
  841.                 else {
  842.                     $node->writeSideMenuRowOnPath($treePath,"",$debug);
  843.                 }
  844.             }
  845.             echo "</table></td></tr>\n";
  846.         }
  847.     }
  848.  
  849. // class PRO_GROUP_NODE

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