1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Cms
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27:
28: /**
29: * Cms Page Model
30: *
31: * @method Mage_Cms_Model_Resource_Page _getResource()
32: * @method Mage_Cms_Model_Resource_Page getResource()
33: * @method string getTitle()
34: * @method Mage_Cms_Model_Page setTitle(string $value)
35: * @method string getRootTemplate()
36: * @method Mage_Cms_Model_Page setRootTemplate(string $value)
37: * @method string getMetaKeywords()
38: * @method Mage_Cms_Model_Page setMetaKeywords(string $value)
39: * @method string getMetaDescription()
40: * @method Mage_Cms_Model_Page setMetaDescription(string $value)
41: * @method string getIdentifier()
42: * @method Mage_Cms_Model_Page setIdentifier(string $value)
43: * @method string getContentHeading()
44: * @method Mage_Cms_Model_Page setContentHeading(string $value)
45: * @method string getContent()
46: * @method Mage_Cms_Model_Page setContent(string $value)
47: * @method string getCreationTime()
48: * @method Mage_Cms_Model_Page setCreationTime(string $value)
49: * @method string getUpdateTime()
50: * @method Mage_Cms_Model_Page setUpdateTime(string $value)
51: * @method int getIsActive()
52: * @method Mage_Cms_Model_Page setIsActive(int $value)
53: * @method int getSortOrder()
54: * @method Mage_Cms_Model_Page setSortOrder(int $value)
55: * @method string getLayoutUpdateXml()
56: * @method Mage_Cms_Model_Page setLayoutUpdateXml(string $value)
57: * @method string getCustomTheme()
58: * @method Mage_Cms_Model_Page setCustomTheme(string $value)
59: * @method string getCustomRootTemplate()
60: * @method Mage_Cms_Model_Page setCustomRootTemplate(string $value)
61: * @method string getCustomLayoutUpdateXml()
62: * @method Mage_Cms_Model_Page setCustomLayoutUpdateXml(string $value)
63: * @method string getCustomThemeFrom()
64: * @method Mage_Cms_Model_Page setCustomThemeFrom(string $value)
65: * @method string getCustomThemeTo()
66: * @method Mage_Cms_Model_Page setCustomThemeTo(string $value)
67: *
68: * @category Mage
69: * @package Mage_Cms
70: * @author Magento Core Team <core@magentocommerce.com>
71: */
72: class Mage_Cms_Model_Page extends Mage_Core_Model_Abstract
73: {
74: const NOROUTE_PAGE_ID = 'no-route';
75:
76: /**
77: * Page's Statuses
78: */
79: const STATUS_ENABLED = 1;
80: const STATUS_DISABLED = 0;
81:
82: const CACHE_TAG = 'cms_page';
83: protected $_cacheTag = 'cms_page';
84:
85: /**
86: * Prefix of model events names
87: *
88: * @var string
89: */
90: protected $_eventPrefix = 'cms_page';
91:
92: /**
93: * Initialize resource model
94: *
95: */
96: protected function _construct()
97: {
98: $this->_init('cms/page');
99: }
100:
101: /**
102: * Load object data
103: *
104: * @param mixed $id
105: * @param string $field
106: * @return Mage_Cms_Model_Page
107: */
108: public function load($id, $field=null)
109: {
110: if (is_null($id)) {
111: return $this->noRoutePage();
112: }
113: return parent::load($id, $field);
114: }
115:
116: /**
117: * Load No-Route Page
118: *
119: * @return Mage_Cms_Model_Page
120: */
121: public function noRoutePage()
122: {
123: return $this->load(self::NOROUTE_PAGE_ID, $this->getIdFieldName());
124: }
125:
126: /**
127: * Check if page identifier exist for specific store
128: * return page id if page exists
129: *
130: * @param string $identifier
131: * @param int $storeId
132: * @return int
133: */
134: public function checkIdentifier($identifier, $storeId)
135: {
136: return $this->_getResource()->checkIdentifier($identifier, $storeId);
137: }
138:
139: /**
140: * Prepare page's statuses.
141: * Available event cms_page_get_available_statuses to customize statuses.
142: *
143: * @return array
144: */
145: public function getAvailableStatuses()
146: {
147: $statuses = new Varien_Object(array(
148: self::STATUS_ENABLED => Mage::helper('cms')->__('Enabled'),
149: self::STATUS_DISABLED => Mage::helper('cms')->__('Disabled'),
150: ));
151:
152: Mage::dispatchEvent('cms_page_get_available_statuses', array('statuses' => $statuses));
153:
154: return $statuses->getData();
155: }
156: }
157: