Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F803228
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Feb 25, 7:32 AM
Size
30 KB
Mime Type
text/x-diff
Expires
Thu, Feb 27, 7:32 AM (1 d, 6 h)
Engine
blob
Format
Raw Data
Handle
576076
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/RC/core/units/general/helpers/sections_helper.php
===================================================================
--- branches/RC/core/units/general/helpers/sections_helper.php (revision 9257)
+++ branches/RC/core/units/general/helpers/sections_helper.php (revision 9258)
@@ -1,216 +1,220 @@
<?php
/**
* Porcesses sections information from configs
*
*/
class kSectionsHelper extends kHelper {
/**
* Holds information about all sections
*
* @var Array
*/
var $Tree = Array();
/**
* Set's prefix and special
*
* @param string $prefix
* @param string $special
* @access public
*/
function Init($prefix, $special, $event_params = null)
{
parent::Init($prefix, $special, $event_params);
$this->BuildTree();
}
/**
* Builds xml for tree in left frame in admin
*
* @param Array $params
*/
function BuildTree()
{
$unit_config_reader = false;
$data = $this->Conn->GetRow('SELECT Data, Cached FROM '.TABLE_PREFIX.'Cache WHERE VarName = "sections_parsed"');
if ($data) {
$this->Tree = unserialize($data['Data']);
return ;
}
$this->Application->UnitConfigReader->includeConfigFiles(MODULES_PATH);
$this->Application->UnitConfigReader->AfterConfigRead();
$this->Tree = Array();
if (!$unit_config_reader) {
$unit_config_reader =& $this->Application->recallObject('kUnitConfigReader');
}
// 1. build base tree (don't update parent with children list yet)
$prefixes = array_keys($unit_config_reader->configData);
foreach ($prefixes as $prefix) {
$config =& $unit_config_reader->configData[$prefix];
$sections = getArrayValue($config, 'Sections');
if (!$sections) continue;
// echo 'Prefix: ['.$prefix.'] has ['.count($sections).'] sections<br />';
foreach ($sections as $section_name => $section_params) {
// we could also skip not allowed sections here in future
if ( isset($section_params['SectionPrefix']) ) {
$section_prefix = $section_params['SectionPrefix'];
}
elseif ( $this->Application->getUnitOption($prefix, 'SectionPrefix') ) {
$section_prefix = $this->Application->getUnitOption($prefix, 'SectionPrefix');
}
else {
$section_prefix = $prefix;
}
$section_params['SectionPrefix'] = $section_prefix;
$section_params['url']['m_opener'] = 'r';
$section_params['url']['no_pass_through'] = 1;
$pass_section = getArrayValue($section_params, 'url', 'pass_section');
if ($pass_section) {
unset($section_params['url']['pass_section']);
$section_params['url']['section'] = $section_name;
if (!isset($section_params['url']['module'])) {
$module_name = $this->Application->findModule('Path', $config['ModuleFolder'].'/', 'Name');
$section_params['url']['module'] = $module_name;
}
}
if (!isset($section_params['url']['t'])) {
$section_params['url']['t'] = 'index';
}
if (!isset($section_params['onclick'])) {
$section_params['onclick'] = 'checkEditMode()';
}
+ if (!isset($section_params['container'])) {
+ $section_params['container'] = 0; // for js tree printing to xml
+ }
+
$current_data = isset($this->Tree[$section_name]) ? $this->Tree[$section_name] : Array();
$this->Tree[$section_name] = array_merge_recursive2($current_data, $section_params);
}
}
// 2. apply section ajustments
foreach ($prefixes as $prefix) {
$config =& $unit_config_reader->configData[$prefix];
$section_ajustments = getArrayValue($config, 'SectionAdjustments');
if (!$section_ajustments) continue;
foreach ($section_ajustments as $section_name => $ajustment_params) {
if (is_array($ajustment_params)) {
$this->Tree[$section_name] = array_merge_recursive2($this->Tree[$section_name], $ajustment_params);
}
else {
// then remove section
unset($this->Tree[$section_name]);
}
}
}
// 3.
foreach ($this->Tree as $section_name => $section_params) {
// 3.1. update parent -> children references
$this->Tree[ $section_params['parent'] ]['children'][ "{$section_params['priority']}" ] = $section_name;
if ($section_params['type'] == stTAB) {
// if this is tab, then mark parent section as TabOnly
$this->Tree[ $section_params['parent'] ]['tabs_only'] = true;
}
// 3.2. process icons here, because they also can be ajusted
if (isset($section_params['icon']) && preg_match('/([^:]+):(.*)/', $section_params['icon'], $regs)) {
$this->Tree[$section_name]['icon'] = $regs[2];
$this->Tree[$section_name]['icon_module'] = $regs[1];
$module_folder = trim( $this->Application->findModule('Name', $regs[1], 'Path'), '/');
if ($module_folder == '') $module_folder = 'core';
}
else {
$module_folder = $this->Application->getUnitOption($section_params['SectionPrefix'], 'ModuleFolder');
}
// this is to display HELP icon instead of missing one.. can be replaced with some other icon to draw attention
$icon_file = $module_folder.'/admin_templates/img/icons/icon24_'.$this->Tree[$section_name]['icon'];
if (!file_exists(FULL_PATH.'/'.$icon_file.'.gif')) {
$this->Tree[$section_name]['icon'] = 'help';
$this->Tree[$section_name]['icon_module'] = 'core';
}
}
$this->Application->HandleEvent( new kEvent('adm:OnAfterBuildTree') );
$this->Conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("sections_parsed", '.$this->Conn->qstr(serialize($this->Tree)).', '.adodb_mktime().')');
}
/**
* Returns details information about section
*
* @param string $section_name
* @return Array
*/
function &getSectionData($section_name)
{
if (isset($this->Tree[$section_name])) {
$ret =& $this->Tree[$section_name];
}
else {
$ret = Array();
}
return $ret;
}
/**
* Returns first child, that is not a folder
*
* @param string $section_name
* @param Array $tree
* @return stirng
*/
function getFirstChild($section_name, $check_permission = false)
{
$section_data =& $this->getSectionData($section_name);
$children = isset($section_data['children']) && $section_data['children'] ? $section_data['children'] : false;
if ($children) {
// get 1st child
ksort($children, SORT_NUMERIC);
foreach ($children as $child_priority => $child_section) {
$section_data =& $this->getSectionData($child_section);
$perm_section = $this->getPermSection($child_section);
$perm_status = $check_permission ? $this->Application->CheckPermission($perm_section.'.view') : true;
if ((isset($section_data['show_mode']) && $section_data['show_mode']) || !$perm_status) {
continue;
}
break;
}
return $this->getFirstChild($child_section, $check_permission);
}
return $section_name;
}
/**
* Returns section for permission checking based on given section
*
* @param string $section_name
* @return string
*/
function getPermSection($section_name)
{
$ret = $section_name;
$section_data =& $this->getSectionData($section_name);
if ($section_data && isset($section_data['perm_prefix'])) {
// this section uses other section permissions
$ret = $this->Application->getUnitOption($section_data['perm_prefix'].'.main', 'PermSection');
}
return $ret;
}
}
?>
\ No newline at end of file
Property changes on: branches/RC/core/units/general/helpers/sections_helper.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.12.2.1
\ No newline at end of property
+1.12.2.2
\ No newline at end of property
Index: branches/RC/core/admin_templates/tree.tpl
===================================================================
--- branches/RC/core/admin_templates/tree.tpl (revision 9257)
+++ branches/RC/core/admin_templates/tree.tpl (revision 9258)
@@ -1,126 +1,125 @@
<inp2:m_Set skip_last_template="1"/>
<inp2:m_include t="incs/header" nobody="yes" noform="yes"/>
<inp2:m_NoDebug/>
<body style="margin: 0px; height: 100%" bgcolor="#DCEBF6">
<inp2:m_RenderElement name="kernel_form"/>
<script type="text/javascript">
function credits(url)
{
var width = 200;
var height = 200;
var screen_x = (screen.availWidth-width)/2;
var screen_y = (screen.availHeight-height)/2;
window.open(url, 'credits', 'width=280,height=520,left='+screen_x+',top='+screen_y);
}
</script>
<script src="js/ajax.js"></script>
<script src="js/tree.js"></script>
<style type="text/css">
.tree_head.td, .tree_head, .tree_head:hover {
font-weight: bold;
font-size: 10px;
color: #FFFFFF;
font-family: Verdana, Arial;
text-decoration: none;
}
.tree {
padding: 0px;
border: none;
border-collapse: collapse;
}
.tree tr td {
padding: 0px;
margin: 0px;
font-family: helvetica, arial, verdana,;
font-size: 11px;
white-space: nowrap;
}
.tree tr td a {
font-size: 11px;
color: #000000;
font-family: Helvetica, Arial, Verdana;
text-decoration: none;
}
.tree tr td a:hover {
color: #009FF0;
}
</style>
<table style="height: 100%; width: 100%; border-collapse: collapse;" border="0">
<tr style="background: #5291DE url(img/menu_bar.gif) repeat-x left bottom;" class="tree_head">
<td align="left" width="80%" height="21">
<a class="tree_head" href="javascript:credits('<inp2:m_Link index_file="help/credits.php" destform="popup"/>');">In-Portal v <inp2:adm_ModuleVersion module="In-Portal"/></a>
</td>
<td align="right" width="20%">
<select name="language" style="width: 62px; border: 0px; background-color: #FFFFFF; font-size: 9px; color: black;" onchange="submit_event('lang', 'OnChangeLanguage', 'index');">
<inp2:m_DefineElement name="lang_elem">
<option value="<inp2:Field name="LanguageId"/>" <inp2:m_if check="SelectedLanguage">selected="selected"</inp2:m_if> ><inp2:Field name="PackName"/></option>
</inp2:m_DefineElement>
<inp2:lang_ListLanguages render_as="lang_elem" row_start_render_as="html:" row_end_render_as="html:"/>
</select>
</td>
</tr>
<tr>
<td colspan="2" style="vertical-align: top; padding: 5px;">
<inp2:m_DefineElement name="xml_node" icon_module="">
<inp2:m_if check="m_ParamEquals" param="children_count" value="0">
<item href="<inp2:m_param name="section_url" js_escape="1"/>" priority="<inp2:m_param name="priority"/>" onclick="<inp2:m_param name="onclick" js_escape="1"/>" icon="<inp2:$SectionPrefix_ModulePath module="$icon_module"/>img/icons/icon24_<inp2:m_param name="icon"/>.gif"><inp2:m_phrase name="$label" escape="1"/></item>
<inp2:m_else/>
- <folder href="<inp2:m_param name="section_url" js_escape="1"/>" priority="<inp2:m_param name="priority"/>" onclick="<inp2:m_param name="onclick" js_escape="1"/>" name="<inp2:m_phrase name="$label" escape="1"/>" icon="<inp2:$SectionPrefix_ModulePath module="$icon_module"/>img/icons/icon24_<inp2:m_param name="icon"/>.gif" load_url="<inp2:m_param name="late_load" js_escape="1"/>"><inp2:adm_PrintSections render_as="xml_node" section_name="$section_name"/></folder>
+ <folder href="<inp2:m_param name="section_url" js_escape="1"/>" priority="<inp2:m_param name="priority"/>" container="<inp2:m_param name="container"/>" onclick="<inp2:m_param name="onclick" js_escape="1"/>" name="<inp2:m_phrase name="$label" escape="1"/>" icon="<inp2:$SectionPrefix_ModulePath module="$icon_module"/>img/icons/icon24_<inp2:m_param name="icon"/>.gif" load_url="<inp2:m_param name="late_load" js_escape="1"/>"><inp2:adm_PrintSections render_as="xml_node" section_name="$section_name"/></folder>
</inp2:m_if>
</inp2:m_DefineElement>
<table class="tree">
<tbody id="tree">
</tbody>
</table>
<script type="text/javascript">
var TREE_ICONS_PATH = 'img/tree';
var TREE_SHOW_PRIORITY = <inp2:m_if check="adm_ConstOn" name="DBG_SHOW_TREE_PRIORITY" debug_mode="1">1<inp2:m_else/>0</inp2:m_if>;
- var TREE_SHOW_FIRST_ITEM = 0;
<inp2:m_DefineElement name="root_node">
- var the_tree = new TreeFolder('tree', '<inp2:m_param name="label"/>', '<inp2:m_param name="section_url"/>', '<inp2:$SectionPrefix_ModulePath module="$icon_module"/>img/icons/icon24_<inp2:m_param name="icon"/>.gif', null, null, '<inp2:m_param name="priority"/>');
+ var the_tree = new TreeFolder('tree', '<inp2:m_param name="label"/>', '<inp2:m_param name="section_url"/>', '<inp2:$SectionPrefix_ModulePath module="$icon_module"/>img/icons/icon24_<inp2:m_param name="icon"/>.gif', null, null, '<inp2:m_param name="priority"/>', '<inp2:m_param name="container"/>');
</inp2:m_DefineElement>
<inp2:adm_PrintSection render_as="root_node" section_name="in-portal:root"/>
the_tree.AddFromXML('<tree><inp2:adm_PrintSections render_as="xml_node" section_name="in-portal:root"/></tree>');
</script>
</td>
</tr>
</table>
<inp2:m_include t="incs/footer"/>
<script type="text/javascript">
// when changing language submit is made to frameset, not the current frame
var $kf = document.getElementById($form_name);
$kf.target = 'main_frame';
function checkCatalog($cat_id) {
var $ret = checkEditMode();
var $right_frame = getFrame('main');
if ($ret && $right_frame.$is_catalog) {
$right_frame.$Catalog.go_to_cat($cat_id);
return 1; // this opens folder, but disables click
}
return $ret;
}
function checkEditMode()
{
var $phrase = "<inp2:adm_TreeEditWarrning label="la_EditingInProgress" escape="1"/>";
if (getFrame('main').$edit_mode) {
return confirm($phrase) ? true : false;
}
return true;
}
</script>
\ No newline at end of file
Property changes on: branches/RC/core/admin_templates/tree.tpl
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7.2.1
\ No newline at end of property
+1.7.2.2
\ No newline at end of property
Index: branches/RC/core/admin_templates/js/tree.js
===================================================================
--- branches/RC/core/admin_templates/js/tree.js (revision 9257)
+++ branches/RC/core/admin_templates/js/tree.js (revision 9258)
@@ -1,638 +1,633 @@
var last_hightlighted = null;
var last_highlighted_key = null;
function TreeItem(title, url, icon, onclick, priority)
{
this.Title = title;
this.Url = url;
this.Rendered = false;
this.Displayed = false;
this.Level = 0;
this.Icon = icon;
this.Onclick = onclick;
this.Priority = isset(priority) ? priority : false;
this.Children = false;
}
TreeItem.prototype.isFolder = function()
{
return typeof(this.folderClick) == 'function';
}
+TreeItem.prototype.isContainer = function()
+{
+ return this.isFolder() && this.Container;
+}
+
TreeItem.prototype.Render = function(before, force)
{
if (!this.Rendered || force) {
if (!isset(before)) {before = null}
tr = document.createElement('tr');
this.ParentElement.insertBefore(tr, before);
if (!this.Displayed) { tr.style.display = 'none' }
td = document.createElement('td');
td.TreeElement = this;
tr.appendChild(td);
this.appendLevel(td);
if (this.ParentFolder != null) this.appendNodeImage(td);
this.appendIcon(td);
this.appendLink(td);
this.Tr = tr;
this.Rendered = true;
// alert(this.Tr.innerHTML)
}
}
TreeItem.prototype.remove = function()
{
var p = this.Tr.parentNode;
p.removeChild(this.Tr);
}
TreeItem.prototype.appendLevel = function(td)
{
for (var i=0; i < this.Level; i++)
{
img = document.createElement('img');
img.style.width = '16px';
img.style.height = '22px';
img.src = TREE_ICONS_PATH+'/ftv2blank.gif';
img.style.verticalAlign = 'middle';
td.appendChild(img);
}
}
TreeItem.prototype.getNodeImage = function(is_last)
{
return is_last ? TREE_ICONS_PATH+'/ftv2lastnode.gif' : TREE_ICONS_PATH+'/ftv2node.gif';
}
TreeItem.prototype.appendNodeImage = function(td)
{
img = document.createElement('img');
img.style.width = '16px';
img.style.height = '22px';
img.src = this.getNodeImage();
img.style.verticalAlign = 'middle';
td.appendChild(img);
}
TreeItem.prototype.appendIcon = function (td)
{
img = document.createElement('img');
img.style.width = '24px';
img.style.height = '22px';
if (this.Icon.indexOf('http://') != -1) {
img.src = this.Icon;
}
else {
img.src = this.Icon;
}
img.style.verticalAlign = 'middle';
td.appendChild(img);
}
TreeItem.prototype.appendLink = function (td)
{
var $node_text = document.createElement('span');
$node_text.innerHTML = this.Title;
if (TREE_SHOW_PRIORITY && this.Priority !== false) {
$node_text.innerHTML += '<span class="priority"><sup>' + this.Priority + '</sup></span>';
}
link = document.createElement('a');
link.nodeValue = this.Title;
link.href = this.Url;
link.target = 'main';
link.appendChild($node_text);
link.treeItem = this;
//addEvent(link, 'click',
link.onclick =
function(ev) {
var e = is.ie ? window.event : ev;
res = true;
if (isset(this.treeItem.Onclick)) {
res = eval(this.treeItem.Onclick);
}
if (!res) { // if we need to cancel onclick action
if (is.ie) {
window.event.cancelBubble = true;
window.event.returnValue = false;
} else {
ev.preventDefault();
ev.stopPropagation();
}
return res;
}
else {
// ensures, that click is made before AJAX request will be sent
if (res === true) {
// only in case of "true" is returned, used in catalog
-
- if (this.treeItem.isFolder() && TREE_SHOW_FIRST_ITEM) {
- this.treeItem.locateFirstItem().propagateUrl();
- this.href = this.treeItem.Url; // update href's url affected by propagateUrl method
+ if (this.treeItem.isContainer()) {
+ this.href = this.treeItem.locateFirstItem().Url;
}
getFrame(link.target).location.href = this.href;
}
if (!this.treeItem.Expanded && this.treeItem.isFolder()) {
if (this.treeItem.folderClick());
}
this.treeItem.highLight();
return false;
}
}
td.appendChild(link);
/*
if (this.LateLoadURL) {
var span = document.createElement('span');
span.innerHTML = ' Reload';
span.treeItem = this;
span.onclick = function(ev) {
this.treeItem.reload();
}
td.appendChild(span);
}
*/
}
TreeItem.prototype.display = function()
{
this.Tr.style.display = is.ie ? 'block' : 'table-row';
this.Displayed = true;
var do_sub = TreeManager.isExpanded(this.Key);
if (this.Children && do_sub && !this.Expanding) {
this.expand();
}
if (this.ParentFolder != null && !this.ParentFolder.Expanded) {
this.ParentFolder.expand();
}
}
TreeItem.prototype.hide = function()
{
this.Tr.style.display = 'none';
this.Displayed = false;
}
TreeItem.prototype.highLight = function()
{
if (last_hightlighted) last_hightlighted.Tr.className = '';
- if (this.Children && this.Children.length > 0 && (this.Children[0].Url.replace('&', '&') == this.Url.replace('&', '&') || TREE_SHOW_FIRST_ITEM)) {
+ if (this.Children && this.Children.length > 0 && this.isContainer()) {
if (!this.Expanded) {
this.expand();
}
this.Children[0].highLight();
return;
}
this.Tr.className = "highlighted";
last_hightlighted = this;
last_highlighted_key = this.Key;
if (!this.Expanded) {
this.expand();
}
}
TreeItem.prototype.expand = function() {
this.display();
}
TreeItem.prototype.collapse = function() { this.hide() }
TreeItem.prototype.updateLastNodes = function(is_last, lines_pattern)
{
if (!isset(is_last)) is_last = true;
if (!isset(this.Tr)) return;
if (!isset(lines_pattern)) { var lines_pattern = new Array() }
imgs = this.Tr.getElementsByTagName('img');
found = false;
for (var i=0; i<imgs.length; i++)
{
the_img = imgs.item(i);
if (in_array(i, lines_pattern) && the_img.src.indexOf('ftv2blank.gif') != -1) {
the_img.src = TREE_ICONS_PATH+'/ftv2vertline.gif';
}
if (this.isNodeImage(the_img))
{
found = true;
break;
}
}
if (found) {
the_img.src = this.getNodeImage(is_last);
}
this.isLast = is_last;
return lines_pattern;
}
TreeItem.prototype.isNodeImage = function(img)
{
return (
img.src.indexOf('ftv2node.gif') != -1 ||
img.src.indexOf('ftv2lastnode.gif') != -1
)
}
TreeItem.prototype.locateLastItem = function()
{
return this;
}
TreeItem.prototype.locateItemByURL = function(url)
{
if (this.Url == url) return this;
return false;
}
TreeItem.prototype.locateItemByKey = function(key)
{
if (this.Key == key) return this;
return false;
}
-TreeItem.prototype.propagateUrl = function()
-{
- var $tree_node = this;
- while (this.ParentFolder != null && $tree_node.Id == 1) {
- $tree_node = $tree_node.ParentFolder;
- $tree_node.Url = this.Url;
- }
-}
-
TreeItem.prototype.reload = function()
{
}
/* FOLDER */
-function TreeFolder(parent_id, title, url, icon, late_load_url, onclick, priority)
+function TreeFolder(parent_id, title, url, icon, late_load_url, onclick, priority, container)
{
var render = false;
if (isset(parent_id)) {
this.ParentElement = document.getElementById(parent_id);
render = true;
}
else {
}
this.Title = title;
this.Url = url;
this.Rendered = false;
this.Displayed = false;
this.Expanded = false;
this.Level = 0;
this.Id = 0;
this.Tr = null;
this.Icon = icon;
this.LateLoadURL = isset(late_load_url) ? late_load_url : false;
this.Loaded = false;
this.Onclick = onclick;
this.Priority = isset(priority) ? priority : false;
+ this.Container = isset(container) ? parseInt(container) : false;
this.Children = new Array();
this.ChildIndex = 0;
if (render) {
this.Expanded = true;
this.Displayed = true;
this.Render();
this.expand();
}
}
TreeFolder.prototype = new TreeItem;
TreeFolder.prototype.locateLastItem = function()
{
if (this.Children.length == 0) return this;
for (var i=0; i<this.Children.length; i++)
{
last_item = this.Children[i].locateLastItem()
}
return last_item;
}
TreeFolder.prototype.locateFirstItem = function()
{
var $folder_node = this;
- while ($folder_node.isFolder() && $folder_node.Children.length > 0) {
+ while ($folder_node.isContainer() && $folder_node.Children.length > 0) {
$folder_node = $folder_node.Children[0];
}
return $folder_node;
}
TreeFolder.prototype.locateItemByURL = function(url, with_late_load)
{
last_item = false;
-
+
if (this.Url == url && ( (with_late_load && this.LateLoadURL) || !with_late_load) ) {
return this;
}
for (var i=0; i<this.Children.length; i++)
{
last_item = this.Children[i].locateItemByURL(url, with_late_load)
if (last_item) return last_item;
}
return last_item;
}
TreeFolder.prototype.locateItemByKey = function(key)
{
last_item = false;
if (this.Key == key) {
return this;
}
for (var i=0; i<this.Children.length; i++)
{
last_item = this.Children[i].locateItemByKey(key)
if (last_item) return last_item;
}
return last_item;
}
TreeFolder.prototype.locateTopItem = function()
{
if (this.ParentFolder == null) return this;
return this.ParentFolder.locateTopItem();
}
TreeFolder.prototype.AddItem = function(an_item, render, display) {
an_item.ParentElement = this.ParentElement;
an_item.Level = this.ParentFolder != null ? this.Level + 1 : 0;
an_item.ParentFolder = this;
last_item = this.locateLastItem();
this.Children.push(an_item);
an_item.Id = this.Children.length;
an_item.Render(last_item.Tr.nextSibling);
var keys = new Array()
var tmp = an_item;
keys.push(tmp.Level + '_' + tmp.Id);
while (tmp.ParentFolder) {
tmp = tmp.ParentFolder
keys.push(tmp.Level + '_' + tmp.Id);
}
keys = keys.reverse();
key_str = keys.join('-');
an_item.Key = key_str;
if (this.Expanded)
{
an_item.display();
}
return an_item;
}
TreeFolder.prototype.AddFromXML = function(xml, render)
{
// start = new Date();
if (!isset(render)) render = true;
doc = getDocumentFromXML(xml);
this.LastFolder = this;
this.ProcessXMLNode(doc, render);
// end = new Date();
this.locateTopItem().updateLastNodes();
// alert('AddFromXML took: '+(end - start))
}
TreeFolder.prototype.ProcessXMLNode = function(node, render)
{
if (!isset(render)) render = true;
if (!isset(this.LastFolder)) this.LastFolder = this;
for (var i=0; i<node.childNodes.length; i++)
{
child = node.childNodes.item(i);
if (child.tagName == 'folder') {
var backupLastFolder = this.LastFolder;
- this.LastFolder = this.LastFolder.AddItem(new TreeFolder(null, child.getAttribute('name'), child.getAttribute('href'), child.getAttribute('icon'), child.getAttribute('load_url'), child.getAttribute('onclick'), child.getAttribute('priority')), render);
+ this.LastFolder = this.LastFolder.AddItem(new TreeFolder(null, child.getAttribute('name'), child.getAttribute('href'), child.getAttribute('icon'), child.getAttribute('load_url'), child.getAttribute('onclick'), child.getAttribute('priority'), child.getAttribute('container')), render);
if (child.hasChildNodes) {
this.ProcessXMLNode(child);
}
this.LastFolder = backupLastFolder;
}
else if (child.tagName == 'item') {
this.LastFolder.AddItem(new TreeItem(child.firstChild.nodeValue, child.getAttribute('href'), child.getAttribute('icon'), child.getAttribute('onclick'), child.getAttribute('priority')), render)
}
else if (child.tagName == 'tree') {
this.LastFolder = this;
this.ProcessXMLNode(child);
}
}
}
TreeFolder.prototype.getNodeImage = function(is_last)
{
if (is_last) {
return this.Expanded ? TREE_ICONS_PATH+'/ftv2mlastnode.gif' : TREE_ICONS_PATH+'/ftv2plastnode.gif';
}
else {
return this.Expanded ? TREE_ICONS_PATH+'/ftv2mnode.gif' : TREE_ICONS_PATH+'/ftv2pnode.gif';
}
}
TreeFolder.prototype.appendNodeImage = function(td, is_last)
{
img = document.createElement('img');
img.style.width = '16px';
img.style.height = '22px';
img.src = this.getNodeImage(is_last);
img.style.cursor = 'hand';
img.style.cursor = 'pointer';
img.style.verticalAlign = 'middle';
img.onclick = function() { this.parentNode.TreeElement.folderClick(this) }
this.Img = img;
td.appendChild(img);
}
TreeFolder.prototype.updateLastNodes = function(is_last, lines_pattern)
{
if (!isset(is_last)) is_last = true;
if (!isset(lines_pattern)) { var lines_pattern = new Array() }
if (!is_last && !in_array(this.Level, lines_pattern)) { lines_pattern.push(this.Level) }
lines_pattern = TreeItem.prototype.updateLastNodes.apply(this, new Array(is_last, lines_pattern))
for (var i=0; i<this.Children.length; i++)
{
lines_pattern = this.Children[i].updateLastNodes((i+1) == this.Children.length, lines_pattern)
}
lines_pattern[array_search(this.Level, lines_pattern)] = -1;
return lines_pattern;
}
TreeFolder.prototype.isNodeImage = function(img)
{
return (
img.src.indexOf('ftv2mlastnode.gif') != -1 ||
img.src.indexOf('ftv2plastnode.gif') != -1 ||
img.src.indexOf('ftv2mnode.gif') != -1 ||
img.src.indexOf('ftv2pnode.gif') != -1
)
}
TreeFolder.prototype.folderClick = function(img)
{
if (this.Expanded) {
this.collapse();
}
else {
this.expand();
}
}
TreeFolder.prototype.remove = function()
{
this.removeChildren();
var p = this.Tr.parentNode;
p.removeChild(this.Tr);
}
TreeFolder.prototype.removeChildren = function()
{
for (var i in this.Children) {
this.Children[i].remove();
}
this.Children = new Array();
}
TreeFolder.prototype.successCallback = function ($request, $params, $object) {
if ($params == 'reload') {
$object.removeChildren();
}
$object.Loaded = true;
$object.ProcessXMLNode($request.responseXML);
$object.Render();
$object.locateTopItem().updateLastNodes();
$object.expand();
if (last_highlighted_key) {
var fld = $object.locateItemByKey(last_highlighted_key)
if (fld) {
fld.highLight();
}
}
}
TreeFolder.prototype.reload = function()
{
Request.headers['Content-type'] = 'text/xml';
Request.makeRequest(this.LateLoadURL, false, '', this.successCallback, this.errorCallback, 'reload', this);
}
TreeFolder.prototype.errorCallback = function($request, $params, $object) {
alert('AJAX ERROR: ' + Request.getErrorHtml($request));
}
TreeFolder.prototype.expand = function(mode)
{
if (this.Expanding) {
return;
}
this.Expanding = true;
if (!isset(mode)) mode = 0;
this.display();
if (mode == 0 || this.Expanded ) {
for (var i=0; i<this.Children.length; i++)
{
this.Children[i].expand(mode+1);
}
}
if (mode == 0) {
if (this.LateLoadURL && !this.Loaded) {
Request.headers['Content-type'] = 'text/xml';
Request.makeRequest(this.LateLoadURL, false, '', this.successCallback, this.errorCallback, '', this);
}
this.Expanded = true;
TreeManager.markStatus(this.Key, 1)
if (isset(this.Img)) {
this.Img.src = this.getNodeImage(this.isLast);
}
}
this.Expanding = false;
}
TreeFolder.prototype.collapse = function(mode)
{
if (!isset(mode)) mode = 0;
for (var i=0; i<this.Children.length; i++)
{
this.Children[i].collapse(mode+1);
this.Children[i].hide();
}
if (mode == 0) {
this.Expanded = false;
TreeManager.markStatus(this.Key, 0)
if (isset(this.Img)) {
this.Img.src = this.getNodeImage(this.isLast);
}
}
}
function TreeManager() {}
TreeManager.ExpandStatus = new Array ();
TreeManager.markStatus = function(id, status)
{
this.ExpandStatus[id] = status;
if (!status) {
for (var i in this.ExpandStatus) {
if (i.indexOf(id) == 0) { // if i starts with the same as id, meaning it is its child node
this.ExpandStatus[i] = 0;
}
}
}
TreeManager.saveStatus()
}
TreeManager.isExpanded = function(id)
{
return (this.ExpandStatus[id] == 1);
}
TreeManager.saveStatus = function ()
{
var cookieString = new Array();
for (var i in this.ExpandStatus) {
if (this.ExpandStatus[i] == 1) {
cookieString.push(i);
}
}
document.cookie = 'TreeExpandStatus=' + cookieString.join(':');
}
TreeManager.loadStatus = function () {
var $tree_status = getCookie('TreeExpandStatus');
if (!$tree_status) {
return ;
}
$tree_status = $tree_status.split(':');
for (var $i = 0; $i < $tree_status.length; $i++) {
this.ExpandStatus[$tree_status[$i]] = true;
}
// print_pre(this.ExpandStatus);
}
TreeManager.loadStatus();
\ No newline at end of file
Property changes on: branches/RC/core/admin_templates/js/tree.js
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.6.2.3
\ No newline at end of property
+1.6.2.4
\ No newline at end of property
Event Timeline
Log In to Comment