function treeJsonAction() { if ($this->_getParam('cmd') == 'moveTreeNode') { return $this->_reorderJson(); } $node = $this->_getParam('node', RM_Categories::ROOT_NAME); $model = new RM_Categories(); $categories = $model->fetchByParent($node); $iso = $this->_translate->getAdapter()->getLocale(); $jsonCategories = $this->_createNodes($model, RM_Categories::ROOT_NAME, $iso); // $jsonCategories = array(); // foreach ($categories as $category){ // $jsonCategory = new stdClass(); // $jsonCategory->id = $category->id; // $jsonCategory->text = $category->$iso; // if ($model->fetchByParent($category->id)->count()){ // $jsonCategory->leaf = 0; // } else { // $jsonCategory->leaf = 1; // } // $jsonCategory->cls = "folder"; // // $jsonCategories[] = $jsonCategory; // } if ($node == RM_Categories::ROOT_NAME) { $jsonCategory = new stdClass(); $jsonCategory->id = RM_Categories::DISABLED; $jsonCategory->text = $this->_translate->_('Admin.Categories.Edit', 'Disabled'); $subCategories = $this->_createNodes($model, $jsonCategory->id, $iso); if (count($subCategories) > 0) { $jsonCategory->children = $subCategories; $jsonCategory->leaf = 0; } else { $jsonCategory->leaf = 1; } $jsonCategory->cls = "folder"; $jsonCategory->iconCls = "RM_categories_disabled_icon"; $jsonCategory->allowDrag = false; $jsonCategories[] = $jsonCategory; $jsonCategory = new stdClass(); $jsonCategory->id = RM_Categories::TRASH; $jsonCategory->text = $this->_translate->_('Admin.Categories.Edit', 'Trash'); $subCategories = $this->_createNodes($model, $jsonCategory->id, $iso); if (count($subCategories) > 0) { $jsonCategory->children = $subCategories; $jsonCategory->leaf = 0; } else { $jsonCategory->leaf = 1; } $jsonCategory->cls = "folder"; $jsonCategory->iconCls = "RM_categories_trash_icon"; $jsonCategory->allowDrag = false; $jsonCategories[] = $jsonCategory; } return array('data' => $jsonCategories); }