Mage_Adminhtml_Block_Urlrewrite_Category_Tree Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Urlrewrite_Category_Tree:

Mage_Adminhtml_Block_Catalog_Category_Abstract Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 __construct ()
 getTreeArray ($parentId=null, $asJson=false, $recursionLevel=3)
 getCategoryCollection ()
 getLoadTreeUrl ()

Protected Member Functions

 _getNodesArray ($node)


Detailed Description

Definition at line 34 of file Tree.php.


Constructor & Destructor Documentation

__construct (  ) 

Set custom template for the block

Reimplemented from Mage_Adminhtml_Block_Catalog_Category_Abstract.

Definition at line 40 of file Tree.php.

00041     {
00042         parent::__construct();
00043         $this->setTemplate('urlrewrite/categories.phtml');
00044     }


Member Function Documentation

_getNodesArray ( node  )  [protected]

Convert categories tree to array recursively

Returns:
array

Definition at line 98 of file Tree.php.

00099     {
00100         $result = array(
00101             'id'             => (int)$node->getId(),
00102             'parent_id'      => (int)$node->getParentId(),
00103             'children_count' => (int)$node->getChildrenCount(),
00104             'is_active'      => (bool)$node->getIsActive(),
00105             'name'           => $node->getName(),
00106             'level'          => (int)$node->getLevel(),
00107             'product_count'  => (int)$node->getProductCount(),
00108         );
00109         if ($node->hasChildren()) {
00110             $result['children'] = array();
00111             foreach ($node->getChildren() as $childNode) {
00112                 $result['children'][] = $this->_getNodesArray($childNode);
00113             }
00114         }
00115         $result['cls'] = ($result['is_active'] ? '' : 'no-') . 'active-category';
00116         $result['expanded'] = false;
00117         if (!empty($result['children'])) {
00118             $result['expanded'] = true;
00119         }
00120         return $result;
00121     }

getCategoryCollection (  ) 

Get categories collection

Returns:
Mage_Catalog_Model_Resource_Eav_Mysql4_Category_Collection

Definition at line 80 of file Tree.php.

00081     {
00082         $collection = $this->_getData('category_collection');
00083         if (is_null($collection)) {
00084             $collection = Mage::getModel('catalog/category')->getCollection()
00085                 ->addAttributeToSelect(array('name', 'is_active'))
00086                 ->setLoadProductCount(true)
00087             ;
00088             $this->setData('category_collection', $collection);
00089         }
00090         return $collection;
00091     }

getLoadTreeUrl (  ) 

Get URL for categories tree ajax loader

Returns:
string

Definition at line 128 of file Tree.php.

00129     {
00130         return Mage::helper('adminhtml')->getUrl('*/*/categoriesJson');
00131     }

getTreeArray ( parentId = null,
asJson = false,
recursionLevel = 3 
)

Get categories tree as recursive array

Parameters:
int $parentId
bool $asJson
int $recursionLevel
Returns:
array

Definition at line 54 of file Tree.php.

00055     {
00056         $result = array();
00057         if ($parentId) {
00058             $category = Mage::getModel('catalog/category')->load($parentId);
00059             if (!empty($category)) {
00060                 $tree = $this->_getNodesArray($this->getNode($category, $recursionLevel));
00061                 if (!empty($tree) && !empty($tree['children'])) {
00062                     $result = $tree['children'];
00063                 }
00064             }
00065         }
00066         else {
00067             $result = $this->_getNodesArray($this->getRoot(null, $recursionLevel));
00068         }
00069         if ($asJson) {
00070             return Zend_Json::encode($result);
00071         }
00072         return $result;
00073     }


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

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