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();
 }
Exemplo n.º 2
0
 public function getBindedPage($formId = false)
 {
     if ($formId === false) {
         $formId = ($tmp = getRequest('param0')) ? $tmp : $formId;
     }
     if (!$formId) {
         return array('page' => array('attribute:id' => 0));
     }
     $hType = umiHierarchyTypesCollection::getInstance()->getTypeByName('webforms', 'page');
     $typeId = umiObjectTypesCollection::getInstance()->getTypeByHierarchyTypeId($hType->getId());
     $type = umiObjectTypesCollection::getInstance()->getType($typeId);
     $sel = new umiSelection();
     $sel->addElementType($hType->getId());
     $sel->addActiveFilter(true);
     $sel->addPropertyFilterEqual($type->getFieldId('form_id'), $formId);
     $result = umiSelectionsParser::runSelection($sel);
     if (!empty($result)) {
         return array('page' => array('attribute:id' => $result[0], 'attribute:href' => umiHierarchy::getInstance()->getPathById($result[0])));
     }
     $sel = new umiSelection();
     $sel->addElementType($hType->getId());
     $sel->addActiveFilter(false);
     $sel->addPropertyFilterEqual($type->getFieldId('form_id'), $formId);
     $result = umiSelectionsParser::runSelection($sel);
     if (!empty($result)) {
         return array('page' => array('attribute:id' => $result[0], 'attribute:href' => umiHierarchy::getInstance()->getPathById($result[0])));
     }
     return array('page' => array('attribute:id' => 0));
 }
 /**
  * Gets news with specified type. Uses paging.
  *
  * @param int $type Id of type (rubric)
  * @param int $limit Limit for output
  * @param int $page Current page for calculate offset
  * @return array
  */
 public function getList($type, $limit, $page = 1)
 {
     $config = parse_ini_file("./config/config.ini", true);
     $page -= 1;
     $hierarchyTypeId = umiHierarchyTypesCollection::getInstance()->getTypeByName("news", "item")->getId();
     $objectTypeId = umiObjectTypesCollection::getInstance()->getBaseType("news", "item");
     $objectType = umiObjectTypesCollection::getInstance()->getType($objectTypeId);
     $publishTimeFieldId = $objectType->getFieldId('publish_time');
     $publishToAppFieldId = $objectType->getFieldId('publish_to_app');
     $sel = new umiSelection();
     $sel->addElementType($hierarchyTypeId);
     $sel->addHierarchyFilter($type, 0, true);
     if ($config["umi"]["ignore-publish-flag"] != 1) {
         $sel->addPropertyFilterEqual($publishToAppFieldId, true);
     }
     $sel->setOrderByProperty($publishTimeFieldId, false);
     $sel->addLimit($limit, $page);
     $result = umiSelectionsParser::runSelection($sel);
     $items = array();
     $size = sizeof($result);
     for ($i = 0; $i < $size; $i++) {
         $elementId = $result[$i];
         $element = umiHierarchy::getInstance()->getElement($elementId);
         if (!$element) {
             continue;
         }
         $items[] = array("id" => $elementId, "header" => $element->getValue("h1"), "date" => $element->getValue("publish_time")->getFormattedDate("d.m.Y"), "image" => "http://" . $_SERVER['HTTP_HOST'] . $element->getValue("anons_pic"), "original_link" => "http://" . $_SERVER['HTTP_HOST'] . umiHierarchy::getInstance()->getPathById($elementId));
     }
     return $items;
 }
Exemplo n.º 4
0
 public function import_comments($from, $to, $fromHTypeId, $toHTypeId)
 {
     $selection = new umiSelection();
     $selection->addElementType($fromHTypeId);
     $selection->addHierarchyFilter($from);
     $commentList = umiSelectionsParser::runSelection($selection);
     foreach ($commentList as $commentId) {
         $newCommentId = $this->makeElementFromExisting($commentId, $to, $toHTypeId);
         $this->import_comments($commentId, $newCommentId, $fromHTypeId, $toHTypeId);
     }
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
 public function getPagesByBaseTypeList($module, $method)
 {
     $hierarchyTypesCollection = umiHierarchyTypesCollection::getInstance();
     $hierarchy = umiHierarchy::getInstance();
     $type = $hierarchyTypesCollection->getTypeByName($module, $method);
     if ($type instanceof iUmiHierarchyType) {
         $type_id = $type->getId();
     } else {
         throw new publicException("Hierarchy type {$module}::{$method} doesn't exists");
     }
     $sel = new umiSelection();
     $sel->addElementType($type_id);
     $sel->addPermissions();
     $result = umiSelectionsParser::runSelection($sel);
     $pages = array();
     foreach ($result as $element_id) {
         $element = $hierarchy->getElement($element_id);
         if ($element instanceof umiHierarchyElement) {
             $pages[] = $element;
         }
     }
     return array("pages" => array("nodes:page" => $pages));
 }
Exemplo n.º 8
0
<?php
  // Get instances
  $oHierarchy  = umiHierarchy::getInstance();
  $oCollection = umiObjectsCollection::getInstance();
  // Let's select the polls
  $oSelection = new umiSelection();
  $iHTypeID   = umiHierarchyTypesCollection::getInstance()->getTypeByName("vote", "poll")->getId();
  $oSelection->addElementType($iHTypeID);
  $aPolls     = umiSelectionsParser::runSelection($oSelection);
  $oSelection = new umiSelection();
  $iTypeID    = umiObjectTypesCollection::getInstance()->getBaseType("vote", "poll_item");
  $oSelection->addObjectType($iTypeID);
  $aAnswers   = umiSelectionsParser::runSelection($oSelection);
  foreach($aPolls as $iPollID) {
      $oPoll            = $oHierarchy->getElement($iPollID);
      $oPollObjectID    = $oPoll->getObject()->getId();
      if(!($oPoll instanceof umiHierarchyElement)) continue;
      $aLocalAnswersIDs = $oPoll->getValue('answers');
      foreach($aAnswers as $iAnswerID) {
          $oAnswer      = $oCollection->getObject($iAnswerID);
          if(!($oAnswer instanceof umiObject)) continue;
          $iLocalPollID = $oAnswer->getValue('poll_rel');
          if($oPollObjectID != $iLocalPollID) continue;
          if(!in_array($iAnswerID, $aLocalAnswersIDs)) {
              $aLocalAnswersIDs[] = $iAnswerID;
          }
      }
      $aAnswers = array_diff($aAnswers, $aLocalAnswersIDs);
      $oPoll->setValue('answers', $aLocalAnswersIDs);
      $oPoll->commit();
  }
Exemplo n.º 9
0
 public function getMessageLink($element_id = false)
 {
     $element_id = $this->analyzeRequiredPath($element_id);
     $per_page = $this->per_page;
     $curr_page = (int) getRequest('p');
     $element = umiHierarchy::getInstance()->getElement($element_id, true);
     if (!$element) {
         throw new publicException(getLabel('error-page-does-not-exist', null, ''));
     }
     $parent_id = $element->getParentId();
     $parent_element = umiHierarchy::getInstance()->getElement($parent_id);
     if (!$parent_element) {
         throw new publicException(getLabel('error-parent-does-not-exist', null, ''));
     }
     if ($element->getValue("publish_time")) {
         $publish_time = $element->getValue("publish_time")->getFormattedDate("U");
     }
     $sel = new umiSelection();
     $sel->setLimitFilter();
     $sel->addLimit($per_page, $curr_page);
     $sel->setElementTypeFilter();
     $topic_hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("forum", "message")->getId();
     $sel->addElementType($topic_hierarchy_type_id);
     $sel->setHierarchyFilter();
     $sel->addHierarchyFilter($parent_id);
     $object_type_id = umiObjectTypesCollection::getInstance()->getBaseType("forum", "message");
     $object_type = umiObjectTypesCollection::getInstance()->getType($object_type_id);
     $publish_time_field_id = $object_type->getFieldId('publish_time');
     $sel->setOrderFilter();
     $sel->setOrderByProperty($publish_time_field_id, true);
     $sel->setPropertyFilter();
     $sel->addPropertyFilterLess($publish_time_field_id, $publish_time);
     $sel->setPermissionsFilter();
     $sel->addPermissions();
     $total = umiSelectionsParser::runSelectionCounts($sel);
     $p = floor(($total - 1) / $this->per_page);
     if ($p < 0) {
         $p = 0;
     }
     return umiHierarchy::getInstance()->getPathById($parent_id) . "?p={$p}#" . $element_id;
 }
Exemplo n.º 10
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);
 }
Exemplo n.º 11
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;
		}
	}
Exemplo n.º 12
0
 /**
  * @desc
  */
 private function prepareBlogSelect($blogIdCurrent = false, $force = false, $template = 'default')
 {
     if ($blogIdCurrent && !$force) {
         return;
     }
     static $bInited = false;
     static $sBlock, $sOption;
     static $aBlogList = array();
     if (!$bInited) {
         list($sBlock, $sOption) = self::loadTemplates('blogs20/' . $template, 'blog_choose_block', 'blog_choose_line');
         $sel = new umiSelection();
         $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("blogs20", "blog")->getId();
         $sel->addElementType($hierarchy_type_id);
         $sel->addPermissions();
         $sel->setPermissionsLevel(2);
         $result = umiSelectionsParser::runSelection($sel);
         $oHierarchy = umiHierarchy::getInstance();
         foreach ($result as $blogId) {
             $aBlogList[$blogId] = $oHierarchy->getElement($blogId)->getValue('title');
         }
         $bInited = true;
     }
     $aLines = array();
     foreach ($aBlogList as $blogId => $blogTitle) {
         $aLines[] = self::parseTemplate($sOption, array('bid' => $blogId, 'title' => $blogTitle, 'selected' => $blogId == $blogIdCurrent ? 'selected' : ''));
     }
     return self::parseTemplate($sBlock, array('subnodes:options' => $aLines));
 }
Exemplo n.º 13
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);
     }
 }
 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);
     }
 }
Exemplo n.º 15
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;
     }
 }
Exemplo n.º 16
0
 public function getSelectionObject()
 {
     $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("catalog", "object")->getId();
     $sel = new umiSelection();
     $sel->setElementTypeFilter();
     $sel->addElementType($hierarchy_type_id);
     $sel->setHierarchyFilter();
     $sel->addHierarchyFilter($this->catalogId, 1);
     $sel->setPermissionsFilter();
     $sel->addPermissions();
     //add custom filters
     kFilters::getInstance($this->catalogId)->applyCustomCountFilters($sel);
     return $sel;
 }
Exemplo n.º 17
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);
     }
 }
Exemplo n.º 18
0
 public function insertlast($template = "default")
 {
     if (!$template) {
         $template = "default";
     }
     $type_id = umiObjectTypesCollection::getInstance()->getBaseType("vote", "poll");
     $type = umiObjectTypesCollection::getInstance()->getType($type_id);
     $time_field_id = $type->getFieldId("publish_time");
     $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("vote", "poll")->getId();
     $sel = new umiSelection();
     $sel->setHierarchyFilter();
     $sel->addElementType($hierarchy_type_id);
     $sel->setLimitFilter();
     $sel->addLimit(1);
     $sel->setOrderFilter();
     $sel->setOrderByProperty($time_field_id, false);
     $sel->addPermissions();
     $sel->forceHierarchyTable();
     $result = umiSelectionsParser::runSelection($sel);
     if (sizeof($result)) {
         list($element_id) = $result;
     } else {
         $element_id = false;
     }
     if ($element_id) {
         return $this->poll($element_id, $template);
     }
 }
Exemplo n.º 19
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;
    }