Source for file OCSP_FRMVIEW.phpclass

Documentation is available at OCSP_FRMVIEW.phpclass

  1. <?php
  2. /**
  3.   * Class file OCSP_FRMVIEW.phpclass
  4.   *
  5.   *
  6.   * @project    Open CSP-Management
  7.   * @package    forms
  8.   * @category   dbms_form
  9.   *
  10.   * @author     Peter Krebs (pk) <pitlinz@users.sourceforge.net>
  11.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  12.   *
  13.   * @since  pk-07-06-30
  14.   *
  15.   ***/
  16.  
  17. require_once dirname(__FILE__)."/languages/de.phpinc";
  18.  
  19. /**
  20.   * class OCSP_FRMVIEW
  21.   *
  22.   * @project    Open CSP-Management
  23.   * @package    forms
  24.   * @category   dbms_form
  25.   *
  26.   * @author     Peter Krebs (pk) <pitlinz@users.sourceforge.net>
  27.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  28.   *
  29.   * @since  pk-07-06-30
  30.   *
  31.   */
  32. {
  33.  
  34.     /*** Aggregations: */
  35.  
  36.  
  37.     /*** Compositions: */
  38.  
  39.     /**
  40.       * @var OCSP_FORM $myForm 
  41.       * @access protected
  42.       */
  43.     protected $myForm=NULL;
  44.  
  45.     /**
  46.       * @var array $myBlocks 
  47.       * @access protected
  48.       */
  49.     protected $myBlocks=array();
  50.  
  51.     /**
  52.       * @var array $myFields 
  53.       * @access protected
  54.       */
  55.     protected $myFields=array();
  56.  
  57.  
  58.     /*** Attributes: */
  59.  
  60.     /**
  61.       * an array of tags to show
  62.       * $btnTags[CMDNAME]=TAGTMPL
  63.       * @var array $btnTags 
  64.       * @access protected
  65.       */
  66.     protected $btnTags=array();
  67.     
  68.     /**
  69.      * array with button positions
  70.      * 
  71.      * - <0: left
  72.      * - >0: rigth
  73.      * 
  74.      * @var array $btnPos 
  75.      * @access protected
  76.      * 
  77.      * @since pk-08-06-02
  78.      */
  79.     protected $btnPos = array();
  80.  
  81.     /**
  82.       * the default icon size
  83.       * is used to select the icon dir
  84.       * @var string 
  85.       * @access proteced
  86.       */
  87.     protected $btnIconSize="22x22";
  88.  
  89.  
  90.  
  91.     /*** Association */
  92.  
  93.     /**
  94.       * @var OCSP_FRMCONTR $myControl 
  95.       * @access protected
  96.       */
  97.     protected $myControl;
  98.  
  99.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  100.     // init methods
  101.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  102.  
  103.     /**
  104.       * @param OCSP_FORM $aForm 
  105.       * @param boolean $debug 
  106.       */
  107.     function OCSP_FRMVIEW(&$aForm,$debug=FALSE)
  108.     {
  109.         $this->setMyForm($aForm);
  110.     }
  111.  
  112.  
  113.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  114.     // getter/setter methods
  115.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  116.  
  117.     /**
  118.       * @return OCSP_FORM 
  119.       */
  120.     function &getMyForm()
  121.     {
  122.         return $this->myForm;
  123.     }
  124.  
  125.     /**
  126.       * @param OCSP_FORM $aForm 
  127.       */
  128.     function setMyForm(&$aForm)
  129.     {
  130.         $this->myForm=&$aForm;
  131.     }
  132.  
  133.     /**
  134.      * alias for setControl
  135.      * 
  136.      * @param OCSP_FRMCONTR $aControll 
  137.      * 
  138.      * @deprecated since pk-08-12-03
  139.      */
  140.     public function setControll(&$aControl)
  141.     {
  142.         $this->setControl($aControl);
  143.     }
  144.  
  145.     /**
  146.      * sets the control object
  147.      *
  148.      * @param OCSP_FRMCONTR $aControl 
  149.      */
  150.     public function setControl(&$aControl)
  151.     {
  152.         $this->myControl=&$aControl;
  153.     }
  154.     
  155.     /**
  156.      * returns the control object
  157.      *
  158.      * @return OCSP_FRMCONTR 
  159.      */
  160.     public function getControl()
  161.     {
  162.         if (!pcf_is_instance_of($this->myControl,"OCSP_FRMCONTR"))
  163.         {
  164.             $this->myControl = $this->getMyForm()->getControl();
  165.         }
  166.         return $this->myControl;
  167.     }
  168.     
  169.     /**
  170.       * @returns int
  171.       * @since pk-05-11-04
  172.       ***/
  173.     function getFrmMode({
  174.         return $this->myForm->getFrmMode();
  175.     }
  176.  
  177.     /**
  178.       * @param int $mode 
  179.       * @since pk-05-11-04
  180.       ***/
  181.     function setFrmMode($mode{
  182.         $this->myForm->setFrmMode($mode);
  183.     }
  184.  
  185.  
  186.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  187.     // db methods
  188.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  189.  
  190.     /**
  191.       * returns the db object from the form
  192.       *
  193.       * @param boolean $debug 
  194.       * @return OCSP_DB 
  195.       */
  196.     function &getDBObj($debug=FALSE)
  197.     {
  198.         if (!pcf_is_instance($this->myForm,'OCSP_FORM'))
  199.         {
  200.             $obj_ret=NULL;
  201.             return $obj_ret;
  202.         else {
  203.             return $this->myForm->getDBObj($debug);
  204.         }
  205.     }
  206.  
  207.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  208.     // block methods
  209.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  210.  
  211.     /**
  212.       * unsets $this->myBlocks
  213.       */
  214.     function unsetBlocks()
  215.     {
  216.         $this->myBlocks=array();
  217.         $this->myFields=array();
  218.     }
  219.  
  220.     /**
  221.       * @param int $aMode 
  222.       * @param boolean $debug 
  223.       * @return array 
  224.       */
  225.     function getBlocksMode($aMode,$debug=FALSE)
  226.     {
  227.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW::getBlocksMode($aMode)");
  228.         if (sizeof($this->myBlocks))
  229.         {
  230.             if ($debugechoDebugLine(__FILE__,__LINE__,"returning stored blocks");
  231.             return $this->myBlocks;
  232.         }
  233.         $arr_blocks=$this->myForm->getBlocks($debug);
  234.         $arr_ret=array();
  235.         foreach($arr_blocks as &$obj_block)
  236.         {
  237.             if ($obj_block->isToShow($aMode,$debug))
  238.             {
  239.                 $this->myBlocks[$obj_block->getId()]=&$obj_block;
  240.             }
  241.         }
  242.         return $this->myBlocks;
  243.     }
  244.  
  245.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  246.     // fields methods
  247.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  248.  
  249.     /**
  250.       * @param int $aMode 
  251.       * @param boolean $debug 
  252.       *
  253.       * @return array of DBMS_FIELDS
  254.       */
  255.     function getFieldsMode($aMode,$debug=FALSE)
  256.     {
  257.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW::getFieldsMode($aMode)");
  258.         if (sizeof($this->myFields))
  259.         {
  260.             if ($debugechoDebugLine(__FILE__,__LINE__,"returning stored fields");
  261.             return $this->myFields;
  262.         }
  263.  
  264.         if ($this->getBlocksMode($aMode,$debug))
  265.         {
  266.             foreach($this->myBlocks as &$obj_block)
  267.             {
  268.                 $arr_flds=$obj_block->getFields($aMode,$debug);
  269.                 //echoDebugLine(__FILE__,__LINE__,"\$arr_flds: <pre>".print_r($arr_flds,TRUE)."</pre>");
  270.                 foreach($arr_flds as &$obj_fld)
  271.                 {
  272.                     $obj_fld->setView($this);
  273.                     $this->myFields[]=&$obj_fld;
  274.                 }
  275.             }
  276.             return $this->myFields;
  277.         else {
  278.             ocsp_logError(__FILE__,__LINE__,"could not load field blocks for mode $aMode");
  279.             return array();
  280.         }
  281.     }
  282.  
  283.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  284.     // button methods
  285.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  286.  
  287.     /**
  288.       * sets the button icon size
  289.       * NOTE this is used to get icon path in sysimages
  290.       * @param string $aSize (example "16x16")
  291.       */
  292.     function setButtonIconSize($aSize)
  293.     {
  294.         $this->btnIconSize=$aSize;
  295.     }
  296.  
  297.     /**
  298.      * alias for setButtonImageTag
  299.      * @param string $aCmd 
  300.      * @param string $imgTag 
  301.      * 
  302.      * @deprecated since pk-08-11-24
  303.      */
  304.     function setButtonTag($aCmd,$imgTag)
  305.     {
  306.         $this->setButtonImageTag($aCmd,$imgTag);
  307.     }
  308.     
  309.     /**
  310.      * sets the button tag
  311.      * 
  312.      * buttons are enclosed by an <a>-tag which does the function.
  313.      *
  314.      * @param string $aCmd 
  315.      * @param string $imgTag 
  316.      * 
  317.      * @since pk-08-11-24
  318.      */
  319.     public function setButtonImageTag($aCmd,$imgTag)
  320.     {
  321.         $this->btnTags[$aCmd]=$imgTag;
  322.     }
  323.     
  324.     /**
  325.      * @param string $aCmd 
  326.      * @param int $pos 
  327.      * 
  328.      * @version pk-08-06-02
  329.      */
  330.     function setButtonPos($aCmd,$pos)
  331.     {
  332.         if (intval($pos0)
  333.         {
  334.             $this->btnPos[-1][$aCmd;
  335.         else {
  336.             $this->btnPos[1][$aCmd;
  337.         }
  338.     }
  339.     
  340.     /**
  341.      * returns the button commands on pos
  342.      * 
  343.      * @param int $pos 
  344.      * 
  345.      * @return array 
  346.      */
  347.     public function getPosButtons($pos)
  348.     {
  349.         $arr_ret array();
  350.         if (intval($pos== 0)
  351.         {
  352.             if (isset($this->btnPos[-1]&& is_array($this->btnPos[-1]))
  353.             {
  354.                 $arr_ret $this->btnPos[-1];
  355.             }
  356.             
  357.             if (isset($this->btnPos[1]&& is_array($this->btnPos[1]))
  358.             {
  359.                 foreach($this->btnPos[1as $str_cmd)
  360.                 {
  361.                     $arr_ret[$str_cmd;
  362.                 }
  363.             }
  364.         else if (intval($pos0{
  365.             if (isset($this->btnPos[-1]&& is_array($this->btnPos[-1]))
  366.             {
  367.                 $arr_ret $this->btnPos[-1];
  368.             }
  369.         else {
  370.             if (isset($this->btnPos[1]&& is_array($this->btnPos[1]))
  371.             {
  372.                 $arr_ret $this->btnPos[1];
  373.             }
  374.         }
  375.         
  376.         return $arr_ret;
  377.     }
  378.  
  379.     /**
  380.       * returns the buttion image tag
  381.       * @param string $aCmd 
  382.       * @param boolean $debug 
  383.       *
  384.       * @global array $OCSP_CONF 
  385.       *
  386.       * @return string 
  387.       *
  388.       */
  389.     function getButtonImgTag($aCmd,$debug=FALSE)
  390.     {
  391.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW::getButtonImgTag($aCmd)");
  392.         if (isset($this->btnTags[$aCmd]))
  393.         {
  394.             return $this->myControl->parseRowTmpl($this->btnTags[$aCmd],$debug);
  395.         else {
  396.             $str_iconPath=OCSP_CONF::getInstance()->getValue('HTSYSTEMPATH')."system"._OCSP_DIRSEP_."sysimages"._OCSP_DIRSEP_."icons-".$this->btnIconSize._OCSP_DIRSEP_;
  397.             if ($debugechoDebugLine(__FILE__,__LINE__,"IconPath$str_iconPath");
  398.             $str_img="";
  399.             if (file_exists($str_iconPath.strtolower($aCmd).".gif"))
  400.             {
  401.                 $str_img=strtolower($aCmd).".gif";
  402.             else if (file_exists($str_iconPath.strtolower($aCmd).".png")) {
  403.                 $str_img=strtolower($aCmd).".png";
  404.             else if (file_exists($str_iconPath.strtolower($aCmd).".jpg")) {
  405.                 $str_img=strtolower($aCmd).".jpg";
  406.             }
  407.             if (!empty($str_img))
  408.             {
  409.                 return "<img src=\"" OCSP_CONF::getInstance()->getValue('SYSIMGURL'"icons-".$this->btnIconSize."/$str_img\" alt=\"$aCmd\" border=\"0\" class=\"button\">";
  410.             else {
  411.                 switch(strtolower($aCmd))
  412.                 {
  413.                     case "delete":
  414.                         return "<img src=\"" OCSP_CONF::getInstance()->getValue('SYSIMGURL'"icons-".$this->btnIconSize."/edittrash.gif\" alt=\"$aCmd\" border=\"0\" class=\"button\">";
  415.                     default:
  416.                         return $aCmd;
  417.                 }
  418.                 
  419.             }
  420.         }
  421.     }
  422.  
  423.  
  424.  
  425. // end of OCSP_FRMVIEW
  426. ?>

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