Source for file OCSP_FRMCONTR_LIST.phpclass
Documentation is available at OCSP_FRMCONTR_LIST.phpclass
  * Class file OCSP_FRMCONTR_LIST.phpclass  
  * @project    Open CSP-Management  
  * @author     Peter Krebs (pk) <pitlinz@users.sourceforge.net>  
  * @license    http://opensource.org/licenses/gpl-license.php GNU Public License  
  * @version $Id: OCSP_FRMCONTR_LIST.phpclass,v 1.23 2008/11/30 13:35:29 pitlinz Exp $  
// -----------------------------------------------------  
// -----------------------------------------------------  
  * class OCSP_FRMCONTR_LIST  
  * @project    Open CSP-Management  
  * @author     Peter Krebs (pk) <pitlinz@users.sourceforge.net>  
  * @license    http://opensource.org/licenses/gpl-license.php GNU Public License  
      * @var array $lstObjValCols   
      * @var string $lstQuery (without limit,offset and order)  
      * @var array $myListValues   
      * @var double $listLoadTS   
      * @var double $lstObjValTS   
      * @var array $lst_groupValues   
      * @var string $lst_orderBy   
      * @var string $tbl_sortLink   
      * an array with a java event as key and a js-function template  
      *      $myRowCmds['onClick']="alert('\$*COLNAME$')";  
      *      will output <tr onClick="alert('VALUE OF $this->curRow[$COLNAME]')" >  
      *  NOTE: avoid " in PARAM as the generated code is enclosed by "  
    /** array of command templates for each row  
      * $tbl_rowBtnCmds[CMDNAME]=CMDTMPLATE  
      * it will generate a button - column as follows:  
      * <td><a pcf_tmpl_parse(CMDTMPLATE,$this->curRow) > $this->myView->getButtonImgTag(CMDNMAE) <a>  
      * @var array $tbl_rowBtnCmds   
      * @var array $tbl_footerCmds   
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
     * returns the unfiltered list sql statement  
     * if $this->lstQuery is empty the query is generated out of the form  
            // <<<< return <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  
            $this->lstQuery=
"SELECT * FROM ".
$arr_keys[0];  
            // <<<< return <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  
        } else if ($obj_tblObj=
$this->myForm->getMyTblObj()) {  
            $str_query =
"SELECT * FROM ".
$obj_tblObj->getMyTable();  
            $arr_joinCols=
$this->myForm->getJoinCols();  
            if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p>JoinCols: </p><pre>".
print_r($arr_joinCols,TRUE).
"</pre>");  
            foreach($this->lstTables as $str_tbl => 
$arr_tblDef)  
                if ($str_tbl != 
$obj_tblObj->getMyTable())  
                    foreach($arr_joinCols as $str_col => 
$arr_tableJoinCols)  
                        echoDebugLine(__FILE__
,__LINE__
,"<p>\$arr_joinColsstrong: $str_col</strong><pre>".
print_r($arr_tableJoinCols,TRUE).
"</pre>");  
                    echoDebugLine(__FILE__
,__LINE__
,"<p><strong>$str_tbl</strong><pre>".
print_r($arr_tblDef,TRUE).
"</pre>");  
            foreach($this->lstTables as $str_tbl => 
$arr_tblDef)  
                if ($this->myDBObj->tblExists($str_tbl))  
                    $arr_keys[$str_tbl]=
$this->myDBObj->getPrimaryKeys($str_tbl);  
                if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p><strong>$str_tbl</strong><pre>".
print_r($arr_tblDef,TRUE).
"</pre>");  
            $str_query =
"SELECT * FROM ".
$this->myForm->getMastertable();  
            unset
($arr_keys[$this->myForm->getMastertable()]); 
            $arr_cols=
$this->myDBObj->getDBTblDesc($this->myForm->getMastertable());  
                foreach($arr_keys as $str_tbl => 
$arr_keys)  
                        while(!$b_tblAdded && 
(list
(,$str_key) = 
each($arr_keys)))  
                            if (isset
($arr_cols[$str_key]))  
                                $str_query.=
" JOIN $str_tbl USING($str_key)";  
                                unset
($arr_keys[$str_tbl]); 
            if ($debug) echoDebugLine(__FILE__
,__LINE__
,"ListQuery: $str_query");  
            // <<<< return <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<  
     * returns the where condition for the filter  
     * you have to prepend "WHERE" OR "AND" to the returned string  
     * @version pk-08-10-01 if filter value is an array -> make or statement  
        foreach($this->myFilter as $str_col => 
$m_val)  
            if (substr($str_col,0,1)==
"?")  
                $str_conditions .= 
$str_whereAnd . 
$m_val;  
            } else if (substr($str_col,0,1) == 
"~") {  
                   $str_conditions .= 
$str_whereAnd . 
substr($str_col,1) . 
" " . 
$this->myDBObj->qs_getLikeStmt($m_val,False,False,$debug);  
            } else if (is_array($m_val)) { // <pk-08-10-01>  
                foreach($m_val as $m_orVal)  
                    $str_orCondition .= 
$str_orSep . 
$str_col . 
"=" . 
$this->myDBObj->qs_getSlashedValue($m_orVal);  
                if (!empty($str_orCondition))  
                    $str_conditions .= 
$str_whereAnd . 
"(" . 
$str_orCondition . 
")";  
                    $str_conditions .= 
$str_whereAnd . 
"1=1"; // to avoid errors for empty conditions  
                $str_conditions .= 
$str_whereAnd . 
$str_col . 
"=" . 
$this->myDBObj->qs_getSlashedValue($m_val);  
      * sets a query for the list elements  
      * @param string $orderStr   
      * @return int (the size of $this->tbl_rowBtnCmds)  
      * adds a button command to the end of a row  
     * returns the row command button array  
     * @param int $pos // -1: left; 1: right (default); 0: both  
        } else if (intval($pos) < 
0) {  
                if (isset
($arr_btn['POS']) && 
(intval($arr_btn['POS']) < 
0))  
                if (!isset
($arr_btn['POS']) || 
(intval($arr_btn['POS']) > -
1))  
      * tr code is generated as follows  
      *     echo "<tr $event=\"".pcf_escape_doubleQuote(pcf_tmpl_parse($jsCmd)."\">";  
      * note sending $event twice overwrites the older setting  
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
      * @return boolean if the list values have been loaded  
     * sets the loaded values as invalide  
      * @return mixed (False if the list rows have not been loaded else the size of $this->myListValues)  
        $arr_flds=
$this->myView->getFields($debug);  
        foreach($arr_flds as &$objField)  
            $objField->setControll($this);  
            $arr_fldDesc=
$objField->getdbDesc();  
            $str_tbl=
$objField->getTable();  
                if (substr($str_tbl,0,8)==
"OBJVALS_")  
                    if (!isset
($this->lstTables[$objField->getTable()]))  
                        $this->lstTables[$objField->getTable()]=
array('TABLE'=>
$objField->getTable());  
                    if (isset
($arr_fldDesc['COLNAME']))  
                        $this->lstTables[$objField->getTable()]['COLS'][]=
$arr_fldDesc['COLNAME'];  
                        if (isset
($arr_fldDesc['PRIMARY_KEY']) && 
($arr_fldDesc['PRIMARY_KEY']))  
                            $this->lstTables[$objField->getTable()]['PK'][]=
$arr_fldDesc['COLNAME'];  
        if ($arr_groups=
$this->myForm->get_listGroups())  
      * @param array $fieldNames   
      * @todo OCSP_FRMCONTR_LIST::loadListObjectValues() replace inline SQL  
                $str_dbTbl=
substr($str_tbl,8);  
                if (!isset
($this->lstTables[$str_dbTbl]['PK']))  
                $arr_pkCol=
$this->lstTables[$str_dbTbl]['PK'];  
                $b_singleKey=
(sizeof($arr_pkCol) == 
1);  
                    ocsp_logError(__FILE__
,__LINE__
,$str_dbTbl.
" has more then 1 private key columns code not implemented");  
                $str_query=
"SELECT CONCAT(".
$str_dbTbl.
"_OV.OV_NAME,'|',".
$str_dbTbl.
".".
$arr_pkCol[0].
") AS OV_IDX";  
                $str_query.=
$char_sep.
$str_dbTbl.
"_OV.".
$arr_pkCol[0];  
                $str_query.=
$char_sep.
"OV_NAME,OV_VALUE FROM ".
$str_dbTbl.
"_OV,".
$str_dbTbl;  
                $str_query.=
" WHERE ".
$this->myDBObj->qs_getWhereIn('OV_NAME',$arr_cols);  
                foreach($arr_pkCol as $str_pkName)  
                    $str_query.=
" AND ".
$str_dbTbl.
"_OV.".
$str_pkName.
"=".
$str_dbTbl.
".".
$str_pkName;  
                    foreach($this->myFilter as $str_col => 
$m_val)  
                        $str_query.=
" AND ".
$str_dbTbl.
".".
$str_col.
"=".
$this->myDBObj->qs_getSlashedValue($m_val);  
                if ($debug) echoDebugLine(__FILE__
,__LINE__
,"querry for objectvalues: <br />".
$str_query);  
                if ($arr_objValues=
$this->myDBObj->queryArray($str_query,0,-
1))  
                        foreach($arr_cols as $str_col)  
                            if (isset
($arr_objValues[$str_col.
"|".
$arr_values[$arr_pkCol[0]]]['OV_VALUE']))  
                                $this->myListValues[$i_idx][$str_col]=
$arr_objValues[$str_col.
"|".
$arr_values[$arr_pkCol[0]]]['OV_VALUE'];  
                    ocsp_logError(__FILE__
,__LINE__
,"no objectvalues found with query: <br />".
$str_query,E_NOTICE);  
      * loads the list values from the database to $this->myListValues  
      * an always sets $this->listLoadTS to time()  
      * @param boolean $forceReload   
      * @return int number of rows found or False  
      * @todo OCSP_FRMCONTR_LIST::loadListValues() replace inline SQL  
      * @version pk-08-01-19 use $this->getListQuery to set $this->lstQuery  
      * @version pk-08-02-15 ~ => LIKE filter type added  
      * @version pk-08-11-26 $forceReload added  
        $this->getDBObj($debug);        // ensure $this->myDBObj is set  
        $this->getListQuery($debug);    // ensure $this->lstQuery is set   
            if ($debug) echoDebugLine(__FILE__
,__LINE__
,"listquery: " . 
$str_query);  
                if ($debug) ocsp_logError(__FILE__
,__LINE__
,'list has no values');  
            if ($debug) echoDebugLine(__FILE__
,__LINE__
,"\$this->lstQuery is empty");  
      * @return array $this->myListValues  
            if ($obj_tblObj=
$this->getMyForm()->getMyTblObj(True,$debug))  
                    $obj_tblObj->setDBVal($this->curRow,$debug);  
                    $obj_tblObj->setDBRow($this->curRow,TRUE,$debug);  
                    if (!$b_canShow) return $this->getListRow($debug);  
      * checks the listgroups for the current row and calls  
      * $this->myView->getGroupRow if it's to do  
                if (isset
($this->curRow[$str_col]))  
                    if (($b_toChange) || 
($this->curRow[$str_col] != 
$mix_value))  
                        $b_toChange=
TRUE; // change each following group  
                        $str_ret.=
$this->myView->getGroupRow($str_col,$this->curRow,$debug);  
     * returns the total number of rows  
        $this->getDBObj($debug);        // ensure $this->myDBObj is set  
        $this->getListQuery($debug);    // ensure $this->lstQuery is set   
                foreach($this->myFilter as $str_col => 
$m_val)  
                    if (substr($str_col,0,1)==
"?")  
                        $str_query .= 
$str_whereAnd . 
$m_val;  
                    } else if (substr($str_col,0,1) == 
"~") {  
                        $str_query .= 
$str_whereAnd . 
substr($str_col,1) . 
" " . 
$this->myDBObj->qs_getLikeStmt($m_val,False,False,$debug);  
                        $str_query .= 
$str_whereAnd . 
$str_col . 
"=" . 
$this->myDBObj->qs_getSlashedValue($m_val);  
            $int_fromPos = 
stripos($str_query,'FROM');  
            $str_query = 
"SELECT COUNT(*) " . 
substr($str_query,($int_fromPos -
1));  
            if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Query: " . 
$str_query);  
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
      * @return string the table id  
        return "tbl_".
$this->myForm->getName();  
      * @param DBMS_FIELD $objField   
            return " ondblclick=\"document.location=\"".
$str_link.
";\"";  
    // footer --------------------------------------  
     * pageing is tourned on if the $_GET['offset'] and $_GET['limit'] are set  
        if (isset
($_GET['offset']) && isset
($_GET['limit']))  
            if ($debug) echoDebugLine(__FILE__
,__LINE__
,"offset & limit found");  
            if (isset
($_SERVER['HTTP_X_REQUESTED_WITH']) && 
($_SERVER['HTTP_X_REQUESTED_WITH'] == 
'XMLHttpRequest'))  
                if ($debug) echoDebugLine(__FILE__
,__LINE__
,"Ajax request: <pre>" . 
print_r($_GET,True) . 
"</pre>");  
                return isset
($_GET['inToDiv']);  
     * returns the html code for the pageing back button  
            if ($debug) echoDebugLine(__FILE__
,__LINE__
,"ajax call not supported");  
        $str_return = 
"<div style=\"float:left;display:block;width:30px;height:28px;\"><a ";  
            $str_return .= 
"onclick=\"jOCSP.load('{$_GET['inToDiv']}','{$str_url}');\"";  
            $str_return .= 
"href=\"{$str_url}\"";  
        $str_return .= 
"><img src=\"" . 
OCSP_CONF::getInstance()->getValue('SYSIMGURL') . 
"icons-22x22/1leftarrow.gif\" class=\"button\" alt=\"back\" title=\"" . 
t_admin('Zurück') . 
"\" /></a>";  
        $str_return = 
"<div style=\"float:right;display:block;width:30px;height:28px;text-align:right;\"><a ";  
            $str_return .= 
"onclick=\"jOCSP.load('{$_GET['inToDiv']}','{$str_url}');\"";  
            $str_return .= 
"href=\"{$str_url}\"";  
        $str_return .= 
"><img src=\"" . 
OCSP_CONF::getInstance()->getValue('SYSIMGURL') . 
"icons-22x22/1rightarrow.gif\" class=\"button\" alt=\"next\" title=\"" . 
t_admin('Weiter') . 
"\" /></a>";  
                    <img src=\"" . 
OCSP_CONF::getInstance()->getValue('SYSIMGURL') . 
"icons-22x22/editConstruct.gif\" class=\"button\" />   
     * sets the footer cmd array  
     * NOTE: overwrites existing commands  
     * @param array $footerCmd   
            if (isset
($arr_tblDesc['PK']) && 
is_array($arr_tblDesc['PK']))  
                foreach($arr_tblDesc['PK'] as $str_colName)  
                $str_ret.=
"_".
$str_colName.
"-".
$this->curRow[$str_colName];  
      * @requires __OCSP_PHPINCPATH__."common/pcf_templates.phpinc";  
            foreach($this->myRowCmds as $str_event => 
$str_cmd)  
                if ($debug) echoDebugLine(__FILE__
,__LINE__
,"<p><strong>{$str_event}</strong></p>");                  
      * @param DBMS_FIELD $objField   
      * @param DBMS_FIELD $objField   
        if ($arr_lnk=
$objField->getListLinkArr())  
            if ((isset
($arr_lnk['A'])) && 
(!empty($arr_lnk['A'])))  
      * @param DBMS_FIELD $objField   
        if ($arr_lnk=
$objField->getListLinkArr())  
            if ((isset
($arr_lnk['A'])) && 
(!empty($arr_lnk['A']))) {  
      * @param string $outerElem   
      * @param string $linkElem   
    function getRowButtons($outerElem=
"td",$linkElem=
"a",$debug=
False)  
                $str_ret.=
$this->myView->getButtonImgTag($str_cmd,$debug).
"</{$linkElem}></{$outerElem}>";  
} // end of OCSP_FRMCONTR_LIST  
 
 
	
		Documentation generated on Thu, 08 Jan 2009 17:46:29 +0100 by phpDocumentor 1.4.0a2