Added in class member variables, fixed warnings about undefined array values, prettied up the code to Campware coding conventions.
This commit is contained in:
parent
3be0939b41
commit
20b1098f3e
1 changed files with 100 additions and 54 deletions
|
@ -1,6 +1,12 @@
|
||||||
<?php
|
<?php
|
||||||
class uiBrowse
|
class uiBrowse
|
||||||
{
|
{
|
||||||
|
var $Base; // uiBase object
|
||||||
|
var $prefix;
|
||||||
|
var $col;
|
||||||
|
var $criteria;
|
||||||
|
var $reloadUrl;
|
||||||
|
|
||||||
function uiBrowse(&$uiBase)
|
function uiBrowse(&$uiBase)
|
||||||
{
|
{
|
||||||
$this->Base =& $uiBase;
|
$this->Base =& $uiBase;
|
||||||
|
@ -10,19 +16,25 @@ class uiBrowse
|
||||||
#$this->results =& $_SESSION[constant('UI_'.$this->prefix.'_SESSNAME')]['results'];
|
#$this->results =& $_SESSION[constant('UI_'.$this->prefix.'_SESSNAME')]['results'];
|
||||||
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
|
$this->reloadUrl = UI_BROWSER.'?popup[]=_reload_parent&popup[]=_close';
|
||||||
|
|
||||||
if (empty($this->criteria['limit'])) $this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT;
|
if (empty($this->criteria['limit'])) {
|
||||||
if (empty($this->criteria['filetype'])) $this->criteria['filetype'] = UI_FILETYPE_ANY;
|
$this->criteria['limit'] = UI_BROWSE_DEFAULT_LIMIT;
|
||||||
|
}
|
||||||
|
if (empty($this->criteria['filetype'])) {
|
||||||
|
$this->criteria['filetype'] = UI_FILETYPE_ANY;
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_array($this->col)) {
|
if (!is_array($this->col)) {
|
||||||
## init Categorys
|
## init Categorys
|
||||||
$this->setDefaults();
|
$this->setDefaults();
|
||||||
}
|
}
|
||||||
}
|
} // constructor
|
||||||
|
|
||||||
|
|
||||||
function setReload()
|
function setReload()
|
||||||
{
|
{
|
||||||
$this->Base->redirUrl = $this->reloadUrl;
|
$this->Base->redirUrl = $this->reloadUrl;
|
||||||
}
|
} // fn setReload
|
||||||
|
|
||||||
|
|
||||||
function setDefaults($reload=FALSE)
|
function setDefaults($reload=FALSE)
|
||||||
{
|
{
|
||||||
|
@ -33,10 +45,10 @@ class uiBrowse
|
||||||
$this->col[3]['category'] = UI_BROWSE_DEFAULT_KEY_3;
|
$this->col[3]['category'] = UI_BROWSE_DEFAULT_KEY_3;
|
||||||
$this->col[3]['value'][0] = '%%all%%';
|
$this->col[3]['value'][0] = '%%all%%';
|
||||||
|
|
||||||
for ($col=1; $col<=3; $col++) {
|
for ($col = 1; $col <= 3; $col++) {
|
||||||
$this->setCategory(array('col' => $col, 'category' => $this->col[$col]['category'], 'value' => array(0 => '%%all%%')));
|
$this->setCategory(array('col' => $col,
|
||||||
|
'category' => $this->col[$col]['category'],
|
||||||
|
'value' => array(0 => '%%all%%')));
|
||||||
$this->setValue(
|
$this->setValue(
|
||||||
array('col' => $col,
|
array('col' => $col,
|
||||||
'category' => $this->col[$col]['category'],
|
'category' => $this->col[$col]['category'],
|
||||||
|
@ -45,35 +57,43 @@ class uiBrowse
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($reload === TRUE) $this->setReload();
|
if ($reload === TRUE) {
|
||||||
|
$this->setReload();
|
||||||
}
|
}
|
||||||
|
} // fn setDefaults
|
||||||
|
|
||||||
|
|
||||||
function getCriteria()
|
function getCriteria()
|
||||||
{
|
{
|
||||||
return $this->criteria;
|
return $this->criteria;
|
||||||
}
|
} // fn getCriteria
|
||||||
|
|
||||||
|
|
||||||
function getResult()
|
function getResult()
|
||||||
{
|
{
|
||||||
$this->searchDB();
|
$this->searchDB();
|
||||||
return $this->results;
|
return $this->results;
|
||||||
}
|
} // fn getResult
|
||||||
|
|
||||||
|
|
||||||
function browseForm($id, $mask2)
|
function browseForm($id, $mask2)
|
||||||
{
|
{
|
||||||
include dirname(__FILE__).'/formmask/metadata.inc.php';
|
include dirname(__FILE__).'/formmask/metadata.inc.php';
|
||||||
#$mask2['browse_columns']['category']['options'][0] = tra('Select a Value');
|
#$mask2['browse_columns']['category']['options'][0] = tra('Select a Value');
|
||||||
foreach ($mask['pages'] as $key=>$val) {
|
foreach ($mask['pages'] as $key => $val) {
|
||||||
foreach ($mask['pages'][$key] as $v){
|
foreach ($mask['pages'][$key] as $v){
|
||||||
if ($v['type']) $mask2['browse_columns']['category']['options'][$this->Base->_formElementEncode($v['element'])] = tra($v['label']);
|
if (isset($v['type']) && $v['type']) {
|
||||||
|
$tmp = $this->Base->_formElementEncode($v['element']);
|
||||||
|
$mask2['browse_columns']['category']['options'][$tmp] = tra($v['label']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for($n=1; $n<=3; $n++) {
|
for ($n = 1; $n <= 3; $n++) {
|
||||||
$form = new HTML_QuickForm('col'.$n, UI_STANDARD_FORM_METHOD, UI_HANDLER);
|
$form = new HTML_QuickForm('col'.$n, UI_STANDARD_FORM_METHOD, UI_HANDLER);
|
||||||
$form->setConstants(array('id' => $id, 'col' => $n, 'category' => $this->Base->_formElementEncode($this->col[$n]['category'])));
|
$form->setConstants(array('id' => $id,
|
||||||
|
'col' => $n,
|
||||||
|
'category' => $this->Base->_formElementEncode($this->col[$n]['category'])));
|
||||||
$mask2['browse_columns']['value']['options'] = $this->options($this->col[$n]['values']['results']);
|
$mask2['browse_columns']['value']['options'] = $this->options($this->col[$n]['values']['results']);
|
||||||
$mask2['browse_columns']['value']['default'] = $this->col[$n]['form_value'];
|
$mask2['browse_columns']['value']['default'] = $this->col[$n]['form_value'];
|
||||||
$this->Base->_parseArr2Form($form, $mask2['browse_columns']);
|
$this->Base->_parseArr2Form($form, $mask2['browse_columns']);
|
||||||
|
@ -93,21 +113,32 @@ class uiBrowse
|
||||||
$output['global']['dynform'] = $renderer->toArray();
|
$output['global']['dynform'] = $renderer->toArray();
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}
|
} // fn browseForm
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $parm
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
function setCategory($parm)
|
function setCategory($parm)
|
||||||
{
|
{
|
||||||
$which = $parm['col'];
|
$which = $parm['col'];
|
||||||
$this->col[$which]['category'] = $this->Base->_formElementDecode($parm['category']);
|
$this->col[$which]['category'] = $this->Base->_formElementDecode($parm['category']);
|
||||||
$this->col[$which]['values'] = $this->Base->gb->browseCategory($this->col[$which]['category'], $this->col[$which]['criteria'], $this->Base->sessid);
|
$criteria = isset($this->col[$which]['criteria']) ? $this->col[$which]['criteria'] : null;
|
||||||
|
$this->col[$which]['values'] = $this->Base->gb->browseCategory($this->col[$which]['category'], $criteria, $this->Base->sessid);
|
||||||
|
|
||||||
$this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix;
|
$this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix;
|
||||||
|
|
||||||
$this->clearHierarchy($which);
|
$this->clearHierarchy($which);
|
||||||
#print_r($this->col);
|
#print_r($this->col);
|
||||||
}
|
} // fn setCategory
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enter description here...
|
||||||
|
*
|
||||||
|
* @param array $parm
|
||||||
|
*/
|
||||||
function setValue($parm)
|
function setValue($parm)
|
||||||
{
|
{
|
||||||
$this->criteria['offset'] = 0;
|
$this->criteria['offset'] = 0;
|
||||||
|
@ -131,7 +162,9 @@ class uiBrowse
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->col[$next]['values'] = $this->Base->gb->browseCategory($this->col[$next]['category'], $this->col[$next]['criteria'], $this->Base->sessid);
|
$nextCriteria = isset($this->col[$next]['criteria']) ? $this->col[$next]['criteria'] : null;
|
||||||
|
$category = isset($this->col[$next]['category']) ? $this->col[$next]['category'] : null;
|
||||||
|
$this->col[$next]['values'] = $this->Base->gb->browseCategory($category, $nextCriteria, $this->Base->sessid);
|
||||||
|
|
||||||
#echo "cat: ".$this->col[$next]['category']."\n";
|
#echo "cat: ".$this->col[$next]['category']."\n";
|
||||||
#echo "criteria: "; print_r($this->col[$next]['criteria']);
|
#echo "criteria: "; print_r($this->col[$next]['criteria']);
|
||||||
|
@ -142,19 +175,21 @@ class uiBrowse
|
||||||
#$this->searchDB();
|
#$this->searchDB();
|
||||||
$this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix;
|
$this->Base->redirUrl = UI_BROWSER.'?act='.$this->prefix;
|
||||||
#$this->setReload();
|
#$this->setReload();
|
||||||
}
|
} // fn setValue
|
||||||
|
|
||||||
|
|
||||||
function options($arr)
|
function options($arr)
|
||||||
{
|
{
|
||||||
$ret['%%all%%'] = '---all---';
|
$ret['%%all%%'] = '---all---';
|
||||||
if (is_array($arr)) {
|
if (is_array($arr)) {
|
||||||
foreach ($arr as $val)
|
foreach ($arr as $val) {
|
||||||
$ret[$val] = $val;
|
$ret[$val] = $val;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
} // fn options
|
||||||
|
|
||||||
|
|
||||||
function clearHierarchy($which)
|
function clearHierarchy($which)
|
||||||
{
|
{
|
||||||
|
@ -165,18 +200,19 @@ class uiBrowse
|
||||||
$this->col[$col]['values'] = NULL;
|
$this->col[$col]['values'] = NULL;
|
||||||
$this->col[$col]['form_value'] = NULL;
|
$this->col[$col]['form_value'] = NULL;
|
||||||
}
|
}
|
||||||
}
|
} // fn clearHierarchy
|
||||||
|
|
||||||
|
|
||||||
function setCriteria() {
|
function setCriteria() {
|
||||||
//$this->criteria['conditions'] = array();
|
//$this->criteria['conditions'] = array();
|
||||||
unset($this->criteria['conditions']);
|
unset($this->criteria['conditions']);
|
||||||
for($col=3; $col>=1; $col--) {
|
for ($col=3; $col>=1; $col--) {
|
||||||
if (is_array($this->col[$col]['criteria'])) {
|
if (is_array($this->col[$col]['criteria'])) {
|
||||||
$this->criteria = array_merge ($this->col[$col]['criteria'], $this->criteria);
|
$this->criteria = array_merge ($this->col[$col]['criteria'], $this->criteria);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // fn setCriteria
|
||||||
|
|
||||||
|
|
||||||
function searchDB()
|
function searchDB()
|
||||||
|
@ -217,7 +253,7 @@ class uiBrowse
|
||||||
#print_r($this->criteria);
|
#print_r($this->criteria);
|
||||||
#print_r($this->results);
|
#print_r($this->results);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
} // fn searchDB
|
||||||
|
|
||||||
|
|
||||||
function pagination(&$results)
|
function pagination(&$results)
|
||||||
|
@ -240,11 +276,18 @@ class uiBrowse
|
||||||
$deltaUpper = UI_BROWSERESULTS_DELTA;
|
$deltaUpper = UI_BROWSERESULTS_DELTA;
|
||||||
$start = $currp;
|
$start = $currp;
|
||||||
|
|
||||||
if ($start+$delta-$maxp > 0) $deltaLower += $start+$delta-$maxp; ## correct lower boarder if page is near end
|
if ($start+$delta-$maxp > 0) {
|
||||||
|
// correct lower border if page is near end
|
||||||
|
$deltaLower += $start+$delta-$maxp;
|
||||||
|
}
|
||||||
|
|
||||||
for ($n = $start-$deltaLower; $n <= $start+$deltaUpper; $n++) {
|
for ($n = $start-$deltaLower; $n <= $start+$deltaUpper; $n++) {
|
||||||
if ($n <= 0) $deltaUpper++; ## correct upper boarder if page is near zero
|
if ($n <= 0) {
|
||||||
elseif ($n <= $maxp) $this->results['pagination'][$n] = $n;
|
// correct upper border if page is near zero
|
||||||
|
$deltaUpper++;
|
||||||
|
} elseif ($n <= $maxp) {
|
||||||
|
$this->results['pagination'][$n] = $n;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#array_pop($this->results['pagination']);
|
#array_pop($this->results['pagination']);
|
||||||
|
@ -253,22 +296,23 @@ class uiBrowse
|
||||||
$this->results['next'] = $results['cnt'] > $this->criteria['offset'] + $this->criteria['limit'] ? TRUE : FALSE;
|
$this->results['next'] = $results['cnt'] > $this->criteria['offset'] + $this->criteria['limit'] ? TRUE : FALSE;
|
||||||
$this->results['prev'] = $this->criteria['offset'] > 0 ? TRUE : FALSE;
|
$this->results['prev'] = $this->criteria['offset'] > 0 ? TRUE : FALSE;
|
||||||
ksort($this->results['pagination']);
|
ksort($this->results['pagination']);
|
||||||
}
|
} // fn pagination
|
||||||
|
|
||||||
|
|
||||||
function reOrder($by)
|
function reOrder($by)
|
||||||
{
|
{
|
||||||
$this->criteria['offset'] = NULL;
|
$this->criteria['offset'] = NULL;
|
||||||
|
|
||||||
if ($this->criteria['orderby'] == $by && !$this->criteria['desc'])
|
if ($this->criteria['orderby'] == $by && !$this->criteria['desc']) {
|
||||||
$this->criteria['desc'] = TRUE;
|
$this->criteria['desc'] = TRUE;
|
||||||
else
|
} else {
|
||||||
$this->criteria['desc'] = FALSE;
|
$this->criteria['desc'] = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
$this->criteria['orderby'] = $by;
|
$this->criteria['orderby'] = $by;
|
||||||
$this->setReload();
|
$this->setReload();
|
||||||
#$this->searchDB();
|
#$this->searchDB();
|
||||||
}
|
} // fn reOrder
|
||||||
|
|
||||||
|
|
||||||
function setOffset($page)
|
function setOffset($page)
|
||||||
|
@ -285,14 +329,16 @@ class uiBrowse
|
||||||
}
|
}
|
||||||
$this->setReload();
|
$this->setReload();
|
||||||
#$this->searchDB();
|
#$this->searchDB();
|
||||||
}
|
} // fn setOffset
|
||||||
|
|
||||||
|
|
||||||
function setLimit($limit)
|
function setLimit($limit)
|
||||||
{
|
{
|
||||||
$this->criteria['limit'] = $limit;
|
$this->criteria['limit'] = $limit;
|
||||||
$this->setReload();
|
$this->setReload();
|
||||||
#$this->searchDB();
|
#$this->searchDB();
|
||||||
}
|
} // fn setLimit
|
||||||
|
|
||||||
|
|
||||||
function setFiletype($filetype)
|
function setFiletype($filetype)
|
||||||
{
|
{
|
||||||
|
@ -308,6 +354,6 @@ class uiBrowse
|
||||||
|
|
||||||
$this->setReload();
|
$this->setReload();
|
||||||
#$this->searchDB();
|
#$this->searchDB();
|
||||||
}
|
} // fn setFiletype
|
||||||
}
|
} // class uiBrowse
|
||||||
?>
|
?>
|
Loading…
Add table
Add a link
Reference in a new issue