/* Copyright (c) 2011 Synology Inc. All rights reserved. */

MODULE_ARTICLE_COLLECTION=function(c,a){MODULE_ARTICLE_COLLECTION.superclass.constructor.call(this,c,a);var b=SYNOBLOG_COLUMN_CENTRAL.instance();b.on("article_update",this.updateModuleContent,this)};Ext.extend(MODULE_ARTICLE_COLLECTION,SYNOBLOG_MODULE,{updateModuleContent:function(){var a=Ext.get(this.div_id+"_content");if(a!=null){a.dom.innerHTML="<table class='module_content' cellspacing='0' cellpadding='0'><tr><td class='module_title'>"+blog_str_article_collection_title+"<hr></td></tr><tr><td><div id='tree-div'></div></td></tr></table>";this.getTreeContent()}},init_module:function(){this.updateModuleContent()},getTreeContent:function(){Ext.Ajax.request({url:"modules/article_collection.php",params:"action=get_tree_date",method:"POST",scope:this,success:function(g,a){var l=Ext.util.JSON.decode(g.responseText);var k=new Ext.tree.TreePanel("tree-div",{lines:true,rootVisible:false,animate:true});var c=new Ext.tree.TreeNode({text:"article_collection",cls:"folder",leaf:false});k.setRootNode(c);var e=0,d=0;while(l.year!=null&&l.year[e]!=null){d=0;var h=l.year[e];var f=new Ext.tree.TreeNode({text:h});while(l[h][d]!=null){var b=new Ext.tree.TreeNode({text:l[h][d]["desc"]+" ("+l[h][d]["num"]+")",leaf:true,id:l[h][d]["id"]});b.on("click",function(i,j){onNavigate("date_"+i.id)},this);f.appendChild(b);d++}f.on("click",f.toggle,f);c.appendChild(f);e++}k.render()}})}});SYNOBLOG.instance().registerModule("article_collection",{hasConfigDialog:0,width:0,height:0},MODULE_ARTICLE_COLLECTION);
