mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-12-17 09:33:13 +00:00
add new show value (searchlist), new opt. param for getAttributeDefinitons()
This commit is contained in:
parent
4e221419f7
commit
3d5d33c4aa
|
|
@ -1073,12 +1073,18 @@ class SeedDMS_Core_AttributeDefinitionGroup { /* {{{ */
|
|||
const show_list = 0x1;
|
||||
const show_details = 0x2;
|
||||
const show_search = 0x4;
|
||||
const show_searchlist = 0x8;
|
||||
|
||||
static function getShowValues() { /* {{{ */
|
||||
return array(1=>'list', 2=>'detail', 4=>'search', 8=>'searchlist');
|
||||
} /* }}} */
|
||||
|
||||
function __construct($id, $name, $comment) { /* {{{ */
|
||||
$this->_id = $id;
|
||||
$this->_name = $name;
|
||||
$this->_comment = $comment;
|
||||
$this->_dms = null;
|
||||
$this->_attrdefs = array();
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
|
|
@ -1223,37 +1229,48 @@ class SeedDMS_Core_AttributeDefinitionGroup { /* {{{ */
|
|||
* Get all attribute defintions of a group
|
||||
*
|
||||
* @param mixed $objtype single object type or list of object types
|
||||
* @param integer $show select only those attributes which match the
|
||||
* bit mask in the given show value
|
||||
* @return array list of attribute definitions, its sequence and show
|
||||
* value. This is an array of array with the keys 'attrdef', 'sequence'
|
||||
* and 'show'
|
||||
*/
|
||||
function getAttributeDefinitions($objtype=array()) { /* {{{ */
|
||||
function getAttributeDefinitions($objtype=array(), $show=0) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
if (!isset($this->_attrdefs)) {
|
||||
$queryStr = "SELECT `tblAttributeDefinitions`.*, `tblAttributeDefinitionGroupAttributeDefinition`.* FROM `tblAttributeDefinitions` ".
|
||||
"LEFT JOIN `tblAttributeDefinitionGroupAttributeDefinition` ON `tblAttributeDefinitionGroupAttributeDefinition`.`attrdef`=`tblAttributeDefinitions`.`id` ".
|
||||
"WHERE `tblAttributeDefinitionGroupAttributeDefinition`.`attrgrp` = '". $this->_id ."' ";
|
||||
$hashtag = md5(implode('', $objtype).$show);
|
||||
if (!isset($this->_attrdefs[$hashtag]) && !$this->_attrdefs[$hashtag]) {
|
||||
/* FIXME: selecting showfilter is not needed if $show=0. I was just to lasy
|
||||
* to take it out with another if($show) ...
|
||||
*/
|
||||
$queryStr = "SELECT ";
|
||||
if($show)
|
||||
$queryStr .= "b.`show`&".(int) $show." showfilter, ";
|
||||
$queryStr .= "a.*, b.* FROM `tblAttributeDefinitions` a ".
|
||||
"LEFT JOIN `tblAttributeDefinitionGroupAttributeDefinition` b ON b.`attrdef`=a.`id` ".
|
||||
"WHERE b.`attrgrp` = '". $this->_id ."' ";
|
||||
if($objtype) {
|
||||
if(is_array($objtype))
|
||||
$queryStr .= ' AND `tblAttributeDefinitions`.`objtype` in (\''.implode("','", $objtype).'\') ';
|
||||
$queryStr .= ' AND a.`objtype` in (\''.implode("','", $objtype).'\') ';
|
||||
else
|
||||
$queryStr .= ' AND `tblAttributeDefinitions`.`objtype`='.intval($objtype).' ';
|
||||
$queryStr .= ' AND a.`objtype`='.intval($objtype).' ';
|
||||
}
|
||||
$queryStr .= "ORDER BY `tblAttributeDefinitionGroupAttributeDefinition`.`sequence` ASC";
|
||||
if($show)
|
||||
$queryStr .= ' HAVING `showfilter`!=0 ';
|
||||
$queryStr .= "ORDER BY b.`sequence` ASC";
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
if (is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
|
||||
$this->_attrdefs = array();
|
||||
$this->_attrdefs[$hashtag] = array();
|
||||
|
||||
foreach ($resArr as $row) {
|
||||
$attrdef = new SeedDMS_Core_AttributeDefinition($row["id"], $row["name"], $row["objtype"], $row["type"], $row["multiple"], $row["minvalues"], $row["maxvalues"], $row["valueset"], $row["regex"]);
|
||||
$attrdef->setDMS($this->_dms);
|
||||
array_push($this->_attrdefs, array('attrdef'=>$attrdef, 'sequence'=>$row['sequence'], 'show'=>$row['show']));
|
||||
array_push($this->_attrdefs[$hashtag], array('attrdef'=>$attrdef, 'sequence'=>$row['sequence'], 'show'=>$row['show']));
|
||||
}
|
||||
}
|
||||
return $this->_attrdefs;
|
||||
return $this->_attrdefs[$hashtag];
|
||||
} /* }}} */
|
||||
|
||||
function addAttributeDefinition($attrdef, $show=false) { /* {{{ */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user