00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class Mage_Cms_Helper_Page extends Mage_Core_Helper_Abstract
00036 {
00037 const XML_PATH_NO_ROUTE_PAGE = 'web/default/cms_no_route';
00038 const XML_PATH_NO_COOKIES_PAGE = 'web/default/cms_no_cookies';
00039 const XML_PATH_HOME_PAGE = 'web/default/cms_home_page';
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 public function renderPage(Mage_Core_Controller_Front_Action $action, $pageId = null)
00051 {
00052 $page = Mage::getSingleton('cms/page');
00053 if (!is_null($pageId) && $pageId!==$page->getId()) {
00054 $page->setStoreId(Mage::app()->getStore()->getId());
00055 if (!$page->load($pageId)) {
00056 return false;
00057 }
00058 }
00059
00060 if (!$page->getId()) {
00061 return false;
00062 }
00063
00064 if ($page->getCustomTheme()) {
00065 if (Mage::app()->getLocale()->IsStoreDateInInterval(null, $page->getCustomThemeFrom(), $page->getCustomThemeTo())) {
00066 list($package, $theme) = explode('/', $page->getCustomTheme());
00067 Mage::getSingleton('core/design_package')
00068 ->setPackageName($package)
00069 ->setTheme($theme);
00070 }
00071 }
00072
00073 $action->getLayout()->getUpdate()
00074 ->addHandle('default')
00075 ->addHandle('cms_page');
00076
00077 $action->addActionLayoutHandles();
00078 if ($page->getRootTemplate()) {
00079 $action->getLayout()->helper('page/layout')
00080 ->applyHandle($page->getRootTemplate());
00081 }
00082
00083 $action->loadLayoutUpdates();
00084 $action->getLayout()->getUpdate()->addUpdate($page->getLayoutUpdateXml());
00085 $action->generateLayoutXml()->generateLayoutBlocks();
00086
00087 if ($page->getRootTemplate()) {
00088 $action->getLayout()->helper('page/layout')
00089 ->applyTemplate($page->getRootTemplate());
00090 }
00091
00092 if ($storage = Mage::getSingleton('catalog/session')) {
00093 $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
00094 }
00095
00096 if ($storage = Mage::getSingleton('checkout/session')) {
00097 $action->getLayout()->getMessagesBlock()->addMessages($storage->getMessages(true));
00098 }
00099
00100 $action->renderLayout();
00101
00102 return true;
00103 }
00104
00105
00106
00107
00108
00109
00110
00111 public function getPageUrl($pageId = null)
00112 {
00113 $page = Mage::getSingleton('cms/page');
00114 if (!is_null($pageId) && $pageId !== $page->getId()) {
00115 $page->setStoreId(Mage::app()->getStore()->getId());
00116 if (!$page->load($pageId)) {
00117 return null;
00118 }
00119 }
00120
00121 if (!$page->getId()) {
00122 return null;
00123 }
00124
00125 return Mage::getUrl(null, array('_direct' => $page->getIdentifier()));
00126 }
00127 }