/**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments Ignored for this operation
  * @return void
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     $context = $flowQuery->getContext();
     if (isset($context[0])) {
         $flowQuery->setContext(array($context[0]));
     } else {
         $flowQuery->setContext(array());
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments Ignored for this operation
  * @return void
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     $context = $flowQuery->getContext();
     if (count($context) > 0) {
         $flowQuery->setContext(array(end($context)));
     } else {
         $flowQuery->setContext(array());
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation.
  * First argument is property to filter by, must be of reference of references type.
  * Second is object to filter by, must be Node.
  * @return mixed
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || empty($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('FilterByReference() needs reference property name by which nodes should be filtered', 1332492263);
     } elseif (!isset($arguments[1]) || empty($arguments[1])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('FilterByReference() needs object by which nodes should be filtered', 1332493263);
     } else {
         $nodes = $flowQuery->getContext();
         $filterByPropertyPath = $arguments[0];
         /** @var Node $object  */
         $object = $arguments[1];
         $filteredNodes = array();
         /** @var Node $node  */
         foreach ($nodes as $node) {
             $propertyValue = $node->getProperty($filterByPropertyPath);
             if (is_array($propertyValue)) {
                 if (in_array($object, $propertyValue)) {
                     $filteredNodes[] = $node;
                 }
             } else {
                 if ($object == $propertyValue) {
                     $filteredNodes[] = $node;
                 }
             }
         }
         $flowQuery->setContext($filteredNodes);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     $outputNodePaths = array();
     $until = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         $prevNodes = $this->getPrevForNode($contextNode);
         if (isset($arguments[0]) && !empty($arguments[0])) {
             $untilQuery = new FlowQuery($prevNodes);
             $untilQuery->pushOperation('filter', array($arguments[0]));
             $until = $untilQuery->get();
         }
         if (isset($until) && !empty($until)) {
             $until = end($until);
             $prevNodes = $this->getNodesUntil($prevNodes, $until);
         }
         if (is_array($prevNodes)) {
             foreach ($prevNodes as $prevNode) {
                 if ($prevNode !== NULL && !isset($outputNodePaths[$prevNode->getPath()])) {
                     $outputNodePaths[$prevNode->getPath()] = TRUE;
                     $output[] = $prevNode;
                 }
             }
         }
     }
     $flowQuery->setContext($output);
     if (isset($arguments[1]) && !empty($arguments[1])) {
         $flowQuery->pushOperation('filter', array($arguments[1]));
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     $outputNodePaths = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         $siteNode = $contextNode->getContext()->getCurrentSiteNode();
         $parentNodes = $this->getParents($contextNode, $siteNode);
         if (isset($arguments[0]) && !empty($arguments[0] && isset($parentNodes[0]))) {
             $untilQuery = new FlowQuery(array($parentNodes[0]));
             $untilQuery->pushOperation('closest', array($arguments[0]));
             $until = $untilQuery->get();
         }
         if (isset($until) && is_array($until) && !empty($until) && isset($until[0])) {
             $parentNodes = $this->getNodesUntil($parentNodes, $until[0]);
         }
         if (is_array($parentNodes)) {
             foreach ($parentNodes as $parentNode) {
                 if ($parentNode !== null && !isset($outputNodePaths[$parentNode->getPath()])) {
                     $outputNodePaths[$parentNode->getPath()] = true;
                     $output[] = $parentNode;
                 }
             }
         }
     }
     $flowQuery->setContext($output);
     if (isset($arguments[1]) && !empty($arguments[1])) {
         $flowQuery->pushOperation('filter', $arguments[1]);
     }
 }
Пример #6
0
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return mixed
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || empty($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('sort() needs property name by which nodes should be sorted', 1332492263);
     } else {
         $nodes = $flowQuery->getContext();
         $sortByPropertyPath = $arguments[0];
         $sortOrder = 'DESC';
         if (isset($arguments[1]) && !empty($arguments[1]) && in_array($arguments[1], array('ASC', 'DESC'))) {
             $sortOrder = $arguments[1];
         }
         $sortedNodes = array();
         $sortSequence = array();
         $nodesByIdentifier = array();
         /** @var Node $node  */
         foreach ($nodes as $node) {
             $propertyValue = $node->getProperty($sortByPropertyPath);
             // \TYPO3\Flow\var_dump($propertyValue);
             if ($propertyValue instanceof \DateTime) {
                 $propertyValue = $propertyValue->getTimestamp();
             }
             $sortSequence[$node->getIdentifier()] = $propertyValue;
             $nodesByIdentifier[$node->getIdentifier()] = $node;
         }
         if ($sortOrder === 'DESC') {
             arsort($sortSequence);
         } else {
             asort($sortSequence);
         }
         foreach ($sortSequence as $nodeIdentifier => $value) {
             $sortedNodes[] = $nodesByIdentifier[$nodeIdentifier];
         }
         $flowQuery->setContext($sortedNodes);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation.
  * First argument is property to filter by, must be DateTime.
  * Second is Date operand, must be DateTime object.
  * And third is a compare operator: '<' or '>', '>' by default
  * @return mixed
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || empty($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('filterByDate() needs property name by which nodes should be filtered', 1332492263);
     } elseif (!isset($arguments[1]) || empty($arguments[1])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('filterByDate() needs date value by which nodes should be filtered', 1332493263);
     } else {
         $nodes = $flowQuery->getContext();
         $filterByPropertyPath = $arguments[0];
         $date = $arguments[1];
         $compareOperator = '>';
         if (isset($arguments[2]) && !empty($arguments[2]) && in_array($arguments[2], array('<', '>'))) {
             $compareOperator = $arguments[2];
         }
         $filteredNodes = array();
         /** @var Node $node  */
         foreach ($nodes as $node) {
             $propertyValue = $node->getProperty($filterByPropertyPath);
             if ($compareOperator == '>') {
                 if ($propertyValue > $date) {
                     $filteredNodes[] = $node;
                 }
             }
             if ($compareOperator == '<') {
                 if ($propertyValue < $date) {
                     $filteredNodes[] = $node;
                 }
             }
         }
         $flowQuery->setContext($filteredNodes);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments A mandatory start and optional end index in the context, negative indices indicate an offset from the start or end respectively
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $context = $flowQuery->getContext();
     if (isset($arguments[0]) && isset($arguments[1])) {
         $context = array_slice($context, (int) $arguments[0], (int) $arguments[1] - (int) $arguments[0]);
     } elseif (isset($arguments[0])) {
         $context = array_slice($context, (int) $arguments[0]);
     }
     $flowQuery->setContext($context);
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments A mandatory start and optional end index in the context, negative indices indicate an offset from the start or end respectively
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $context = $flowQuery->getContext();
     if ($context instanceof \Iterator) {
         $context = iterator_to_array($context);
     }
     if (isset($arguments[0]) && isset($arguments[1])) {
         $context = array_slice($context, (int) $arguments[0], (int) $arguments[1] - (int) $arguments[0]);
     } elseif (isset($arguments[0])) {
         $context = array_slice($context, (int) $arguments[0]);
     }
     $flowQuery->setContext($context);
 }
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the elements to add (as array in index 0)
  * @return void
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     foreach ($flowQuery->getContext() as $element) {
         $output[] = $element;
     }
     if (isset($arguments[0])) {
         foreach ($arguments[0] as $element) {
             $output[] = $element;
         }
     }
     $flowQuery->setContext($output);
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery The FlowQuery object
  * @param array $arguments The arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || !is_array($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('context() requires an array argument of context properties', 1398030427);
     }
     $output = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         $contextProperties = $contextNode->getContext()->getProperties();
         $modifiedContext = $this->contextFactory->create(array_merge($contextProperties, $arguments[0]));
         $nodeInModifiedContext = $modifiedContext->getNodeByIdentifier($contextNode->getIdentifier());
         if ($nodeInModifiedContext !== null) {
             $output[$nodeInModifiedContext->getPath()] = $nodeInModifiedContext;
         }
     }
     $flowQuery->setContext(array_values($output));
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     $outputNodePaths = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         $parentNode = $contextNode->getParent();
         if ($parentNode !== null && !isset($outputNodePaths[$parentNode->getPath()])) {
             $output[] = $parentNode;
             $outputNodePaths[$parentNode->getPath()] = true;
         }
     }
     $flowQuery->setContext($output);
     if (isset($arguments[0]) && !empty($arguments[0])) {
         $flowQuery->pushOperation('filter', $arguments);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     $outputNodePaths = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         $prevNode = $this->getPrevForNode($contextNode);
         if ($prevNode !== NULL && !isset($outputNodePaths[$prevNode->getPath()])) {
             $outputNodePaths[$prevNode->getPath()] = TRUE;
             $output[] = $prevNode;
         }
     }
     $flowQuery->setContext($output);
     if (isset($arguments[0]) && !empty($arguments[0])) {
         $flowQuery->pushOperation('filter', $arguments);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery
  * @param array $arguments
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $subject = $arguments[0];
     if (!isset($subject) || empty($subject)) {
         $flowQuery->setContext(array());
         return;
     }
     $filteredContext = array();
     $context = $flowQuery->getContext();
     if (is_string($subject)) {
         foreach ($context as $contextElement) {
             $contextElementQuery = new FlowQuery(array($contextElement));
             $contextElementQuery->pushOperation('children', $arguments);
             if ($contextElementQuery->count() > 0) {
                 $filteredContext[] = $contextElement;
             }
         }
     } else {
         if ($subject instanceof \TYPO3\Eel\FlowQuery\FlowQuery) {
             $elements = $subject->get();
         } elseif ($subject instanceof \Traversable) {
             $elements = iterator_to_array($subject);
         } elseif (is_object($subject)) {
             $elements = array($subject);
         } elseif (is_array($subject)) {
             $elements = $subject;
         } else {
             throw new \TYPO3\Eel\FlowQuery\FizzleException('supplied argument for has operation not supported', 1332489625);
         }
         foreach ($elements as $element) {
             if ($element instanceof NodeInterface) {
                 $parentsQuery = new FlowQuery(array($element));
                 /** @var NodeInterface $parent */
                 foreach ($parentsQuery->parents(array())->get() as $parent) {
                     /** @var NodeInterface $contextElement */
                     foreach ($context as $contextElement) {
                         if ($contextElement->getIdentifier() === $parent->getIdentifier()) {
                             $filteredContext[] = $contextElement;
                         }
                     }
                 }
             }
         }
         $filteredContext = array_unique($filteredContext);
     }
     $flowQuery->setContext($filteredContext);
 }
Пример #15
0
 /**
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $user = false;
     if (count($arguments) > 0 && is_string($arguments[0])) {
         $user = $this->apiConnector->fetchUser($arguments[0]);
     }
     if ($user) {
         $groups = $this->apiConnector->fetchGroups();
         $user['memberships'] = array_filter($groups, function ($group) use($user) {
             return in_array($user['name'], $group['members']) && isset($group['neos_group_type']) && !empty($group['neos_group_type']);
         });
         $user['additionalProperties'] = array_filter($user, function ($key) {
             return strpos($key, 'neos_') === 0;
         }, ARRAY_FILTER_USE_KEY);
     }
     $flowQuery->setContext($user);
 }
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the elements to add (as array in index 0)
  * @return void
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     foreach ($flowQuery->getContext() as $element) {
         $output[] = $element;
     }
     if (isset($arguments[0])) {
         if (is_array($arguments[0]) || $arguments[0] instanceof \Traversable) {
             foreach ($arguments[0] as $element) {
                 $output[] = $element;
             }
         } else {
             $output[] = $arguments[0];
         }
     }
     $flowQuery->setContext($output);
 }
Пример #17
0
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return mixed|null if the operation is final, the return value
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     $outputNodePaths = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         foreach ($contextNode->getChildNodes() as $childNode) {
             if (!isset($outputNodePaths[$childNode->getPath()])) {
                 $output[] = $childNode;
                 $outputNodePaths[$childNode->getPath()] = TRUE;
             }
         }
     }
     $flowQuery->setContext($output);
     if (isset($arguments[0]) && !empty($arguments[0])) {
         $flowQuery->pushOperation('filter', $arguments);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || empty($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('closest() requires a filter argument', 1332492263);
     }
     $output = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         $contextNodeQuery = new FlowQuery(array($contextNode));
         $contextNodeQuery->pushOperation('first', array());
         $contextNodeQuery->pushOperation('filter', $arguments);
         $parentsQuery = new FlowQuery(array($contextNode));
         $contextNodeQuery->pushOperation('add', array($parentsQuery->parents($arguments[0])->get()));
         foreach ($contextNodeQuery as $result) {
             $output[$result->getPath()] = $result;
         }
     }
     $flowQuery->setContext(array_values($output));
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return mixed
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || empty($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('hasCategory() needs a category to filter for', 1332492263);
     } else {
         $nodesWithCategorySet = [];
         $categoryNode = $arguments[0];
         $nodes = $flowQuery->getContext();
         foreach ($nodes as $node) {
             /** @var $node NodeInterface */
             $nodeCategories = $node->getProperty("categories");
             if (is_array($nodeCategories) && in_array($categoryNode, $nodeCategories)) {
                 $nodesWithCategorySet[] = $node;
             }
         }
         $flowQuery->setContext($nodesWithCategorySet);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery
  * @param array $arguments
  * @return void
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || empty($arguments[0])) {
         return;
     }
     if ($arguments[0] instanceof NodeInterface) {
         $filteredContext = array();
         $context = $flowQuery->getContext();
         foreach ($context as $element) {
             if ($element === $arguments[0]) {
                 $filteredContext[] = $element;
                 break;
             }
         }
         $flowQuery->setContext($filteredContext);
     } else {
         parent::evaluate($flowQuery, $arguments);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return mixed
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     if (!is_array($arguments)) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('removeImportantNews() needs a true/false argument', 1332492263);
     } else {
         if (!$arguments[0]) {
             $nodes = $flowQuery->getContext();
             $nonImportantNews = [];
             foreach ($nodes as $node) {
                 /** @var $node NodeInterface */
                 $isImportant = $node->getProperty("important");
                 if (!$isImportant) {
                     $nonImportantNews[] = $node;
                 }
             }
             $flowQuery->setContext($nonImportantNews);
         }
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the filter expression to use (in index 0)
  * @return void
  * @throws \TYPO3\Eel\FlowQuery\FizzleException
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || empty($arguments[0])) {
         return;
     }
     if (!is_string($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FizzleException('filter operation expects string argument', 1332489625);
     }
     $filter = $arguments[0];
     $parsedFilter = \TYPO3\Eel\FlowQuery\FizzleParser::parseFilterGroup($filter);
     $filteredContext = array();
     $context = $flowQuery->getContext();
     foreach ($context as $element) {
         if ($this->matchesFilterGroup($element, $parsedFilter)) {
             $filteredContext[] = $element;
         }
     }
     $flowQuery->setContext($filteredContext);
 }
Пример #23
0
 /**
  * {@inheritdoc}
  *
  * @param \TYPO3\Eel\FlowQuery\FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return mixed|null if the operation is final, the return value
  */
 public function evaluate(\TYPO3\Eel\FlowQuery\FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     $outputNodePaths = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         $siteNode = $this->nodeRepository->getContext()->getCurrentSiteNode();
         while ($contextNode->getParent() !== $siteNode) {
             $contextNode = $contextNode->getParent();
             if (!isset($outputNodePaths[$contextNode->getPath()])) {
                 $output[] = $contextNode;
                 $outputNodePaths[$contextNode->getPath()] = TRUE;
             }
         }
     }
     $flowQuery->setContext($output);
     if (isset($arguments[0]) && !empty($arguments[0])) {
         $flowQuery->pushOperation('filter', $arguments);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     $outputNodePaths = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         /** @var NodeInterface $contextNode */
         $siteNode = $contextNode->getContext()->getCurrentSiteNode();
         while ($contextNode !== $siteNode && $contextNode->getParent() !== null) {
             $contextNode = $contextNode->getParent();
             if (!isset($outputNodePaths[$contextNode->getPath()])) {
                 $output[] = $contextNode;
                 $outputNodePaths[$contextNode->getPath()] = true;
             }
         }
     }
     $flowQuery->setContext($output);
     if (isset($arguments[0]) && !empty($arguments[0])) {
         $flowQuery->pushOperation('filter', $arguments);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     $outputNodePaths = array();
     foreach ($flowQuery->getContext() as $contextNode) {
         $nextNodes = $this->getNextForNode($contextNode);
         if (is_array($nextNodes)) {
             foreach ($nextNodes as $nextNode) {
                 if ($nextNode !== null && !isset($outputNodePaths[$nextNode->getPath()])) {
                     $outputNodePaths[$nextNode->getPath()] = true;
                     $output[] = $nextNode;
                 }
             }
         }
     }
     $flowQuery->setContext($output);
     if (isset($arguments[0]) && !empty($arguments[0])) {
         $flowQuery->pushOperation('filter', $arguments);
     }
 }
 /**
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $context = $flowQuery->getContext();
     if (!isset($context[0])) {
         return NULL;
     }
     $output = array();
     /* @var $element NodeInterface */
     $element = $context[0];
     $properties = ObjectAccess::getPropertyPath($element, 'properties');
     $dynamicPropertyPrefix = $this->settings['propertyPrefix'];
     $propertyConfiguration = $element->getNodeType()->getProperties();
     // Retrieve human readable label for each dynamic property from the properties configuration.
     // Don't show properties which don't exist anymore in the node types configuration.
     foreach ($propertyConfiguration as $propertyName => $propertyConfig) {
         if (strpos($propertyName, $dynamicPropertyPrefix) === 0) {
             $output[$propertyName] = array('label' => $propertyConfig['ui']['label'], 'value' => array_key_exists($propertyName, $properties) ? $properties[$propertyName] : $propertyConfig['defaultValue']);
         }
     }
     $flowQuery->setContext($output);
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return mixed
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || empty($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('findByAuthor() needs a author to filter for', 1460741060);
     } else {
         /** @var NodeInterface $author */
         $author = $arguments[0];
         if ($author->getNodeType()->getName() !== 'JohannesSteu.Neos.News:Author') {
             throw new \TYPO3\Eel\FlowQuery\FlowQueryException('findByAuthor() only accepts as parameter Nodes of type JohannesSteu.Neos.News:Author but ' . $author->getNodeType() . ' given', 1460741067);
         }
         $nodesWithAuthorSet = [];
         $nodes = $flowQuery->getContext();
         foreach ($nodes as $node) {
             /** @var $node NodeInterface */
             $nodeAuthor = $node->getProperty("author");
             if (isset($nodeAuthor) && $nodeAuthor === $author) {
                 $nodesWithAuthorSet[] = $node;
             }
         }
         $flowQuery->setContext($nodesWithAuthorSet);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments First argument is the property to filter for, second is the date to filter for
  * @return mixed
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || empty($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('findByDateintervall() needs a property to filter for', 1460741060);
     } else {
         if (!isset($arguments[1]) || empty($arguments[1])) {
             throw new \TYPO3\Eel\FlowQuery\FlowQueryException('findByDateintervall() needs a date to filter in format for', 1460741060);
         }
         // todo pretty dirty & rough implementation right now, make this cleaner
         $property = $arguments[0];
         $dateToFilterFor = explode('-', $arguments[1]);
         $startDate = new \DateTime('now');
         $startDate->setTime(0, 0, 0);
         if (count($dateToFilterFor) > 1) {
             $startDate->setDate($dateToFilterFor[0], $dateToFilterFor[1], 1);
             $endDate = clone $startDate;
             // Add one month
             $endDate->setDate($dateToFilterFor[0], $dateToFilterFor[1] + 1, 1);
         } else {
             $startDate->setDate($dateToFilterFor[0], 1, 1);
             $endDate = clone $startDate;
             // Add one year
             $endDate->setDate($dateToFilterFor[0] + 1, 1, 1);
         }
         $nodesInDateIntervall = [];
         $nodes = $flowQuery->getContext();
         foreach ($nodes as $node) {
             /** @var NodeInterface $node */
             /** @var \DateTime $date */
             $date = $node->getProperty($property);
             if ($date->getTimestamp() >= $startDate->getTimestamp() && $date->getTimestamp() < $endDate->getTimestamp()) {
                 $nodesInDateIntervall[] = $node;
             }
         }
         $flowQuery->setContext($nodesInDateIntervall);
     }
 }
Пример #29
0
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return mixed
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     if (!isset($arguments[0]) || empty($arguments[0])) {
         throw new \TYPO3\Eel\FlowQuery\FlowQueryException('related() needs property name by which nodes should be matched', 1332492263);
     } else {
         $nodes = $flowQuery->getContext();
         // Property that contains the reference
         $lookupProperty = $arguments[0];
         // The last element of the nodes array is the one for which the type should be compared
         $comparer = array_pop($nodes);
         $identifier = $comparer->getIdentifier();
         // Define an output array
         $relatedNodes = array();
         /** @var Node $node */
         foreach ($nodes as $node) {
             if ($node->hasProperty($lookupProperty)) {
                 if ($this->containsMatchingReference($node->getProperty($lookupProperty), $identifier)) {
                     $relatedNodes[] = $node;
                 }
             }
         }
         $flowQuery->setContext($relatedNodes);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @param FlowQuery $flowQuery the FlowQuery object
  * @param array $arguments the arguments for this operation
  * @return void
  */
 public function evaluate(FlowQuery $flowQuery, array $arguments)
 {
     $output = array();
     $outputNodePaths = array();
     /** @var NodeInterface $contextNode */
     foreach ($flowQuery->getContext() as $contextNode) {
         $outputNodePaths[$contextNode->getPath()] = true;
     }
     foreach ($flowQuery->getContext() as $contextNode) {
         $parentNode = $contextNode->getParent();
         if ($parentNode instanceof NodeInterface) {
             foreach ($parentNode->getChildNodes() as $childNode) {
                 if (!isset($outputNodePaths[$childNode->getPath()])) {
                     $output[] = $childNode;
                     $outputNodePaths[$childNode->getPath()] = true;
                 }
             }
         }
     }
     $flowQuery->setContext($output);
     if (isset($arguments[0]) && !empty($arguments[0])) {
         $flowQuery->pushOperation('filter', $arguments);
     }
 }