/** * Send a lost password e-mail * @param object */ protected function sendPasswordLink($objMember) { $objNotification = \NotificationCenter\Model\Notification::findByPk($this->nc_notification); if ($objNotification === null) { $this->log('The notification was not found ID ' . $this->nc_notification, __METHOD__, TL_ERROR); return; } $confirmationId = md5(uniqid(mt_rand(), true)); // Store the confirmation ID $objMember = \MemberModel::findByPk($objMember->id); $objMember->activation = $confirmationId; $objMember->save(); $arrTokens = array(); // Add member tokens foreach ($objMember->row() as $k => $v) { $arrTokens['member_' . $k] = $v; } $arrTokens['recipient_email'] = $objMember->email; $arrTokens['domain'] = \Idna::decode(\Environment::get('host')); $arrTokens['link'] = \Idna::decode(\Environment::get('base')) . \Environment::get('request') . ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos(\Environment::get('request'), '?') !== false ? '&' : '?') . 'token=' . $confirmationId; $objNotification->send($arrTokens); $this->log('A new password has been requested for user ID ' . $objMember->id . ' (' . $objMember->email . ')', __METHOD__, TL_ACCESS); // Check whether there is a jumpTo page if (($objJumpTo = $this->objModel->getRelated('jumpTo')) !== null) { $this->jumpToOrReload($objJumpTo->row()); } $this->reload(); }
/** * Generate the module * * @return string */ public function run() { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_live_update'); $objTemplate->updateClass = 'tl_confirm'; $objTemplate->updateHeadline = $GLOBALS['TL_LANG']['tl_maintenance']['liveUpdate']; $objTemplate->isActive = $this->isActive(); $strMessage = ' <a href="contao/changelog.php" onclick="Backend.openModalIframe({\'width\':860,\'title\':\'CHANGELOG\',\'url\':this.href});return false" title="' . specialchars($GLOBALS['TL_LANG']['tl_maintenance']['changelog']) . '"><img src="' . TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/changelog.gif" width="14" height="14" alt="" style="vertical-align:text-bottom;padding-left:3px"></a>'; // Newer version available if (\Config::get('latestVersion') && version_compare(VERSION . '.' . BUILD, \Config::get('latestVersion'), '<')) { $objTemplate->updateClass = 'tl_info'; $objTemplate->updateMessage = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['newVersion'], \Config::get('latestVersion')) . $strMessage; } else { $objTemplate->updateClass = 'tl_confirm'; $objTemplate->updateMessage = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['upToDate'], VERSION . '.' . BUILD) . $strMessage; } // Automatically switch to SSL if (\Environment::get('ssl')) { \Config::set('liveUpdateBase', str_replace('http://', 'https://', \Config::get('liveUpdateBase'))); } $objTemplate->uid = \Config::get('liveUpdateId'); $objTemplate->updateServer = \Config::get('liveUpdateBase') . 'index.php'; // Run the update if (\Input::get('token') != '') { $this->runLiveUpdate($objTemplate); } $objTemplate->version = VERSION . '.' . BUILD; $objTemplate->liveUpdateId = $GLOBALS['TL_LANG']['tl_maintenance']['liveUpdateId']; $objTemplate->runLiveUpdate = specialchars($GLOBALS['TL_LANG']['tl_maintenance']['runLiveUpdate']); $objTemplate->referer = base64_encode(\Environment::get('base') . \Environment::get('request') . '|' . \Environment::get('server')); $objTemplate->updateHelp = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['updateHelp'], '<a href="http://luid.inetrobots.com" target="_blank">Live Update ID</a>'); $objTemplate->phar = file_exists(TL_ROOT . '/contao/update.phar.php'); $objTemplate->toLiveUpdate = $GLOBALS['TL_LANG']['tl_maintenance']['toLiveUpdate']; return $objTemplate->parse(); }
/** * Generate the module * * @return string */ public function run() { /** @var BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_maintenance_mode'); $objTemplate->action = ampersand(\Environment::get('request')); $objTemplate->headline = $GLOBALS['TL_LANG']['tl_maintenance']['maintenanceMode']; $objTemplate->isActive = $this->isActive(); try { $driver = \System::getContainer()->get('lexik_maintenance.driver.factory')->getDriver(); $isLocked = $driver->isExists(); } catch (\Exception $e) { return ''; } // Toggle the maintenance mode if (\Input::post('FORM_SUBMIT') == 'tl_maintenance_mode') { if ($isLocked) { $driver->unlock(); } else { $driver->lock(); } $this->reload(); } if ($isLocked) { $objTemplate->class = 'tl_confirm'; $objTemplate->explain = $GLOBALS['TL_LANG']['MSC']['maintenanceEnabled']; $objTemplate->submit = $GLOBALS['TL_LANG']['tl_maintenance']['maintenanceDisable']; } else { $objTemplate->class = 'tl_info'; $objTemplate->explain = $GLOBALS['TL_LANG']['MSC']['maintenanceDisabled']; $objTemplate->submit = $GLOBALS['TL_LANG']['tl_maintenance']['maintenanceEnable']; } return $objTemplate->parse(); }
/** * Compile the view */ protected function compile() { if (!$this->getConfigAttribute('plain')) { if ($this->getConfigAttribute('table') === true) { $this->setConfigAttribute('table', $this->definition->getName()); } if ($this->getConfigAttribute('id') === true) { $this->setConfigAttribute('id', \Input::get('id')); } $strHref = \Environment::get('script') . '?do=' . \Input::get('do'); if ($this->view->getHref() != '') { $strHref .= '&' . $this->view->getHref(); } $this->setConfigAttribute('rt', \RequestToken::get()); $attributes = array(); if ($this->getConfigAttribute('id')) { $attributes[] = 'id'; } if ($this->getConfigAttribute('table')) { $attributes[] = 'table'; } $attributes[] = 'rt'; $strHref .= '&' . $this->buildHref($attributes); $this->view->setHref($strHref); } }
public function getConfiguration($param) { $dc = Database::getInstance(); $obj = $dc->prepare('SELECT * FROM tl_rs_settings ORDER BY have_license,language, language_demo ASC')->execute()->fetchAllAssoc(); $returner = array(); $error = true; $edit_link = '<a href="contao/main.php?do=readspeaker_settings&act=edit&id=%s&rt=%s&ref=%s" title="" class="edit"><img src="system/themes/default/images/edit.gif" width="12" height="16" alt="Edit "></a>'; if (count($obj) >= 1) { $error = false; foreach ($obj as $key => $row) { if ($row['have_license']) { $returner['ID: ' . $row['customer_id']][$row['id']] = $GLOBALS['TL_LANG']['MSC']['rs_language_codes'][$row['language']] . ' ' . ($row['domain'] ? '[' . $row['domain'] . ']' : ''); // . ' ' . ($row['note'] ? '<span class="tl_blue" >[' . $row['note'] . ']</span>' : ''); } else { $returner['DEMO'][$row['id']] = $GLOBALS['TL_LANG']['MSC']['rs_language_codes'][$row['language_demo']] . ' ' . ($row['domain'] ? '[' . $row['domain'] . ']' : ''); // . ' ' . ($row['note'] ? '<span class="tl_blue" >[' . $row['note'] . ']</span>' : ''); } } } if ($error) { $session = $this->Session->get('referer'); $session[TL_REFERER_ID]['current'] = substr(\Environment::get('requestUri'), strlen(TL_PATH) + 1); $this->Session->set('referer', $session); Message::addRaw(sprintf($GLOBALS['TL_LANG']['tl_module']['error']['error_no_settings'], REQUEST_TOKEN, TL_REFERER_ID)); } return $returner; }
/** * Generate the robots.txt files */ public static function generateRobotsTxts() { // delete all existing domain specific robots.txt files foreach (scandir(static::getDomainSpecificFolderPath(true)) as $entry) { if (!is_dir($entry) && ($pos = strpos($entry, FILE_ROBOTS_TXT_DOMAIN_SPECIFIC_PREFIX)) !== FALSE && $pos == 0 && ($pos = strpos($entry, FILE_ROBOTS_TXT_DOMAIN_SPECIFIC_SUFFIX)) !== FALSE && $pos == strlen($entry) - strlen(FILE_ROBOTS_TXT_DOMAIN_SPECIFIC_SUFFIX)) { $filePathOld = static::getDomainSpecificFolderPath(true) . "/" . $entry; if (file_exists($filePathOld)) { unlink($filePathOld); } } } // create all robots.txt files $blnGenerationSuccess = true; $objFallbackRootPage = static::getFallbackRootPages(); while ($objFallbackRootPage->next()) { $filePath = TL_ROOT . "/" . FILE_ROBOTS_TXT; if (static::isDomainSpecicCreationAllowed($objFallbackRootPage->useDomainSpecificRobotsTxt)) { $filePath = static::getDomainSpecificFilePath($objFallbackRootPage->alias, true); } $fileContent = $objFallbackRootPage->robotsTxtContent; if ($objFallbackRootPage->createSitemap && $objFallbackRootPage->sitemapName != '' && $objFallbackRootPage->robotsTxtAddAbsoluteSitemapPath) { $strDomain = ($objFallbackRootPage->useSSL ? 'https://' : 'http://') . ($objFallbackRootPage->dns ?: \Environment::get('host')) . TL_PATH . '/'; $fileContent .= "\n"; $objRootPage = static::getRootPagesByDns($objFallbackRootPage->dns); while ($objRootPage->next()) { $fileContent .= "Sitemap: " . $strDomain . "share/" . $objRootPage->sitemapName . ".xml\n"; } } if (file_put_contents($filePath, $fileContent) === FALSE) { $blnGenerationSuccess = false; } } return $blnGenerationSuccess; }
/** * Send the personal data change e-mail * @param object * @param array * @param object */ public function sendPersonalDataEmail($objUser, $arrData, $objModule) { if (!$objModule->nc_notification) { return; } $arrTokens = array(); $arrTokens['admin_email'] = $GLOBALS['TL_ADMIN_EMAIL']; $arrTokens['domain'] = \Environment::get('host'); // Support newsletters if (in_array('newsletter', $this->Config->getActiveModules())) { if (!is_array($arrData['newsletter'])) { if ($arrData['newsletter'] != '') { $objChannels = \Database::getInstance()->execute("SELECT title FROM tl_newsletter_channel WHERE id IN(" . implode(',', array_map('intval', (array) $arrData['newsletter'])) . ")"); $arrTokens['member_newsletter'] = implode("\n", $objChannels->fetchEach('title')); } else { $arrTokens['member_newsletter'] = ''; } } } // Translate/format old values foreach ($_SESSION['PERSONAL_DATA'] as $strFieldName => $strFieldValue) { $arrTokens['member_old_' . $strFieldName] = \Haste\Util\Format::dcaValue('tl_member', $strFieldName, $strFieldValue); } // Translate/format new values foreach ($arrData as $strFieldName => $strFieldValue) { $arrTokens['member_' . $strFieldName] = \Haste\Util\Format::dcaValue('tl_member', $strFieldName, $strFieldValue); } $objNotification = \NotificationCenter\Model\Notification::findByPk($objModule->nc_notification); if ($objNotification !== null) { $objNotification->send($arrTokens); } }
/** * 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); }
/** * Generate the module * * @return string */ public function run() { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_live_update'); $objTemplate->updateClass = 'tl_confirm'; $objTemplate->updateHeadline = $GLOBALS['TL_LANG']['tl_maintenance']['liveUpdate']; $objTemplate->isActive = $this->isActive(); // Newer version available if (\Config::get('latestVersion') && version_compare(VERSION . '.' . BUILD, \Config::get('latestVersion'), '<')) { $objTemplate->updateClass = 'tl_info'; $objTemplate->updateMessage = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['newVersion'], \Config::get('latestVersion')); } else { $objTemplate->updateClass = 'tl_confirm'; $objTemplate->updateMessage = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['upToDate'], VERSION . '.' . BUILD); } // Automatically switch to SSL if (\Environment::get('ssl')) { \Config::set('liveUpdateBase', str_replace('http://', 'https://', \Config::get('liveUpdateBase'))); } $objTemplate->uid = \Config::get('liveUpdateId'); $objTemplate->updateServer = \Config::get('liveUpdateBase') . 'index.php'; // Run the update if (\Input::get('token') != '') { $this->runLiveUpdate($objTemplate); } $objTemplate->version = VERSION . '.' . BUILD; $objTemplate->liveUpdateId = $GLOBALS['TL_LANG']['tl_maintenance']['liveUpdateId']; $objTemplate->runLiveUpdate = specialchars($GLOBALS['TL_LANG']['tl_maintenance']['runLiveUpdate']); $objTemplate->referer = base64_encode(\Environment::get('base') . \Environment::get('request') . '|' . \Environment::get('server')); $objTemplate->updateHelp = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['updateHelp'], '<a href="http://luid.inetrobots.com" target="_blank">Live Update ID</a>'); $objTemplate->phar = file_exists(TL_ROOT . '/contao/update.phar.php'); $objTemplate->toLiveUpdate = $GLOBALS['TL_LANG']['tl_maintenance']['toLiveUpdate']; return $objTemplate->parse(); }
/** * Run the controller and parse the login template */ public function run() { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_login'); // Show a cookie warning if (\Input::get('referer', true) != '' && empty($_COOKIE)) { $objTemplate->noCookies = $GLOBALS['TL_LANG']['MSC']['noCookies']; } $strHeadline = sprintf($GLOBALS['TL_LANG']['MSC']['loginTo'], \Config::get('websiteTitle')); $objTemplate->theme = \Backend::getTheme(); $objTemplate->messages = \Message::generate(); $objTemplate->base = \Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->languages = \System::getLanguages(true); $objTemplate->title = specialchars($strHeadline); $objTemplate->charset = \Config::get('characterSet'); $objTemplate->action = ampersand(\Environment::get('request')); $objTemplate->userLanguage = $GLOBALS['TL_LANG']['tl_user']['language'][0]; $objTemplate->headline = $strHeadline; $objTemplate->curLanguage = \Input::post('language') ?: str_replace('-', '_', $GLOBALS['TL_LANGUAGE']); $objTemplate->curUsername = \Input::post('username') ?: ''; $objTemplate->uClass = $_POST && empty($_POST['username']) ? ' class="login_error"' : ''; $objTemplate->pClass = $_POST && empty($_POST['password']) ? ' class="login_error"' : ''; $objTemplate->loginButton = specialchars($GLOBALS['TL_LANG']['MSC']['loginBT']); $objTemplate->username = $GLOBALS['TL_LANG']['tl_user']['username'][0]; $objTemplate->password = $GLOBALS['TL_LANG']['MSC']['password'][0]; $objTemplate->feLink = $GLOBALS['TL_LANG']['MSC']['feLink']; $objTemplate->frontendFile = \Environment::get('base'); $objTemplate->disableCron = \Config::get('disableCron'); $objTemplate->ie6warning = sprintf($GLOBALS['TL_LANG']['ERR']['ie6warning'], '<a href="http://ie6countdown.com">', '</a>'); $objTemplate->default = $GLOBALS['TL_LANG']['MSC']['default']; $objTemplate->output(); }
/** * Run the controller and parse the template */ public function run() { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_preview'); $objTemplate->base = \Environment::get('base'); $objTemplate->language = $GLOBALS['TL_LANGUAGE']; $objTemplate->title = specialchars($GLOBALS['TL_LANG']['MSC']['fePreview']); $objTemplate->charset = \Config::get('characterSet'); $objTemplate->site = \Input::get('site', true); if (\Input::get('url')) { $objTemplate->url = \Environment::get('base') . \Input::get('url'); } elseif (\Input::get('page')) { $objTemplate->url = $this->redirectToFrontendPage(\Input::get('page'), \Input::get('article'), true); } else { $objTemplate->url = \Environment::get('base'); } // Switch to a particular member (see #6546) if (\Input::get('user') && $this->User->isAdmin) { $objUser = \MemberModel::findByUsername(\Input::get('user')); if ($objUser !== null) { $strHash = sha1(session_id() . (!\Config::get('disableIpCheck') ? \Environment::get('ip') : '') . 'FE_USER_AUTH'); // Remove old sessions $this->Database->prepare("DELETE FROM tl_session WHERE tstamp<? OR hash=?")->execute(time() - \Config::get('sessionTimeout'), $strHash); // Insert the new session $this->Database->prepare("INSERT INTO tl_session (pid, tstamp, name, sessionID, ip, hash) VALUES (?, ?, ?, ?, ?, ?)")->execute($objUser->id, time(), 'FE_USER_AUTH', session_id(), \Environment::get('ip'), $strHash); // Set the cookie $this->setCookie('FE_USER_AUTH', $strHash, time() + \Config::get('sessionTimeout'), null, null, false, true); $objTemplate->user = \Input::post('user'); } } \Config::set('debugMode', false); $objTemplate->output(); }
/** * Generate the module */ protected function compile() { global $objPage; $arrJumpTo = array(); $arrNewsletter = array(); $strRequest = ampersand(\Environment::get('request'), true); $objNewsletter = \NewsletterModel::findSentByPids($this->nl_channels); if ($objNewsletter !== null) { while ($objNewsletter->next()) { if (($objTarget = $objNewsletter->getRelated('pid')) === null) { continue; } $jumpTo = intval($objTarget->jumpTo); // A jumpTo page is not mandatory for newsletter channels (see #6521) but required for the list module if ($jumpTo < 1) { throw new \Exception("Newsletter channels without redirect page cannot be used in a newsletter list"); } $strUrl = $strRequest; if (!isset($arrJumpTo[$objTarget->jumpTo])) { $objJumpTo = $objTarget->getRelated('jumpTo')->loadDetails(); if ($objJumpTo !== null) { $arrJumpTo[$objTarget->jumpTo] = $this->generateFrontendUrl($objJumpTo->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s'); } else { $arrJumpTo[$objTarget->jumpTo] = $strUrl; } } $strUrl = $arrJumpTo[$objTarget->jumpTo]; $strAlias = $objNewsletter->alias != '' && !\Config::get('disableAlias') ? $objNewsletter->alias : $objNewsletter->id; $arrNewsletter[] = array('subject' => $objNewsletter->subject, 'title' => strip_insert_tags($objNewsletter->subject), 'href' => sprintf($strUrl, $strAlias), 'date' => \Date::parse($objPage->dateFormat, $objNewsletter->date), 'datim' => \Date::parse($objPage->datimFormat, $objNewsletter->date), 'time' => \Date::parse($objPage->timeFormat, $objNewsletter->date), 'channel' => $objNewsletter->channel); } } $this->Template->newsletters = $arrNewsletter; }
public function registerViewAssets() { $al = \AssetList::getInstance(); $v = \View::getInstance(); $env = \Environment::get(); $identifier = 'menuitem/' . $this->menuItem->getHandle() . '/view'; foreach (array('CSS' => 'view.css', 'JAVASCRIPT' => 'view.js') as $t => $i) { $r = $env->getRecord(DIRNAME_MENU_ITEMS . '/' . $this->menuItem->getHandle() . '/' . $i, $this->menuItem->getPackageHandle()); if ($r->exists()) { switch ($t) { case 'CSS': $asset = new CssAsset($identifier); $asset->setAssetURL($r->url); $asset->setAssetPath($r->file); $al->registerAsset($asset); $v->requireAsset('css', $identifier); break; case 'JAVASCRIPT': $asset = new JavascriptAsset($identifier); $asset->setAssetURL($r->url); $asset->setAssetPath($r->file); $al->registerAsset($asset); $v->requireAsset('javascript', $identifier); break; } } } }
/** * Generate the module */ protected function compile() { $this->Template->size = ''; // Set the size if ($this->playerSize != '') { $size = deserialize($this->playerSize); if (is_array($size)) { $this->Template->size = ' width="' . $size[0] . '" height="' . $size[1] . '"'; } } $this->Template->poster = false; // Optional poster if ($this->posterSRC != '') { if (($objFile = \FilesModel::findByUuid($this->posterSRC)) !== null) { $this->Template->poster = $objFile->path; } } // Check for SSL (see #6900) $protocol = \Environment::get('ssl') ? 'https://' : 'http://'; $objFile = new \stdClass(); $objFile->mime = 'video/x-youtube'; $objFile->path = $protocol . 'www.youtube.com/watch?v=' . $this->youtube; $this->Template->isVideo = true; $this->Template->files = array($objFile); $this->Template->autoplay = $this->autoplay; }
/** * Logout the current user and redirect * * @return string */ public function generate() { if (TL_MODE == 'BE') { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['logout'][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(); } // Set last page visited if ($this->redirectBack) { $_SESSION['LAST_PAGE_VISITED'] = $this->getReferer(); } $this->import('FrontendUser', 'User'); $strRedirect = \Environment::get('base'); // Redirect to last page visited if ($this->redirectBack && !empty($_SESSION['LAST_PAGE_VISITED'])) { $strRedirect = $_SESSION['LAST_PAGE_VISITED']; } elseif ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) !== null) { /** @var \PageModel $objTarget */ $strRedirect = $objTarget->getFrontendUrl(); } // Log out and redirect if ($this->User->logout()) { $this->redirect($strRedirect); } return ''; }
/** * Show message while we are waiting for server-to-server order confirmation * @param IsotopeProductCollection The order being places * @param Module The checkout module instance * @return boolean */ public function processPayment(IsotopeProductCollection $objOrder, \Module $objModule) { if ($objOrder->order_status > 0) { unset($_SESSION['POSTSALE_TIMEOUT']); return true; } if (!isset($_SESSION['POSTSALE_TIMEOUT'])) { $_SESSION['POSTSALE_TIMEOUT'] = 12; } else { $_SESSION['POSTSALE_TIMEOUT'] = $_SESSION['POSTSALE_TIMEOUT'] - 1; } if ($_SESSION['POSTSALE_TIMEOUT'] > 0) { // Reload page every 5 seconds $GLOBALS['TL_HEAD'][] = '<meta http-equiv="refresh" content="5,' . \Environment::get('base') . \Environment::get('request') . '">'; // Do not index or cache the page global $objPage; $objPage->noSearch = 1; $objPage->cache = 0; $objTemplate = new \Isotope\Template('mod_message'); $objTemplate->type = 'processing'; $objTemplate->message = $GLOBALS['TL_LANG']['MSC']['payment_processing']; return $objTemplate->parse(); } unset($_SESSION['POSTSALE_TIMEOUT']); \System::log('Payment could not be processed.', __METHOD__, TL_ERROR); return false; }
/** * Generate the module */ protected function compile() { \System::loadLanguageFile('tl_autoload'); // Process the request if (\Input::post('FORM_SUBMIT') == 'tl_autoload') { $this->createAutoloadFiles(); $this->reload(); } $arrModules = array(); // List all modules foreach (scan(TL_ROOT . '/system/modules') as $strFile) { if (strncmp($strFile, '.', 1) === 0 || !is_dir(TL_ROOT . '/system/modules/' . $strFile)) { continue; } $arrModules[] = $strFile; } $this->Template->modules = $arrModules; $this->Template->messages = \Message::generate(); $this->Template->href = $this->getReferer(true); $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['backBTTitle']); $this->Template->button = $GLOBALS['TL_LANG']['MSC']['backBT']; $this->Template->headline = $GLOBALS['TL_LANG']['tl_autoload']['headline']; $this->Template->action = ampersand(\Environment::get('request')); $this->Template->available = $GLOBALS['TL_LANG']['tl_autoload']['available']; $this->Template->xplAvailable = $GLOBALS['TL_LANG']['tl_autoload']['xplAvailable']; $this->Template->selectAll = $GLOBALS['TL_LANG']['MSC']['selectAll']; $this->Template->override = $GLOBALS['TL_LANG']['tl_autoload']['override']; $this->Template->xplOverride = $GLOBALS['TL_LANG']['tl_autoload']['xplOverride']; $this->Template->submitButton = specialchars($GLOBALS['TL_LANG']['MSC']['continue']); $this->Template->autoload = $GLOBALS['TL_LANG']['tl_autoload']['autoload']; $this->Template->ideCompat = $GLOBALS['TL_LANG']['tl_autoload']['ideCompat']; }
public function getAttributeKeyIconSRC() { $type = $this->getAttributeType(); $env = \Environment::get(); $url = $env->getURL(implode('/', array(DIRNAME_ATTRIBUTES . '/' . $type->getAttributeTypeHandle() . '/' . FILENAME_BLOCK_ICON)), $type->getPackageHandle()); return $url; }
/** * Generate the content element */ protected function compile() { global $objPage; // Contao framework sets images to max-width 100%, which collides with Google's CSS if (!$this->dlh_googlemap_nocss) { \delahaye\googlemaps\Googlemap::CssInjection(); } // get the map data $arrParams = array('mapSize' => deserialize($this->dlh_googlemap_size), 'zoom' => $this->dlh_googlemap_zoom); $arrParams['mapSize'][2] = $arrParams['mapSize'][2] == 'pcnt' ? '%' : $arrParams['mapSize'][2]; $arrMap = \delahaye\googlemaps\Googlemap::getMapData($this->dlh_googlemap, $objPage->outputFormat, $arrParams); // static map if ($this->dlh_googlemap_static) { $this->Template = new \FrontendTemplate('ce_dlh_googlemapsstatic'); if ($this->dlh_googlemap_url) { $arrMap['staticMap'] = '<a href="' . $this->dlh_googlemap_url . '"' . ($this->rel ? ($objPage->outputFormat == 'html5' ? ' data-lightbox="' : ' rel="') . $this->rel . '"' : '') . ' title="' . addslashes($this->linkTitle) . '"' . ($this->target ? ' onclick="window.open(this.href); return false;"' : '') . '>' . $arrMap['staticMap'] . '</a>'; } } else { if ($this->dlh_googlemap_template && $this->dlh_googlemap_template != 'ce_dlh_googlemaps_default') { $this->Template = new \FrontendTemplate($this->dlh_googlemap_template); } $GLOBALS['TL_JAVASCRIPT'][] = 'http' . (\Environment::get('ssl') ? 's' : '') . '://maps.google.com/maps/api/js?language=' . $arrMap['language'] . '&sensor=' . ($arrMap['sensor'] ? 'true' : 'false'); } $this->Template->map = $arrMap; $this->Template->tabs = $this->dlh_googlemap_tabs; $this->Template->labels = $GLOBALS['TL_LANG']['dlh_googlemaps']['labels']; }
protected function compile() { parent::compile(); $support = array('ie' => 9, 'chrome' => 3, 'firefox' => 4, 'opera' => 10, 'safari' => 5); $agent = \Environment::get('agent'); $this->Template->useCss = isset($support[$agent->browser]) && $agent->version >= $support[$agent->browser]; }
/** * Add the social images to the page * * @param \PageModel $objPage * @param \LayoutModel $objLayout */ public function addSocialImages(\PageModel $objPage, \LayoutModel $objLayout) { if (!is_array($GLOBALS['SOCIAL_IMAGES']) || count($GLOBALS['SOCIAL_IMAGES']) < 1) { return; } $arrImages = array_unique($GLOBALS['SOCIAL_IMAGES']); // Limit the images if ($objLayout->socialImages_limit > 0) { $arrImages = array_slice($arrImages, 0, $objLayout->socialImages_limit); } $arrDimensions = deserialize($objLayout->socialImages_size, true); $strHost = (\Environment::get('ssl') ? 'https://' : 'http://') . \Environment::get('host') . TL_PATH; foreach ($arrImages as $strImage) { // Check the dimensions limit if ($arrDimensions[0] > 0 && $arrDimensions[1] > 0) { list($width, $height) = getimagesize(TL_ROOT . '/' . $strImage); if ($width < $arrDimensions[0] || $height < $arrDimensions[1]) { continue; } } if ($objPage->outputFormat == 'xhtml') { $GLOBALS['TL_HEAD'][] = '<meta property="og:image" content="' . $strHost . '/' . $strImage . '" />'; } else { $GLOBALS['TL_HEAD'][] = '<meta property="og:image" content="' . $strHost . '/' . $strImage . '">'; } } }
/** * * @param $view string */ protected function includeFooter($view) { if ($_file = Environment::get()->getPath(DIRNAME_ATTRIBUTES . '/' . $view . '_footer.php')) { $type = $this->attributeType; include $_file; } }
/** * Generate the module */ protected function compile() { /** @var \PageModel $objPage */ global $objPage; if (!strlen($this->inColumn)) { $this->inColumn = 'main'; } $intCount = 0; $articles = array(); $id = $objPage->id; $this->Template->request = \Environment::get('request'); // Show the articles of a different page if ($this->defineRoot && $this->rootPage > 0) { if (($objTarget = $this->objModel->getRelated('rootPage')) !== null) { $id = $objTarget->id; /** @var \PageModel $objTarget */ $this->Template->request = $objTarget->getFrontendUrl(); } } // Get published articles $objArticles = \ArticleModel::findPublishedByPidAndColumn($id, $this->inColumn); if ($objArticles === null) { return; } while ($objArticles->next()) { // Skip first article if (++$intCount <= intval($this->skipFirst)) { continue; } $cssID = deserialize($objArticles->cssID, true); $alias = $objArticles->alias ?: $objArticles->title; $articles[] = array('link' => $objArticles->title, 'title' => specialchars($objArticles->title), 'id' => $cssID[0] ?: standardize($alias), 'articleId' => $objArticles->id); } $this->Template->articles = $articles; }
public static function loadRoute($route) { // run this method only one time if (!self::$can_run) { return; } self::$can_run = false; $__r_controller = $route['controller']; $__r_action = $route['action']; $__r_params = $route['params']; self::$controller = $__r_controller; $__r_file = Environment::get('Application.controllers') . '/' . $__r_controller . '.php'; if (file_exists($__r_file) == false || is_readable($__r_file) == false) { if (self::$debug) { throw new Exception("Invalid controller file: {$__r_file}"); } else { call_user_func(self::$error404); } } else { include_once $__r_file; $__r_class = $__r_controller . 'Controller'; if (class_exists($__r_class)) { $__r_object = new $__r_class(); if (is_callable(array($__r_object, $__r_action)) == false) { $__r_action = 'index'; } self::$action = $__r_action; call_user_func_array(array($__r_object, $__r_action), $__r_params); } else { throw new Exception("Invalid class: {$__r_class}"); } } }
/** * Run the controller and parse the template */ public function run() { $this->Template = new BackendTemplate('be_picker'); $this->Template->main = ''; // Ajax request if ($_POST && Environment::get('isAjaxRequest')) { $this->objAjax = new Ajax(Input::post('action')); $this->objAjax->executePreActions(); } $strTable = Input::get('table'); $strField = Input::get('field'); $this->loadDataContainer($strTable); $objDca = new DC_Table($strTable); // AJAX request if ($_POST && Environment::get('isAjaxRequest')) { $this->objAjax->executePostActions($objDca); } $objFileTree = new $GLOBALS['BE_FFL']['fileSelector'](array('strId' => $strField, 'strTable' => $strTable, 'strField' => $strField, 'strName' => $strField, 'varValue' => explode(',', Input::get('value'))), $objDca); $this->Template->main = $objFileTree->generate(); $this->Template->theme = $this->getTheme(); $this->Template->base = Environment::get('base'); $this->Template->language = $GLOBALS['TL_LANGUAGE']; $this->Template->title = specialchars($GLOBALS['TL_LANG']['MSC']['filepicker']); $this->Template->headline = $GLOBALS['TL_LANG']['MSC']['ppHeadline']; $this->Template->charset = $GLOBALS['TL_CONFIG']['characterSet']; $this->Template->options = $this->createPageList(); $this->Template->expandNode = $GLOBALS['TL_LANG']['MSC']['expandNode']; $this->Template->collapseNode = $GLOBALS['TL_LANG']['MSC']['collapseNode']; $this->Template->loadingData = $GLOBALS['TL_LANG']['MSC']['loadingData']; $this->Template->search = $GLOBALS['TL_LANG']['MSC']['search']; $this->Template->action = ampersand(Environment::get('request')); $this->Template->value = $this->Session->get('file_selector_search'); $GLOBALS['TL_CONFIG']['debugMode'] = false; $this->Template->output(); }
/** * Generate the module */ protected function compile() { $this->Template->src = $this->singleSRC; $this->Template->href = $this->source == 'external' ? $this->url : $this->singleSRC; $this->Template->alt = $this->altContent; $this->Template->var = 'swf' . $this->id; $this->Template->transparent = $this->transparent ? true : false; $this->Template->interactive = $this->interactive ? true : false; $this->Template->flashId = $this->flashID ?: 'swf_' . $this->id; $this->Template->fsCommand = ' ' . preg_replace('/[\\n\\r]/', "\n ", \StringUtil::decodeEntities($this->flashJS)); $this->Template->flashvars = 'URL=' . \Environment::get('base'); $this->Template->version = $this->version ?: '6.0.0'; $size = \StringUtil::deserialize($this->size); $this->Template->width = $size[0]; $this->Template->height = $size[1]; $intMaxWidth = TL_MODE == 'BE' ? 320 : \Config::get('maxImageWidth'); // Adjust movie size if ($intMaxWidth > 0 && $size[0] > $intMaxWidth) { $this->Template->width = $intMaxWidth; $this->Template->height = floor($intMaxWidth * $size[1] / $size[0]); } if (strlen($this->flashvars)) { $this->Template->flashvars .= '&' . \StringUtil::decodeEntities($this->flashvars); } }
/** * Do not show the module if no calendar has been selected * * @return string */ public function generate() { if (TL_MODE == 'BE') { /** @var \BackendTemplate|object $objTemplate */ $objTemplate = new \BackendTemplate('be_wildcard'); $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['calendar'][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(); } $this->cal_calendar = $this->sortOutProtected(deserialize($this->cal_calendar, true)); // Return if there are no calendars if (!is_array($this->cal_calendar) || empty($this->cal_calendar)) { return ''; } $this->strUrl = preg_replace('/\\?.*$/', '', \Environment::get('request')); $this->strLink = $this->strUrl; if ($this->jumpTo && ($objTarget = $this->objModel->getRelated('jumpTo')) !== null) { /** @var \PageModel $objTarget */ $this->strLink = $objTarget->getFrontendUrl(); } return parent::generate(); }
public function testGet() { $get = array('n' => 'v'); $env = new Environment($get, array(), array()); $this->assertEquals('v', $env->get('n')); $this->assertNull($env->get('not-existed-param')); }
/** * 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); }
/** * Constructs a Drush alias for an environment. Used to supply * organizational Drush aliases not provided by the API. * * @param Environment $environment Environment to create an alias for * @return string * @throws TerminusException */ private function constructAlias($environment) { $site_name = $environment->site->get('name'); $site_id = $environment->site->get('id'); $env_id = $environment->get('id'); $db_bindings = $environment->bindings->getByType('dbserver'); $hostnames = array_keys((array) $environment->getHostnames()); if (empty($hostnames) || empty($db_bindings)) { throw new TerminusException('No hostname entry for {site}.{env}', ['site' => $site_name, 'env' => $env_id], 1); } $db_binding = array_shift($db_bindings); $uri = array_shift($hostnames); $db_pass = $db_binding->get('password'); $db_port = $db_binding->get('port'); if (strpos(TERMINUS_HOST, 'onebox') !== false) { $remote_user = "******"; $remote_host = TERMINUS_HOST; $db_url = "mysql://*****:*****@{$remote_host}:{$db_port}"; $db_url .= '/pantheon'; } else { $remote_user = "******"; $remote_host = "appserver.{$env_id}.{$site_id}.drush.in"; $db_url = "mysql://*****:*****@dbserver.{$environment}.{$site_id}"; $db_url .= ".drush.in:{$db_port}/pantheon"; } $output = "array(\n 'uri' => {$uri},\n 'db-url' => {$db_url},\n 'db-allows-remote' => true,\n 'remote-host' => {$remote_host},\n 'remote-user' => {$remote_user},\n 'ssh-options' => '-p 2222 -o \"AddressFamily inet\"',\n 'path-aliases' => array(\n '%files' => 'code/sites/default/files',\n '%drush-script' => 'drush',\n ),\n );"; return $output; }