本文整理汇总了PHP中BackendTemplate类的典型用法代码示例。如果您正苦于以下问题:PHP BackendTemplate类的具体用法?PHP BackendTemplate怎么用?PHP BackendTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BackendTemplate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* {@inheritdoc}
*/
public function handle(\Input $input)
{
$this->handleRunOnce();
// PATCH
if ($input->post('FORM_SUBMIT') == 'database-update') {
$count = 0;
$sql = deserialize($input->post('sql'));
if (is_array($sql)) {
foreach ($sql as $key) {
if (isset($_SESSION['sql_commands'][$key])) {
$this->Database->query(str_replace('DEFAULT CHARSET=utf8;', 'DEFAULT CHARSET=utf8 COLLATE ' . $GLOBALS['TL_CONFIG']['dbCollation'] . ';', $_SESSION['sql_commands'][$key]));
$count++;
}
}
}
$_SESSION['sql_commands'] = array();
Messages::addConfirmation(sprintf($GLOBALS['TL_LANG']['composer_client']['databaseUpdated'], $count));
$this->reload();
}
/** @var \Contao\Database\Installer $installer */
$installer = \System::importStatic('Database\\Installer');
$form = $installer->generateSqlForm();
if (empty($form)) {
Messages::addInfo($GLOBALS['TL_LANG']['composer_client']['databaseUptodate']);
$this->redirect('contao/main.php?do=composer');
}
$form = preg_replace('#(<label for="sql_\\d+")>(CREATE TABLE)#', '$1 class="create_table">$2', $form);
$form = preg_replace('#(<label for="sql_\\d+")>(ALTER TABLE `[^`]+` ADD)#', '$1 class="alter_add">$2', $form);
$form = preg_replace('#(<label for="sql_\\d+")>(ALTER TABLE `[^`]+` DROP)#', '$1 class="alter_drop">$2', $form);
$form = preg_replace('#(<label for="sql_\\d+")>(DROP TABLE)#', '$1 class="drop_table">$2', $form);
$template = new \BackendTemplate('be_composer_client_update');
$template->composer = $this->composer;
$template->form = $form;
return $template->parse();
}
示例2: generate
/**
* 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();
}
示例3: generate
/**
* Display a wildcard in the back end
*
* @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']['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();
}
// Set the item from the auto_item parameter
if (!isset($_GET['items']) && \Config::get('useAutoItem') && isset($_GET['auto_item'])) {
\Input::setGet('items', \Input::get('auto_item'));
}
// Do not index or cache the page if no news item has been specified
if (!\Input::get('items')) {
/** @var \PageModel $objPage */
global $objPage;
$objPage->noSearch = 1;
$objPage->cache = 0;
return '';
}
$this->news_archives = $this->sortOutProtected(deserialize($this->news_archives));
// Do not index or cache the page if there are no archives
if (!is_array($this->news_archives) || empty($this->news_archives)) {
/** @var \PageModel $objPage */
global $objPage;
$objPage->noSearch = 1;
$objPage->cache = 0;
return '';
}
return parent::generate();
}
示例4: run
/**
* 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();
}
示例5: generate
/**
* Display a wildcard in the back end
* @return string
*/
public function generate()
{
if (TL_MODE == 'BE') {
$objTemplate = new BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### NEWS READER ###';
$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();
}
// Return if no news item has been specified
if (!$this->Input->get('items')) {
global $objPage;
// Do not index the page
$objPage->noSearch = 1;
$objPage->cache = 0;
return '';
}
$this->news_archives = $this->sortOutProtected(deserialize($this->news_archives));
// Return if there are no archives
if (!is_array($this->news_archives) || count($this->news_archives) < 1) {
global $objPage;
// Do not index the page
$objPage->noSearch = 1;
$objPage->cache = 0;
return '';
}
return parent::generate();
}
示例6: generate
/**
* generate function.
*
* @access public
* @return void
*/
public function generate()
{
if (TL_MODE == 'BE') {
$objTemplate = new \BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### PHOTOALBUMS 2 MODULE ###';
return $objTemplate->parse();
}
// Set Pa2 Type
$this->pa2type = 'MOD';
// Deserialize vars
$this->groups = deserialize($this->groups);
$this->pa2Archives = deserialize($this->pa2Archives);
$this->pa2AlbumSort = deserialize($this->pa2AlbumSort);
$this->pa2AlbumsMetaFields = deserialize($this->pa2AlbumsMetaFields);
$this->pa2ImagesMetaFields = deserialize($this->pa2ImagesMetaFields);
$this->pa2TimeFilterStart = deserialize($this->pa2TimeFilterStart);
$this->pa2TimeFilterEnd = deserialize($this->pa2TimeFilterEnd);
// Set true and false on checkboxes
$this->pa2ImagesShowHeadline = $this->pa2ImagesShowHeadline == 1 ? true : false;
$this->pa2ImagesShowTitle = $this->pa2ImagesShowTitle == 1 ? true : false;
$this->pa2ImagesShowTeaser = $this->pa2ImagesShowTeaser == 1 ? true : false;
$this->pa2AlbumsShowHeadline = $this->pa2AlbumsShowHeadline == 1 ? true : false;
$this->pa2AlbumsShowTitle = $this->pa2AlbumsShowTitle == 1 ? true : false;
$this->pa2AlbumsShowTeaser = $this->pa2AlbumsShowTeaser == 1 ? true : false;
$this->pa2AlbumLightbox = $this->pa2Mode == 'pa2_only_album_view' ? true : false;
$this->pa2DetailPage = $this->pa2Mode == 'pa2_with_detail_page' ? $this->pa2DetailPage : '';
// Set the item from the auto_item parameter
if ($GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) {
$this->Input->setGet('album', $this->Input->get('auto_item'));
}
return parent::generate();
}
示例7: generate
/**
* Do not display the module if there are no articles
* @return string
*/
public function generate()
{
if (TL_MODE == 'BE') {
$objTemplate = new \BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### ARTICLE NAVIGATION ###';
$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;
$this->objArticles = \ArticleModel::findPublishedWithTeaserByPidAndColumn($objPage->id, $this->strColumn);
// Return if there are no articles
if ($this->objArticles === null) {
return '';
}
// Redirect to the first article if no article is selected
if (!\Input::get('articles')) {
if (!$this->loadFirst) {
return '';
}
$strAlias = $this->objArticles->alias != '' && !$GLOBALS['TL_CONFIG']['disableAlias'] ? $this->objArticles->alias : $this->objArticles->id;
$this->redirect($this->addToUrl('articles=' . $strAlias));
}
return parent::generate();
}
示例8: generate
/**
* Display a wildcard in the back end
* @return string
*/
public function generate()
{
if (TL_MODE == 'BE') {
$objTemplate = new \BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### RSS READER ###';
$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->objFeed = new \SimplePie();
$arrUrls = trimsplit('[\\n\\t ]', trim($this->rss_feed));
if (count($arrUrls) > 1) {
$this->objFeed->set_feed_url($arrUrls);
} else {
$this->objFeed->set_feed_url($arrUrls[0]);
}
$this->objFeed->set_output_encoding($GLOBALS['TL_CONFIG']['characterSet']);
$this->objFeed->set_cache_location(TL_ROOT . '/system/tmp');
$this->objFeed->enable_cache(false);
if ($this->rss_cache > 0) {
$this->objFeed->enable_cache(true);
$this->objFeed->set_cache_duration($this->rss_cache);
}
if (!$this->objFeed->init()) {
$this->log('Error importing RSS feed "' . $this->rss_feed . '"', 'ModuleRssReader generate()', TL_ERROR);
return '';
}
$this->objFeed->handle_content_type();
return parent::generate();
}
示例9: generate
/**
* Display a wildcard in the back end
*
* @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']['listing'][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();
}
// Return if the table or the fields have not been set
if ($this->list_table == '' || $this->list_fields == '') {
return '';
}
// Disable the details page
if (\Input::get('show') && $this->list_info == '') {
return '';
}
// Fallback to the default template
if ($this->list_layout == '') {
$this->list_layout = 'list_default';
}
$this->strTemplate = $this->list_layout;
$this->list_where = $this->replaceInsertTags($this->list_where, false);
$this->list_info_where = $this->replaceInsertTags($this->list_info_where, false);
return parent::generate();
}
示例10: __construct
public function __construct()
{
// define the Named Application
if (!defined('NAMED_APPLICATION')) {
define('NAMED_APPLICATION', 'backend');
}
// set the module
$this->setModule(SpoonFilter::getGetValue('module', null, ''));
// set the requested file
$this->setFile(SpoonFilter::getGetValue('file', null, ''));
// set the language
$this->setLanguage(SpoonFilter::getGetValue('language', array_keys(BackendLanguage::getWorkingLanguages()), SITE_DEFAULT_LANGUAGE));
// build the path
if ($this->module == 'core') {
$path = BACKEND_CORE_PATH . '/js/' . $this->getFile();
} else {
$path = BACKEND_MODULES_PATH . '/' . $this->getModule() . '/js/' . $this->getFile();
}
// set correct headers
SpoonHTTP::setHeaders('content-type: application/javascript');
// create a new template instance (this will handle all stuff for us)
$tpl = new BackendTemplate();
// enable addslashes on each locale
$tpl->setAddSlashes(true);
// display
$tpl->display($path, true);
}
示例11: generateWizardList
/**
* @param \Database_Result $records
* @param string $id
* @param \DcaWizard $dcaWizard
*
* @return string
*/
public function generateWizardList($records, $id, $dcaWizard)
{
$return = '';
$rows = $dcaWizard->getRows($records);
// Alter the rows
\System::loadLanguageFile('tl_iso_product_collection');
$rows = array_map(function ($row) {
// Force an algebraic sign for quantity
$row['quantity'] = sprintf('%+d', $row['quantity']);
// Make referenced product collection editable in a popup
$row['product_collection_id'] = $row['product_collection_id'] ? sprintf('<a href="contao/main.php?do=iso_orders&act=edit&id=%1$u&popup=1&nb=1&rt=%4$s" title="%3$s" onclick="Backend.openModalIframe({\'width\':768,\'title\':\'%3$s\',\'url\':this.href});return false">%2$s</a>', $row['product_collection_id'], \Image::getHtml('edit.gif') . $row['product_collection_id'], sprintf($GLOBALS['TL_LANG']['tl_iso_product_collection']['edit'][1], $row['product_collection_id']), REQUEST_TOKEN) : '-';
return $row;
}, $rows);
if ($rows) {
$template = new \BackendTemplate('be_widget_dcawizard');
$template->headerFields = $dcaWizard->getHeaderFields();
$template->hasRows = !empty($rows);
$template->rows = $rows;
$template->fields = $dcaWizard->fields;
$template->showOperations = $dcaWizard->showOperations;
if ($dcaWizard->showOperations) {
$template->operations = $dcaWizard->getActiveRowOperations();
}
$template->generateOperation = function ($operation, $row) use($dcaWizard) {
return $dcaWizard->generateRowOperation($operation, $row);
};
$dom = new \DOMDocument('1.0', 'utf-8');
$dom->loadHTML($template->parse());
$return = $dom->saveHTML($dom->getElementsByTagName('table')->item(0));
}
// Add the member's total bonus points
$return .= sprintf('<strong style="display: inline-block; margin: 4px 0 2px 6px; border-bottom: 3px double">%s</strong>', Stock::getStockForProduct($dcaWizard->currentRecord));
return $return;
}
示例12: handle
/**
* {@inheritdoc}
*/
public function handle(\Input $input)
{
$repositoryManager = $this->getRepositoryManager();
/** @var RepositoryInterface $localRepository */
$localRepository = $repositoryManager->getLocalRepository();
$dependencyMap = $this->calculateDependencyMap($localRepository);
$dependencyGraph = array();
$localPackages = $localRepository->getPackages();
$localPackages = array_filter($localPackages, function (PackageInterface $localPackage) use($dependencyMap) {
$name = $localPackage->getName();
return !isset($dependencyMap[$name]) && !$localPackage instanceof \Composer\Package\AliasPackage;
});
$allLocalPackages = $localRepository->getPackages();
$allLocalPackages = array_combine(array_map(function (PackageInterface $localPackage) {
return $localPackage->getName();
}, $allLocalPackages), $allLocalPackages);
$localPackagesCount = count($localPackages);
$index = 0;
/** @var \Composer\Package\PackageInterface $package */
foreach ($localPackages as $package) {
$this->buildDependencyGraph($allLocalPackages, $localRepository, $package, null, $package->getPrettyVersion(), $dependencyGraph, ++$index == $localPackagesCount);
}
$template = new \BackendTemplate('be_composer_client_dependency_graph');
$template->composer = $this->composer;
$template->dependencyGraph = $dependencyGraph;
return $template->parse();
}
示例13: handle
/**
* {@inheritdoc}
*/
public function handle(\Input $input)
{
$repositoryManager = $this->getRepositoryManager();
// calculate replace map
$replaceMap = $this->calculateReplaceMap($repositoryManager->getLocalRepository());
// calculate contao-legacy replace map.
$legacyReplaceMap = $this->calculateLegacyReplaceMap($repositoryManager->getLocalRepository());
// build list of explicit required packages
$requiresList = $this->buildRequiresList($this->composer->getPackage(), $replaceMap);
// build list of dependencies
$dependenciesList = $this->buildDependenciesList($requiresList, $repositoryManager->getLocalRepository());
// build not yet installed package list
$notInstalledList = $this->buildNotInstalledList($this->composer->getPackage(), $repositoryManager->getLocalRepository());
// calculate dependency graph
$dependencyMap = $this->calculateDependencyMap($repositoryManager->getLocalRepository());
// build grouped list of packages
$groupedPackages = $this->buildGroupedPackagesList($this->composer->getPackage(), $repositoryManager->getLocalRepository(), $requiresList, $dependencyMap, $notInstalledList);
$template = new \BackendTemplate('be_composer_client');
$template->composer = $this->composer;
$template->dependencyMap = $dependencyMap;
$template->replaceMap = $replaceMap;
$template->legacyReplaceMap = $legacyReplaceMap;
$template->groupedPackages = $groupedPackages;
$template->requiresList = $requiresList;
$template->dependenciesList = $dependenciesList;
if ('detached' !== $GLOBALS['TL_CONFIG']['composerExecutionMode']) {
$template->output = $_SESSION['COMPOSER_OUTPUT'];
}
unset($_SESSION['COMPOSER_OUTPUT']);
return $template->parse();
}
示例14: run
/**
* 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();
}
示例15: generate
/**
* 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']['carpet_list'][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->carpet_categories = $this->sortOutProtected(deserialize($this->carpet_categories));
// No carpaets categries available
if (!is_array($this->carpet_categories) || empty($this->carpet_categories)) {
return '';
}
// Show the catalog detail if an item has been selected
if ($this->carpet_detailModule > 0 && (isset($_GET['items']) || $GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item']))) {
return $this->getFrontendModule($this->carpet_detailModule, $this->strColumn);
}
if (TL_MODE == 'FE') {
$GLOBALS['TL_JAVASCRIPT'][] = 'system/modules/carpet/assets/jquery.raty.min.js|static';
}
return parent::generate();
}