1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27:
28: 29: 30: 31: 32: 33: 34:
35: class Mage_Cms_Block_Page extends Mage_Core_Block_Abstract
36: {
37: 38: 39: 40: 41:
42: public function getPage()
43: {
44: if (!$this->hasData('page')) {
45: if ($this->getPageId()) {
46: $page = Mage::getModel('cms/page')
47: ->setStoreId(Mage::app()->getStore()->getId())
48: ->load($this->getPageId(), 'identifier');
49: } else {
50: $page = Mage::getSingleton('cms/page');
51: }
52: $this->setData('page', $page);
53: }
54: return $this->getData('page');
55: }
56:
57: 58: 59: 60: 61:
62: protected function _prepareLayout()
63: {
64: $page = $this->getPage();
65:
66:
67: if (Mage::getStoreConfig('web/default/show_cms_breadcrumbs')
68: && ($breadcrumbs = $this->getLayout()->getBlock('breadcrumbs'))
69: && ($page->getIdentifier()!==Mage::getStoreConfig('web/default/cms_home_page'))
70: && ($page->getIdentifier()!==Mage::getStoreConfig('web/default/cms_no_route'))) {
71: $breadcrumbs->addCrumb('home', array('label'=>Mage::helper('cms')->__('Home'), 'title'=>Mage::helper('cms')->__('Go to Home Page'), 'link'=>Mage::getBaseUrl()));
72: $breadcrumbs->addCrumb('cms_page', array('label'=>$page->getTitle(), 'title'=>$page->getTitle()));
73: }
74:
75: $root = $this->getLayout()->getBlock('root');
76: if ($root) {
77: $root->addBodyClass('cms-'.$page->getIdentifier());
78: }
79:
80: $head = $this->getLayout()->getBlock('head');
81: if ($head) {
82: $head->setTitle($page->getTitle());
83: $head->setKeywords($page->getMetaKeywords());
84: $head->setDescription($page->getMetaDescription());
85: }
86:
87: return parent::_prepareLayout();
88: }
89:
90: 91: 92: 93: 94:
95: protected function _toHtml()
96: {
97:
98: $helper = Mage::helper('cms');
99: $processor = $helper->getPageTemplateProcessor();
100: $html = $processor->filter($this->getPage()->getContent());
101: $html = $this->getMessagesBlock()->toHtml() . $html;
102: return $html;
103: }
104: }
105: