wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
tree.js.php
Go to the documentation of this file.
1 /**
2  * @class wcmf.tree.Tree. Build on Ext.tree.TreePanel
3  */
4 wcmf.tree.Tree = function(config) {
5  /**
6  * @cfg {Array} customParams An assoziative array of additional values passed to the controller [optional]
7  */
8  Ext.apply(this, config);
9 
10  // create the root node
11  var root = new Ext.tree.AsyncTreeNode({
12  text:Message.get("Root"),
13  draggable:false,
14  id:'root'
15  });
16 
17  // add default config properties
18  config.useArrows = true,
19  config.autoScroll = true,
20  config.animate = true,
21  config.containerScroll = true,
22  config.root = root,
23  config.loader = new wcmf.tree.TreeLoader({
24  dataUrl:'<?php echo $APP_URL; ?>',
25  baseParams:{controller:'<?php echo $controller; ?>', context:'<?php echo $context; ?>', usr_action:'loadChildren', response_format:'JSON', sid:'<?php echo session_id() ?>'}
26  })
27 
28  wcmf.tree.Tree.superclass.constructor.call(this, config);
29 
30  // add custom parameters to the baseParams of the TreeLoader
31  if (this.customParams)
32  for (var i in this.customParams)
33  this.loader.baseParams.add(this.customParams[i]);
34 };
35 
36 Ext.extend(wcmf.tree.Tree, Ext.tree.TreePanel, {
37 });
38 
39 /**
40  * @class wcmf.tree.TreeLoader. Build on Ext.tree.TreeLoader
41  */
42 wcmf.tree.TreeLoader = function(config) {
43  wcmf.tree.TreeLoader.superclass.constructor.call(this, config);
44 }
45 Ext.extend(wcmf.tree.TreeLoader, Ext.tree.TreeLoader, {
46  processResponse : function(response, node, callback) {
47  var responseArray = Ext.decode(response.responseText);
48 
49  try {
50  for(var i=0; i<responseArray['objects'].length; i++) {
51  var responseNode = responseArray['objects'][i];
52  var nodeDef = {
53  'text':responseNode.text,
54  'id':responseNode.oid,
55  'leaf':!responseNode.hasChildren,
56  'qtip':'',
57  'qtipTitle':responseNode.oid,
58  'cls':responseNode.hasChildren ? 'folder' : 'file',
59  'href':responseNode.onClickAction
60  }
61  var n = this.createNode(nodeDef);
62  if(n) {
63  node.appendChild(n);
64  }
65  }
66  if(typeof callback == "function") {
67  callback(this, node);
68  }
69  } catch(e) {
70  this.handleFailure(response);
71  }
72  }
73 });
get($message, $parameters=null, $domain='', $lang='')
Use the Message class to output messages. You need not instantiate a Message object because the metho...