grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026_name = $name; $this->json = new JSON(); } /** * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, * please update your code, use __construct instead */ public function Tree($name) { $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8,'. ' please update your code'; if (isset($GLOBALS['log'])) { $GLOBALS['log']->deprecated($deprecatedMessage); } else { trigger_error($deprecatedMessage, E_USER_DEPRECATED); } self::__construct($name); } /** * optionally add json.js, required for making AJAX Calls. * @param null $reference */ public function include_json_reference($reference = null) { // TODO: possibly deprecate // if (empty($reference)) { // $this->_header_files[]='include/JSON.js'; // } else { // $this->_header_files[]=$reference; // } } /** * @param $node */ public function add_node($node) { $this->_nodes[$node->uid] = $node; } /** * @return string - html for including necessary javascript files. */ public function generate_header() { $ret = "\n"; foreach ($this->_header_files as $filename) { $ret .= "\n"; } return $ret; } /** * properties set here will be accessible from the tree's name space.. * @param $name * @param $value */ public function set_param($name, $value) { if (!empty($name) && !empty($value)) { $this->_params[$name] = $value; } } /** * @param bool $scriptTags * @return string */ public function generate_nodes_array($scriptTags = true) { global $sugar_config; $node = null; $ret = array(); foreach ($this->_nodes as $node) { $ret['nodes'][] = $node->get_definition(); } //todo removed site_url setting from here. //todo make these variables unique. $tree_data = "var TREE_DATA= " . $this->json->encode($ret) . ";\n"; $tree_data .= "var param= " . $this->json->encode($this->_params) . ";\n"; $tree_data .= "var mytree;\n"; $tree_data .= "treeinit(mytree,TREE_DATA,'{$this->_name}',param);\n"; if ($scriptTags) { return ''; } else { return $tree_data; } } /** * Generates the javascript node arrays without calling treeinit(). Also generates a callback function that can be * easily called to instatiate the treeview object onload(). * * IE6/7 will throw an "Operation Aborted" error when calling certain types of scripts before the page is fully * loaded. The workaround is to move the init() call to the onload handler. See: http://www.viavirtualearth. * com/wiki/DeferScript.ashx * * @param bool insertScriptTags Flag to add "; } return $treeData; } /** * @return array */ public function generateNodesRaw() { $node = null; $ret = array(); $return = array(); foreach ($this->_nodes as $node) { $ret['nodes'][] = $node->get_definition(); } $return['tree_data'] = $ret; $return['param'] = $this->_params; return $return; } }