Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1245314
sections_helper.php
No One
Temporary
Actions
Download 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
Fri, Nov 21, 6:17 AM
Size
3 KB
Mime Type
text/x-php
Expires
Sun, Nov 23, 6:17 AM (1 d, 22 h)
Engine
blob
Format
Raw Data
Handle
809831
Attached To
rINP In-Portal
sections_helper.php
View Options
<?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
;
if
(
defined
(
'CACHE_PARSED_CONFIGS'
)
&&
CACHE_PARSED_CONFIGS
)
{
$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
();
}
$this
->
Tree
=
Array
();
if
(!
$unit_config_reader
)
{
$unit_config_reader
=&
$this
->
Application
->
recallObject
(
'kUnitConfigReader'
);
}
$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
$section_params
[
'SectionPrefix'
]
=
$prefix
;
$section_params
[
'url'
][
'm_opener'
]
=
'r'
;
$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'
;
}
$current_data
=
isset
(
$this
->
Tree
[
$section_name
])
?
$this
->
Tree
[
$section_name
]
:
Array
();
$this
->
Tree
[
$section_name
]
=
array_merge_recursive2
(
$current_data
,
$section_params
);
$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
;
}
}
}
if
(
defined
(
'CACHE_PARSED_CONFIGS'
)
&&
CACHE_PARSED_CONFIGS
)
{
$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
;
}
}
?>
Event Timeline
Log In to Comment