/**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getType() != 'metamodels') {
         return true;
     }
     /** @var IItem $model */
     $model = $item->getExtra('model');
     $attribute = $model->getAttribute($this->attribute);
     // metamoel does not have this attribute, skip
     if (!$attribute) {
         return true;
     }
     $value = $model->get($this->attribute);
     switch ($this->operator) {
         case static::OPERATOR_EQUALS:
             return $value == $this->value;
             break;
         case static::OPERATOR_EQUALS_OR_GREATER_THAN:
             return $value >= $this->value;
             break;
         case static::OPERATOR_EQUALS_OR_LESSER_THAN:
             return $value <= $this->value;
             break;
         case static::OPERATOR_GREATER_THAN:
             return $value > $this->value;
             break;
         case static::OPERATOR_LESSER_THAN:
             return $value < $this->value;
             break;
     }
     return false;
 }
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getType() != 'article') {
         return true;
     }
     $guests = $item->getExtra('guests');
     return $guests == $this->acceptedGuestsStatus;
 }
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getType() != 'page') {
         return true;
     }
     $type = $item->getExtra('type');
     return $type == $this->acceptedType;
 }
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getType() != 'page') {
         return true;
     }
     $protected = $item->getExtra('protected');
     return $protected == $this->acceptedProtectedStatus;
 }
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getType() != 'page') {
         return true;
     }
     $hide = $item->getExtra('hide');
     return $hide == $this->acceptedHideStatus;
 }
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getType() != 'page') {
         return true;
     }
     $sitemap = $item->getExtra('sitemap');
     return in_array($sitemap, $this->acceptedSitemapStatus);
 }
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getType() != 'page') {
         return true;
     }
     $pageId = $item->getExtra('id');
     return $pageId == $this->pageId;
 }
 /**
  * Determine if the condition match on the item.
  *
  * @param ItemInterface $item
  *
  * @return bool
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getType() != 'metamodels') {
         return true;
     }
     /** @var IItem $model */
     $model = $item->getExtra('model');
     return $model->getMetaModel() == $this->metaModel;
 }
示例#9
0
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     $parent = $item->getParent();
     if (!$parent) {
         return false;
     }
     if ($this->condition) {
         return $this->condition->matchItem($parent);
     }
     return true;
 }
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getType() != 'article') {
         return true;
     }
     $published = $item->getExtra('published');
     $start = $item->getExtra('start');
     $stop = $item->getExtra('stop');
     $time = time();
     return $published && (!$start || $start <= $time) && (!$stop || $stop >= $time);
 }
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getType() != 'content') {
         return true;
     }
     $invisible = $item->getExtra('invisible');
     $start = $item->getExtra('start');
     $stop = $item->getExtra('stop');
     $time = time();
     return !$invisible && (!$start || $start <= $time) && (!$stop || $stop >= $time);
 }
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getType() != 'article') {
         return true;
     }
     if (!FE_USER_LOGGED_IN) {
         return false;
     }
     $articleGroups = $item->getExtra('groups');
     $memberGroups = \FrontendUser::getInstance()->groups;
     $groups = array_intersect($memberGroups, $articleGroups);
     return (bool) count($groups);
 }
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getType() != 'page') {
         return true;
     }
     if (!FE_USER_LOGGED_IN) {
         return false;
     }
     $pageGroups = deserialize($item->getExtra('groups'), true);
     if (empty($pageGroups)) {
         return true;
     }
     $memberGroups = \FrontendUser::getInstance()->groups;
     $groups = array_intersect($memberGroups, $pageGroups);
     return (bool) count($groups);
 }
示例#14
0
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     return $item->getType() == $this->acceptedType;
 }
示例#15
0
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     $level = $item->getLevel();
     return $this->min <= $level && $level <= $this->max;
 }
示例#16
0
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     return $item->isCurrent();
 }
示例#17
0
 /**
  * {@inheritdoc}
  */
 public function matchItem(ItemInterface $item)
 {
     return $item->isTrail();
 }
示例#18
0
 public function classesFunction($context, ItemInterface $item, $hasChildren)
 {
     $classes = array('level_' . $item->getLevel(), 'type_' . $item->getType());
     if ($item->isCurrent()) {
         $classes[] = 'active';
     }
     if ($item->isTrail()) {
         $classes[] = 'trail';
     }
     if ($hasChildren) {
         $classes[] = 'children';
     }
     if ($this->linkIsVisibleFunction($context, $item)) {
         $classes[] = 'show-link';
     } else {
         $classes[] = 'hide-link';
     }
     if (isset($context['loop'])) {
         if ($context['loop']['first']) {
             $classes[] = 'first';
         }
         if ($context['loop']['last']) {
             $classes[] = 'last';
         }
         $classes[] = 'item_' . $context['loop']['index'];
     }
     /** @var EventDispatcherInterface $eventDispatcher */
     $eventDispatcher = $GLOBALS['container']['event-dispatcher'];
     $event = new GenerateItemClassesEvent($item);
     $event->setClasses($classes);
     $eventDispatcher->dispatch(XNavigationEvents::GENERATE_ITEM_CLASSES, $event);
     return $event->getClasses();
 }
 /**
  * @param ItemInterface $item
  * @param array $values
  */
 protected function renderAttributeMapping(ItemInterface $item, array $values)
 {
     foreach ($this->attributeMapping[static::ATTRIBUTE_TYPE_LABEL] as $name => $mapping) {
         /** @var IAttribute $attribute */
         $attribute = $mapping['attribute'];
         $colName = $attribute->getColName();
         $item->setLabelAttribute($name, specialchars($values[$mapping['format']][$colName]));
     }
     foreach ($this->attributeMapping[static::ATTRIBUTE_TYPE_LINK] as $name => $mapping) {
         /** @var IAttribute $attribute */
         $attribute = $mapping['attribute'];
         $colName = $attribute->getColName();
         $item->setLinkAttribute($name, specialchars($values[$mapping['format']][$colName]));
     }
     foreach ($this->attributeMapping[static::ATTRIBUTE_TYPE_ITEM] as $name => $mapping) {
         /** @var IAttribute $attribute */
         $attribute = $mapping['attribute'];
         $colName = $attribute->getColName();
         $item->setAttribute($name, specialchars($values[$mapping['format']][$colName]));
     }
 }
示例#20
0
 /**
  * {@inheritdoc}
  */
 public function setParent(ItemInterface $parent = null)
 {
     $this->setParentCollection($parent ? $parent->getChildren() : null);
 }