Mage_Cms_Model_Mysql4_Page_Collection Class Reference

Inheritance diagram for Mage_Cms_Model_Mysql4_Page_Collection:

Mage_Core_Model_Mysql4_Collection_Abstract Varien_Data_Collection_Db Varien_Data_Collection

List of all members.

Public Member Functions

 toOptionArray ()
 setFirstStoreFlag ($flag=false)
 addStoreFilter ($store, $withAdmin=true)

Protected Member Functions

 _construct ()
 _afterLoad ()

Protected Attributes

 $_previewFlag


Detailed Description

Definition at line 35 of file Collection.php.


Member Function Documentation

_afterLoad (  )  [protected]

Reimplemented from Varien_Data_Collection_Db.

Definition at line 55 of file Collection.php.

00056     {
00057         if ($this->_previewFlag) {
00058             $items = $this->getColumnValues('page_id');
00059             if (count($items)) {
00060                 $select = $this->getConnection()->select()
00061                         ->from($this->getTable('cms/page_store'))
00062                         ->where($this->getTable('cms/page_store').'.page_id IN (?)', $items);
00063                 if ($result = $this->getConnection()->fetchPairs($select)) {
00064                     foreach ($this as $item) {
00065                         if (!isset($result[$item->getData('page_id')])) {
00066                             continue;
00067                         }
00068                         if ($result[$item->getData('page_id')] == 0) {
00069                             $stores = Mage::app()->getStores(false, true);
00070                             $storeId = current($stores)->getId();
00071                             $storeCode = key($stores);
00072                         } else {
00073                             $storeId = $result[$item->getData('page_id')];
00074                             $storeCode = Mage::app()->getStore($storeId)->getCode();
00075                         }
00076                         $item->setData('_first_store_id', $storeId);
00077                         $item->setData('store_code', $storeCode);
00078                     }
00079                 }
00080             }
00081         }
00082 
00083         parent::_afterLoad();
00084     }

_construct (  )  [protected]

Initialization here

Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.

Definition at line 39 of file Collection.php.

00040     {
00041         $this->_init('cms/page');
00042     }

addStoreFilter ( store,
withAdmin = true 
)

Add Filter by store

Parameters:
int|Mage_Core_Model_Store $store
Returns:
Mage_Cms_Model_Mysql4_Page_Collection

Definition at line 92 of file Collection.php.

00093     {
00094         if ($store instanceof Mage_Core_Model_Store) {
00095             $store = array($store->getId());
00096         }
00097 
00098         $this->getSelect()->join(
00099             array('store_table' => $this->getTable('cms/page_store')),
00100             'main_table.page_id = store_table.page_id',
00101             array()
00102         )
00103         ->where('store_table.store_id in (?)', ($withAdmin ? array(0, $store) : $store))
00104         ->group('main_table.page_id');
00105 
00106         return $this;
00107     }

setFirstStoreFlag ( flag = false  ) 

Definition at line 49 of file Collection.php.

00050     {
00051         $this->_previewFlag = $flag;
00052         return $this;
00053     }

toOptionArray (  ) 

Reimplemented from Varien_Data_Collection.

Definition at line 44 of file Collection.php.

00045     {
00046         return $this->_toOptionArray('identifier', 'title');
00047     }


Member Data Documentation

$_previewFlag [protected]

Definition at line 37 of file Collection.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:52 2009 for Magento by  doxygen 1.5.8