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

MODULE_ARTICLE_COLLECTION=Ext.extend(SYNOBLOG_MODULE,{tree:null,constructor:function(b,a){SYNOBLOG.instance().on("article_update",this.updateModuleContent,this);MODULE_ARTICLE_COLLECTION.superclass.constructor.call(this,b,a)},init_module:function(){this.updateModuleContent()},updateModuleContent:function(){Ext.Ajax.request({url:SYNOPHOTO_UTILS.url_prefix+"/photo/blog/modules/article_collection.php",params:{action:"get_tree_date"},method:"POST",scope:this,success:function(a,b){if(this.tree){this.tree.destroy()}var c=Ext.util.JSON.decode(a.responseText);this.tree=this.getArticleTree(c);this.tree.getRootNode().expand()}})},getArticleTree:function(g){var a=new Ext.tree.TreePanel({renderTo:"article_collection_content",useArrows:true,rootVisible:false,animate:true,border:false,cls:"collection-tree",root:{text:"Article Collection",id:"source",iconCls:"collec-tree-icon",expanded:true,children:[]}});var d=0,b=0;while(g.year!=null&&g.year[d]!=null){b=0;$year_num=0;var e=g.year[d];var f=new Ext.tree.TreeNode({text:e,cls:"tree-node-year"});while(g[e][b]!=null){var c=new Ext.tree.TreeNode({text:g[e][b]["desc"]+" ("+g[e][b]["num"]+")",leaf:true,id:g[e][b]["id"],cls:"tree-node-month"});c.on("click",function(h,i){onNavigate("date_"+h.id)},this);f.appendChild(c);$year_num+=g[e][b]["num"];b++}f.text=e+" ("+$year_num+")";f.on("click",f.toggle,f);a.root.appendChild(f);d++}return a}});SYNOBLOG.instance().registerModule("article_collection",{title:null,width:0,height:0},MODULE_ARTICLE_COLLECTION);
