Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Sun, Aug 24, 11:08 PM

in-portal

Index: branches/unlabeled/unlabeled-1.11.2/core/units/general/helpers/sections_helper.php
===================================================================
--- branches/unlabeled/unlabeled-1.11.2/core/units/general/helpers/sections_helper.php (revision 7032)
+++ branches/unlabeled/unlabeled-1.11.2/core/units/general/helpers/sections_helper.php (revision 7033)
@@ -1,150 +1,152 @@
<?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['icon']) && preg_match('/([^:]+):(.*)/', $section_params['icon'], $regs)) {
- $section_params['icon'] = $regs[2];
- $section_params['icon_module'] = $regs[1];
- }
-
$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. update parent -> children references
+ // 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];
+ }
}
$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;
}
}
?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.11.2/core/units/general/helpers/sections_helper.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.11.2.1
\ No newline at end of property
+1.11.2.2
\ No newline at end of property

Event Timeline