public function generateAddActions($arrData, $id, Watchlist $objWatchlist) { global $objPage; if ($objPage === null) { return; } if (\Validator::isUuid($id)) { $objFile = \FilesModel::findByUuid($id); } else { $objFile = \FilesModel::findBy('path', $id); } $objItem = new WatchlistItemModel(); $objItem->pid = Watchlist::getInstance()->getId(); $objItem->uuid = $objFile->uuid; $objItem->pageID = $objPage->id; $objItem->cid = $arrData['id']; $objItem->type = $arrData['type']; $objT = new \FrontendTemplate('watchlist_add_actions'); $objT->addHref = ampersand(\Controller::generateFrontendUrl($objPage->row()) . '?act=' . WATCHLIST_ACT_ADD . '&cid=' . $objItem->cid . '&type=' . $objItem->type . '&id=' . $strUuid . '&title=' . urlencode($objItem->getTitle())); $objT->addTitle = $GLOBALS['TL_LANG']['WATCHLIST']['addTitle']; $objT->addLink = $GLOBALS['TL_LANG']['WATCHLIST']['addLink']; $objT->active = $objWatchlist->isInList($strUuid); $objT->id = $strUuid; return $objT->parse(); }
protected function runAction() { global $objPage; switch (\Input::get('act')) { case WATCHLIST_ACT_DELETE: Watchlist::getInstance()->deleteItem(\Input::get('id')); break; case WATCHLIST_ACT_ADD: $objItem = new WatchlistItemModel(); $objItem->pid = Watchlist::getInstance()->getId(); $objItem->uuid = \Input::get('id'); $objItem->pageID = $objPage->id; $objItem->cid = \Input::get('cid'); $objItem->type = \Input::get('type'); $objItem->title = \Input::get('title'); $objItem->tstamp = time(); Watchlist::getInstance()->addItem($objItem); break; case WATCHLIST_ACT_DELETE_ALL: Watchlist::getInstance()->deleteAll(); break; case WATCHLIST_ACT_DOWNLOAD_ALL: Watchlist::getInstance()->downloadAll(); break; } // if ajax -> return the content of the watchlist if (\Environment::get('isAjaxRequest')) { die(json_encode(array('action' => \Input::get('act'), 'watchlist' => Watchlist::getInstance()->generate(), 'notification' => Watchlist::getInstance()->generateNotifications(), 'count' => Watchlist::getInstance()->count(), 'cssClass' => Watchlist::getInstance()->count() > 0 ? 'not-empty' : 'empty'))); } // no js support -- redirect and remove GET parameters \Controller::redirect(\Controller::generateFrontendUrl($objPage->row())); }
/** * @deprecated */ public static function loadStoreDetails(array $arrStore, $jumpTo = null) { //load country names //@todo load only once. not every time. $arrCountryNames = \System::getCountries(); //full localized country name //@todo rename country to countrycode in database $arrStore['countrycode'] = $arrStore['country']; $arrStore['country'] = $arrCountryNames[$arrStore['countrycode']]; // generate jump to if ($jumpTo) { if (($objLocation = \PageModel::findByPk($jumpTo)) !== null) { //@todo language parameter $strStoreKey = !$GLOBALS['TL_CONFIG']['useAutoItem'] ? '/store/' : '/'; $strStoreValue = $arrStore['alias']; $arrStore['href'] = \Controller::generateFrontendUrl($objLocation->row(), $strStoreKey . $strStoreValue); } } // opening times $arrStore['opening_times'] = deserialize($arrStore['opening_times']); // store logo //@todo change size and properties in module if ($arrStore['logo']) { if (($objLogo = \FilesModel::findByUuid($arrStore['logo'])) !== null) { $arrLogo = $objLogo->row(); $arrMeta = deserialize($arrLogo['meta']); $arrLogo['meta'] = $arrMeta[$GLOBALS['TL_LANGUAGE']]; $arrStore['logo'] = $arrLogo; } else { $arrStore['logo'] = null; } } return $arrStore; }
/** * compile */ protected function compile() { if ($this->cssID[0] == '') { $cssID = $this->cssID; $cssID[0] = 'modal-' . $this->id; $this->cssID = $cssID; } $modal = new Component(); $modal->setId($this->cssID[0])->setSize($this->bootstrap_modalSize); if ($this->cssID[1]) { $modal->addClass($this->cssID[1]); } // check if ajax is used if ($this->bootstrap_modalAjax) { $this->Template->hideFrame = $this->isAjax; $this->Template->hideContent = !$this->Template->hideFrame; } if ($this->Template->hideContent) { $url = \Controller::generateFrontendUrl($GLOBALS['objPage']->row()) . '?bootstrap_modal=' . $this->id; //$url = sprintf(Bootstrap::getConfigVar('modal.remoteUrl'), $GLOBALS['objPage']->id, $this->id); $modal->setAttribute('data-remote', $url)->render($this->Template); return; } if ($this->headline) { $headline = Element::create($this->hl)->addClass('modal-title')->addChild($this->headline); $modal->setTitle($headline); } $modal->setContent($this->getContent())->setFooter($this->getButtons())->setCloseButton(Bootstrap::getConfigVar('modal.dismiss'), true)->render($this->Template); }
public static function checkPermissionForProtectedHomeDirs($strFile) { $strUuid = \Config::get('protectedHomeDirRoot'); if (!$strFile) { return; } if ($strUuid && ($strProtectedHomeDirRootPath = \HeimrichHannot\HastePlus\Files::getPathFromUuid($strUuid)) !== null) { // check only if path inside the protected root dir if (StringUtil::startsWith($strFile, $strProtectedHomeDirRootPath)) { if (FE_USER_LOGGED_IN) { if (($objFrontendUser = \FrontendUser::getInstance()) !== null) { if (\Config::get('allowAccessByMemberId') && $objFrontendUser->assignProtectedDir && $objFrontendUser->protectedHomeDir) { $strProtectedHomeDirMemberRootPath = Files::getPathFromUuid($objFrontendUser->protectedHomeDir); // fe user id = dir owner member id if (StringUtil::startsWith($strFile, $strProtectedHomeDirMemberRootPath)) { return; } } if (\Config::get('allowAccessByMemberGroups')) { $arrAllowedGroups = deserialize(\Config::get('allowedMemberGroups'), true); if (array_intersect(deserialize($objFrontendUser->groups, true), $arrAllowedGroups)) { return; } } } } $intNoAccessPage = \Config::get('jumpToNoAccess'); if ($intNoAccessPage && ($objPageJumpTo = \PageModel::findByPk($intNoAccessPage)) !== null) { \Controller::redirect(\Controller::generateFrontendUrl($objPageJumpTo->row())); } else { die($GLOBALS['TL_LANG']['MSC']['noAccessDownload']); } } } }
protected static function addCurrentPage(FileCreditModel $objCredit) { global $objPage; $strRequestRaw = preg_replace('/\\?.*/', '', \Environment::get('request')); // strip get parameter from url $strRequest = rtrim($strRequestRaw, "/"); $strAlias = \Controller::generateFrontendUrl($objPage->row()); // only accept pages or auto_item pages if (!Validator::isRequestAlias($strRequest, $strAlias)) { // cleanup pages that no longer exist $objModel = FileCreditPageModel::findByPidAndPageAndUrl($objCredit->id, $objPage->id, $strRequestRaw); if ($objModel !== null) { while ($objModel->next()) { $objModel->delete(); } } return false; } $objModel = FileCreditPageModel::findByPidAndPageAndUrl($objCredit->id, $objPage->id, $strRequest); // do not index page again if ($objModel !== null) { return false; } $arrSet = array('pid' => $objCredit->id, 'tstamp' => time(), 'page' => $objPage->id, 'url' => $strRequest, 'protected' => $objPage->protected ? '1' : '', 'groups' => $objPage->groups, 'language' => $objPage->language, 'published' => 1, 'start' => '', 'stop' => ''); // create: add new page for the credit $objModel = new FileCreditPageModel(); $objModel->setRow($arrSet); $objModel->save(); return true; }
/** * Display a wildcard in the back end * @return string */ public function generate() { if (TL_MODE == 'BE') { $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['newsreader'][0]) . ' ###'; $objTemplate->title = $this->headline; $objTemplate->id = $this->id; $objTemplate->link = $this->name; $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; return $objTemplate->parse(); } global $objPage; if ($this->news_template_modal) { $this->strTemplate = 'mod_news_modal'; $this->news_template = $this->news_template_modal; // list config $this->news_showInModal = true; $this->news_readerModule = $this->id; // set modal css ID for generateModal() and parent::generate() $arrCss = deserialize($this->cssID, true); $arrCss[0] = NewsPlusHelper::getCSSModalID($this->id); $this->cssID = $arrCss; $this->base = \Controller::generateFrontendUrl($objPage->row()); if ($this->Environment->isAjaxRequest && !$this->isSearchIndexer()) { $this->strTemplate = 'mod_news_modal_ajax'; $this->generateAjax(); } if (!$this->checkConditions()) { return $this->generateModal(); } } return parent::generate(); }
protected function compile() { global $objPage; // Set the flags $GLOBALS['NEWS_FILTER_SHOW_SEARCH'] = $this->news_filterShowSearch ? true : false; // filter news by search $GLOBALS['NEWS_FILTER_USE_SEARCH_INDEX'] = $this->news_filterUseSearchIndex ? true : false; // filter news by search index or tl_news table $GLOBALS['NEWS_FILTER_FUZZY_SEARCH'] = $this->news_filterFuzzySearch ? true : false; // use fuzzy search $GLOBALS['NEWS_FILTER_SEARCH_QUERY_TYPE'] = $this->news_filterSearchQueryType ? "and" : "or"; // query type 'and' or 'or' $this->strCategoryTemplate = $this->news_filterCategoryTemplate ?: NULL; // Show search form in template $this->Template->showSearch = $this->news_filterShowSearch ?: NULL; $this->Template->showCategories = $this->news_filterShowCategories ?: NULL; // Set Fields $this->Template->searchKeywords = trim(\Input::get('searchKeywords')); $this->news_archives = $this->sortOutProtected(deserialize($this->news_archives)); // Return if there are no archives if (!is_array($this->news_archives) || empty($this->news_archives)) { return ''; } // news archive, with newscategories (news_categories module) $this->news_filterNewsCategoryArchives = deserialize($this->news_filterNewsCategoryArchives, true); $sql = "SELECT * FROM tl_news_archive WHERE tl_news_archive.id IN(" . implode(',', array_map('intval', $this->news_archives)) . ") ORDER BY title"; /** @var \Contao\Database\Result $rs */ $rs = \Database::getInstance()->query($sql); $arrResult = $rs->fetchAllAssoc(); if (empty($arrResult)) { return ''; } $objTemplate = new \FrontendTemplate($this->searchTpl ?: $this->strCategoryTemplate); $objTemplate->filterName = $GLOBALS['TL_LANG']['news_plus']['filterLabel']; $objTemplate->rootPageLink = \Controller::generateFrontendUrl($objPage->row()); if ($this->strCategoryTemplate == 'filter_cat_multilevel') { $strNewsArchives = trim(\Input::get('newscategories')); $strNewsCategories = trim(\Input::get('category')); if ($strNewsArchives || $strNewsCategories) { $filterName = ModuleNewsListPlus::findArchiveTitleByPid($strNewsArchives); // overwrite title with news_category if ($filterName && $strNewsCategories) { $objNewsCategory = \NewsCategories\NewsCategoryModel::findPublishedByIdOrAlias($strNewsCategories); if ($objNewsCategory !== null) { $filterName = $objNewsCategory->frontendTitle ? $objNewsCategory->frontendTitle : $objNewsCategory->title; } } $objTemplate->filterName = self::getShortCategoryTitle($filterName); $objTemplate->filterResetName = $GLOBALS['TL_LANG']['news_plus']['resetFilterLabel']; $objTemplate->pageLink = $objPage->alias; $objTemplate->activeNewsArchive = $strNewsArchives; $objTemplate->activeCategory = $strNewsCategories; } $objTemplate->categories = self::groupCategoriesByArchivesTitle($arrResult); } else { $objTemplate->optionValues = self::getCategoriesFromArchiveTitle($arrResult); } $this->Template->categories = $objTemplate->parse(); }
public static function parseCredit(FileCreditModel $objModel, array $arrPids = array(), $objModule) { global $objPage; $objTemplate = new \FrontendTemplate(!$objModule->creditsGroupBy ? 'filecredit_default' : 'filecredit_grouped'); // skip if no files model exists if (($objFilesModel = $objModel->getRelated('uuid')) === null) { return null; } // cleanup: remove credits where copyright was deleted if ($objFilesModel->copyright == '') { FileCreditPageModel::deleteByPid($objModel->id); $objModel->delete(); return null; } // skip if credit occurs on no page if (($objCreditPages = FileCreditPageModel::findPublishedByPids(array($objModel->id))) === null) { return null; } while ($objCreditPages->next()) { $arrCredit = $objCreditPages->row(); // not a child of current root page if (!empty($arrPids) && !in_array($arrCredit['page'], $arrPids)) { continue; } if ($arrCredit['url'] == '' && ($objTarget = \PageModel::findByPk($arrCredit['page'])) !== null) { $arrCredit['url'] = \Controller::generateFrontendUrl($objTarget->row()); } $arrPages[] = $arrCredit; } if ($arrPages === null) { return null; } $objTemplate->setData($objModel->row()); $objTemplate->fileData = $objFilesModel->row(); static::addCopyrightToTemplate($objTemplate, $objFilesModel, $objModule); $objTemplate->link = $GLOBALS['TL_LANG']['MSC']['creditLinkText']; $objTemplate->pagesLabel = $GLOBALS['TL_LANG']['MSC']['creditPagesLabel']; $objTemplate->path = $objFilesModel->path; $objTemplate->pages = $arrPages; $objTemplate->pageCount = count($arrPages); // colorbox support if ($objPage->outputFormat == 'xhtml') { $strLightboxId = 'lightbox'; } else { $strLightboxId = 'lightbox[' . substr(md5($objTemplate->getName() . '_' . $objFilesModel->id), 0, 6) . ']'; } $objTemplate->attribute = $strLightboxId ? ($objPage->outputFormat == 'html5' ? ' data-gallery="#gallery-' . $objModule->id . '" data-lightbox="' : ' rel="') . $strLightboxId . '"' : ''; $objTemplate->addImage = false; // Add an image if (!is_file(TL_ROOT . '/' . $objModel->path)) { $arrData = array('singleSRC' => $objFilesModel->path, 'doNotIndex' => true); $size = deserialize($objModule->imgSize); if ($size[0] > 0 || $size[1] > 0 || is_numeric($size[2])) { $arrData['size'] = $objModule->imgSize; } \Controller::addImageToTemplate($objTemplate, $arrData); } return array('pages' => $arrPages, 'order' => static::getSortValue($objModule->creditsSortBy, $objTemplate), 'group' => static::getGroupValue($objModule->creditsGroupBy, $objTemplate), 'output' => $objTemplate->parse()); }
protected function compile() { global $objPage; $this->Template->href = \Controller::generateFrontendUrl($this->objTarget->row()); if ($objPage->id == $this->jumpTo) { $this->Template->active = true; } }
protected function generateForumlayout($activeRecord) { Message::addInfo("Generating Layout"); $row = $activeRecord->row(); $row['skipInternalHook'] = true; $url = Controller::generateFrontendUrl($row, null, null, false); $frontendRequest = new \Contao\Request(); $frontendRequest->send(Environment::get('url') . '/' . $url); }
public static function addSubscriptions(Order $objOrder, $arrTokens) { $strEmail = $objOrder->getBillingAddress()->email; $objAddress = $objOrder->getShippingAddress() ?: $objOrder->getBillingAddress(); $arrItems = $objOrder->getItems(); $objSession = \Session::getInstance(); if (!($intModule = $objSession->get('isotopeCheckoutModuleIdSubscriptions'))) { return true; } $objSession->remove('isotopeCheckoutModuleIdSubscriptions'); $objModule = \ModuleModel::findByPk($intModule); foreach ($arrItems as $item) { switch ($objModule->iso_direct_checkout_product_mode) { case 'product_type': $objFieldpalette = FieldPaletteModel::findBy('iso_direct_checkout_product_type', Standard::findAvailableByIdOrAlias($item->product_id)->type); break; default: $objFieldpalette = FieldPaletteModel::findBy('iso_direct_checkout_product', $item->product_id); break; } if ($objFieldpalette !== null && $objFieldpalette->iso_addSubscription) { if ($objFieldpalette->iso_subscriptionArchive && (!$objFieldpalette->iso_addSubscriptionCheckbox || \Input::post('subscribeToProduct_' . $item->product_id))) { $objSubscription = Subscription::findOneBy(array('email=?', 'pid=?', 'activation!=?', 'disable=?'), array($strEmail, $objFieldpalette->iso_subscriptionArchive, '', 1)); if (!$objSubscription) { $objSubscription = new Subscription(); } if ($objFieldpalette->iso_addActivation) { $strToken = md5(uniqid(mt_rand(), true)); $objSubscription->disable = true; $objSubscription->activation = $strToken; if (($objNotification = Notification::findByPk($objFieldpalette->iso_activationNotification)) !== null) { if ($objFieldpalette->iso_activationJumpTo && ($objPageRedirect = \PageModel::findByPk($objFieldpalette->iso_activationJumpTo)) !== null) { $arrTokens['link'] = \Environment::get('url') . '/' . \Controller::generateFrontendUrl($objPageRedirect->row()) . '?token=' . $strToken; } $objNotification->send($arrTokens, $GLOBALS['TL_LANGUAGE']); } } $arrAddressFields = \Config::get('iso_addressFields'); if ($arrAddressFields === null) { $arrAddressFields = serialize(array_keys(static::getIsotopeAddressFields())); } foreach (deserialize($arrAddressFields, true) as $strName) { $objSubscription->{$strName} = $objAddress->{$strName}; } $objSubscription->email = $strEmail; $objSubscription->pid = $objFieldpalette->iso_subscriptionArchive; $objSubscription->tstamp = $objSubscription->dateAdded = time(); $objSubscription->quantity = \Input::post('quantity'); $objSubscription->order_id = $objOrder->id; $objSubscription->save(); } } } return true; }
public function show() { global $objPage; $back = \Controller::generateFrontendUrl($objPage->row(), null, null, true); $blnAjax = false; $objModal = new Modal($this->objModal, $this->arrConfig); $objModal->setBackLink($back); $objResponse = new ResponseSuccess(); $objResponse->setResult(new ResponseData($objModal->generate(), array('id' => $this->objModal->id))); $objResponse->setUrl(AjaxAction::removeAjaxParametersFromUrl(Request::getInstance()->getRequestUri())); return $objResponse; }
/** * Display a wildcard in the back end * * @return string */ public function generate() { if (TL_MODE == 'BE') { $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['eventreader_plus'][0]) . ' ###'; $objTemplate->title = $this->headline; $objTemplate->id = $this->id; $objTemplate->link = $this->name; $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id; return $objTemplate->parse(); } global $objPage; // add registration before generating event details, otherwise formhybrid ajax requests wont get triggered if (in_array('event_registration', \ModuleLoader::getActive()) && $this->addRegistration && $this->checkConditions() && $this->objEvent->addRegistration) { if (!$this->objEvent->codes && !\Input::get('step') || \Input::get('step') == EventRegistration::STEP_REGISTRATION) { if ($this->registrationFormModule > 0) { $this->registration = \Controller::getFrontendModule($this->registrationFormModule); } } else { if (\Input::get('step') == EventRegistration::STEP_SUMMARY) { if ($this->summaryModule > 0) { $this->registration = \Controller::getFrontendModule($this->summaryModule); } } else { if ($this->codeCheckModule > 0) { $this->registration = \Controller::getFrontendModule($this->codeCheckModule); } } } } if ($this->cal_template_modal) { $this->strTemplate = $this->customTpl ?: 'mod_event_modal'; $this->cal_template = $this->cal_template_modal; // list config $this->cal_showInModal = true; $this->cal_readerModule = $this->id; // set modal css ID for generateModal() and parent::generate() $arrCss = deserialize($this->cssID, true); $arrCss[0] = EventsPlusHelper::getCSSModalID($this->id); $this->cssID = $arrCss; $this->base = \Controller::generateFrontendUrl($objPage->row()); if ($this->Environment->isAjaxRequest && !$this->isSearchIndexer()) { $this->strTemplate = 'mod_event_modal_ajax'; if (!$this->generateAjax()) { return ''; } } if (!$this->checkConditions()) { return $this->generateModal(); } } return parent::generate(); }
/** * Generate a link to the relation submission form page * * @param \PageModel $objPage * @param \Model $objEntity * @param array $arrRelation * * @return string The url to the relation submission page */ public function getRelationLink(\PageModel $objPage, \Model $objEntity, array $arrRelation) { $objPage = \PageModel::findWithDetails($objPage->id); $strParam = $arrRelation['request_parameter'] ?: $arrRelation['submissionField']; if (\Config::get('useAutoItem') && $arrRelation['useAutoItem']) { $varPath = !\Config::get('disableAlias') ? '/' : '/' . $strParam . '/'; $varValue = !\Config::get('disableAlias') && $objEntity->alias ? $objEntity->alias : $objEntity->id; return \Controller::generateFrontendUrl($objPage->row(), $varPath . $varValue, $objPage->language, true); } $strQuery = $strParam . '=' . (!\Config::get('disableAlias') && $objEntity->alias ? $objEntity->alias : $objEntity->id); return Url::addQueryString($strQuery, \Controller::generateFrontendUrl($objPage->row(), null, $objPage->language, true)); }
protected function compile() { $this->Template->formId = $this->strFormId; $arrFieldDcas = array('email' => array('label' => &$GLOBALS['TL_LANG']['tl_module']['email'], 'inputType' => 'text', 'eval' => array('rgxp' => 'email', 'mandatory' => true)), 'submit' => array('inputType' => 'submit', 'label' => &$GLOBALS['TL_LANG']['MSC']['cancel'])); $arrWidgets = array(); foreach ($arrFieldDcas as $strName => $arrData) { if ($strClass = $GLOBALS['TL_FFL'][$arrData['inputType']]) { $arrWidgets[] = new $strClass(\Widget::getAttributesFromDca($arrData, $strName)); } } if (\Input::post('FORM_SUBMIT') == $this->strFormId) { // validate foreach ($arrWidgets as $objWidget) { $objWidget->validate(); if ($objWidget->hasErrors()) { $this->blnDoNotSubmit = true; } } if (!$this->blnDoNotSubmit) { // cancel subscription $strEmail = \Input::post('email'); $arrArchives = deserialize($this->iso_cancellationArchives, true); $blnNoSuccess = false; foreach ($arrArchives as $intArchive) { if (($objSubscription = Subscription::findBy(array('email=?', 'pid=?'), array($strEmail, $intArchive))) === null) { if (count($arrArchives) == 1) { $this->Template->error = sprintf($GLOBALS['TL_LANG']['MSC']['iso_subscriptionDoesNotExist'], $strEmail, SubscriptionArchive::findByPk($intArchive)->title); $blnNoSuccess = true; } break; } $objSubscription->delete(); } if (!$blnNoSuccess) { // success message if (count($arrArchives) > 1) { $this->Template->success = $GLOBALS['TL_LANG']['MSC']['iso_subscriptionsCancelledSuccessfully']; } else { $this->Template->success = sprintf($GLOBALS['TL_LANG']['MSC']['iso_subscriptionCancelledSuccessfully'], $strEmail, SubscriptionArchive::findByPk($arrArchives[0])->title); } // redirect if ($this->jumpTo && ($objPageRedirect = \PageModel::findByPk($this->jumpTo)) !== null) { \Controller::redirect(\Controller::generateFrontendUrl($objPageRedirect->row())); } } } } // parse (validated) widgets $this->Template->fields = implode('', array_map(function ($objWidget) { return $objWidget->parse(); }, $arrWidgets)); }
/** * Generate the canonical link * * @param $objPage * @return string */ private static function generateLink($objPage) { $strUrl = ''; $strDomain = \Environment::get('base'); $objCanonicalPage = \PageModel::findWithDetails($objPage->canonicalJumpTo); if ($objCanonicalPage !== null) { if ($objCanonicalPage->domain != '') { $strDomain = (\Environment::get('ssl') ? 'https://' : 'http://') . $objCanonicalPage->domain . TL_PATH . '/'; } $strUrl = $strDomain . \Controller::generateFrontendUrl($objCanonicalPage->row(), null, $objCanonicalPage->language); } return $strUrl; }
public function generateEditActions(WatchlistItemModel $objItem, Watchlist $objWatchlist) { $objPage = \PageModel::findByPk($objItem->pageID); if ($objPage === null) { return; } $objT = new \FrontendTemplate('watchlist_edit_actions'); $objT->delHref = ampersand(\Controller::generateFrontendUrl($objPage->row()) . '?act=' . WATCHLIST_ACT_DELETE . '&id=' . \String::binToUuid($objItem->uuid) . '&title=' . urlencode($objItem->title)); $objT->delTitle = $GLOBALS['TL_LANG']['WATCHLIST']['delTitle']; $objT->delLink = $GLOBALS['TL_LANG']['WATCHLIST']['delLink']; $objT->id = \String::binToUuid($objItem->uuid); return $objT->parse(); }
/** * Return the payment form * @param IsotopeProductCollection The order being places * @param Module The checkout module instance * @return string */ public function checkoutForm(IsotopeProductCollection $objOrder, \Module $objModule) { // get current host and $strDescription = \Environment::get('host'); $objContact = \PageModel::findWithDetails($this->wirecard_contact); $arrParams = array('customerId' => $this->wirecard_customer_id, 'language' => $GLOBALS['TL_LANGUAGE'], 'paymentType' => 'SELECT', 'amount' => number_format($objOrder->getTotal(), 2, '.', ''), 'currency' => $objOrder->currency, 'orderDescription' => $strDescription, 'successUrl' => \Environment::get('base') . $objModule->generateUrlForStep('complete', $objOrder), 'cancelUrl' => \Environment::get('base') . $objModule->generateUrlForStep('process'), 'failureUrl' => \Environment::get('base') . $objModule->generateUrlForStep('failed'), 'serviceUrl' => \Environment::get('base') . \Controller::generateFrontendUrl($objContact->row()), 'confirmUrl' => \Environment::get('base') . 'system/modules/isotope/postsale.php?mod=pay&id=' . $this->id, 'customerStatement' => $strDescription, 'order_id' => $objOrder->id, 'order_uniqid' => $objOrder->uniqid, 'secret' => $this->wirecard_secret, 'REQUEST_TOKEN' => REQUEST_TOKEN); $arrParams['requestFingerprintOrder'] = implode(',', array_keys($arrParams)) . ',requestFingerprintOrder'; $arrParams['requestFingerprint'] = $this->calcHashArray($arrParams); $objTemplate = new \Isotope\Template('iso_payment_wirecard'); $objTemplate->setData($this->arrData); $objTemplate->action = 'https://checkout.wirecard.com/page/init.php'; $objTemplate->params = array_filter(array_diff_key($arrParams, array('secret' => ''))); return $objTemplate->parse(); }
/** * Generate module */ protected function compile() { $GLOBALS['TL_JAVASCRIPT']['googleapis-maps'] = 'https://maps.googleapis.com/maps/api/js?sensor=false&language=' . $GLOBALS['TL_LANGUAGE']; $GLOBALS['TL_JAVASCRIPT']['markerclusterer'] = 'system/modules/anyStores/assets/js/markerclusterer.js'; // get published stores from categories $objStores = AnyStoresModel::findPublishedByCategory(deserialize($this->anystores_categories)); // return if no stores found if (!$objStores) { return; } // generate entries while ($objStores->next()) { // generate jump to //@todo copy do AnyStoresModule and extends from it if ($this->jumpTo) { if (($objLocation = \PageModel::findByPk($this->jumpTo)) !== null) { //@todo language parameter $strStoreKey = !$GLOBALS['TL_CONFIG']['useAutoItem'] ? '/store/' : '/'; $strStoreValue = $objStores->alias; $objStores->href = \Controller::generateFrontendUrl($objLocation->row(), $strStoreKey . $strStoreValue); } } // unset logo because json_encode drops error: // Malformed UTF-8 characters, possibly incorrectly encoded //@todo maybe ->loadDetails() fix it $objStores->logo = null; // encode email $objStores->email = \String::encodeEmail($objStores->email); } // get all stores $arrStores = $objStores->fetchAll(); $this->Template->entries = $arrStores; if (!($strJson = json_encode($arrStores))) { $this->log(json_last_error_msg(), __METHOD__, TL_ERROR); //@todo stop display the broken module return; } // Temporär $this->Template->json = $strJson; //@todo cleanup $path = 'system/modules/anyStores/html/' . $this->id . '-locations.json'; $this->Template->path = $path; //JSON schreiben //@todo: Muss noch in tl_storelocator_map zum save_callback verschoben werden!!! #$file = new \File($path); #$file->write($strJson); //@todo language #$this->log('Neue JSON-Datei erstellt', __METHOD__, TL_FILES); }
public static function generateUrl($strGroup, $strAction = null, array $arrAttributes = array(), $blnKeepParams = true, $strUrl = null) { global $objPage; if ($strUrl === null) { $strUrl = $blnKeepParams ? null : \Controller::generateFrontendUrl($objPage->row(), null, null, true); } $strUrl = Url::addQueryString(Ajax::AJAX_ATTR_SCOPE . '=' . Ajax::AJAX_SCOPE_DEFAULT, $strUrl); $strUrl = Url::addQueryString(Ajax::AJAX_ATTR_GROUP . '=' . $strGroup, $strUrl); if ($strAction !== null) { $strUrl = Url::addQueryString(Ajax::AJAX_ATTR_ACT . '=' . $strAction, $strUrl); } foreach ($arrAttributes as $key => $attribute) { $strUrl = Url::addQueryString($key . '=' . $attribute, $strUrl); } return $strUrl; }
/** * @param AddDataForContentEvent $event */ public function addDataForContent(AddDataForContentEvent $event) { if (!$event->getModule() instanceof \ModuleNewsReader && \Input::get('auto_item')) { return; } $alias = \Input::get('auto_item'); $model = \NewsModel::findByIdOrAlias($alias); if (!$model) { return; } global $objPage; //TODO test url by multi domains $event->setUrl(\Controller::generateFrontendUrl($objPage->row(), '/' . $model->alias, \Config::get('addLanguageToUrl'), $objPage->domain)); $event->setTemplate('search_content_news'); $event->setData($model); }
public function generateForumlayout(DataContainer $dc) { // Return if there is no active record (override all) if (!$dc->activeRecord || $dc->activeRecord->type != 'phpbb_forum') { return; } $row = $dc->activeRecord->row(); // If it's a new object with no values we can skip here if (empty($row['phpbb_path']) && empty($row['phpbb_alias'])) { return; } Message::addInfo("Generating Layout"); $row['skipInternalHook'] = true; $url = Controller::generateFrontendUrl($row, null, null, false); $frontendRequest = new \Contao\Request(); $frontendRequest->send(Environment::get('url') . '/' . $url); }
/** * Prepare URL from ID and keep query string from current string * @param mixed * @return string */ protected static function prepareUrl($varUrl) { if ($varUrl === null) { $varUrl = \Environment::get('request'); } elseif (is_numeric($varUrl)) { if (($objJump = \PageModel::findByPk($varUrl)) === null) { throw new \InvalidArgumentException('Given page id does not exist.'); } $varUrl = \Controller::generateFrontendUrl($objJump->row()); list(, $strQueryString) = explode('?', \Environment::get('request'), 2); if ($strQueryString != '') { $varUrl .= '?' . $strQueryString; } } $varUrl = ampersand($varUrl, false); return $varUrl; }
protected function compile() { foreach ($this->trail as $id) { $item = \ShopCategoryModel::findById($id); switch ($item->type) { case "category": $pageId = $this->acquisto_jumpTo; $pageAdd = '/category/' . $item->alias; break; case "redirect": $objRedirect = \ShopCategoryModel::findById($item['categoryJump']); $pageId = $this->acquisto_jumpTo; $pageAdd = '/category/' . $objRedirect->alias; break; case "page": $pageId = $item->jumpTo; $pageAdd = ''; break; default: if (isset($GLOBALS['TL_HOOKS']['modifyOwnCategoryTyp']) && is_array($GLOBALS['TL_HOOKS']['modifyOwnCategoryTyp'])) { foreach ($GLOBALS['TL_HOOKS']['modifyOwnCategoryTyp'] as $callback) { $this->import($callback[0]); $item = $this->{$callback}[0]->{$callback}[1]($item); } } $blnHook = true; break; } if (!$blnHook) { $objPage = $this->Database->prepare("SELECT id, alias FROM tl_page WHERE id=?")->limit(1)->execute($pageId); $item->href = \Controller::generateFrontendUrl($objPage->row(), $pageAdd); } if ($item->cssClass) { $item->css = $item->cssClass; } if ($this->showHidden && $item->hide or !$item->hide) { $items[] = $item; } } $items[0]->css = trim($items[0]->css . ' first'); $items[count($items) - 1]->css = trim($items[count($items) - 1]->css . ' active last'); $items[count($items) - 1]->href = ''; $this->Template->items = $items; }
/** * {@inheritdoc} */ public function handle403($pageId, \PageModel $rootPage) { if ($rootPage->browser_auth_basic_realm && !FE_USER_LOGGED_IN) { $authenticate = <<<EOF WWW-Authenticate: Basic realm="{$rootPage->browser_auth_basic_realm}" EOF; header('HTTP/1.1 401 Unauthorized'); header($authenticate); // Look for an error_403 page $obj403 = \PageModel::find403ByPid($rootPage->id); // Die if there is no page at all if ($obj403 === null) { echo '403 Forbidden'; exit; } // Generate the error page if (!$obj403->autoforward || !$obj403->jumpTo) { global $objPage; $objPage = $obj403->loadDetails(); $objHandler = new $GLOBALS['TL_PTY']['regular'](); $objHandler->generate($objPage); exit; } // Forward to another page $nextPage = \PageModel::findPublishedById($obj403->jumpTo); if ($nextPage === null) { $this->log('Forward page ID "' . $obj403->jumpTo . '" does not exist', 'PageError403 generate()', TL_ERROR); die('Forward page not found'); } $url = \Environment::get('base') . \Controller::generateFrontendUrl($nextPage->row(), null, $rootPage->language); echo <<<EOF <!DOCTYPE html> <html lang="de"> <head> <meta http-equiv="refresh" content="5; URL={$url}"> </head> <body> Redirecting to <a href="{$url}">{$url}</a> </body> </html> EOF; exit; } }
public function processFormData($arrSubmitted, $arrData, $arrFiles, $arrLabels, \Form $objForm) { // check if there is a form field which we use as the code if (($objField = \FormFieldModel::findBy(array("pid = ?", "useCode = '1'"), array($objForm->id))) === null) { return; } // check if there is submitted data for the form field if (!isset($arrSubmitted[$objField->name])) { return; } // get the code $code = $arrSubmitted[$objField->name]; // check if there is a page present for this alias if (($objPage = \PageModel::findPublishedByIdOrAlias($code)) === null) { return; } // redirect to page \Controller::redirect(\Controller::generateFrontendUrl($objPage->row(), null, null, true)); }
protected function compile() { if ($this->check_news && FE_USER_LOGGED_IN) { $this->Import('FrontendUser', 'Member'); $objMember = \MemberModel::findById($this->Member->id); $arrArchives = deserialize($this->news_archives); if (is_array($arrArchives)) { $objNews = $this->Database->prepare("SELECT * FROM tl_news WHERE pid IN(" . implode(",", $arrArchives) . ") && tstamp > ? && published='1'")->execute($objMember->lastLogin); if (!$objNews->count()) { $objPage = \PageModel::findById($this->jumpTo); \Controller::redirect(\Controller::generateFrontendUrl($objPage->row(), '')); } } } if (!FE_USER_LOGGED_IN && $this->redirecter_guests or FE_USER_LOGGED_IN && $this->redirecter_protected) { $objPage = \PageModel::findById($this->jumpTo); $this->redirect($this->generateFrontendUrl($objPage->row(), '')); } }
public function processMemberParticipation($objUser) { if (TL_MODE != 'FE') { return false; } $objParticipation = ParticipationController::getActiveParticipation(); if ($objParticipation === null) { return false; } if (($objConfig = ParticipationController::findParticipationDataConfigClass($objParticipation)) !== null) { global $objPage; $objJumpTo = $objConfig->getJumpToPage(); // redirect first, otherwise participation process will run twice if ($objJumpTo !== null && $objPage->id != $objJumpTo->id) { \Controller::redirect(\Controller::generateFrontendUrl($objJumpTo->row())); } $objConfig->runAfterAuthentication($objUser); return true; } }
/** * @param Database_Result $objPage * @param Database_Result $objLayout * @param PageRegular $objPageRegular */ public function login($objPage, $objLayout, $objPageRegular) { $time = time(); $objMember = \Database::getInstance()->prepare("SELECT * FROM tl_member WHERE loginLink = ? AND (loginLinkExpire > ? OR loginLinkExpire = '')")->execute($this->authKey, $time); $objMemberModel = \MemberModel::findById($objMember->id); if ($objMember->numRows != 1 || $objMember->loginLink != $this->authKey) { return; } if (!FE_USER_LOGGED_IN) { // Generate the cookie hash $this->strHash = sha1(session_id() . (!\Config::get('disableIpCheck') ? \Environment::get('ip') : '') . 'FE_USER_AUTH'); // Clean up old sessions \Database::getInstance()->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute($time - \Config::get('sessionTimeout'), $this->strHash); // Save the session in the database \Database::getInstance()->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute($objMember->id, $time, 'FE_USER_AUTH', session_id(), \Environment::get('ip'), $this->strHash); // Set the authentication cookie \System::setCookie('FE_USER_AUTH', $this->strHash, $time + \Config::get('sessionTimeout'), null, null, false, true); // Set the login status (backwards compatibility) $_SESSION['TL_USER_LOGGED_IN'] = true; // Save the login status $_SESSION['TL_USER_LOGGED_IN'] = true; \System::log('User "' . $objMember->username . '" logged in by authKey', 'LoginLink()', TL_ACCESS); \Controller::reload(); } if ($objMember->jumpTo) { $objPage = \PageModel::findByPk($objMember->jumpTo); } $strUrl = \Controller::generateFrontendUrl($objPage->row()); $strParam = ''; foreach ($_GET as $index => $value) { if ($index == 'key') { continue; } if (!$strParam) { $strParam .= '?' . $index . '=' . \Input::get($index); } else { $strParam .= '&' . $index . '=' . \Input::get($index); } } \Controller::redirect($strUrl . $strParam); }