本文整理汇总了PHP中PageModel::findBy方法的典型用法代码示例。如果您正苦于以下问题:PHP PageModel::findBy方法的具体用法?PHP PageModel::findBy怎么用?PHP PageModel::findBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageModel
的用法示例。
在下文中一共展示了PageModel::findBy方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPages
/**
* 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();
}
}
示例2: getRootPages
public function getRootPages(\DataContainer $dc)
{
$arrOptions = array();
$objPages = \PageModel::findBy('type', 'root');
if ($objPages === null) {
return $arrOptions;
}
return $objPages->fetchEach('title');
}
示例3: generate
/**
* Return if there are no files
* @return string
*/
public function generate()
{
global $objPage;
$pageGlossar = explode('|', $objPage->glossar);
$Page = \PageModel::findBy(array("glossar LIKE '%|" . implode("|%' OR glossar LIKE '%|", $pageGlossar) . "|%'"), array());
if (empty($Page)) {
return;
}
$countTerms = array();
$arrPages = array();
while ($Page->next()) {
$ap = array('id' => $Page->id, 'weight' => 0, 'title' => $Page->title, 'description' => $Page->description, 'glossar' => explode('|', $Page->glossar), 'fallback_glossar' => explode('|', $Page->fallback_glossar), 'url' => $this->generateFrontendUrl($Page->row()));
foreach ($ap['glossar'] as $term) {
if ($term != '') {
$countTerms[$term] = !empty($term) ? $countTerms[$term] + 1 : 1;
}
}
if ($ap['id'] != $objPage->id) {
$arrPages[] = $ap;
}
}
asort($countTerms);
$this->countTerms = $countTerms;
$max = 0;
foreach ($arrPages as &$p_page) {
foreach ($countTerms as $term => $count) {
if (in_array($term, $p_page['glossar'])) {
$p_page['weight']++;
}
}
if ($p_page['weight'] > $max) {
$max = $p_page['weight'];
}
}
$this->max = $max;
foreach ($arrPages as &$p_page) {
$x = $p_page['weight'] / $max;
$p_page['weight'] = 1 + $x;
}
$this->pages = $arrPages;
if (!isset($_GET['items']) && $GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) {
\Input::setGet('items', \Input::get('auto_item'));
}
if (!isset($_GET['alpha']) && $GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) {
\Input::setGet('alpha', \Input::get('auto_item'));
}
return parent::generate();
}
示例4: prepare
/**
* prepare
*/
public function prepare()
{
// load backend user
$this->import('BackendUser', 'User');
// check permission
if ($this->User->isAdmin || $this->User->hasAccess('page', 'modules') && isset($this->User->pagemounts) && is_array($this->User->pagemounts)) {
// check if table exists
if (!$this->Database->tableExists('tl_page')) {
return;
}
// get all existing root pages
$objPages = \PageModel::findBy('type', 'root', array('order' => 'title'));
// there are at minimum two pages
if (!is_null($objPages) && $objPages->count() > 1) {
// prepare directentry array
$arrDirectEntry = array();
// set counter
$intCounter = 1;
// do this foreach page
while ($objPages->next()) {
// check page permission
if ($this->User->isAdmin || in_array($objPages->id, $this->User->pagemounts)) {
if (version_compare(VERSION, '3.5', '<')) {
$strQuery = http_build_query(['do' => 'page', 'node' => $objPages->id]);
} else {
$strQuery = http_build_query(['do' => 'page', 'node' => $objPages->id, 'pn' => $objPages->id]);
}
// set the icon url and title
$arrDirectEntry[$intCounter]['icons']['page']['url'] = 'contao/main.php?' . $strQuery;
$arrDirectEntry[$intCounter]['icons']['page']['title'] = 'page';
$arrDirectEntry[$intCounter]['icons']['page']['icon'] = 'page';
// set the page url and title
$arrDirectEntry[$intCounter]['name']['url'] = 'contao/main.php?' . $strQuery;
$arrDirectEntry[$intCounter]['name']['title'] = $objPages->title;
$arrDirectEntry[$intCounter]['name']['link'] = strlen($objPages->title) > 17 ? substr($objPages->title, 0, 15) . '...' : $objPages->title;
// add one to counter
$intCounter++;
}
}
// add to direcentries service
$this->import('DirectEntries');
$this->DirectEntries->addDirectEntry('design', 'page', $arrDirectEntry);
}
}
}
示例5: languageLabels
public function languageLabels($row, $label, $dc = null, $imageAttribute = '', $blnReturnImage = false, $blnProtected = false)
{
// generate the default label
$objDcaClass = null;
if (in_array('cacheicon', ModuleLoader::getActive())) {
$objDcaClass = new tl_page_cacheicon();
} elseif (in_array('Avisota', ModuleLoader::getActive())) {
$objDcaClass = new tl_page_avisota();
} else {
$objDcaClass = new tl_page();
}
$label = $objDcaClass->addIcon($row, $label, $dc, $imageAttribute, $blnReturnImage, $blnProtected);
// return the label for root or folder page
if ($row['type'] == 'root' || $row['type'] == 'folder') {
return $label;
}
// load the current page
$objPage = PageModel::findWithDetails($row['id']);
// prepare alternate pages
$objAlternates = null;
if ($objPage->languageMain) {
// get all pages referencing the same fallback page
$t = \PageModel::getTable();
$objAlternates = PageModel::findBy(array("{$t}.languageMain = ? OR {$t}.id = ?"), array($objPage->languageMain, $objPage->languageMain));
} else {
// get all pages referencing the current page as its fallback
$objAlternates = PageModel::findByLanguageMain($objPage->id);
}
// check if alternates were found
if ($objAlternates !== null) {
$label .= '<ul class="tl_page_language_alternates">';
// go through each page and add link
while ($objAlternates->next()) {
if ($objAlternates->id == $objPage->id) {
continue;
}
$objAlternates->current()->loadDetails();
$label .= '<li><a href="contao/main.php?do=page&node=' . $objAlternates->id . '&ref=' . TL_REFERER_ID . '">' . $objAlternates->language . '</a></li>';
}
$label .= '</ul>';
}
return $label;
}
示例6: collectItems
public function collectItems(CollectItemsEvent $event)
{
$item = $event->getParentItem();
if ($item->getType() == 'page') {
$table = \PageModel::getTable();
$columns = array("{$table}.pid=?");
if (!BE_USER_LOGGED_IN) {
$time = time();
$columns[] = "({$table}.start='' OR {$table}.start<{$time}) AND ({$table}.stop='' OR {$table}.stop>{$time}) AND {$table}.published=1";
}
$pages = \PageModel::findBy($columns, array($item->getExtra('id')), array('order' => 'sorting'));
if ($pages) {
$factory = $event->getFactory();
foreach ($pages as $page) {
$factory->createItem('page', $page->id, $item);
}
}
}
if ($item->getType() == 'pages') {
$ids = explode(',', $item->getName());
$ids = array_filter($ids);
$table = \PageModel::getTable();
$columns = array('(' . implode(' OR ', array_fill(0, count($ids), "{$table}.id=?")) . ')');
$sorting = "FIELD({$table}.id, " . implode(', ', array_fill(0, count($ids), "?")) . ")";
if (!BE_USER_LOGGED_IN) {
$time = time();
$columns[] = "({$table}.start='' OR {$table}.start<{$time}) AND ({$table}.stop='' OR {$table}.stop>{$time}) AND {$table}.published=1";
}
$pages = \PageModel::findBy($columns, array_merge($ids, $ids), array('order' => $sorting));
if ($pages) {
$factory = $event->getFactory();
foreach ($pages as $page) {
$factory->createItem('page', $page->id, $item);
}
}
}
}
示例7: addProductsToSearchIndex
/**
* Adds the product urls to the array so they get indexed when search index is rebuilt in the maintenance module
*
* @param array $arrPages Absolute page urls
* @param int $intRoot Root page id
* @param bool $blnIsSitemap True if it's a sitemap module call (= treat differently when page is protected etc.)
*
* @return array Extended array of absolute page urls
*/
public function addProductsToSearchIndex($arrPages, $intRoot = 0, $blnIsSitemap = false)
{
$t = \PageModel::getTable();
$time = \Date::floorToMinute();
$arrValue = array();
$arrColumn = array("{$t}.type='root'", "{$t}.published='1'", "({$t}.start='' OR {$t}.start<'{$time}')", "({$t}.stop='' OR {$t}.stop>'" . ($time + 60) . "')");
if ($intRoot > 0) {
$arrColumn[] = "{$t}.id=?";
$arrValue[] = $intRoot;
}
$objRoots = \PageModel::findBy($arrColumn, $arrValue);
if (null !== $objRoots) {
foreach ($objRoots as $objRoot) {
$arrPageIds = \Database::getInstance()->getChildRecords($objRoot->id, $t, false);
$arrPageIds[] = $intRoot;
$objProducts = Product::findPublishedByCategories($arrPageIds);
if (null !== $objProducts) {
foreach ($objProducts as $objProduct) {
// Find the categories in the current root
$arrCategories = array_intersect($objProduct->getCategories(), $arrPageIds);
$intRemaining = count($arrCategories);
foreach ($arrCategories as $intPage) {
$objPage = \PageModel::findByPk($intPage);
--$intRemaining;
// The target page does not exist
if ($objPage === null) {
continue;
}
// The target page has not been published
if (!$objPage->published || $objPage->start != '' && $objPage->start > $time || $objPage->stop != '' && $objPage->stop < $time + 60) {
continue;
}
// The target page is exempt from the sitemap
if ($blnIsSitemap && $objPage->sitemap == 'map_never') {
continue;
}
// Do not generate a reader for the index page, except if it is the only one
if ($intRemaining > 0 && $objPage->alias == 'index') {
continue;
}
// Generate the domain
$strDomain = $objRoot->useSSL ? 'https://' : 'http://';
$strDomain .= ($objRoot->dns ?: \Environment::get('host')) . TL_PATH . '/';
// Pass root language to page object
$objPage->language = $objRoot->language;
$arrPages[] = $strDomain . $objProduct->generateUrl($objPage);
// Only take the first category because this is our primary one
// Having multiple reader pages in the sitemap XML would mean duplicate content
break;
}
}
}
}
}
return array_unique($arrPages);
}
示例8: buildPageTree
protected function buildPageTree(\stdClass $parent, Cache $cache)
{
$pageModels = \PageModel::findBy(['pid=? AND (start=? OR start<?) AND (stop=? OR stop>?) AND published=?'], [$parent->id, '', time(), '', time(), 1], ['order' => 'sorting']);
if ($pageModels) {
foreach ($pageModels as $pageModel) {
$pageObject = new \stdClass();
$pageObject->id = $pageModel->id;
$pageObject->title = $pageModel->title;
$pageObject->children = new \ArrayObject();
if ($pageModel->theme_plus_disable_assets_cache || in_array($pageModel->type, ['root', 'forward', 'redirect'])) {
$pageObject->hasCache = false;
} else {
$cachedCss = ($raw = $cache->fetch('css:' . $pageModel->id)) ? highlight_string('<?php' . $raw, true) : false;
$cachedHeadJs = ($raw = $cache->fetch('js:head:' . $pageModel->id)) ? highlight_string('<?php' . $raw, true) : false;
$cachedBodyJs = ($raw = $cache->fetch('js:body:' . $pageModel->id)) ? highlight_string('<?php' . $raw, true) : false;
$pageObject->hasCache = true;
$pageObject->cssCache = $cachedCss;
$pageObject->headJsCache = $cachedHeadJs;
$pageObject->bodyJsCache = $cachedBodyJs;
}
$parent->children->append($pageObject);
$this->buildPageTree($pageObject, $cache);
}
}
}
示例9: getDomains
/**
* Retreives all available domains in this installation (plus empty selection)
*
* @return array
*/
public function getDomains()
{
// options array
$options = array('' => $GLOBALS['TL_LANG']['tl_short_urls']['noDomain']);
// get the root pages and their dns settings
if (version_compare(VERSION, '3.5', '>=')) {
if (($objPages = \PageModel::findPublishedRootPages()) !== null) {
while ($objPages->next()) {
if ($objPages->dns) {
$options[$objPages->id] = $objPages->dns;
}
}
}
} else {
$t = \PageModel::getTable();
$arrColumns = array("{$t}.type=?");
if (!BE_USER_LOGGED_IN) {
$time = time();
$arrColumns[] = "({$t}.start='' OR {$t}.start<='{$time}') AND ({$t}.stop='' OR {$t}.stop>'" . ($time + 60) . "') AND {$t}.published='1'";
}
$objPages = \PageModel::findBy($arrColumns, 'root');
if ($objPages !== null) {
while ($objPages->next()) {
if ($objPages->dns) {
$options[$objPages->id] = $objPages->dns;
}
}
}
}
// return the options
return $options;
}
示例10: findCategories
/**
* The ids of all pages we take care of. This is what should later be used eg. for filter data.
*
* @return array
*/
protected function findCategories()
{
if (null === $this->arrCategories) {
if ($this->defineRoot && $this->rootPage > 0) {
$objPage = \PageModel::findWithDetails($this->rootPage);
} else {
global $objPage;
}
$t = \PageModel::getTable();
$arrCategories = null;
$arrUnpublished = array();
$strWhere = "{$t}.type!='error_403' AND {$t}.type!='error_404'";
if (!BE_USER_LOGGED_IN) {
$time = time();
$objUnpublished = \PageModel::findBy(array("({$t}.start!='' AND {$t}.start>{$time}) OR ({$t}.stop!='' AND {$t}.stop<{$time}) OR {$t}.published=?"), array(''));
$arrUnpublished = $objUnpublished->fetchEach('id');
//$strWhere .= " AND ($t.start='' OR $t.start<$time) AND ($t.stop='' OR $t.stop>$time) AND $t.published='1'";
}
switch ($this->iso_category_scope) {
case 'global':
$arrCategories = array($objPage->rootId);
$arrCategories = \Database::getInstance()->getChildRecords($objPage->rootId, 'tl_page', false, $arrCategories, $strWhere);
$arrCategories = array_diff($arrCategories, $arrUnpublished);
break;
case 'current_and_first_child':
$arrCategories = \Database::getInstance()->execute("SELECT id FROM tl_page WHERE pid={$objPage->id} AND {$strWhere}")->fetchEach('id');
$arrCategories[] = $objPage->id;
break;
case 'current_and_all_children':
$arrCategories = array($objPage->id);
$arrCategories = \Database::getInstance()->getChildRecords($objPage->id, 'tl_page', false, $arrCategories, $strWhere);
$arrCategories = array_diff($arrCategories, $arrUnpublished);
break;
case 'parent':
$arrCategories = array($objPage->pid);
break;
case 'product':
/** @var \Isotope\Model\Product\Standard $objProduct */
$objProduct = Product_Model::findAvailableByIdOrAlias(\Haste\Input\Input::getAutoItem('product'));
if ($objProduct !== null) {
$arrCategories = $objProduct->getCategories(true);
} else {
$arrCategories = array(0);
}
break;
case 'article':
$arrCategories = array($GLOBALS['ISO_CONFIG']['current_article']['pid'] ?: $objPage->id);
break;
case '':
case 'current_category':
$arrCategories = array($objPage->id);
break;
default:
if (isset($GLOBALS['ISO_HOOKS']['findCategories']) && is_array($GLOBALS['ISO_HOOKS']['findCategories'])) {
foreach ($GLOBALS['ISO_HOOKS']['findCategories'] as $callback) {
$objCallback = \System::importStatic($callback[0]);
$arrCategories = $objCallback->{$callback}[1]($this);
if ($arrCategories !== false) {
break;
}
}
}
break;
}
$this->arrCategories = empty($arrCategories) ? array(0) : $arrCategories;
}
return $this->arrCategories;
}
示例11: parseCustomizeFrontendTemplate
/**
* Edit the Frontend Template
*/
public function parseCustomizeFrontendTemplate($strContent, $strTemplate)
{
global $objPage;
$isFullpage = $this->isFullPageEnabled($objPage);
if ($strTemplate == "mod_article") {
$sectionHeaderID = 3;
// TODO: verwaltbar machen!!!
$sectionFooterID = 4;
$objArticle = NULL;
$articleClass = array();
$articlePattern = '/<div([A-Za-z0-9\\s\\-_=;",:\\.\\(\\)\'#\\/%]{0,})class="mod_article([A-Za-z0-9\\s\\-_]{0,})"([A-Za-z0-9\\s\\-_=;",:\\.\\(\\)\'#\\/%]{0,})>/';
preg_match_all('/id="([A-Za-z0-9\\-_]{0,})"/', $strContent, $idMatches);
if (is_array($idMatches) && count($idMatches[0]) > 0) {
$objArticle = \ArticleModel::findByIdOrAlias($idMatches[1][0]);
}
if ($isFullpage) {
if ($objArticle) {
if ($objArticle->enableSectionHeader) {
$sectionHeaderID = $objArticle->sectionHeaderModule;
$strContent = preg_replace($articlePattern, '<div$1class="mod_article$2"$3><div class="header section-header">{{insert_module::' . $sectionHeaderID . '}}</div>', $strContent);
}
if ($objArticle->enableSectionFooter) {
$sectionFooterID = $objArticle->sectionFooterModule;
$strContent = preg_replace('/<\\/div>$/', '<div class="footer section-footer">{{insert_module::' . $sectionFooterID . '}}</div></div>', $strContent);
}
if ($objArticle->enableOverlay) {
$strOverlayContent = '';
if ($objArticle->showTitleInOverlay) {
$strArticleTitle = $objArticle->title;
if (strlen($objArticle->alt_title)) {
$strArticleTitle = $objArticle->alt_title;
}
$strOverlayContent = '<div class="overlay-title"><div class="title-inner">' . $strArticleTitle . '</div></div>';
}
$strClass = "";
if ($objArticle->overlayTransparent) {
$strClass = " overlay-trans";
}
$strOverlayTags = '<div class="show-overlay"></div><div class="overlay article-overlay' . $strClass . ' shown"><div class="close"></div>' . $strOverlayContent . '</div>';
$strContent = preg_replace($articlePattern, '<div$1class="mod_article has-overlay$2"$3>', $strContent);
$strContent = preg_replace('/<\\/div>$/', $strOverlayTags . '</div>', $strContent);
}
if ($objArticle->enableFullpageNavigation) {
$navNext = "";
$navPrev = "";
if ($objPage->fullpageDirection == "horizontal") {
// TODO NAVI RIGHT UND LEFT!!
} else {
$navNext = '<div class="navigation-top" onClick="DPS.Fullpage.sectionBack(this);"></div>';
$navPrev = '<div class="navigation-bottom" onClick="DPS.Fullpage.sectionForward(this);"></div>';
}
$navigationTags = '<div class="fullpage-navigation">' . $navNext . $navPrev . '</div>';
// $strContent = preg_replace($articlePattern, '', $strContent);
$strContent = preg_replace('/<\\/div>$/', $navigationTags . '</div>', $strContent);
}
}
if ($objPage->fullpageDirection == "horizontal") {
$articleClass[] = 'slide';
} else {
$articleClass[] = 'section';
}
// $strContent = preg_replace('/<div([A-Za-z0-9\s\-_=;",:\\.\(\)\'#\/%]{0,})class="mod_article([A-Za-z0-9\s\-_]{0,})"([A-Za-z0-9\s\-_=;",:\\.\(\)\'#\/%]{0,})>/', '<div$1class="mod_article$2"$3><div class="article-inner">', $strContent);
// $strContent = $strContent . '</div>';
}
if ($objArticle) {
if ($objArticle->enableBackgroundImage && $objArticle->singleSRC != "") {
$objFile = \FilesModel::findByUuid($objArticle->singleSRC);
if ($objFile === null && !\Validator::isUuid($objArticle->singleSRC)) {
$strContent = '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>' . $strContent;
}
if ($objFile && is_file(TL_ROOT . '/' . $objFile->path)) {
preg_match_all($articlePattern, $strContent, $arrArticleMatches);
if (is_array($arrArticleMatches[0]) && count($arrArticleMatches[0]) > 0) {
$bgPosition = str_replace('_', ' ', $objArticle->backgroundImagePosition);
if (!$bgPosition) {
$bgPosition = "center center";
}
if (preg_match('/style="/', $arrArticleMatches[0][0])) {
$styles = 'background-image:url(\'' . $objFile->path . '\');background-position:' . $bgPosition . ';';
$replStyles = '';
if (preg_match('/style="/', $arrArticleMatches[1][0])) {
$replStyles = str_replace('style="', 'style="' . $styles, $arrArticleMatches[1][0]);
} elseif (preg_match('/style="/', $arrArticleMatches[3][0])) {
$replStyles = str_replace('style="', 'style="' . $styles, $arrArticleMatches[3][0]);
}
$strContent = preg_replace($articlePattern, '<div' . $replStyles . 'class="mod_article$2"$3>', $strContent);
} else {
$strContent = preg_replace($articlePattern, '<div$1class="mod_article$2" style="background-image:url(\'' . $objFile->path . '\');background-position:' . $bgPosition . ';"$3>', $strContent);
}
$strContent = preg_replace($articlePattern, '<div$1class="mod_article has-background-image bg-fixed bg-image bg-cover$2"$3">', $strContent);
}
}
}
if ($objArticle->enableNavigation) {
$articleNavigationTag = '<div class="navigation-container">';
$objAllArticles = \ArticleModel::findBy(array("pid=?", "inColumn=?", "published=?"), array($objArticle->pid, "main", "1"), array("order" => "sorting"));
$nextArticle = false;
//.........这里部分代码省略.........