00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Catalog 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 /** 00028 * Category View block 00029 * 00030 * @category Mage 00031 * @package Mage_Catalog 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 class Mage_Catalog_Block_Category_View extends Mage_Core_Block_Template 00035 { 00036 protected function _prepareLayout() 00037 { 00038 parent::_prepareLayout(); 00039 00040 $this->getLayout()->createBlock('catalog/breadcrumbs'); 00041 00042 if ($headBlock = $this->getLayout()->getBlock('head')) { 00043 if ($title = $this->getCurrentCategory()->getMetaTitle()) { 00044 $headBlock->setTitle($title); 00045 } 00046 if ($description = $this->getCurrentCategory()->getMetaDescription()) { 00047 $headBlock->setDescription($description); 00048 } 00049 if ($keywords = $this->getCurrentCategory()->getMetaKeywords()) { 00050 $headBlock->setKeywords($keywords); 00051 } 00052 /* 00053 want to show rss feed in the url 00054 */ 00055 if ($this->IsRssCatalogEnable() && $this->IsTopCategory()) { 00056 $title = $this->helper('rss')->__('%s RSS Feed',$this->getCurrentCategory()->getName()); 00057 $headBlock->addItem('rss', $this->getRssLink(), 'title="'.$title.'"'); 00058 } 00059 } 00060 00061 return $this; 00062 } 00063 00064 public function IsRssCatalogEnable() 00065 { 00066 return Mage::getStoreConfig('rss/catalog/category'); 00067 } 00068 00069 public function IsTopCategory() 00070 { 00071 return $this->getCurrentCategory()->getLevel()==2; 00072 } 00073 00074 public function getRssLink() 00075 { 00076 return Mage::getUrl('rss/catalog/category',array('cid' => $this->getCurrentCategory()->getId(), 'store_id' => Mage::app()->getStore()->getId())); 00077 } 00078 00079 public function getProductListHtml() 00080 { 00081 return $this->getChildHtml('product_list'); 00082 } 00083 00084 /** 00085 * Retrieve current category model object 00086 * 00087 * @return Mage_Catalog_Model_Category 00088 */ 00089 public function getCurrentCategory() 00090 { 00091 if (!$this->hasData('current_category')) { 00092 $this->setData('current_category', Mage::registry('current_category')); 00093 } 00094 return $this->getData('current_category'); 00095 } 00096 00097 public function getCmsBlockHtml() 00098 { 00099 if (!$this->getData('cms_block_html')) { 00100 $html = $this->getLayout()->createBlock('cms/block') 00101 ->setBlockId($this->getCurrentCategory()->getLandingPage()) 00102 ->toHtml(); 00103 $this->setData('cms_block_html', $html); 00104 } 00105 return $this->getData('cms_block_html'); 00106 } 00107 00108 public function isProductMode() 00109 { 00110 return $this->getCurrentCategory()->getDisplayMode()==Mage_Catalog_Model_Category::DM_PRODUCT; 00111 } 00112 00113 public function isMixedMode() 00114 { 00115 return $this->getCurrentCategory()->getDisplayMode()==Mage_Catalog_Model_Category::DM_MIXED; 00116 } 00117 00118 public function isContentMode() 00119 { 00120 return $this->getCurrentCategory()->getDisplayMode()==Mage_Catalog_Model_Category::DM_PAGE; 00121 } 00122 }