Overview

Packages

  • Agora
  • None

Classes

  • Agora_Application
  • Agora_Block_Forums
  • Agora_Block_Thread
  • Agora_Block_Threads
  • Agora_Tree_Flat
  • Agora_ViewComments

Functions

  • handle_avatarselect
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * The Agora_Tree_Flat:: class extends the Horde_Tree_Base class to provide
  4:  * agora flat threded view.
  5:  *
  6:  * Copyright 2005-2012 Horde LLC (http://www.horde.org/)
  7:  *
  8:  * See the enclosed file COPYING for license information (LGPL). If you
  9:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 10:  *
 11:  * @author Ben Chavet <ben@horde.org>
 12:  * @author Duck <duck@obala.net>
 13:  */
 14: class Agora_Tree_Flat extends Horde_Tree_Base {
 15: 
 16:     /**
 17:      * TODO
 18:      *
 19:      * @var array
 20:      */
 21:     var $_nodes = array();
 22: 
 23:     /**
 24:      * Constructor.
 25:      */
 26:     public function __construct($tree_name, array $params = array())
 27:     {
 28:         parent::__construct($tree_name, 'Html', $params);
 29:         $this->_static = true;
 30:     }
 31: 
 32:     /**
 33:      * Returns the tree.
 34:      *
 35:      * @return string  The HTML code of the rendered tree.
 36:      */
 37:     public function getTree($static = false)
 38:     {
 39:         $this->_buildIndents($this->_root_nodes);
 40: 
 41:         $tree = '';
 42:         foreach ($this->_root_nodes as $node_id) {
 43:             $tree .= $this->_buildTree($node_id);
 44:         }
 45:         return $tree;
 46:     }
 47: 
 48:     /**
 49:      * Checks the current environment to see if we can render the HTML tree.
 50:      * HTML is always renderable, at least until we add a php-gtk tree
 51:      * backend, in which case this implementation will actually need a body.
 52:      *
 53:      * @static
 54:      *
 55:      * @return boolean  Whether or not this Tree:: backend will function.
 56:      */
 57:     public function isSupported()
 58:     {
 59:         return true;
 60:     }
 61: 
 62:     /**
 63:      * Returns just the JS node definitions as a string. This is a no-op for
 64:      * the select renderer.
 65:      */
 66:     public function renderNodeDefinitions()
 67:     {
 68:     }
 69: 
 70:     /**
 71:      * Adds additional parameters to a node.
 72:      *
 73:      * @param string $id     The unique node id.
 74:      * @param array $params  Any other parameters to set.
 75:      * <pre>
 76:      * selected --  Whether this node is selected
 77:      * </pre>
 78:      */
 79:     public function addNodeParams($id, $params = array())
 80:     {
 81:         if (!is_array($params)) {
 82:             $params = array($params);
 83:         }
 84: 
 85:         $allowed = array('selected');
 86: 
 87:         foreach ($params as $param_id => $param_val) {
 88:             /* Set only allowed and non-null params. */
 89:             if (in_array($param_id, $allowed) && !is_null($param_val)) {
 90:                 $this->_nodes[$id][$param_id] = $param_val;
 91:             }
 92:         }
 93:     }
 94: 
 95:     /**
 96:      * Recursive function to walk through the tree array and build the output.
 97:      *
 98:      * @access private
 99:      *
100:      * @param string $node_id  The Node ID.
101:      *
102:      * @return string  The tree rendering.
103:      */
104:     protected function _buildTree($node_id)
105:     {
106:         $extra = $this->_nodes[$node_id]['extra'][1];
107:         $output = '<div class="messageContainer" style="margin-left: ' . (int)$this->_nodes[$node_id]['indent'] . '0px">' . "\n"
108:                 . '<div class="messageAuthor">' . "\n"
109:                 . $extra['link'] . '<strong>' . $extra['message_subject'] . '</strong></a><br />' . "\n"
110:                 . _("Posted by") . ': ' . $extra['message_author'] . "\n<br />"
111:                 . _("on: ") . $extra['message_date'] . "\n"
112:                 . ' <br /> ' . "\n";
113: 
114:         if (isset($extra['message_author_moderator'])) {
115:             $output .= _("Moderator") . '<br />';
116:         }
117: 
118:         if (!empty($extra['actions'])) {
119:             $output .= '<span class="small"> [ ' . implode(', ', $extra['actions']) . ' ] </span>';
120:         }
121: 
122:         $output .= '</div>' . "\n"
123:                  . '<div class="messageBody"><p>' . $this->_nodes[$node_id]['label'] . '</p></div>' . "\n"
124:                  . '<br class="clear" /></div>' . "\n";
125: 
126:         if (isset($this->_nodes[$node_id]['children']) &&
127:             $this->_nodes[$node_id]['expanded']) {
128:             $num_subnodes = count($this->_nodes[$node_id]['children']);
129:             for ($c = 0; $c < $num_subnodes; $c++) {
130:                 $child_node_id = $this->_nodes[$node_id]['children'][$c];
131:                 $output .= $this->_buildTree($child_node_id);
132:             }
133:         }
134: 
135:         return $output;
136:     }
137: }
138: 
API documentation generated by ApiGen