public function shared_files()
 {
     $this->setDataType("list");
     $this->setActionType("view");
     if ($this->ifNotXmlMode()) {
         return $this->doData();
     }
     $per_page = 20;
     $curr_page = getRequest('p');
     $hierarchyTypes = umiHierarchyTypesCollection::getInstance();
     $hierarchy_type_id = $hierarchyTypes->getTypeByName("filemanager", "shared_file")->getId();
     $sel = new umiSelection();
     $sel->addLimit($per_page, $curr_page);
     $sel->addElementType($hierarchy_type_id);
     $this->autoDetectAllFilters($sel);
     $sel->addPermissions();
     $result = umiSelectionsParser::runSelection($sel);
     $total = umiSelectionsParser::runSelectionCounts($sel);
     $this->setDataType("list");
     $this->setActionType("view");
     $this->setDataRange($per_page, $curr_page * $per_page);
     $data = $this->prepareData($result, "pages");
     $this->setData($data, $total);
     return $this->doData();
 }
예제 #2
0
 public function count_users()
 {
     $typeId = umiObjectTypesCollection::getInstance()->getBaseType("users", "user");
     $type = umiObjectTypesCollection::getInstance()->getType($typeId);
     $isActiveField = $type->getFieldId('is_activated');
     $sel = new umiSelection();
     $sel->addObjectType($typeId);
     $sel->addPropertyFilterEqual($isActiveField, true);
     return umiSelectionsParser::runSelectionCounts($sel);
     $total;
 }
예제 #3
0
 public static function getDatabaseStatus()
 {
     $result = array();
     $v1723bdd4ee51910267a625cae41ced8a = umiHierarchyTypesCollection::getInstance();
     $v9b81909fd0da3add2602a8d0ede0e4e7 = umiObjectTypesCollection::getInstance();
     $v3527525cd11a98e16f6c1d31fe7d89dd = $v1723bdd4ee51910267a625cae41ced8a->getTypesList();
     foreach ($v3527525cd11a98e16f6c1d31fe7d89dd as $v89b0b9deff65f8b9cd1f71bc74ce36ba) {
         $vacf567c9c3d6cf7c6e2cc0ce108e0631 = $v89b0b9deff65f8b9cd1f71bc74ce36ba->getId();
         $v4aa3988e15afb9618423a0c2961a469f = self::checkIfBranchedByHierarchyTypeId($vacf567c9c3d6cf7c6e2cc0ce108e0631);
         $v8be74552df93e31bbdd6b36ed74bdb6a = new umiSelection();
         $v8be74552df93e31bbdd6b36ed74bdb6a->addElementType($vacf567c9c3d6cf7c6e2cc0ce108e0631);
         $ve2942a04780e223b215eb8b663cf5353 = umiSelectionsParser::runSelectionCounts($v8be74552df93e31bbdd6b36ed74bdb6a);
         $result[] = array('id' => $vacf567c9c3d6cf7c6e2cc0ce108e0631, 'isBranched' => $v4aa3988e15afb9618423a0c2961a469f, 'count' => $ve2942a04780e223b215eb8b663cf5353);
     }
     return $result;
 }
예제 #4
0
 public function subscribers_list()
 {
     // input
     $iDispId = $_REQUEST['param0'];
     // set tab
     $this->sheets_set_active("subscribers_list");
     //input:
     $this->load_forms();
     $iCurrPage = (int) $_REQUEST['p'];
     $params = array();
     // gen banners list
     $params['rows'] = "";
     //
     $oSbsSelection = new umiSelection();
     $oSbsSelection->setObjectTypeFilter();
     $oSbsSelection->setLimitFilter();
     $oSbsSelection->addLimit($this->per_page, $iCurrPage);
     $iHierarchyTypeId = umiHierarchyTypesCollection::getInstance()->getTypeByName("dispatches", "subscriber")->getId();
     $iSbsTypeId = umiObjectTypesCollection::getInstance()->getTypeByHierarchyTypeId($iHierarchyTypeId);
     $oSbsType = umiObjectTypesCollection::getInstance()->getType($iSbsTypeId);
     $oSbsSelection->addObjectType($iSbsTypeId);
     // add curr dispatch filter
     if ($iDispId) {
         $oDispObj = umiObjectsCollection::getInstance()->getObject($iDispId);
         if ($oDispObj instanceof umiObject) {
             $oSbsSelection->setPropertyFilter();
             $oSbsSelection->addPropertyFilterEqual($oSbsType->getFieldId('subscriber_dispatches'), $iDispId);
         }
     }
     $arrSelResults = umiSelectionsParser::runSelection($oSbsSelection);
     $iCountResults = umiSelectionsParser::runSelectionCounts($oSbsSelection);
     $iSbsNum = $this->per_page * $iCurrPage;
     for ($iI = 0; $iI < count($arrSelResults); $iI++) {
         $params['rows'] .= self::renderSubscriber($arrSelResults[$iI], ++$iSbsNum);
     }
     $params['pages'] = $this->generateNumPage($iCountResults, $this->per_page, $iCurrPage);
     return $this->parse_form("subscribers_list", $params);
 }
 public function pages_mklist_by_tags($s_tags, $i_domain_id = NULL, $s_template = "tags", $i_per_page = false, $b_ignore_paging = false, $s_base_types = '')
 {
     /*
      */
     // init and context :
     $s_tpl_pages = "pages";
     $s_tpl_page = "page";
     $s_tpl_pages_empty = "pages_empty";
     // validate input :
     $i_per_page = intval($i_per_page);
     if (!$i_per_page) {
         $i_per_page = 10;
     }
     if ($i_per_page === -1) {
         $b_ignore_paging = true;
     }
     $s_template = strval($s_template);
     if (!strlen($s_template)) {
         $s_template = "tags";
     }
     $i_curr_page = intval(getRequest('p'));
     if ($b_ignore_paging) {
         $i_curr_page = 0;
     }
     $s_base_types = strval($s_base_types);
     // load templates :
     list($tpl_pages, $tpl_page, $tpl_pages_empty) = def_module::loadTemplates("content/" . $s_template, $s_tpl_pages, $s_tpl_page, $s_tpl_pages_empty);
     // process :
     $o_sel = new umiSelection();
     if ($i_domain_id) {
         $o_sel->setIsDomainIgnored(false);
     } else {
         $o_sel->setIsDomainIgnored(true);
     }
     if (strlen($s_base_types)) {
         $o_sel->setElementTypeFilter();
         $arr_base_types = preg_split("/\\s+/is", $s_base_types);
         foreach ($arr_base_types as $s_next_type) {
             $arr_next_type = explode('.', $s_next_type);
             if (count($arr_next_type) === 2) {
                 $o_hierarchy_type = umiHierarchyTypesCollection::getInstance()->getTypeByName($arr_next_type[0], $arr_next_type[1]);
                 if ($o_hierarchy_type instanceof umiHierarchyType) {
                     $i_hierarchy_type_id = $o_hierarchy_type->getId();
                     $o_sel->addElementType($i_hierarchy_type_id);
                 }
             }
         }
     }
     $o_sel->forceHierarchyTable();
     $o_object_type = umiObjectTypesCollection::getInstance()->getTypeByGUID('root-pages-type');
     $i_tags_field_id = $o_object_type->getFieldId('tags');
     $arr_tags = preg_split("/\\s*,\\s*/is", $s_tags);
     $o_sel->setPropertyFilter();
     $o_sel->addPropertyFilterEqual($i_tags_field_id, $arr_tags);
     $o_sel->setPermissionsFilter();
     $o_sel->addPermissions();
     if ($i_per_page !== -1) {
         $o_sel->setLimitFilter();
         $o_sel->addLimit($i_per_page, $i_curr_page);
     }
     $result = umiSelectionsParser::runSelection($o_sel);
     $total = umiSelectionsParser::runSelectionCounts($o_sel);
     $block_arr = array();
     if (($sz = sizeof($result)) > 0) {
         $arr_items = array();
         for ($i = 0; $i < $sz; $i++) {
             $line_arr = array();
             $element_id = intval($result[$i]);
             $element = umiHierarchy::getInstance()->getElement($element_id);
             if (!$element) {
                 continue;
             }
             $line_arr['attribute:id'] = $element_id;
             $line_arr['node:name'] = $element->getName();
             $line_arr['attribute:link'] = umiHierarchy::getInstance()->getPathById($element_id);
             $line_arr['void:header'] = $lines_arr['name'] = $element->getName();
             if ($publish_time = $element->getValue('publish_time')) {
                 $line_arr['attribute:publish_time'] = $publish_time->getFormattedDate("U");
             }
             $arr_items[] = def_module::parseTemplate($tpl_page, $line_arr, $element_id);
             umiHierarchy::getInstance()->unloadElement($element_id);
         }
         $block_arr['subnodes:items'] = $arr_items;
         $block_arr['tags'] = $s_tags;
         $block_arr['total'] = $total;
         $block_arr['per_page'] = $i_per_page;
         return def_module::parseTemplate($tpl_pages, $block_arr);
     } else {
         return def_module::parseTemplate($tpl_pages_empty, $block_arr);
     }
 }
예제 #6
0
 public function lastlents($elementPath, $template = "default", $per_page = false, $ignore_paging = false)
 {
     if (!$per_page) {
         $per_page = $this->per_page;
     }
     list($template_block, $template_block_empty, $template_line, $template_archive) = def_module::loadTemplates("news/" . $template, "listlents_block", "listlents_block_empty", "listlents_item", "listlents_archive");
     $curr_page = (int) getRequest('p');
     if ($ignore_paging) {
         $curr_page = 0;
     }
     $parent_id = $this->analyzeRequiredPath($elementPath);
     if ($parent_id === false) {
         throw new publicException(getLabel('error-page-does-not-exist', null, $elementPath));
     }
     $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("news", "rubric")->getId();
     $sel = new umiSelection();
     $sel->addElementType($hierarchy_type_id);
     $sel->addHierarchyFilter($parent_id, 0, true);
     $sel->addPermissions();
     $sel->addLimit($per_page, $curr_page);
     $result = umiSelectionsParser::runSelection($sel);
     $total = umiSelectionsParser::runSelectionCounts($sel);
     if (($sz = sizeof($result)) > 0) {
         $block_arr = array();
         $lines = array();
         for ($i = 0; $i < $sz; $i++) {
             $line_arr = array();
             $element_id = $result[$i];
             $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['void:header'] = $lines_arr['name'] = $element->getName();
             $line_arr['node:name'] = $element->getName();
             $lines[] = self::parseTemplate($template_line, $line_arr, $element_id);
             $this->pushEditable("news", "rubric", $element_id);
         }
         if (is_array($parent_id)) {
             list($parent_id) = $parent_id;
         }
         $block_arr['subnodes:items'] = $block_arr['void:lines'] = $lines;
         $block_arr['total'] = $total;
         $block_arr['per_page'] = $per_page;
         return self::parseTemplate($template_block, $block_arr, $parent_id);
     } else {
         return $template_block_empty;
     }
 }
예제 #7
0
 public function count()
 {
     return umiSelectionsParser::runSelectionCounts($this);
 }
예제 #8
0
 public function makeAdminOutputList($s_data_action, $s_items_type, $o_selection, $i_limit, $i_offset)
 {
     // process selection
     $arr_result = umiSelectionsParser::runSelection($o_selection);
     $i_total = umiSelectionsParser::runSelectionCounts($o_selection);
     // Устанавливаем тип для вывода данных в "list" - список
     $this->setDataType("list");
     // Устанавливаем действие над списокм
     $this->setActionType($s_data_action);
     // Указываем диапозон данных
     $this->setDataRange($i_limit, $i_offset);
     // Подготавливаем данные, чтобы потом корректно их вывести
     $data = $this->prepareData($arr_result, $s_items_type);
     // Завершаем вывод
     $this->setData($data, $i_total);
     return $this->doData();
 }
예제 #9
0
 public function collectAllChanges($module, $method, $parentElementId = false)
 {
     $endTime = time();
     $beginTime = $endTime - 3600 * 24 * 30;
     $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName($module, $method)->getId();
     $object_type_id = umiObjectTypesCollection::getInstance()->getBaseType($module, $method);
     $object_type = umiObjectTypesCollection::getInstance()->getType($object_type_id);
     $publish_time_field_id = $object_type->getFieldId('publish_time');
     $sel = new umiSelection();
     $sel->setElementTypeFilter();
     $sel->addElementType($hierarchy_type_id);
     $sel->setPermissionsFilter();
     $sel->addPermissions();
     $sel->setOrderFilter();
     $sel->setOrderByProperty($publish_time_field_id, false);
     $sel->setPropertyFilter();
     $sel->addPropertyFilterBetween($publish_time_field_id, $beginTime, $endTime);
     if ($parentElementId !== false) {
         if (!is_numeric($parentElementId)) {
             $parentElementId = umiHierarchy::getInstance()->getIdByPath($parentElementId);
         }
         $sel->setHierarchyFilter();
         $sel->addHierarchyFilter($parentElementId);
     }
     $result = umiSelectionsParser::runSelection($sel);
     $total = umiSelectionsParser::runSelectionCounts($sel);
     $res = array();
     foreach ($result as $elementId) {
         $childs = sizeof(umiHierarchy::getInstance()->getChilds($elementId));
         $res[] = array("id" => $elementId, "childs" => $childs);
     }
     return array("result" => $res, "total" => $total);
 }
 /**
  * Установка активности поля в зависимости от набранных фильтров
  */
 protected function setState(&$arField)
 {
     $bNeedRestoreFields = $bNeedRestoreKFields = false;
     $fields_filter = isset($_REQUEST['fields_filter']) ? $_REQUEST['fields_filter'] : array();
     $k_fields_filter = isset($_REQUEST['k_fields_filter']) ? $_REQUEST['k_fields_filter'] : array();
     $field_name = $arField['name'];
     if (isset($fields_filter[$field_name])) {
         $bNeedRestoreFields = $fields_filter[$field_name];
         unset($_REQUEST['fields_filter'][$field_name]);
     }
     if (isset($k_fields_filter[$field_name])) {
         $bNeedRestoreKFields = $k_fields_filter[$field_name];
         unset($_REQUEST['k_fields_filter'][$field_name]);
     }
     $iFieldId = $arField['id'];
     switch ($arField['type']) {
         case "boolean":
             $sel = $this->getCurrentCountSelection();
             $sel->addPropertyFilterEqual($iFieldId, 1);
             $sqls = umiSelectionsParser::parseSelection($sel);
             $query_key = trim(str_replace(array("\n", "\r", "\t", " "), "", $sqls['count']));
             $count = 0;
             //Count of goods with this value, with selected filters but without filering on this field
             if ($query_key) {
                 $oCache = kFilters::getInstance($this->catalogId)->getCache();
                 //try load from cache
                 $count = $oCache->getQuery($query_key, $this->catalogId);
                 if (is_null($count)) {
                     $count = umiSelectionsParser::runSelectionCounts($sel);
                     //save to cache
                     $oCache->saveQuery($count, $query_key, $this->catalogId);
                 }
             }
             if ($count == 0) {
                 $arField['active'] = false;
             } else {
                 $arField['active'] = true;
             }
             break;
         case "option":
             $arValues = $arField['values'];
             foreach ($arValues as $i => $arValue) {
                 $sel = $this->getCurrentCountSelection();
                 $sel->addPropertyFilterEqual($iFieldId, $arValue['id']);
                 $sqls = umiSelectionsParser::parseSelection($sel);
                 $query_key = trim(str_replace(array("\n", "\r", "\t", " "), "", $sqls['count']));
                 $count = 0;
                 //Count of goods with this value, with selected filters but without filering on this field
                 if ($query_key) {
                     $oCache = kFilters::getInstance($this->catalogId)->getCache();
                     //try load from cache
                     $count = $oCache->getQuery($query_key, $this->catalogId);
                     if (is_null($count)) {
                         $count = umiSelectionsParser::runSelectionCounts($sel);
                         //save to cache
                         $oCache->saveQuery($count, $query_key, $this->catalogId);
                     }
                 }
                 if ($count == 0) {
                     $arField['values'][$i]['active'] = false;
                 } else {
                     $arField['values'][$i]['active'] = true;
                 }
             }
             break;
     }
     if ($bNeedRestoreFields !== false) {
         $_REQUEST['fields_filter'][$field_name] = $bNeedRestoreFields;
     }
     if ($bNeedRestoreKFields !== false) {
         $_REQUEST['k_fields_filter'][$field_name] = $bNeedRestoreKFields;
     }
 }
예제 #11
0
 public function album($path = false, $template = "default", $limit = false, $ignore_paging = false)
 {
     $curr_page = (int) getRequest('p');
     $per_page = $limit ? $limit : $this->per_page;
     if ($ignore_paging) {
         $curr_page = 0;
     }
     $element_id = $this->analyzeRequiredPath($path);
     if ($element_id === false && $path != KEYWORD_GRAB_ALL) {
         throw new publicException(getLabel('error-page-does-not-exist', null, $path));
     }
     list($template_block, $template_block_empty, $template_line) = def_module::loadTemplates("photoalbum/" . $template, "album_block", "album_block_empty", "album_block_line");
     $block_arr = array();
     $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("photoalbum", "photo")->getId();
     $sel = new umiSelection();
     $sel->addElementType($hierarchy_type_id);
     if ($path != KEYWORD_GRAB_ALL) {
         $sel->addHierarchyFilter($element_id);
     }
     $sel->addPermissions();
     $sel->addLimit($per_page, $curr_page);
     $result = umiSelectionsParser::runSelection($sel);
     $total = umiSelectionsParser::runSelectionCounts($sel);
     $block_arr['id'] = $block_arr['void:album_id'] = $element_id;
     $lines = array();
     if ($total > 0) {
         foreach ($result as $photo_element_id) {
             $line_arr = array();
             $photo_element = umiHierarchy::getInstance()->getElement($photo_element_id);
             if (!$photo_element) {
                 continue;
             }
             $line_arr['attribute:id'] = $photo_element_id;
             $line_arr['attribute:link'] = umiHierarchy::getInstance()->getPathById($photo_element_id);
             $line_arr['xlink:href'] = "upage://" . $photo_element_id;
             $line_arr['node:name'] = $photo_element->getName();
             $this->pushEditable("photoalbum", "photo", $photo_element_id);
             $lines[] = self::parseTemplate($template_line, $line_arr, $photo_element_id);
         }
     } else {
         return self::parseTemplate($template_block_empty, $block_arr, $element_id);
     }
     $block_arr['subnodes:items'] = $block_arr['void:lines'] = $lines;
     $block_arr['total'] = $total;
     $block_arr['per_page'] = $per_page;
     $block_arr['link'] = umiHierarchy::getInstance()->getPathById($element_id);
     return self::parseTemplate($template_block, $block_arr, $element_id);
 }
예제 #12
0
	public function projects($template = "default", $limit = false, $ignore_paging = false) {
		list($template_block, $template_block_empty, $template_line) = def_module::loadTemplates("faq/".$template, "projects_block", "projects_block_empty", "projects_block_line");

		$hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("faq", "project")->getId();

		$per_page = ($limit) ? $limit : $this->per_page;
		$curr_page = (int) getRequest('p');
		if($ignore_paging) $curr_page = 0;

		$sel = new umiSelection;
		$sel->addElementType($hierarchy_type_id);
		$sel->addLimit($per_page, $curr_page);
		$sel->addPermissions();
		$result = umiSelectionsParser::runSelection($sel);
		$total = umiSelectionsParser::runSelectionCounts($sel);

		if(($sz = sizeof($result)) > 0) {
			$block_arr = Array();

			$lines = Array();
			for($i = 0; $i < $sz; $i++) {
				if ($i < $limit || $limit === false) {
					$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:name'] = $line_arr['void:text'] = $element->getName();
					$line_arr['void:alt_name'] = $element->getAltName();
					$line_arr['attribute:link'] = $element->link;
					$line_arr['xlink:href'] = "upage://" . $element_id;

					$this->pushEditable("faq", "project", $element_id);
					$lines[] = self::parseTemplate($template_line, $line_arr, $element_id);
				}
			}

			$block_arr['subnodes:lines'] = $lines;
			$block_arr['total'] = $total;
			$block_arr['per_page'] = $per_page;

			return self::parseTemplate($template_block, $block_arr);
		} else {
			return $template_block_empty;
		}
	}
예제 #13
0
    function getDateLink($day, $month, $year)
    {
        
        $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("news", "item")->getId();

        $object_type_id = umiObjectTypesCollection::getInstance()->getBaseType("news", "item");
        $object_type = umiObjectTypesCollection::getInstance()->getType($object_type_id);
        $publish_time_field_id = $object_type->getFieldId('publish_time');


        $sel = new umiSelection;
        $sel->setElementTypeFilter();
        $sel->addElementType($hierarchy_type_id);
        
        $sel->setPermissionsFilter();
        $sel->addPermissions();

        $date1 = mktime(0, 0, 0, $month, $day, $year);
        $date2 = mktime(23, 59, 59, $month, $day, $year);
        
        $sel->setPropertyFilter();
        $sel->addPropertyFilterBetween($publish_time_field_id, $date1, $date2);
        
        $result = umiSelectionsParser::runSelection($sel);
        $total = umiSelectionsParser::runSelectionCounts($sel);

        if (!empty($result))
        {
        	if ($total > 1)
            {
                $link = "?year=" . $year . "&month=" . $month . "&day=" . $day;	
            }
            else
            {
                list($element_id) = $result;
                $link = umiHierarchy::getInstance()->getPathById($element_id)
                      . "?year=" . $year . "&month=" . $month  ;	
            }
        }
        else
        {
        	$link = "";
        }
        
        return $link;
    }
예제 #14
0
 public function getGroupUsersCount($groupId = false)
 {
     $objectTypes = umiObjectTypesCollection::getInstance();
     $userObjectTypeId = $objectTypes->getBaseType('users', 'user');
     $userObjectType = $objectTypes->getType($userObjectTypeId);
     if ($userObjectType instanceof umiObjectType == false) {
         throw new publicException("Can't load user object type");
     }
     $sel = new umiSelection();
     $sel->addObjectType($userObjectTypeId);
     if ($groupId !== false) {
         if ($groupId != 0) {
             $sel->addPropertyFilterEqual($userObjectType->getFieldId('groups'), $groupId);
         } else {
             $sel->addPropertyFilterIsNull($userObjectType->getFieldId('groups'));
         }
     }
     return umiSelectionsParser::runSelectionCounts($sel);
 }
예제 #15
0
 public function checkAddressExistence($_sAddress)
 {
     $count = 0;
     if ($_sAddress) {
         $find = '%' . $_sAddress . '%';
         $oTypes = umiObjectTypesCollection::getInstance();
         $iTypeId = $oTypes->getBaseType('webforms', 'address');
         $oSelection = new umiSelection();
         $oSelection->addObjectType($iTypeId);
         $oSelection->addPropertyFilterLike($oTypes->getType($iTypeId)->getFieldId('address_list'), $find);
         $count = umiSelectionsParser::runSelectionCounts($oSelection);
     }
     if (!$count) {
         $this->errorNewMessage("%unknown_address%");
         $this->errorPanic();
     }
 }
예제 #16
0
 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);
     }
 }
예제 #17
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);
     }
 }
예제 #18
0
 public function getFilteredPages($v94757cae63fd3e398c0811a976dd6bbe, $vdfc394bd05a4b48161c790034af522a8, $v2063c1608d6e0baf80249c42e2be5804, $v9d85c254b5062e518a134a61950999c3 = 10, $v66f6181bcb4cff4cd38fbc804a036db6 = "default", $v126424c808da347218ba631a78feaf04 = false, $v3aabf39f2d943fa886d86dcbbee4d910 = false, $v375a52cb87b22005816fe7a418ec6660 = true)
 {
     $ve1ba980ce14a8c0d7e2779f895ab8695 = getRequest('p');
     if ($v126424c808da347218ba631a78feaf04) {
         $ve1ba980ce14a8c0d7e2779f895ab8695 = 0;
     }
     list($v364f9b183bd2dd9e0beb45c754830a6c, $ve6a2fd7211958cfe50efa4d14bd332f5, $v28d65bb7a643774ada22f54ca0679289) = def_module::loadTemplates("filtered_pages/" . $v66f6181bcb4cff4cd38fbc804a036db6, "pages_block", "pages_block_line", "pages_block_empty");
     $v599dcce2998a6b40b1e38e8c6006cb0a = umiObjectTypesCollection::getInstance()->getType($v94757cae63fd3e398c0811a976dd6bbe);
     if ($v599dcce2998a6b40b1e38e8c6006cb0a instanceof umiObjectType) {
         if ($vf8a30f899e9d691c760031d60ea0f3a2 = $v599dcce2998a6b40b1e38e8c6006cb0a->getFieldId($vdfc394bd05a4b48161c790034af522a8)) {
             $v8be74552df93e31bbdd6b36ed74bdb6a = new umiSelection();
             $v8be74552df93e31bbdd6b36ed74bdb6a->forceHierarchyTable(true);
             $v8be74552df93e31bbdd6b36ed74bdb6a->addObjectType($v94757cae63fd3e398c0811a976dd6bbe);
             $v06e3d36fa30cea095545139854ad1fb9 = umiFieldsCollection::getInstance()->getField($vf8a30f899e9d691c760031d60ea0f3a2);
             if ($v051369818a8073bba5feeb0e957eb308 = $v06e3d36fa30cea095545139854ad1fb9->getGuideId()) {
                 if (!is_numeric($v2063c1608d6e0baf80249c42e2be5804)) {
                     $vd47c20d305d6a44856735d5fe5c086ca = umiObjectsCollection::getInstance()->getGuidedItems($v051369818a8073bba5feeb0e957eb308);
                     $v2063c1608d6e0baf80249c42e2be5804 = array_search($v2063c1608d6e0baf80249c42e2be5804, $vd47c20d305d6a44856735d5fe5c086ca);
                 }
             }
             $v8be74552df93e31bbdd6b36ed74bdb6a->addPropertyFilterEqual($vf8a30f899e9d691c760031d60ea0f3a2, $v2063c1608d6e0baf80249c42e2be5804);
             $v8be74552df93e31bbdd6b36ed74bdb6a->addPermissions();
             $v8be74552df93e31bbdd6b36ed74bdb6a->addLimit($v9d85c254b5062e518a134a61950999c3, $ve1ba980ce14a8c0d7e2779f895ab8695);
             $v8be74552df93e31bbdd6b36ed74bdb6a->addActiveFilter(true);
             if ($v3aabf39f2d943fa886d86dcbbee4d910) {
                 $v8be74552df93e31bbdd6b36ed74bdb6a->setOrderByProperty($v3aabf39f2d943fa886d86dcbbee4d910, $v375a52cb87b22005816fe7a418ec6660);
             } else {
                 $v8be74552df93e31bbdd6b36ed74bdb6a->setOrderByObjectId($v375a52cb87b22005816fe7a418ec6660);
             }
             $result = umiSelectionsParser::runSelection($v8be74552df93e31bbdd6b36ed74bdb6a);
             $vfbb44b4487415b134bce9c790a27fe5e = umiSelectionsParser::runSelectionCounts($v8be74552df93e31bbdd6b36ed74bdb6a);
             $vfca1bff8ad8b3a8585abfb0ad523ba42 = array();
             if ($vfbb44b4487415b134bce9c790a27fe5e > 0) {
                 $v691d502cfd0e0626cd3b058e5682ad1c = array();
                 $v12a673c3eb40ea95d992c775443b8709 = umiHierarchy::getInstance();
                 foreach ($result as $v7057e8409c7c531a1a6e9ac3df4ed549) {
                     $v8e2dcfd7e7e24b1ca76c1193f645902b = $v12a673c3eb40ea95d992c775443b8709->getElement($v7057e8409c7c531a1a6e9ac3df4ed549);
                     if ($v8e2dcfd7e7e24b1ca76c1193f645902b instanceof umiHierarchyElement) {
                         $v691d502cfd0e0626cd3b058e5682ad1c[] = def_module::parseTemplate($ve6a2fd7211958cfe50efa4d14bd332f5, array('attribute:id' => $v8e2dcfd7e7e24b1ca76c1193f645902b->id, 'attribute:link' => $v8e2dcfd7e7e24b1ca76c1193f645902b->link, 'node:name' => $v8e2dcfd7e7e24b1ca76c1193f645902b->name));
                     }
                 }
                 $vfca1bff8ad8b3a8585abfb0ad523ba42['subnodes:items'] = $v691d502cfd0e0626cd3b058e5682ad1c;
                 $v66f6181bcb4cff4cd38fbc804a036db6 = $v364f9b183bd2dd9e0beb45c754830a6c;
             } else {
                 $v66f6181bcb4cff4cd38fbc804a036db6 = $v28d65bb7a643774ada22f54ca0679289;
             }
             $vfca1bff8ad8b3a8585abfb0ad523ba42['total'] = $vfbb44b4487415b134bce9c790a27fe5e;
             $vfca1bff8ad8b3a8585abfb0ad523ba42['per_page'] = $v9d85c254b5062e518a134a61950999c3;
             return def_module::parseTemplate($v66f6181bcb4cff4cd38fbc804a036db6, $vfca1bff8ad8b3a8585abfb0ad523ba42);
         } else {
             throw new publicException("Type \"" . $v599dcce2998a6b40b1e38e8c6006cb0a->getName() . "\" doesn't have property \"{$vdfc394bd05a4b48161c790034af522a8}\"");
         }
     } else {
         throw new publicException("Wrong type id \"{$v94757cae63fd3e398c0811a976dd6bbe}\"");
     }
 }
예제 #19
0
 /**
  * @desc Выводит список черновиков текущего пользователя
  * @param Int $blogId Идентификатор блога
  * @param String $template Имя файла шаблона для вывода
  * @return string|array
  */
 public function draughtsList($blogId = false, $template = 'default', $limit = false)
 {
     list($sTemplateBlock, $sTemplateLine) = self::loadTemplates('blogs20/' . $template, 'posts_list_block', 'posts_list_line');
     $page = (int) getRequest('p');
     $oBlog = null;
     $oHierarchy = umiHierarchy::getInstance();
     if ($blogId === false) {
         $iTmp = getRequest('param0');
         if ($iTmp) {
             $blogId = (int) $iTmp;
         }
     }
     $hierarchyTypes = umiHierarchyTypesCollection::getInstance();
     $blogHierachyTypeId = $hierarchyTypes->getTypeByName("blogs20", "blog")->getId();
     $sel = new umiSelection();
     $hierarchy_type_id = $hierarchyTypes->getTypeByName("blogs20", "post")->getId();
     $sel->addElementType($hierarchy_type_id);
     $typesCollection = umiObjectTypesCollection::getInstance();
     $typeId = $typesCollection->getTypeByHierarchyTypeId($hierarchy_type_id);
     $postType = $typesCollection->getType($typeId);
     $userId = cmsController::getInstance()->getModule('users')->user_id;
     $sel->addOwnerFilter(array($userId));
     if ($blogId !== false) {
         $oBlog = $oHierarchy->getElement($blogId);
         if ($oBlog && $oBlog->getHierarchyType() == $blogHierachyTypeId) {
             $sel->addHierarchyFilter($blogId);
         }
     }
     $sel->addActiveFilter(false);
     $sel->setOrderByProperty($postType->getFieldId('publish_time'), false);
     $sel->addLimit($limit ? $limit : $this->posts_per_page, $page);
     self::applyTimeRange($sel, $postType);
     $result = umiSelectionsParser::runSelection($sel);
     $total = umiSelectionsParser::runSelectionCounts($sel);
     $aLines = array();
     foreach ($result as $iPostId) {
         $oPost = $oHierarchy->getElement($iPostId);
         if (!$oPost) {
             continue;
         }
         if (!$oBlog) {
             $oBlog = $oHierarchy->getElement($oPost->getRel());
         }
         if (!$oBlog) {
             continue;
         }
         $sPostLink = '/blogs20/postView/' . $iPostId . '/';
         $sBlogLink = $oHierarchy->getPathById($oBlog->getId(), true);
         $aLineParam = array();
         $aLineParam['attribute:id'] = $iPostId;
         $aLineParam['attribute:author_id'] = $oPost->getObject()->getOwnerId();
         $aLineParam['node:name'] = $oPost->getName();
         $aLineParam['post_link'] = $sPostLink;
         $aLineParam['blog_link'] = $sBlogLink;
         $aLineParam['bid'] = $oBlog->getId();
         $aLineParam['blog_title'] = $oBlog->getValue('title');
         $aLineParam['title'] = $oPost->getValue('title');
         $aLineParam['content'] = $oPost->getValue('content');
         $aLineParam['cut'] = $this->prepareCut($aLineParam['content'], $sPostLink, $template);
         $aLineParam['subnodes:tags'] = $this->prepareTags($oPost->getValue('tags'));
         $aLineParam['comments_count'] = $oHierarchy->getChildsCount($iPostId, false);
         $this->pushEditable("blogs20", "post", $iPostId);
         $aLines[] = self::parseTemplate($sTemplateLine, $aLineParam, $iPostId);
     }
     $aBlockParam = array();
     $aBlockParam['void:lines'] = $aBlockParam['subnodes:items'] = $aLines;
     $aBlockParam['bid'] = $blogId;
     $aBlockParam['per_page'] = $limit ? $limit : $this->posts_per_page;
     $aBlockParam['total'] = $total;
     return self::parseTemplate($sTemplateBlock, $aBlockParam);
 }