本文整理汇总了PHP中umiHierarchy::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP umiHierarchy::getInstance方法的具体用法?PHP umiHierarchy::getInstance怎么用?PHP umiHierarchy::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类umiHierarchy
的用法示例。
在下文中一共展示了umiHierarchy::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCloneElement
public function onCloneElement(iUmiEventPoint $oEventPoint)
{
if ($oEventPoint->getMode() == 'after') {
/**
* @var umiHierarchy
*/
$hierarchy = umiHierarchy::getInstance();
$elementId = $oEventPoint->getParam('newElementId');
/**
* @var umiHierarchyElement
*/
$element = $hierarchy->getElement($elementId);
if ($element && $element->getTypeId() == umiHierarchyTypesCollection::getInstance()->getTypeByName('vote', 'poll')->getId()) {
$collection = umiObjectsCollection::getInstance();
$answersIDs = $element->getValue('answers');
$newAnswers = array();
foreach ($answersIDs as $answerId) {
if ($newAnswerId = $collection->cloneObject($answerId)) {
$newAnswers[] = $newAnswerId;
$answer = $collection->getObject($newAnswerId);
$answer->setValue('poll_rel', $elementId);
$answer->setValue('count', 0);
$answer->commit();
}
}
$element->setValue('answers', $newAnswers);
$element->commit();
}
}
}
示例2: validateItem
public function validateItem(iUmiHierarchyElement $orderItem) {
if(!is_array($this->catalog_items)) {
return false;
}
foreach($this->catalog_items as $catalogItem) {
if($catalogItem->id == $orderItem->id) {
return true;
}
}
$parentId = $orderItem->getParentId();
if($parentId) {
$hierarchy = umiHierarchy::getInstance();
$parents = $hierarchy->getAllParents($parentId, true);
if(isset($parents[0])) unset($parents[0]);
foreach($this->catalog_items as $catalogItem) {
if(in_array($catalogItem->id, $parents)) {
return true;
}
}
}
return false;
}
示例3: create
/**
* Создать новый товар для заказа.
* Выбор класса осуществляется следующим образом:
* 1. берется элемент $elementId - товар каталога
* 2. у него берется значение свойства "item_type_id" ("Тип товара"), которое является справочником
* 3. у него в свою очередь берется свойство "class_name", по которому определяется необходимый класс
* Если тип не указан, то используется класс orderItem.
* @param Integer $elementId
* @param Integer|Boolean $storeId = false id склада, на котором находится товар
* @return orderItem товар в заказе (объект класса orderItem или его наследнка)
*/
public static function create($elementId, $storeId = false)
{
$objectTypes = umiObjectTypesCollection::getInstance();
$objects = umiObjectsCollection::getInstance();
$emarket = cmsController::getInstance()->getModule('emarket');
$objectTypeId = $objectTypes->getBaseType('emarket', 'order_item');
$hierarchy = umiHierarchy::getInstance();
$objectId = $objects->addObject('', $objectTypeId);
$object = $objects->getObject($objectId);
if ($object instanceof iUmiObject == false) {
throw new coreException("Couldn't load order item object #{$objectId}");
}
$element = $hierarchy->getElement($elementId);
if ($element instanceof iUmiHierarchyElement == false) {
throw new publicException("Page #{$elementId} not found");
}
$price = $emarket->getPrice($element, true);
$object->item_price = $price;
$object->item_amount = 0;
$itemTypeId = self::getItemTypeId($element->getObjectTypeId());
$object->item_type_id = $itemTypeId;
$object->item_link = $element;
$object->name = $element->name;
return self::get($object->getId());
}
示例4: onPageCreate
public function onPageCreate(iUmiEventPoint $event)
{
if (!$event->getRef('element') instanceof umiHierarchyElement) {
return;
}
$pageId = $event->getRef('element')->getId();
$hierarchy = umiHierarchy::getInstance();
$page = $hierarchy->getElement($pageId);
$postparams = http_build_query(array('message' => $page->content, 'title' => $page->name, 'link' => 'http://netizenhostels.com' . $hierarchy->getPathById($page->id) . '?media=mobile'));
$options = array("http" => array("method" => "POST", "header" => "Content-type: application/x-www-form-urlencoded", "content" => $postparams));
$context = stream_context_create($options);
$result = file_get_contents('http://netizen.octopod.com/push/send_message.php', false, $context);
// if ($page->getIsActive()) {
// file_get_contents('http://netizen.octopod.com/push/send_message.php?message='.$page->altName);
/*
file_put_contents(
sys_get_temp_dir().'/zzzzzy',print_r(array(
'id' => $page->id,
'name' => $page->name,
'permalink' => $page->altName,
'anons' => $page->anons,
'content' => $page->content,
'url' => $hierarchy->getPathById($page->id)
),true)
);
*/
// }
}
示例5: getList
/**
* 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;
}
示例6: onAddTopicToDispatch
public function onAddTopicToDispatch(iUmiEventPoint $oEvent)
{
$iDispatchId = regedit::getInstance()->getVal("//modules/forum/dispatch_id");
if (!$iDispatchId) {
return false;
}
$dispatches_module = cmsController::getInstance()->getModule('dispatches');
if (!$dispatches_module) {
return false;
}
$iTopicId = (int) $oEvent->getParam('topic_id');
$oTopicElement = umiHierarchy::getInstance()->getElement($iTopicId);
if ($oTopicElement instanceof umiHierarchyElement) {
$sTitle = (string) getRequest('title');
$sMessage = (string) getRequest('body');
$iHierarchyTypeId = umiHierarchyTypesCollection::getInstance()->getTypeByName("dispatches", "message")->getId();
$iMsgTypeId = umiObjectTypesCollection::getInstance()->getTypeByHierarchyTypeId($iHierarchyTypeId);
$oMsgType = umiObjectTypesCollection::getInstance()->getType($iMsgTypeId);
$iMsgObjId = umiObjectsCollection::getInstance()->addObject($sTitle, $iMsgTypeId);
$oMsgObj = umiObjectsCollection::getInstance()->getObject($iMsgObjId);
if ($oMsgObj instanceof umiObject) {
$iReleaseId = $dispatches_module->getNewReleaseInstanceId($iDispatchId);
$oMsgObj->setValue('release_reference', $iReleaseId);
$oMsgObj->setValue('header', $sTitle);
$oMsgObj->setValue('body', $sMessage);
$oMsgObj->commit();
return true;
} else {
return false;
}
} else {
return false;
}
}
示例7: add
public function add() {
$parent = $this->expectElement("param0");
$type = (string) getRequest("param1");
$mode = (string) getRequest("param2");
$this->setHeaderLabel("header-news-add-" . $type);
$inputData = Array( "type" => $type,
"parent" => $parent,
'type-id' => getRequest('type-id'),
"allowed-element-types" => Array('rubric', 'item'));
if($mode == "do") {
$element_id = $this->saveAddedElementData($inputData);
if($type == "item") {
umiHierarchy::getInstance()->moveFirst($element_id, ($parent instanceof umiHierarchyElement)?$parent->getId():0);
}
$this->chooseRedirect();
}
$this->setDataType("form");
$this->setActionType("create");
$data = $this->prepareData($inputData, "page");
$this->setData($data);
return $this->doData();
}
示例8: isHierarchyAllowed
public function isHierarchyAllowed($element_id)
{
$element = umiHierarchy::getInstance()->getElement($element_id);
if (!$element) {
return true;
}
if ($element->getIsDefault()) {
return true;
}
$allowed_pages = array('emarket', 'webforms', 'users', 'catalog');
$type = umiHierarchyTypesCollection::getInstance()->getType($element->getTypeId());
if (in_array($type->getName(), $allowed_pages)) {
return true;
}
$allowed_hierarchy_elements = $this->getValue('iframe_pages');
if (empty($allowed_hierarchy_elements)) {
return false;
}
foreach ($allowed_hierarchy_elements as $hierarchy_element) {
if ($hierarchy_element->getId() == $element_id) {
return true;
}
}
foreach ($allowed_hierarchy_elements as $hierarchy_element) {
if (umiHierarchy::getInstance()->hasParent($element_id, $hierarchy_element)) {
return true;
}
}
return false;
}
示例9: systemEventsNotify
public function systemEventsNotify(iUmiEventPoint $event)
{
$eventId = $event->getEventId();
$titleLabel = $titleLabel = 'event-' . $eventId . '-title';
$contentLabel = 'event-' . $eventId . '-content';
$title = getLabel($titleLabel, 'common/content/config');
$content = getLabel($contentLabel, 'common/content/config');
if ($titleLabel == $title) {
return;
}
if ($element = $event->getRef('element')) {
$hierarchy = umiHierarchy::getInstance();
$oldbForce = $hierarchy->forceAbsolutePath(true);
$params = array('%page-name%' => $element->name, '%page-link%' => $element->link);
$hierarchy->forceAbsolutePath($oldbForce);
} else {
$params = array();
}
if ($object = $event->getRef('object')) {
$params['%object-name%'] = $object->name;
$objectTypes = umiObjectTypesCollection::getInstance();
$objectType = $objectTypes->getType($object->getTypeId());
if ($hierarchyTypeId = $objectType->getHierarchyTypeId()) {
$hierarchyTypes = umiHierarchyTypesCollection::getInstance();
$hierarchyType = $hierarchyTypes->getType($hierarchyTypeId);
$params['%object-type%'] = $hierarchyType->getTitle();
}
}
$title = str_replace(array_keys($params), array_values($params), $title);
$content = str_replace(array_keys($params), array_values($params), $content);
$this->dispatchSystemEvent($title, $content);
}
示例10: getBindedPage
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));
}
示例11: parsePath
protected function parsePath($vd6fe1d0be6347b8ef2427fa629c04485)
{
$vd6fe1d0be6347b8ef2427fa629c04485 = parent::parsePath($vd6fe1d0be6347b8ef2427fa629c04485);
$v47c80780ab608cc046f2a6e6f071feb6 = explode("/", $vd6fe1d0be6347b8ef2427fa629c04485);
if (sizeof($v47c80780ab608cc046f2a6e6f071feb6) >= 2) {
switch ($v47c80780ab608cc046f2a6e6f071feb6[0]) {
case "dominant":
$vb81ca7c0ccaa77e7aa91936ab0070695 = umiHierarchy::getInstance();
return $vb81ca7c0ccaa77e7aa91936ab0070695->getDominantTypeId($this->getTypeId($v47c80780ab608cc046f2a6e6f071feb6[1]));
case "child":
$vdb6d9b451b818ccc9a449383f2f0c450 = umiObjectTypesCollection::getInstance();
return $vdb6d9b451b818ccc9a449383f2f0c450->getChildClasses($this->getTypeId($v47c80780ab608cc046f2a6e6f071feb6[1]));
}
}
$v47c80780ab608cc046f2a6e6f071feb6 = explode(".", $vd6fe1d0be6347b8ef2427fa629c04485);
if (is_array($v47c80780ab608cc046f2a6e6f071feb6)) {
$vd6fe1d0be6347b8ef2427fa629c04485 = trim($v47c80780ab608cc046f2a6e6f071feb6[0], '/');
if (sizeof($v47c80780ab608cc046f2a6e6f071feb6) > 1) {
$this->group_name = $v47c80780ab608cc046f2a6e6f071feb6[1];
}
if (sizeof($v47c80780ab608cc046f2a6e6f071feb6) > 2) {
$this->field_name = $v47c80780ab608cc046f2a6e6f071feb6[2];
}
}
return $vd6fe1d0be6347b8ef2427fa629c04485;
}
示例12: prepareElementsToExport
public function prepareElementsToExport() {
$objectId = getRequest('param0');
$complete = false;
$objects = umiObjectsCollection::getInstance();
$object = $objects->getObject($objectId);
$formatId = $object->format;
$format = $objects->getObject($formatId);
$suffix = $format->sid;
if($suffix != 'YML') {
$data = array(
"attribute:complete" => (int) $complete,
"attribute:preparation" => (int) !$complete,
);
baseModuleAdmin::setData($data);
return baseModuleAdmin::doData();
}
$offset = (int) getSession("export_offset_" . $objectId);
$blockSize = mainConfiguration::getInstance()->get("modules", "exchange.splitter.limit") ? mainConfiguration::getInstance()->get("modules", "exchange.splitter.limit") : 25;
if(!file_exists(CURRENT_WORKING_DIR . "/sys-temp/yml/" . $objectId . 'el')) {
throw new publicException('<a href="' . getLabel("label-errors-no-information") . '" target="blank">' . getLabel("label-errors-no-information") .'</a>');
}
$elementsToExport = unserialize(file_get_contents(CURRENT_WORKING_DIR . "/sys-temp/yml/" . $objectId . 'el'));
$elements = umiHierarchy::getInstance();
$errors = array();
for ($i = $offset; $i <= $offset + $blockSize -1; $i++) {
if(!array_key_exists($i, $elementsToExport)) {
$complete = true;
break;
}
$element = $elements->getElement($elementsToExport[$i]);
if($element instanceof umiHierarchyElement) {
try {
$element->updateYML();
} catch (Exception $e) {
$errors[] = $e->getMessage() . " #{$elementsToExport[$i]}";
}
}
}
$_SESSION["export_offset_" . $objectId] = $offset + $blockSize;
if ($complete) {
unset($_SESSION["export_offset_" . $objectId]);
}
$data = array(
"attribute:complete" => (int) $complete,
"nodes:log" => $errors
);
baseModuleAdmin::setData($data);
return baseModuleAdmin::doData();
}
示例13: size_table
public function size_table()
{
$page = umiHierarchy::getInstance()->getElement(112);
//print_r($page);die;
$res = $page->getValue('content');
umiHierarchy::getInstance()->unloadElement($id);
return $res;
}
示例14: __construct
/**
* Защищённый конструктор
* @param int $catalogId ID категории каталога
*/
protected function __construct($catalogId)
{
$this->catalogId = $catalogId;
$this->cache = new kFiltersCache();
$this->objectsTypeId = umiHierarchy::getInstance()->getDominantTypeId($this->catalogId);
$this->sContentTable = umiBranch::getBranchedTableByTypeId($this->objectsTypeId);
$this->customLogic = new kFiltersCustomLogic($this->catalogId, $this->objectsTypeId);
}
示例15: page
public function page($v7552cd149af7495ee7d8225974e50f80)
{
$vb81ca7c0ccaa77e7aa91936ab0070695 = umiHierarchy::getInstance();
if (is_numeric($v7552cd149af7495ee7d8225974e50f80) == false) {
$v7552cd149af7495ee7d8225974e50f80 = $vb81ca7c0ccaa77e7aa91936ab0070695->getIdByPath($v7552cd149af7495ee7d8225974e50f80);
}
if ($v7552cd149af7495ee7d8225974e50f80 !== false) {
$this->elementId = (int) $v7552cd149af7495ee7d8225974e50f80;
}
return $this;
}