Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Adminhtml_Cms_PageController
  • Mage_Adminhtml_Model_System_Config_Source_Cms_Wysiwyg_Enabled
  • Mage_Cms_Block_Block
  • Mage_Cms_Block_Page
  • Mage_Cms_Block_Widget_Block
  • Mage_Cms_Block_Widget_Page_Link
  • Mage_Cms_Controller_Router
  • Mage_Cms_Helper_Data
  • Mage_Cms_Helper_Page
  • Mage_Cms_Helper_Wysiwyg_Images
  • Mage_Cms_IndexController
  • Mage_Cms_Model_Block
  • Mage_Cms_Model_Mysql4_Block
  • Mage_Cms_Model_Mysql4_Block_Collection
  • Mage_Cms_Model_Mysql4_Page
  • Mage_Cms_Model_Mysql4_Page_Collection
  • Mage_Cms_Model_Mysql4_Page_Service
  • Mage_Cms_Model_Observer
  • Mage_Cms_Model_Page
  • Mage_Cms_Model_Resource_Block
  • Mage_Cms_Model_Resource_Block_Collection
  • Mage_Cms_Model_Resource_Page
  • Mage_Cms_Model_Resource_Page_Collection
  • Mage_Cms_Model_Resource_Page_Service
  • Mage_Cms_Model_Template_Filter
  • Mage_Cms_Model_Wysiwyg_Config
  • Mage_Cms_Model_Wysiwyg_Images_Storage
  • Mage_Cms_Model_Wysiwyg_Images_Storage_Collection
  • Mage_Cms_PageController
  • Overview
  • Package
  • Class
  • Tree
  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 collection
 30:  *
 31:  * @category    Mage
 32:  * @package     Mage_Cms
 33:  * @author      Magento Core Team <core@magentocommerce.com>
 34:  */
 35: class Mage_Cms_Model_Resource_Page_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
 36: {
 37:     /**
 38:      * Load data for preview flag
 39:      *
 40:      * @var bool
 41:      */
 42:     protected $_previewFlag;
 43: 
 44: 
 45:     /**
 46:      * Define resource model
 47:      *
 48:      */
 49:     protected function _construct()
 50:     {
 51:         $this->_init('cms/page');
 52:         $this->_map['fields']['page_id'] = 'main_table.page_id';
 53:         $this->_map['fields']['store']   = 'store_table.store_id';
 54:     }
 55: 
 56:     /**
 57:      * deprecated after 1.4.0.1, use toOptionIdArray()
 58:      *
 59:      * @return array
 60:      */
 61:     public function toOptionArray()
 62:     {
 63:         return $this->_toOptionArray('identifier', 'title');
 64:     }
 65: 
 66:     /**
 67:      * Returns pairs identifier - title for unique identifiers
 68:      * and pairs identifier|page_id - title for non-unique after first
 69:      *
 70:      * @return array
 71:      */
 72:     public function toOptionIdArray()
 73:     {
 74:         $res = array();
 75:         $existingIdentifiers = array();
 76:         foreach ($this as $item) {
 77:             $identifier = $item->getData('identifier');
 78: 
 79:             $data['value'] = $identifier;
 80:             $data['label'] = $item->getData('title');
 81: 
 82:             if (in_array($identifier, $existingIdentifiers)) {
 83:                 $data['value'] .= '|' . $item->getData('page_id');
 84:             } else {
 85:                 $existingIdentifiers[] = $identifier;
 86:             }
 87: 
 88:             $res[] = $data;
 89:         }
 90: 
 91:         return $res;
 92:     }
 93: 
 94:     /**
 95:      * Set first store flag
 96:      *
 97:      * @param bool $flag
 98:      * @return Mage_Cms_Model_Resource_Page_Collection
 99:      */
100:     public function setFirstStoreFlag($flag = false)
101:     {
102:         $this->_previewFlag = $flag;
103:         return $this;
104:     }
105: 
106:     /**
107:      * Perform operations after collection load
108:      *
109:      * @return Mage_Cms_Model_Resource_Page_Collection
110:      */
111:     protected function _afterLoad()
112:     {
113:         if ($this->_previewFlag) {
114:             $items = $this->getColumnValues('page_id');
115:             $connection = $this->getConnection();
116:             if (count($items)) {
117:                 $select = $connection->select()
118:                         ->from(array('cps'=>$this->getTable('cms/page_store')))
119:                         ->where('cps.page_id IN (?)', $items);
120: 
121:                 if ($result = $connection->fetchPairs($select)) {
122:                     foreach ($this as $item) {
123:                         if (!isset($result[$item->getData('page_id')])) {
124:                             continue;
125:                         }
126:                         if ($result[$item->getData('page_id')] == 0) {
127:                             $stores = Mage::app()->getStores(false, true);
128:                             $storeId = current($stores)->getId();
129:                             $storeCode = key($stores);
130:                         } else {
131:                             $storeId = $result[$item->getData('page_id')];
132:                             $storeCode = Mage::app()->getStore($storeId)->getCode();
133:                         }
134:                         $item->setData('_first_store_id', $storeId);
135:                         $item->setData('store_code', $storeCode);
136:                     }
137:                 }
138:             }
139:         }
140: 
141:         return parent::_afterLoad();
142:     }
143: 
144:     /**
145:      * Add filter by store
146:      *
147:      * @param int|Mage_Core_Model_Store $store
148:      * @param bool $withAdmin
149:      * @return Mage_Cms_Model_Resource_Page_Collection
150:      */
151:     public function addStoreFilter($store, $withAdmin = true)
152:     {
153:         if (!$this->getFlag('store_filter_added')) {
154:             if ($store instanceof Mage_Core_Model_Store) {
155:                 $store = array($store->getId());
156:             }
157: 
158:             if (!is_array($store)) {
159:                 $store = array($store);
160:             }
161: 
162:             if ($withAdmin) {
163:                 $store[] = Mage_Core_Model_App::ADMIN_STORE_ID;
164:             }
165: 
166:             $this->addFilter('store', array('in' => $store), 'public');
167:         }
168:         return $this;
169:     }
170: 
171:     /**
172:      * Join store relation table if there is store filter
173:      */
174:     protected function _renderFiltersBefore()
175:     {
176:         if ($this->getFilter('store')) {
177:             $this->getSelect()->join(
178:                 array('store_table' => $this->getTable('cms/page_store')),
179:                 'main_table.page_id = store_table.page_id',
180:                 array()
181:             )->group('main_table.page_id');
182: 
183:             /*
184:              * Allow analytic functions usage because of one field grouping
185:              */
186:             $this->_useAnalyticFunction = true;
187:         }
188:         return parent::_renderFiltersBefore();
189:     }
190: 
191: 
192:     /**
193:      * Get SQL for get record count.
194:      * Extra GROUP BY strip added.
195:      *
196:      * @return Varien_Db_Select
197:      */
198:     public function getSelectCountSql()
199:     {
200:         $countSelect = parent::getSelectCountSql();
201: 
202:         $countSelect->reset(Zend_Db_Select::GROUP);
203: 
204:         return $countSelect;
205:     }
206: }
207: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0