Source for file OCSP_FRMCONTR_LIST_FLEXGRID.phpclass

Documentation is available at OCSP_FRMCONTR_LIST_FLEXGRID.phpclass

  1. <?php
  2. /**
  3.   * openCSP class file
  4.   *
  5.   * @project Open CSP-Management
  6.   * @package default
  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-29.05.2008
  12.   * @version $Id: OCSP_FRMCONTR_LIST_FLEXGRID.phpclass,v 1.8 2008/09/02 07:07:18 pitlinz Exp $
  13.   */
  14.  
  15. // ---------------------------------------------------------
  16. // requirements
  17. // ---------------------------------------------------------
  18.  
  19. if (!class_exists('OCSP_FRMCONTR_LIST'))
  20. {
  21.     require dirname(__FILE___OCSP_DIRSEP_ "OCSP_FRMCONTR_LIST.phpclass";
  22. }
  23.  
  24. /**
  25.   * openCSP class file
  26.   *
  27.   * @project Open CSP-Management
  28.   * @package default
  29.   *
  30.   * @author Peter Krebs <pitlinz@users.sourceforge.net>
  31.   * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  32.   *
  33.   * @since pk-29.05.2008
  34.   * @version $Id: OCSP_FRMCONTR_LIST_FLEXGRID.phpclass,v 1.8 2008/09/02 07:07:18 pitlinz Exp $
  35.   */
  36. {
  37.     /*** class constants  --------------------------------------------- */
  38.  
  39.     /**
  40.      * @constant string CLASS_SRC_FILE
  41.      *
  42.      * @abstract
  43.      */
  44.     const CLASS_SRC_FILE = __FILE__;
  45.     
  46.     /*** compostion --------------------------------------------------- */
  47.     
  48.     /*** attributes  -------------------------------------------------- */
  49.     
  50.     /**
  51.      * @var string $myJsonUrl 
  52.      */
  53.     protected $myJsonUrl "";
  54.     
  55.     /*** factory / construct  ----------------------------------------- */
  56.     
  57.     /*** getter / setter ---------------------------------------------- */
  58.     
  59.     /**
  60.      * @param string 
  61.      */
  62.     public function setJsonUrl($aUrl)
  63.     {
  64.         $this->myJsonUrl $aUrl;
  65.     }
  66.     
  67.     /**
  68.      * @return string 
  69.      */
  70.     public function getJsonUrl()
  71.     {
  72.         if (empty($this->myJsonUrl))
  73.         {
  74.             $this->myJsonUrl OCSP_OBJ::getConf('jOCSPURL'"flexgridRPC.php";
  75.         
  76.         $str_url pcf_HTML_changeURI_GetValue($this->myJsonUrl,'lstKey',$this->getListKey());
  77.         $str_url pcf_HTML_changeURI_GetValue($str_url,'lstFRM_ID',$this->myForm->getId());
  78.         return $str_url;
  79.     }
  80.     
  81.     /**
  82.      * returns the jason string for a page
  83.      *
  84.      * @param int $page 
  85.      * @param int $rp 
  86.      * @param string $sortname 
  87.      * @param string $sortorder 
  88.      * @param string $qtype (filter column name)
  89.      * @param string $query (filter value)
  90.      * @param boolean $debug 
  91.      * 
  92.      * @return string 
  93.      * 
  94.      */
  95.     public function getJsonPage($page,$rp,$sortname,$sortorder,$qtype="",$query="",$debug=False)
  96.     {        
  97.                 
  98.         ob_start();    
  99.         $str_debug="";
  100.         $this->setOffset((intval($page)-1$rp);
  101.         $this->setLimit($rp);
  102.  
  103.         if (!empty($query&& (strtolower($query!= "undefined"))
  104.         {
  105.             if (intval($query))
  106.             {
  107.                 $this->myFilter['?FLEXGRID' $qtype" $qtype =$query;
  108.             else {
  109.                 $bol_like False;
  110.                 if (strstr($query,"*"))
  111.                 
  112.                     $query=str_replace("*","%",$query);
  113.                     $bol_like=True
  114.                 else if (strstr($query,"%")) {
  115.                     $bol_like=True;
  116.                 }
  117.                 
  118.                 if ($bol_like)
  119.                 {
  120.                     $this->myFilter['?FLEXGRID' $qtype" UPPER($qtypeLIKE 'strtoupper($query"'";
  121.                 else {
  122.                     $this->myFilter['?FLEXGRID' $qtype" UPPER($qtypeLIKE 'strtoupper($query"%'";
  123.                 }
  124.                 
  125.             }
  126.         }
  127.         
  128.         if (!empty($sortname&& (strtolower($sortname!= "undefined"))
  129.         {
  130.             $str_orderBy $sortname;
  131.             if (!empty($sortorder&& (strtolower($sortorder!= "undefined")) 
  132.             {
  133.                 $str_orderBy .= " " $sortorder;
  134.             }
  135.             $this->setOrderBy($str_orderBy);
  136.         }
  137.         
  138.         $str_ret     "{";
  139.         
  140.         $str_ret .= "page: " $page;
  141.         $str_ret .= ",total: " $this->getNofTotalRows();
  142.         
  143.         $arr_cols     array();
  144.         $arr_idCols array();
  145.          
  146.         if ($arr_fields $this->myForm->getFields(Null,$debug))
  147.         {            
  148.             foreach($arr_fields as &$obj_fld)
  149.             {
  150.                 if ($debug$str_debug .= "Fld: ".$obj_fld->getName()." ";
  151.                 if (!$obj_fld->isHidden('flexgrid'))
  152.                 {
  153.                     $arr_cols[$obj_fld->getName();
  154.                 }    
  155.  
  156.                 if ($obj_fld->isPrimaryKey())
  157.                 {
  158.                     $arr_idCols[$obj_fld->getName();
  159.                 }
  160.             }
  161.         }
  162.         
  163.         $str_debug.= " FIELDLIST: " implode('|',array_merge($arr_cols,$arr_idCols));
  164.                 
  165.         $str_ret .= ",rows: [";
  166.         $cha_rowSep "";        
  167.         
  168.         $arr_LeftButtons     $this->myView->getPosButtons(-1);
  169.         $arr_RightButtons     $this->myView->getPosButtons(1);
  170.         
  171.         while($arr_row $this->getListRow($debug))
  172.         {
  173.             if (sizeof($arr_idCols== 1)
  174.             {
  175.                 $str_rowId $arr_row[$arr_idCols[0]];
  176.             else {
  177.                 $str_rowid "";
  178.                 $cha_sep "";                
  179.                 foreach($arr_idCols as $str_colName)
  180.                 {
  181.                     $str_rowId .= $cha_sep $str_colName."-".$arr_row[$str_colName];
  182.                     $cha_sep '_';
  183.                 }
  184.             }
  185.             
  186.             $str_ret .= $cha_rowSep "{id: '" .$str_rowId "',cell:[";
  187.             
  188.             $cha_sep="";            
  189.             if (sizeof($arr_LeftButtons))
  190.             {
  191.                 $str_buttons "";
  192.                 foreach($arr_LeftButtons as $str_cmd)
  193.                 {
  194.                     $str_buttons .= "<a href=\"#\" " pcf_tmpl_parse($this->tbl_rowBtnCmds[$str_cmd],$arr_row">";
  195.                     $str_buttons .= $this->myView->getButtonImgTag($str_cmd);
  196.                     $str_buttons .= "</a>";
  197.                 }
  198.                 
  199.                 $str_ret .= $cha_sep "'" pcf_js_escape($str_buttons."'";
  200.                 $cha_sep ",";
  201.             }
  202.             
  203.             foreach($arr_cols as $str_colName)
  204.             {
  205.                 $str_ret .= $cha_sep ."'" pcf_js_escape($this->myForm->getField($str_colName)->getListValue($arr_row[$str_colName])) "'";
  206.                 $cha_sep ',';
  207.             }
  208.             
  209.  
  210.             if (sizeof($arr_RightButtons))
  211.             {
  212.                 $str_buttons "";
  213.                 foreach($arr_RightButtons as $str_cmd)
  214.                 {
  215.                     $str_buttons .= "<a href=\"#\" " pcf_tmpl_parse($this->tbl_rowBtnCmds[$str_cmd],$arr_row">";
  216.                     $str_buttons .= $this->myView->getButtonImgTag($str_cmd);
  217.                     $str_buttons .= "</a>";
  218.                 }
  219.                 
  220.                 $str_ret .= $cha_sep "'" pcf_js_escape($str_buttons."'";
  221.                 $cha_sep ",";
  222.             }            
  223.             
  224.             $str_ret .= "]}";
  225.             $cha_rowSep ",";
  226.         }
  227.                 
  228.         $str_ret .= "]";
  229.         if ($debug
  230.         {
  231.             $str_ret .= ", debug: '" pcf_js_escape($str_debug"'";
  232.             $str_ret .= ", lstQuery: '" pcf_js_escape($this->getListQuery()) ."'";
  233.             $str_ret .= ", obOutput: '" pcf_js_escape(ob_get_contents()) "'";
  234.         }
  235.         ob_end_clean();
  236.         $str_ret .= "}";
  237.         
  238.         return $str_ret;
  239.     }
  240. }
  241.  
  242. ?>

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