Source for file PRO_CMS_PAGE.phpclass

Documentation is available at PRO_CMS_PAGE.phpclass

  1. <?php
  2. /**
  3.   * openCSP class file PRO_CMS_PAGE.phpclass
  4.   *
  5.   * @project Open CSP-Management
  6.   * @package shop
  7.   *
  8.   * @author Peter Krebs <pitlinz@users.sourceforge.net>
  9.   * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  10.   *
  11.   * @since pk-05.08.2008
  12.   * @version $Id: PRO_CMS_PAGE.phpclass,v 1.4 2008/10/15 06:55:16 pitlinz Exp $
  13.   */
  14.  
  15.     // ---------------------------------------------------------
  16.     // requirements
  17.     // ---------------------------------------------------------
  18.  
  19.     pcf_require_class('CMS_PAGE',"cms/page/");
  20.     pcf_require_class('PRO_PRODUCT',dirname(__FILE__)."/");
  21.     pcf_require_class('PRO_PART',dirname(__FILE__)."/");
  22.     
  23. /**
  24.   * openCSP class PRO_CMS_PAGE
  25.   *
  26.   * @project Open CSP-Management
  27.   * @package shop
  28.   *
  29.   * @author Peter Krebs <pitlinz@users.sourceforge.net>
  30.   * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  31.   *
  32.   * @since pk-05.08.2008
  33.   * @version $Id: PRO_CMS_PAGE.phpclass,v 1.4 2008/10/15 06:55:16 pitlinz Exp $
  34.   */
  35. class PRO_CMS_PAGE extends CMS_PAGE
  36. {
  37.     // ---------------------------------------------------------------------------
  38.     // constants
  39.     // ---------------------------------------------------------------------------
  40.     
  41.     /**
  42.      * @constant string CLASS_SRC_FILE
  43.      */
  44.     const CLASS_SRC_FILE = __FILE__;
  45.  
  46.     // ---------------------------------------------------------------------------
  47.     // class (static)
  48.     // ---------------------------------------------------------------------------
  49.     
  50.     /*** class vars ------------------------------------------------------ */
  51.     
  52.     /*** class methods --------------------------------------------------- */
  53.     
  54.     // ---------------------------------------------------------------------------
  55.     // object vars
  56.     // ---------------------------------------------------------------------------
  57.     
  58.     /*** compostion --------------------------------------------------- */
  59.     
  60.     protected $myProduct = Null;
  61.     
  62.     /*** attributes  -------------------------------------------------- */
  63.     
  64.     /**
  65.       * @var string $includeRoot 
  66.       */
  67.     protected $includeRoot="templates/";    
  68.     
  69.     // ---------------------------------------------------------------------------
  70.     // factory / construct
  71.     // ---------------------------------------------------------------------------
  72.     
  73.     // ---------------------------------------------------------------------------
  74.     // getter / setter
  75.     // ---------------------------------------------------------------------------    
  76.  
  77.     /**
  78.       * returns a array of variables used by the page object
  79.       *
  80.       * array[varName]=array(
  81.       *     [TYPE]          datatype
  82.       *     [FLDCLASS]      name of DBMS_FIELD* class
  83.       *     [CLASSVALS]     array of values of [FLDCLASS]
  84.       *
  85.       * @global array $OCSP_CONF 
  86.       *
  87.       * @returns array
  88.       *
  89.       * @since pk-04-08-10
  90.       * @version pk-05-06-17
  91.       *
  92.       ***/
  93.     protected function getObjVarDef(
  94.     {
  95.         $arr_ret parent::getObjVarDef();    
  96.     
  97.         $arr_ret["tmpl_PRODUCT"]array(
  98.                 "TYPE"      => "string",
  99.                 "FLDCLASS"  => "DBMS_FIELD_FILESELECTLIST",
  100.                 "CLASSVALS" =>array(
  101.                     "label"         => t_admin("Template"),
  102.                     "allowNull"     => True,
  103.                     "isSearchable"  => True,
  104.                     "showInList"    => False,
  105.                     "toolTip"       => t_admin("Include Template f&uumlr das Produkt"),
  106.                     "rootDir"       => $this->includeRoot,
  107.                     //"defaultDir"    => $this->includeRoot."shop",
  108.                     "allow_mkdir"   => True,
  109.                     "allow_upload"  => True
  110.                 )
  111.             )
  112.  
  113.          return $arr_ret;
  114.     }
  115.     
  116.     /**
  117.      * returns the product
  118.      *
  119.      * @return PRO_PRODUCT 
  120.      */
  121.     public function &getMyProduct()
  122.     {
  123.         if (!isset($this->myProduct))
  124.         {
  125.             do {
  126.                 if (isset($_POST['PRO_ID']&& ($int_proId=intval($_POST['PRO_ID'])))
  127.                     break;
  128.                 if (isset($_GET['PRO_ID']&& ($int_proId=intval($_GET['PRO_ID'])))
  129.                     break;
  130.                 if (isset($_POST['PAR_ID']))
  131.                 {
  132.                     if ($obj_part PRO_PART::getInstance(intval($_POST['PAR_ID'])))
  133.                     {
  134.                         $int_proId $obj_part->getProductId();
  135.                         break;
  136.                     }
  137.                 }
  138.                 if (isset($_GET['PAR_ID']))
  139.                 {
  140.                     if ($obj_part PRO_PART::getInstance(intval($_GET['PAR_ID'])))
  141.                     {
  142.                         $int_proId $obj_part->getProductId();
  143.                         break;
  144.                     }
  145.                 }
  146.                 
  147.                 $int_proId 0;                
  148.             while(False);
  149.             
  150.             $this->myProduct = PRO_PRODUCT::getInstance($int_proId);
  151.         }
  152.         
  153.         return $this->myProduct;
  154.     }
  155.     
  156.     /**
  157.      * sets the product
  158.      *
  159.      * @param PRO_PRODUCT $aProduct 
  160.      */
  161.     public function setMyProduct(&$aProduct)
  162.     {
  163.         $this->myProduct = $aProduct;
  164.     }
  165.     
  166.     // ---------------------------------------------------------------------------
  167.     // navigation
  168.     // ---------------------------------------------------------------------------
  169.     
  170.     /**
  171.      * returns the menu key
  172.      * 
  173.      * @param boolean $debug 
  174.      * 
  175.      * @return string 
  176.      */
  177.     public function getMenKey($debug=False)
  178.     {
  179.         if ($debugechoDebugMethod(__FILE__,get_class($this),"PRO_CMS_PAGE::getMenKey()");
  180.         
  181.         if ($str_ret = (string) $this->getMenId())
  182.         {
  183.             if ($this->getMyProduct())
  184.             {
  185.                 $str_ret .= "-" $this->myProduct->getProGroupId();
  186.             }
  187.             return $str_ret;
  188.         else {
  189.             return Null;
  190.         }
  191.     }
  192.     
  193.         
  194.     // ---------------------------------------------------------------------------
  195.     // output
  196.     // ---------------------------------------------------------------------------
  197.     
  198.     /**
  199.      * renders the product
  200.      *
  201.      * @param boolean $debug 
  202.      * 
  203.      * @return string (html)
  204.      */
  205.     protected function renderProduct($debug=False)
  206.     {
  207.         if ($debugechoDebugMethod(__FILE__,get_class($this),"PRO_CMS_PAGE::renderProduct();");
  208.  
  209.         $str_ret "";
  210.         
  211.         if ($this->getMyProduct($debug))
  212.         {
  213.             $str_tmpl $this->getDBField('tmpl_PRODUCT');
  214.             ob_start();
  215.             include __OCSP_PROJECTPATH__.$str_tmpl;
  216.             $str_ret .= ob_get_contents();
  217.             ob_end_clean();
  218.         else {
  219.             $str_ret.="<p>No Product set</p>";
  220.         }
  221.         return $str_ret;
  222.     
  223.     
  224.     /**
  225.       * returns the content of the page
  226.       *
  227.       * @param int $chaShowMode 
  228.       * @param boolean $debug 
  229.       *
  230.       * @return string 
  231.       * @since pk-07-08-25
  232.       * @version pk-07-10-04
  233.       * @version pk-08-07-25
  234.       */
  235.     public function getContent($chaShowMode=0,$debug=False
  236.     {           
  237.         if ($debugechoDebugMethod(__FILE__,get_class($this),"CMS_PHPINC_PAGE::getContent($chaShowMode)","<pre>" print_r($this->getDBVal(),True"</pre>");
  238.  
  239.         if (($chaShowMode == 0))
  240.         {
  241.             if ($this->getContentCalled())
  242.             {
  243.                 throw new Exception('content called twice');
  244.             else {
  245.                 $this->setContentCalled(True);
  246.             }
  247.         }        
  248.                 
  249.         if (($chaShowMode != CHAPTER_SHOWMODE_PROGRAMM&& ($chaShowMode != 0))
  250.         {
  251.             return parent::getContent($chaShowMode,$debug);
  252.         else {
  253.             
  254.             $str_ret="";
  255.             if ($chaShowMode != CHAPTER_SHOWMODE_PROGRAMM)
  256.             {
  257.                 $str_ret .= $this->getContent(CHAPTER_SHOWMODE_ALLWAYS_TOP,$debug)
  258.             }
  259.  
  260.             $str_ret .= $this->renderProduct($debug);
  261.  
  262.             if ($chaShowMode != CHAPTER_SHOWMODE_PROGRAMM)
  263.             {
  264.                 $str_ret.=$this->getContent(CHAPTER_SHOWMODE_ALLWAYS_BOTTOM)
  265.             }            
  266.             
  267.             return $str_ret;            
  268.         }
  269.     }    
  270.         
  271. }
  272.  
  273. ?>

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