php abstract class __custom_photoalbum public function albumlist templ

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
abstract class __custom_photoalbum {
public function albumlist($template = "default", $per_page = false, $ignore_paging = false) {
if(!$per_page) $per_page = 10;
$curr_page = (int) getRequest('p');
if($ignore_paging) {
$curr_page = 0;
}
list($template_block, $template_block_empty, $template_line) = def_module::loadTemplates("tpls/photoalbum/{$template}.tpl", "albums_list_block", "albums_list_block_empty", "albums_list_block_line");
$block_arr = Array();
$hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("photoalbum", "album")->getId();
$object_type_id = umiObjectTypesCollection::getInstance()->getBaseType("photoalbum", "album");
$object_type = umiObjectTypesCollection::getInstance()->getType($object_type_id);
$sel = new umiSelection;
$sel->setElementTypeFilter();
$sel->addElementType($hierarchy_type_id);
if (isset($_GET['filter']) && isset($_GET['value'])) {
$field = (string) getRequest('filter');
$f_val = (int) getRequest('value');
$f_id = $object_type->getFieldId($field);
if ($f_val > 0 && $f_id > 0)
{
$sel->setPropertyFilter();
$sel->addPropertyFilterEqual($f_id, $f_val);
}
}
$sel->setLimitFilter();
$sel->addLimit($per_page, $curr_page);
$sel->setPermissionsFilter();
$sel->addPermissions();
$result = umiSelectionsParser::runSelection($sel);
$total = umiSelectionsParser::runSelectionCounts($sel);
$lines = Array();
if($total > 0) {
foreach($result as $element_id) {
$line_arr = Array();
$element = umiHierarchy::getInstance()->getElement($element_id);
$line_arr['attribute:id'] = $element_id;
$line_arr['attribute:link'] = umiHierarchy::getInstance()->getPathById($element_id);
$line_arr['xlink:href'] = "upage://" . $element_id;
$line_arr['node:name'] = $element->getName();
templater::pushEditable("photoalbum", "album", $element_id);
$lines[] = photoalbum::parseTemplate($template_line, $line_arr, $element_id);
}
} else {
return photoalbum::parseTemplate($template_block_empty, $block_arr);
}
$block_arr['subnodes:items'] = $block_arr['void:lines'] = $lines;
$block_arr['total'] = $total;
$block_arr['per_page'] = $per_page;
return photoalbum::parseTemplate($template_block, $block_arr);
}
public function insert_marks($template = "default", $field = "kultura", $type_id = 748) {
list($template_block, $template_block_item, $template_block_item_active) = $this->loadTemplates("./tpls/photoalbum/{$template}.tpl", "marks_block", "marks_block_item", "marks_block_item_a");
$block_arr = Array();
$objects = umiObjectsCollection::getInstance();
$mark = getRequest('value');
$sel = new umiSelection;
$sel->setObjectTypeFilter();
$sel->addObjectType($type_id);
$result = umiSelectionsParser::runSelection($sel);
$total = umiSelectionsParser::runSelectionCounts($sel);
if (!$total) return "";
$items = Array();
$arr = Array();
foreach($result as $id)
{
$ob_name = $objects->getObject($id)->getName();
$arr[$ob_name] = $id;
}
ksort($arr);
foreach ($arr as $key=>$value) {
$item_arr = Array();
$item_arr['void:id'] = $item_arr['attribute:id'] = $value;
$item_arr['attribute:link'] = "?filter={$field}&value={$value}";
$item_arr['attribute:name'] = $key;
$tpl = ($mark == $value) ? $template_block_item_active : $template_block_item;
$items[] = $this->parseTemplate($tpl, $item_arr, false, $value);
}
$block_arr['subnodes:items'] = $items;
$block_arr['total'] = $total;
return $this->parseTemplate($template_block, $block_arr);
}
};
?>