0byt3m1n1
Path:
/
data
/
applications
/
aps
/
magento
/
1.1.3-2
/
standard
/
htdocs
/
app
/
code
/
core
/
Mage
/
Rss
/
Block
/
[
Home
]
File: List.php
<?php /** * Magento * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/osl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@magentocommerce.com so we can send you a copy immediately. * * @category Mage * @package Mage_Rss * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ /** * Review form block * * @category Mage * @package Mage_Rss * @author Magento Core Team <core@magentocommerce.com> */ class Mage_Rss_Block_List extends Mage_Core_Block_Template { const XML_PATH_RSS_METHODS = 'rss'; protected $_rssFeeds = array(); /** * Retrieve rss feeds * * @return array */ public function getRssFeeds() { return empty($this->_rssFeeds) ? false : $this->_rssFeeds; } /** * Add new rss feed * * @param string $url * @param string $label * @return Mage_Core_Helper_Abstract */ public function addRssFeed($url, $label, $param = array(), $customerGroup=false) { $param = array_merge($param, array('sid' => $this->getCurrentStoreId())); if ($customerGroup) { $param = array_merge($param, array('cid' => $this->getCurrentCustomerGroupId())); } $this->_rssFeeds[] = new Varien_Object( array( 'url' => Mage::getUrl($url, $param), 'label' => $label ) ); return $this; } public function resetRssFeed() { $this->_rssFeeds=array(); } public function getCurrentStoreId() { return Mage::app()->getStore()->getId(); } public function getCurrentCustomerGroupId() { return Mage::getSingleton('customer/session')->getCustomerGroupId(); } /** * Retrieve rss catalog feeds * * array structure: * * @return array */ public function getRssCatalogFeeds() { $this->resetRssFeed(); $this->CategoriesRssFeed(); return $this->getRssFeeds(); /* $section = Mage::getSingleton('adminhtml/config')->getSections(); $catalogFeeds = $section->rss->groups->catalog->fields[0]; $res = array(); foreach($catalogFeeds as $code => $feed){ $prefix = self::XML_PATH_RSS_METHODS.'/catalog/'.$code; if (!Mage::getStoreConfig($prefix) || $code=='tag') { continue; } $res[$code] = $feed; } return $res; */ } public function getRssMiscFeeds() { $this->resetRssFeed(); $this->NewProductRssFeed(); $this->SpecialProductRssFeed(); $this->SalesRuleProductRssFeed(); return $this->getRssFeeds(); } /* public function getCatalogRssUrl($code) { $store_id = Mage::app()->getStore()->getId(); $param = array('sid' => $store_id); $custGroup = Mage::getSingleton('customer/session')->getCustomerGroupId(); if ($custGroup) { $param = array_merge($param, array('cid' => $custGroup)); } return Mage::getUrl('rss/catalog/'.$code, $param); } */ public function NewProductRssFeed() { $path = self::XML_PATH_RSS_METHODS.'/catalog/new'; if((bool)Mage::getStoreConfig($path)){ $this->addRssFeed($path, $this->__('New Products')); } } public function SpecialProductRssFeed() { $path = self::XML_PATH_RSS_METHODS.'/catalog/special'; if((bool)Mage::getStoreConfig($path)){ $this->addRssFeed($path, $this->__('Special/Discount Products'),array(),true); } } public function SalesRuleProductRssFeed() { $path = self::XML_PATH_RSS_METHODS.'/catalog/salesrule'; if((bool)Mage::getStoreConfig($path)){ $this->addRssFeed($path, $this->__('Coupons/Discounts'),array(),true); } } public function CategoriesRssFeed() { $path = self::XML_PATH_RSS_METHODS.'/catalog/category'; if((bool)Mage::getStoreConfig($path)){ $category = Mage::getModel('catalog/category'); /* @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection */ $treeModel = $category->getTreeModel()->loadNode(Mage::app()->getStore()->getRootCategoryId()); $nodes = $treeModel->loadChildren()->getChildren(); $nodeIds = array(); foreach ($nodes as $node) { $nodeIds[] = $node->getId(); } $collection = $category->getCollection() ->addAttributeToSelect('url_key') ->addAttributeToSelect('name') ->addAttributeToSelect('is_anchor') ->addAttributeToFilter('is_active',1) ->addIdFilter($nodeIds) ->addAttributeToSort('name') ->load(); foreach ($collection as $category) { $this->addRssFeed('rss/catalog/category', $category->getName(),array('cid'=>$category->getId())); } } } }