Index: branches/5.2.x/core/units/helpers/sections_helper.php
===================================================================
diff -u -N -r14560 -r14628
--- branches/5.2.x/core/units/helpers/sections_helper.php (.../sections_helper.php) (revision 14560)
+++ branches/5.2.x/core/units/helpers/sections_helper.php (.../sections_helper.php) (revision 14628)
@@ -1,6 +1,6 @@
Application->isCachingType(CACHING_TYPE_MEMORY) ) {
$data = $this->Application->getCache('master:sections_parsed', false, CacheSettings::$sectionsParsedRebuildTime);
@@ -105,10 +106,11 @@
foreach ($prefixes as $prefix) {
$config =& $this->Application->UnitConfigReader->configData[$prefix];
- if (array_key_exists('ConfigPriority', $config)) {
+ if ( array_key_exists('ConfigPriority', $config) ) {
$prioritized_prefixes[$prefix] = $config['ConfigPriority'];
continue;
}
+
$this->_processPrefixSections($prefix);
}
@@ -118,20 +120,24 @@
$this->_processPrefixSections($prefix);
}
- // 2. apply section ajustments
+ // 2. apply section adjustments
foreach ($prefixes as $prefix) {
$config =& $this->Application->UnitConfigReader->configData[$prefix];
- $section_ajustments = getArrayValue($config, 'SectionAdjustments');
- if (!$section_ajustments) continue;
+ $section_adjustments = getArrayValue($config, 'SectionAdjustments');
+ /* @var $section_adjustments Array */
- foreach ($section_ajustments as $section_name => $ajustment_params) {
- if (is_array($ajustment_params)) {
- if (!array_key_exists($section_name, $this->Tree)) {
- // don't process ajustments for non-existing sections
+ if ( !$section_adjustments ) {
+ continue;
+ }
+
+ foreach ($section_adjustments as $section_name => $adjustment_params) {
+ if ( is_array($adjustment_params) ) {
+ if ( !array_key_exists($section_name, $this->Tree) ) {
+ // don't process adjustments for non-existing sections
continue;
}
- $this->Tree[$section_name] = kUtil::array_merge_recursive($this->Tree[$section_name], $ajustment_params);
+ $this->Tree[$section_name] = kUtil::array_merge_recursive($this->Tree[$section_name], $adjustment_params);
}
else {
// then remove section
@@ -146,52 +152,46 @@
$parent_section = $section_params['parent'];
$section_order = "{$section_params['priority']}";
- if (!isset($parent_section)) {
+ if ( !isset($parent_section) ) {
// don't process parent section of "in-portal:root" section
continue;
}
- if (!array_key_exists('children', $this->Tree[$parent_section])) {
+ if ( !array_key_exists('children', $this->Tree[$parent_section]) ) {
$this->Tree[$parent_section]['children'] = Array ();
}
- if (array_key_exists($section_order, $this->Tree[$parent_section]['children'])) {
- trigger_error(
- 'Section "' . $section_name . '" has replaced section "' .
- $this->Tree[$parent_section]['children'][$section_order] .
- '" (parent section: "' . $parent_section .
- '"; duplicate priority: ' . $section_order . ')',
- E_USER_WARNING
- );
+ if ( array_key_exists($section_order, $this->Tree[$parent_section]['children']) ) {
+ trigger_error('Section "' . $section_name . '" has replaced section "' . $this->Tree[$parent_section]['children'][$section_order] . '" (parent section: "' . $parent_section . '"; duplicate priority: ' . $section_order . ')', E_USER_WARNING);
}
$this->Tree[$parent_section]['children'][$section_order] = $section_name;
- if ($section_params['type'] == stTAB) {
+ if ( $section_params['type'] == stTAB ) {
// if this is tab, then mark parent section as TabOnly
$this->Tree[$parent_section]['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)) {
+ // 3.2. process icons here, because they also can be adjusted
+ 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]; // set "icon_module" used in "combined_header" block
- $module_folder = trim( $this->Application->findModule('Name', $regs[1], 'Path'), '/');
+ $module_folder = trim($this->Application->findModule('Name', $regs[1], 'Path'), '/');
- if ($module_folder == '') {
+ if ( $module_folder == '' ) {
$module_folder = 'core';
}
}
else {
$module_folder = $this->Application->getUnitOption($section_params['SectionPrefix'], 'ModuleFolder');
- if (!array_key_exists('icon_module', $section_params)) {
+ if ( !array_key_exists('icon_module', $section_params) ) {
// set "icon_module" used in "combined_header" block
$this->Tree[$section_name]['icon_module'] = $this->Application->findModule('Path', $module_folder . '/', 'Name');
}
}
// 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'];
+ $icon_file = $module_folder . '/admin_templates/img/icons/icon24_' . $this->Tree[$section_name]['icon'];
/*$core_file = FULL_PATH.'/core/admin_templates/img/icons/icon24_' . $this->Tree[$section_name]['icon'].'.png';
if ($module_folder != 'core' && file_exists($core_file) && file_exists(FULL_PATH.'/'.$icon_file.'.png')) {
@@ -200,13 +200,13 @@
}
}*/
- if (!file_exists(FULL_PATH . '/' . $icon_file . '.png')) {
+ if ( !file_exists(FULL_PATH . '/' . $icon_file . '.png') ) {
$this->Tree[$section_name]['icon'] = 'help';
$this->Tree[$section_name]['icon_module'] = 'core';
}
}
- $this->Application->HandleEvent( new kEvent('adm:OnAfterBuildTree') );
+ $this->Application->HandleEvent(new kEvent('adm:OnAfterBuildTree'));
if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) {
$this->Application->setCache('master:sections_parsed', serialize($this->Tree));
@@ -220,12 +220,12 @@
{
$config =& $this->Application->UnitConfigReader->configData[$prefix];
$sections = getArrayValue($config, 'Sections');
- if (!$sections) {
+ /* @var $sections Array */
+
+ if ( !$sections ) {
return ;
}
-// echo 'Prefix: ['.$prefix.'] has ['.count($sections).'] sections
';
-
foreach ($sections as $section_name => $section_params) {
// we could also skip not allowed sections here in future
if ( isset($section_params['SectionPrefix']) ) {
@@ -237,35 +237,37 @@
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) {
+ 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');
+
+ 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'])) {
+ if ( !isset($section_params['url']['t']) ) {
$section_params['url']['t'] = 'index';
}
- if (!isset($section_params['onclick'])) {
+ if ( !isset($section_params['onclick']) ) {
$section_params['onclick'] = 'checkEditMode()';
}
- if (!isset($section_params['container'])) {
+ 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();
+ $current_data = isset($this->Tree[$section_name]) ? $this->Tree[$section_name] : Array ();
- if ($current_data) {
+ if ( $current_data ) {
trigger_error('Section "' . $section_name . '" declaration (originally defined in "' . $current_data['SectionPrefix'] . '") was overwriten from "' . $prefix . '"', E_USER_WARNING);
}
@@ -294,19 +296,21 @@
* Returns first child, that is not a folder
*
* @param string $section_name
- * @param Array $tree
- * @return stirng
+ * @param bool $check_permission
+ * @return string
+ * @access public
*/
- function getFirstChild($section_name, $check_permission = false)
+ public 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) {
+ /* @var $children Array */
+
+ if ( $children ) {
// get 1st child
ksort($children, SORT_NUMERIC);
- foreach ($children as $child_priority => $child_section) {
- if (!$this->sectionVisible($child_section, $check_permission)) {
+ foreach ($children as $child_section) {
+ if ( !$this->sectionVisible($child_section, $check_permission) ) {
continue;
}