本文整理汇总了PHP中PageModel::findPublishedById方法的典型用法代码示例。如果您正苦于以下问题:PHP PageModel::findPublishedById方法的具体用法?PHP PageModel::findPublishedById怎么用?PHP PageModel::findPublishedById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageModel
的用法示例。
在下文中一共展示了PageModel::findPublishedById方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* 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);
}
示例2: generate
/**
* 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);
}
示例3: compile
/**
* 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;
}
示例4: generate
/**
* Generate an error 404 page
*
* @param integer $pageId
* @param string $strDomain
* @param string $strHost
* @param boolean $blnUnusedGet
*/
public function generate($pageId, $strDomain = null, $strHost = null, $blnUnusedGet = false)
{
// Add a log entry
if ($blnUnusedGet) {
$this->log('The request for page ID "' . $pageId . '" contained unused GET parameters: "' . implode('", "', \Input::getUnusedGet()) . '" (' . \Environment::get('base') . \Environment::get('request') . ')', __METHOD__, TL_ERROR);
} elseif ($strDomain !== null || $strHost !== null) {
$this->log('Page ID "' . $pageId . '" was requested via "' . $strHost . '" but can only be accessed via "' . $strDomain . '" (' . \Environment::get('base') . \Environment::get('request') . ')', __METHOD__, TL_ERROR);
} elseif ($pageId != 'favicon.ico' && $pageId != 'robots.txt') {
$this->log('No active page for page ID "' . $pageId . '", host "' . \Environment::get('host') . '" and languages "' . implode(', ', \Environment::get('httpAcceptLanguage')) . '" (' . \Environment::get('base') . \Environment::get('request') . ')', __METHOD__, TL_ERROR);
}
// Check the search index (see #3761)
\Search::removeEntry(\Environment::get('request'));
// Find the matching root page
$objRootPage = $this->getRootPageFromUrl();
// Forward if the language should be but is not set (see #4028)
if (\Config::get('addLanguageToUrl')) {
// Get the request string without the index.php fragment
if (\Environment::get('request') == 'index.php') {
$strRequest = '';
} else {
$strRequest = str_replace('index.php/', '', \Environment::get('request'));
}
// Only redirect if there is no language fragment (see #4669)
if ($strRequest != '' && !preg_match('@^[a-z]{2}(-[A-Z]{2})?/@', $strRequest)) {
// Handle language fragments without trailing slash (see #7666)
if (preg_match('@^[a-z]{2}(-[A-Z]{2})?$@', $strRequest)) {
$this->redirect(($GLOBALS['TL_CONFIG']['rewriteURL'] ? '' : 'index.php/') . $strRequest . '/', 301);
} else {
$this->redirect(($GLOBALS['TL_CONFIG']['rewriteURL'] ? '' : 'index.php/') . $objRootPage->language . '/' . $strRequest, 301);
}
}
}
// Look for a 404 page
$obj404 = \PageModel::find404ByPid($objRootPage->id);
// Die if there is no page at all
if (null === $obj404) {
header('HTTP/1.1 404 Not Found');
die_nicely('be_no_page', 'Page not found');
}
// Generate the error page
if (!$obj404->autoforward || !$obj404->jumpTo) {
/** @var \PageModel $objPage */
global $objPage;
$objPage = $obj404->loadDetails();
/** @var \PageRegular $objHandler */
$objHandler = new $GLOBALS['TL_PTY']['regular']();
header('HTTP/1.1 404 Not Found');
$objHandler->generate($objPage);
exit;
}
// Forward to another page
$objNextPage = \PageModel::findPublishedById($obj404->jumpTo);
if (null === $objNextPage) {
header('HTTP/1.1 404 Not Found');
$this->log('Forward page ID "' . $obj404->jumpTo . '" does not exist', __METHOD__, TL_ERROR);
die_nicely('be_no_forward', 'Forward page not found');
}
$this->redirect($this->generateFrontendUrl($objNextPage->row(), null, $objRootPage->language), $obj404->redirect == 'temporary' ? 302 : 301);
}
示例5: generate
/**
* Generate an error 404 page
* @param integer
* @param string
* @param string
*/
public function generate($pageId, $strDomain = null, $strHost = null)
{
// Add a log entry
if ($strDomain !== null || $strHost !== null) {
$this->log('Page ID "' . $pageId . '" can only be accessed via domain "' . $strDomain . '" (current request via "' . $strHost . '")', 'PageError404 generate()', TL_ERROR);
} elseif ($pageId != 'favicon.ico' && $pageId != 'robots.txt') {
$this->log('No active page for page ID "' . $pageId . '", host "' . \Environment::get('host') . '" and languages "' . implode(', ', \Environment::get('httpAcceptLanguage')) . '" (' . \Environment::get('base') . \Environment::get('request') . ')', 'PageError404 generate()', TL_ERROR);
}
// Check the search index (see #3761)
\Search::removeEntry(\Environment::get('request'));
// Find the matching root page
$objRootPage = $this->getRootPageFromUrl();
// Forward if the language should be but is not set (see #4028)
if ($GLOBALS['TL_CONFIG']['addLanguageToUrl']) {
// Get the request string without the index.php fragment
if (\Environment::get('request') == 'index.php') {
$strRequest = '';
} else {
$strRequest = str_replace('index.php/', '', \Environment::get('request'));
}
// Only redirect if there is no language fragment (see #4669)
if ($strRequest != '' && !preg_match('@^[a-z]{2}/@', $strRequest)) {
$this->redirect($objRootPage->language . '/' . \Environment::get('request'), 301);
}
}
// Look for an 404 page
$obj404 = \PageModel::find404ByPid($objRootPage->id);
// Die if there is no page at all
if ($obj404 === null) {
header('HTTP/1.1 404 Not Found');
die('Page not found');
}
// Generate the error page
if (!$obj404->autoforward || !$obj404->jumpTo) {
global $objPage;
$objPage = $this->getPageDetails($obj404);
$objHandler = new $GLOBALS['TL_PTY']['regular']();
header('HTTP/1.1 404 Not Found');
$objHandler->generate($objPage);
exit;
}
// Forward to another page
$objNextPage = \PageModel::findPublishedById($obj404->jumpTo);
if ($objNextPage === null) {
header('HTTP/1.1 404 Not Found');
$this->log('Forward page ID "' . $obj404->jumpTo . '" does not exist', 'PageError404 generate()', TL_ERROR);
die('Forward page not found');
}
$this->redirect($this->generateFrontendUrl($objNextPage->row(), null, $objRootPage->language), $obj404->redirect == 'temporary' ? 302 : 301);
}
示例6: generate
/**
* Check whether the target page and the article are published
*
* @return string
*/
public function generate()
{
$objArticle = \ArticleModel::findPublishedById($this->article);
if ($objArticle === null) {
return '';
}
// Use findPublished() instead of getRelated()
$objParent = \PageModel::findPublishedById($objArticle->pid);
if ($objParent === null) {
return '';
}
$this->objArticle = $objArticle;
$this->objParent = $objParent;
return parent::generate();
}
示例7: handle403
/**
* {@inheritdoc}
*/
public function handle403($pageId, \PageModel $rootPage)
{
if ($rootPage->browser_auth_basic_realm && !FE_USER_LOGGED_IN) {
$authenticate = <<<EOF
WWW-Authenticate: Basic realm="{$rootPage->browser_auth_basic_realm}"
EOF;
header('HTTP/1.1 401 Unauthorized');
header($authenticate);
// Look for an error_403 page
$obj403 = \PageModel::find403ByPid($rootPage->id);
// Die if there is no page at all
if ($obj403 === null) {
echo '403 Forbidden';
exit;
}
// Generate the error page
if (!$obj403->autoforward || !$obj403->jumpTo) {
global $objPage;
$objPage = $obj403->loadDetails();
$objHandler = new $GLOBALS['TL_PTY']['regular']();
$objHandler->generate($objPage);
exit;
}
// Forward to another page
$nextPage = \PageModel::findPublishedById($obj403->jumpTo);
if ($nextPage === null) {
$this->log('Forward page ID "' . $obj403->jumpTo . '" does not exist', 'PageError403 generate()', TL_ERROR);
die('Forward page not found');
}
$url = \Environment::get('base') . \Controller::generateFrontendUrl($nextPage->row(), null, $rootPage->language);
echo <<<EOF
<!DOCTYPE html>
<html lang="de">
<head>
<meta http-equiv="refresh" content="5; URL={$url}">
</head>
<body>
Redirecting to <a href="{$url}">{$url}</a>
</body>
</html>
EOF;
exit;
}
}
示例8: generate
/**
* Generate an error 403 page
*
* @param integer $pageId
* @param \PageModel $objRootPage
*/
public function generate($pageId, $objRootPage = null)
{
// Add a log entry
$this->log('Access to page ID "' . $pageId . '" denied', __METHOD__, 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 a 403 page
$obj403 = \PageModel::find403ByPid($objRootPage->id);
// Die if there is no page at all
if (null === $obj403) {
header('HTTP/1.1 403 Forbidden');
die_nicely('be_forbidden', 'Forbidden');
}
// Generate the error page
if (!$obj403->autoforward || !$obj403->jumpTo) {
/** @var \PageModel $objPage */
global $objPage;
// Die nicely if the page is a 403 page already (see #8060)
if ($objPage && $objPage->type == 'error_403') {
header('HTTP/1.1 403 Forbidden');
die_nicely('be_forbidden', 'Forbidden');
}
$objPage = $obj403->loadDetails();
/** @var \PageRegular $objHandler */
$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 (null === $objNextPage) {
header('HTTP/1.1 403 Forbidden');
$this->log('Forward page ID "' . $obj403->jumpTo . '" does not exist', __METHOD__, TL_ERROR);
die_nicely('be_no_forward', 'Forward page not found');
}
$this->redirect($this->generateFrontendUrl($objNextPage->loadDetails()->row(), null, $objRootPage->language, true), $obj403->redirect == 'temporary' ? 302 : 301);
}
示例9: parseArticlesHook
public function parseArticlesHook(&$objTemplate, $arrArticle, $objModule)
{
if (!($objModule->useModal && $arrArticle['source'] == 'default')) {
return false;
}
$objJumpTo = \PageModel::findPublishedById($objTemplate->archive->jumpTo);
if ($objJumpTo === null || !$objJumpTo->linkModal) {
return false;
}
$objModal = ModalModel::findPublishedByIdOrAlias($objJumpTo->modal);
if ($objModal === null) {
return false;
}
$objJumpTo = \PageModel::findWithDetails($objJumpTo->id);
$arrConfig = ModalController::getModalConfig($objModal->current(), $objJumpTo->layout);
$blnAjax = true;
$blnRedirect = true;
$objTemplate->link = ModalController::generateModalUrl($arrArticle, $objTemplate->archive->jumpTo, $blnAjax, $blnRedirect);
$objTemplate->linkHeadline = ModalController::convertLinkToModalLink($objTemplate->linkHeadline, $objTemplate->link, $arrConfig, $blnRedirect);
$objTemplate->more = ModalController::convertLinkToModalLink($objTemplate->more, $objTemplate->link, $arrConfig, $blnRedirect);
}
示例10: generate
public function generate($pageId, $rootPage = null)
{
// Use the given root page object if available (thanks to Andreas Schempp)
if ($rootPage === null) {
$rootPage = $this->getRootPageFromUrl();
} else {
$rootPage = \PageModel::findPublishedById(is_integer($rootPage) ? $rootPage : $rootPage->id);
}
if ($rootPage && $rootPage->browser_auth_enabled) {
if (array_key_exists($rootPage->browser_auth_module, $GLOBALS['BROWSER_AUTH_MODULES'])) {
$this->log('Access to page ID "' . $pageId . '" denied', 'PageAuth generate()', TL_ERROR);
$authModuleClass = $GLOBALS['BROWSER_AUTH_MODULES'][$rootPage->browser_auth_module];
$authModule = new $authModuleClass();
$authModule->handle403($pageId, $rootPage);
} else {
$this->log('Root page ID "' . $rootPage->id . '" does not have a suitable auth module!', 'PageAuth generate()', TL_ERROR);
header('HTTP/1.1 501 Not Implemented');
echo '501 Not Implemented';
exit;
}
}
$page = new static::$page403Class();
$page->generate($pageId, $rootPage);
}
示例11: handleArticle
/**
* Handle articles
* @return bool return true, or false if the articles does not exist
*/
protected function handleArticle()
{
if (($objArticle = \ArticleModel::findPublishedById($this->articleId, array('eager' => true))) === null) {
return false;
}
if (($objTarget = \PageModel::findPublishedById($objArticle->pid)) === null) {
return false;
}
$objTarget = $objTarget->loadDetails();
if ($objTarget->domain != '' && $objTarget->domain != \Environment::get('host')) {
$this->target = true;
}
$strParams = '/articles/' . (!\Config::get('disableAlias') && $objArticle->alias != '' ? $objArticle->alias : $objArticle->id);
$this->setHref(ampersand(\Controller::generateFrontendUrl($objTarget->row(), $strParams, null, $this->target)));
$this->setTitle(sprintf($GLOBALS['TL_LANG']['MSC']['linkteaser']['articleTitle'], $objArticle->title));
$this->setLink(sprintf($this->getLink(), $objArticle->title));
return true;
}
示例12: jumpToOrReload
/**
* Redirect to a jumpTo page or reload the current page
*
* @param integer|array $intId
* @param string $strParams
* @param string $strForceLang
*/
protected function jumpToOrReload($intId, $strParams = null, $strForceLang = null)
{
/** @var \PageModel $objPage */
global $objPage;
// Always redirect if there are additional arguments (see #5734)
$blnForceRedirect = $strParams !== null || $strForceLang !== null;
if (is_array($intId)) {
if ($intId['id'] != '') {
if ($intId['id'] != $objPage->id || $blnForceRedirect) {
$this->redirect($this->generateFrontendUrl($intId, $strParams, $strForceLang));
}
}
} elseif ($intId > 0) {
if ($intId != $objPage->id || $blnForceRedirect) {
if (($objNextPage = \PageModel::findPublishedById($intId)) !== null) {
$this->redirect($this->generateFrontendUrl($objNextPage->row(), $strParams, $strForceLang));
}
}
}
$this->reload();
}
示例13: canCheckout
/**
* Check if the checkout can be executed
*
* @return bool
*/
protected function canCheckout()
{
// Redirect to login page if not logged in
if ($this->iso_checkout_method == 'member' && FE_USER_LOGGED_IN !== true) {
/** @type \PageModel $objJump */
$objJump = \PageModel::findPublishedById($this->iso_login_jumpTo);
if (null === $objJump) {
$this->Template = new \Isotope\Template('mod_message');
$this->Template->type = 'error';
$this->Template->message = $GLOBALS['TL_LANG']['ERR']['isoLoginRequired'];
return false;
}
$objJump->loadDetails();
\Controller::redirect($objJump->getFrontendUrl(null, $objJump->language));
} elseif ($this->iso_checkout_method == 'guest' && FE_USER_LOGGED_IN === true) {
$this->Template = new \Isotope\Template('mod_message');
$this->Template->type = 'error';
$this->Template->message = $GLOBALS['TL_LANG']['ERR']['checkoutNotAllowed'];
return false;
}
// Return error message if cart is empty
if (Isotope::getCart()->isEmpty()) {
$this->Template = new \Isotope\Template('mod_message');
$this->Template->type = 'empty';
$this->Template->message = $GLOBALS['TL_LANG']['MSC']['noItemsInCart'];
return false;
}
// Insufficient cart subtotal
if (Isotope::getCart()->hasErrors()) {
if ($this->iso_cart_jumpTo > 0) {
/** @type \PageModel $objJump */
$objJump = \PageModel::findPublishedById($this->iso_cart_jumpTo);
if (null !== $objJump) {
$objJump->loadDetails();
\Controller::redirect($objJump->getFrontendUrl(null, $objJump->language));
}
}
$this->Template = new \Isotope\Template('mod_message');
$this->Template->type = 'error';
$this->Template->message = implode("</p>\n<p class=\"error message\">", Isotope::getCart()->getErrors());
return false;
}
return true;
}
示例14: activateOrDelete
/**
* activateOrDelete
*/
protected function activateOrDelete()
{
$dbChange = false;
$objComments = \CommentsModel::findByActivation_token(\Input::get('activation_token'));
if ($objComments === NULL) {
die(utf8_decode($GLOBALS['TL_LANG']['MOD']['member_rating']['invalidToken']));
}
// delete or publish comment via url, received from a notification email
if (\Input::get('del') == 'true') {
$dbChange = true;
$this->log('DELETE FROM tl_comments WHERE id=' . $objComments->id, __METHOD__, TL_GENERAL);
$objComments->delete();
$msg = $GLOBALS['TL_LANG']['MOD']['member_rating']['itemHasBeenActivated'];
if (($objNextPage = \PageModel::findPublishedById($this->emailNotifyPage_DeleteComment)) !== NULL) {
$this->redirect($this->generateFrontendUrl($objNextPage->row()));
}
} elseif (\Input::get('publish') == 'true') {
$dbChange = true;
$objComments->published = 1;
$objComments->activation_token = '';
$objComments->save();
$this->log('A new version of tl_comments ID ' . $objComments->id . ' has been created', __METHOD__, TL_GENERAL);
$msg = $GLOBALS['TL_LANG']['MOD']['member_rating']['itemHasBeenActivated'];
if (($objNextPage = \PageModel::findPublishedById($this->emailNotifyPage_ActivateComment)) !== NULL) {
$this->redirect($this->generateFrontendUrl($objNextPage->row()));
}
} else {
//
}
if ($dbChange === true) {
die($msg);
}
exit;
}
示例15: checkBeforeCheckout
/**
* @category ISO_HOOKS: preCheckout
*
* @param ProductCollection\Order $order
* @param Checkout $checkout
*
* @return bool
*/
public function checkBeforeCheckout(ProductCollection\Order $order, Checkout $checkout)
{
foreach ($order->getItems() as $item) {
/** @var Product|\Model $product */
$product = $item->getProduct();
$productType = $product->getRelated('type');
$stock = Stock::getStockForProduct($product->id);
if ($productType->stockmanagement_active && false !== $stock && $item->quantity > $stock) {
Message::addError($GLOBALS['TL_LANG']['MSC']['simpleStockmanagement']['productQuantityUnavailable']);
if ($checkout->iso_cart_jumpTo > 0) {
/** @type \PageModel $jumpTo */
$jumpTo = \PageModel::findPublishedById($checkout->iso_cart_jumpTo);
if (null !== $jumpTo) {
$jumpTo->loadDetails();
\Controller::redirect($jumpTo->getFrontendUrl(null, $jumpTo->language));
}
}
return false;
}
}
return true;
}