Пример #1
0
 /**
  * Returns an array of orderings created from a given demand object.
  *
  * @param Tx_MooxNews_Domain_Model_DemandInterface $demand
  * @return array<\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface>
  */
 protected function createOrderingsFromDemand(Tx_MooxNews_Domain_Model_DemandInterface $demand)
 {
     $orderings = array();
     if (Tx_MooxNews_Utility_Validation::isValidOrdering($demand->getOrder(), $demand->getOrderByAllowed())) {
         $orderList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $demand->getOrder(), TRUE);
         if (!empty($orderList)) {
             // go through every order statement
             foreach ($orderList as $orderItem) {
                 list($orderField, $ascDesc) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(' ', $orderItem, TRUE);
                 // count == 1 means that no direction is given
                 if ($ascDesc) {
                     $orderings[$orderField] = strtolower($ascDesc) == 'desc' ? \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING : \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING;
                 } else {
                     $orderings[$orderField] = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING;
                 }
             }
         }
     }
     return $orderings;
 }
Пример #2
0
 /**
  * Returns an array of orderings created from a given demand object.
  *
  * @param Tx_MooxNews_Domain_Model_DemandInterface $demand
  * @return array<\TYPO3\CMS\Extbase\Persistence\Generic\Qom\ConstraintInterface>
  */
 protected function createOrderingsFromDemand(Tx_MooxNews_Domain_Model_DemandInterface $demand)
 {
     $orderings = array();
     if ($demand->getTopNewsFirst()) {
         $orderings['istopnews'] = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING;
     }
     if (Tx_MooxNews_Utility_Validation::isValidOrdering($demand->getOrder(), $demand->getOrderByAllowed())) {
         $orderList = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $demand->getOrder(), TRUE);
         if (!empty($orderList)) {
             // go through every order statement
             foreach ($orderList as $orderItem) {
                 list($orderField, $ascDesc) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(' ', $orderItem, TRUE);
                 // count == 1 means that no direction is given
                 if ($ascDesc) {
                     $orderings[$orderField] = strtolower($ascDesc) == 'desc' ? \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING : \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING;
                 } else {
                     $orderings[$orderField] = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING;
                 }
                 $orderFieldUnderscored = \TYPO3\CMS\Core\Utility\GeneralUtility::camelCaseToLowerCaseUnderscored($orderField);
                 if (isset($GLOBALS['TCA']['tx_mooxnews_domain_model_news']['columns'][$orderFieldUnderscored]['addToMooxNewsFrontendSorting']['additionalSorting'])) {
                     $additionalSorting = $GLOBALS['TCA']['tx_mooxnews_domain_model_news']['columns'][$orderFieldUnderscored]['addToMooxNewsFrontendSorting']['additionalSorting'];
                     if ($additionalSorting != '') {
                         list($orderField, $ascDesc) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(' ', $additionalSorting, TRUE);
                         // count == 1 means that no direction is given
                         if (!isset($orderings[$orderField])) {
                             if ($ascDesc) {
                                 $orderings[$orderField] = strtolower($ascDesc) == 'desc' ? \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING : \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING;
                             } else {
                                 $orderings[$orderField] = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING;
                             }
                         }
                     }
                 }
             }
             if (!isset($orderings['title'])) {
                 $orderings['title'] = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING;
             }
         }
     }
     return $orderings;
 }