コード例 #1
0
 /**
  * @param int $currentPage
  * @return void
  */
 public function indexAction($currentPage = 1)
 {
     // set current page
     $this->currentPage = (int) $currentPage;
     if ($this->currentPage < 1) {
         $this->currentPage = 1;
     }
     if ($this->currentPage > $this->numberOfPages) {
         // set $modifiedObjects to NULL if the page does not exist
         $modifiedObjects = null;
     } else {
         // modify query
         $this->itemsPerPage = (int) $this->configuration['itemsPerPage'];
         $query = $this->objects->getQuery();
         $query->setLimit($this->itemsPerPage);
         $this->offset = $this->itemsPerPage * ($this->currentPage - 1);
         if ($this->currentPage > 1) {
             $query->setOffset($this->offset);
         }
         $modifiedObjects = $query->execute();
     }
     $this->view->assign('contentArguments', array($this->widgetConfiguration['as'] => $modifiedObjects));
     $this->view->assign('configuration', $this->configuration);
     $this->view->assign('pagination', $this->buildPagination());
 }
コード例 #2
0
 /**
  * Save current timestamp to session
  *
  * @param QueryResultInterface $forms
  * @param array $settings
  * @return void
  */
 public static function saveFormStartInSession($forms, array $settings)
 {
     $form = $forms->getFirst();
     if ($form !== null && self::sessionCheckEnabled($settings)) {
         self::getTyposcriptFrontendController()->fe_user->setKey('ses', 'powermailFormstart' . $form->getUid(), time());
         self::getTyposcriptFrontendController()->storeSessionData();
     }
 }
コード例 #3
0
 /**
  * @param string $order
  */
 public function indexAction($order = \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING)
 {
     $order = $order == \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING ? \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_DESCENDING : \TYPO3\CMS\Extbase\Persistence\QueryInterface::ORDER_ASCENDING;
     $query = $this->objects->getQuery();
     $query->setOrderings(array($this->widgetConfiguration['property'] => $order));
     $modifiedObjects = $query->execute();
     $this->view->assign('contentArguments', array($this->widgetConfiguration['as'] => $modifiedObjects));
     $this->view->assign('order', $order);
 }
コード例 #4
0
 /**
  * @param string $order
  */
 public function indexAction($char = '%')
 {
     $query = $this->objects->getQuery();
     // just get objects with configured beginning char
     $query->matching($query->like($this->widgetConfiguration['property'], $char . '%'));
     $modifiedObjects = $query->execute();
     $this->view->assign('contentArguments', array($this->widgetConfiguration['as'] => $modifiedObjects));
     $this->view->assign('letters', range('A', 'Z'));
     $this->view->assign('char', $char);
 }
コード例 #5
0
 /**
  * Save current timestamp to session
  *
  * @param QueryResultInterface $forms
  * @param array $settings
  * @return void
  */
 public static function saveFormStartInSession($forms, array $settings)
 {
     $form = $forms->getFirst();
     if ($form !== null && self::sessionCheckEnabled($settings)) {
         /** @var TypoScriptFrontendController $typoScriptFrontendController */
         $typoScriptFrontendController = $GLOBALS['TSFE'];
         $typoScriptFrontendController->fe_user->setKey('ses', 'powermailFormstart' . $form->getUid(), time());
         $typoScriptFrontendController->storeSessionData();
     }
 }
コード例 #6
0
 /**
  * @param string $order
  */
 public function indexAction($char = '%')
 {
     $query = $this->objects->getQuery();
     // get selected objects only (title starting with specific letter)
     $query->matching($query->like($this->widgetConfiguration['property'], $char . '%'));
     $modifiedObjects = $query->execute();
     $this->view->assign('contentArguments', array($this->widgetConfiguration['as'] => $modifiedObjects));
     // create an array with all letters from A to Z
     foreach (range('A', 'Z') as $letter) {
         $letters[] = $letter;
     }
     $this->view->assign('letters', $letters);
     $this->view->assign('char', $char);
 }
コード例 #7
0
ファイル: PaginateController.php プロジェクト: Apen/t3devapi
 /**
  * Main action which does all the fun
  *
  * @param integer $currentPage
  * @return void
  */
 public function indexAction($currentPage = 1)
 {
     // set current page
     $this->currentPage = (int) $currentPage;
     if ($this->currentPage < 1) {
         $this->currentPage = 1;
     } elseif ($this->currentPage > $this->numberOfPages) {
         $this->currentPage = $this->numberOfPages;
     }
     // modify query
     $itemsPerPage = (int) $this->configuration['itemsPerPage'];
     if (is_a($this->objects, '\\TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface') || is_a($this->objects, 'TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface')) {
         $query = $this->objects->getQuery();
         // limit should only be used if needed and pagination only if results > itemsPerPage
         if ($itemsPerPage < $this->objects->count()) {
             $query->setLimit($itemsPerPage);
         }
         if ($this->currentPage > 1) {
             $query->setOffset((int) ($itemsPerPage * ($this->currentPage - 1)));
         }
         $modifiedObjects = $query->execute();
     } else {
         if (empty($this->objects)) {
             return null;
         }
         $offset = 0;
         if ($this->currentPage > 1) {
             $offset = (int) ($itemsPerPage * ($this->currentPage - 1));
         }
         $modifiedObjects = array_slice($this->objects, $offset, (int) $itemsPerPage);
     }
     $this->view->assign('contentArguments', array($this->widgetConfiguration['as'] => $modifiedObjects));
     $this->view->assign('configuration', $this->configuration);
     $this->view->assign('pagination', $this->buildPagination());
 }
コード例 #8
0
 /**
  * Main action terms will be sorted
  * by the currentCharacter
  *
  * @param string $character
  *
  * @throws Exception
  *
  * @return void
  */
 public function indexAction($character = '')
 {
     if (TRUE === empty($character)) {
         $this->query->setLimit(1)->setOrderings(array($this->field => QueryInterface::ORDER_ASCENDING));
         $firstObject = $this->query->execute()->toArray();
         $this->query = $this->objects->getQuery();
         if (TRUE === empty($firstObject)) {
             $this->view->assign('noObjects', TRUE);
         } else {
             $getter = 'get' . GeneralUtility::underscoredToUpperCamelCase($this->field);
             if (TRUE === method_exists($firstObject[0], $getter)) {
                 $this->currentCharacter = strtoupper(substr($firstObject[0]->{$getter}(), 0, 1));
             } else {
                 throw new Exception('Getter for "' . $this->field . '" in "' . get_class($firstObject[0]) . '" does not exist', 1433257601);
             }
         }
     } else {
         $this->currentCharacter = $character;
     }
     $this->currentCharacter = str_replace(array('AE', 'OE', 'UE'), array('Ä', 'Ö', 'Ü'), $this->currentCharacter);
     $objects = $this->getMatchings()->execute()->toArray();
     $this->view->assign('configuration', $this->configuration);
     $this->view->assign('pagination', $this->buildPagination());
     $this->view->assign('contentArguments', array($this->widgetConfiguration['as'] => $objects));
 }
コード例 #9
0
ファイル: PaginateController.php プロジェクト: kalypso63/news
 /**
  * Main action
  *
  * @param integer $currentPage
  * @return void
  */
 public function indexAction($currentPage = 1)
 {
     // set current page
     $this->currentPage = (int) $currentPage;
     if ($this->currentPage < 1) {
         $this->currentPage = 1;
     }
     if ($this->currentPage > $this->numberOfPages) {
         // set $modifiedObjects to NULL if the page does not exist
         $modifiedObjects = null;
     } else {
         // modify query
         $itemsPerPage = (int) $this->configuration['itemsPerPage'];
         $query = $this->objects->getQuery();
         if ($this->currentPage === $this->numberOfPages && $this->initialLimit > 0) {
             $difference = $this->initialLimit - (int) ($itemsPerPage * ($this->currentPage - 1));
             if ($difference > 0) {
                 $query->setLimit($difference);
             } else {
                 $query->setLimit($itemsPerPage);
             }
         } else {
             $query->setLimit($itemsPerPage);
         }
         if ($this->currentPage > 1) {
             $offset = (int) ($itemsPerPage * ($this->currentPage - 1));
             $offset = $offset + $this->initialOffset;
             $query->setOffset($offset);
         } elseif ($this->initialOffset > 0) {
             $query->setOffset($this->initialOffset);
         }
         $modifiedObjects = $query->execute();
     }
     $this->view->assign('contentArguments', array($this->widgetConfiguration['as'] => $modifiedObjects));
     $this->view->assign('configuration', $this->configuration);
     $this->view->assign('pagination', $this->buildPagination());
     if (!empty($this->templatePath)) {
         $this->view->setTemplatePathAndFilename($this->templatePath);
     }
 }
コード例 #10
0
 /**
  * Main action which does all the fun
  *
  * @param integer $currentPage
  * @return void
  */
 public function indexAction($currentPage = 1)
 {
     // ugly patch to work without extbase (sry for that)
     $widgetIdentifier = '__widget_0';
     if (tx_additionalreports_util::intFromVer(TYPO3_version) >= 6002000) {
         $widgetIdentifier = '@widget_0';
     }
     if ($currentPage == 1 && !empty($_GET['tx__'][$widgetIdentifier]['currentPage'])) {
         $currentPage = (int) $_GET['tx__'][$widgetIdentifier]['currentPage'];
     }
     // set current page
     $this->currentPage = (int) $currentPage;
     if ($this->currentPage < 1) {
         $this->currentPage = 1;
     } elseif ($this->currentPage > $this->numberOfPages) {
         $this->currentPage = $this->numberOfPages;
     }
     // modify query
     $itemsPerPage = (int) $this->configuration['itemsPerPage'];
     if (is_a($this->objects, '\\TYPO3\\CMS\\Extbase\\Persistence\\QueryResultInterface')) {
         $query = $this->objects->getQuery();
         // limit should only be used if needed and pagination only if results > itemsPerPage
         if ($itemsPerPage < $this->objects->count()) {
             $query->setLimit($itemsPerPage);
         }
         if ($this->currentPage > 1) {
             $query->setOffset((int) ($itemsPerPage * ($this->currentPage - 1)));
         }
         $modifiedObjects = $query->execute();
     } else {
         $offset = 0;
         if ($this->currentPage > 1) {
             $offset = (int) ($itemsPerPage * ($this->currentPage - 1));
         }
         $modifiedObjects = array_slice($this->objects, $offset, (int) $itemsPerPage);
     }
     $this->view->assign('contentArguments', array($this->widgetConfiguration['as'] => $modifiedObjects));
     $this->view->assign('configuration', $this->configuration);
     $this->view->assign('pagination', $this->buildPagination());
 }
コード例 #11
0
ファイル: PaginateController.php プロジェクト: burguin/test01
 /**
  * @param int $itemsPerPage
  * @param int $offset
  *
  * @return array|QueryResultInterface
  * @throws \InvalidArgumentException
  */
 protected function prepareObjectsSlice($itemsPerPage, $offset)
 {
     if ($this->objects instanceof QueryResultInterface) {
         $query = $this->objects->getQuery();
         $query->setLimit($itemsPerPage);
         if ($offset > 0) {
             $query->setOffset($offset);
         }
         $modifiedObjects = $query->execute();
         return $modifiedObjects;
     } elseif ($this->objects instanceof ObjectStorage) {
         $modifiedObjects = array();
         $endOfRange = $offset + $itemsPerPage;
         for ($i = $offset; $i < $endOfRange; $i++) {
             $modifiedObjects[] = $this->objects->toArray()[$i];
         }
         return $modifiedObjects;
     } elseif (is_array($this->objects)) {
         $modifiedObjects = array_slice($this->objects, $offset, $itemsPerPage);
         return $modifiedObjects;
     } else {
         throw new \InvalidArgumentException('The view helper "' . get_class($this) . '" accepts as argument "QueryResultInterface", "\\SplObjectStorage", "ObjectStorage" or an array. ' . 'given: ' . get_class($this->objects), 1385547291);
     }
 }
コード例 #12
0
ファイル: MapController.php プロジェクト: evoWeb/store_finder
 /**
  * Get center from query result based on center of all coordinates. If only one
  * is found this is used. In case none was found the center based on the request
  * gets calculated
  *
  * @param \TYPO3\CMS\Extbase\Persistence\QueryResultInterface $queryResult
  *
  * @return Model\Location
  */
 protected function getCenterOfQueryResult($queryResult)
 {
     if ($queryResult->count() == 1) {
         return $queryResult->getFirst();
     } elseif (!$queryResult->count()) {
         return $this->getCenter();
     }
     /** @var Model\Location $center */
     $center = $this->objectManager->get('Evoweb\\StoreFinder\\Domain\\Model\\Location');
     $x = $y = $z = 0;
     /** @var Model\Location $location */
     foreach ($queryResult as $location) {
         $x += cos($location->getLatitude()) * cos($location->getLongitude());
         $y += cos($location->getLatitude()) * sin($location->getLongitude());
         $z += sin($location->getLatitude());
     }
     $x /= $queryResult->count();
     $y /= $queryResult->count();
     $z /= $queryResult->count();
     $center->setLongitude(atan2($y, $x));
     $center->setLatitude(atan2($z, sqrt($x * $x + $y * $y)));
     return $center;
 }
コード例 #13
0
 /**
  * Main action
  *
  * @param int $currentPage
  * @param array $order
  * @return void
  */
 public function indexAction($currentPage = 1, $order = NULL)
 {
     // set current page
     $this->currentPage = (int) $currentPage;
     if ($this->currentPage < 1) {
         $this->currentPage = 1;
     }
     if ($this->currentPage > $this->numberOfPages) {
         // set $modifiedObjects to NULL if the page does not exist
         $modifiedObjects = NULL;
     } else {
         // modify query
         $itemsPerPage = (int) $this->configuration['itemsPerPage'];
         $query = $this->objects->getQuery();
         if (is_array($order) && count($order)) {
             if (strtolower($order['dir']) == "desc") {
                 $dir = QueryInterface::ORDER_DESCENDING;
             } else {
                 $dir = QueryInterface::ORDER_ASCENDING;
             }
             $setOrderings[$order['by']] = $dir;
             $lookupTcaTable = $this->configuration['orderByFields'][$order['by']]['config']['model'];
             if ($lookupTcaTable != "" && isset($GLOBALS['TCA'][$lookupTcaTable]['columns'][$order['by']]['moox']['sortable']['additional_sorting']) && $GLOBALS['TCA'][$lookupTcaTable]['columns'][$order['by']]['moox']['sortable']['additional_sorting'] != "") {
                 foreach (explode(",", $GLOBALS['TCA'][$lookupTcaTable]['columns'][$order['by']]['moox']['sortable']['additional_sorting']) as $additionalSorting) {
                     $additionalSorting = explode(" ", $additionalSorting);
                     $field = $additionalSorting[0];
                     $direction = $additionalSorting[1];
                     if (strtolower($direction) == "desc") {
                         $setOrderings[$field] = QueryInterface::ORDER_DESCENDING;
                     } else {
                         $setOrderings[$field] = QueryInterface::ORDER_ASCENDING;
                     }
                 }
             }
             $query->setOrderings($setOrderings);
             $this->order = $order;
         } else {
             if (strtolower($this->order['dir']) == "desc") {
                 $dir = QueryInterface::ORDER_DESCENDING;
             } else {
                 $dir = QueryInterface::ORDER_ASCENDING;
             }
             $query->setOrderings([$this->order['by'] => $dir]);
         }
         if ($this->currentPage === $this->numberOfPages && $this->initialLimit > 0) {
             $difference = $this->initialLimit - (int) ($itemsPerPage * ($this->currentPage - 1));
             if ($difference > 0) {
                 $query->setLimit($difference);
             } else {
                 $query->setLimit($itemsPerPage);
             }
         } else {
             $query->setLimit($itemsPerPage);
         }
         if ($this->currentPage > 1) {
             $offset = (int) ($itemsPerPage * ($this->currentPage - 1));
             $offset = $offset + $this->initialOffset;
             $query->setOffset($offset);
         } elseif ($this->initialOffset > 0) {
             $query->setOffset($this->initialOffset);
         }
         $modifiedObjects = $query->execute();
     }
     $this->view->assign('contentArguments', [$this->widgetConfiguration['as'] => $modifiedObjects]);
     $this->view->assign('configuration', $this->configuration);
     $this->view->assign('pagination', $this->buildPagination($this->order));
     if (!empty($this->templatePath)) {
         $this->view->setTemplatePathAndFilename($this->templatePath);
     }
 }
コード例 #14
0
 /**
  * Sort entities by the localized name
  *
  * @param \TYPO3\CMS\Extbase\Persistence\QueryResultInterface $entities to be sorted
  * @param string $orderDirection may be "asc" or "desc". Default is "asc".
  * @return array entities ordered by localized name
  */
 public function localizedSort(\TYPO3\CMS\Extbase\Persistence\QueryResultInterface $entities, $orderDirection = 'asc')
 {
     $result = $entities->toArray();
     $locale = \SJBR\StaticInfoTables\Utility\LocalizationUtility::setCollatingLocale();
     if ($locale !== FALSE) {
         if ($orderDirection === 'asc') {
             uasort($result, array($this, 'strcollOnLocalizedName'));
         } else {
             uasort($result, array($this, 'strcollOnLocalizedNameDesc'));
         }
     }
     return $result;
 }
コード例 #15
0
 /**
  * Like rows() but works with an existing QueryResult.
  *
  * @param QueryResultInterface $result
  * @param null $keyField See \CIC\Cicbase\Arr::column
  * @param null $valueField See \CIC\Cicbase\Arr::column
  * @return array
  * @throws \Exception
  */
 public function rowsFromQueryResult(QueryResultInterface $result, $keyField = NULL, $valueField = NULL)
 {
     $rows = $this->persistenceManager->getObjectDataByQuery($result->getQuery());
     if ($keyField !== NULL || $valueField !== NULL) {
         return Arr::column($rows, $valueField, $keyField);
     }
     return $rows;
 }