OStore.tree.cat = function(config){
config = config || {};
Ext.applyIf(config,{
url: OStore.config.connectorUrl
,action: 'mgr/cat/getnodes'
,expandFirst: true
,rootId: '0'
,rootName: 'Top categories'
,rootVisible: true
//,sortAction: 'categories/nodesUpdate'
});
OStore.tree.cat.superclass.constructor.call(this,config);
};
Ext.extend(OStore.tree.cat,MODx.tree.Tree,{
});
Ext.reg('ostore-panel-cats',OStore.tree.cat);class OStoreGetListProcessor extends modObjectGetListProcessor {
public $classKey = 'osWh';
public $languageTopics = array('ostore:default');
public $defaultSortField = 'name';
public $defaultSortDirection = 'ASC';
public $objectType = 'ostore.wh';
}
return 'OStoreGetListProcessor';[{
"text":"Node 1 title <span dir=\"ltr\">(1)<\/span>"
,"id":"web_1"
,"pk":1
,"cls":"icon-document x-tree-node-leaf icon-resource psave pview pedit pduplicate pnew pnew_modDocument pnew pnew_modSymLink pnew pnew_modWebLink pnew pnew_modStaticResource pqcreate pqupdate pdelete pundelete ppublish punpublish"
,"type":"modResource"
,"classKey":"modDocument"
,"ctx":"web"
,"hide_children_in_tree":0
,"qtip":""
,"preview_url":"http:\/\/localhost\/modx\/"
,"page":"?a=30&id=1"
,"allowDrop":true
,"hasChildren":false,"children":[],"expanded":true
},{
"text":"Node 2 title <span dir=\"ltr\">(2)<\/span>"
,"id":"web_4"
,"pk":4
,"cls":"icon-translateddocument x-tree-node-leaf icon-resource psave pview pedit pduplicate pnew pnew_modDocument pnew pnew_modSymLink pnew pnew_modWebLink pnew pnew_modStaticResource pqcreate pqupdate pdelete pundelete ppublish punpublish"
,"type":"modResource"
,"classKey":"modTranslatedDocument"
,"ctx":"web"
,"hide_children_in_tree":0
,"qtip":"<i> <\/i>"
,"preview_url":"http:\/\/localhost\/modx\/translated-page.html"
,"page":"?a=30&id=2"
,"allowDrop":true
,"hasChildren":false
,"children":[]
,"expanded":true
},{
"text":"Node 3 title <span dir=\"ltr\">(3)<\/span>"
,"id":"web_5"
,"pk":5
,"cls":"icon-translateddocument x-tree-node-leaf icon-resource psave pview pedit pduplicate pnew pnew_modDocument pnew pnew_modSymLink pnew pnew_modWebLink pnew pnew_modStaticResource pqcreate pqupdate pdelete pundelete ppublish punpublish"
,"type":"modResource"
,"classKey":"modTranslatedDocument"
,"ctx":"web"
,"hide_children_in_tree":0
,"qtip":""
,"preview_url":"http:\/\/localhost\/modx\/getresources-test.html"
,"page":"?a=30&id=3"
,"allowDrop":true
,"hasChildren":false
,"children":[]
,"expanded":true
}][{
"title": 'Category 1'
,"dateAdded": '2012-10-1'
,"anotherCustomProperty": 'custom property value'
},{
"title": 'Category 2'
,"dateAdded": '2012-09-02'
,"anotherCustomProperty": 'custom property value'
}]class OStoreGetNodesProcessor extends modResourceGetNodesProcessor {osCat is already created and works ( if get it by modObjectGetListProcessor for example.)
public $itemClass = 'osCat';
}
return 'OStoreGetNodesProcessor';
,useDefaultToolbar: true
,tbar: [
{
icon: MODx.config.template_url+'images/restyle/icons/folder.png'
,cls: 'x-btn-icon'
,tooltip: { text: _('ostore.cat.create') }
,handler: this.test
}
]
,test: function(){
alert('test')
},handler: function() { alert('ok') }OStore.tree.cat = function(config){
...
,useDefaultToolbar: true
,tbar: [
{
icon: MODx.config.template_url+'images/restyle/icons/folder.png'
,cls: 'x-btn-icon'
,tooltip: { text: _('ostore.cat.create') }
,handler: this.test
}
]
...
});Ext.extend(OStore.tree.cat,MODx.tree.Tree,{
test: function(){
alert('test')
}
});
/*
* Get list by parent
*/
public function process() {
// Get parent ID
$parentId = str_replace('n_ug_','', $this->getProperty('id') );
// Get child tags
$tagList = $this->getTags($parentId);
// Write list
$newList = array();
foreach( $tagList as $item ){
// Check if children exist
$itemChilds = $this->getTags($item->get('id'));
if( !empty($itemChilds) ){
$leaf = false;
$type = 'dir';
}else{
$leaf = true;
$type = 'file';
}
// Write new node item
$newList[] = array(
'text' => $item->get('name'),
'name' => $item->get('name'),
'description' => $item->get('description'),
'parentid' => $item->get('id'),
'id' => 'n_ug_0' . $item->get('id'),
'leaf' => $leaf,
'type' => $type,
'cls' => ''
);
}
return $this->toJSON($newList);
}