/** * @param $routeName * @param null|string $lastModificationDate * @return $this */ protected function addUrl($routeName, $lastModificationDate = null) { if ($this->pageIsIndexable($routeName)) { $this->urls[] = (new Url($this->router->route($routeName, true)))->setLastMod($lastModificationDate); } return $this; }
/** * Redirect to an other URLs * * @param string $path * @param int $statusCode * * @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse */ protected function createRedirectResponse($path, $statusCode) { $path = $this->router->route($path, true); if ($this->request->isXmlHttpRequest() === true) { return $this->createAjaxRedirectResponse($path); } return new SymfonyRedirectResponse($path, $statusCode); }
/** * @param array $data * @param string $value * * @return string */ protected function getUrl(array $data, $value) { $url = sprintf($data['pattern'], $value); if (isset($data['isRoute'])) { return $this->router->route($url); } return $url; }
/** * @param string $searchTerm * @param string $areas * @param string $sortDirection * @return array */ public function fetchSearchResults($searchTerm, $areas, $sortDirection) { $results = $this->repository->getAllSearchResults($this->mapSearchAreasToFields($areas), $searchTerm, $sortDirection); $cResults = count($results); for ($i = 0; $i < $cResults; ++$i) { $results[$i]['hyperlink'] = $this->router->route(sprintf($this->getRouteName(), $results[$i]['id'])); } return $results; }
/** * @param string $route * @param string $translationPhrase * @param string $iconClass * @param string $buttonClass * @param bool $useAjax */ public function addOption($route, $translationPhrase, $iconClass, $buttonClass = 'btn-default', $useAjax = false) { $ajax = $useAjax === true ? ' data-ajax-form="true"' : ''; $value = ' <a href="' . $this->router->route($route) . '" class="btn btn-xs ' . $buttonClass . '"' . $ajax . ' title="' . $translationPhrase . '">'; $value .= '<i class="glyphicon ' . $iconClass . '"></i>'; $value .= '<span class="sr-only">' . $translationPhrase . '</span>'; $value .= '</a>'; $this->options[] = $value; }
/** * Parst einen Text und zerlegt diesen bei Bedarf mehrere Seiten * * @param string $text * @param string $baseUrlPath * * @return array */ public function splitTextIntoPages($text, $baseUrlPath) { $matches = []; preg_match_all($this->getSplitPagesRegex(), $text, $matches); $pages = preg_split($this->getSplitPagesRegex(), $text, -1, PREG_SPLIT_NO_EMPTY); $currentPage = $this->getCurrentPage($pages); $nextPage = !empty($pages[$currentPage]) ? $this->router->route($baseUrlPath) . 'page_' . ($currentPage + 1) . '/' : ''; $previousPage = $currentPage > 1 ? $this->router->route($baseUrlPath) . ($currentPage - 1 > 1 ? 'page_' . ($currentPage - 1) . '/' : '') : ''; return ['toc' => $this->tableOfContents->generateTOC($matches[0], $baseUrlPath), 'text' => $pages[$currentPage - 1], 'next' => $nextPage, 'previous' => $previousPage]; }
/** * Erzeugt das Captchafeld für das Template * * @param integer $captchaLength * @param string $formFieldId * @param bool $inputOnly * @param string $path * * @return string */ public function captcha($captchaLength = self::CAPTCHA_DEFAULT_LENGTH, $formFieldId = self::CAPTCHA_DEFAULT_INPUT_ID, $inputOnly = false, $path = '') { if ($this->user->isAuthenticated() === false) { $path = sha1($this->router->route(empty($path) === true ? $this->request->getQuery() : $path)); $this->sessionHandler->set('captcha_' . $path, $this->secureHelper->salt($captchaLength)); $this->view->assign('captcha', ['width' => $captchaLength * 25, 'id' => $formFieldId, 'height' => 30, 'input_only' => $inputOnly, 'path' => $path]); return $this->view->fetchTemplate('Captcha/Partials/captcha.tpl'); } return ''; }
/** * @return array */ public function fetchFeedItems() { $items = []; $results = $this->filesRepository->getAll($this->date->getCurrentDateTime(), 10); $cResults = count($results); for ($i = 0; $i < $cResults; ++$i) { $items[] = ['title' => $results[$i]['title'], 'date' => $this->date->timestamp($results[$i]['start']), 'description' => $this->formatter->shortenEntry($results[$i]['text'], 300, 0), 'link' => $this->router->route('files/index/details/id_' . $results[$i]['id'], true)]; } return $items; }
/** * @param array $matches * * @return string */ private function rewriteInternalUriCallback(array $matches) { if ($this->internalUriValidationRule->isValid($matches[7]) === true) { $resourceParts = explode('/', $matches[7]); $path = $this->getResourcePath($resourceParts); if ($this->controllerActionExists->controllerActionExists($path) === true) { return '<a' . $matches[1] . 'href="' . $this->router->route($matches[7]) . '"'; } } return $matches[0]; }
/** * Versendet einen Newsletter * * @param int $newsletterId * @param string|array $recipients * @param bool $bcc * * @return bool */ public function sendNewsletter($newsletterId, $recipients, $bcc = false) { $settings = $this->config->getSettings(Schema::MODULE_NAME); $newsletter = $this->newsletterRepository->getOneById($newsletterId); $sender = ['email' => $settings['mail'], 'name' => $this->config->getSettings(\ACP3\Modules\ACP3\System\Installer\Schema::MODULE_NAME)['site_title']]; $this->mailer->reset()->setBcc($bcc)->setFrom($sender)->setSubject($newsletter['title'])->setUrlWeb($this->router->route('newsletter/archive/details/id_' . $newsletterId, true))->setMailSignature($settings['mailsig']); if ($newsletter['html'] == 1) { $this->mailer->setTemplate('newsletter/layout.email.tpl'); $this->mailer->setHtmlBody($newsletter['text']); } else { $this->mailer->setBody($newsletter['text']); } $this->mailer->setRecipients($recipients); return $this->mailer->send(); }
/** * @param int $mode * @param string $uri * * @return string */ protected function getMenuItemHref($mode, $uri) { if ($mode == 1 || $mode == 2 || $mode == 4) { return $this->router->route($uri); } return $uri; }
/** * @inheritdoc */ protected function getDbValueIfExists(array $dbResultRow, $field) { if (isset($dbResultRow[$field])) { if ((int) $dbResultRow[$field] === 0) { $route = $this->router->route('acp/newsletter/accounts/activate/id_' . $dbResultRow[$this->primaryKey]); $title = $this->translator->t('newsletter', 'activate_account'); $value = '<a href="' . $route . '" title="' . $title . '">'; $value .= '<i class="glyphicon glyphicon-remove text-danger"></i>'; $value .= '</a>'; } else { $value = '<i class="glyphicon glyphicon-ok text-success"></i>'; } return $value; } return null; }
/** * @param bool $customUris * @param array|string $page * @param int $pageNumber * @param string $requestQuery * * @return string */ protected function fetchTocPageUri($customUris, $page, $pageNumber, $requestQuery) { if ($customUris === true && is_array($page) === true) { return $page['uri']; } return $this->router->route($requestQuery) . ($pageNumber > 1 ? 'page_' . $pageNumber . '/' : ''); }
/** * @inheritdoc */ public function fetchDataAndRenderColumn(array $column, array $dbResultRow) { $dbValue = $this->getValue($column, $dbResultRow); $value = ''; if ($dbResultRow['last'] != $dbValue) { $value .= $this->fetchSortDirectionHtml($this->router->route(sprintf($column['custom']['route_sort_down'], $dbResultRow[$this->primaryKey])), 'down'); } if ($dbResultRow['first'] != $dbValue) { $value .= $this->fetchSortDirectionHtml($this->router->route(sprintf($column['custom']['route_sort_up'], $dbResultRow[$this->primaryKey])), 'up'); } if ($dbResultRow['first'] == $dbResultRow['last']) { $value = $this->fetchSortForbiddenHtml(); } $column['attribute']['data-order'] = $dbResultRow[$this->getFirstDbField($column)]; return $this->render($column, $value); }
/** * @param array $params * @param string $action * @param string $area * * @return array */ private function collectData(array $params, $action, $area) { $accessCheck = []; $accessCheck['uri'] = $this->router->route($params['path']); if (isset($params['title'])) { $accessCheck['title'] = $params['title']; } if (isset($params['lang'])) { $langArray = explode('|', $params['lang']); $accessCheck['lang'] = $this->translator->t($langArray[0], $langArray[1]); } else { $accessCheck['lang'] = $this->translator->t($action[0], $area . '_' . $action[1] . '_' . $action[2]); } if (isset($params['class'])) { $accessCheck['class'] = $params['class']; } $accessCheck['mode'] = $params['mode']; return $accessCheck; }
/** * @param string $path * * @return bool */ private function stepAlreadyExists($path) { $route = $this->router->route($path); foreach ($this->steps as $step) { if ($step['uri'] === $route) { return true; } } return false; }
/** * helper function for deleting a result set * * @param string $action * @param string|null $moduleConfirmUrl * @param string|null $moduleIndexUrl * * @return array|JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse */ private function deleteItem($action, $moduleConfirmUrl = null, $moduleIndexUrl = null) { $entries = $this->prepareRequestData(); if (empty($entries)) { return $this->redirectMessages->setMessage(false, $this->translator->t('system', 'no_entries_selected'), $moduleIndexUrl); } elseif ($action !== 'confirmed') { $data = ['action' => 'confirmed', 'entries' => $entries]; return $this->alerts->confirmBoxPost($this->prepareConfirmationBoxText($entries), $data, $this->router->route($moduleConfirmUrl), $this->router->route($moduleIndexUrl)); } return $entries; }
/** * @param string $path * @param array $arguments * @return string */ protected function esiInclude($path, array $arguments) { $routeArguments = ''; foreach ($arguments as $key => $value) { $routeArguments .= '/' . $key . '_' . $value; } $debug = ''; if ($this->applicationMode === ApplicationMode::PRODUCTION) { $debug = ' onerror="continue"'; } $esiTag = '<esi:include src="' . $this->router->route($path . $routeArguments, true) . '"' . $debug . ' />'; return $esiTag; }
/** * @return array */ public function render() { if ($this->totalResults > $this->resultsPerPage) { $areaPrefix = $this->request->getArea() === AreaEnum::AREA_ADMIN ? 'acp/' : ''; $link = $this->router->route($areaPrefix . $this->request->getUriWithoutPages()); $this->currentPage = (int) $this->request->getParameters()->get('page', 1); $this->totalPages = (int) ceil($this->totalResults / $this->resultsPerPage); $this->setMetaStatements(); $range = $this->calculateRange(); $this->showFirstPageLink($link, $range); $this->showPreviousPageLink($link); for ($i = (int) $range['start']; $i <= $range['end']; ++$i) { $this->pagination[] = $this->buildPageNumber($i, $link . ($i > 1 ? 'page_' . $i . '/' : '') . $this->urlFragment, '', $this->currentPage === $i); } $this->showNextPageLink($link); $this->showLastPageLink($link, $range); } return $this->pagination; }
/** * @param string $emailAddress * @param string $hash * * @return bool */ protected function sendDoubleOptInEmail($emailAddress, $hash) { $url = $this->router->route('newsletter/index/activate/hash_' . $hash, true); $systemSettings = $this->config->getSettings(\ACP3\Modules\ACP3\System\Installer\Schema::MODULE_NAME); $settings = $this->config->getSettings(Schema::MODULE_NAME); $subject = $this->translator->t('newsletter', 'subscribe_mail_subject', ['%title%' => $systemSettings['site_title']]); $body = $this->translator->t('newsletter', 'subscribe_mail_body', ['{host}' => $this->request->getHost()]) . "\n\n"; $from = ['email' => $settings['mail'], 'name' => $systemSettings['site_title']]; $this->mailer->reset()->setFrom($from)->setSubject($subject)->setMailSignature($settings['mailsig']); if ($settings['html'] == 1) { $this->mailer->setTemplate('newsletter/layout.email.tpl'); $body .= '<a href="' . $url . '">' . $url . '<a>'; $this->mailer->setHtmlBody($this->stringFormatter->nl2p($body)); } else { $body .= $url; $this->mailer->setBody($body); } $this->mailer->setRecipients($emailAddress); return $this->mailer->send(); }
/** * If there is an URI alias available, set the alias as the canonical URI * * @param \ACP3\Core\Application\Event\ControllerActionBeforeDispatchEvent $event */ public function onBeforeDispatch(ControllerActionBeforeDispatchEvent $event) { if ($this->isInFrontend($event) && $this->uriAliasExists()) { $this->metaStatements->setCanonicalUri($this->router->route($this->request->getQuery())); } }
/** * @inheritdoc */ public function process(array $params, \Smarty_Internal_Template $smarty) { return $this->router->route(!empty($params['args']) ? $params['args'] : '', isset($params['absolute']) ? (bool) $params['absolute'] : false, isset($params['secure']) ? (bool) $params['secure'] : false); }
/** * @param string $value * @param string $path * @return bool */ protected function checkCaptcha($value, $path) { $indexName = 'captcha_' . sha1($this->router->route(empty($path) === true ? $this->request->getQuery() : $path)); return preg_match('/^[a-zA-Z0-9]+$/', $value) && strtolower($value) === strtolower($this->sessionHandler->get($indexName, '')); }