/** * If the Garden.PrivateCommunity config setting is enabled, * then bypass the sign-in redirection and let the Basic Pages * view permission logic handle the redirection for * pages requested by guests. * * @param $Sender Gdn_Dispatcher */ public function Gdn_Dispatcher_BeforeBlockDetect_Handler($Sender) { if (C('Garden.PrivateCommunity', false)) { $BlockExceptions =& $Sender->EventArguments['BlockExceptions']; $PathRequest = Gdn::Request()->Path(); $PageModel = new PageModel(); // Handle path requests that match "page/urlcode" $PathMatch = 'page/'; if (substr($PathRequest, 0, strlen($PathMatch)) === $PathMatch) { $Page = $PageModel->GetByUrlCode(substr($PathRequest, strlen($PathMatch), strlen($PathRequest))); // Only bypass Garden.PrivateCommunity redirection if custom page view permission is enabled. if (isset($Page->ViewPermission) && (bool) $Page->ViewPermission) { $BlockExceptions['/^page(\\/.*)?$/'] = Gdn_Dispatcher::BLOCK_NEVER; } } else { if (!strstr($PathRequest, '/')) { // NOTE: Increases overhead every time the Dispatch method is called. // There is room for optimization to be done here. // // Handle path requests which don't contain a forward slash // because the request could possibly be for a page with // a path of "urlcode" $Page = $PageModel->GetByUrlCode($PathRequest); // Only bypass Garden.PrivateCommunity redirection if custom page view permission is enabled. if (isset($Page->ViewPermission) && (bool) $Page->ViewPermission) { $BlockExceptions['/^' . $PathRequest . '(\\/.*)?$/'] = Gdn_Dispatcher::BLOCK_NEVER; } } } } }
/** * Redirect to an internal page * @param \PageModel $objPage */ public function generate($objPage) { // Forward to the jumpTo or first published page if ($objPage->jumpTo) { /** @var \PageModel $objNextPage */ $objNextPage = $objPage->getRelated('jumpTo'); } else { $objNextPage = \PageModel::findFirstPublishedRegularByPid($objPage->id); } // Forward page does not exist if ($objNextPage === null) { header('HTTP/1.1 404 Not Found'); $this->log('Forward page ID "' . $objPage->jumpTo . '" does not exist', __METHOD__, TL_ERROR); die_nicely('be_no_forward', 'Forward page not found'); } $strForceLang = null; // Check the target page language (see #4706) if (\Config::get('addLanguageToUrl')) { $objNextPage->loadDetails(); // see #3983 $strForceLang = $objNextPage->language; } $strGet = ''; $strQuery = \Environment::get('queryString'); $arrQuery = array(); // Extract the query string keys (see #5867) if ($strQuery != '') { $arrChunks = explode('&', $strQuery); foreach ($arrChunks as $strChunk) { list($k, ) = explode('=', $strChunk, 2); $arrQuery[] = $k; } } // Add $_GET parameters if (!empty($_GET)) { foreach (array_keys($_GET) as $key) { if (\Config::get('disableAlias') && $key == 'id') { continue; } if (\Config::get('addLanguageToUrl') && $key == 'language') { continue; } // Ignore the query string parameters (see #5867) if (in_array($key, $arrQuery)) { continue; } // Ignore the auto_item parameter (see #5886) if ($key == 'auto_item') { $strGet .= '/' . \Input::get($key); } else { $strGet .= '/' . $key . '/' . \Input::get($key); } } } // Append the query string (see #5867) if ($strQuery != '') { $strQuery = '?' . $strQuery; } $this->redirect($this->generateFrontendUrl($objNextPage->row(), $strGet, $strForceLang) . $strQuery, $objPage->redirect == 'temporary' ? 302 : 301); }
public function indexAction() { $fc = FrontController::getInstance(); $model = new PageModel(); header('HTTP/1.0 Not Found'); $fc->setBody($model->render('404.php', TEMPLATE)); }
/** * действие для странички о нас - About * * @param Request $request * @return int */ public function aboutAction(Request $request) { $model = new PageModel(); $text = $model->getById(2); $args = array('text' => $text); return $this->render('about', $args); }
public function Page($Reference) { $PageModel = new PageModel(); $Page = $PageModel->GetFullID($Reference); if (!$Page) { throw NotFoundException(); } $this->Page = $Page; if ($this->Head) { SetMetaTags($Page, $this); if ($Page->CustomCss) { $CustomCss = "\n" . $Page->CustomCss; if (!StringBeginsWith(trim($CustomCss), '<style', True)) { $CustomCss = Wrap($CustomCss, 'style', array('type' => 'text/css')); } $this->Head->AddString($CustomCss); } if ($Page->CustomJs) { $CustomJs = $Page->CustomJs; if (!StringBeginsWith(trim($CustomJs), '<script', True)) { $CustomJs = Wrap($CustomJs, 'script', array('type' => 'text/javascript')); } $this->Head->AddString($CustomJs); } } if ($Page->SectionID) { $this->Section = BuildNode($Page, 'Section'); $this->SectionID = $Page->SectionID; CandyHooks::AddModules($this, $this->Section); } $this->FireEvent('ContentPage'); if ($Page->View) { $this->View = $this->FetchViewLocation($this->View, False, False, False); } if (!$this->View) { $this->View = $this->FetchViewLocation('view', 'page', '', False); if (!$this->View) { $this->View = 'default'; } } $this->Title($Page->Title); $this->SetData('Content', $Page, True); $this->EventArguments['Format'] =& $Page->Format; $this->EventArguments['Body'] =& $Page->Body; $this->FireEvent('BeforeBodyFormat'); $this->ContentBodyHtml = Gdn_Format::To($Page->Body, $Page->Format); $Doc = PqDocument($this->ContentBodyHtml); $Header = $Doc->Find('h1'); $CountH1 = count($Header); if ($CountH1 == 0) { $this->SetData('Headline', Gdn_Format::Text($Page->Title)); } elseif ($CountH1 == 1) { $this->SetData('Headline', $Header->Text()); $Header->Remove(); $this->ContentBodyHtml = $Doc->Html(); } // $this->AddModule('PageInfoModule'); $this->Render(); }
public function pageAction(Request $request) { $pageModel = new PageModel(); $pageText = $pageModel->getById($request->get('id')); $log = $this->render('log'); $args = array('text' => array($pageText), 'id' => $request->get('id'), 'log' => $log); return $this->render('page', $args); }
public function updatePage(PageModel $page, $oldurl) { $this->connect(); $oldurl = '"' . $this->db->real_escape_string($oldurl) . '"'; $url = '"' . $this->db->real_escape_string($page->getPageURL()) . '"'; $title = '"' . $this->db->real_escape_string($page->getPageTitle()) . '"'; $content = '"' . $this->db->real_escape_string($page->getPageContent()) . '"'; //MySqli Insert Query $update_row = $this->db->query("UPDATE " . self::$table . " SET url={$url} ,title={$title}, content={$content} WHERE url={$oldurl}"); if ($update_row) { return $update_row; } else { return $this->db->error; } }
/** * Generate the content element */ protected function compile() { $link = '/articles/'; $objArticle = $this->objArticle; if ($objArticle->inColumn != 'main') { $link .= $objArticle->inColumn . ':'; } $link .= $objArticle->alias ?: $objArticle->id; $this->Template->href = $this->objParent->getFrontendUrl($link); // Clean the RTE output $this->Template->text = \StringUtil::toHtml5($objArticle->teaser); $this->Template->headline = $objArticle->title; $this->Template->readMore = \StringUtil::specialchars(sprintf($GLOBALS['TL_LANG']['MSC']['readMore'], $objArticle->title)); $this->Template->more = $GLOBALS['TL_LANG']['MSC']['more']; }
/** * Generate an error 403 page * @param integer * @param object */ public function generate($pageId, $objRootPage = null) { // Add a log entry $this->log('Access to page ID "' . $pageId . '" denied', 'PageError403 generate()', TL_ERROR); // Use the given root page object if available (thanks to Andreas Schempp) if ($objRootPage === null) { $objRootPage = $this->getRootPageFromUrl(); } else { $objRootPage = \PageModel::findPublishedById(is_integer($objRootPage) ? $objRootPage : $objRootPage->id); } // Look for an error_403 page $obj403 = \PageModel::find403ByPid($objRootPage->id); // Die if there is no page at all if ($obj403 === null) { header('HTTP/1.1 403 Forbidden'); die('Forbidden'); } // Generate the error page if (!$obj403->autoforward || !$obj403->jumpTo) { global $objPage; $objPage = $this->getPageDetails($obj403); $objHandler = new $GLOBALS['TL_PTY']['regular'](); header('HTTP/1.1 403 Forbidden'); $objHandler->generate($objPage); exit; } // Forward to another page $objNextPage = \PageModel::findPublishedById($obj403->jumpTo); if ($objNextPage === null) { header('HTTP/1.1 403 Forbidden'); $this->log('Forward page ID "' . $obj403->jumpTo . '" does not exist', 'PageError403 generate()', TL_ERROR); die('Forward page not found'); } $this->redirect($this->generateFrontendUrl($objNextPage->row(), null, $objRootPage->language), $obj403->redirect == 'temporary' ? 302 : 301); }
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']); } } } }
/** * Generate the module */ protected function compile() { /** @var \PageModel $objPage */ global $objPage; // Set the trail and level if ($this->defineRoot && $this->rootPage > 0) { $trail = array($this->rootPage); $level = 0; } else { $trail = $objPage->trail; $level = $this->levelOffset > 0 ? $this->levelOffset : 0; } $lang = null; $host = null; // Overwrite the domain and language if the reference page belongs to a differnt root page (see #3765) if ($this->defineRoot && $this->rootPage > 0) { $objRootPage = \PageModel::findWithDetails($this->rootPage); // Set the language if (\Config::get('addLanguageToUrl') && $objRootPage->rootLanguage != $objPage->rootLanguage) { $lang = $objRootPage->rootLanguage; } // Set the domain if ($objRootPage->rootId != $objPage->rootId && $objRootPage->domain != '' && $objRootPage->domain != $objPage->domain) { $host = $objRootPage->domain; } } $this->Template->request = ampersand(\Environment::get('indexFreeRequest')); $this->Template->skipId = 'skipNavigation' . $this->id; $this->Template->skipNavigation = specialchars($GLOBALS['TL_LANG']['MSC']['skipNavigation']); $this->Template->items = $this->renderNavigation($trail[$level], 1, $host, $lang); }
/** * @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; }
/** * Generate the module */ protected function compile() { $intList = $this->athletes_group; $objMembers = $this->Database->prepare("SELECT * FROM tl_athlete WHERE published=1 AND pid=? ORDER BY sorting")->execute($intList); //$objMembers = \MembersModel; // Return if no Members were found if (!$objMembers->numRows) { return; } $strLink = ''; // Generate a jumpTo link if ($this->jumpTo > 0) { $objJump = \PageModel::findByPk($this->jumpTo); if ($objJump !== null) { $strLink = $this->generateFrontendUrl($objJump->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s'); } } $arrMembers = array(); // Generate Members while ($objMembers->next()) { $strPhoto = ''; $objPhoto = \FilesModel::findByPk($objMembers->photo); // Add photo image if ($objPhoto !== null) { $strPhoto = \Image::getHtml(\Image::get($objPhoto->path, '140', '187', 'center_center')); } $arrMembers[] = array('name' => $objMembers->name, 'family' => $objMembers->family, 'post' => $objMembers->post, 'joined' => $objMembers->joined, 'photo' => $strPhoto, 'link' => strlen($strLink) ? sprintf($strLink, $objMembers->alias) : ''); } $this->Template->members = $arrMembers; }
/** * Generate the module */ protected function compile() { global $objPage; $arrJumpTo = array(); $arrNewsletter = array(); $objNewsletter = \NewsletterModel::findSentByPids($this->nl_channels); if ($objNewsletter !== null) { while ($objNewsletter->next()) { if (($objTarget = $objNewsletter->getRelated('pid')) === null || !$objTarget->jumpTo) { continue; } if (!isset($arrJumpTo[$objTarget->jumpTo])) { $objJumpTo = \PageModel::findPublishedById($objTarget->jumpTo); if ($objJumpTo !== null) { $arrJumpTo[$objTarget->jumpTo] = $this->generateFrontendUrl($objJumpTo->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s'); } else { $arrJumpTo[$objTarget->jumpTo] = null; } } $strUrl = $arrJumpTo[$objTarget->jumpTo]; if ($strUrl === null) { continue; } $strAlias = $objNewsletter->alias != '' && !$GLOBALS['TL_CONFIG']['disableAlias'] ? $objNewsletter->alias : $objNewsletter->id; $arrNewsletter[] = array('subject' => $objNewsletter->subject, 'title' => strip_insert_tags($objNewsletter->subject), 'href' => sprintf($strUrl, $strAlias), 'date' => $this->parseDate($objPage->dateFormat, $objNewsletter->date), 'datim' => $this->parseDate($objPage->datimFormat, $objNewsletter->date), 'time' => $this->parseDate($objPage->timeFormat, $objNewsletter->date), 'channel' => $objNewsletter->channel); } } $this->Template->newsletters = $arrNewsletter; }
/** * Get config value from transformed arrData and add logic to modify the value here * @param $strKey * * @return mixed|string */ public function __get($strKey) { $varValue = $this->arrData[$strKey]; switch ($strKey) { case 'strAction': if ($varValue && ($objActionPage = \PageModel::findWithDetails($varValue)) !== null) { $varValue = \Controller::generateFrontendUrl($objActionPage->row(), null, null, true); } else { $varValue = Url::removeQueryString(array('file'), \Environment::get('uri')); // remove all query parameters within ajax request if (Ajax::isRelated(Form::FORMHYBRID_NAME) !== false) { $varValue = AjaxAction::removeAjaxParametersFromUrl($varValue); } } // async form if ($this->async) { $varValue = AjaxAction::generateUrl(Form::FORMHYBRID_NAME, 'asyncFormSubmit'); } // add hash if ($this->addHashToAction) { $varValue .= '#' . ($this->customHash ?: $this->strFormId); } break; case 'arrDefaultValues': $varValue = FormHelper::getAssocMultiColumnWizardList($varValue, 'field'); break; } return $varValue; }
/** * Collect the images from page * @param object * @param object */ public function collectPageImages($objPage, $objLayout) { if (!$objLayout->socialImages) { return; } // Initialize the array if (!is_array($GLOBALS['SOCIAL_IMAGES'])) { $GLOBALS['SOCIAL_IMAGES'] = array(); } // Add the current page image if ($objPage->socialImage && ($objImage = \FilesModel::findByUuid($objPage->socialImage)) !== null && is_file(TL_ROOT . '/' . $objImage->path)) { array_unshift($GLOBALS['SOCIAL_IMAGES'], $objImage->path); } else { $objTrail = \PageModel::findParentsById($objPage->id); if ($objTrail !== null) { while ($objTrail->next()) { // Add the image if ($objTrail->socialImage && ($objImage = \FilesModel::findByUuid($objTrail->socialImage)) !== null && is_file(TL_ROOT . '/' . $objImage->path)) { array_unshift($GLOBALS['SOCIAL_IMAGES'], $objImage->path); break; } } } } }
public function checkLog($ptable, $tstamp, $item) { switch ($ptable) { case 'tl_article': $objArticle = \ArticleModel::findById($item['pid']); $objPage = \PageModel::findById($objArticle->pid); $item['page'] = $objPage->title; $item['showUrl'] = $this->generateFrontendUrl($objPage->row(), ''); break; case 'tl_news': $objNews = \NewsModel::findById($item['pid']); $objArchive = \NewsArchiveModel::findById($objNews->pid); $objPage = \PageModel::findById($objArchive->jumpTo); $item['page'] = $objNews->headline; $item['showUrl'] = ampersand($this->generateFrontendUrl($objPage->row(), (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/items/') . (!\Config::get('disableAlias') && $objNews->alias != '' ? $objNews->alias : $objNews->id))); break; case 'tl_calendar': break; case 'tl_faq': $objFAQ = \FaqModel::findById($item['id']); $objCategory = \FaqCategoryModel::findById($item['pid']); $objPage = \PageModel::findById($objCategory->jumpTo); $item['htmlElement'] = '<div class="ce_faq"><h1>' . $objFAQ->question . '</h1>' . $objFAQ->answer . '</div>'; $item['page'] = $objCategory->title; $item['title'] = $objFAQ->question; $item['showUrl'] = ampersand($this->generateFrontendUrl($objPage->row(), (\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/' : '/items/') . (!\Config::get('disableAlias') && $objFAQ->alias != '' ? $objFAQ->alias : $objFAQ->id))); break; } return $item; }
protected function compile() { if ($this->defineRoot) { $objPage = \PageModel::findByPk($this->rootPage); } else { global $objPage; } if (null === $objPage) { return; } $intOffset = (int) $this->levelOffset; // Random image if ($this->randomPageImage) { $intOffset = -1; } $arrImage = PageImage::getOne($objPage, $intOffset, (bool) $this->inheritPageImage); if (null === $arrImage) { return; } $arrSize = deserialize($this->imgSize); $arrImage['src'] = $this->getImage($arrImage['path'], $arrSize[0], $arrSize[1], $arrSize[2]); $this->Template->setData($arrImage); if (($imgSize = @getimagesize(TL_ROOT . '/' . rawurldecode($arrImage['src']))) !== false) { $this->Template->size = ' ' . $imgSize[3]; } }
/** * get all pages and cached by static::$pages */ protected static function getPages() { $result = \PageModel::findAll(); if ($result) { while ($result->next()) { $buffer = $result->current(); $trail = \PageModel::findBy('pid', $buffer->id); if ($trail) { $bufferTrail = array(); while ($trail->next()) { $bufferTrail[$trail->sorting] = $trail->current(); } $sort = array_keys($bufferTrail); array_multisort($sort); $arr = array(); foreach ($sort as $v) { $arr[$v] = $bufferTrail[$v]; } $buffer->__set('trail', $arr); } static::$pages[$result->pid][$result->sorting] = $buffer; } static::sortPages(); } }
/** * Parse the template * @return string */ public function generate() { if (TL_MODE == 'BE') { // create new backend template $objTemplate = new \BackendTemplate('be_include'); // get the article $objArticle = \ArticleModel::findByPk($this->articleAlias); if ($objArticle === null) { return parent::generate(); } // get the parent pages $objPages = \PageModel::findParentsById($objArticle->pid); if ($objPages === null) { return parent::generate(); } // get the page titles $arrPageTitles = array_reverse($objPages->fetchEach('title')); // set breadcrumb to original element $objTemplate->original = array('crumbs' => implode(' » ', $arrPageTitles), 'article' => array('title' => $objArticle->title, 'link' => 'contao/main.php?do=article&table=tl_content&id=' . $objArticle->id . '&rt=' . REQUEST_TOKEN)); // get include breadcrumbs $includes = \IncludeInfoHelper::getIncludes('articleAlias', $this->articleAlias, $this->id); // set include breadcrumbs if (count($includes) > 1) { $objTemplate->includes = $includes; } // add CSS $GLOBALS['TL_CSS'][] = \IncludeInfoHelper::BACKEND_CSS; // return info + content return $objTemplate->parse() . parent::generate(); } // return content only return parent::generate(); }
function __construct($args) { $args = array_merge(array('depth' => 'response'), $args); $this->depth = $args['depth']; // argument assertions if (!isset($args['pageID'])) { throw new InvalidArgumentException('Missing pageID as argument to PageModel constructor'); } if (!isset(self::$pageTable)) { self::$pageTable = QFrame_Db_Table::getTable('page'); } if (!isset(self::$sectionTable)) { self::$sectionTable = QFrame_Db_Table::getTable('section'); } if (!isset(self::$questionTable)) { self::$questionTable = QFrame_Db_Table::getTable('question'); } if (!isset(self::$ruleTable)) { self::$ruleTable = QFrame_Db_Table::getTable('rule'); } if (!isset(self::$questionTypeTable)) { self::$questionTypeTable = QFrame_Db_Table::getTable('question_type'); } if (!isset(self::$pageReferenceTable)) { self::$pageReferenceTable = QFrame_Db_Table::getTable('page_reference'); } if (!isset(self::$referenceDetailTable)) { self::$referenceDetailTable = QFrame_Db_Table::getTable('reference_detail'); } $rows = self::$pageTable->fetchRows('pageID', $args['pageID']); $this->pageRow = $rows[0]; // page row assertion if ($this->pageRow === NULL) { throw new Exception('Page not found [' . $args['pageID'] . ']'); } $ruleRows = self::$ruleTable->fetchRows('targetID', $this->pageRow->pageID, null, $this->pageRow->instanceID); $disableCount = 0; foreach ($ruleRows as $row) { if ($row->enabled === 'Y' && $row->type === 'disablePage') { $disableCount++; } elseif ($row->enabled === 'Y' && $row->type === 'enablePage') { $disableCount--; } } if ($this->pageRow->defaultPageHidden) { $disableCount++; } if ($disableCount != $this->pageRow->disableCount) { $this->pageRow->disableCount = $disableCount; $this->pageRow->save(); } if ($this->depth !== 'page') { $this->_loadSections(); } $pageReferenceRows = self::$pageReferenceTable->fetchRows('pageID', $this->pageRow->pageID, null, $this->pageRow->instanceID); foreach ($pageReferenceRows as $row) { $rows = self::$referenceDetailTable->fetchRows('referenceDetailID', $row->referenceDetailID, null, $this->pageRow->instanceID); $this->referenceDetailRows[] = $rows[0]->toArray(); } }
/** * Generate the module */ protected function compile() { $this->Template->text_title = $GLOBALS['TL_LANG']['MSC']['price_title']; $this->Template->text_model = $GLOBALS['TL_LANG']['MSC']['price_model']; $this->Template->text_SKU = $GLOBALS['TL_LANG']['MSC']['price_SKU']; $this->Template->text_description = $GLOBALS['TL_LANG']['MSC']['price_description']; $this->Template->text_amount = $GLOBALS['TL_LANG']['MSC']['price_amount']; $this->Template->text_unit = $GLOBALS['TL_LANG']['MSC']['price_unit']; $this->Template->text_price = $GLOBALS['TL_LANG']['MSC']['price_price']; $this->strTemplate = $this->pricelist_template; $intList = $this->pricelist; $objPricelist = $this->Database->prepare("SELECT * FROM tl_pricelist WHERE id=?")->execute($intList); $objItems = $this->Database->prepare("SELECT * FROM tl_pricelist_item WHERE published=1 AND pid=? ORDER BY sorting")->execute($intList); // Return if no Products were found if (!$objItems->numRows) { $this->Template->empty = $GLOBALS['TL_LANG']['MSC']['emptyPriceList']; return; } $this->Template->description = $objPricelist->description; $objJump = \PageModel::findByPk($objPricelist->jumpTo); $strLink = $this->generateFrontendUrl($objJump->row()); $arrItems = array(); $i = 0; // Generate Products while ($objItems->next()) { $i = $i + 1; $arrItems[] = array('no' => $i, 'title' => $objItems->title, 'sku' => $objItems->sku, 'model' => $objItems->model, 'price' => $objItems->price ? $objItems->price . ' ' . $objPricelist->currency : '<a href=' . $strLink . '>تماس بگیرید</a>', 'date' => $objItems->tstamp, 'unit' => $objItems->unit, 'amount' => $objItems->amount, 'sale' => $objItems->sale, 'stock' => $objItems->stock, 'url' => $objItems->url, 'description' => $objItems->description); } $this->Template->items = $arrItems; }
/** * Generate the module */ protected function compile() { /** @var \PageModel $objPage */ global $objPage; $lang = null; $host = null; // Start from the website root if there is no reference page if (!$this->rootPage) { $this->rootPage = $objPage->rootId; } else { $objRootPage = \PageModel::findWithDetails($this->rootPage); // Set the language if (\Config::get('addLanguageToUrl') && $objRootPage->rootLanguage != $objPage->rootLanguage) { $lang = $objRootPage->rootLanguage; } // Set the domain if ($objRootPage->rootId != $objPage->rootId && $objRootPage->domain != '' && $objRootPage->domain != $objPage->domain) { $host = $objRootPage->domain; } } $this->showLevel = 0; $this->hardLimit = false; $this->levelOffset = 0; $this->Template->items = $this->renderNavigation($this->rootPage, 1, $host, $lang); }
public function checkForShortURL() { // only do something in the frontend if (TL_MODE != 'FE') { return; } // check if we have one or more Short URLs if (($objShortURL = \ShortURLsModel::findActiveByName(\Environment::get('request'))) !== null) { // go through each short URL while ($objShortURL->next()) { // check if there is a target set if (!$objShortURL->target) { continue; } // check for domain restriction if ($objShortURL->domain) { if (($objDomain = \PageModel::findById($objShortURL->domain)) !== null) { if (strcasecmp($objDomain->dns, \Environment::get('host')) !== 0) { continue; } } } // build redirect URL $url = self::processTarget($objShortURL->target); // prevent infinite redirects if ($url == \Environment::get('base') . \Environment::get('request')) { continue; } // execute redirect \Controller::redirect($url, $objShortURL->redirect == 'permanent' ? 301 : 302); } } }
public function getActiveLayoutSections(\DataContainer $dc) { $callback = $GLOBALS['TL_DCA']['tl_article']['fields']['inColumn']['bit3_merger_original_options_callback']; if (is_array($callback)) { $object = \System::importStatic($callback[0]); $methodName = $callback[1]; $sections = $object->{$methodName}($dc); } else { $sections = call_user_func($callback, $dc); } if ($dc->activeRecord->pid) { $page = \PageModel::findWithDetails($dc->activeRecord->pid); // Get the layout sections foreach (array('layout', 'mobileLayout') as $key) { if (!$page->{$key}) { continue; } $layout = \LayoutModel::findByPk($page->{$key}); if ($layout === null) { continue; } $modules = deserialize($layout->modules); if (empty($modules) || !is_array($modules)) { continue; } // Find all sections with an article module (see #6094) foreach ($modules as $module) { if ($module['mod'] != 0 && $module['enable']) { $this->joinModule($module['col'], $module['mod'], $sections); } } } } return array_values(array_unique($sections)); }
public static function last() { $row = parent::last(PageModel::get_table_name()); $pm = new PageModel($row["page_text"], $row["adventure_id"], $row["image_url"], $row["date_created"]); $pm->id = $row["id"]; return $pm; }
/** * load modal content */ public function loadModalContent() { global $objPage; $id = \Input::get('modal'); if ($id == '') { return; } $page = \Input::get('page'); // load layout because we need to initiate bootstrap /** @var \PageModel $objPage */ $objPage = \PageModel::findByPk($page); $objPage->loadDetails(); if ($objPage === null) { $this->log(sprintf('Page ID %s not found', $page), 'Netzmacht\\Bootstrap\\Ajax::loadModalContent', TL_ERROR); exit; } $objLayout = $this->getPageLayout($objPage); // Set the layout template and template group $objPage->template = $objLayout->template ?: 'fe_page'; $objPage->templateGroup = $objLayout->getRelated('pid')->templates; // trigger getPageLayout hook so if (isset($GLOBALS['TL_HOOKS']['getPageLayout']) && is_array($GLOBALS['TL_HOOKS']['getPageLayout'])) { foreach ($GLOBALS['TL_HOOKS']['getPageLayout'] as $hook) { $this->import($hook[0]); $this->{$hook[0]}->{$hook[1]}($objPage, $objLayout, $this); } } $model = \ModuleModel::findOneBy('type="bootstrap_modal" AND tl_module.id', $id); if ($model === null) { exit; } $model->isAjax = true; $this->output($this->getFrontendModule($model)); }
public function testError() { PageModel::Error(); $this->expectOutputString("Error"); PageModel::Error("1213"); $this->expectOutputString("ErrorError<br><br>1213"); }
/** * Redirect to an internal page * @param object */ public function generate($objPage) { // Forward to the jumpTo or first published page if ($objPage->jumpTo) { $objNextPage = \PageModel::findPublishedById($objPage->jumpTo); } else { $objNextPage = \PageModel::findFirstPublishedRegularByPid($objPage->id); } // Forward page does not exist if ($objNextPage === null) { header('HTTP/1.1 404 Not Found'); $this->log('Forward page ID "' . $objPage->jumpTo . '" does not exist', 'PageForward generate()', TL_ERROR); die('Forward page not found'); } $strGet = ''; // Add $_GET parameters if (is_array($_GET) && !empty($_GET)) { foreach (array_keys($_GET) as $key) { if ($GLOBALS['TL_CONFIG']['disableAlias'] && $key == 'id') { continue; } if ($GLOBALS['TL_CONFIG']['addLanguageToUrl'] && $key == 'language') { continue; } $strGet .= '/' . $key . '/' . \Input::get($key); } } $this->redirect($this->generateFrontendUrl($objNextPage->row(), $strGet), $objPage->redirect == 'temporary' ? 302 : 301); }
function __construct($id_menu = NULL, $lang = NULL) { $this->session = NEnvironment::getSession('Menu'); $this->pageModel = PageModel::init(); if ($id_menu == NULL) { if (isset($_GET["id_menu"])) { $this->session['id_menu'] = $_GET["id_menu"]; } if (!isset($this->session['id_menu'])) { $this->session['id_menu'] = NEnvironment::getVariable('ADMIN_DEFAULT_IDMENU'); } $this->id_menu = $this->session['id_menu']; } else { $this->id_menu = $id_menu; } if (@$lang == NULL) { if (!isset(NEnvironment::getSession('Page')->lang)) { $this->lang = NEnvironment::getVariable('ADMIN_DEFAULT_LANG'); } $this->lang = NEnvironment::getSession('Page')->lang; } else { $this->lang = $lang; } $this->var = NEnvironment::getConfig('ADMINMENU'); }