本文整理汇总了PHP中ModuleModel::findMultipleByIds方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleModel::findMultipleByIds方法的具体用法?PHP ModuleModel::findMultipleByIds怎么用?PHP ModuleModel::findMultipleByIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleModel
的用法示例。
在下文中一共展示了ModuleModel::findMultipleByIds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* Generate a regular page
*
* @param \PageModel $objPage
* @param boolean $blnCheckRequest
*/
public function generate($objPage, $blnCheckRequest = false)
{
$GLOBALS['TL_KEYWORDS'] = '';
$GLOBALS['TL_LANGUAGE'] = $objPage->language;
\System::loadLanguageFile('default');
// Static URLs
$this->setStaticUrls();
// Get the page layout
$objLayout = $this->getPageLayout($objPage);
// HOOK: modify the page or layout object (see #4736)
if (isset($GLOBALS['TL_HOOKS']['getPageLayout']) && is_array($GLOBALS['TL_HOOKS']['getPageLayout'])) {
foreach ($GLOBALS['TL_HOOKS']['getPageLayout'] as $callback) {
$this->import($callback[0]);
$this->{$callback[0]}->{$callback[1]}($objPage, $objLayout, $this);
}
}
/** @var \ThemeModel $objTheme */
$objTheme = $objLayout->getRelated('pid');
// Set the layout template and template group
$objPage->template = $objLayout->template ?: 'fe_page';
$objPage->templateGroup = $objTheme->templates;
// Store the output format
list($strFormat, $strVariant) = explode('_', $objLayout->doctype);
$objPage->outputFormat = $strFormat;
$objPage->outputVariant = $strVariant;
// Initialize the template
$this->createTemplate($objPage, $objLayout);
// Initialize modules and sections
$arrCustomSections = array();
$arrSections = array('header', 'left', 'right', 'main', 'footer');
$arrModules = deserialize($objLayout->modules);
$arrModuleIds = array();
// Filter the disabled modules
foreach ($arrModules as $module) {
if ($module['enable']) {
$arrModuleIds[] = $module['mod'];
}
}
// Get all modules in a single DB query
$objModules = \ModuleModel::findMultipleByIds($arrModuleIds);
if ($objModules !== null || $arrModules[0]['mod'] == 0) {
$arrMapper = array();
// Create a mapper array in case a module is included more than once (see #4849)
if ($objModules !== null) {
while ($objModules->next()) {
$arrMapper[$objModules->id] = $objModules->current();
}
}
foreach ($arrModules as $arrModule) {
// Disabled module
if (!$arrModule['enable']) {
continue;
}
// Replace the module ID with the module model
if ($arrModule['mod'] > 0 && isset($arrMapper[$arrModule['mod']])) {
$arrModule['mod'] = $arrMapper[$arrModule['mod']];
}
// Generate the modules
if (in_array($arrModule['col'], $arrSections)) {
// Filter active sections (see #3273)
if ($arrModule['col'] == 'header' && $objLayout->rows != '2rwh' && $objLayout->rows != '3rw') {
continue;
}
if ($arrModule['col'] == 'left' && $objLayout->cols != '2cll' && $objLayout->cols != '3cl') {
continue;
}
if ($arrModule['col'] == 'right' && $objLayout->cols != '2clr' && $objLayout->cols != '3cl') {
continue;
}
if ($arrModule['col'] == 'footer' && $objLayout->rows != '2rwf' && $objLayout->rows != '3rw') {
continue;
}
$this->Template->{$arrModule['col']} .= $this->getFrontendModule($arrModule['mod'], $arrModule['col']);
} else {
$arrCustomSections[$arrModule['col']] .= $this->getFrontendModule($arrModule['mod'], $arrModule['col']);
}
}
}
$this->Template->sections = $arrCustomSections;
// Mark RTL languages (see #7171)
if ($GLOBALS['TL_LANG']['MSC']['textDirection'] == 'rtl') {
$this->Template->isRTL = true;
}
// HOOK: modify the page or layout object
if (isset($GLOBALS['TL_HOOKS']['generatePage']) && is_array($GLOBALS['TL_HOOKS']['generatePage'])) {
foreach ($GLOBALS['TL_HOOKS']['generatePage'] as $callback) {
$this->import($callback[0]);
$this->{$callback[0]}->{$callback[1]}($objPage, $objLayout, $this);
}
}
// Set the page title and description AFTER the modules have been generated
$this->Template->mainTitle = $objPage->rootPageTitle;
$this->Template->pageTitle = $objPage->pageTitle ?: $objPage->title;
// Meta robots tag
//.........这里部分代码省略.........
示例2: generate
/**
* Generate a regular page
* @param object
*/
public function generate($objPage)
{
$GLOBALS['TL_KEYWORDS'] = '';
$GLOBALS['TL_LANGUAGE'] = $objPage->language;
$this->loadLanguageFile('default');
// Static URLs
$this->setStaticUrl('TL_FILES_URL', $objPage->staticFiles);
$this->setStaticUrl('TL_SCRIPT_URL', $objPage->staticSystem);
$this->setStaticUrl('TL_PLUGINS_URL', $objPage->staticPlugins);
// Get the page layout
$objLayout = $this->getPageLayout($objPage);
$objPage->template = $objLayout->template ?: 'fe_page';
$objPage->templateGroup = $objLayout->getRelated('pid')->templates;
// Store the output format
list($strFormat, $strVariant) = explode('_', $objLayout->doctype);
$objPage->outputFormat = $strFormat;
$objPage->outputVariant = $strVariant;
// Initialize the template
$this->createTemplate($objPage, $objLayout);
// Initialize modules and sections
$arrCustomSections = array();
$arrSections = array('header', 'left', 'right', 'main', 'footer');
$arrModules = deserialize($objLayout->modules);
// Get all modules in a single DB query
$arrModuleIds = array_map(function ($arr) {
return $arr['mod'];
}, $arrModules);
$objModules = \ModuleModel::findMultipleByIds($arrModuleIds);
if ($objModules !== null || $arrModules[0]['mod'] == 0) {
foreach ($arrModules as $arrModule) {
// Replace the module ID with the result row
if ($arrModule['mod'] > 0) {
$objModules->next();
$arrModule['mod'] = $objModules;
}
// Generate the modules
if (in_array($arrModule['col'], $arrSections)) {
// Filter active sections (see #3273)
if ($arrModule['col'] == 'header' && $objLayout->rows != '2rwh' && $objLayout->rows != '3rw') {
continue;
}
if ($arrModule['col'] == 'left' && $objLayout->cols != '2cll' && $objLayout->cols != '3cl') {
continue;
}
if ($arrModule['col'] == 'right' && $objLayout->cols != '2clr' && $objLayout->cols != '3cl') {
continue;
}
if ($arrModule['col'] == 'footer' && $objLayout->rows != '2rwf' && $objLayout->rows != '3rw') {
continue;
}
$this->Template->{$arrModule}['col'] .= $this->getFrontendModule($arrModule['mod'], $arrModule['col']);
} else {
$arrCustomSections[$arrModule['col']] .= $this->getFrontendModule($arrModule['mod'], $arrModule['col']);
}
}
}
$this->Template->sections = $arrCustomSections;
// HOOK: modify the page or layout object
if (isset($GLOBALS['TL_HOOKS']['generatePage']) && is_array($GLOBALS['TL_HOOKS']['generatePage'])) {
foreach ($GLOBALS['TL_HOOKS']['generatePage'] as $callback) {
$this->import($callback[0]);
$this->{$callback}[0]->{$callback}[1]($objPage, $objLayout, $this);
}
}
// Set the page title and description AFTER the modules have been generated
$this->Template->mainTitle = $objPage->rootTitle;
$this->Template->pageTitle = $objPage->pageTitle ?: $objPage->title;
// Meta robots tag
$this->Template->robots = $objPage->robots ?: 'index,follow';
// Remove shy-entities (see #2709)
$this->Template->mainTitle = str_replace('[-]', '', $this->Template->mainTitle);
$this->Template->pageTitle = str_replace('[-]', '', $this->Template->pageTitle);
// Assign the title (backwards compatibility)
$this->Template->title = $this->Template->mainTitle . ' - ' . $this->Template->pageTitle;
$this->Template->description = str_replace(array("\n", "\r", '"'), array(' ', '', ''), $objPage->description);
// Body onload and body classes
$this->Template->onload = trim($objLayout->onload);
$this->Template->class = trim($objLayout->cssClass . ' ' . $objPage->cssClass);
// HOOK: extension "bodyclass"
if (in_array('bodyclass', $this->Config->getActiveModules())) {
if (strlen($objPage->cssBody)) {
$this->Template->class .= ' ' . $objPage->cssBody;
}
}
// Execute AFTER the modules have been generated and create footer scripts first
$this->createFooterScripts($objPage, $objLayout);
$this->createHeaderScripts($objPage, $objLayout);
// Print the template to the screen
$this->Template->output();
}