コード例 #1
0
 public function getObjectsList($template = "default", $path = false, $limit = false, $ignore_paging = false, $i_need_deep = 0, $field_id = false, $asc = true)
 {
     // шаблон для tpl шаблонизатора
     if (!$template) {
         $template = "default";
     }
     // глубина поиска
     if (!$i_need_deep) {
         $i_need_deep = intval(getRequest('param4'));
     }
     if (!$i_need_deep) {
         $i_need_deep = 0;
     }
     $i_need_deep = intval($i_need_deep);
     if ($i_need_deep === -1) {
         $i_need_deep = 100;
     }
     $hierarchy = umiHierarchy::getInstance();
     list($template_block, $template_block_empty, $template_block_search_empty, $template_line) = def_module::loadTemplates("catalog/" . $template, "objects_block", "objects_block_empty", "objects_block_search_empty", "objects_block_line");
     // идентификатор объектов для поиска
     $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("catalog", "object")->getId();
     // идшник каталога в котором производиться отбор
     $category_id = $this->analyzeRequiredPath($path);
     // не задан каталог или патс не задан исключение
     if ($category_id === false && $path != KEYWORD_GRAB_ALL) {
         throw new publicException(getLabel('error-page-does-not-exist', null, $path));
     }
     // получть каталог
     $category_element = $hierarchy->getElement($category_id);
     // количество для выбора
     $per_page = $limit ? $limit : $this->per_page;
     $curr_page = getRequest('p');
     if ($ignore_paging) {
         $curr_page = 0;
     }
     // задаёться выборка
     $sel = new umiSelection();
     $sel->setElementTypeFilter();
     $sel->addElementType($hierarchy_type_id);
     if ($path != KEYWORD_GRAB_ALL) {
         $sel->setHierarchyFilter();
         $sel->addHierarchyFilter($category_id, $i_need_deep);
     }
     $sel->setPermissionsFilter();
     $sel->addPermissions();
     // полуить тип по айд
     $hierarchy_type = umiHierarchyTypesCollection::getInstance()->getType($hierarchy_type_id);
     // Получить тип данных, связанный с базовым типом МОДУЛЬ МЕТОД
     $type_id = umiObjectTypesCollection::getInstance()->getBaseType($hierarchy_type->getName(), $hierarchy_type->getExt());
     if ($path === KEYWORD_GRAB_ALL) {
         $curr_category_id = cmsController::getInstance()->getCurrentElementId();
     } else {
         $curr_category_id = $category_id;
     }
     if ($path != KEYWORD_GRAB_ALL) {
         // Определить id типа данных, которому принадлежат больше всего дочерних страниц для указанной страницы
         $type_id = $hierarchy->getDominantTypeId($curr_category_id, $i_need_deep, $hierarchy_type_id);
     }
     if (!$type_id) {
         $type_id = umiObjectTypesCollection::getInstance()->getBaseType($hierarchy_type->getName(), $hierarchy_type->getExt());
     }
     if ($type_id) {
         $this->autoDetectOrders($sel, $type_id);
         $this->autoDetectFilters($sel, $type_id);
         if ($this->isSelectionFiltered) {
             $template_block_empty = $template_block_search_empty;
             $this->isSelectionFiltered = false;
         }
     } else {
         $sel->setOrderFilter();
         $sel->setOrderByName();
     }
     if ($curr_page !== "all") {
         $curr_page = (int) $curr_page;
         $sel->setLimitFilter();
         $sel->addLimit($per_page, $curr_page);
     }
     if ($field_id) {
         if (is_numeric($field_id)) {
             $sel->setOrderByProperty($field_id, $asc);
         } else {
             if ($type_id) {
                 $field_id = umiObjectTypesCollection::getInstance()->getType($type_id)->getFieldId($field_id);
                 if ($field_id) {
                     $sel->setOrderByProperty($field_id, $asc);
                 } else {
                     $sel->setOrderByOrd($asc);
                 }
             } else {
                 $sel->setOrderByOrd($asc);
             }
         }
     } else {
         $sel->setOrderByOrd($asc);
     }
     $result = umiSelectionsParser::runSelection($sel);
     $total = umiSelectionsParser::runSelectionCounts($sel);
     // формируется результат
     if (($sz = sizeof($result)) > 0) {
         $block_arr = array();
         $lines = array();
         for ($i = 0; $i < $sz; $i++) {
             $element_id = $result[$i];
             $element = umiHierarchy::getInstance()->getElement($element_id);
             if (!$element) {
                 continue;
             }
             $line_arr = array();
             $line_arr['attribute:id'] = $element_id;
             $line_arr['attribute:alt_name'] = $element->getAltName();
             $line_arr['attribute:link'] = umiHierarchy::getInstance()->getPathById($element_id);
             $line_arr['xlink:href'] = "upage://" . $element_id;
             $line_arr['node:text'] = $element->getName();
             $lines[] = self::parseTemplate($template_line, $line_arr, $element_id);
             $this->pushEditable("catalog", "object", $element_id);
             umiHierarchy::getInstance()->unloadElement($element_id);
         }
         $block_arr['subnodes:lines'] = $lines;
         $block_arr['numpages'] = umiPagenum::generateNumPage($total, $per_page);
         $block_arr['total'] = $total;
         $block_arr['per_page'] = $per_page;
         $block_arr['category_id'] = $category_id;
         if ($type_id) {
             $block_arr['type_id'] = $type_id;
         }
         return self::parseTemplate($template_block, $block_arr, $category_id);
     } else {
         $block_arr['numpages'] = umiPagenum::generateNumPage(0, 0);
         $block_arr['lines'] = "";
         $block_arr['total'] = 0;
         $block_arr['per_page'] = 0;
         $block_arr['category_id'] = $category_id;
         return self::parseTemplate($template_block_empty, $block_arr, $category_id);
     }
 }
コード例 #2
0
ファイル: class.php プロジェクト: BGCX261/zimmerli-svn-to-git
 public function getObjectsList($template = "default", $path = false, $limit = false, $ignore_paging = false, $i_need_deep = -1, $field_id = false, $asc = true)
 {
     if (!$template) {
         $template = "default";
     }
     if (!$i_need_deep) {
         $i_need_deep = intval(getRequest('param4'));
     }
     if (!$i_need_deep) {
         $i_need_deep = 0;
     }
     $i_need_deep = intval($i_need_deep);
     if ($i_need_deep === -1) {
         $i_need_deep = 100;
     }
     $hierarchy = umiHierarchy::getInstance();
     list($template_block, $template_block_empty, $template_block_search_empty, $template_line) = def_module::loadTemplates("catalog/" . $template, "objects_block", "objects_block_empty", "objects_block_search_empty", "objects_block_line");
     $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("catalog", "object")->getId();
     $category_id = $this->analyzeRequiredPath($path);
     if ($category_id === false && $path != KEYWORD_GRAB_ALL) {
         throw new publicException(getLabel('error-page-does-not-exist', null, $path));
     }
     $category_element = $hierarchy->getElement($category_id);
     $per_page = $limit ? $limit : $this->per_page;
     $curr_page = getRequest('p');
     if ($ignore_paging) {
         $curr_page = 0;
     }
     $sel = new umiSelection();
     $sel->setElementTypeFilter();
     $sel->addElementType($hierarchy_type_id);
     if ($path != KEYWORD_GRAB_ALL) {
         $sel->setHierarchyFilter();
         $sel->addHierarchyFilter($category_id, $i_need_deep);
     }
     $sel->setPermissionsFilter();
     $sel->addPermissions();
     $hierarchy_type = umiHierarchyTypesCollection::getInstance()->getType($hierarchy_type_id);
     $type_id = umiObjectTypesCollection::getInstance()->getBaseType($hierarchy_type->getName(), $hierarchy_type->getExt());
     if ($path === KEYWORD_GRAB_ALL) {
         $curr_category_id = cmsController::getInstance()->getCurrentElementId();
     } else {
         $curr_category_id = $category_id;
     }
     if ($path != KEYWORD_GRAB_ALL) {
         $type_id = $hierarchy->getDominantTypeId($curr_category_id, $i_need_deep, $hierarchy_type_id);
     }
     if (!$type_id) {
         $type_id = umiObjectTypesCollection::getInstance()->getBaseType($hierarchy_type->getName(), $hierarchy_type->getExt());
     }
     if ($type_id) {
         $this->autoDetectOrders($sel, $type_id);
         $this->autoDetectFilters($sel, $type_id);
         if ($this->isSelectionFiltered) {
             $template_block_empty = $template_block_search_empty;
             $this->isSelectionFiltered = false;
         }
     } else {
         $sel->setOrderFilter();
         $sel->setOrderByName();
     }
     if ($curr_page !== "all") {
         $curr_page = (int) $curr_page;
         $sel->setLimitFilter();
         $sel->addLimit($per_page, $curr_page);
     }
     if ($field_id) {
         if (is_numeric($field_id)) {
             $sel->setOrderByProperty($field_id, $asc);
         } else {
             if ($type_id) {
                 $field_id = umiObjectTypesCollection::getInstance()->getType($type_id)->getFieldId($field_id);
                 if ($field_id) {
                     $sel->setOrderByProperty($field_id, $asc);
                 } else {
                     $sel->setOrderByOrd($asc);
                 }
             } else {
                 $sel->setOrderByOrd($asc);
             }
         }
     } else {
         $sel->setOrderByOrd($asc);
     }
     $result = umiSelectionsParser::runSelection($sel);
     $total = umiSelectionsParser::runSelectionCounts($sel);
     if (($sz = sizeof($result)) > 0) {
         $block_arr = array();
         $lines = array();
         for ($i = 0; $i < $sz; $i++) {
             $element_id = $result[$i];
             $element = umiHierarchy::getInstance()->getElement($element_id);
             if (!$element) {
                 continue;
             }
             $line_arr = array();
             $line_arr['attribute:id'] = $element_id;
             $line_arr['attribute:alt_name'] = $element->getAltName();
             $line_arr['attribute:link'] = umiHierarchy::getInstance()->getPathById($element_id);
             $line_arr['xlink:href'] = "upage://" . $element_id;
             $line_arr['node:text'] = $element->getName();
             $lines[] = self::parseTemplate($template_line, $line_arr, $element_id);
             $this->pushEditable("catalog", "object", $element_id);
             umiHierarchy::getInstance()->unloadElement($element_id);
         }
         $block_arr['subnodes:lines'] = $lines;
         $block_arr['numpages'] = umiPagenum::generateNumPage($total, $per_page);
         $block_arr['total'] = $total;
         $block_arr['per_page'] = $per_page;
         $block_arr['category_id'] = $category_id;
         if ($type_id) {
             $block_arr['type_id'] = $type_id;
         }
         return self::parseTemplate($template_block, $block_arr, $category_id);
     } else {
         $block_arr['numpages'] = umiPagenum::generateNumPage(0, 0);
         $block_arr['lines'] = "";
         $block_arr['total'] = 0;
         $block_arr['per_page'] = 0;
         $block_arr['category_id'] = $category_id;
         return self::parseTemplate($template_block_empty, $block_arr, $category_id);
     }
 }
コード例 #3
0
 public function numpages($vfbb44b4487415b134bce9c790a27fe5e = 0, $v9d85c254b5062e518a134a61950999c3 = 0, $v66f6181bcb4cff4cd38fbc804a036db6 = "default", $v51746fc9cfaaf892e94c2d56d7508b37 = "p", $vc381645e69cb46e1f8cd9c8efaf89360 = false)
 {
     if (!$v51746fc9cfaaf892e94c2d56d7508b37) {
         $v51746fc9cfaaf892e94c2d56d7508b37 = "p";
     }
     if (!$vc381645e69cb46e1f8cd9c8efaf89360) {
         (int) ($vc381645e69cb46e1f8cd9c8efaf89360 = false);
     }
     return umiPagenum::generateNumPage($vfbb44b4487415b134bce9c790a27fe5e, $v9d85c254b5062e518a134a61950999c3, $v66f6181bcb4cff4cd38fbc804a036db6, $v51746fc9cfaaf892e94c2d56d7508b37, $vc381645e69cb46e1f8cd9c8efaf89360);
 }