Index: branches/5.3.x/core/kernel/db/db_tag_processor.php
===================================================================
diff -u -N -r15677 -r15698
--- branches/5.3.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 15677)
+++ branches/5.3.x/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 15698)
@@ -1,6 +1,6 @@
Application->getUnitOption($this->Prefix, 'ViewMenuPhrase');
+ $item_name = $this->getUnitConfig()->getViewMenuPhrase();
+
return $this->Application->Phrase($item_name);
}
@@ -69,41 +70,45 @@
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['spearator_block'];
$separator = $this->Application->ParseBlock($block_params);
- $filter_menu = $this->Application->getUnitOption($this->Prefix,'FilterMenu');
- if (!$filter_menu) {
- trigger_error('no filters defined for prefix '.$this->Prefix.', but DrawFilterMenu tag used', E_USER_NOTICE);
+ $filter_menu = $this->getUnitConfig()->getFilterMenu();
+
+ if ( !$filter_menu ) {
+ trigger_error('no filters defined for prefix ' . $this->Prefix . ', but DrawFilterMenu tag used', E_USER_NOTICE);
+
return '';
}
// Params: label, filter_action, filter_status
$block_params['name'] = $params['item_block'];
- $view_filter = $this->Application->RecallVar($this->getPrefixSpecial().'_view_filter');
- if ($view_filter === false) {
+ $view_filter = $this->Application->RecallVar($this->getPrefixSpecial() . '_view_filter');
+ if ( $view_filter === false ) {
$event_params = Array ('prefix' => $this->Prefix, 'special' => $this->Special, 'name' => 'OnRemoveFilters');
- $this->Application->HandleEvent( new kEvent($event_params) );
- $view_filter = $this->Application->RecallVar($this->getPrefixSpecial().'_view_filter');
+ $this->Application->HandleEvent(new kEvent($event_params));
+ $view_filter = $this->Application->RecallVar($this->getPrefixSpecial() . '_view_filter');
}
+
$view_filter = unserialize($view_filter);
- $filters = Array();
+ $filters = Array ();
$prefix_special = $this->getPrefixSpecial();
foreach ($filter_menu['Filters'] as $filter_key => $filter_params) {
- $group_params = isset($filter_params['group_id']) ? $filter_menu['Groups'][ $filter_params['group_id'] ] : Array();
- if (!isset($group_params['element_type'])) {
+ $group_params = isset($filter_params['group_id']) ? $filter_menu['Groups'][$filter_params['group_id']] : Array ();
+ if ( !isset($group_params['element_type']) ) {
$group_params['element_type'] = 'checkbox';
}
- if (!$filter_params) {
+ if ( !$filter_params ) {
$filters[] = $separator;
continue;
}
- $block_params['label'] = addslashes( $this->Application->Phrase($filter_params['label']) );
- if (getArrayValue($view_filter,$filter_key)) {
+ $block_params['label'] = addslashes($this->Application->Phrase($filter_params['label']));
+
+ if ( getArrayValue($view_filter, $filter_key) ) {
$submit = 0;
- if (isset($params['old_style'])) {
+ if ( isset($params['old_style']) ) {
$status = $group_params['element_type'] == 'checkbox' ? 1 : 2;
}
else {
@@ -114,7 +119,8 @@
$submit = 1;
$status = 'null';
}
- $block_params['filter_action'] = 'set_filter("'.$prefix_special.'","'.$filter_key.'","'.$submit.'",'.$params['ajax'].');';
+
+ $block_params['filter_action'] = 'set_filter("' . $prefix_special . '","' . $filter_key . '","' . $submit . '",' . $params['ajax'] . ');';
$block_params['filter_status'] = $status; // 1 - checkbox, 2 - radio, 0 - no image
$filters[] = $this->Application->ParseBlock($block_params);
}
@@ -213,16 +219,16 @@
$def_block = isset($params['block']) ? $params['block'] : '';
$force_block = isset($params['force_block']) ? $params['force_block'] : false;
- $grids = $this->Application->getUnitOption($this->Prefix,'Grids');
- $grid_config = $grids[$params['grid']]['Fields'];
+ $grid = $this->getUnitConfig()->getGridByName($params['grid']);
+ $grid_config = $grid['Fields'];
$picker_helper = $this->Application->recallObject('ColumnPickerHelper');
/* @var $picker_helper kColumnPickerHelper */
$picker_helper->ApplyPicker($this->getPrefixSpecial(), $grid_config, $params['grid']);
- if ($mode == 'fields') {
- return "'".join("','", array_keys($grid_config))."'";
+ if ( $mode == 'fields' ) {
+ return "'" . join("','", array_keys($grid_config)) . "'";
}
$object =& $this->GetList($params);
@@ -243,19 +249,19 @@
$w = $picker_helper->GetWidth($field);
- if ($w) {
+ if ( $w ) {
// column picker width overrides width from unit config
$block_params['width'] = $w;
}
$field_options = $object->GetFieldOptions($field);
- if (array_key_exists('use_phrases', $field_options)) {
+ if ( array_key_exists('use_phrases', $field_options) ) {
$block_params['use_phrases'] = $field_options['use_phrases'];
}
$block_params['is_last'] = ($i == count($grid_config));
- $o.= $this->Application->ParseBlock($block_params, 1);
+ $o .= $this->Application->ParseBlock($block_params, 1);
}
return $o;
@@ -282,10 +288,9 @@
function GridFieldsCount($params)
{
- $grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
- $grid_config = $grids[$params['grid']]['Fields'];
+ $grid = $this->getUnitConfig()->getGridByName($params['grid']);
- return count($grid_config);
+ return count($grid['Fields']);
}
/**
@@ -461,7 +466,8 @@
$direction = (isset($params['direction']) && $params['direction'] == "H") ? "H" : "V";
$columns = (isset($params['columns'])) ? $params['columns'] : 1;
- $id_field = (isset($params['id_field'])) ? $params['id_field'] : $this->Application->getUnitOption($this->Prefix, 'IDField');
+ $config = $this->getUnitConfig();
+ $id_field = (isset($params['id_field'])) ? $params['id_field'] : $config->getIDField();
if ( $columns > 1 && $direction == 'V' ) {
$records_left = array_splice($list->Records, $list->GetSelectedCount()); // because we have 1 more record for "More..." link detection (don't need to sort it)
@@ -490,8 +496,7 @@
$displayed = Array ();
$column_number = 1;
- $cache_mod_rw = $this->Application->getUnitOption($this->Prefix, 'CacheModRewrite') &&
- $this->Application->RewriteURLs() && !$this->Application->isCachingType(CACHING_TYPE_MEMORY);
+ $cache_mod_rw = $config->getCacheModRewrite() && $this->Application->RewriteURLs() && !$this->Application->isCachingType(CACHING_TYPE_MEMORY);
$limit = isset($params['limit']) ? $params['limit'] : false;
@@ -614,7 +619,7 @@
$list_helper = $this->Application->recallObject('ListHelper');
/* @var $list_helper ListHelper */
- $select_clause = $this->Application->getUnitOption($object->Prefix, 'NavigationSelectClause', null);
+ $select_clause = $object->getUnitConfig()->getNavigationSelectClause(null);
return $list_helper->getNavigationResource($object, $params['list'], false, $select_clause);
}
@@ -635,7 +640,7 @@
$list_helper = $this->Application->recallObject('ListHelper');
/* @var $list_helper ListHelper */
- $select_clause = $this->Application->getUnitOption($object->Prefix, 'NavigationSelectClause', null);
+ $select_clause = $object->getUnitConfig()->getNavigationSelectClause(null);
return $list_helper->getNavigationResource($object, $params['list'], true, $select_clause);
}
@@ -1585,18 +1590,17 @@
}
/**
- * Returns index where 1st changable sorting field begins
+ * Returns index where 1st changeable sorting field begins
*
* @return int
* @access private
*/
function getUserSortIndex()
{
- $list_sortings = $this->Application->getUnitOption($this->Prefix, 'ListSortings', Array ());
- $sorting_prefix = getArrayValue($list_sortings, $this->Special) ? $this->Special : '';
+ $list_sortings = $this->getUnitConfig()->getListSortingsBySpecial($this, Array ());
$user_sorting_start = 0;
- $forced_sorting = getArrayValue($list_sortings, $sorting_prefix, 'ForcedSorting');
+ $forced_sorting = getArrayValue($list_sortings, 'ForcedSorting');
return $forced_sorting ? count($forced_sorting) : $user_sorting_start;
}
@@ -1798,8 +1802,7 @@
*/
function UseItemIcons($params)
{
- $grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
- return array_key_exists('Icons', $grids[ $params['grid'] ]);
+ return array_key_exists('Icons', $this->getUnitConfig()->getGridByName($params['grid']));
}
/**
@@ -1830,15 +1833,15 @@
*/
function GridSelector($params)
{
- $grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
+ $grid = $this->getUnitConfig()->getGridByName($params['grid']);
- return array_key_exists('Selector', $grids[ $params['grid'] ]) ? $grids[ $params['grid'] ]['Selector'] : $params['default'];
+ return array_key_exists('Selector', $grid) ? $grid['Selector'] : $params['default'];
}
function ItemIcon($params)
{
- $grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
- $grid = $grids[ $params['grid'] ];
+ $config = $this->getUnitConfig();
+ $grid = $config->getGridByName($params['grid']);
if ( !isset($grid['Icons']) ) {
return '';
@@ -1852,8 +1855,7 @@
return isset($icons[$icon_name]) ? $icons[$icon_name] : '';
}
- $status_fields = $this->Application->getUnitOption($this->Prefix, 'StatusField', Array ());
- /* @var $status_fields Array */
+ $status_fields = $config->getStatusField(false, Array ());
if ( !$status_fields ) {
return $icons['default'];
@@ -1881,77 +1883,88 @@
*/
function SectionTitle($params)
{
+ $config = $this->getUnitConfig();
$preset_name = kUtil::replaceModuleSection($params['title_preset']);
- $title_presets = $this->Application->getUnitOption($this->Prefix,'TitlePresets');
- $title_info = array_key_exists($preset_name, $title_presets) ? $title_presets[$preset_name] : false;
+ $title_info = $config->getTitlePresetByName($preset_name);
- if ($title_info === false) {
+ if ( $title_info === false ) {
$title = str_replace('#preset_name#', $preset_name, $params['title']);
- if ($this->Application->ConfigValue('UseSmallHeader') && isset($params['group_title']) && $params['group_title']) {
- $title .= ' - '.$params['group_title'];
+
+ if ( $this->Application->ConfigValue('UseSmallHeader') && isset($params['group_title']) && $params['group_title'] ) {
+ $title .= ' - ' . $params['group_title'];
}
+
return $title;
}
- if (array_key_exists('default', $title_presets) && $title_presets['default']) {
+ $default_title_preset = $config->getTitlePresetByName('default');
+
+ if ( $default_title_preset ) {
// use default labels + custom labels specified in preset used
- $title_info = kUtil::array_merge_recursive($title_presets['default'], $title_info);
+ $title_info = kUtil::array_merge_recursive($default_title_preset, $title_info);
}
$title = $title_info['format'];
// 1. get objects in use for title construction
- $objects = Array();
- $object_status = Array();
- $status_labels = Array();
+ $objects = Array ();
+ $object_status = Array ();
+ $status_labels = Array ();
$prefixes = array_key_exists('prefixes', $title_info) ? $title_info['prefixes'] : false;
$all_tag_params = array_key_exists('tag_params', $title_info) ? $title_info['tag_params'] : false;
/* @var $prefixes Array */
- if ($prefixes) {
+ if ( $prefixes ) {
// extract tag_params passed directly to SectionTitle tag for specific prefix
foreach ($params as $tp_name => $tp_value) {
- if (preg_match('/(.*)\[(.*)\]/', $tp_name, $regs)) {
- $all_tag_params[ $regs[1] ][ $regs[2] ] = $tp_value;
+ if ( preg_match('/(.*)\[(.*)\]/', $tp_name, $regs) ) {
+ $all_tag_params[$regs[1]][$regs[2]] = $tp_value;
unset($params[$tp_name]);
}
}
- $tag_params = Array();
+ $tag_params = Array ();
+
foreach ($prefixes as $prefix_special) {
$prefix_data = $this->Application->processPrefix($prefix_special);
- $prefix_data['prefix_special'] = rtrim($prefix_data['prefix_special'],'.');
+ $prefix_data['prefix_special'] = rtrim($prefix_data['prefix_special'], '.');
- if ($all_tag_params) {
+ if ( $all_tag_params ) {
$tag_params = getArrayValue($all_tag_params, $prefix_data['prefix_special']);
- if (!$tag_params) {
- $tag_params = Array();
+
+ if ( !$tag_params ) {
+ $tag_params = Array ();
}
}
$tag_params = array_merge($params, $tag_params);
- $objects[ $prefix_data['prefix_special'] ] = $this->Application->recallObject($prefix_data['prefix_special'], $prefix_data['prefix'], $tag_params);
- $object_status[ $prefix_data['prefix_special'] ] = $objects[ $prefix_data['prefix_special'] ]->IsNewItem() ? 'new' : 'edit';
+ $objects[$prefix_data['prefix_special']] = $this->Application->recallObject($prefix_data['prefix_special'], $prefix_data['prefix'], $tag_params);
+ $object_status[$prefix_data['prefix_special']] = $objects[$prefix_data['prefix_special']]->IsNewItem() ? 'new' : 'edit';
// a. set object's status field (adding item/editing item) for each object in title
- if (getArrayValue($title_info[ $object_status[ $prefix_data['prefix_special'] ].'_status_labels' ],$prefix_data['prefix_special'])) {
- $status_labels[ $prefix_data['prefix_special'] ] = $title_info[ $object_status[ $prefix_data['prefix_special'] ].'_status_labels' ][ $prefix_data['prefix_special'] ];
- $title = str_replace('#'.$prefix_data['prefix_special'].'_status#', $status_labels[ $prefix_data['prefix_special'] ], $title);
+ if ( getArrayValue($title_info[$object_status[$prefix_data['prefix_special']] . '_status_labels'], $prefix_data['prefix_special']) ) {
+ $status_labels[$prefix_data['prefix_special']] = $title_info[$object_status[$prefix_data['prefix_special']] . '_status_labels'][$prefix_data['prefix_special']];
+ $title = str_replace('#' . $prefix_data['prefix_special'] . '_status#', $status_labels[$prefix_data['prefix_special']], $title);
}
// b. setting object's titlefield value (in titlebar ONLY) to default in case if object beeing created with no titlefield filled in
- if ($object_status[ $prefix_data['prefix_special'] ] == 'new') {
- $new_value = $this->getInfo( $objects[ $prefix_data['prefix_special'] ], 'titlefield' );
- if(!$new_value && getArrayValue($title_info['new_titlefield'],$prefix_data['prefix_special']) ) $new_value = $this->Application->Phrase($title_info['new_titlefield'][ $prefix_data['prefix_special'] ]);
- $title = str_replace('#'.$prefix_data['prefix_special'].'_titlefield#', $new_value, $title);
+ if ( $object_status[$prefix_data['prefix_special']] == 'new' ) {
+ $new_value = $this->getInfo($objects[$prefix_data['prefix_special']], 'titlefield');
+
+ if ( !$new_value && getArrayValue($title_info['new_titlefield'], $prefix_data['prefix_special']) ) {
+ $new_value = $this->Application->Phrase($title_info['new_titlefield'][$prefix_data['prefix_special']]);
+ }
+
+ $title = str_replace('#' . $prefix_data['prefix_special'] . '_titlefield#', $new_value, $title);
}
}
}
// replace to section title
$section = array_key_exists('section', $params) ? $params['section'] : false;
- if ($section) {
+
+ if ( $section ) {
$sections_helper = $this->Application->recallObject('SectionsHelper');
/* @var $sections_helper kSectionsHelper */
@@ -1963,31 +1976,32 @@
$title = $this->Application->ReplaceLanguageTags($title, false);
// 3. find and replace any replacement vars
- preg_match_all('/#(.*_.*)#/Uis',$title,$rets);
- if ($rets[1]) {
- $replacement_vars = array_keys( array_flip($rets[1]) );
+ preg_match_all('/#(.*_.*)#/Uis', $title, $rets);
+ if ( $rets[1] ) {
+ $replacement_vars = array_keys(array_flip($rets[1]));
+
foreach ($replacement_vars as $replacement_var) {
- $var_info = explode('_',$replacement_var,2);
- $object =& $objects[ $var_info[0] ];
- $new_value = $this->getInfo($object,$var_info[1]);
- $title = str_replace('#'.$replacement_var.'#', $new_value, $title);
+ $var_info = explode('_', $replacement_var, 2);
+ $object =& $objects[$var_info[0]];
+ $new_value = $this->getInfo($object, $var_info[1]);
+ $title = str_replace('#' . $replacement_var . '#', $new_value, $title);
}
}
- // replace trailing spaces inside title preset + '' occurences into single space
+ // replace trailing spaces inside title preset + '' occurrences into single space
$title = preg_replace('/[ ]*\'\'[ ]*/', ' ', $title);
- if ($this->Application->ConfigValue('UseSmallHeader') && isset($params['group_title']) && $params['group_title']) {
- $title .= ' - '.$params['group_title'];
+ if ( $this->Application->ConfigValue('UseSmallHeader') && isset($params['group_title']) && $params['group_title'] ) {
+ $title .= ' - ' . $params['group_title'];
}
$first_chars = $this->SelectParam($params, 'first_chars,cut_first');
- if ($first_chars && !preg_match('/(.*)<\/a>/', $title)) {
+ if ( $first_chars && !preg_match('/(.*)<\/a>/', $title) ) {
// don't cut titles, that contain phrase translation links
$stripped_title = strip_tags($title, $this->SelectParam($params, 'allowed_tags'));
- if (mb_strlen($stripped_title) > $first_chars) {
+ if ( mb_strlen($stripped_title) > $first_chars ) {
$title = mb_substr($stripped_title, 0, $first_chars) . ' ...';
}
}
@@ -2007,13 +2021,15 @@
{
switch ( $info_type ) {
case 'titlefield':
- $field = $this->Application->getUnitOption($object->Prefix, 'TitleField');
+ $field = $object->getUnitConfig()->getTitleField();
+
return $field !== false ? $object->GetField($field) : 'TitleField Missing';
break;
case 'recordcount':
if ( $object->GetRecordsCount(false) != $object->GetRecordsCount() ) {
$of_phrase = $this->Application->Phrase('lc_of');
+
return $object->GetRecordsCount() . ' ' . $of_phrase . ' ' . $object->GetRecordsCount(false);
}
@@ -2137,8 +2153,9 @@
$field = $this->SelectParam($params, 'name,field');
$sql = 'SELECT FieldLabel
- FROM '.$this->Application->getUnitOption('cf', 'TableName').'
- WHERE FieldName = '.$this->Conn->qstr($field);
+ FROM ' . $this->Application->getUnitConfig('cf')->getTableName() . '
+ WHERE FieldName = ' . $this->Conn->qstr($field);
+
return $this->Application->Phrase($this->Conn->GetOne($sql));
}
@@ -2486,28 +2503,29 @@
{
static $language_code = null;
- if (!isset($language_code)) {
- $language_code = 'en'; // defaut value
+ if ( !isset($language_code) ) {
+ $language_code = 'en'; // default value
- if ($this->Application->isAdmin) {
+ if ( $this->Application->isAdmin ) {
$language_id = $this->Application->Phrases->LanguageId;
}
else {
$language_id = $this->Application->GetDefaultLanguageId(); // $this->Application->GetVar('m_lang');
}
$sql = 'SELECT Locale
- FROM '. $this->Application->getUnitOption('lang', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('lang')->getTableName() . '
WHERE LanguageId = ' . $language_id;
- $locale = strtolower( $this->Conn->GetOne($sql) );
+ $locale = strtolower($this->Conn->GetOne($sql));
- if (file_exists(FULL_PATH . EDITOR_PATH . 'editor/lang/' . $locale . '.js')) {
+ if ( file_exists(FULL_PATH . EDITOR_PATH . 'editor/lang/' . $locale . '.js') ) {
// found language file, that exactly matches locale name (e.g. "en")
$language_code = $locale;
}
else {
$locale = explode('-', $locale);
- if (file_exists(FULL_PATH . EDITOR_PATH . 'editor/lang/' . $locale[0] . '.js')) {
+
+ if ( file_exists(FULL_PATH . EDITOR_PATH . 'editor/lang/' . $locale[0] . '.js') ) {
// language file matches first part of locale (e.g. "ru-RU")
$language_code = $locale[0];
}
@@ -2542,15 +2560,17 @@
$styles_js = $this->Application->BaseURL($theme_path) . 'styles.js';
- /*$page_id = $this->Application->GetVar('c_id');
+ $page_id = $this->Application->GetVar('c_id');
$content_id = $this->Application->GetVar('content_id');
$preview_url = '';
- if ($page_id && $content_id) {
+ /*if ($page_id && $content_id) {
// editing content block from Front-End, not category in admin
+ $categories_config = $this->Application->getUnitConfig('c');
+
$sql = 'SELECT NamedParentPath
- FROM ' . $this->Application->getUnitOption('c', 'TableName') . '
- WHERE ' . $this->Application->getUnitOption('c', 'IDField') . ' = ' . (int)$page_id;
+ FROM ' . $categories_config->getTableName() . '
+ WHERE ' . $categories_config->getIDField() . ' = ' . (int)$page_id;
$template = strtolower( $this->Conn->GetOne($sql) );
$url_params = Array ('m_cat_id' => $page_id, 'no_amp' => 1, 'editing_mode' => EDITING_MODE_CONTENT, 'pass' => 'm');
@@ -2674,6 +2694,7 @@
* @param Array $params
* @return string
* @access protected
+ * @throws InvalidArgumentException
*/
protected function AdminEditButton($params)
{
@@ -2690,9 +2711,11 @@
$template = $params['template'];
}
else {
- $admin_template_prefix = $this->Application->getUnitOption($item_prefix, 'AdminTemplatePrefix');
- $template = $this->Application->getUnitOption($item_prefix, 'AdminTemplatePath') . '/' . $admin_template_prefix . 'edit';
+ $item_config = $this->Application->getUnitConfig($item_prefix);
+ $admin_template_prefix = $item_config->getAdminTemplatePrefix();
+ $template = $item_config->getAdminTemplatePath() . '/' . $admin_template_prefix . 'edit';
+
if ( !$admin_template_prefix ) {
throw new InvalidArgumentException('Automatic admin editing template detection failed because of missing "AdminTemplatePrefix" unit config option in "' . $this->Prefix . '" unit config');
}
@@ -2793,8 +2816,8 @@
function PermSection($params)
{
$section = $this->SelectParam($params, 'section,name');
- $perm_sections = $this->Application->getUnitOption($this->Prefix, 'PermSection');
- return isset($perm_sections[$section]) ? $perm_sections[$section] : '';
+
+ return $this->getUnitConfig()->getPermSectionByName($section, '');
}
function PerPageSelected($params)
@@ -2825,9 +2848,9 @@
*/
function getEditTabs($preset_name)
{
- $presets = $this->Application->getUnitOption($this->Prefix, 'EditTabPresets');
+ $presets = $this->getUnitConfig()->getEditTabPresets();
- if (!$presets || !isset($presets[$preset_name]) || count($presets[$preset_name]) == 0) {
+ if ( !$presets || !isset($presets[$preset_name]) || count($presets[$preset_name]) == 0 ) {
return false;
}
@@ -2917,7 +2940,7 @@
*/
function UnitOption($params)
{
- return $this->Application->getUnitOption($this->Prefix, $params['name']);
+ return $this->getUnitConfig()->getSetting($params['name']);
}
/**
@@ -2929,15 +2952,15 @@
function VisibleToolbarButtons($params)
{
$preset_name = kUtil::replaceModuleSection($params['title_preset']);
- $title_presets = $this->Application->getUnitOption($this->Prefix, 'TitlePresets');
+ $preset_info = $this->getUnitConfig()->getTitlePresetByName($preset_name);
- if (!array_key_exists($preset_name, $title_presets)) {
+ if ( !$preset_info ) {
trigger_error('Title preset not specified or missing (in tag "' . $this->getPrefixSpecial() . ':' . __METHOD__ . '")', E_USER_NOTICE);
+
return false;
}
- $preset_info = $title_presets[$preset_name];
- if (!array_key_exists('toolbar_buttons', $preset_info) || !is_array($preset_info['toolbar_buttons'])) {
+ if ( !array_key_exists('toolbar_buttons', $preset_info) || !is_array($preset_info['toolbar_buttons']) ) {
return false;
}
@@ -2982,21 +3005,17 @@
function FieldVisible($params)
{
$check_field = $params['field'];
- $fields = $this->Application->getUnitOption($this->Prefix, 'Fields');
+ $field_options = $this->_getFieldDefinition($check_field);
- if (!array_key_exists($check_field, $fields)) {
- // field not found in real fields array -> it's 100% virtual then
- $fields = $this->Application->getUnitOption($this->Prefix, 'VirtualFields', Array ());
- }
-
- if (!array_key_exists($check_field, $fields)) {
+ if ( !$field_options ) {
$params['field'] = 'Password';
+
return $check_field == 'VerifyPassword' ? $this->FieldVisible($params) : true;
}
- $show_mode = array_key_exists('show_mode', $fields[$check_field]) ? $fields[$check_field]['show_mode'] : true;
+ $show_mode = array_key_exists('show_mode', $field_options) ? $field_options['show_mode'] : true;
- if ($show_mode === smDEBUG) {
+ if ( $show_mode === smDEBUG ) {
return defined('DEBUG_MODE') && DEBUG_MODE;
}
@@ -3011,25 +3030,24 @@
*/
function FieldsVisible($params)
{
- if (!$params['fields']) {
+ if ( !$params['fields'] ) {
return true;
}
$check_fields = explode(',', $params['fields']);
- $fields = $this->Application->getUnitOption($this->Prefix, 'Fields');
- $virtual_fields = $this->Application->getUnitOption($this->Prefix, 'VirtualFields');
foreach ($check_fields as $check_field) {
// when at least one field in subsection is visible, then subsection is visible too
+ $field_options = $this->_getFieldDefinition($check_field);
- if (array_key_exists($check_field, $fields)) {
- $show_mode = array_key_exists('show_mode', $fields[$check_field]) ? $fields[$check_field]['show_mode'] : true;
+ if ( $field_options ) {
+ $show_mode = array_key_exists('show_mode', $field_options) ? $field_options['show_mode'] : true;
}
else {
- $show_mode = array_key_exists('show_mode', $virtual_fields[$check_field]) ? $virtual_fields[$check_field]['show_mode'] : true;
+ $show_mode = true;
}
- if (($show_mode === true) || (($show_mode === smDEBUG) && (defined('DEBUG_MODE') && DEBUG_MODE))) {
+ if ( ($show_mode === true) || (($show_mode === smDEBUG) && (defined('DEBUG_MODE') && DEBUG_MODE)) ) {
// field is visible
return true;
}
@@ -3039,6 +3057,25 @@
}
/**
+ * Returns field definition
+ *
+ * @param string $field_name
+ * @return Array
+ * @access protected
+ */
+ protected function _getFieldDefinition($field_name)
+ {
+ $config = $this->getUnitConfig();
+ $ret = $config->getFieldByName($field_name);
+
+ if ( !$ret ) {
+ $ret = $config->getVirtualFieldByName($field_name);
+ }
+
+ return $ret;
+ }
+
+ /**
* Checks, that requested option is checked inside field value
*
* @param Array $params