Source for file OCSP_FRMVIEW_LIST.phpclass

Documentation is available at OCSP_FRMVIEW_LIST.phpclass

  1. <?php
  2. /**
  3.   * Class file OCSP_FRMVIEW_LIST.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__)."/OCSP_FRMVIEW.phpclass";
  18. require_once __OCSP_PHPINCPATH__ "common"  _OCSP_DIRSEP_ "pcf_templates.phpinc";
  19.  
  20.  
  21. /**
  22.   * class OCSP_FRMVIEW_LIST
  23.   *
  24.   * @project    Open CSP-Management
  25.   * @package    forms
  26.   * @category   dbms_form
  27.   *
  28.   * @author     Peter Krebs (pk) <pitlinz@users.sourceforge.net>
  29.   * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
  30.   *
  31.   * @since  pk-07-06-30
  32.   *
  33.   */
  34. {
  35.  
  36.     /*** Aggregations: */
  37.  
  38.  
  39.     /*** Compositions: */
  40.  
  41.  
  42.     /*** Attributes: */
  43.  
  44.     /**
  45.       * @var string $tbl_summary 
  46.       * @access protected
  47.       * @see http://www.w3.org/TR/html4/struct/tables.html#adef-summary
  48.       */
  49.     protected $tbl_summary="";
  50.  
  51.     /**
  52.       * @var string $tbl_caption 
  53.       * @access protected
  54.       * @see http://www.w3.org/TR/html4/struct/tables.html#edef-CAPTION
  55.       */
  56.     protected $tbl_caption="";
  57.  
  58.     /**
  59.       * the default icon size
  60.       * is used to select the icon dir
  61.       * @var string 
  62.       * @access proteced
  63.       */
  64.     protected $btnIconSize="16x16";
  65.  
  66.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  67.     // init methods
  68.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  69.  
  70.  
  71.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  72.     // getter/setter methods
  73.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  74.  
  75.  
  76.     /**
  77.       * @param boolean $debug 
  78.       * @return array 
  79.       */
  80.     function getFields($debug=FALSE)
  81.     {
  82.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_LIST::getFields()");
  83.         return $this->getFieldsMode(FRM_MODE_LIST,$debug);
  84.     }
  85.  
  86.     /**
  87.       * @return int 
  88.       */
  89.     function getNbrOfColumns()
  90.     {
  91.         return (sizeof($this->myFields)+$this->myControl->getNofBtnCols());
  92.     }
  93.  
  94.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  95.     // output
  96.     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  97.  
  98.     /**
  99.       * @param boolean $debug 
  100.       * @return string 
  101.       */
  102.     function getTableStart($debug=False)
  103.     {
  104.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_LIST::getTableStart()");
  105.         $str_ret="<table id=\"".$this->myControl->getTableId()."\"";
  106.         $str_ret.=$this->myControl->getTableEvents($debug);
  107.         if (!empty($this->tbl_summary))
  108.         {
  109.             $str_ret.=" summary=\"".htmlspecialchars($this->tbl_summary)."\"";
  110.         }
  111.         $str_ret.=" ".$this->getMyForm()->getLayoutField('FRMLST_TABLEADD');
  112.         $str_ret.=">";
  113.         if (!empty($this->tbl_caption))
  114.         {
  115.             $str_ret.="<caption>".$this->tbl_caption."</caption>";
  116.         }
  117.         return $str_ret."\n";
  118.     }
  119.  
  120.     /**
  121.       * @param boolean $debug 
  122.       * @return string 
  123.       */
  124.     function getTableHeader($debug=False)
  125.     {
  126.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_LIST::getTableHeader()");
  127.         
  128.         
  129.         
  130.         $str_ret="<thead " $this->getMyForm()->getLayoutField('FRMLST_THEADADD'">";
  131.         $str_ret.="<tr ".$this->myControl->getHeadRowEvents().">";
  132.  
  133.         foreach($this->myFields as &$obj_field)
  134.         {
  135.             if (!$obj_field->isHidden('list'))
  136.             {
  137.                 $str_ret.="<th ".$this->myControl->getHeadColEvents($obj_field)." " $this->getMyForm()->getLayoutField('FRMLST_THADD'">";
  138.                 $str_ret.=$obj_field->getLstLabel();
  139.                 $str_ret.="</th>";
  140.             }
  141.         }
  142.         if ($i_btnCosl=$this->myControl->getNofBtnCols())
  143.         {
  144.             $str_ret.="<th colspan=\"".$i_btnCosl."\">&nbsp;</th>";
  145.         }
  146.  
  147.         $str_ret.="</tr>";
  148.         $str_ret.="</thead>";
  149.         return $str_ret."\n";
  150.     }
  151.  
  152.     /**
  153.       * @param boolean $debug 
  154.       * @return string 
  155.       */
  156.     function getTableFooter($debug=False)
  157.     {
  158.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_LIST::getTableFooter()");
  159.         if ($str_footerTag=$this->myControl->getFooterLinks($debug))
  160.         {
  161.             $str_ret ="<tfoot>";
  162.             $str_ret.="<tr>";
  163.             $str_ret.="<th colspan=\"".$this->getNbrOfColumns()."\" align=\"left\">";
  164.              $str_ret.=$str_footerTag;
  165.             $str_ret.="</th>";
  166.             $str_ret.="</tr>";
  167.             $str_ret.="</tfoot>\n";
  168.             return $str_ret;
  169.         else {
  170.             return "";
  171.         }
  172.     }
  173.  
  174.     
  175.     /**
  176.      * returns the html code for the cells in the body (without <tr>)
  177.      *
  178.      * @param array $rowVals 
  179.      * @param boolean $debug 
  180.      * 
  181.      * @return string (html)
  182.      * 
  183.      * @since pk-08-01-21
  184.      */
  185.     function getBodyRowCols($rowVals,$debug)
  186.     {
  187.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_LIST::getBodyRowCols(()");
  188.         
  189.         $str_globalArrName="LISTROW_".$this->myForm->getId();
  190.         global ${$str_globalArrName};
  191.         ${$str_globalArrName}=$rowVals;
  192.         
  193.         $str_ret="";
  194.         
  195.         foreach($this->myFields as &$obj_field)
  196.         {
  197.             if (!$obj_field->isHidden('list'))
  198.             {
  199.                 $str_ret.="<td ".$this->myControl->getColCmd($obj_field,$debug)." "pcf_tmpl_parse($obj_field->get_lstTDAdd(),$this->myControl->getCurRow()) ">";
  200.                 if ($str_link=$this->myControl->getColLink($obj_field,$debug))
  201.                 {
  202.                     $str_ret.=$str_link;
  203.                   }
  204.                 $mix_listValue=(isset($rowVals[$obj_field->getName()]$rowVals[$obj_field->getName()NULL);
  205.                 $str_ret.=$obj_field->getListValue(pcf_gerHTMLspecialChars($mix_listValue),$str_globalArrName,$debug);
  206.                 if (!empty($str_link))
  207.                 {
  208.                     $str_ret.=$this->myControl->getColLinkEnd($obj_field,$debug);
  209.                 }
  210.                    $str_ret.="</td>";
  211.             }
  212.           }
  213.           
  214.         $str_ret.=$this->myControl->getRowButtons("td class=\"imgWidth16\"","a",$debug);
  215.  
  216.         return $str_ret;
  217.         
  218.     }
  219.     
  220.     /**
  221.      * returns the html code for the body rows
  222.      *  
  223.      * @param boolean $debug 
  224.      * 
  225.      * @return string (html)
  226.      * 
  227.      * @version pk-08-01-21
  228.      */
  229.     function getTableBodyRows($debug=FALSE)
  230.     {
  231.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_LIST::getTableBodyRows()");
  232.         $str_ret="";$str_class="even";
  233.  
  234.         $str_globalArrName="LISTROW_".$this->myForm->getId();
  235.         global ${$str_globalArrName};
  236.         
  237.         while($arr_row=$this->myControl->getListRow($debug))
  238.         {
  239.             ${$str_globalArrName}=$arr_row;
  240.             $str_ret.=$this->myControl->getListGroups($debug);
  241.             if ($str_class != "odd"$str_class="odd";
  242.             else $str_class="even";
  243.             $str_rowId=$this->myControl->getRowId();
  244.             if (!empty($str_rowId)) $str_rowId=" id=\"$str_rowId\" ";
  245.             $str_ret.="<tr $str_rowId".$this->myControl->getRowCmd($debug)." class=\"".$str_class."\">";
  246.  
  247.             $str_ret.=$this->getBodyRowCols($arr_row,$debug);
  248.             
  249.             $str_ret.="</tr>\n";
  250.         }
  251.         return $str_ret;
  252.     }
  253.  
  254.     /**
  255.       * returns the headline for a list group
  256.       *
  257.       * @param string $col 
  258.       * @param array $row 
  259.       * @param boolean $debug 
  260.       *
  261.       * @return string 
  262.       *
  263.       * @requres pcf_templates.phpinc
  264.       *
  265.       * @since pk-07-10-16
  266.       */
  267.     function getGroupRow($col,$row,$debug)
  268.     {
  269.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_LIST::getGroupRow($col)");
  270.  
  271.         $str_ret="";
  272.         $arr_lstGroups=$this->myForm->get_listGroups();
  273.         if (isset($arr_lstGroups[$col]&& is_array($arr_lstGroups[$col]))
  274.         {
  275.             require_once __OCSP_PHPINCPATH__."common"._OCSP_DIRSEP_."pcf_templates.phpinc";
  276.             $str_ret.="<tr >";
  277.             $str_ret.="<td colspan=\"".$this->getNbrOfColumns()."\"";            
  278.             if (isset($arr_lstGroups[$col]['CSSCLASS'])  && !empty($arr_lstGroups[$col]['CSSCLASS']))
  279.             {
  280.                 $str_ret.=" class=\"".$arr_lstGroups[$col]['CSSCLASS']."\" ";
  281.             }
  282.             if (isset($arr_lstGroups[$col]['CSSSTYLE']&& !empty($arr_lstGroups[$col]['CSSSTYLE']))
  283.             {
  284.                 $str_ret.=" style=\"".$arr_lstGroups[$col]['CSSSTYLE']."\" ";
  285.             }
  286.             $str_ret.=">";
  287.             if (isset($arr_lstGroups[$col]['TMPL']&& !empty($arr_lstGroups[$col]['TMPL']))
  288.             {
  289.                 $str_ret.=pcf_tmpl_parse($arr_lstGroups[$col]['TMPL'],$row);
  290.             else {
  291.                 $str_ret.=$row[$col];
  292.             }
  293.  
  294.             $str_ret.="</td></tr>";
  295.             //<pre>".print_r($arr_lstGroups[$col],TRUE)."</pre></td></tr>";
  296.         }
  297.  
  298.         return $str_ret;
  299.     }
  300.  
  301.     /**
  302.       * @param boolean $debug 
  303.       * @return string 
  304.       */
  305.     function getTableBodyStart($debug)
  306.     {
  307.         return "<tbody id=\"tbody_".$this->myControl->getTableId()."\">\n";
  308.     }
  309.  
  310.     /**
  311.       * @param boolean $debug 
  312.       * @return string 
  313.       */
  314.     function getTableBody($debug=FALSE)
  315.     {             
  316.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_LIST::getTableBody()");
  317.  
  318.         $int_nofRows=$this->myControl->loadListValues($debug);           
  319.         if (intval($int_nofRows))
  320.         {
  321.             $str_class="";
  322.             $str_ret =$this->getTableBodyStart($debug);
  323.             $str_ret.=$this->getTableBodyRows($debug);
  324.             $str_ret.="</tbody>\n";
  325.             return $str_ret;
  326.         else {
  327.             $str_ret =$this->getTableBodyStart($debug);
  328.             $str_ret.="<tr><td colspan=\"".$this->getNbrOfColumns()."\">Keine Datens&auml;tze gefunden</td></tr>";
  329.             $str_ret.="</tbody>\n";
  330.             return $str_ret;
  331.         }
  332.     }
  333.  
  334.     /**
  335.      * returns the list HTML code
  336.      * 
  337.      * @param boolean $debug 
  338.      * 
  339.      * @return string 
  340.      */
  341.     function getList($debug=False)
  342.     {  
  343.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_LIST::getList()");
  344.  
  345.         $str_ret =$this->getTableStart($debug);
  346.         $str_ret.=$this->getTableHeader($debug);
  347.         $str_ret.=$this->getTableFooter($debug);
  348.         $str_ret.=$this->getTableBody($debug);
  349.  
  350.  
  351.         $str_ret.="</table>";
  352.         return $str_ret;
  353.     }
  354.  
  355.     
  356.     function getCSV($strFileName=Null,$charset="UTF-8",$debug=False)
  357.     {
  358.         if ($debugechoDebugMethod(__FILE__,get_class($this),"OCSP_FRMVIEW_LIST::getCSV()");
  359.         pcf_require_class('OCSP_BROWSER',"common/");
  360.         
  361.         if (empty($str_FileName)) 
  362.         {
  363.             $str_FileName $this->getMyForm()->getName(".csv";
  364.         }
  365.         
  366.         header("Pragma: public");
  367.         header("Expires: 0");
  368.         header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  369.         header("Content-Type: text/cvs; charset=".$charset);
  370.         header("Last-Modified: " gmdate("D, d M Y H:i:s"" GMT");        
  371.         
  372.         if (OCSP_BROWSER::getInstance()->isIE())
  373.         {
  374.             header("Content-Disposition: filename=".$strFileName);
  375.         else {
  376.             header"Content-Disposition: attachment; filename=".$strFileName);
  377.         }
  378.  
  379.         $bol_headerRow False;
  380.         while($arr_row=$this->myControl->getListRow($debug))
  381.         {
  382.             
  383.             if (!$bol_headerRow)
  384.             {
  385.                 $str_header "";
  386.                 foreach($arr_row as $str_col => $mix_val)
  387.                 {
  388.                     $str_header .= '"' $str_col '";';
  389.                 }
  390.  
  391.                 $str_header substr($str_header,0,-1);
  392.                 $str_header str_replace("\n"," ",$str_header);
  393.                 $str_header str_replace("\r"," ",$str_header);
  394.             
  395.                 if (OCSP_BROWSER::getInstance()->isIE())
  396.                 {
  397.                     echo $str_header "\r\n";
  398.                 else {
  399.                     echo $str_header "\n";
  400.                 }       
  401.  
  402.                 $bol_headerRow True;
  403.                 
  404.             }
  405.             $str_line="";            
  406.             foreach($arr_row as $str_col => $mix_val)
  407.             {                
  408.                 
  409.                 switch(True)
  410.                 {
  411.                     case (is_null($mix_val)):
  412.                         $str_line .= ";";
  413.                         break;                    
  414.                     case (is_int($mix_val)):
  415.                     case (is_float($mix_val)):
  416.                     case (is_double($mix_val)):
  417.                         $str_line .= $mix_val ";";
  418.                         break;
  419.                     case (is_bool($mix_val)):
  420.                         $str_line .= ($mix_val "1" "0"";";
  421.                         break;
  422.                     case (is_array($mix_val)):
  423.                         $mix_val implode(',',$mix_val);
  424.                     default:
  425.                         if ($charset == "UTF-8")
  426.                         {
  427.                             if (!OCSP_OBJ::isUTF8($mix_val))
  428.                             {
  429.                                 $mix_val utf8_encode($mix_val);
  430.                             }
  431.                         else if (OCSP_OBJ::isMultiByteStr()) {
  432.                             $mix_val utf8_decode($mix_val);
  433.                         }
  434.                         $str_line .= '"' str_replace('"',"'",$mix_val'";';
  435.                 }                     
  436.               }
  437.                     
  438.               $str_line substr($str_line,0,-1);
  439.             $str_line str_replace("\n"," ",$str_line);
  440.             $str_line str_replace("\r"," ",$str_line);
  441.             
  442.             if (OCSP_BROWSER::getInstance()->isIE())
  443.             {
  444.                 echo $str_line "\r\n";
  445.             else {
  446.                 echo $str_line "\n";
  447.             }              
  448.         }
  449.     }
  450.     
  451.  
  452. // end of OCSP_FRMVIEW_LIST
  453. ?>

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