Index: core/install/install_toolkit.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/install/install_toolkit.php (revision 15682)
+++ core/install/install_toolkit.php (revision )
@@ -494,12 +494,13 @@
$this->rebuildThemes();
}
- $id_field = $this->Application->getUnitOption('theme', 'IDField');
- $table_name = $this->Application->getUnitOption('theme', 'TableName');
+ $theme_config = $this->Application->getUnitConfig('theme');
+ $id_field = $theme_config->getIDField();
$sql = 'SELECT Name, ' . $id_field . '
- FROM ' . $table_name . '
+ FROM ' . $theme_config->getTableName() . '
ORDER BY Name ASC';
+
return $this->Conn->GetCol($sql, $id_field);
}
@@ -853,7 +854,7 @@
$sql = 'SELECT FieldName, CustomFieldId
FROM ' . TABLE_PREFIX . 'CustomFields
- WHERE Type = ' . $item_type . ' AND IsSystem = 0'; // config is not read here yet :( $this->Application->getUnitOption('p', 'ItemType');
+ WHERE Type = ' . $item_type . ' AND IsSystem = 0'; // config is not read here yet :( $this->Application->getUnitConfig('p')->getItemType();
$custom_fields = $db->GetCol($sql, 'CustomFieldId');
foreach ($custom_fields as $cf_id => $cf_name) {
\ No newline at end of file
Index: core/units/helpers/page_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/page_helper.php (revision 15682)
+++ core/units/helpers/page_helper.php (revision )
@@ -33,7 +33,7 @@
);
$sql = 'SELECT CASE pr.CreatedById WHEN ' . USER_ROOT . ' THEN "root" WHEN ' . USER_GUEST . ' THEN "Guest" ELSE IF(u.Username = "", u.Email, u.Username) END
- FROM ' . $this->Application->getUnitOption('page-revision', 'TableName') . ' pr
+ FROM ' . $this->Application->getUnitConfig('page-revision')->getTableName() . ' pr
LEFT JOIN ' . TABLE_PREFIX . 'Users u ON u.PortalUserId = pr.CreatedById
WHERE (' . implode(') AND (', $where_clause) . ')';
$users = $this->Conn->GetCol($sql);
Index: core/units/priorites/priority_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/priorites/priority_eh.php (revision 15682)
+++ core/units/priorites/priority_eh.php (revision )
@@ -133,8 +133,7 @@
)
);
- $prefixes = $this->Application->getUnitOption($event->Prefix, 'ProcessPrefixes', Array ());
- /* @var $prefixes Array */
+ $prefixes = $event->getUnitConfig()->getProcessPrefixes(Array ());
foreach ($prefixes as $prefix) {
foreach ($hooks as $hook) {
@@ -186,6 +185,7 @@
}
$object = $event->MasterEvent->getObject();
+ /* @var $object kDBItem */
$tmp = $this->Application->RecallVar('priority_changes'.$this->Application->GetVar('m_wid'));
$changes = $tmp ? unserialize($tmp) : array();
@@ -302,8 +302,9 @@
$ids = $this->StoreSelectedIDs($dummy_event);
if ($ids) {
- $id_field = $this->Application->getUnitOption($prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
+ $config = $this->Application->getUnitConfig($prefix);
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
if ( $this->Application->IsTempMode($prefix) ) {
$table_name = $this->Application->GetTempName($table_name, 'prefix:' . $prefix);
Index: core/units/helpers/file_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/file_helper.php (revision 15682)
+++ core/units/helpers/file_helper.php (revision )
@@ -53,8 +53,9 @@
*/
public function SaveItemFiles(&$object)
{
- $table_name = $this->Application->getUnitOption('#file', 'TableName');
- $max_file_count = $this->Application->getUnitOption($object->Prefix, 'FileCount'); // $this->Application->ConfigValue($object->Prefix.'_MaxImageCount');
+ $table_name = $this->Application->getUnitConfig('#file')->getTableName();
+ $max_file_count = $object->getUnitConfig()->getFileCount();
+// $max_file_count = $this->Application->ConfigValue($object->Prefix . '_MaxImageCount');
$this->CheckFolder(FULL_PATH . ITEM_FILES_PATH);
@@ -159,13 +160,9 @@
*/
public function createUploadFields($prefix, $fields_values, $is_image = false)
{
- $field_options = Array (
- 'type' => 'string',
- 'max_len' => 240,
- 'default' => '',
- );
+ $field_options = Array ('type' => 'string', 'max_len' => 240, 'default' => '',);
- if ($is_image) {
+ if ( $is_image ) {
$field_options['formatter'] = 'kPictureFormatter';
$field_options['include_path'] = 1;
$field_options['allowed_types'] = Array ('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif', 'image/bmp');
@@ -178,29 +175,28 @@
$field_prefix = 'File';
}
- $fields = $this->Application->getUnitOption($prefix, 'Fields');
- $virtual_fields = $this->Application->getUnitOption($prefix, 'VirtualFields');
-
$image_count = 0;
+ $config = $this->Application->getUnitConfig($prefix);
+
foreach ($fields_values as $field_name => $field_value) {
- if (preg_match('/^('.$field_prefix.'[\d]+|Primary'.$field_prefix.')$/', $field_name)) {
+ if ( preg_match('/^(' . $field_prefix . '[\d]+|Primary' . $field_prefix . ')$/', $field_name) ) {
- $fields[$field_name] = $field_options;
- $virtual_fields[$field_name] = $field_options;
- $this->_createCustomFields($prefix, $field_name, $virtual_fields, $is_image);
+ $config->addFields($field_options, $field_name);
+ $config->addVirtualFields($field_options, $field_name);
+ $this->_createCustomFields($prefix, $field_name, $config, $is_image);
$image_count++;
}
}
- if (!$image_count) {
+ if ( !$image_count ) {
// no images found in POST -> create default image fields
- $image_count = $this->Application->ConfigValue($prefix.'_MaxImageCount');
+ $image_count = $this->Application->ConfigValue($prefix . '_MaxImageCount');
- if ($is_image) {
+ if ( $is_image ) {
$created_count = 1;
$image_names = Array ('Primary' . $field_prefix => '');
- while ($created_count < $image_count) {
+ while ( $created_count < $image_count ) {
$image_names[$field_prefix . $created_count] = '';
$created_count++;
}
@@ -209,22 +205,20 @@
$created_count = 0;
$image_names = Array ();
- while ($created_count < $image_count) {
+ while ( $created_count < $image_count ) {
$image_names[$field_prefix . ($created_count + 1)] = '';
$created_count++;
}
}
- if ($created_count) {
+ if ( $created_count ) {
$this->createUploadFields($prefix, $image_names, $is_image);
}
- return ;
+ return;
}
- $this->Application->setUnitOption($prefix, $field_prefix.'Count', $image_count);
- $this->Application->setUnitOption($prefix, 'Fields', $fields);
- $this->Application->setUnitOption($prefix, 'VirtualFields', $virtual_fields);
+ $config->setSetting($field_prefix . 'Count', $image_count);
}
/**
@@ -232,17 +226,17 @@
*
* @param string $prefix
* @param string $field_name
- * @param Array $virtual_fields
+ * @param kUnitConfig $config
* @param bool $is_image
* @return void
* @access protected
*/
- protected function _createCustomFields($prefix, $field_name, &$virtual_fields, $is_image = false)
+ protected function _createCustomFields($prefix, $field_name, kUnitConfig $config, $is_image = false)
{
- $virtual_fields['Delete' . $field_name] = Array ('type' => 'int', 'default' => 0);
+ $config->addVirtualFields(Array ('type' => 'int', 'default' => 0), 'Delete' . $field_name);
if ( $is_image ) {
- $virtual_fields[$field_name . 'Alt'] = Array ('type' => 'string', 'default' => '');
+ $config->addVirtualFields(Array ('type' => 'string', 'default' => ''), $field_name . 'Alt');
}
}
\ No newline at end of file
Index: core/units/groups/group_tp.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/groups/group_tp.php (revision 15682)
+++ core/units/groups/group_tp.php (revision )
@@ -23,14 +23,15 @@
*/
function ModifyUnitConfig($params)
{
- $edit_tab_presets = $this->Application->getUnitOption($this->Prefix, 'EditTabPresets');
-
$event = new kEvent($this->getPrefixSpecial() . ':OnItemBuild');
$permission = $event->getSection() . '.advanced:manage_permissions';
+
- if (!$this->Application->CheckPermission($permission)) {
+ if ( !$this->Application->CheckPermission($permission) ) {
- unset($edit_tab_presets['Default']['permissions']);
- }
+ $config = $this->getUnitConfig();
- $this->Application->setUnitOption($this->Prefix, 'EditTabPresets', $edit_tab_presets);
+ $edit_tab_preset = $config->getEditTabPresetByName('Default');
+ unset($edit_tab_preset['permissions']);
+ $config->addEditTabPresets($edit_tab_preset, 'Default');
+ }
}
}
\ No newline at end of file
Index: core/units/sections/site_config_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/sections/site_config_eh.php (revision 15682)
+++ core/units/sections/site_config_eh.php (revision )
@@ -43,8 +43,10 @@
$cut_pos = strrpos($prefix_file, '_config.php');
$prefix_file = substr($prefix_file, 0, $cut_pos) . '_' . $event->MasterEvent->Prefix . '.php';
+ $master_config = $event->MasterEvent->getUnitConfig();
+
if (file_exists(SYSTEM_PRESET_PATH . DIRECTORY_SEPARATOR . $prefix_file)) {
- if ( $this->Application->getUnitOption($event->MasterEvent->Prefix, 'SiteConfigProcessed') ) {
+ if ( $master_config->getSiteConfigProcessed() ) {
// don't apply same site config twice during installation
return ;
}
@@ -70,6 +72,6 @@
// apply changes
$this->_helper->processConfigChanges($event->MasterEvent->Prefix, $changes);
- $this->Application->setUnitOption($event->MasterEvent->Prefix, 'SiteConfigProcessed', true);
+ $master_config->setSiteConfigProcessed(true);
}
}
\ No newline at end of file
Index: core/kernel/utility/unit_config.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/utility/unit_config.php (revision )
+++ core/kernel/utility/unit_config.php (revision )
@@ -0,0 +1,1029 @@
+ ConfigMappings
+ * StatusField -> StatusFields
+ * PermSection -> PermSections
+ */
+
+/**
+ * @method Array getFilterMenu(mixed $default = false)
+ * @method kUnitConfig setFilterMenu(Array $value)
+ *
+ * @method Array getConfigMapping(mixed $default = false)
+ * @method kUnitConfig setConfigMapping(Array $value)
+ *
+ *
+ * @method string getModuleFolder(mixed $default = false)
+ * @method kUnitConfig setModuleFolder(string $value)
+ *
+ * @method string getBasePath(mixed $default = false)
+ * @method kUnitConfig setBasePath(string $value)
+ *
+ * @method Array getEventHandlerClass(mixed $default = false)
+ * @method kUnitConfig setEventHandlerClass(Array $value)
+ *
+ * @method Array getTagProcessorClass(mixed $default = false)
+ * @method kUnitConfig setTagProcessorClass(Array $value)
+ *
+ * @method Array getItemClass(mixed $default = false)
+ * @method kUnitConfig setItemClass(Array $value)
+ *
+ * @method Array getListClass(mixed $default = false)
+ * @method kUnitConfig setListClass(Array $value)
+ *
+ * @method Array getValidatorClass(mixed $default = false)
+ * @method kUnitConfig setValidatorClass(Array $value)
+ *
+ * @method Array getQueryString(mixed $default = false)
+ * @method kUnitConfig setQueryString(Array $value)
+ *
+ * @method string getPermItemPrefix(mixed $default = false)
+ * @method kUnitConfig setPermItemPrefix(string $value)
+ *
+ * @method string getPermTabText(mixed $default = false)
+ * @method kUnitConfig setPermTabText(string $value)
+ *
+ * @method Array getPermSection(mixed $default = false)
+ * @method kUnitConfig setPermSection(Array $value)
+ *
+ * @method bool getAutoLoad(mixed $default = false)
+ * @method kUnitConfig setAutoLoad(bool $value)
+ *
+ * @method string getIDField(mixed $default = false)
+ * @method kUnitConfig setIDField(string $value)
+ *
+ * @method string getTableName(mixed $default = false)
+ * @method kUnitConfig setTableName(string $value)
+ *
+ * @method string getCustomDataTableName(mixed $default = false)
+ * @method kUnitConfig setCustomDataTableName(string $value)
+ *
+ * @method kUnitConfig setStatusField(Array $value)
+ *
+ * @method string getTitleField(mixed $default = false)
+ * @method kUnitConfig setTitleField(string $value)
+ *
+ * @method string getOrderField(mixed $default = false)
+ * @method kUnitConfig setOrderField(string $value)
+ *
+ * @method string getOwnerField(mixed $default = false)
+ * @method kUnitConfig setOwnerField(string $value)
+ *
+ * @method int getConfigPriority(mixed $default = false)
+ * @method kUnitConfig setConfigPriority(int $value)
+ *
+ * @method bool getCatalogItem(mixed $default = false)
+ * @method kUnitConfig setCatalogItem(bool $value)
+ *
+ * @method string getCatalogSelectorName(mixed $default = false)
+ * @method kUnitConfig setCatalogSelectorName(string $value)
+ *
+ * @method string getAdminTemplatePath(mixed $default = false)
+ * @method kUnitConfig setAdminTemplatePath(string $value)
+ *
+ * @method string getAdminTemplatePrefix(mixed $default = false)
+ * @method kUnitConfig setAdminTemplatePrefix(string $value)
+ *
+ * @method string getSearchConfigPostfix(mixed $default = false)
+ * @method kUnitConfig setSearchConfigPostfix(string $value)
+ *
+ * @method string getTitlePhrase(mixed $default = false)
+ * @method kUnitConfig setTitlePhrase(string $value)
+ *
+ * @method int getItemType(mixed $default = false)
+ * @method kUnitConfig setItemType(int $value)
+ *
+ * @method Array getStatisticsInfo(mixed $default = false)
+ * @method kUnitConfig setStatisticsInfo(Array $value)
+ *
+ * @method string getViewMenuPhrase(mixed $default = false)
+ * @method kUnitConfig setViewMenuPhrase(string $value)
+ *
+ * @method string getCatalogTabIcon(mixed $default = false)
+ * @method kUnitConfig setCatalogTabIcon(string $value)
+ *
+ * @method bool getCacheModRewrite(mixed $default = false)
+ * @method kUnitConfig setCacheModRewrite(bool $value)
+ *
+ * @method kUnitConfig setParentTableKey(mixed $value)
+ *
+ * @method kUnitConfig setForeignKey(mixed $value)
+ *
+ * @method string getConstrain(mixed $default = false)
+ * @method kUnitConfig setConstrain(string $value)
+ *
+ * @method bool getAutoDelete(mixed $default = false)
+ * @method kUnitConfig setAutoDelete(bool $value)
+ *
+ * @method bool getAutoClone(mixed $default = false)
+ * @method kUnitConfig setAutoClone(bool $value)
+ *
+ * @method string getParentPrefix(mixed $default = false)
+ * @method kUnitConfig setParentPrefix(string $value)
+ *
+ * @method bool getCheckSimulatniousEdit(mixed $default = false)
+ * @method kUnitConfig setCheckSimulatniousEdit(bool $value)
+ *
+ * @method bool getPortalStyleEnv(mixed $default = false)
+ * @method kUnitConfig setPortalStyleEnv(bool $value)
+ *
+ * @method int getRewritePriority(mixed $default = false)
+ * @method kUnitConfig setRewritePriority(int $value)
+ *
+ * @method Array getRewriteListener(mixed $default = false)
+ * @method kUnitConfig setRewriteListener(Array $value)
+ *
+ * @method bool getForceDontLogChanges(mixed $default = false)
+ * @method kUnitConfig setForceDontLogChanges(bool $value)
+ *
+ * @method Array getUserProfileMapping(mixed $default = false)
+ * @method kUnitConfig setUserProfileMapping(Array $value)
+ *
+ * @method bool getUsePendingEditing(mixed $default = false)
+ * @method kUnitConfig setUsePendingEditing(bool $value)
+ *
+ * @method string getNavigationSelectClause(mixed $default = false)
+ * @method kUnitConfig setNavigationSelectClause(string $value)
+ *
+ * @method bool getPopulateMlFields(bool $default = false)
+ * @method kUnitConfig setPopulateMlFields(bool $value)
+ *
+ * @method bool getLogChanges(bool $default = false)
+ * @method kUnitConfig setLogChanges(bool $value)
+ *
+ * @method int getFileCount(bool $default = false)
+ * @method kUnitConfig setFileCount(int $value)
+ *
+ * @method int getImageCount(bool $default = false)
+ * @method kUnitConfig setImageCount(int $value)
+ *
+ * @method string getDownloadHelperClass(bool $default = false)
+ * @method kUnitConfig setDownloadHelperClass(string $value)
+ *
+ * @method string getSectionPrefix(bool $default = false)
+ * @method kUnitConfig setSectionPrefix(string $value)
+ *
+ * @method bool getSiteConfigProcessed(bool $default = false)
+ * @method kUnitConfig setSiteConfigProcessed(bool $value)
+ *
+ *
+ * @method Array getRegisterClasses(mixed $default = false)
+ * @method kUnitConfig setRegisterClasses(Array $value)
+ * @method kUnitConfig addRegisterClasses(Array $value, string $name = null)
+ * @method kUnitConfig removeRegisterClasses(string $name = null)
+ *
+ * @method Array getScheduledTasks(mixed $default = false)
+ * @method Array getScheduledTaskByName(string $name, mixed $default = false)
+ * @method kUnitConfig setScheduledTasks(Array $value)
+ * @method kUnitConfig addScheduledTasks(Array $value, string $name = null)
+ * @method kUnitConfig removeScheduledTasks(string $name = null)
+ *
+ * @method Array getTitlePresets(mixed $default = false)
+ * @method Array getTitlePresetByName(string $name, mixed $default = false)
+ * @method kUnitConfig setTitlePresets(Array $value)
+ * @method kUnitConfig addTitlePresets(Array $value, string $name = null)
+ * @method kUnitConfig removeTitlePresets(string $name = null)
+ *
+ * @method Array getSections(mixed $default = false)
+ * @method Array getSectionByName(string $name, mixed $default = false)
+ * @method kUnitConfig setSections(Array $value)
+ * @method kUnitConfig addSections(Array $value, string $name = null)
+ * @method kUnitConfig removeSections(string $name = null)
+ *
+ * @method Array getFields(mixed $default = false)
+ * @method Array getFieldByName(string $name, mixed $default = false)
+ * @method kUnitConfig setFields(Array $value)
+ * @method kUnitConfig addFields(Array $value, string $name = null)
+ * @method kUnitConfig removeFields(string $name = null)
+ *
+ * @method Array getVirtualFields(mixed $default = false)
+ * @method Array getVirtualFieldByName(string $name, mixed $default = false)
+ * @method kUnitConfig setVirtualFields(Array $value)
+ * @method kUnitConfig addVirtualFields(Array $value, string $name = null)
+ * @method kUnitConfig removeVirtualFields(string $name = null)
+ *
+ * @method Array getGrids(mixed $default = false)
+ * @method Array getGridByName(string $name, mixed $default = false)
+ * @method kUnitConfig setGrids(Array $value)
+ * @method kUnitConfig addGrids(Array $value, string $name = null)
+ * @method kUnitConfig removeGrids(string $name = null)
+ *
+ * @method Array getHooks(mixed $default = false)
+ * @method kUnitConfig setHooks(Array $value)
+ * @method kUnitConfig addHooks(Array $value, string $name = null)
+ * @method kUnitConfig removeHooks(string $name = null)
+ *
+ * @method Array getAggregateTags(mixed $default = false)
+ * @method kUnitConfig setAggregateTags(Array $value)
+ * @method kUnitConfig addAggregateTags(Array $value, string $name = null)
+ * @method kUnitConfig removeAggregateTags(string $name = null)
+ *
+ * @method Array getEditTabPresets(mixed $default = false)
+ * @method Array getEditTabPresetByName(string $name, mixed $default = false)
+ * @method kUnitConfig setEditTabPresets(Array $value)
+ * @method kUnitConfig addEditTabPresets(Array $value, string $name = null)
+ * @method kUnitConfig removeEditTabPresets(string $name = null)
+ *
+ * @method Array getSubItems(mixed $default = false)
+ * @method kUnitConfig setSubItems(Array $value)
+ * @method kUnitConfig addSubItems(string $value, string $name = null)
+ * @method kUnitConfig removeSubItems(string $name = null)
+ *
+ * @method Array getCustomFields(mixed $default = false)
+ * @method string getCustomFieldByName(string $name, mixed $default = false)
+ * @method kUnitConfig setCustomFields(Array $value)
+ * @method kUnitConfig addCustomFields(Array $value, string $name = null)
+ * @method kUnitConfig removeCustomFields(string $name = null)
+ *
+ * @method Array getClones(mixed $default = false)
+ * @method Array getCloneByName(string $name, mixed $default = false)
+ * @method kUnitConfig setClones(Array $value)
+ * @method kUnitConfig addClones(Array $value, string $name = null)
+ * @method kUnitConfig removeClones(string $name = null)
+ *
+ * @method Array getProcessPrefixes(mixed $default = false)
+ * @method kUnitConfig setProcessPrefixes(Array $value)
+ * @method kUnitConfig addProcessPrefixes(string $value, string $name = null)
+ * @method kUnitConfig removeProcessPrefixes(string $name = null)
+ *
+ * @method Array getForms(mixed $default = false)
+ * @method Array getFormByName(string $name, mixed $default = false)
+ * @method kUnitConfig setForms(Array $value)
+ * @method kUnitConfig addForms(Array $value, string $name = null)
+ * @method kUnitConfig removeForms(string $name = null)
+ *
+ * @method Array getReplacementTemplates(mixed $default = false)
+ * @method string getReplacementTemplateByName(string $name, mixed $default = false)
+ * @method kUnitConfig setReplacementTemplates(Array $value)
+ * @method kUnitConfig addReplacementTemplates(string $value, string $name = null)
+ * @method kUnitConfig removeReplacementTemplates(string $name = null)
+ *
+ * @method Array getItemPropertyMappings(mixed $default = false)
+ * @method string getItemPropertyMappingByName(string $name, mixed $default = false)
+ * @method kUnitConfig setItemPropertyMappings(Array $value)
+ * @method kUnitConfig addItemPropertyMappings(string $value, string $name = null)
+ * @method kUnitConfig removeItemPropertyMappings(string $name = null)
+ *
+ * @method Array getSectionAdjustments(mixed $default = false)
+ * @method mixed getSectionAdjustmentByName(string $name, mixed $default = false)
+ * @method kUnitConfig setSectionAdjustments(Array $value)
+ * @method kUnitConfig addSectionAdjustments(mixed $value, string $name = null)
+ * @method kUnitConfig removeSectionAdjustments(string $name = null)
+ *
+ * @method Array getImportKeys(mixed $default = false)
+ * @method kUnitConfig setImportKeys(Array $value)
+ * @method kUnitConfig addImportKeys(mixed $value, string $name = null)
+ * @method kUnitConfig removeImportKeys(string $name = null)
+ *
+ *
+ * @method Array getCalculatedFieldSpecials(mixed $default = Array ())
+ * @method Array getCalculatedFieldsBySpecial(mixed $special, mixed $default = Array ())
+ * @method kUnitConfig setCalculatedFieldsBySpecial(mixed $special, Array $value)
+ * @method kUnitConfig addCalculatedFieldsBySpecial(mixed $special, mixed $value, string $name = null)
+ * @method kUnitConfig removeCalculatedFieldsBySpecial(mixed $special, string $name = null)
+ *
+ * @method Array getAggregatedCalculatedFieldSpecials(mixed $default = Array ())
+ * @method Array getAggregatedCalculatedFieldsBySpecial(mixed $special, mixed $default = Array ())
+ * @method kUnitConfig setAggregatedCalculatedFieldsBySpecial(mixed $special, Array $value)
+ * @method kUnitConfig addAggregatedCalculatedFieldsBySpecial(mixed $special, mixed $value, string $name = null)
+ * @method kUnitConfig removeAggregatedCalculatedFieldsBySpecial(mixed $special, string $name = null)
+ *
+ * @method Array getListSQLSpecials(mixed $default = Array ())
+ * @method string getListSQLsBySpecial(mixed $special, mixed $default = Array ())
+ * @method kUnitConfig setListSQLsBySpecial(mixed $special, string $value)
+ * @method kUnitConfig removeListSQLsBySpecial(mixed $special, string $name = null)
+ *
+ * @method Array getListSortingSpecials(mixed $default = Array ())
+ * @method Array getListSortingsBySpecial(mixed $special, mixed $default = Array ())
+ * @method kUnitConfig setListSortingsBySpecial(mixed $special, Array $value)
+ * @method kUnitConfig addListSortingsBySpecial(mixed $special, mixed $value, string $name = null)
+ * @method kUnitConfig removeListSortingsBySpecial(mixed $special, string $name = null)
+ *
+ * @method Array getItemSQLSpecials(mixed $default = Array ())
+ * @method string getItemSQLsBySpecial(mixed $special, mixed $default = Array ())
+ * @method kUnitConfig setItemSQLsBySpecial(mixed $special, string $value)
+ * @method kUnitConfig removeItemSQLsBySpecial(mixed $special, string $name = null)
+ */
+class kUnitConfig {
+
+ /**
+ * Unit config prefix
+ *
+ * @var string
+ * @access protected
+ */
+ protected $_prefix = '';
+
+ /**
+ * Default unit config data
+ *
+ * @var Array
+ * @access protected
+ */
+ protected static $_defaults = Array (
+ 'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
+ 'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
+ 'EventHandlerClass' => Array ('class' => 'kDBEventHandler', 'file' => '', 'build_event' => 'OnBuild'),
+ 'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
+
+ 'AutoLoad' => true,
+
+ 'QueryString' => Array (
+ 1 => 'id',
+ 2 => 'Page',
+ 3 => 'PerPage',
+ 4 => 'event',
+ 5 => 'mode',
+ ),
+
+ 'ListSQLs' => Array (
+ '' => ' SELECT %1$s.* %2$s
+ FROM %1$s',
+ ),
+
+ 'Fields' => Array (),
+ );
+
+ /**
+ * Word endings, that are suffixed with "es" instead of just "s" during pluralisation
+ *
+ * @var string
+ * @access protected
+ */
+ protected static $_singularEndingsRegExp = '/(x|s|z|sh|ch)$/';
+
+ /**
+ * Words, that ends with es/s, but are always singulars
+ *
+ * @var string
+ * @access protected
+ */
+ protected static $_alwaysSingularRegExp = '/(class|LogChanges|ForceDontLogChanges|PopulateMlFields)$/i';
+
+ /**
+ * Unit config data
+ *
+ * @var Array
+ * @access protected
+ */
+ protected $_data = Array ();
+
+ /**
+ * Unit config settings that can have different values based on special
+ *
+ * @var Array
+ * @access protected
+ */
+ protected $_specialBased = Array (
+ 'CalculatedFields', 'AggregatedCalculatedFields', 'ListSQLs', 'ListSortings', 'ItemSQLs',
+ );
+
+ /**
+ * Unit config settings, that allow data to be added without a key
+ *
+ * @var Array
+ * @access protected
+ */
+ protected $_withoutKeys = Array (
+ 'RegisterClasses', 'Hooks', 'AggregateTags'
+ );
+
+ /**
+ * Dynamic method name, that was called
+ *
+ * @var string
+ * @access protected
+ */
+ protected $_currentMethodName = '';
+
+ /**
+ * Arguments given to dynamic method name, that was called
+ *
+ * @var Array
+ * @access protected
+ */
+ protected $_currentArguments = Array ();
+
+ /**
+ * Creates new instance of kUnitConfig class
+ *
+ * @param string $prefix
+ * @param Array $defaults
+ * @param bool $use_global_defaults
+ * @access public
+ */
+ public function __construct($prefix, $defaults = null, $use_global_defaults = true)
+ {
+ $this->_prefix = $prefix;
+
+ $merge_with = $use_global_defaults ? self::$_defaults : Array ();
+ $this->_data = array_merge($merge_with, isset($defaults) ? $defaults : Array ());
+ }
+
+ /**
+ * Returns unit config prefix
+ *
+ * @return string
+ * @access public
+ */
+ public function getPrefix()
+ {
+ return $this->_prefix;
+ }
+
+ /**
+ * Ensures, that only unit config data is saved when object is serialized
+ *
+ * @return Array
+ * @access public
+ */
+ public function __sleep()
+ {
+ return Array ('_prefix', '_data');
+ }
+
+ /**
+ * Dumps unit config into a file
+ *
+ * @return void
+ * @access public
+ */
+ public function dump()
+ {
+ kUtil::print_r($this->_data, 'Unit Config', true);
+ }
+
+ /**
+ * Returns unit config data in raw form
+ *
+ * @return Array
+ * @access public
+ */
+ public function getRaw()
+ {
+ return $this->_data;
+ }
+
+ /**
+ * Processed dynamically created methods for changing unit config settings
+ *
+ * @param string $method_name
+ * @param Array $arguments
+ * @return mixed
+ * @throws InvalidArgumentException
+ * @throws RuntimeException
+ * @access public
+ */
+ public function __call($method_name, $arguments)
+ {
+// === regular ===
+// get{SettingName}()
+// set{SettingName}($value)
+// add{SettingName}s(string $value, string $name = null)
+// remove{SettingName}(string $name = null)
+
+// === by special ===
+// get{SettingName}Specials()
+// get{SettingName}sBySpecial($special)
+// set{SettingName}BySpecial($special, $value)
+// add{SettingName}sBySpecial(string $special, Array $value, string $name = null)
+// remove{SettingName}sBySpecial(string $special, $name = null)
+
+ if ( !preg_match('/^(get|set|add|remove)(.*?)(BySpecial|Specials|ByName)*$/', $method_name, $regs) ) {
+ throw new RuntimeException('Unknown method ' . __CLASS__ . '::' . $this->_currentMethodName . '');
+ }
+
+ $this->_currentMethodName = $method_name;
+ $this->_currentArguments = $arguments;
+ $to_call = '_process' . ucfirst($regs[1]);
+
+ return $this->$to_call($regs[2], isset($regs[3]) ? $regs[3] : '');
+ }
+
+ /**
+ * Processes calls to "get*" methods
+ *
+ * @param string $setting_name
+ * @param string $suffix
+ * @return mixed
+ * @access protected
+ */
+ protected function _processGet($setting_name, $suffix = '')
+ {
+ $is_plural = $this->_isPluralSetting($setting_name);
+
+ if ( $suffix == 'BySpecial' && $is_plural ) {
+ // get{SettingName}BySpecial($special, $default = false)
+ $this->_verifyArguments(Array ('special'));
+
+ return $this->getSetting($setting_name, $this->_getDefaultValue(1, Array ()), $this->_currentArguments[0]);
+ }
+ elseif ( $suffix == 'Specials' && !$is_plural ) {
+ // get{SettingName}Specials($default = Array ())
+ $result = $this->getSetting($this->_getPlural($setting_name), $this->_getDefaultValue(0, Array ()));
+
+ return array_keys($result);
+ }
+ elseif ( $suffix == 'ByName' && !$is_plural ) {
+ $sub_key = $this->_currentArguments[0];
+ $result = $this->getSetting($this->_getPlural($setting_name), Array ());
+
+ return isset($result[$sub_key]) ? $result[$sub_key] : $this->_getDefaultValue(1, false);
+ }
+
+ // get{SettingName}($default = false)
+ return $this->getSetting($setting_name, $this->_getDefaultValue(0, false));
+ }
+
+ /**
+ * Returns default value from given argument or false, when not passed
+ *
+ * @param int $arg_index
+ * @param mixed $default
+ * @return bool
+ * @access protected
+ */
+ protected function _getDefaultValue($arg_index, $default = false)
+ {
+ return isset($this->_currentArguments[$arg_index]) ? $this->_currentArguments[$arg_index] : $default;
+ }
+
+ /**
+ * Processes calls to "set*" methods
+ *
+ * @param string $setting_name
+ * @param string $suffix
+ * @return kUnitConfig
+ * @access protected
+ */
+ protected function _processSet($setting_name, $suffix = '')
+ {
+ $is_plural = $this->_isPluralSetting($setting_name);
+
+ if ( $suffix == 'BySpecial' && $is_plural ) {
+ // set{SettingName}BySpecial($special, $value)
+ $this->_verifyArguments(Array ('special', 'value'));
+
+ return $this->setSetting($setting_name, $this->_currentArguments[1], $this->_currentArguments[0]);
+ }
+
+ // set{SettingName}($value)
+ $this->_verifyArguments(Array ('value'));
+
+ return $this->setSetting($setting_name, $this->_currentArguments[0]);
+ }
+
+ /**
+ * Processes calls to "add*" method
+ *
+ * @param string $setting_name
+ * @param string $suffix
+ * @return kUnitConfig
+ * @access protected
+ * @throws InvalidArgumentException
+ */
+ protected function _processAdd($setting_name, $suffix = '')
+ {
+ $arguments = $this->_currentArguments;
+
+ if ( !$this->_isPluralSetting($setting_name) ) {
+ throw new InvalidArgumentException('Setting "' . $setting_name . '" isn\'t plural');
+ }
+
+ if ( $suffix == 'BySpecial' ) {
+ // add{SettingName}BySpecial(string $special, string $value, string $name = null)
+ $this->_verifyArguments(Array ('special', 'value'));
+
+ if ( isset($arguments[2]) ) {
+ // add a single value
+ $this->_addToSetting($this->_getSingular($setting_name), $arguments[1], $arguments[2], $arguments[0]);
+ }
+ else {
+ // add multiple values
+ $this->_addToSetting($setting_name, $arguments[1], null, $arguments[0]);
+ }
+ }
+ else {
+ // add{SettingName}(string $value, string $name = null)
+ $this->_verifyArguments(Array ('value'));
+
+ if ( isset($arguments[1]) ) {
+ // add a single value
+ $this->_addToSetting($this->_getSingular($setting_name), $arguments[0], $arguments[1]);
+ }
+ else {
+ // add multiple value
+ $this->_addToSetting($setting_name, $arguments[0], null);
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Adds a value to a setting
+ *
+ * @param string $name
+ * @param mixed $value
+ * @param string $array_key
+ * @param string $special
+ * @return kUnitConfig
+ * @throws InvalidArgumentException
+ */
+ protected function _addToSetting($name, $value, $array_key, $special = null)
+ {
+ if ( $this->_isPluralSetting($name) ) {
+ // multiple values given - merge with current values
+ if ( !is_array($value) ) {
+ throw new InvalidArgumentException('Argument $value must be an array');
+ }
+
+ $result = $this->getSetting($name, Array (), $special);
+ $this->setSetting($name, array_merge($result, $value), $special);
+ }
+ else {
+ // single value given
+ $result = $this->getSetting($this->_getPlural($name), Array (), $special);
+
+ if ( $this->_isWithoutKeySetting($name) ) {
+ $result[] = $value;
+ }
+ else {
+ $result[$array_key] = $value;
+ }
+
+ $this->setSetting($this->_getPlural($name), $result, $special);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Processes calls to "remove*" method
+ *
+ * @param string $setting_name
+ * @param string $suffix
+ * @return kUnitConfig
+ * @access protected
+ * @throws InvalidArgumentException
+ */
+ protected function _processRemove($setting_name, $suffix = '')
+ {
+ $arguments = $this->_currentArguments;
+
+ if ( !$this->_isPluralSetting($setting_name) ) {
+ throw new InvalidArgumentException('Setting "' . $setting_name . '" isn\'t plural');
+ }
+
+ if ( $suffix == 'BySpecial' ) {
+ // remove{SettingName}BySpecial(string $special, string $name = null)
+ $this->_verifyArguments(Array ('special'));
+
+ if ( isset($arguments[1]) ) {
+ // remove single value
+ $this->_removeFromSetting($this->_getSingular($setting_name), $arguments[1], $arguments[0]);
+ }
+ else {
+ // remove multiple value
+ $this->_removeFromSetting($setting_name, null, $arguments[0]);
+ }
+ }
+ else {
+ // remove{SettingName}(string $name = null)
+ if ( isset($arguments[0]) ) {
+ // remove single value
+ $this->_removeFromSetting($this->_getSingular($setting_name), $arguments[0]);
+ }
+ else {
+ // remove multiple values
+ $this->_removeFromSetting($setting_name, null);
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Removes a value from a setting
+ *
+ * @param string $name
+ * @param string $array_key
+ * @param string $special
+ * @return kUnitConfig
+ * @access protected
+ * @throws RuntimeException
+ */
+ protected function _removeFromSetting($name, $array_key = null, $special = null)
+ {
+ if ( $this->_isPluralSetting($name) ) {
+ // remove multiple values
+ if ( $this->getSetting($name, false, $special) !== false ) {
+ $this->setSetting($name, null, $special);
+ }
+ }
+ else {
+ // remove single value
+ if ( $this->_isWithoutKeySetting($name) ) {
+ throw new RuntimeException('Unable to change setting without key');
+ }
+
+ $result = $this->getSetting($this->_getPlural($name), false, $special);
+
+ if ( $result !== false ) {
+ unset($result[$array_key]);
+ $this->setSetting($this->_getPlural($name), $result, $special);
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Verifies argument count given
+ *
+ * @param Array $argument_names
+ * @return void
+ * @access protected
+ * @throws InvalidArgumentException
+ */
+ protected function _verifyArguments($argument_names)
+ {
+ if ( count($this->_currentArguments) < count($argument_names) ) {
+ throw new InvalidArgumentException('Method ' . __CLASS__ . '::' . $this->_currentMethodName . ' expects following arguments: $' . implode(', $', $argument_names) . '');
+ }
+ }
+
+ /**
+ * Returns setting value by name and filter by special (if passed)
+ *
+ * @param string $name
+ * @param mixed $default
+ * @param string|kBase $special
+ * @return mixed
+ * @access public
+ */
+ public function getSetting($name, $default = false, $special = null)
+ {
+ if ( in_array($name, $this->_specialBased) && isset($special) ) {
+ $use_special = $this->_guessSpecial($name, $special);
+
+ return isset($this->_data[$name][$use_special]) ? $this->_data[$name][$use_special] : $default;
+ }
+
+ return isset($this->_data[$name]) ? $this->_data[$name] : $default;
+ }
+
+ /**
+ * Changes value of a setting
+ *
+ * @param string $name
+ * @param mixed $value
+ * @param string|kBase $special
+ * @return kUnitConfig
+ * @access public
+ */
+ public function setSetting($name, $value, $special = null)
+ {
+ if ( in_array($name, $this->_specialBased) && isset($special) ) {
+ if ( !isset($this->_data[$name]) ) {
+ $this->_data[$name] = Array ();
+ }
+
+ $use_special = $this->_guessSpecial($name, $special);
+
+ if ( !isset($value) ) {
+ unset($this->_data[$name][$use_special]);
+ }
+ else {
+ $this->_data[$name][$use_special] = $value;
+ }
+ }
+ else {
+ if ( !isset($value) ) {
+ unset($this->_data[$name]);
+ }
+ else {
+ $this->_data[$name] = $value;
+ }
+ }
+
+ return $this;
+ }
+
+ /**
+ * Detects settings, that accept arrays
+ *
+ * @param string $name
+ * @return bool
+ * @access protected
+ */
+ protected function _isPluralSetting($name)
+ {
+ if ( preg_match(self::$_alwaysSingularRegExp, $name) ) {
+ // simplified exceptions
+ return false;
+ }
+
+ return preg_match('/(es|s)$/', $name);
+ }
+
+ /**
+ * Detects anonymous settings
+ *
+ * @param string $name
+ * @return bool
+ * @access protected
+ */
+ protected function _isWithoutKeySetting($name)
+ {
+ return in_array($this->_getPlural($name), $this->_withoutKeys);
+ }
+
+ /**
+ * Returns plural form given word
+ *
+ * @param string $name
+ * @return string
+ * @access protected
+ */
+ protected function _getPlural($name)
+ {
+ return preg_match(self::$_singularEndingsRegExp, $name) ? $name . 'es' : $name . 's';
+ }
+
+ /**
+ * Returns singular form of given word
+ *
+ * @param $name
+ * @return mixed
+ * @throws InvalidArgumentException
+ */
+ protected function _getSingular($name)
+ {
+ if ( !$this->_isPluralSetting($name) ) {
+ throw new InvalidArgumentException('Setting "' . $name . '" isn\'t plural');
+ }
+
+ return preg_replace('/(es|s)$/', '', $name);
+ }
+
+ /**
+ * Guesses special to be used by event
+ *
+ * @param string $setting_name
+ * @param string|kBase $special
+ * @return string
+ * @access protected
+ */
+ protected function _guessSpecial($setting_name, $special)
+ {
+ $use_special = $special instanceof kBase ? $special->Special : $special;
+ $value = $this->getSetting($setting_name, Array ());
+
+ return isset($value[$use_special]) ? $use_special : '';
+ }
+
+ /**
+ * Adds new tab to existing edit tab preset
+ *
+ * @param string $preset_name
+ * @param Array $value
+ * @param string $name
+ * @return kUnitConfig
+ * @throws InvalidArgumentException
+ * @access public
+ */
+ public function addEditTabPresetTabs($preset_name, $value, $name = null)
+ {
+ $preset = $this->getEditTabPresetByName($preset_name, false);
+
+ if ( $preset === false ) {
+ throw new InvalidArgumentException('Edit tab preset "' . $preset_name . '" not defined in "' . $this->_prefix . '" unit config');
+ }
+
+ if ( isset($name) ) {
+ $preset[$name] = $value;
+ }
+ else {
+ $preset = array_merge($preset, $value);
+ }
+
+ $this->addEditTabPresets($preset, $preset_name);
+
+ return $this;
+ }
+
+ public function addGridFields($grid_name, $value, $name = null)
+ {
+ $grid = $this->getGridByName($grid_name, false);
+
+ if ( $grid === false ) {
+ throw new InvalidArgumentException('Grid "' . $grid_name . '" not defined in "' . $this->_prefix . '" unit config');
+ }
+
+ if ( isset($name) ) {
+ $grid['Fields'][$name] = $value;
+ }
+ else {
+ $grid['Fields'] = array_merge($grid['Fields'], $value);
+ }
+
+ $this->addGrids($grid, $grid_name);
+
+ return $this;
+ }
+
+ /**
+ * Returns individual permission section
+ *
+ * @param string $name
+ * @param Array $default
+ * @return Array
+ * @access public
+ * @todo Rename setting to plural form and them remove this method
+ */
+ public function getPermSectionByName($name, $default = Array ())
+ {
+ $perm_sections = $this->getPermSection(Array ());
+
+ return isset($perm_sections[$name]) ? $perm_sections[$name] : $default;
+ }
+
+ /**
+ * Returns foreign key by given prefix
+ *
+ * @param string $parent_prefix
+ * @param mixed $default
+ * @return string|bool
+ * @access public
+ */
+ public function getForeignKey($parent_prefix = null, $default = false)
+ {
+ return $this->_getSettingByPrefix('ForeignKey', $parent_prefix, $default);
+ }
+
+ /**
+ * Returns parent table key by given prefix
+ *
+ * @param string $parent_prefix
+ * @param mixed $default
+ * @return string|bool
+ * @access public
+ */
+ public function getParentTableKey($parent_prefix = null, $default = false)
+ {
+ return $this->_getSettingByPrefix('ParentTableKey', $parent_prefix, $default);
+ }
+
+ /**
+ * Returns value of a setting by prefix (special workaround for non-special settings)
+ *
+ * @param string $name
+ * @param string $prefix
+ * @param mixed $default
+ * @return mixed
+ * @access protected
+ */
+ protected function _getSettingByPrefix($name, $prefix = null, $default = false)
+ {
+ $value = $this->getSetting($name, $default);
+
+ if ( !is_array($value) || !isset($prefix) ) {
+ return $value;
+ }
+
+ return isset($value[$prefix]) ? $value[$prefix] : $default;
+ }
+
+ /**
+ * Returns status field with option to get first field only
+ *
+ * @param bool $first_only
+ * @param mixed $default
+ * @return mixed
+ * @access public
+ */
+ public function getStatusField($first_only = false, $default = false)
+ {
+ $value = $this->getSetting('StatusField', $default);
+
+ return $first_only ? $value[0] : $value;
+ }
+}
Index: core/units/mailing_lists/mailing_list_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/mailing_lists/mailing_list_eh.php (revision 15682)
+++ core/units/mailing_lists/mailing_list_eh.php (revision )
@@ -94,11 +94,11 @@
$ids = $event->getEventParam('ids');
if ( $ids ) {
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $config = $event->getUnitConfig();
+ $id_field = $config->getIDField();
$sql = 'SELECT ' . $id_field . '
- FROM ' . $table_name . '
+ FROM ' . $config->getTableName() . '
WHERE ' . $id_field . ' IN (' . implode(',', $ids) . ') AND Status <> ' . MailingList::PARTIALLY_PROCESSED;
$allowed_ids = $this->Conn->GetCol($sql);
@@ -249,7 +249,7 @@
$object = $event->getObject();
/* @var $object kDBItem */
- $sql = 'DELETE FROM ' . $this->Application->getUnitOption('email-queue', 'TableName') . '
+ $sql = 'DELETE FROM ' . $this->Application->getUnitConfig('email-queue')->getTableName() . '
WHERE MailingId = ' . $object->GetID();
$this->Conn->Query($sql);
}
@@ -283,8 +283,9 @@
*/
function OnGenerateEmailQueue($event)
{
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $config = $event->getUnitConfig();
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
$where_clause = Array (
'Status NOT IN (' . MailingList::CANCELLED . ',' . MailingList::PROCESSED . ')',
@@ -367,7 +368,7 @@
return ;
}
- $queue_table = $this->Application->getUnitOption('email-queue', 'TableName');
+ $queue_table = $this->Application->getUnitConfig('email-queue')->getTableName();
// get queue part to send
$sql = 'SELECT *
\ No newline at end of file
Index: core/units/helpers/multilanguage_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/multilanguage_helper.php (revision 15682)
+++ core/units/helpers/multilanguage_helper.php (revision )
@@ -99,8 +99,10 @@
if ( $ret === false ) {
$this->Conn->nextQueryCachable = true;
- $sql = 'SELECT ' . $this->Application->getUnitOption('lang', 'IDField') . '
- FROM ' . $this->Application->getUnitOption('lang', 'TableName');
+ $config = $this->Application->getUnitConfig('lang');
+
+ $sql = 'SELECT ' . $config->getIDField() . '
+ FROM ' . $config->getTableName();
$ret = $this->Conn->GetCol($sql);
$this->Application->setCache($cache_key, $ret);
@@ -181,7 +183,7 @@
$this->Application->UnitConfigReader->ReReadConfigs();
}
- foreach ($this->Application->UnitConfigReader->configData as $prefix => $config_data) {
+ foreach ($this->Application->UnitConfigReader->getPrefixes() as $prefix) {
$this->createFields($prefix);
}
}
@@ -201,8 +203,9 @@
$this->Application->UnitConfigReader->runAfterConfigRead($prefix);
}
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
- $this->curFields = $this->Application->getUnitOption($prefix, 'Fields');
+ $config = $this->Application->getUnitConfig($prefix);
+ $table_name = $config->getTableName();
+ $this->curFields = $config->getFields();
if ( !($table_name && $this->curFields) || ($table_name && !$this->Conn->TableFound($table_name, kUtil::constOn('IS_INSTALL'))) ) {
// invalid config found or prefix not found
@@ -274,8 +277,9 @@
*/
public function copyMissingData($prefix, $src_language, $dst_language)
{
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
- $this->curFields = $this->Application->getUnitOption($prefix, 'Fields');
+ $config = $this->Application->getUnitConfig($prefix);
+ $table_name = $config->getTableName();
+ $this->curFields = $config->getFields();
if ( !($table_name && $this->curFields) || ($table_name && !$this->Conn->TableFound($table_name, kUtil::constOn('IS_INSTALL'))) ) {
// invalid config found or prefix not found
@@ -296,7 +300,7 @@
function deleteField($prefix, $custom_id)
{
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
+ $table_name = $this->Application->getUnitConfig($prefix)->getTableName();
$sql = 'DESCRIBE '.$table_name.' "l%_cust_'.$custom_id.'"';
$fields = $this->Conn->GetCol($sql);
@@ -352,7 +356,7 @@
static $single_lang = null;
if (!isset($single_lang)) {
// if single language mode, then create indexes only on primary columns
- $table_name = $this->Application->getUnitOption('lang', 'TableName');
+ $table_name = $this->Application->getUnitConfig('lang')->getTableName();
$sql = 'SELECT COUNT(*)
FROM '.$table_name.'
WHERE Enabled = 1';
@@ -468,9 +472,10 @@
*/
public function replaceMLCalculatedFields(kEvent $event)
{
+ $config = $event->getUnitConfig();
$editing_language = $this->getEditingLanguage();
- $calculated_fields = $this->Application->getUnitOption($event->Prefix, 'CalculatedFields', Array ());
+ $calculated_fields = $config->getSetting('CalculatedFields', Array ());
/* @var $calculated_fields Array */
foreach ($calculated_fields as $special => $fields) {
@@ -479,7 +484,7 @@
}
}
- $this->Application->setUnitOption($event->Prefix, 'CalculatedFields', $calculated_fields);
+ $config->setSetting('CalculatedFields', $calculated_fields);
}
/**
Index: core/units/scheduled_tasks/scheduled_task_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/scheduled_tasks/scheduled_task_eh.php (revision 15682)
+++ core/units/scheduled_tasks/scheduled_task_eh.php (revision )
@@ -138,11 +138,11 @@
$ids = $event->getEventParam('ids');
if ( $ids ) {
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $config = $event->getUnitConfig();
+ $id_field = $config->getIDField();
$sql = 'SELECT ' . $id_field . '
- FROM ' . $table_name . '
+ FROM ' . $config->getTableName() . '
WHERE ' . $id_field . ' IN (' . implode(',', $ids) . ') AND Type <> ' . ScheduledTask::TYPE_SYSTEM;
$event->setEventParam('ids', $this->Conn->GetCol($sql));
}
\ No newline at end of file
Index: core/kernel/processors/tag_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/processors/tag_processor.php (revision 15682)
+++ core/kernel/processors/tag_processor.php (revision )
@@ -297,8 +297,9 @@
}
}
else {
- $module_folder = $this->Application->getUnitOption($this->Prefix, 'ModuleFolder');
+ $module_folder = $this->getUnitConfig()->getModuleFolder();
}
+
return '../../'.$module_folder.'/admin_templates/';
}
}
\ No newline at end of file
Index: core/units/helpers/mailing_list_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/mailing_list_helper.php (revision 15682)
+++ core/units/helpers/mailing_list_helper.php (revision )
@@ -225,8 +225,9 @@
return $recipient_ids;
}
- $id_field = $this->Application->getUnitOption($recipient_type, 'IDField');
- $table_name = $this->Application->getUnitOption($recipient_type, 'TableName');
+ $config = $this->Application->getUnitConfig($recipient_type);
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
$sql = 'SELECT ' . $title_field . '
FROM ' . $table_name . '
@@ -246,14 +247,14 @@
unset($mailing_totals[0]);
}
- $id_field = $this->Application->getUnitOption('mailing-list', 'IDField');
- $table_name = $this->Application->getUnitOption('mailing-list', 'TableName');
+ $config = $this->Application->getUnitConfig('mailing-list');
+ $table_name = $config->getTableName();
// update sent email count for each processed mailing
foreach ($mailing_totals as $mailing_id => $mailing_total) {
$sql = 'UPDATE ' . $table_name . '
SET EmailsSent = EmailsSent + ' . $mailing_total . '
- WHERE ' . $id_field . ' = ' . $mailing_id;
+ WHERE ' . $config->getIDField() . ' = ' . $mailing_id;
$this->Conn->Query($sql);
}
@@ -274,7 +275,7 @@
$esender = $this->Application->recallObject('EmailSender');
/* @var $esender kEmailSendingHelper */
- $queue_table = $this->Application->getUnitOption('email-queue', 'TableName');
+ $queue_table = $this->Application->getUnitConfig('email-queue')->getTableName();
$i = 0;
$message = Array ();
\ No newline at end of file
Index: core/kernel/db/db_tag_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/db/db_tag_processor.php (revision 15682)
+++ core/kernel/db/db_tag_processor.php (revision )
@@ -36,7 +36,8 @@
*/
function GetItemName($params)
{
- $item_name = $this->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');
+ $filter_menu = $this->getUnitConfig()->getFilterMenu();
+
- if (!$filter_menu) {
+ if ( !$filter_menu ) {
- trigger_error('no filters defined for prefix '.$this->Prefix.', but DrawFilterMenu tag used', E_USER_NOTICE);
+ 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');
+ $view_filter = $this->Application->RecallVar($this->getPrefixSpecial() . '_view_filter');
- if ($view_filter === false) {
+ if ( $view_filter === false ) {
$event_params = Array ('prefix' => $this->Prefix, 'special' => $this->Special, 'name' => 'OnRemoveFilters');
- $this->Application->HandleEvent( new kEvent($event_params) );
+ $this->Application->HandleEvent(new kEvent($event_params));
- $view_filter = $this->Application->RecallVar($this->getPrefixSpecial().'_view_filter');
+ $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();
+ $group_params = isset($filter_params['group_id']) ? $filter_menu['Groups'][$filter_params['group_id']] : Array ();
- if (!isset($group_params['element_type'])) {
+ 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']) );
+ $block_params['label'] = addslashes($this->Application->Phrase($filter_params['label']));
+
- if (getArrayValue($view_filter,$filter_key)) {
+ 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') {
+ if ( $mode == 'fields' ) {
- return "'".join("','", array_keys($grid_config))."'";
+ 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']) {
+ if ( $this->Application->ConfigValue('UseSmallHeader') && isset($params['group_title']) && $params['group_title'] ) {
- $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();
+ $objects = Array ();
- $object_status = Array();
+ $object_status = Array ();
- $status_labels = 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)) {
+ if ( preg_match('/(.*)\[(.*)\]/', $tp_name, $regs) ) {
- $all_tag_params[ $regs[1] ][ $regs[2] ] = $tp_value;
+ $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) {
+ if ( !$tag_params ) {
- $tag_params = Array();
+ $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);
+ $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';
+ $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'])) {
+ 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'] ];
+ $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);
+ $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') {
+ if ( $object_status[$prefix_data['prefix_special']] == 'new' ) {
- $new_value = $this->getInfo( $objects[ $prefix_data['prefix_special'] ], 'titlefield' );
+ $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'] ]);
+
+ 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);
+ $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);
+ preg_match_all('/#(.*_.*)#/Uis', $title, $rets);
- if ($rets[1]) {
+ if ( $rets[1] ) {
- $replacement_vars = array_keys( array_flip($rets[1]) );
+ $replacement_vars = array_keys(array_flip($rets[1]));
+
foreach ($replacement_vars as $replacement_var) {
- $var_info = explode('_',$replacement_var,2);
+ $var_info = explode('_', $replacement_var, 2);
- $object =& $objects[ $var_info[0] ];
+ $object =& $objects[$var_info[0]];
- $new_value = $this->getInfo($object,$var_info[1]);
+ $new_value = $this->getInfo($object, $var_info[1]);
- $title = str_replace('#'.$replacement_var.'#', $new_value, $title);
+ $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']) {
+ if ( $this->Application->ConfigValue('UseSmallHeader') && isset($params['group_title']) && $params['group_title'] ) {
- $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').'
+ FROM ' . $this->Application->getUnitConfig('cf')->getTableName() . '
- WHERE FieldName = '.$this->Conn->qstr($field);
+ WHERE FieldName = ' . $this->Conn->qstr($field);
+
return $this->Application->Phrase($this->Conn->GetOne($sql));
}
@@ -2486,10 +2503,10 @@
{
static $language_code = null;
- if (!isset($language_code)) {
+ if ( !isset($language_code) ) {
- $language_code = 'en'; // defaut value
+ $language_code = 'en'; // default value
- if ($this->Application->isAdmin) {
+ if ( $this->Application->isAdmin ) {
$language_id = $this->Application->Phrases->LanguageId;
}
else {
@@ -2497,17 +2514,18 @@
}
$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,31 +3030,49 @@
*/
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;
}
}
return false;
+ }
+
+ /**
+ * 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;
}
/**
\ No newline at end of file
Index: core/kernel/managers/rewrite_url_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/managers/rewrite_url_processor.php (revision 15682)
+++ core/kernel/managers/rewrite_url_processor.php (revision )
@@ -725,8 +725,7 @@
{
list ($prefix) = explode('.', $prefix_special);
- $query_vars = $this->Application->getUnitOption($prefix, 'QueryString', Array ());
- /* @var $query_vars Array */
+ $query_vars = $this->Application->getUnitConfig($prefix)->getQueryString(Array ());
if ( !$query_vars ) {
// given prefix doesn't use "env" variable to pass it's data
@@ -962,7 +961,7 @@
foreach ($pass_info as $pass_index => $pass_element) {
list ($prefix) = explode('.', $pass_element);
- $catalog_item = $this->Application->findModule('Var', $prefix) && $this->Application->getUnitOption($prefix, 'CatalogItem');
+ $catalog_item = $this->Application->findModule('Var', $prefix) && $this->Application->getUnitConfig($prefix)->getCatalogItem();
if ( array_key_exists($prefix, $this->rewriteListeners) ) {
// if next prefix is same as current, but with special => exclude current prefix from url
\ No newline at end of file
Index: core/kernel/utility/formatters/multilang_formatter.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/utility/formatters/multilang_formatter.php (revision 15682)
+++ core/kernel/utility/formatters/multilang_formatter.php (revision )
@@ -74,18 +74,19 @@
return ;
}
+ $config = $object->getUnitConfig();
$lang_field_name = $this->LangFieldName($field_name);
//substitute title field
- $title_field = $this->Application->getUnitOption($object->Prefix, 'TitleField');
+ $title_field = $config->getTitleField();
if ($title_field == $field_name) {
- $this->Application->setUnitOption($object->Prefix, 'TitleField', $lang_field_name);
+ $object->getUnitConfig()->setTitleField($lang_field_name);
}
$languages = $this->helper->getLanguages();
$primary_language_id = $this->Application->GetDefaultLanguageId();
- $fields = $this->Application->getUnitOption($object->Prefix, 'Fields', Array ());
- $virtual_fields = $this->Application->getUnitOption($object->Prefix, 'VirtualFields', Array ());
+ $fields = $config->getFields(Array ());
+ $virtual_fields = $config->getVirtualFields(Array ());
// substitute real field
if (array_key_exists($field_name, $fields)) {
@@ -119,7 +120,7 @@
}
elseif (array_key_exists($field_name, $virtual_fields)) {
// substitute virtual field
- $calculated_fields = $this->Application->getUnitOption($object->Prefix, 'CalculatedFields', Array ());
+ $calculated_fields = $config->getSetting('CalculatedFields', Array ());
$calculated_field_special = array_key_exists($object->Special, $calculated_fields) ? $object->Special : (array_key_exists('', $calculated_fields) ? '' : false);
/* @var $calculated_fields Array */
@@ -169,7 +170,7 @@
$object->setCalculatedFields($object_calculated_fields);
// save back calculated fields
- $this->Application->setUnitOption($object->Prefix, 'CalculatedFields', $calculated_fields);
+ $config->setSetting('CalculatedFields', $calculated_fields);
// makes original field non-required
$object_fields = $object->getFields(); // use kDBBase::getFields, since there are no kDBList::setRequired
@@ -182,7 +183,7 @@
}
// substitute grid fields
- $grids = $this->Application->getUnitOption($object->Prefix, 'Grids', Array ());
+ $grids = $config->getGrids(Array ());
/* @var $grids Array */
foreach ($grids as $name => $grid) {
@@ -210,7 +211,7 @@
}
}
}
- $this->Application->setUnitOption($object->Prefix, 'Grids', $grids);
+ $config->setGrids($grids);
//TODO: substitute possible language-fields sortings after changing language
if ( $object->isVirtualField($field_name) ) {
@@ -221,8 +222,8 @@
}
$field_options['options_processed'] = true;
- $this->Application->setUnitOption($object->Prefix, 'Fields', $fields);
- $this->Application->setUnitOption($object->Prefix, 'VirtualFields', $virtual_fields);
+ $config->setFields($fields);
+ $config->setVirtualFields($virtual_fields);
}
/*function UpdateSubFields($field, $value, &$options, &$object)
\ No newline at end of file
Index: core/install.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/install.php (revision 15682)
+++ core/install.php (revision )
@@ -922,12 +922,13 @@
case 'select_theme':
// 1. mark theme, that user is selected
$theme_id = $this->GetVar('theme');
- $theme_table = $this->Application->getUnitOption('theme', 'TableName');
- $theme_idfield = $this->Application->getUnitOption('theme', 'IDField');
+ $theme_config = $this->Application->getUnitConfig('theme');
+ $theme_table = $theme_config->getTableName();
+ $theme_id_field = $theme_config->getIDField();
$sql = 'UPDATE ' . $theme_table . '
SET Enabled = 1, PrimaryTheme = 1
- WHERE ' . $theme_idfield . ' = ' . $theme_id;
+ WHERE ' . $theme_id_field . ' = ' . $theme_id;
$this->Conn->Query($sql);
$this->toolkit->rebuildThemes(); // rescan theme to create structure after theme is enabled !!!
@@ -936,7 +937,7 @@
if ($this->Application->GetVar('install_demo_data')) {
$sql = 'SELECT Name
FROM ' . $theme_table . '
- WHERE ' . $theme_idfield . ' = ' . $theme_id;
+ WHERE ' . $theme_id_field . ' = ' . $theme_id;
$theme_name = $this->Conn->GetOne($sql);
$site_path = $this->toolkit->getSystemConfig('Misc', 'WebsitePath') . '/';
Index: core/units/general/general_config.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/general/general_config.php (revision 15682)
+++ core/units/general/general_config.php (revision )
@@ -1,6 +1,6 @@
'm',
- 'EventHandlerClass' => Array ('class' => 'kEventHandler', 'file' => '', 'build_event' => 'OnBuild'),
-// 'TagProcessorClass' => Array ('class' => 'kMainTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
+$config = new kUnitConfig('m', null, false);
- 'QueryString' => Array (
+$config->setEventHandlerClass(Array ('class' => 'kEventHandler', 'file' => '', 'build_event' => 'OnBuild'));
+//$config->setTagProcessorClass(Array ('class' => 'kMainTagProcessor', 'file' => '', 'build_event' => 'OnBuild'));
+
+$config->setQueryString(Array (
- 1 => 'cat_id',
- 2 => 'cat_page',
- 3 => 'lang',
- 4 => 'theme',
- 5 => 'opener',
- 6 => 'wid',
+ 1 => 'cat_id',
+ 2 => 'cat_page',
+ 3 => 'lang',
+ 4 => 'theme',
+ 5 => 'opener',
+ 6 => 'wid',
- ),
+));
- 'TitleField' => 'CachedNavbar',
- 'TitlePhrase' => 'la_Text_Category',
- 'CatalogTabIcon' => 'icon16_section.png',
- 'ItemType' => 1,
- 'TableName' => TABLE_PREFIX . 'Categories',
+$config->setTitleField('CachedNavbar');
+$config->setTitlePhrase('la_Text_Category');
+$config->setCatalogTabIcon('icon16_section.png');
+$config->setItemType(1);
+$config->setTableName(TABLE_PREFIX . 'Categories');
+$config->setCatalogItem(true);
+$config->setPortalStyleEnv(true);
- 'CatalogItem' => true,
+$config->setRewritePriority(100);
+$config->setRewriteListener('c_EventHandler:CategoryRewriteListener');
- 'PortalStyleEnv' => true,
-
- 'RewritePriority' => 100,
- 'RewriteListener' => 'c_EventHandler:CategoryRewriteListener',
-
- 'PermTabText' => 'In-Portal',
- 'PermSection' => Array ('search' => 'in-portal:configuration_search', 'custom' => 'in-portal:configuration_custom'),
-);
\ No newline at end of file
+$config->setPermTabText('In-Portal');
+$config->setPermSection(Array ('search' => 'in-portal:configuration_search', 'custom' => 'in-portal:configuration_custom'));
Index: core/units/filters/item_filter_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/filters/item_filter_eh.php (revision 15682)
+++ core/units/filters/item_filter_eh.php (revision )
@@ -104,10 +104,9 @@
$field = $object->GetDBField('FilterField');
if ( $field ) {
- $fields = $this->Application->getUnitOption($prefix, 'Fields');
- $virtual_fields = $this->Application->getUnitOption($prefix, 'VirtualFields');
+ $config = $this->Application->getUnitConfig($prefix);
- if ( !isset($fields[$field]) && !isset($virtual_fields[$field]) ) {
+ if ( !$config->getFieldByName($field) && !$config->getVirtualFieldByName($field) ) {
$object->SetError('FilterField', 'non_existing', null, Array ($prefix));
}
}
Index: core/units/helpers/themes_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/themes_helper.php (revision 15682)
+++ core/units/helpers/themes_helper.php (revision )
@@ -58,8 +58,9 @@
return false;
}
- $id_field = $this->Application->getUnitOption('theme', 'IDField');
- $table_name = $this->Application->getUnitOption('theme', 'TableName');
+ $config = $this->Application->getUnitConfig('theme');
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
$sql = 'SELECT *
FROM ' . $table_name . '
@@ -149,8 +150,10 @@
*/
protected function _saveThemeSettings($theme_id, $theme_path)
{
- $id_field = $this->Application->getUnitOption('theme', 'IDField');
- $table_name = $this->Application->getUnitOption('theme', 'TableName');
+ $config = $this->Application->getUnitConfig('theme');
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
+
$this->Conn->doUpdate($this->_getThemeSettings($theme_id, $theme_path), $table_name, $id_field . ' = ' . $theme_id);
}
@@ -509,8 +512,9 @@
catch ( UnexpectedValueException $e ) {
}
- $id_field = $this->Application->getUnitOption('theme', 'IDField');
- $table_name = $this->Application->getUnitOption('theme', 'TableName');
+ $config = $this->Application->getUnitConfig('theme');
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
// 1. only one theme found -> enable it and make primary
/*if (count($themes_found) == 1) {
@@ -554,10 +558,10 @@
return ;
}
- $id_field = $this->Application->getUnitOption('theme', 'IDField');
- $table_name = $this->Application->getUnitOption('theme', 'TableName');
+ $config = $this->Application->getUnitConfig('theme');
+ $id_field = $config->getIDField();
- $sql = 'DELETE FROM '.$table_name.'
+ $sql = 'DELETE FROM '. $config->getTableName() .'
WHERE '.$id_field.' IN ('.implode(',', $theme_ids).')';
$this->Conn->Query($sql);
@@ -585,11 +589,10 @@
if ($theme_id === false) {
// query, because "m_theme" is always empty in admin
- $id_field = $this->Application->getUnitOption('theme', 'IDField');
- $table_name = $this->Application->getUnitOption('theme', 'TableName');
+ $config = $this->Application->getUnitConfig('theme');
- $sql = 'SELECT ' . $id_field . '
- FROM ' . $table_name . '
+ $sql = 'SELECT ' . $config->getIDField() . '
+ FROM ' . $config->getTableName() . '
WHERE (PrimaryTheme = 1) AND (Enabled = 1)';
$theme_id = $this->Conn->GetOne($sql);
}
@@ -623,9 +626,10 @@
}
$template_crc = kUtil::crc32(mb_strtolower($template));
+ $categories_config = $this->Application->getUnitConfig('c');
- $sql = 'SELECT ' . $this->Application->getUnitOption('c', 'IDField') . '
- FROM ' . $this->Application->getUnitOption('c', 'TableName') . '
+ $sql = 'SELECT ' . $categories_config->getIDField() . '
+ FROM ' . $categories_config->getTableName() . '
WHERE
(
(NamedParentPathHash = ' . $template_crc . ') OR
\ No newline at end of file
Index: core/units/captcha/captcha_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/captcha/captcha_eh.php (revision 15682)
+++ core/units/captcha/captcha_eh.php (revision )
@@ -40,8 +40,8 @@
/* @var $captcha_helper kCaptchaHelper */
// create field for captcha code storage
- $virtual_fields = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'VirtualFields');
- $virtual_fields['Captcha'] = Array ('type' => 'string', 'default' => '');
- $this->Application->setUnitOption($event->MasterEvent->Prefix, 'VirtualFields', $virtual_fields);
+ $event->MasterEvent->getUnitConfig()->addVirtualFields(Array (
+ 'Captcha' => Array ('type' => 'string', 'default' => ''),
+ ));
}
}
Index: core/units/helpers/template_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/template_helper.php (revision 15682)
+++ core/units/helpers/template_helper.php (revision )
@@ -94,11 +94,13 @@
function _getThemeName()
{
+ $config = $this->Application->getUnitConfig('theme');
$theme_id = (int)$this->Application->GetVar('theme_id');
$sql = 'SELECT Name
- FROM ' . $this->Application->getUnitOption('theme', 'TableName') . '
- WHERE ' . $this->Application->getUnitOption('theme', 'IDField') . ' = ' . $theme_id;
+ FROM ' . $config->getTableName() . '
+ WHERE ' . $config->getIDField() . ' = ' . $theme_id;
+
return $this->Conn->GetOne($sql);
}
\ No newline at end of file
Index: core/units/helpers/language_import_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/language_import_helper.php (revision 15682)
+++ core/units/helpers/language_import_helper.php (revision )
@@ -268,7 +268,7 @@
// get languages
$sql = 'SELECT *
- FROM ' . $this->Application->getUnitOption('lang','TableName') . '
+ FROM ' . $this->Application->getUnitConfig('lang')->getTableName() . '
WHERE LanguageId IN (' . implode(',', $language_ids) . ')';
$languages = $this->Conn->Query($sql, 'LanguageId');
@@ -288,7 +288,7 @@
}
$sql = 'SELECT *
- FROM ' . $this->Application->getUnitOption('phrases','TableName') . '
+ FROM ' . $this->Application->getUnitConfig('phrases')->getTableName() . '
WHERE PhraseType IN (' . implode(',', $phrase_types) . ') AND Module IN (' . implode(',', $phrase_modules) . ') AND ' . $limit_where . '
ORDER BY Phrase';
$phrases = $this->Conn->Query($sql, 'PhraseId');
@@ -306,7 +306,7 @@
}
$sql = 'SELECT *
- FROM ' . $this->Application->getUnitOption('email-template', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('email-template')->getTableName() . '
WHERE `Type` IN (' . implode(',', $phrase_types) . ') AND (' . substr($module_sql, 0, -4) . ') AND ' . $limit_where . '
ORDER BY TemplateName, `Type`';
$email_templates = $this->Conn->Query($sql, 'TemplateId');
@@ -320,7 +320,7 @@
$limit_where = 'TRUE';
}
- $country_table = $this->Application->getUnitOption('country-state', 'TableName');
+ $country_table = $this->Application->getUnitConfig('country-state')->getTableName();
// countries
$sql = 'SELECT *
@@ -531,9 +531,11 @@
$key_field = $prefix == 'phrases' ? 'Phrase' : 'TemplateName';
$ids = $this->getExportIDs($prefix);
+ $config = $this->Application->getUnitConfig($prefix);
+
$sql = 'SELECT ' . $key_field . '
- FROM ' . $this->Application->getUnitOption($prefix, 'TableName') . '
- WHERE ' . $this->Application->getUnitOption($prefix, 'IDField') . ' IN (' . $ids . ')';
+ FROM ' . $config->getTableName() . '
+ WHERE ' . $config->getIDField() . ' IN (' . $ids . ')';
$rows = $this->Conn->GetIterator($sql);
if ( count($rows) ) {
@@ -575,12 +577,13 @@
}
// perform insert for records, that are missing in live table
+ $config = $this->Application->getUnitConfig($prefix);
$to_insert = array_diff($temp_records, $live_records);
if ( $to_insert ) {
$to_insert = $this->Conn->qstrArray($to_insert);
- $sql = 'INSERT INTO ' . $this->Application->getUnitOption($prefix, 'TableName') . '
+ $sql = 'INSERT INTO ' . $config->getTableName() . '
SELECT *
FROM ' . $this->_tables[$prefix] . '
WHERE ' . $unique_field . ' IN (' . implode(',', $to_insert) . ')';
@@ -596,7 +599,7 @@
if ( $to_update ) {
$to_update = $this->Conn->qstrArray($to_update);
- $sql = 'UPDATE ' . $this->Application->getUnitOption($prefix, 'TableName') . ' live
+ $sql = 'UPDATE ' . $config->getTableName() . ' live
SET ';
foreach ($data_fields as $index => $data_field) {
@@ -648,7 +651,7 @@
function _getTableData($language_id, $prefix, $unique_field, $data_field, $temp_mode = false)
{
$data_field = sprintf($data_field, $language_id);
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
+ $table_name = $this->Application->getUnitConfig($prefix)->getTableName();
if ($temp_mode) {
// for temp table get only records, that have contents on given language (not empty and isset)
@@ -714,8 +717,9 @@
*/
protected function _prepareTempTable($prefix, $drop_only = false)
{
- $id_field = $this->Application->getUnitOption($prefix, 'IDField');
- $table = $this->Application->getUnitOption($prefix,'TableName');
+ $config = $this->Application->getUnitConfig($prefix);
+ $id_field = $config->getIDField();
+ $table = $config->getTableName();
$temp_table = $this->Application->GetTempName($table);
$sql = 'DROP TABLE IF EXISTS %s';
@@ -760,7 +764,8 @@
function _updateEventsCache()
{
$sql = 'SELECT TemplateId, CONCAT(TemplateName,"_",Type) AS EventMix
- FROM ' . $this->Application->getUnitOption('email-template', 'TableName');
+ FROM ' . $this->Application->getUnitConfig('email-template')->getTableName();
+
$this->events_hash = $this->Conn->GetCol($sql, 'EventMix');
}
\ No newline at end of file
Index: core/units/languages/languages_item.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/languages/languages_item.php (revision 15682)
+++ core/units/languages/languages_item.php (revision )
@@ -18,7 +18,9 @@
{
function generateID()
{
- $sql = 'SELECT MAX('.$this->IDField.') FROM '.$this->Application->getUnitOption($this->Prefix, 'TableName');
+ $sql = 'SELECT MAX(' . $this->IDField . ')
+ FROM ' . $this->getUnitConfig()->getTableName();
+
return $this->Conn->GetOne($sql) + 1;
}
@@ -79,7 +81,7 @@
$to_language = $this->GetID();
$this->Application->UnitConfigReader->ReReadConfigs();
- foreach ($this->Application->UnitConfigReader->configData as $prefix => $config_data) {
+ foreach ($this->Application->UnitConfigReader->getPrefixes() as $prefix) {
$ml_helper->copyMissingData($prefix, $from_language, $to_language);
}
}
\ No newline at end of file
Index: core/units/permissions/permissions_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/permissions/permissions_event_handler.php (revision 15682)
+++ core/units/permissions/permissions_event_handler.php (revision )
@@ -144,7 +144,7 @@
if ( $section_data && isset($section_data['perm_prefix']) ) {
// using permission from other prefix
- $section_name = $this->Application->getUnitOption($section_data['perm_prefix'] . '.main', 'PermSection');
+ $section_name = $this->Application->getUnitConfig($section_data['perm_prefix'])->getPermSectionByName('main');
}
foreach ($section_permissions as $perm_name => $perm_value) {
\ No newline at end of file
Index: core/units/helpers/col_picker_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/col_picker_helper.php (revision 15682)
+++ core/units/helpers/col_picker_helper.php (revision )
@@ -175,12 +175,15 @@
function GetColumns($prefix)
{
$splited = $this->Application->processPrefix($prefix);
- $grids = $this->Application->getUnitOption($splited['prefix'], 'Grids');
- $conf_fields = $this->UseFreezer ? array_merge_recursive(
- array('__FREEZER__' => array('title' => '__FREEZER__')),
- $grids[$this->GridName]['Fields']
- ) : $grids[$this->GridName]['Fields'];
-// $conf_fields = $grids[$this->GridName]['Fields'];
+ $grid = $this->Application->getUnitConfig($splited['prefix'])->getGridByName($this->GridName);
+
+ if ( $this->UseFreezer ) {
+ $freezer_column = Array ('__FREEZER__' => Array ('title' => '__FREEZER__'));
+ $conf_fields = array_merge_recursive($freezer_column, $grid['Fields']);
+ }
+ else {
+ $conf_fields = $grid['Fields'];
+ }
// we NEED to recall dummy here to apply fields changes imposed by formatters,
// such as replacing multilingual field titles etc.
\ No newline at end of file
Index: core/units/phrases/phrases_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/phrases/phrases_event_handler.php (revision 15682)
+++ core/units/phrases/phrases_event_handler.php (revision )
@@ -132,8 +132,10 @@
function _getPhraseId($phrase)
{
- $sql = 'SELECT ' . $this->Application->getUnitOption($this->Prefix, 'IDField') . '
- FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . '
+ $config = $this->getUnitConfig();
+
+ $sql = 'SELECT ' . $config->getIDField() . '
+ FROM ' . $config->getTableName() . '
WHERE PhraseKey = ' . $this->Conn->qstr( mb_strtoupper($phrase) );
return $this->Conn->GetOne($sql);
@@ -203,7 +205,7 @@
protected function _getPrimaryTranslation($phrase)
{
$sql = 'SELECT l' . $this->Application->GetDefaultLanguageId() . '_Translation
- FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . '
+ FROM ' . $this->getUnitConfig()->getTableName() . '
WHERE PhraseKey = ' . $this->Conn->qstr( mb_strtoupper($phrase) );
return $this->Conn->GetOne($sql);
@@ -443,9 +445,11 @@
parent::OnAfterConfigRead($event);
if ( $this->Application->findModule('Name', 'Custom') ) {
- $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+ $config = $event->getUnitConfig();
+
+ $fields = $config->getFields();
$fields['Module']['default'] = 'Custom';
- $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+ $config->setFields($fields);
}
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper');
@@ -454,7 +458,7 @@
$ml_helper->replaceMLCalculatedFields($event);
if ( $this->Application->GetVar('regional') ) {
- $this->Application->setUnitOption($event->Prefix, 'PopulateMlFields', true);
+ $event->getUnitConfig()->setPopulateMlFields(true);
}
}
@@ -526,7 +530,7 @@
return;
}
- $this->Application->setUnitOption('phrases', 'AutoLoad', false);
+ $this->Application->getUnitConfig('phrases')->setAutoLoad(false);
$this->StoreSelectedIDs($event);
$this->Application->StoreVar('export_language_ids', $this->Application->GetVar('m_lang'));
\ No newline at end of file
Index: core/units/languages/languages_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/languages/languages_event_handler.php (revision 15682)
+++ core/units/languages/languages_event_handler.php (revision )
@@ -188,26 +188,28 @@
{
parent::OnAfterConfigRead($event);
- $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
-
- // set dynamic hints for options in date format fields
- $options = $fields['InputDateFormat']['options'];
- if ($options) {
- foreach ($options as $i => $v) {
- $options[$i] = $v . ' (' . adodb_date($i) . ')';
+ $this->_evaluateFieldFormats($event, 'InputDateFormat');
+ $this->_evaluateFieldFormats($event, 'InputTimeFormat');
- }
+ }
- $fields['InputDateFormat']['options'] = $options;
- }
- $options = $fields['InputTimeFormat']['options'];
- if ($options) {
- foreach ($options as $i => $v) {
- $options[$i] = $v . ' (' . adodb_date($i) . ')';
+ /**
+ * Set dynamic hints for options in date format fields
+ *
+ * @param kEvent $event
+ * @param string $field
+ * @return void
+ * @access protected
+ */
+ protected function _evaluateFieldFormats(kEvent $event, $field)
+ {
+ $config = $event->getUnitConfig();
+ $field_options = $config->getFieldByName($field);
+
+ foreach ($field_options['options'] as $option_key => $option_title) {
+ $field_options['options'][$option_key] .= ' (' . adodb_date($option_key) . ')';
- }
+ }
- $fields['InputTimeFormat']['options'] = $options;
- }
- $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+ $config->addFields($field_options, $field);
}
/**
@@ -238,8 +240,7 @@
$object = $event->getObject();
/* @var $object kDBItem */
- $status_fields = $this->Application->getUnitOption($event->Prefix, 'StatusField');
- $status_field = array_shift($status_fields);
+ $status_field = $event->getUnitConfig()->getStatusField(true);
if ( $object->GetDBField('PrimaryLang') == 1 && $object->GetDBField($status_field) == 0 ) {
$object->SetDBField($status_field, 1);
@@ -405,12 +406,12 @@
foreach ($pending_actions as $src_language => $dst_language) {
// phrases import
- $sql = 'UPDATE ' . $this->Application->getUnitOption('phrases', 'TableName') . '
+ $sql = 'UPDATE ' . $this->Application->getUnitConfig('phrases')->getTableName() . '
SET l' . $dst_language . '_Translation = l' . $src_language . '_Translation';
$this->Conn->Query($sql);
// events import
- $sql = 'UPDATE ' . $this->Application->getUnitOption('email-template', 'TableName') . '
+ $sql = 'UPDATE ' . $this->Application->getUnitConfig('email-template')->getTableName() . '
SET
l' . $dst_language . '_Subject = l' . $src_language . '_Subject,
l' . $dst_language . '_HtmlBody = l' . $src_language . '_HtmlBody,
@@ -443,7 +444,7 @@
$object->SetDBField('CopyLabels', 1);
$sql = 'SELECT ' . $object->IDField . '
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ FROM ' . $event->getUnitConfig()->getTableName() . '
WHERE PrimaryLang = 1';
$primary_lang_id = $this->Conn->GetOne($sql);
@@ -480,10 +481,11 @@
{
parent::OnBeforeDeleteFromLive($event);
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
+ $config = $event->getUnitConfig();
+ $id_field = $config->getIDField();
$sql = 'SELECT ' . $id_field . '
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ FROM ' . $config->getTableName() . '
WHERE ' . $id_field . ' = ' . $event->getEventParam('id');
$id = $this->Conn->GetOne($sql);
@@ -584,7 +586,7 @@
return;
}
- $this->Application->setUnitOption('phrases', 'AutoLoad', false);
+ $this->Application->getUnitConfig('phrases')->setAutoLoad(false);
$this->StoreSelectedIDs($event);
$this->Application->StoreVar('export_language_ids', implode(',', $this->getSelectedIDs($event)));
@@ -730,7 +732,7 @@
'l' . $object->GetID() . '_HtmlBody' => NULL,
'l' . $object->GetID() . '_PlainTextBody' => NULL,
);
- $this->Conn->doUpdate($fields_hash, $this->Application->getUnitOption('email-template', 'TableName'), 1);
+ $this->Conn->doUpdate($fields_hash, $this->Application->getUnitConfig('email-template')->getTableName(), 1);
// clean Phrases table
$fields_hash = Array (
@@ -738,7 +740,7 @@
'l' . $object->GetID() . '_HintTranslation' => NULL,
'l' . $object->GetID() . '_ColumnTranslation' => NULL,
);
- $this->Conn->doUpdate($fields_hash, $this->Application->getUnitOption('phrases', 'TableName'), 1);
+ $this->Conn->doUpdate($fields_hash, $this->Application->getUnitConfig('phrases')->getTableName(), 1);
}
/**
\ No newline at end of file
Index: core/units/admin/admin_events_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/admin/admin_events_handler.php (revision 15682)
+++ core/units/admin/admin_events_handler.php (revision )
@@ -324,7 +324,7 @@
$prefix = preg_replace('/^' . preg_quote(TABLE_PREFIX, '/') . '/', '', $table_name);
if ( $this->Application->prefixRegistred($prefix) ) {
// when prefix is found -> use it's table (don't affect K3 tables named in lowecase)
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
+ $table_name = $this->Application->getUnitConfig($prefix)->getTableName();
}
}
@@ -924,17 +924,15 @@
{
parent::OnAfterConfigRead($event);
- $section_adjustments = $this->Application->getUnitOption($event->Prefix, 'SectionAdjustments', Array());
+ $config = $event->getUnitConfig();
if ( !$this->Application->ConfigValue('AdvancedUserManagement') ) {
- $section_adjustments['in-portal:user_groups'] = 'remove';
+ $config->addSectionAdjustments('remove', 'in-portal:user_groups');
}
- $section_adjustments['in-portal:root'] = Array (
+ $config->addSectionAdjustments(Array (
'label' => $this->Application->ConfigValue('Site_Name')
- );
-
- $this->Application->setUnitOption($event->Prefix, 'SectionAdjustments', $section_adjustments);
+ ), 'in-portal:root');
}
/**
@@ -1149,13 +1147,13 @@
// rules from all enabled themes
$sql = 'SELECT ImageResizeRules
- FROM ' . $this->Application->getUnitOption('theme', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('theme')->getTableName() . '
WHERE Enabled = 1';
$mass_resizer->addRules($this->Conn->GetCol($sql));
$mass_resizer->run();
}
-
+
/**
* Returns popup size (by template), if not cached, then parse template to get value
*
@@ -1295,7 +1293,7 @@
foreach ($this->_unitFields as $prefix => $fields) {
$sql = 'SELECT ' . implode(',', array_unique($fields)) . '
- FROM ' . $this->Application->getUnitOption($prefix, 'TableName');
+ FROM ' . $this->Application->getUnitConfig($prefix)->getTableName();
$unit_data = $this->Conn->GetIterator($sql);
if ( !count($unit_data) ) {
\ No newline at end of file
Index: core/kernel/managers/scheduled_task_manager.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/managers/scheduled_task_manager.php (revision 15682)
+++ core/kernel/managers/scheduled_task_manager.php (revision )
@@ -67,7 +67,7 @@
$timeout_clause = 'LastRunStatus = ' . ScheduledTask::LAST_RUN_RUNNING . ' AND Timeout > 0 AND ' . adodb_mktime() . ' - LastRunOn > Timeout';
$sql = 'SELECT *
- FROM ' . $this->Application->getUnitOption('scheduled-task', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('scheduled-task')->getTableName() . '
WHERE (Status = ' . STATUS_ACTIVE . ') AND ((LastRunStatus != ' . ScheduledTask::LAST_RUN_RUNNING . ') OR (' . $timeout_clause . '))';
$scheduled_tasks = $this->Conn->Query($sql, 'Name');
}
@@ -221,7 +221,7 @@
{
$this->Conn->doUpdate(
$fields_hash,
- $this->Application->getUnitOption('scheduled-task', 'TableName'),
+ $this->Application->getUnitConfig('scheduled-task')->getTableName(),
'Name = ' . $this->Conn->qstr($scheduled_task_data['Name'])
);
\ No newline at end of file
Index: core/units/helpers/list_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/list_helper.php (revision 15682)
+++ core/units/helpers/list_helper.php (revision )
@@ -26,24 +26,24 @@
{
static $cache = Array ();
- if (array_key_exists($list->getPrefixSpecial(), $cache)) {
+ if ( array_key_exists($list->getPrefixSpecial(), $cache) ) {
- return $cache[ $list->getPrefixSpecial() ];
+ return $cache[$list->getPrefixSpecial()];
}
$user_sorting_start = $this->getUserSortIndex($list);
- $sorting_configs = $this->Application->getUnitOption($list->Prefix, 'ConfigMapping', Array ());
- $list_sortings = $this->Application->getUnitOption($list->Prefix, 'ListSortings', Array ());
- $sorting_prefix = getArrayValue($list_sortings, $list->Special) ? $list->Special : '';
+ $config = $list->getUnitConfig();
+ $sorting_configs = $config->getConfigMapping(Array ());
+ $list_sortings = $config->getListSortingsBySpecial($list, Array ());
- if (array_key_exists('DefaultSorting1Field', $sorting_configs)) {
+ if ( array_key_exists('DefaultSorting1Field', $sorting_configs) ) {
- $list_sortings[$sorting_prefix]['Sorting'] = Array (
+ $list_sortings['Sorting'] = Array (
$this->Application->ConfigValue($sorting_configs['DefaultSorting1Field']) => $this->Application->ConfigValue($sorting_configs['DefaultSorting1Dir']),
$this->Application->ConfigValue($sorting_configs['DefaultSorting2Field']) => $this->Application->ConfigValue($sorting_configs['DefaultSorting2Dir']),
);
}
- $sorting = getArrayValue($list_sortings, $sorting_prefix, 'Sorting');
+ $sorting = getArrayValue($list_sortings, 'Sorting');
$sort_fields = is_array($sorting) ? array_keys($sorting) : Array ();
for ($order_number = 0; $order_number < 2; $order_number++) {
@@ -52,39 +52,42 @@
$current_order_field = $list->GetOrderField($sorting_pos, true);
$current_order_direction = $list->GetOrderDirection($sorting_pos, true);
- if (!$current_order_field || !$current_order_direction) {
+ if ( !$current_order_field || !$current_order_direction ) {
// no sorting defined for this sorting position
continue;
}
// remove language prefix from field
$field_options = $list->GetFieldOptions($current_order_field);
- if (array_key_exists('formatter', $field_options) && $field_options['formatter'] == 'kMultiLanguage') {
+ if ( array_key_exists('formatter', $field_options) && $field_options['formatter'] == 'kMultiLanguage' ) {
// remove language prefix
$current_order_field = preg_replace('/^l[\d]+_(.*)/', '\\1', $current_order_field);
}
// user sorting found
- if (array_key_exists($order_number, $sort_fields)) {
+ if ( array_key_exists($order_number, $sort_fields) ) {
// default sorting found
$default_order_field = $sort_fields[$order_number];
$default_order_direction = $sorting[$default_order_field]; // because people can write
- if ($current_order_field != $default_order_field || strcasecmp($current_order_direction, $default_order_direction) != 0) {
+ if ( $current_order_field != $default_order_field || strcasecmp($current_order_direction, $default_order_direction) != 0 ) {
// #1. user sorting differs from default sorting -> changed
- $cache[ $list->getPrefixSpecial() ] = true;
+ $cache[$list->getPrefixSpecial()] = true;
+
return true;
}
}
else {
// #2. user sorting + no default sorting -> changed
- $cache[ $list->getPrefixSpecial() ] = true;
+ $cache[$list->getPrefixSpecial()] = true;
+
return true;
}
}
// #3. user sorting match default or not defined -> not changed
- $cache[ $list->getPrefixSpecial() ] = false;
+ $cache[$list->getPrefixSpecial()] = false;
+
return false;
}
@@ -98,16 +101,16 @@
function getDefaultPerPage($prefix, $default = 10)
{
$ret = false;
- $config_mapping = $this->Application->getUnitOption($prefix, 'ConfigMapping');
+ $config_mapping = $this->Application->getUnitConfig($prefix)->getConfigMapping();
- if ($config_mapping) {
+ if ( $config_mapping ) {
- if (!array_key_exists('PerPage', $config_mapping)) {
+ if ( !array_key_exists('PerPage', $config_mapping) ) {
trigger_error('Incorrect mapping of PerPage key in config for prefix ' . $prefix . '', E_USER_WARNING);
}
$per_page = $this->Application->ConfigValue($config_mapping['PerPage']);
- if ($per_page) {
+ if ( $per_page ) {
return $per_page;
}
}
@@ -127,11 +130,10 @@
*/
function getUserSortIndex(&$list)
{
- $list_sortings = $this->Application->getUnitOption($list->Prefix, 'ListSortings', Array ());
- $sorting_prefix = getArrayValue($list_sortings, $list->Special) ? $list->Special : '';
+ $list_sortings = $list->getUnitConfig()->getListSortingsBySpecial($list, Array ());
$user_sorting_start = 0;
- $forced_sorting = getArrayValue($list_sortings, $sorting_prefix, 'ForcedSorting');
+ $forced_sorting = getArrayValue($list_sortings, 'ForcedSorting');
if ( $forced_sorting ) {
$user_sorting_start = count($forced_sorting);
\ No newline at end of file
Index: core/units/users/users_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/users/users_event_handler.php (revision 15682)
+++ core/units/users/users_event_handler.php (revision )
@@ -185,7 +185,7 @@
}
$user_dummy->Load($id);
- $status_field = $user_dummy->getStatusField();
+ $status_field = $event->getUnitConfig()->getStatusField(true);
if ( $user_dummy->GetDBField($status_field) != STATUS_ACTIVE ) {
// not active user is not allowed to update his record (he could not activate himself manually)
@@ -875,16 +875,16 @@
}
}
- if ( $found && $allow_reset ) {
+ if ($found && $allow_reset) {
$this->Application->emailUser('USER.PSWDC', $user->GetID());
$event->redirect = $this->Application->GetVar('template_success');
- return;
+ return ;
}
if ( strlen($email_or_username) ) {
$object->SetError('ForgotLogin', $found ? 'reset_denied' : ($is_email ? 'unknown_email' : 'unknown_username'));
- }
+ }
if ( !$object->ValidateField('ForgotLogin') ) {
$event->status = kEvent::erFAIL;
@@ -1174,7 +1174,7 @@
/* @var $user_dummy kDBItem */
$user_dummy->Load($id);
- $status_field = $user_dummy->getStatusField();
+ $status_field = $event->getUnitConfig()->getStatusField(true);
if ( $user_dummy->GetDBField($status_field) != STATUS_ACTIVE ) {
// not active user is not allowed to update his record (he could not activate himself manually)
@@ -1199,7 +1199,7 @@
if ( $object->Validate() ) {
// validation on, password match too
$fields_hash = Array ('VariableValue' => $object->GetDBField('RootPassword'));
- $conf_table = $this->Application->getUnitOption('conf', 'TableName');
+ $conf_table = $this->Application->getUnitConfig('conf')->getTableName();
$this->Conn->doUpdate($fields_hash, $conf_table, 'VariableName = "RootPass"');
$event->SetRedirectParam('opener', 'u');
}
@@ -1405,12 +1405,12 @@
*/
function getUserStatus($user_id)
{
- $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $config = $this->getUnitConfig();
$sql = 'SELECT Status
- FROM '.$table_name.'
- WHERE '.$id_field.' = '.$user_id;
+ FROM '. $config->getTableName() .'
+ WHERE '. $config->getIDField() .' = '.$user_id;
+
return $this->Conn->GetOne($sql);
}
@@ -1507,8 +1507,9 @@
{
parent::OnAfterConfigRead($event);
- $forms = $this->Application->getUnitOption($event->Prefix, 'Forms');
- $form_fields =& $forms['default']['Fields'];
+ $config = $event->getUnitConfig();
+ $default_form = $config->getFormByName('default');
+ $form_fields =& $default_form['Fields'];
// 1. arrange user registration countries
$site_helper = $this->Application->recallObject('SiteHelper');
@@ -1540,7 +1541,7 @@
// 5. remove groups tab on editing forms when AdvancedUserManagement config variable not set
if (!$this->Application->ConfigValue('AdvancedUserManagement')) {
- $edit_tab_presets = $this->Application->getUnitOption($event->Prefix, 'EditTabPresets');
+ $edit_tab_presets = $config->getEditTabPresets();
foreach ($edit_tab_presets as $preset_name => $preset_tabs) {
if (array_key_exists('groups', $preset_tabs)) {
@@ -1553,7 +1554,7 @@
}
}
- $this->Application->setUnitOption($event->Prefix, 'EditTabPresets', $edit_tab_presets);
+ $config->setEditTabPresets($edit_tab_presets);
}
}
@@ -1566,7 +1567,7 @@
$form_fields['Username']['max_len'] = $max_username ? $max_username : 255;
}
- $this->Application->setUnitOption($event->Prefix, 'Forms', $forms);
+ $config->addForms($default_form, 'default');
}
/**
@@ -1635,18 +1636,18 @@
$this->clearSelectedIDs($event);
$dst_field = $this->Application->RecallVar('dst_field');
- if ( $dst_field != 'PrimaryGroupId' ) {
+ if ($dst_field != 'PrimaryGroupId') {
- return;
+ return ;
}
$group_ids = array_keys($this->Application->GetVar('g'));
$primary_group_id = $group_ids ? array_shift($group_ids) : false;
- if ( !$user_ids || !$primary_group_id ) {
+ if (!$user_ids || !$primary_group_id) {
- return;
+ return ;
}
- $table_name = $this->Application->getUnitOption('ug', 'TableName');
+ $table_name = $this->Application->getUnitConfig('ug')->getTableName();
// 1. mark group as primary
$sql = 'UPDATE ' . TABLE_PREFIX . 'Users
Index: core/units/helpers/csv_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/csv_helper.php (revision 15682)
+++ core/units/helpers/csv_helper.php (revision )
@@ -60,12 +60,11 @@
$file = fopen($export_data['file_name'], $first_step ? 'w' : 'a');
- $prefix_elems = preg_split('/\.|_/', $export_data['prefix'], 2);
- $grids = $this->Application->getUnitOption($prefix_elems[0], 'Grids');
- $grid_config = $grids[$export_data['grid']]['Fields'];
+ $prefix_elements = preg_split('/\.|_/', $export_data['prefix'], 2);
+ $grid_config = $this->_getGridColumns($prefix_elements[0], $export_data['grid']);
$list_params = Array ('per_page' => $export_data['step'], 'grid' => $export_data['grid']);
- $list = $this->Application->recallObject(rtrim(implode('.', $prefix_elems), '.'), $prefix_elems[0] . '_List', $list_params);
+ $list = $this->Application->recallObject(rtrim(implode('.', $prefix_elements), '.'), $prefix_elements[0] . '_List', $list_params);
/* @var $list kDBList */
$list->SetPage($export_data['page']);
@@ -75,7 +74,7 @@
$picker_helper = $this->Application->recallObject('ColumnPickerHelper');
/* @var $picker_helper kColumnPickerHelper */
- $picker_helper->ApplyPicker(rtrim(implode('.', $prefix_elems), '.'), $grid_config, $export_data['grid']);
+ $picker_helper->ApplyPicker(rtrim(implode('.', $prefix_elements), '.'), $grid_config, $export_data['grid']);
if ( $first_step ) {
// if UTF-16, write Unicode marker
@@ -178,28 +177,33 @@
function ImportStart($filename)
{
- if(!file_exists($filename) || !is_file($filename)) return 'cant_open_file';
+ if ( !file_exists($filename) || !is_file($filename) ) {
+ return 'cant_open_file';
+ }
- $import_data = Array();
+ $import_data = Array ();
$import_data['source_encoding'] = strtoupper(CHARSET);
$import_data['encoding'] = $this->Application->ConfigValue('CSVExportEncoding') ? false : 'UTF-16LE';
$import_data['errors'] = '';
// convert file in case of UTF-16LE
- if($import_data['source_encoding'] != $import_data['encoding']) {
+ if ( $import_data['source_encoding'] != $import_data['encoding'] ) {
- copy($filename, $filename.'.orginal');
+ copy($filename, $filename . '.orginal');
$file_content = file_get_contents($filename);
$file = fopen($filename, 'w');
- fwrite($file, mb_convert_encoding(str_replace(chr(0xFF).chr(0xFE), '', $file_content), $import_data['source_encoding'], $import_data['encoding']));
+ fwrite($file, mb_convert_encoding(str_replace(chr(0xFF) . chr(0xFE), '', $file_content), $import_data['source_encoding'], $import_data['encoding']));
fclose($file);
-
}
$import_data['prefix'] = $this->PrefixSpecial;
$import_data['grid'] = $this->grid;
$import_data['file'] = $filename;
$import_data['total_lines'] = count(file($filename));
- if(!$import_data['total_lines']) $import_data['total_lines'] = 1;
+
+ if ( !$import_data['total_lines'] ) {
+ $import_data['total_lines'] = 1;
+ }
+
unset($file_content);
$import_data['lines_processed'] = 0;
$import_data['delimiter'] = $this->delimiter_mapping[(int)$this->Application->ConfigValue('CSVExportDelimiter')];
@@ -214,50 +218,76 @@
$headers = fgetcsv($file, 8192, $import_data['delimiter'], $import_data['enclosure']);
fclose($file);
- $prefix_elems = preg_split('/\.|_/', $import_data['prefix'], 2);
- $grids = $this->Application->getUnitOption($prefix_elems[0], 'Grids');
- $grid_config = $grids[ $import_data['grid'] ]['Fields'];
+ $prefix_elements = preg_split('/\.|_/', $import_data['prefix'], 2);
+ $grid_config = $this->_getGridColumns($prefix_elements[0], $import_data['grid']);
$field_list = Array();
+
- foreach($grid_config as $field_name => $field_data) {
+ foreach ($grid_config as $field_name => $field_data) {
- if(isset($field_data['export_field'])) {
+ if ( isset($field_data['export_field']) ) {
$field_name = $field_data['export_field'];
}
+
$field_title = isset($field_data['title']) ? $field_data['title'] : 'column:la_fld_' . $field_name;
$field_label = $this->Application->Phrase($field_title);
$field_pos = array_search($field_label, $headers);
+
- if($field_pos !== false) {
+ if ( $field_pos !== false ) {
$field_list[$field_pos] = $field_name;
}
}
- if(!count($field_list)) return 'no_matching_columns';
+ if ( !count($field_list) ) {
+ return 'no_matching_columns';
+ }
+
$import_data['field_list'] = $field_list;
// getting key list
- $field_positions = Array();
+ $field_positions = Array ();
- $config_key_list = $this->Application->getUnitOption($prefix_elems[0], 'ImportKeys');
- if(!$config_key_list) $config_key_list = Array();
- array_unshift($config_key_list, Array($this->Application->getUnitOption($prefix_elems[0], 'IDField')));
+ $config = $this->Application->getUnitConfig($prefix_elements[0]);
+ $config_key_list = $config->getImportKeys();
+ if ( !$config_key_list ) {
+ $config_key_list = Array ();
+ }
+
- $key_list = Array();
+ $key_list = Array ();
+ array_unshift($config_key_list, Array ($config->getIDField()));
+
- foreach($config_key_list as $arr_key => $import_key) {
+ foreach ($config_key_list as $arr_key => $import_key) {
- $key_list[$arr_key] = is_array($import_key) ? $import_key : Array($import_key);
+ $key_list[$arr_key] = is_array($import_key) ? $import_key : Array ($import_key);
- foreach($key_list[$arr_key] as $key_field) {
+ foreach ($key_list[$arr_key] as $key_field) {
$field_positions[$key_field] = array_search($key_field, $import_data['field_list']);
- if($field_positions[$key_field] === false) {
+ if ( $field_positions[$key_field] === false ) {
// no such key field combination in imported file
unset($key_list[$arr_key]);
break;
}
}
}
+
$import_data['key_list'] = $key_list;
$import_data['field_positions'] = $field_positions;
$this->Application->StoreVar('import_data', serialize($import_data));
return true;
+ }
+
+ /**
+ * Returns columns of given grid
+ *
+ * @param string $prefix
+ * @param string $grid_name
+ * @return Array
+ * @access protected
+ */
+ protected function _getGridColumns($prefix, $grid_name)
+ {
+ $grid = $this->Application->getUnitConfig($prefix)->getGridByName($grid_name);
+
+ return $grid['Fields'];
}
function ImportStep()
\ No newline at end of file
Index: core/units/helpers/sections_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/sections_helper.php (revision 15682)
+++ core/units/helpers/sections_helper.php (revision )
@@ -94,13 +94,13 @@
// 1.1. process prefixes without priority
$prioritized_prefixes = Array ();
- $prefixes = array_keys($this->Application->UnitConfigReader->configData);
+ $prefixes = $this->Application->UnitConfigReader->getPrefixes();
foreach ($prefixes as $prefix) {
- $config =& $this->Application->UnitConfigReader->configData[$prefix];
+ $config = $this->Application->getUnitConfig($prefix);
- if ( array_key_exists('ConfigPriority', $config) ) {
- $prioritized_prefixes[$prefix] = $config['ConfigPriority'];
+ if ( $config->getConfigPriority() !== false ) {
+ $prioritized_prefixes[$prefix] = $config->getConfigPriority();
continue;
}
@@ -115,10 +115,10 @@
// 2. apply section adjustments
foreach ($prefixes as $prefix) {
- $config =& $this->Application->UnitConfigReader->configData[$prefix];
- $section_adjustments = getArrayValue($config, 'SectionAdjustments');
- /* @var $section_adjustments Array */
+ $config = $this->Application->getUnitConfig($prefix);
+ $section_adjustments = $config->getSectionAdjustments();
+
if ( !$section_adjustments ) {
continue;
}
@@ -176,7 +176,8 @@
}
}
else {
- $module_folder = $this->Application->getUnitOption($section_params['SectionPrefix'], 'ModuleFolder');
+ $module_folder = $this->Application->getUnitConfig($section_params['SectionPrefix'])->getModuleFolder();
+
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');
@@ -211,9 +212,8 @@
function _processPrefixSections($prefix)
{
- $config =& $this->Application->UnitConfigReader->configData[$prefix];
- $sections = getArrayValue($config, 'Sections');
- /* @var $sections Array */
+ $config = $this->Application->getUnitConfig($prefix);
+ $sections = $config->getSections();
if ( !$sections ) {
return ;
@@ -224,8 +224,8 @@
if ( isset($section_params['SectionPrefix']) ) {
$section_prefix = $section_params['SectionPrefix'];
}
- elseif ( $this->Application->getUnitOption($prefix, 'SectionPrefix') ) {
- $section_prefix = $this->Application->getUnitOption($prefix, 'SectionPrefix');
+ elseif ( $this->Application->getUnitConfig($prefix)->getSectionPrefix() ) {
+ $section_prefix = $this->Application->getUnitConfig($prefix)->getSectionPrefix();
}
else {
$section_prefix = $prefix;
@@ -245,7 +245,7 @@
$section_params['url']['section'] = $section_name;
if ( !isset($section_params['url']['module']) ) {
- $module_name = $this->Application->findModule('Path', $config['ModuleFolder'] . '/', 'Name');
+ $module_name = $this->Application->findModule('Path', $config->getModuleFolder() . '/', 'Name');
$section_params['url']['module'] = $module_name;
}
}
@@ -371,8 +371,9 @@
if ($section_data && isset($section_data['perm_prefix'])) {
// this section uses other section permissions
- $ret = $this->Application->getUnitOption($section_data['perm_prefix'].'.main', 'PermSection');
+ $ret = $this->Application->getUnitConfig($section_data['perm_prefix'])->getPermSectionByName('main');
}
+
return $ret;
}
}
\ No newline at end of file
Index: core/units/logs/change_logs/change_log_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/logs/change_logs/change_log_eh.php (revision 15682)
+++ core/units/logs/change_logs/change_log_eh.php (revision )
@@ -48,7 +48,7 @@
$object = $event->getObject();
/* @var $object kDBItem */
- $sql = 'UPDATE ' . $this->Application->getUnitOption('session-log', 'TableName') . '
+ $sql = 'UPDATE ' . $this->Application->getUnitConfig('session-log')->getTableName() . '
SET AffectedItems = AffectedItems - 1
WHERE SessionLogId = ' . $object->GetDBField('SessionLogId');
$this->Conn->Query($sql);
\ No newline at end of file
Index: core/units/statistics/statistics_tag_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/statistics/statistics_tag_processor.php (revision 15682)
+++ core/units/statistics/statistics_tag_processor.php (revision )
@@ -219,16 +219,17 @@
$value = $this->Application->getCache($cache_key);
if ($value === false) {
- $statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
+ $config = $this->Application->getUnitConfig($prefix);
+ $statistics_info = $this->_getPendingStatisticsInfo($prefix);
+
if (!$statistics_info) {
return 0;
}
- $table = $this->Application->getUnitOption($prefix, 'TableName');
- $status_field = array_shift( $this->Application->getUnitOption($prefix, 'StatusField') );
+ $status_field = $config->getStatusField(true);
$this->Conn->nextQueryCachable = true;
$sql = 'SELECT COUNT(*)
- FROM '.$table.'
+ FROM '. $config->getTableName() .'
WHERE '.$status_field.' = '.$statistics_info['status'];
$value = $this->Conn->GetOne($sql);
$this->Application->setCache($cache_key, $value);
@@ -237,6 +238,20 @@
return $value;
}
+ /**
+ * Returns pending statistics info
+ *
+ * @param string $prefix
+ * @return string
+ * @access protected
+ */
+ protected function _getPendingStatisticsInfo($prefix)
+ {
+ $config = $this->Application->getUnitConfig($prefix);
+
+ return getArrayValue($config->getStatisticsInfo(), 'pending');
+ }
+
function GetTotalPending()
{
$prefixes = $this->getPendingPrefixes();
@@ -293,7 +308,7 @@
$prefixes = Array();
foreach ($check_prefixes as $prefix) {
- $statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
+ $statistics_info = $this->_getPendingStatisticsInfo($prefix);
if ($statistics_info) {
$prefixes[] = $prefix;
}
@@ -303,7 +318,7 @@
foreach ($prefixes as $i => $prefix) {
$block_params['prefix'] = $prefix;
- $statistics_info = $this->Application->getUnitOption($prefix.'.pending', 'StatisticsInfo');
+ $statistics_info = $this->_getPendingStatisticsInfo($prefix);
if ($i % $columns == 0) {
$column_number = 1;
\ No newline at end of file
Index: core/units/forms/submission_log/submission_log_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/forms/submission_log/submission_log_eh.php (revision 15682)
+++ core/units/forms/submission_log/submission_log_eh.php (revision )
@@ -217,8 +217,8 @@
$sql = 'SELECT f.ReplyFromEmail, sl.' . $object->IDField . '
FROM ' . $object->TableName . ' sl
- JOIN ' . $this->Application->getUnitOption('formsubs', 'TableName') . ' fs ON fs.FormSubmissionId = sl.FormSubmissionId
- JOIN ' . $this->Application->getUnitOption('form', 'TableName') . ' f ON f.FormId = fs.FormId
+ JOIN ' . $this->Application->getUnitConfig('formsubs')->getTableName() . ' fs ON fs.FormSubmissionId = sl.FormSubmissionId
+ JOIN ' . $this->Application->getUnitConfig('form')->getTableName() . ' f ON f.FormId = fs.FormId
WHERE sl.' . $object->IDField . ' IN (' . implode(',', $ids) . ')';
$reply_emails = $this->Conn->GetCol($sql, $object->IDField);
\ No newline at end of file
Index: core/kernel/managers/subscription_manager.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/managers/subscription_manager.php (revision 15682)
+++ core/kernel/managers/subscription_manager.php (revision )
@@ -104,7 +104,7 @@
public function getEmailTemplateId($template_name, $type = EmailTemplate::TEMPLATE_TYPE_FRONTEND)
{
$sql = 'SELECT TemplateId
- FROM ' . $this->Application->getUnitOption('email-template', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('email-template')->getTableName() . '
WHERE TemplateName = ' . $this->Conn->qstr($template_name) . ' AND Type = ' . $type;
$id = $this->Conn->GetOne($sql);
\ No newline at end of file
Index: core/units/permissions/permissions_tag_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/permissions/permissions_tag_processor.php (revision 15682)
+++ core/units/permissions/permissions_tag_processor.php (revision )
@@ -59,7 +59,7 @@
if ($section_data && isset($section_data['perm_prefix'])) {
// using permission from other prefix
- $section_name = $this->Application->getUnitOption($section_data['perm_prefix'].'.main', 'PermSection');
+ $section_name = $this->Application->getUnitConfig($section_data['perm_prefix'])->getPermSectionByName('main');
}
$permissions_helper = $this->Application->recallObject('PermissionsHelper');
@@ -95,7 +95,7 @@
$prefix = $this->Application->GetVar('item_prefix');
$module = $this->Application->findModule('Var', $prefix, 'Name');
- $perm_live_table = $this->Application->getUnitOption('c-perm', 'TableName');
+ $perm_live_table = $this->Application->getUnitConfig('c-perm')->getTableName();
$perm_temp_table = $this->Application->GetTempName($perm_live_table, 'prefix:'.$this->Prefix);
if ($category->GetID() == 0) {
@@ -177,7 +177,7 @@
$ret = '';
$block_params = $params;
foreach ($this->Application->ModuleInfo as $module_name => $module_data) {
- if (!$this->Application->prefixRegistred($module_data['Var']) || !$this->Application->getUnitOption($module_data['Var'], 'CatalogItem')) continue;
+ if (!$this->Application->prefixRegistred($module_data['Var']) || !$this->Application->getUnitConfig($module_data['Var'])->getCatalogItem()) continue;
$params['item_prefix'] = $module_data['Var'];
$ret .= $this->Application->IncludeTemplate($params);
}
@@ -201,15 +201,14 @@
if ( $category_path === false ) {
// not cached
if ( $category_id > 0 ) {
- $id_field = $this->Application->getUnitOption('c', 'IDField');
- $table_name = $this->Application->getUnitOption('c', 'TableName');
-
$ml_formatter = $this->Application->recallObject('kMultiLanguage');
/* @var $ml_formatter kMultiLanguage */
+ $categories_config = $this->Application->getUnitConfig('c');
+
$sql = 'SELECT ' . $ml_formatter->LangFieldName('CachedNavbar') . '
- FROM ' . $table_name . '
- WHERE ' . $id_field . ' = ' . $category_id;
+ FROM ' . $categories_config->getTableName() . '
+ WHERE ' . $categories_config->getIDField() . ' = ' . $category_id;
$cached_navbar = preg_replace('/^Content(&\|&){0,1}/i', '', $this->Conn->GetOne($sql));
$category_path = trim($this->CategoryPath(Array ('cat_id' => 0)) . ' > ' . str_replace('&|&', ' > ', $cached_navbar), ' > ');
}
\ No newline at end of file
Index: core/units/helpers/rating_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/rating_helper.php (revision 15682)
+++ core/units/helpers/rating_helper.php (revision )
@@ -53,7 +53,7 @@
public function ratingBar(&$object, $show_div = true, $additional_msg = '', $additional_style = '')
{
// 1. user is allowed to vote by permissions
- $perm_prefix = $this->Application->getUnitOption($object->Prefix, 'PermItemPrefix');
+ $perm_prefix = $object->getUnitConfig()->getPermItemPrefix();
$static = !$this->Application->CheckPermission($perm_prefix . '.RATE', 0, $object->GetDBField('CategoryId'));
// 2. user isn't voting too frequently
@@ -178,7 +178,7 @@
return '@err:' . $this->_replaceInPhrase('already_voted');
}
- $perm_prefix = $this->Application->getUnitOption($object->Prefix, 'PermItemPrefix');
+ $perm_prefix = $object->getUnitConfig()->getPermItemPrefix();
$can_rate = $this->Application->CheckPermission($perm_prefix . '.RATE', 0, $object->GetDBField('CategoryId'));
$rating = (int)$this->Application->GetVar('rating'); // not numeric rating is from GoogleBot :(
$additional_style = $this->Application->GetVar('size');
@@ -257,7 +257,7 @@
/* @var $spam_helper SpamHelper */
// 2. user isn't voting too frequently
- $config_mapping = $this->Application->getUnitOption($object->Prefix, 'ConfigMapping');
+ $config_mapping = $object->getUnitConfig()->getConfigMapping();
$review_settings = $config_mapping['RatingDelayValue'] . ':' . $config_mapping['RatingDelayInterval'];
$spam_helper->InitHelper($object->GetDBField('ResourceId'), 'Rating', $review_settings, $object->GetCol('ResourceId'));
\ No newline at end of file
Index: core/units/site_domains/site_domain_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/site_domains/site_domain_eh.php (revision 15682)
+++ core/units/site_domains/site_domain_eh.php (revision )
@@ -162,18 +162,19 @@
'PrimaryPaymentTypeId', 'PaymentTypes'
);
+ $config = $event->getUnitConfig();
+
// remove field definitions
- $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+ $fields = $config->getFields();
foreach ($remove_fields as $remove_field) {
unset($fields[$remove_field]);
}
- $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+ $config->setFields($fields);
// remove grid columns
- $grids = $this->Application->getUnitOption($event->Prefix, 'Grids', Array ());
- /* @var $grids Array */
+ $grids = $config->getGrids(Array ());
foreach ($grids as $grid_name => $grid_info) {
foreach ($remove_fields as $remove_field) {
@@ -183,7 +184,7 @@
}
}
- $this->Application->setUnitOption($event->Prefix, 'Grids', $grids);
+ $config->setGrids($grids);
}
}
Index: core/kernel/utility/event.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/utility/event.php (revision 15682)
+++ core/kernel/utility/event.php (revision )
@@ -408,29 +408,33 @@
public function getSection()
{
$perm_section = $this->getEventParam('PermSection');
+
- if ($perm_section) {
+ if ( $perm_section ) {
return $perm_section;
}
// 1. get section by current top_prefix
$top_prefix = $this->getEventParam('top_prefix');
+
- if ($top_prefix == false) {
+ if ( $top_prefix == false ) {
$top_prefix = $this->Application->GetTopmostPrefix($this->Prefix, true);
$this->setEventParam('top_prefix', $top_prefix);
}
- $section = $this->Application->getUnitOption($top_prefix.'.main', 'PermSection');
+ $section = $this->Application->getUnitConfig($top_prefix)->getPermSectionByName('main');
+
// 2. check if this section has perm_prefix mapping to other prefix
$sections_helper = $this->Application->recallObject('SectionsHelper');
/* @var $sections_helper kSectionsHelper */
$section_data =& $sections_helper->getSectionData($section);
+
- if ($section_data && isset($section_data['perm_prefix']) && $section_data['perm_prefix'] != $top_prefix) {
+ if ( $section_data && isset($section_data['perm_prefix']) && $section_data['perm_prefix'] != $top_prefix ) {
$this->setEventParam('top_prefix', $section_data['perm_prefix']);
- $section = $this->Application->getUnitOption($section_data['perm_prefix'].'.main', 'PermSection');
+ $section = $this->Application->getUnitConfig($section_data['perm_prefix'])->getPermSectionByName('main');
}
- if (!$section) {
+ if ( !$section ) {
throw new Exception('Permission section not specified for prefix ' . $top_prefix . '');
}
\ No newline at end of file
Index: core/units/logs/email_logs/email_log_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/logs/email_logs/email_log_eh.php (revision 15682)
+++ core/units/logs/email_logs/email_log_eh.php (revision )
@@ -73,8 +73,10 @@
return;
}
- $sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . '
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ $config = $event->getUnitConfig();
+
+ $sql = 'SELECT ' . $config->getIDField() . '
+ FROM ' . $config->getTableName() . '
WHERE ' . TIMENOW . ' - SentOn > ' . $rotation_interval;
$ids = $this->Conn->GetCol($sql);
\ No newline at end of file
Index: core/units/category_items/category_items_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/category_items/category_items_event_handler.php (revision 15682)
+++ core/units/category_items/category_items_event_handler.php (revision )
@@ -121,14 +121,12 @@
{
parent::OnAfterClone($event);
- $id = $event->getEventParam('id');
- $table = $this->Application->getUnitOption($event->Prefix, 'TableName');
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
+ $config = $event->getUnitConfig();
- $sql = 'UPDATE %s
+ $sql = 'UPDATE ' . $config->getTableName() . '
SET PrimaryCat = 0
- WHERE %s = %s';
- $this->Conn->Query(sprintf($sql, $table, $id_field, $id));
+ WHERE ' . $config->getIDField() . ' = ' . $event->getEventParam('id');
+ $this->Conn->Query($sql);
}
/**
@@ -151,8 +149,8 @@
$item = $this->Application->recallObject($item_prefix . '.-item', null, Array ('skip_autoload' => true));
/* @var $item kCatDBItem */
- $ci_table = $this->Application->getUnitOption($event->Prefix, 'TableName');
- $item_table = $this->Application->getUnitOption($item_prefix, 'TableName');
+ $ci_table = $event->getUnitConfig()->getTableName();
+ $item_table = $this->Application->getUnitConfig($item_prefix)->getTableName();
$sql = 'SELECT ItemResourceId, CategoryId
FROM %1$s
\ No newline at end of file
Index: core/units/helpers/user_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/user_helper.php (revision 15682)
+++ core/units/helpers/user_helper.php (revision )
@@ -524,7 +524,7 @@
*/
function checkBanRules(&$object)
{
- $table = $this->Application->getUnitOption('ban-rule', 'TableName');
+ $table = $this->Application->getUnitConfig('ban-rule')->getTableName();
if (!$this->Conn->TableFound($table)) {
// when ban table not found -> assume user is ok by default
@@ -607,7 +607,7 @@
function _checkValueExist($field, $value)
{
$sql = 'SELECT *
- FROM ' . $this->Application->getUnitOption('u', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('u')->getTableName() . '
WHERE '. $field .' = ' . $this->Conn->qstr($value);
return $this->Conn->GetOne($sql);
\ No newline at end of file
Index: core/units/themes/themes_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/themes/themes_eh.php (revision 15682)
+++ core/units/themes/themes_eh.php (revision )
@@ -77,8 +77,8 @@
function setPrimary($id)
{
- $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $config = $this->getUnitConfig();
+ $table_name = $config->getTableName();
$sql = 'UPDATE '.$table_name.'
SET PrimaryTheme = 0';
@@ -87,7 +87,7 @@
$sql = 'UPDATE '.$table_name.'
SET PrimaryTheme = 1, Enabled = 1
- WHERE '.$id_field.' = '.$id;
+ WHERE '. $config->getIDField() .' = '.$id;
$this->Conn->Query($sql);
}
@@ -127,14 +127,12 @@
return ;
}
+ $config = $event->getUnitConfig();
$ids = $event->getEventParam('ids');
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
-
$sql = 'SELECT COUNT(*)
- FROM ' . $table_name . '
- WHERE ' . $id_field . ' IN (' . $ids . ') AND (Enabled = 1)';
+ FROM ' . $config->getTableName() . '
+ WHERE ' . $config->getIDField() . ' IN (' . $ids . ') AND (Enabled = 1)';
$enabled_themes = $this->Conn->GetOne($sql);
if ( $enabled_themes ) {
Index: core/units/email_templates/email_template_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/email_templates/email_template_eh.php (revision 15682)
+++ core/units/email_templates/email_template_eh.php (revision )
@@ -70,7 +70,7 @@
$exceptions = Array ('Category' => 'c', 'Users' => 'u');
$main_prefix = $exceptions[$module[1]];
}
- $section = $this->Application->getUnitOption($main_prefix . '.email', 'PermSection');
+ $section = $this->Application->getUnitConfig($main_prefix)->getPermSectionByName('email');
$event->setEventParam('PermSection', $section);
}
@@ -162,12 +162,11 @@
return;
}
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $config = $event->getUnitConfig();
- $sql = 'UPDATE ' . $table_name . '
+ $sql = 'UPDATE ' . $config->getTableName() . '
SET FrontEndOnly = 1
- WHERE ' . $id_field . ' IN (' . implode(',', $this->StoreSelectedIDs($event)) . ')';
+ WHERE ' . $config->getIDField() . ' IN (' . implode(',', $this->StoreSelectedIDs($event)) . ')';
$this->Conn->Query($sql);
$this->clearSelectedIDs($event);
@@ -196,13 +195,12 @@
if ( $items_info ) {
list ($user_id, ) = each($items_info);
+ $config = $event->getUnitConfig();
$ids = $this->Application->RecallVar($event->getPrefixSpecial() . '_selected_ids');
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
- $sql = 'UPDATE ' . $table_name . '
+ $sql = 'UPDATE ' . $config->getTableName() . '
SET ' . $this->Application->RecallVar('dst_field') . ' = ' . $user_id . '
- WHERE ' . $id_field . ' IN (' . $ids . ')';
+ WHERE ' . $config->getIDField() . ' IN (' . $ids . ')';
$this->Conn->Query($sql);
}
@@ -306,12 +304,14 @@
$options[$module_name] = $module_name;
}
- $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+ $config = $event->getUnitConfig();
+
+ $fields = $config->getFields();
$fields['Module']['options'] = $options;
- $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+ $config->setFields($fields);
if ( $this->Application->GetVar('regional') ) {
- $this->Application->setUnitOption($event->Prefix, 'PopulateMlFields', true);
+ $config->setPopulateMlFields(true);
}
}
@@ -683,7 +683,7 @@
return;
}
- $this->Application->setUnitOption('phrases', 'AutoLoad', false);
+ $this->Application->getUnitConfig('phrases')->setAutoLoad(false);
$this->StoreSelectedIDs($event);
$this->Application->StoreVar('export_language_ids', $this->Application->GetVar('m_lang'));
\ No newline at end of file
Index: core/kernel/utility/unit_config_reader.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/utility/unit_config_reader.php (revision 15682)
+++ core/kernel/utility/unit_config_reader.php (revision )
@@ -19,10 +19,11 @@
/**
* Configs reader
*
- * @var Array
+ * @var Array|kUnitConfig[]
* @access private
*/
var $configData = Array();
+
var $configFiles = Array();
var $CacheExpired = false;
@@ -230,12 +231,14 @@
function ParseConfigs()
{
// 1. process normal configs
- $prioritized_configs = array();
+ $prioritized_configs = Array ();
+
foreach ($this->configData as $prefix => $config) {
- if (isset($config['ConfigPriority'])) {
- $prioritized_configs[$prefix] = $config['ConfigPriority'];
+ if ( $config->getConfigPriority() !== false ) {
+ $prioritized_configs[$prefix] = $config->getConfigPriority();
continue;
}
+
$this->parseConfig($prefix);
}
@@ -264,23 +267,26 @@
$store_cache = $this->StoreCache;
}
- if ($store_cache || (defined('IS_INSTALL') && IS_INSTALL)) {
+ if ( $store_cache || (defined('IS_INSTALL') && IS_INSTALL) ) {
// cache is not stored during install, but dynamic clones should be processed in any case
$this->processDynamicClones();
$this->retrieveCollections();
}
- if ($store_cache) {
+ if ( $store_cache ) {
$this->_sortRewriteListeners();
$this->Application->HandleEvent(new kEvent('adm:OnAfterCacheRebuild'));
$this->Application->cacheManager->UpdateUnitCache();
- if (defined('DEBUG_MODE') && DEBUG_MODE && defined('DBG_VALIDATE_CONFIGS') && DBG_VALIDATE_CONFIGS) {
+ if ( defined('DEBUG_MODE') && DEBUG_MODE && defined('DBG_VALIDATE_CONFIGS') && DBG_VALIDATE_CONFIGS ) {
// validate configs here to have changes from OnAfterConfigRead hooks to prefixes
foreach ($this->configData as $prefix => $config) {
- if (!isset($config['TableName'])) continue;
+ if ( !$config->getTableName() ) {
+ continue;
+ }
+
$this->ValidateConfig($prefix);
}
}
@@ -371,26 +377,26 @@
{
foreach ($this->configData as $prefix => $config) {
// collect replacement templates
- if (array_key_exists('ReplacementTemplates', $config) && $config['ReplacementTemplates']) {
- $this->Application->ReplacementTemplates = array_merge($this->Application->ReplacementTemplates, $config['ReplacementTemplates']);
+ if ( $config->getReplacementTemplates() ) {
+ $this->Application->ReplacementTemplates = array_merge($this->Application->ReplacementTemplates, $config->getReplacementTemplates());
}
// collect rewrite listeners
- if (array_key_exists('RewriteListener', $config) && $config['RewriteListener']) {
- $rewrite_listeners = $config['RewriteListener'];
+ if ( $config->getRewriteListener() ) {
+ $rewrite_listeners = $config->getRewriteListener();
- if (!is_array($rewrite_listeners)) {
+ if ( !is_array($rewrite_listeners) ) {
// when one method is used to build and parse url
$rewrite_listeners = Array ($rewrite_listeners, $rewrite_listeners);
}
foreach ($rewrite_listeners as $index => $rewrite_listener) {
- if (strpos($rewrite_listener, ':') === false) {
+ if ( strpos($rewrite_listener, ':') === false ) {
$rewrite_listeners[$index] = $prefix . '_EventHandler:' . $rewrite_listener;
}
}
- $rewrite_priority = array_key_exists('RewritePriority', $config) ? $config['RewritePriority'] : false;
+ $rewrite_priority = $config->getRewritePriority();
$this->Application->RewriteListeners[$prefix] = Array ('listener' => $rewrite_listeners, 'priority' => $rewrite_priority);
}
@@ -414,13 +420,13 @@
protected function parseClasses($prefix)
{
- $config =& $this->configData[$prefix];
+ $config = $this->configData[$prefix];
$register_classes = $this->getClasses($prefix);
foreach ($register_classes as $class_info) {
$this->Application->registerClass(
$class_info['class'],
- $config['BasePath'] . DIRECTORY_SEPARATOR . $class_info['file'],
+ $config->getBasePath() . DIRECTORY_SEPARATOR . $class_info['file'],
$class_info['pseudo']
);
@@ -432,57 +438,57 @@
protected function parseScheduledTasks($prefix)
{
- $config =& $this->configData[$prefix];
+ $config = $this->configData[$prefix];
- if ( !isset($config['ScheduledTasks']) || !$config['ScheduledTasks'] ) {
+ if ( !$config->getScheduledTasks() ) {
return ;
}
- $scheduled_tasks = $config['ScheduledTasks'];
+ $scheduled_tasks = $config->getScheduledTasks();
foreach ($scheduled_tasks as $short_name => $scheduled_task_info) {
$event_status = array_key_exists('Status', $scheduled_task_info) ? $scheduled_task_info['Status'] : STATUS_ACTIVE;
- $this->Application->delayUnitProcessing('registerScheduledTask', Array ( $short_name, $config['Prefix'] . ':' . $scheduled_task_info['EventName'], $scheduled_task_info['RunSchedule'], $event_status ));
+ $this->Application->delayUnitProcessing('registerScheduledTask', Array ( $short_name, $config->getPrefix() . ':' . $scheduled_task_info['EventName'], $scheduled_task_info['RunSchedule'], $event_status ));
}
}
protected function parseHooks($prefix)
{
- $config =& $this->configData[$prefix];
+ $config = $this->configData[$prefix];
- if ( !isset($config['Hooks']) || !$config['Hooks'] ) {
+ if ( !$config->getHooks() ) {
- return ;
+ return;
}
- $hooks = $config['Hooks'];
+ $hooks = $config->getHooks();
foreach ($hooks as $hook) {
- if ( isset($config['ParentPrefix']) && ($hook['HookToPrefix'] == $config['ParentPrefix']) ) {
- trigger_error('Depricated Hook Usage [prefix: ' . $config['Prefix'] . '; do_prefix: ' . $hook['DoPrefix'] . '] use #PARENT# as HookToPrefix value, where HookToPrefix is same as ParentPrefix', defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_NOTICE);
+ if ( $config->getParentPrefix() && ($hook['HookToPrefix'] == $config->getParentPrefix()) ) {
+ trigger_error('Deprecated Hook Usage [prefix: ' . $config->getPrefix() . '; do_prefix: ' . $hook['DoPrefix'] . '] use #PARENT# as HookToPrefix value, where HookToPrefix is same as ParentPrefix', defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_NOTICE);
}
- if ($hook['HookToPrefix'] == '') {
+ if ( $hook['HookToPrefix'] == '' ) {
// new: set hooktoprefix to current prefix if not set
- $hook['HookToPrefix'] = $config['Prefix'];
+ $hook['HookToPrefix'] = $config->getPrefix();
}
- if ( isset($config['ParentPrefix']) ) {
+ if ( $config->getParentPrefix() ) {
// new: allow to set hook to parent prefix what ever it is
- if ($hook['HookToPrefix'] == '#PARENT#') {
+ if ( $hook['HookToPrefix'] == '#PARENT#' ) {
- $hook['HookToPrefix'] = $config['ParentPrefix'];
+ $hook['HookToPrefix'] = $config->getParentPrefix();
}
- if ($hook['DoPrefix'] == '#PARENT#') {
+ if ( $hook['DoPrefix'] == '#PARENT#' ) {
- $hook['DoPrefix'] = $config['ParentPrefix'];
+ $hook['DoPrefix'] = $config->getParentPrefix();
}
}
- elseif ($hook['HookToPrefix'] == '#PARENT#' || $hook['DoPrefix'] == '#PARENT#') {
+ elseif ( $hook['HookToPrefix'] == '#PARENT#' || $hook['DoPrefix'] == '#PARENT#' ) {
// we need parent prefix but it's not set !
continue;
}
$hook_events = (array)$hook['HookToEvent'];
- $do_prefix = $hook['DoPrefix'] == '' ? $config['Prefix'] : $hook['DoPrefix'];
+ $do_prefix = $hook['DoPrefix'] == '' ? $config->getPrefix() : $hook['DoPrefix'];
foreach ($hook_events as $hook_event) {
$hook_event = $hook['HookToPrefix'] . '.' . $hook['HookToSpecial'] . ':' . $hook_event;
@@ -495,21 +501,25 @@
protected function parseAggregatedTags($prefix)
{
- $config =& $this->configData[$prefix];
- $aggregated_tags = isset($config['AggregateTags']) ? $config['AggregateTags'] : Array ();
+ $config = $this->configData[$prefix];
+ $aggregated_tags = $config->getAggregateTags();
+ if ( !$aggregated_tags ) {
+ return;
+ }
+
foreach ($aggregated_tags as $aggregate_tag) {
- if ( isset($config['ParentPrefix']) ) {
- if ($aggregate_tag['AggregateTo'] == $config['ParentPrefix']) {
- trigger_error('Depricated Aggregate Tag Usage [prefix: '.$config['Prefix'].'; AggregateTo: '.$aggregate_tag['AggregateTo'].'] use #PARENT# as AggregateTo value, where AggregateTo is same as ParentPrefix', defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_NOTICE);
+ if ( $config->getParentPrefix() ) {
+ if ( $aggregate_tag['AggregateTo'] == $config->getParentPrefix() ) {
+ trigger_error('Deprecated Aggregate Tag Usage [prefix: ' . $config->getPrefix() . '; AggregateTo: ' . $aggregate_tag['AggregateTo'] . '] use #PARENT# as AggregateTo value, where AggregateTo is same as ParentPrefix', defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_NOTICE);
}
- if ($aggregate_tag['AggregateTo'] == '#PARENT#') {
+ if ( $aggregate_tag['AggregateTo'] == '#PARENT#' ) {
- $aggregate_tag['AggregateTo'] = $config['ParentPrefix'];
+ $aggregate_tag['AggregateTo'] = $config->getParentPrefix();
}
}
- $aggregate_tag['LocalPrefix'] = $config['Prefix'];
+ $aggregate_tag['LocalPrefix'] = $config->getPrefix();
$this->Application->delayUnitProcessing('registerAggregateTag', Array ($aggregate_tag));
}
}
@@ -518,23 +528,23 @@
{
global $debugger;
- $config =& $this->configData[$prefix];
+ $config = $this->configData[$prefix];
- $tablename = $config['TableName'];
+ $table_name = $config->getTableName();
$float_types = Array ('float', 'double', 'numeric');
- $table_found = $this->Conn->Query('SHOW TABLES LIKE "'.$tablename.'"');
+ $table_found = $this->Conn->Query('SHOW TABLES LIKE "' . $table_name . '"');
- if (!$table_found) {
+ if ( !$table_found ) {
// config present, but table missing, strange
kUtil::safeDefine('DBG_RAISE_ON_WARNINGS', 1);
- $debugger->appendHTML("Config Warning: Table $tablename missing, but prefix ".$config['Prefix']." requires it!");
+ $debugger->appendHTML("Config Warning: Table $table_name missing, but prefix " . $prefix . " requires it!");
$debugger->WarningCount++;
- return ;
+ return;
}
- $res = $this->Conn->Query('DESCRIBE '.$tablename);
- $config_link = $debugger->getFileLink(FULL_PATH.$this->prefixFiles[$config['Prefix']], 1, $config['Prefix']);
+ $res = $this->Conn->Query('DESCRIBE ' . $table_name);
+ $config_link = $debugger->getFileLink(FULL_PATH . $this->prefixFiles[$prefix], 1, $prefix);
$error_messages = Array (
'field_not_found' => 'Field %s exists in the database, but is not defined in config',
@@ -553,77 +563,78 @@
);
$config_errors = Array ();
- $tablename = preg_replace('/^'.preg_quote(TABLE_PREFIX, '/').'(.*)/', '\\1', $tablename); // remove table prefix
+ $fields = $config->getFields();
+ $table_name = preg_replace('/^' . preg_quote(TABLE_PREFIX, '/') . '(.*)/', '\\1', $table_name); // remove table prefix
+ if ( $fields ) {
- // validate unit config field declaration in relation to database table structure
- foreach ($res as $field) {
- $f_name = $field['Field'];
+ // validate unit config field declaration in relation to database table structure
+ foreach ($res as $field) {
+ $f_name = $field['Field'];
- if (getArrayValue($config, 'Fields')) {
- if (preg_match('/l[\d]+_[\w]/', $f_name)) {
+ if ( preg_match('/l[\d]+_[\w]/', $f_name) ) {
// skip multilingual fields
continue;
}
- if (!array_key_exists ($f_name, $config['Fields'])) {
+ if ( !array_key_exists($f_name, $fields) ) {
$config_errors[] = sprintf($error_messages['field_not_found'], $f_name);
}
else {
$db_default = $field['Default'];
- if (is_numeric($db_default)) {
+ if ( is_numeric($db_default) ) {
$db_default = preg_match('/[\.,]/', $db_default) ? (float)$db_default : (int)$db_default;
}
$default_missing = false;
- $options = $config['Fields'][$f_name];
+ $options = $fields[$f_name];
$not_null = isset($options['not_null']) && $options['not_null'];
$formatter = array_key_exists('formatter', $options) ? $options['formatter'] : false;
- if (!array_key_exists('default', $options)) {
+ if ( !array_key_exists('default', $options) ) {
$config_errors[] = sprintf($error_messages['default_missing'], $f_name);
$default_missing = true;
}
- if ($field['Null'] != 'YES') {
+ if ( $field['Null'] != 'YES' ) {
// field is NOT NULL in database (MySQL5 for null returns "NO", but MySQL4 returns "")
- if ( $f_name != $config['IDField'] && !isset($options['not_null']) /*&& !isset($options['required'])*/ ) {
+ if ( $f_name != $config->getIDField() && !isset($options['not_null']) /*&& !isset($options['required'])*/ ) {
$config_errors[] = sprintf($error_messages['not_null_error1'], $f_name);
}
- if ($not_null && !isset($options['default']) ) {
+ if ( $not_null && !isset($options['default']) ) {
$config_errors[] = sprintf($error_messages['not_null_error2'], $f_name);
}
}
- elseif ($not_null) {
+ elseif ( $not_null ) {
$config_errors[] = sprintf($error_messages['not_null_error3'], $f_name);
}
- if (($formatter == 'kDateFormatter') && $not_null) {
+ if ( ($formatter == 'kDateFormatter') && $not_null ) {
$config_errors[] = sprintf($error_messages['date_column_not_null_error'], $f_name);
}
// columns, holding userid should have NULL as default value
- if (array_key_exists('type', $options) && !$default_missing) {
+ if ( array_key_exists('type', $options) && !$default_missing ) {
// both type and default value set
- if (preg_match('/ById$/', $f_name) && $options['default'] !== null) {
+ if ( preg_match('/ById$/', $f_name) && $options['default'] !== null ) {
$config_errors[] = sprintf($error_messages['user_column_default_error'], $f_name);
}
}
- if (!array_key_exists('type', $options)) {
+ if ( !array_key_exists('type', $options) ) {
$config_errors[] = sprintf($error_messages['type_missing'], $f_name);
}
- if (!$default_missing && ($field['Type'] != 'text')) {
+ if ( !$default_missing && ($field['Type'] != 'text') ) {
if ( is_null($db_default) && $not_null ) {
$db_default = $options['type'] == 'string' ? '' : 0;
}
- if ($f_name == $config['IDField'] && $options['type'] != 'string' && $options['default'] !== 0) {
+ if ( $f_name == $config->getIDField() && $options['type'] != 'string' && $options['default'] !== 0 ) {
$config_errors[] = sprintf($error_messages['invalid_default'], 'IDField ', $f_name, $this->varDump($options['default']), $this->varDump($field['Default']));
}
- else if (((string)$options['default'] != '#NOW#') && ($db_default !== $options['default']) && !in_array($options['type'], $float_types)) {
+ else if ( ((string)$options['default'] != '#NOW#') && ($db_default !== $options['default']) && !in_array($options['type'], $float_types) ) {
$config_errors[] = sprintf($error_messages['invalid_default'], '', $f_name, $this->varDump($options['default']), $this->varDump($db_default));
}
}
@@ -632,27 +643,29 @@
}
// validate virtual fields
- if ( array_key_exists('VirtualFields', $config) ) {
- foreach ($config['VirtualFields'] as $f_name => $options) {
+ if ( $config->getVirtualFields() ) {
+ foreach ($config->getVirtualFields() as $f_name => $options) {
- if (!array_key_exists('type', $options)) {
+ if ( !array_key_exists('type', $options) ) {
$config_errors[] = sprintf($error_messages['virtual_type_missing'], $f_name);
}
- if (array_key_exists('not_null', $options)) {
+ if ( array_key_exists('not_null', $options) ) {
$config_errors[] = sprintf($error_messages['virtual_not_null_error'], $f_name);
}
- if (!array_key_exists('default', $options)) {
+ if ( !array_key_exists('default', $options) ) {
$config_errors[] = sprintf($error_messages['virtual_default_missing'], $f_name);
}
}
}
// validate calculated fields
- if ( array_key_exists('CalculatedFields', $config) ) {
- foreach ($config['CalculatedFields'] as $special => $calculated_fields) {
- foreach ($calculated_fields as $calculated_field => $calculated_field_expr) {
- if ( !isset($config['VirtualFields'][$calculated_field]) ) {
+ if ( $config->getCalculatedFieldSpecials() ) {
+ $virtual_fields = $config->getVirtualFields();
+
+ foreach ($config->getCalculatedFieldSpecials() as $special) {
+ foreach ($config->getCalculatedFieldsBySpecial($special) as $calculated_field => $calculated_field_expr) {
+ if ( !isset($virtual_fields[$calculated_field]) ) {
$config_errors[] = sprintf($error_messages['invalid_calculated_field'], $calculated_field);
}
}
@@ -661,9 +674,9 @@
$config_errors = array_unique($config_errors);
}
- if ($config_errors) {
+ if ( $config_errors ) {
- $error_prefix = 'Config Error'.(count($config_errors) > 1 ? 's' : '').': for prefix '.$config_link.' ('.$tablename.') in unit config:
';
+ $error_prefix = 'Config Error' . (count($config_errors) > 1 ? 's' : '') . ': for prefix ' . $config_link . ' (' . $table_name . ') in unit config:
';
- $config_errors = $error_prefix.' '.implode('
', $config_errors);
+ $config_errors = $error_prefix . ' ' . implode('
', $config_errors);
kUtil::safeDefine('DBG_RAISE_ON_WARNINGS', 1);
$debugger->appendHTML($config_errors);
@@ -678,45 +691,54 @@
function postProcessConfig($prefix, $config_key, $dst_prefix_var)
{
- $main_config =& $this->configData[$prefix];
- $sub_configs = isset($main_config[$config_key]) && $main_config[$config_key] ? $main_config[$config_key] : Array ();
+ $main_config = $this->configData[$prefix];
+ $sub_configs = $main_config->getSetting($config_key);
+
if ( !$sub_configs ) {
return Array ();
}
- unset($main_config[$config_key]);
- $processed = array();
- foreach ($sub_configs as $sub_prefix => $sub_config) {
+ $processed = Array ();
+ $main_config->setSetting($config_key, null);
+
+ foreach ($sub_configs as $sub_prefix => $sub_config_data) {
- if ($config_key == 'AggregateConfigs' && !isset($this->configData[$sub_prefix])) {
+ if ( $config_key == 'AggregateConfigs' && !isset($this->configData[$sub_prefix]) ) {
$this->loadConfig($sub_prefix);
}
- $sub_config['Prefix'] = $sub_prefix;
- $this->configData[$sub_prefix] = kUtil::array_merge_recursive($this->configData[$$dst_prefix_var], $sub_config);
+ $sub_config_data['Prefix'] = $sub_prefix;
+ $sub_config_base = $this->configData[$$dst_prefix_var]->getRaw();
+ $sub_config = new kUnitConfig($sub_prefix, kUtil::array_merge_recursive($sub_config_base, $sub_config_data));
+ $this->configData[$sub_prefix] = $sub_config;
+
// when merging empty array to non-empty results non-empty array, but empty is required
- foreach ($sub_config as $sub_key => $sub_value) {
- if (!$sub_value) {
- unset($this->configData[$sub_prefix][$sub_key]);
+ foreach ($sub_config_data as $sub_key => $sub_value) {
+ if ( !$sub_value && is_array($sub_value) ) {
+ $sub_config->setSetting($sub_key, null);
}
}
+
- if ($config_key == 'Clones') {
+ if ( $config_key == 'Clones' ) {
$this->prefixFiles[$sub_prefix] = $this->prefixFiles[$prefix];
}
$this->postProcessConfig($sub_prefix, $config_key, $dst_prefix_var);
+
- if ($config_key == 'AggregateConfigs') {
+ if ( $config_key == 'AggregateConfigs' ) {
$processed = array_merge($this->postProcessConfig($sub_prefix, 'Clones', 'prefix'), $processed);
}
- elseif ($this->ProcessAllConfigs) {
+ elseif ( $this->ProcessAllConfigs ) {
$this->parseConfig($sub_prefix);
}
+
array_push($processed, $sub_prefix);
}
- if (!$prefix) {
+ if ( !$prefix ) {
- // configs, that used only for cloning & not used ifself
+ // configs, that used only for cloning & not used itself
unset($this->configData[$prefix]);
}
+
return array_unique($processed);
}
@@ -724,14 +746,14 @@
{
$config_found = file_exists(FULL_PATH . $filename) && $this->configAllowed($filename);
- if (defined('DEBUG_MODE') && DEBUG_MODE && defined('DBG_PROFILE_INCLUDES') && DBG_PROFILE_INCLUDES) {
+ if ( defined('DEBUG_MODE') && DEBUG_MODE && defined('DBG_PROFILE_INCLUDES') && DBG_PROFILE_INCLUDES ) {
if ( in_array($filename, get_included_files()) ) {
return '';
}
global $debugger;
- if ($config_found) {
+ if ( $config_found ) {
$file = FULL_PATH . $filename;
$file_crc = crc32($file);
@@ -741,26 +763,34 @@
$debugger->profilerAddTotal('includes', 'inc_' . $file_crc);
}
}
- elseif ($config_found) {
+ elseif ( $config_found ) {
include_once(FULL_PATH . $filename);
}
- if ($config_found) {
+ if ( $config_found ) {
+ /* @var $config kUnitConfig|Array */
+
- if (isset($config) && $config) {
+ if ( isset($config) && $config ) {
// config file is included for 1st time -> save it's content for future processing
+ if ( !is_object($config) ) {
- $prefix = array_key_exists('Prefix', $config) ? $config['Prefix'] : '';
+ $prefix = array_key_exists('Prefix', $config) ? $config['Prefix'] : '';
+ $config = new kUnitConfig($prefix, $config);
+ }
+ else {
+ $prefix = $config->getPrefix();
+ }
- preg_match($this->_moduleFolderRegExp, $filename, $rets);
- $config['ModuleFolder'] = str_replace(DIRECTORY_SEPARATOR, '/', $rets[1]);
- $config['BasePath'] = dirname(FULL_PATH . $filename);
+ preg_match($this->_moduleFolderRegExp, $filename, $regs);
+ $config->setModuleFolder(str_replace(DIRECTORY_SEPARATOR, '/', $regs[1]));
+ $config->setBasePath(dirname(FULL_PATH . $filename));
- if (array_key_exists('AdminTemplatePath', $config)) {
+ if ( $config->getAdminTemplatePath() !== false ) {
// append template base folder for admin templates path of this prefix
- $module_templates = $rets[1] == 'core' ? '' : substr($rets[1], 8) . '/';
- $config['AdminTemplatePath'] = $module_templates . $config['AdminTemplatePath'];
+ $module_templates = $regs[1] == 'core' ? '' : substr($regs[1], 8) . '/';
+ $config->setAdminTemplatePath($module_templates . $config->getAdminTemplatePath());
}
- if (array_key_exists($prefix, $this->prefixFiles) && ($this->prefixFiles[$prefix] != $filename)) {
+ if ( array_key_exists($prefix, $this->prefixFiles) && ($this->prefixFiles[$prefix] != $filename) ) {
trigger_error(
'Single unit config prefix "' . $prefix . '" ' .
'is used in multiple unit config files: ' .
@@ -832,89 +862,49 @@
}
/**
- * Reads unit (specified by $prefix)
- * option specified by $option
+ * Returns unit config for given prefix
*
* @param string $prefix
- * @param string $name
- * @param mixed $default
- * @return string
+ * @return kUnitConfig
* @access public
*/
- function getUnitOption($prefix, $name, $default = false)
+ public function getUnitConfig($prefix = null)
{
- if (preg_match('/(.*)\.(.*)/', $prefix, $rets)) {
- if (!isset($this->configData[$rets[1]])) {
- $this->loadConfig($rets[1]);
- }
- $ret = isset($this->configData[$rets[1]][$name][$rets[2]]) ? $this->configData[$rets[1]][$name][$rets[2]] : false;
-// $ret = getArrayValue($this->configData, $rets[1], $name, $rets[2]);
- }
- else {
- if (!isset($this->configData[$prefix])) {
+ if ( !isset($this->configData[$prefix]) ) {
- $this->loadConfig($prefix);
- }
+ $this->loadConfig($prefix);
+ }
- $ret = isset($this->configData[$prefix][$name]) ? $this->configData[$prefix][$name] : false;
-// $ret = getArrayValue($this->configData, $prefix, $name);
- }
- return $ret === false ? $default : $ret;
- }
- /**
- * Read all unit with $prefix options
- *
- * @param string $prefix
- * @return Array
- * @access public
- */
- function getUnitOptions($prefix)
- {
- if (!isset($this->configData[$prefix])) {
- $this->loadConfig($prefix);
- }
-
return $this->configData[$prefix];
}
/**
- * Set's new unit option value
+ * Returns prefixes of unit configs, that were registered
*
- * @param string $prefix
- * @param string $name
- * @param string $value
+ * @return Array
* @access public
*/
- function setUnitOption($prefix, $name, $value)
+ public function getPrefixes()
{
- if ( preg_match('/(.*)\.(.*)/', $prefix, $rets) ) {
- if ( !isset($this->configData[$rets[1]]) ) {
- $this->loadConfig($rets[1]);
+ return array_keys($this->configData);
- }
+ }
- $this->configData[$rets[1]][$name][$rets[2]] = $value;
- }
- else {
- if ( !isset($this->configData[$prefix]) ) {
- $this->loadConfig($prefix);
- }
-
- $this->configData[$prefix][$name] = $value;
- }
- }
-
protected function getClasses($prefix)
{
- $config =& $this->configData[$prefix];
+ $config = $this->configData[$prefix];
$class_params = Array ('ItemClass', 'ListClass', 'EventHandlerClass', 'TagProcessorClass');
- $register_classes = isset($config['RegisterClasses']) ? $config['RegisterClasses'] : Array ();
+ $register_classes = $config->getRegisterClasses();
foreach ($class_params as $param_name) {
- if ( !isset($config[$param_name]) ) {
+ $value = $config->getSetting($param_name);
+
+ if ( !$value ) {
continue;
}
- $config[$param_name]['pseudo'] = $this->getPseudoByOptionName($param_name, $prefix);
- $register_classes[] = $config[$param_name];
+ $value['pseudo'] = $this->getPseudoByOptionName($param_name, $prefix);
+ $config->setSetting($param_name, $value);
+
+ $register_classes[] = $value;
}
return $register_classes;
@@ -1011,8 +1001,8 @@
$this->includeConfigFiles(MODULES_PATH); //make sure to re-read all configs
$this->AfterConfigRead();
- foreach ($this->configData as $prefix => $config_data) {
- $callback_function[0]->$callback_function[1]($prefix, $config_data, $params);
+ foreach ($this->configData as $prefix => $config) {
+ $callback_function[0]->$callback_function[1]($prefix, $config, $params);
}
}
\ No newline at end of file
Index: core/units/modules/modules_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/modules/modules_event_handler.php (revision 15682)
+++ core/units/modules/modules_event_handler.php (revision )
@@ -90,8 +90,7 @@
}
$updated = 0;
- $status_field = $this->Application->getUnitOption($event->Prefix, 'StatusField');
- $status_field = array_shift($status_field);
+ $status_field = $event->getUnitConfig()->getStatusField(true);
foreach ($ids as $id) {
$object->Load($id);
\ No newline at end of file
Index: core/units/custom_data/custom_data_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/custom_data/custom_data_event_handler.php (revision 15682)
+++ core/units/custom_data/custom_data_event_handler.php (revision )
@@ -24,26 +24,34 @@
*/
function OnDefineCustomFields($event)
{
- // 1. clone customdata table
+ // 1. clone custom data table
- $clones = $this->Application->getUnitOption('cdata', 'Clones');
-
- $data_table = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'CustomDataTableName');
-
- if ( !$data_table ) {
- $data_table = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'TableName') . 'CustomData';
- }
-
- $clones[$event->MasterEvent->Prefix.'-cdata'] = Array (
+ $this->Application->getUnitConfig('cdata')->addClones(Array (
+ $event->MasterEvent->Prefix . '-cdata' => Array (
- 'ParentPrefix' => $event->MasterEvent->Prefix,
+ 'ParentPrefix' => $event->MasterEvent->Prefix,
- 'TableName' => $data_table,
- );
- $this->Application->setUnitOption('cdata', 'Clones', $clones);
+ 'TableName' => $this->_getDataTable($event->MasterEvent),
+ )
+ ));
// 2. add custom field information to main item
$this->createCustomFields($event->MasterEvent->Prefix);
}
/**
+ * Returns custom data table name for given event
+ *
+ * @param kEvent $event
+ * @return string
+ * @access protected
+ */
+ protected function _getDataTable(kEvent $event)
+ {
+ $config = $event->getUnitConfig();
+ $ret = $config->getCustomDataTableName();
+
+ return $ret ? $ret : $config->getTableName() . 'CustomData';
+ }
+
+ /**
* Returns list of custom fields for a given $prefix
*
* @param $prefix
@@ -55,34 +63,34 @@
{
static $custom_fields = Array ();
- if (defined('IS_INSTALL') && IS_INSTALL && !$this->Application->TableFound('CustomFields', true)) {
+ if ( defined('IS_INSTALL') && IS_INSTALL && !$this->Application->TableFound('CustomFields', true) ) {
return false;
}
- if (!$prefix) {
+ if ( !$prefix ) {
// prefix not specified
return false;
}
- $item_type = $this->Application->getUnitOption($prefix, 'ItemType');
+ $item_type = $this->Application->getUnitConfig($prefix)->getItemType();
- if (!$item_type) {
+ if ( !$item_type ) {
// no main config of such type
return false;
}
$no_caching = (defined('IS_INSTALL') && IS_INSTALL) || (defined('CUSTOM_FIELD_ADDED') && CUSTOM_FIELD_ADDED);
- if (!$custom_fields || $no_caching) {
+ if ( !$custom_fields || $no_caching ) {
// query all custom fields at once -> saves 4 sqls queries
- if ($no_caching) {
+ if ( $no_caching ) {
$all_custom_fields = $this->getCustomFields();
}
else {
$cache_key = 'all_custom_fields[%CfSerial%][%ModSerial%]';
$all_custom_fields = $this->Application->getCache($cache_key, false);
- if ($all_custom_fields === false) {
+ if ( $all_custom_fields === false ) {
$this->Conn->nextQueryCachable = true;
$all_custom_fields = $this->getCustomFields();
$this->Application->setCache($cache_key, $all_custom_fields);
@@ -91,7 +99,7 @@
foreach ($all_custom_fields as $custom_field_id => $custom_field_data) {
$cf_type = $custom_field_data['Type'];
- if (!array_key_exists($cf_type, $custom_fields)) {
+ if ( !array_key_exists($cf_type, $custom_fields) ) {
$custom_fields[$cf_type] = Array ();
}
@@ -129,30 +137,37 @@
{
parent::OnAfterConfigRead($event);
- $main_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $config = $event->getUnitConfig();
+ $main_prefix = $config->getParentPrefix();
+
if ( !$main_prefix ) {
- return ;
+ return;
}
$custom_fields = $this->scanCustomFields($main_prefix);
+
if ( !$custom_fields ) {
- return ;
+ return;
}
- // 2. create fields (for customdata item)
+ // 2. create fields (for custom data item)
- $fields = $this->Application->getUnitOption($event->Prefix, 'Fields', Array ());
- $field_options = Array ('type' => 'string', 'formatter' => 'kMultiLanguage', 'db_type' => 'text', 'default' => '');
+ $field_options = Array (
+ 'type' => 'string',
+ 'formatter' => 'kMultiLanguage', 'db_type' => 'text',
+ 'default' => ''
+ );
foreach ($custom_fields as $custom_id => $custom_params) {
- if ( isset($fields['cust_' . $custom_id]) ) {
+ $field_name = 'cust_' . $custom_id;
+
+ if ( $config->getFieldByName($field_name) ) {
continue;
}
- $fields['cust_' . $custom_id] = $field_options;
- $fields['cust_' . $custom_id]['force_primary'] = !$custom_params['MultiLingual'];
- }
- $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+ $field_options['force_primary'] = !$custom_params['MultiLingual'];
+ $config->addFields($field_options, $field_name);
- }
+ }
+ }
/**
* Creates "cust_" virtual fields for main item
@@ -169,7 +184,7 @@
}
$calculated_fields = Array ();
- $virtual_fields = $this->Application->getUnitOption($prefix, 'VirtualFields', Array ());
+ $config = $this->Application->getUnitConfig($prefix);
$cf_helper = $this->Application->recallObject('InpCustomFieldsHelper');
/* @var $cf_helper InpCustomFieldsHelper */
@@ -219,24 +234,24 @@
break;
}
- if ( !isset($virtual_fields['cust_' . $custom_name]) ) {
- $virtual_fields['cust_' . $custom_name] = Array ();
- }
- $virtual_fields['cust_' . $custom_name] = kUtil::array_merge_recursive($field_options, $virtual_fields['cust_' . $custom_name]);
+ $field_name = 'cust_' . $custom_name;
+ $old_field_options = $config->getVirtualFieldByName($field_name, Array ());
+
+ $config->addVirtualFields(Array (
+ $field_name => kUtil::array_merge_recursive($field_options, $old_field_options)
+ ));
+
$custom_fields[$custom_id] = $custom_name;
}
- $config_calculated_fields = $this->Application->getUnitOption($prefix, 'CalculatedFields', Array ());
- foreach ($config_calculated_fields as $special => $special_fields) {
+ foreach ($config->getCalculatedFieldSpecials() as $special) {
if ( $special == '-virtual' ) {
continue;
}
- $config_calculated_fields[$special] = array_merge($config_calculated_fields[$special], $calculated_fields);
+ $config->addCalculatedFieldsBySpecial($special, $calculated_fields);
}
- $this->Application->setUnitOption($prefix, 'CalculatedFields', $config_calculated_fields);
- $this->Application->setUnitOption($prefix, 'CustomFields', $custom_fields);
- $this->Application->setUnitOption($prefix, 'VirtualFields', $virtual_fields);
+ $config->setCustomFields($custom_fields);
}
}
\ No newline at end of file
Index: core/units/skins/skin_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/skins/skin_eh.php (revision 15682)
+++ core/units/skins/skin_eh.php (revision )
@@ -73,8 +73,8 @@
function setPrimary($id)
{
- $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $config = $this->getUnitConfig();
+ $table_name = $config->getTableName();
$sql = 'UPDATE '.$table_name.'
SET IsPrimary = 0';
@@ -83,7 +83,7 @@
$sql = 'UPDATE '.$table_name.'
SET IsPrimary = 1
- WHERE '.$id_field.' = '.$id;
+ WHERE '. $config->getIDField() .' = '.$id;
$this->Conn->Query($sql);
}
\ No newline at end of file
Index: core/units/admin/admin_tag_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/admin/admin_tag_processor.php (revision 15690)
+++ core/units/admin/admin_tag_processor.php (revision )
@@ -396,7 +396,7 @@
$ret = '';
$special = isset($params['special']) ? $params['special'] : '';
$replace_main = isset($params['replace_m']) && $params['replace_m'];
- $skip_prefixes = isset($params['skip_prefixes']) ? explode(',', $params['skip_prefixes']) : Array();
+ $skip_prefixes = isset($params['skip_prefixes']) ? explode(',', $params['skip_prefixes']) : Array ();
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['render_as'];
@@ -404,29 +404,39 @@
foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
$prefix = $module_info['Var'];
- if ($prefix == 'm' && $replace_main) {
+ if ( $prefix == 'm' && $replace_main ) {
$prefix = 'c';
}
- if (in_array($prefix, $skip_prefixes) || !$this->Application->prefixRegistred($prefix) || !$this->Application->getUnitOption($prefix, 'CatalogItem')) {
+ if ( $this->Application->prefixRegistred($prefix) ) {
+ $config = $this->Application->getUnitConfig($prefix);
+ }
+ else {
+ $config = null;
+ }
+
+ if ( in_array($prefix, $skip_prefixes) || !is_object($config) || !$config->getCatalogItem() ) {
continue;
}
- $icon = $this->Application->getUnitOption($prefix, 'CatalogTabIcon');
+ $icon = $config->getCatalogTabIcon();
+
- if (strpos($icon, ':') !== false) {
+ if ( strpos($icon, ':') !== false ) {
list ($icon_module, $icon) = explode(':', $icon, 2);
}
else {
$icon_module = 'core';
}
- $label = $this->Application->getUnitOption($prefix, $params['title_property']);
+ $label = $config->getSetting($params['title_property']);
$block_params['title'] = $label;
$block_params['prefix'] = $prefix;
$block_params['icon_module'] = $icon_module;
$block_params['icon'] = $icon;
+
$ret .= $this->Application->ParseBlock($block_params);
}
+
return $ret;
}
@@ -438,8 +448,10 @@
*/
function CatalogTab($params)
{
- $icon = $this->Application->getUnitOption($params['prefix'], 'CatalogTabIcon');
+ $config = $this->Application->getUnitConfig($params['prefix']);
+ $icon = $config->getCatalogTabIcon();
+
- if (strpos($icon, ':') !== false) {
+ if ( strpos($icon, ':') !== false ) {
list ($icon_module, $icon) = explode(':', $icon, 2);
}
else {
@@ -450,7 +462,7 @@
$block_params['name'] = $params['render_as'];
$block_params['icon_module'] = $icon_module;
$block_params['icon'] = $icon;
- $block_params['title'] = $this->Application->getUnitOption($params['prefix'], $params['title_property']);
+ $block_params['title'] = $config->getSetting($params['title_property']);
return $this->Application->ParseBlock($block_params);
}
\ No newline at end of file
Index: core/units/helpers/priority_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/priority_helper.php (revision 15682)
+++ core/units/helpers/priority_helper.php (revision )
@@ -31,7 +31,7 @@
/* @var $object kDBItem */
$field_options = $object->GetFieldOptions('Priority');
- $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $table_name = $event->getUnitConfig()->getTableName();
$sql = 'SELECT COUNT(*)
FROM ' . $table_name . ' item_table
@@ -98,8 +98,9 @@
return Array ($id);
}
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $config = $event->getUnitConfig();
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
if ( $this->Application->IsTempMode($event->Prefix, $event->Special) ) {
$table_name = $this->Application->GetTempName($table_name, 'prefix:' . $event->Prefix);
@@ -180,8 +181,9 @@
*/
function recalculatePriorities($event, $constrain = '', $joins = '')
{
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $config = $event->getUnitConfig();
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
if ( $constrain ) {
$constrain = $this->normalizeConstrain($constrain);
\ No newline at end of file
Index: core/kernel/managers/plain_url_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/managers/plain_url_processor.php (revision 15682)
+++ core/kernel/managers/plain_url_processor.php (revision )
@@ -253,9 +253,10 @@
public function BuildModuleEnv($prefix_special, &$params, $pass_events = false)
{
list($prefix) = explode('.', $prefix_special);
- $query_vars = $this->Application->getUnitOption($prefix, 'QueryString', Array ());
- /* @var $query_vars Array */
+ $config = $this->Application->getUnitConfig($prefix);
+ $query_vars = $config->getQueryString(Array ());
+
//if pass events is off and event is not implicitly passed
if ( !$pass_events && !isset($params[$prefix_special . '_event']) ) {
$params[$prefix_special . '_event'] = ''; // remove event from url if requested
@@ -283,7 +284,7 @@
}
$ret = implode('-', $escaped);
- if ( $this->Application->getUnitOption($prefix, 'PortalStyleEnv') == true ) {
+ if ( $config->getPortalStyleEnv() == true ) {
$ret = preg_replace('/^([a-zA-Z]+)-([0-9]+)-(.*)/', '\\1\\2-\\3', $ret);
}
\ No newline at end of file
Index: core/kernel/db/cat_tag_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/db/cat_tag_processor.php (revision 15682)
+++ core/kernel/db/cat_tag_processor.php (revision )
@@ -32,38 +32,50 @@
function ItemIcon($params)
{
- $grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
- $grid = $grids[ $params['grid'] ];
+ $config = $this->getUnitConfig();
+ $grid = $config->getGridByName($params['grid']);
- if (!array_key_exists('Icons', $grid)) {
+ if ( !array_key_exists('Icons', $grid) ) {
return '';
}
$icons = $grid['Icons'];
- if (array_key_exists('name', $params)) {
+ if ( array_key_exists('name', $params) ) {
$icon_name = $params['name'];
+
return array_key_exists($icon_name, $icons) ? $icons[$icon_name] : '';
}
- $status_fields = $this->Application->getUnitOption($this->Prefix, 'StatusField');
+ $status_field = $config->getStatusField(true);
- if (!$status_fields) {
+ if ( !$status_field ) {
return $icons['default'];
}
$object = $this->getObject($params);
/* @var $object kDBList */
- $value = $object->GetDBField($status_fields[0]); // sets base status icon
+ $value = $object->GetDBField($status_field); // sets base status icon
- if ($value == STATUS_ACTIVE) {
+ if ( $value == STATUS_ACTIVE ) {
-// if( $object->HasField('IsPop') && $object->GetDBField('IsPop') ) $value = 'POP';
-// if( $object->HasField('IsHot') && $object->GetDBField('IsHot') ) $value = 'HOT';
- if( $object->HasField('IsNew') && $object->GetDBField('IsNew') ) $value = 'NEW';
-// if( $object->HasField('EditorsPick') && $object->GetDBField('EditorsPick') ) $value = 'PICK';
+ /*if ( $object->HasField('IsPop') && $object->GetDBField('IsPop') ) {
+ $value = 'POP';
- }
+ }
+ if ( $object->HasField('IsHot') && $object->GetDBField('IsHot') ) {
+ $value = 'HOT';
+ }*/
+
+ if ( $object->HasField('IsNew') && $object->GetDBField('IsNew') ) {
+ $value = 'NEW';
+ }
+
+ /*if ( $object->HasField('EditorsPick') && $object->GetDBField('EditorsPick') ) {
+ $value = 'PICK';
+ }*/
+ }
+
return array_key_exists($value, $icons) ? $icons[$value] : $icons['default'];
}
@@ -282,15 +294,13 @@
*/
function DisplayOriginal($params)
{
- // original id found & greather then zero + show original
+ // original id found & greater then zero + show original
$display_original = isset($params['display_original']) && $params['display_original'];
- $owner_field = $this->Application->getUnitOption($this->Prefix, 'OwnerField');
- if (!$owner_field) {
- $owner_field = 'CreatedById';
- }
-
$object = $this->getObject($params);
+ /* @var $object kCatDBItem */
+
+ $owner_field = $this->getUnitConfig()->getOwnerField('CreatedById');
$perm_value = $this->PermHelper->ModifyCheckPermission($object->GetDBField($owner_field), $object->GetDBField('CategoryId'), $this->Prefix);
return $display_original && ($perm_value == 1) && $this->Application->GetVar($this->Prefix.'.original_id');
@@ -315,10 +325,8 @@
$params['cat_id'] = $object->isLoaded() ? $object->GetDBField('ParentPath') : $this->Application->GetVar('m_cat_id');
// 2. owner restriction
- $owner_field = $this->Application->getUnitOption($this->Prefix, 'OwnerField');
- if (!$owner_field) {
- $owner_field = 'CreatedById';
- }
+ $owner_field = $this->getUnitConfig()->getOwnerField('CreatedById');
+
$is_owner = $object->GetDBField($owner_field) == $this->Application->RecallVar('user_id');
return $perm_helper->TagPermissionCheck($params, $is_owner);
@@ -359,10 +367,10 @@
$cache_key = $object->Prefix . '_additional_images[%' . $this->Application->incrementCacheSerial($object->Prefix, $object->GetID(), false) . '%]';
$ret = $this->Application->getCache($cache_key);
- if ($ret === false) {
+ if ( $ret === false ) {
$this->Conn->nextQueryCachable = true;
$sql = 'SELECT ImageId
- FROM ' . $this->Application->getUnitOption('img', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('img')->getTableName() . '
WHERE ResourceId = ' . $object->GetDBField('ResourceId') . ' AND DefaultImg != 1 AND Enabled = 1';
$ret = $this->Conn->GetOne($sql) ? 1 : 0;
@@ -393,13 +401,13 @@
$object = $this->getObject($params);
/* @var $object kDBList */
- if (!isset($favorite_status[$this->Special])) {
+ if ( !isset($favorite_status[$this->Special]) ) {
$resource_ids = $object->GetCol('ResourceId');
$user_id = $this->Application->RecallVar('user_id');
$sql = 'SELECT FavoriteId, ResourceId
- FROM '.$this->Application->getUnitOption('fav', 'TableName').'
+ FROM ' . $this->Application->getUnitConfig('fav')->getTableName() . '
- WHERE (PortalUserId = '.$user_id.') AND (ResourceId IN ('.implode(',', $resource_ids).'))';
+ WHERE (PortalUserId = ' . $user_id . ') AND (ResourceId IN (' . implode(',', $resource_ids) . '))';
$favorite_status[$this->Special] = $this->Conn->GetCol($sql, 'ResourceId');
}
@@ -583,25 +591,27 @@
function AdvancedSearchForm($params)
{
- $search_table = $this->Application->getUnitOption('confs', 'TableName');
+ $search_table = $this->Application->getUnitConfig('confs')->getTableName();
$module_name = $this->Application->findModule('Var', $this->Prefix, 'Name');
$sql = 'SELECT *
- FROM '.$search_table.'
+ FROM ' . $search_table . '
- WHERE (ModuleName = '.$this->Conn->qstr($module_name).') AND (AdvancedSearch = 1)
+ WHERE (ModuleName = ' . $this->Conn->qstr($module_name) . ') AND (AdvancedSearch = 1)
ORDER BY DisplayOrder';
$search_config = $this->Conn->Query($sql);
$ret = '';
+
foreach ($search_config as $record) {
$params['name'] = $this->SelectParam($params, 'and_or_render_as,and_or_block');
$params['field'] = $record['FieldName'];
$params['andor'] = $this->Application->ParseBlock($params);
- $params['name'] = $this->SelectParam($params, $record['FieldType'].'_render_as,'.$record['FieldType'].'_block');
+ $params['name'] = $this->SelectParam($params, $record['FieldType'] . '_render_as,' . $record['FieldType'] . '_block');
$params['caption'] = $this->Application->Phrase($record['DisplayName']);
$ret .= $this->Application->ParseBlock($params);
}
+
return $ret;
}
@@ -623,12 +633,14 @@
$row_data = $this->Application->getCache($cache_key);
if ( $row_data === false ) {
+ $config = $this->getUnitConfig();
+
if ( $local && ($category_id > 0) ) {
// scan only current category & it's children
list ($tree_left, $tree_right) = $this->Application->getTreeIndex($category_id);
$sql = 'SELECT MAX(item_table.Modified) AS ModDate, MAX(item_table.CreatedOn) AS NewDate
- FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . ' item_table
+ FROM ' . $config->getTableName() . ' item_table
LEFT JOIN ' . TABLE_PREFIX . 'CategoryItems ci ON (item_table.ResourceId = ci.ItemResourceId)
LEFT JOIN ' . TABLE_PREFIX . 'Categories c ON c.CategoryId = ci.CategoryId
WHERE c.TreeLeft BETWEEN ' . $tree_left . ' AND ' . $tree_right;
@@ -636,7 +648,7 @@
else {
// scan all categories in system
$sql = 'SELECT MAX(Modified) AS ModDate, MAX(CreatedOn) AS NewDate
- FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName');
+ FROM ' . $config->getTableName();
}
$this->Conn->nextQueryCachable = true;
@@ -693,10 +705,12 @@
$category_id = $this->Application->findModule('Var', $this->Prefix, 'RootCat');
}
- $id_field = $this->Application->getUnitOption('c', 'IDField');
- $title_field = $this->Application->getUnitOption('c', 'TitleField');
- $table_name = $this->Application->getUnitOption('c', 'TableName');
+ $category_config = $this->Application->getUnitConfig('c');
+ $id_field = $category_config->getIDField();
+ $title_field = $category_config->getTitleField();
+ $table_name = $category_config->getTableName();
+
$count_helper = $this->Application->recallObject('CountHelper');
/* @var $count_helper kCountHelper */
@@ -745,10 +759,11 @@
}
$category_ids = explode('|', substr($category_ids, 1, -1));
+ $category_config = $this->Application->getUnitConfig('c');
- $id_field = $this->Application->getUnitOption('c', 'IDField');
- $title_field = $this->Application->getUnitOption('c', 'TitleField');
- $table_name = $this->Application->getUnitOption('c', 'TableName');
+ $id_field = $category_config->getIDField();
+ $title_field = $category_config->getTitleField();
+ $table_name = $category_config->getTableName();
$sql = 'SELECT '.$title_field.' AS CategoryName, '.$id_field.', l' . $this->Application->GetVar('m_lang') . '_CachedNavbar AS CachedNavbar
FROM '.$table_name.'
@@ -841,7 +856,8 @@
$object = $this->getObject($params);
/* @var $object kDBList */
- $edit_template = $this->Application->getUnitOption($this->Prefix, 'AdminTemplatePath') . '/' . $this->Application->getUnitOption($this->Prefix, 'AdminTemplatePrefix') . 'edit';
+ $config = $this->getUnitConfig();
+ $edit_template = $config->getAdminTemplatePath() . '/' . $config->getAdminTemplatePrefix() . 'edit';
$url_params = Array (
'm_opener' => 'd',
@@ -870,9 +886,11 @@
{
static $languages = null;
- if (!isset($languages)) {
+ if ( !isset($languages) ) {
- $sql = 'SELECT ' . $this->Application->getUnitOption('lang', 'IDField') . '
- FROM ' . $this->Application->getUnitOption('lang', 'TableName') . '
+ $language_config = $this->Application->getUnitConfig('lang');
+
+ $sql = 'SELECT ' . $language_config->getIDField() . '
+ FROM ' . $language_config->getTableName() . '
WHERE Enabled = 1';
$languages = $this->Conn->GetCol($sql);
}
@@ -884,7 +902,8 @@
foreach ($languages as $language_id) {
$check_field = 'l' . $language_id . '_' . $field;
+
- if ($object->GetErrorMsg($check_field, false)) {
+ if ( $object->GetErrorMsg($check_field, false) ) {
return true;
}
}
@@ -900,7 +919,7 @@
*/
function AllowedCategoriesJSON($params)
{
- if ($this->Application->RecallVar('user_id') == USER_ROOT) {
+ if ( $this->Application->RecallVar('user_id') == USER_ROOT ) {
$categories = true;
}
else {
@@ -910,13 +929,10 @@
$perm_helper = $this->Application->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
- $perm_prefix = $this->Application->getUnitOption($this->Prefix, 'PermItemPrefix');
+ $perm_prefix = $this->getUnitConfig()->getPermItemPrefix();
$categories = $perm_helper->getPermissionCategories($perm_prefix . '.' . ($object->IsNewItem() ? 'ADD' : 'MODIFY'));
}
- $json_helper = $this->Application->recallObject('JSONHelper');
- /* @var $json_helper JSONHelper */
-
- return $json_helper->encode($categories);
+ return json_encode($categories);
}
}
\ No newline at end of file
Index: core/units/helpers/cat_dbitem_export_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/cat_dbitem_export_helper.php (revision 15682)
+++ core/units/helpers/cat_dbitem_export_helper.php (revision )
@@ -46,7 +46,7 @@
var $exportOptions = Array();
/**
- * Item beeing currenly exported
+ * Item being currently exported
*
* @var kCatDBItem
*/
@@ -485,7 +485,7 @@
function getExportSQL($count_only = false)
{
- if ( !$this->Application->getUnitOption($this->curItem->Prefix, 'CatalogItem') ) {
+ if ( !$this->curItem->getUnitConfig()->getCatalogItem() ) {
return $this->GetPlainExportSQL($count_only); // in case this is not a CategoryItem
}
@@ -496,7 +496,7 @@
$custom_sql = $this->getCustomSQL();
if ( $custom_sql ) {
- $custom_table = $this->Application->getUnitOption($this->curItem->Prefix . '-cdata', 'TableName');
+ $custom_table = $this->Application->getUnitConfig($this->curItem->Prefix . '-cdata')->getTableName();
$join_clauses[$custom_table . ' custom_data'] = 'custom_data.ResourceId = item_table.ResourceId';
}
@@ -551,23 +551,24 @@
{
$this->exportOptions = $this->loadOptions($event);
$this->exportFields = $this->exportOptions['ExportColumns'];
- $this->curItem = $event->getObject( Array('skip_autoload' => true) );
+ $this->curItem = $event->getObject(Array ('skip_autoload' => true));
- $this->customFields = $this->Application->getUnitOption($event->Prefix, 'CustomFields');
+ $this->customFields = $event->getUnitConfig()->getCustomFields();
$this->openFile($event);
- if ($this->exportOptions['start_from'] == 0) // first export step
- {
+ if ( $this->exportOptions['start_from'] == 0 ) {
+ // first export step
- if (!getArrayValue($this->exportOptions, 'IsBaseCategory')) {
+ if ( !getArrayValue($this->exportOptions, 'IsBaseCategory') ) {
$this->exportOptions['IsBaseCategory'] = 0;
}
- if ($this->exportOptions['IsBaseCategory'] ) {
+ if ( $this->exportOptions['IsBaseCategory'] ) {
$sql = 'SELECT ParentPath
- FROM '.TABLE_PREFIX.'Categories
+ FROM ' . TABLE_PREFIX . 'Categories
WHERE CategoryId = ' . (int)$this->Application->GetVar('m_cat_id');
$parent_path = $this->Conn->GetOne($sql);
$parent_path = explode('|', substr($parent_path, 1, -1));
+
- if ($parent_path && $parent_path[0] == $this->Application->getBaseCategory()) {
+ if ( $parent_path && $parent_path[0] == $this->Application->getBaseCategory() ) {
array_shift($parent_path);
}
@@ -575,16 +576,15 @@
}
// 1. export field titles if required
- if ($this->exportOptions['IncludeFieldTitles'])
- {
+ if ( $this->exportOptions['IncludeFieldTitles'] ) {
- $data_array = Array();
+ $data_array = Array ();
- foreach ($this->exportFields as $export_field)
- {
+ foreach ($this->exportFields as $export_field) {
$data_array = array_merge($data_array, $this->getFieldCaption($export_field));
}
$this->writeRecord($data_array);
}
+
- $this->exportOptions['total_records'] = $this->Conn->GetOne( $this->getExportSQL(true) );
+ $this->exportOptions['total_records'] = $this->Conn->GetOne($this->getExportSQL(true));
}
// 2. export data
@@ -786,7 +786,7 @@
}
$this->curItem->Clear();
$this->curItem->SetDBField('CategoryId', NULL); // since default value is import root category
- $this->customFields = $this->Application->getUnitOption($event->Prefix, 'CustomFields');
+ $this->customFields = $event->getUnitConfig()->getCustomFields();
if (isset($record_data)) {
$this->setImportData($record_data);
@@ -875,22 +875,24 @@
function processCurrentItem($event, $record_data)
{
$save_method = 'Create';
- $load_keys = Array();
+ $load_keys = Array ();
// create/update categories
$backup_category_id = $this->Application->GetVar('m_cat_id');
// perform replace duplicates code
- if ($this->exportOptions['ReplaceDuplicates']) {
+ if ( $this->exportOptions['ReplaceDuplicates'] ) {
// get replace keys first, then reset current item to empty one
$category_id = $this->getItemCategory();
+
- if ($this->exportOptions['CheckDuplicatesMethod'] == 1) {
+ if ( $this->exportOptions['CheckDuplicatesMethod'] == 1 ) {
- if ($this->curItem->GetID()) {
+ if ( $this->curItem->GetID() ) {
- $load_keys = Array($this->curItem->IDField => $this->curItem->GetID());
+ $load_keys = Array ($this->curItem->IDField => $this->curItem->GetID());
}
}
else {
$key_fields = $this->exportOptions['DuplicateCheckFields'];
+
foreach ($key_fields as $key_field) {
$load_keys[$key_field] = $this->curItem->GetDBField($key_field);
}
@@ -898,49 +900,52 @@
$this->resetImportObject($event, IMPORT_LIVE);
- if (count($load_keys)) {
+ if ( count($load_keys) ) {
$where_clause = '';
$language_id = (int)$this->Application->GetVar('m_lang');
- if (!$language_id) {
+ if ( !$language_id ) {
$language_id = 1;
}
foreach ($load_keys as $field_name => $field_value) {
- if (preg_match('/^cust_(.*)/', $field_name, $regs)) {
+ if ( preg_match('/^cust_(.*)/', $field_name, $regs) ) {
$custom_id = array_search($regs[1], $this->customFields);
- $field_name = 'l'.$language_id.'_cust_'.$custom_id;
+ $field_name = 'l' . $language_id . '_cust_' . $custom_id;
- $where_clause .= '(custom_data.`'.$field_name.'` = '.$this->Conn->qstr($field_value).') AND ';
+ $where_clause .= '(custom_data.`' . $field_name . '` = ' . $this->Conn->qstr($field_value) . ') AND ';
}
else {
- $where_clause .= '(item_table.`'.$field_name.'` = '.$this->Conn->qstr($field_value).') AND ';
+ $where_clause .= '(item_table.`' . $field_name . '` = ' . $this->Conn->qstr($field_value) . ') AND ';
}
-
}
$where_clause = substr($where_clause, 0, -5);
$item_id = $this->getFromCache('new_ids', kUtil::crc32($where_clause));
+
- if (!$item_id) {
+ if ( !$item_id ) {
- if ($this->exportOptions['CheckDuplicatesMethod'] == 2) {
+ if ( $this->exportOptions['CheckDuplicatesMethod'] == 2 ) {
// by other fields
$parent_path = $this->getParentPath($category_id);
- $where_clause = '(c.ParentPath LIKE "'.$parent_path.'%") AND '.$where_clause;
+ $where_clause = '(c.ParentPath LIKE "' . $parent_path . '%") AND ' . $where_clause;
}
- $cdata_table = $this->Application->getUnitOption($event->Prefix.'-cdata', 'TableName');
+ $cdata_table = $this->Application->getUnitConfig($event->Prefix . '-cdata')->getTableName();
+
- $sql = 'SELECT '.$this->curItem->IDField.'
+ $sql = 'SELECT ' . $this->curItem->IDField . '
- FROM '.$this->curItem->TableName.' item_table
+ FROM ' . $this->curItem->TableName . ' item_table
- LEFT JOIN '.$cdata_table.' custom_data ON custom_data.ResourceId = item_table.ResourceId
+ LEFT JOIN ' . $cdata_table . ' custom_data ON custom_data.ResourceId = item_table.ResourceId
- LEFT JOIN '.TABLE_PREFIX.'CategoryItems ci ON ci.ItemResourceId = item_table.ResourceId
+ LEFT JOIN ' . TABLE_PREFIX . 'CategoryItems ci ON ci.ItemResourceId = item_table.ResourceId
- LEFT JOIN '.TABLE_PREFIX.'Categories c ON c.CategoryId = ci.CategoryId
+ LEFT JOIN ' . TABLE_PREFIX . 'Categories c ON c.CategoryId = ci.CategoryId
- WHERE '.$where_clause;
+ WHERE ' . $where_clause;
$item_id = $this->Conn->GetOne($sql);
}
+
$save_method = $item_id && $this->curItem->Load($item_id) ? 'Update' : 'Create';
+
- if ($save_method == 'Update') {
+ if ( $save_method == 'Update' ) {
// replace id from csv file with found id (only when ID is found in cvs file)
- if (in_array($this->curItem->IDField, $this->exportFields)) {
+ if ( in_array($this->curItem->IDField, $this->exportFields) ) {
- $record_data[ array_search($this->curItem->IDField, $this->exportFields) ] = $item_id;
+ $record_data[array_search($this->curItem->IDField, $this->exportFields)] = $item_id;
}
}
}
@@ -953,27 +958,29 @@
}
// create main record
- if ($save_method == 'Create') {
+ if ( $save_method == 'Create' ) {
$this->fillRequiredFields($this->false, $this->curItem, true);
}
// $sql_start = microtime(true);
- if (!$this->curItem->$save_method()) {
+ if ( !$this->curItem->$save_method() ) {
$this->Application->SetVar('m_cat_id', $backup_category_id);
+
return false;
}
// $sql_end = microtime(true);
// $this->saveLog('SQL ['.$save_method.'] Time: '.($sql_end - $sql_start).'s');
- if ($load_keys && ($save_method == 'Create') && $this->exportOptions['ReplaceDuplicates']) {
+ if ( $load_keys && ($save_method == 'Create') && $this->exportOptions['ReplaceDuplicates'] ) {
// map new id to old id
- $this->addToCache('new_ids', kUtil::crc32($where_clause), $this->curItem->GetID() );
+ $this->addToCache('new_ids', kUtil::crc32($where_clause), $this->curItem->GetID());
}
// assign item to categories
$this->curItem->assignToCategory($category_id, false);
$this->Application->SetVar('m_cat_id', $backup_category_id);
+
return true;
}
@@ -1251,26 +1258,26 @@
*/
function prepareExportColumns($event)
{
- $object = $event->getObject( Array('skip_autoload' => true) );
+ $object = $event->getObject(Array ('skip_autoload' => true));
/* @var $object kCatDBItem */
if ( !$object->isField('ExportColumns') ) {
// import/export prefix was used (see kDBEventHandler::prepareObject) but object don't plan to be imported/exported
- return ;
+ return;
}
- $available_columns = Array();
+ $available_columns = Array ();
- if ($this->Application->getUnitOption($event->Prefix, 'CatalogItem')) {
+ if ( $event->getUnitConfig()->getCatalogItem() ) {
// category field (mixed)
$available_columns['__CATEGORY__CategoryPath'] = 'CategoryPath';
- if ($event->Special == 'import') {
+ if ( $event->Special == 'import' ) {
// category field (separated fields)
$max_level = $this->Application->ConfigValue('MaxImportCategoryLevels');
$i = 0;
- while ($i < $max_level) {
+ while ( $i < $max_level ) {
- $available_columns['__CATEGORY__Category'.($i + 1)] = 'Category'.($i + 1);
+ $available_columns['__CATEGORY__Category' . ($i + 1)] = 'Category' . ($i + 1);
$i++;
}
}
@@ -1281,11 +1288,11 @@
foreach ($fields as $field_name => $field_options) {
if ( !$object->skipField($field_name) ) {
- $available_columns[$field_name] = $field_name.( $object->isRequired($field_name) ? '*' : '');
+ $available_columns[$field_name] = $field_name . ($object->isRequired($field_name) ? '*' : '');
}
}
- $handler = $this->Application->recallObject($event->Prefix.'_EventHandler');
+ $handler = $this->Application->recallObject($event->Prefix . '_EventHandler');
/* @var $handler kDBEventHandler */
$available_columns = array_merge($available_columns, $handler->getCustomExportColumns($event));
@@ -1293,26 +1300,23 @@
// custom fields
$custom_fields = $object->getCustomFields();
- foreach ($custom_fields as $custom_id => $custom_name)
- {
+ foreach ($custom_fields as $custom_id => $custom_name) {
- $available_columns['__CUSTOM__'.$custom_name] = $custom_name;
+ $available_columns['__CUSTOM__' . $custom_name] = $custom_name;
}
// columns already in use
- $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
+ $items_info = $this->Application->GetVar($event->getPrefixSpecial(true));
- if ($items_info)
- {
+ if ( $items_info ) {
list($item_id, $field_values) = each($items_info);
$export_keys = $field_values['ExportColumns'];
- $export_keys = $export_keys ? explode('|', substr($export_keys, 1, -1) ) : Array();
+ $export_keys = $export_keys ? explode('|', substr($export_keys, 1, -1)) : Array ();
}
else {
- $export_keys = Array();
+ $export_keys = Array ();
}
- $export_columns = Array();
+ $export_columns = Array ();
- foreach ($export_keys as $field_key)
- {
+ foreach ($export_keys as $field_key) {
$field_name = $this->getExportField($field_key);
$export_columns[$field_key] = $field_name;
unset($available_columns[$field_key]);
@@ -1424,7 +1428,7 @@
*/
function getModuleName($event)
{
- $module_path = $this->Application->getUnitOption($event->Prefix, 'ModuleFolder') . '/';
+ $module_path = $event->getUnitConfig()->getModuleFolder() . '/';
$module_name = $this->Application->findModule('Path', $module_path, 'Name');
return mb_strtolower($module_name);
\ No newline at end of file
Index: core/units/custom_fields/custom_fields_tag_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/custom_fields/custom_fields_tag_processor.php (revision 15682)
+++ core/units/custom_fields/custom_fields_tag_processor.php (revision )
@@ -73,7 +73,7 @@
$this->setParamValue($params, 'value_field');
$list =& $this->GetList($params);
- $id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
+ $id_field = $this->getUnitConfig()->getIDField();
$list->Query();
$o = '';
\ No newline at end of file
Index: core/kernel/nparser/compiler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/nparser/compiler.php (revision 15682)
+++ core/kernel/nparser/compiler.php (revision )
@@ -91,7 +91,7 @@
// find Front-End templates (from enabled themes only)
$sql = 'SELECT Name
- FROM ' . $this->Application->getUnitOption('theme', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('theme')->getTableName() . '
WHERE Enabled = 1';
$themes = $this->Conn->GetCol($sql);
\ No newline at end of file
Index: core/units/page_revisions/page_revision_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/page_revisions/page_revision_eh.php (revision 15682)
+++ core/units/page_revisions/page_revision_eh.php (revision )
@@ -350,8 +350,10 @@
'CreatedById = ' . $this->Application->RecallVar('user_id'),
);
- $sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . '
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ $config = $event->getUnitConfig();
+
+ $sql = 'SELECT ' . $config->getIDField() . '
+ FROM ' . $config->getTableName() . '
WHERE (' . implode(') AND (', $where_clause) . ')';
return $this->Conn->GetOne($sql);
@@ -366,7 +368,7 @@
function getNextAvailableRevision($event)
{
$sql = 'SELECT MAX(RevisionNumber)
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ FROM ' . $event->getUnitConfig()->getTableName() . '
WHERE PageId = ' . $this->Application->GetVar('m_cat_id');
$max_revision = (int)$this->Conn->GetOne($sql);
Index: core/kernel/session/session_storage.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/session/session_storage.php (revision 15682)
+++ core/kernel/session/session_storage.php (revision )
@@ -304,7 +304,7 @@
return ;
}
- $log_table = $this->Application->getUnitOption('session-log', 'TableName');
+ $log_table = $this->Application->getUnitConfig('session-log')->getTableName();
if ($log_table) {
// mark session with proper status
\ No newline at end of file
Index: core/kernel/kbase.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/kbase.php (revision 15682)
+++ core/kernel/kbase.php (revision )
@@ -103,6 +103,17 @@
}
/**
+ * Returns unit config, used in tag
+ *
+ * @return kUnitConfig
+ * @access public
+ */
+ public function getUnitConfig()
+ {
+ return $this->Application->getUnitConfig($this->Prefix);
+ }
+
+ /**
* Creates string representation of a class (for logging)
*
* @return string
@@ -271,7 +282,7 @@
*/
public function SwitchToLive()
{
- $this->TableName = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $this->TableName = $this->getUnitConfig()->getTableName();
}
/**
@@ -281,7 +292,7 @@
*/
public function SwitchToTemp()
{
- $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $table_name = $this->getUnitConfig()->getTableName();
$this->TableName = $this->Application->GetTempName($table_name, 'prefix:' . $this->Prefix);
}
@@ -476,8 +487,9 @@
$this->populateMultiLangFields = $populate_ml_fields;
}
- $this->IDField = $this->Application->getUnitOption($this->Prefix, 'IDField');
- $this->TableName = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $config = $this->getUnitConfig();
+ $this->IDField = $config->getIDField();
+ $this->TableName = $config->getTableName();
$this->initForm($form_name);
$this->defineFields();
@@ -500,20 +512,22 @@
*/
protected function initForm($form_name = null)
{
- $forms = $this->Application->getUnitOption($this->Prefix, 'Forms', Array ());
+ $config = $this->getUnitConfig();
$this->formName = $form_name;
- $this->formConfig = isset($forms['default']) ? $forms['default'] : Array ();
+ $this->formConfig = $config->getFormByName('default', Array ());
if ( !$this->formName ) {
return ;
}
- if ( !isset($forms[$this->formName]) ) {
+ $form_data = $config->getFormByName($this->formName);
+
+ if ( !$form_data ) {
trigger_error('Form "' . $this->formName . '" isn\'t declared in "' . $this->Prefix . '" unit config.', E_USER_NOTICE);
}
else {
- $this->formConfig = kUtil::array_merge_recursive($this->formConfig, $forms[$this->formName]);
+ $this->formConfig = kUtil::array_merge_recursive($this->formConfig, $form_data);
}
}
@@ -557,7 +571,7 @@
*/
public function getFormOption($option, $default = false)
{
- $ret = $this->Application->getUnitOption($this->Prefix, $option, $default);
+ $ret = $this->getUnitConfig()->getSetting($option, $default);
if ( isset($this->formConfig[$option]) ) {
$ret = kUtil::array_merge_recursive($ret, $this->formConfig[$option]);
@@ -683,8 +697,9 @@
return;
}
- $fields = $this->Application->getUnitOption($this->Prefix, 'Fields', Array ());
- $virtual_fields = $this->Application->getUnitOption($this->Prefix, 'VirtualFields', Array ());
+ $config = $this->getUnitConfig();
+ $fields = $config->getFields(Array ());
+ $virtual_fields = $config->getVirtualFields(Array ());
foreach ($field_modifiers as $field => $field_options) {
foreach ($field_options as $option_name => $option_value) {
@@ -708,8 +723,8 @@
}
}
- $this->Application->setUnitOption($this->Prefix, 'Fields', $fields);
- $this->Application->setUnitOption($this->Prefix, 'VirtualFields', $virtual_fields);
+ $config->setFields($fields);
+ $config->setVirtualFields($virtual_fields);
}
/**
@@ -1050,33 +1065,29 @@
*/
public function getLinkedInfo($special = '', $guess_special = false)
{
- $parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix');
+ $config = $this->getUnitConfig();
+ $parent_prefix = $config->getParentPrefix();
+
- if ($parent_prefix) {
+ if ( $parent_prefix ) {
// if this is linked table, then set id from main table
$table_info = Array (
- 'TableName' => $this->Application->getUnitOption($this->Prefix,'TableName'),
- 'IdField' => $this->Application->getUnitOption($this->Prefix,'IDField'),
- 'ForeignKey' => $this->Application->getUnitOption($this->Prefix,'ForeignKey'),
- 'ParentTableKey' => $this->Application->getUnitOption($this->Prefix,'ParentTableKey'),
+ 'TableName' => $config->getTableName(),
+ 'IdField' => $config->getIDField(),
+ 'ForeignKey' => $config->getForeignKey($parent_prefix),
+ 'ParentTableKey' => $config->getParentTableKey($parent_prefix),
'ParentPrefix' => $parent_prefix
);
- if (is_array($table_info['ForeignKey'])) {
- $table_info['ForeignKey'] = getArrayValue($table_info, 'ForeignKey', $parent_prefix);
- }
-
- if (is_array($table_info['ParentTableKey'])) {
- $table_info['ParentTableKey'] = getArrayValue($table_info, 'ParentTableKey', $parent_prefix);
- }
-
- $main_object = $this->Application->recallObject($parent_prefix.'.'.$special, null, Array ('raise_warnings' => 0));
+ $main_object = $this->Application->recallObject($parent_prefix . '.' . $special, null, Array ('raise_warnings' => 0));
/* @var $main_object kDBItem */
- if (!$main_object->isLoaded() && $guess_special) {
+ if ( !$main_object->isLoaded() && $guess_special ) {
$main_object = $this->Application->recallObject($parent_prefix);
}
- return array_merge($table_info, Array('ParentId'=> $main_object->GetDBField( $table_info['ParentTableKey'] ) ) );
+ $table_info['ParentId'] = $main_object->GetDBField($table_info['ParentTableKey']);
+
+ return $table_info;
}
return false;
Index: core/units/config_search/config_search_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/config_search/config_search_event_handler.php (revision 15682)
+++ core/units/config_search/config_search_event_handler.php (revision )
@@ -27,7 +27,8 @@
{
$module = $this->Application->GetVar('module');
$main_prefix = $this->Application->findModule('Name', $module, 'Var');
- $section = $this->Application->getUnitOption($main_prefix.'.search', 'PermSection');
+
+ $section = $this->Application->getUnitConfig($main_prefix)->getPermSectionByName('search');
$event->setEventParam('PermSection', $section);
return parent::CheckPermission($event);
\ No newline at end of file
Index: core/units/helpers/site_config_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/site_config_helper.php (revision 15682)
+++ core/units/helpers/site_config_helper.php (revision )
@@ -89,13 +89,16 @@
{
extract($changes);
- $section_adjustments = $this->Application->getUnitOption('core-sections', 'SectionAdjustments', Array ());
- $title_presets = $this->Application->getUnitOption($prefix, 'TitlePresets', Array ());
- $fields = $this->Application->getUnitOption($prefix, 'Fields', Array ());
- $virtual_fields = $this->Application->getUnitOption($prefix, 'VirtualFields', Array ());
- $edit_tab_presets = $this->Application->getUnitOption($prefix, 'EditTabPresets', Array ());
- $grids = $this->Application->getUnitOption($prefix, 'Grids', Array ());
+ $config = $this->Application->getUnitConfig($prefix);
+ $core_config = $this->Application->getUnitConfig('core-sections');
+ $section_adjustments = $core_config->getSectionAdjustments(Array ());
+ $title_presets = $config->getTitlePresets(Array ());
+ $fields = $config->getFields(Array ());
+ $virtual_fields = $config->getVirtualFields(Array ());
+ $edit_tab_presets = $config->getEditTabPresets(Array ());
+ $grids = $config->getGrids(Array ());
+
$field_names = array_keys($fields);
$virtual_field_names = array_keys($virtual_fields);
@@ -173,12 +176,12 @@
}
// save changes
- $this->Application->setUnitOption('core-sections', 'SectionAdjustments', $section_adjustments);
- $this->Application->setUnitOption($prefix, 'TitlePresets', $title_presets);
- $this->Application->setUnitOption($prefix, 'Fields', $fields);
- $this->Application->setUnitOption($prefix, 'VirtualFields', $virtual_fields);
- $this->Application->setUnitOption($prefix, 'EditTabPresets', $edit_tab_presets);
- $this->Application->setUnitOption($prefix, 'Grids', $grids);
+ $core_config->setSectionAdjustments($section_adjustments);
+ $config->setTitlePresets($title_presets);
+ $config->setFields($fields);
+ $config->setVirtualFields($virtual_fields);
+ $config->setEditTabPresets($edit_tab_presets);
+ $config->setGrids($grids);
}
/**
\ No newline at end of file
Index: core/units/helpers/search_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/search_helper.php (revision 15682)
+++ core/units/helpers/search_helper.php (revision )
@@ -193,7 +193,7 @@
if (!$stop_words) {
$sql = 'SELECT StopWord
- FROM ' . $this->Application->getUnitOption('stop-word', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('stop-word')->getTableName() . '
ORDER BY LENGTH(StopWord) DESC, StopWord ASC';
$stop_words = $this->Conn->GetCol($sql);
@@ -246,8 +246,8 @@
function processAutomaticFilters($event, $search_keyword, $custom_filter)
{
$grid_name = $this->Application->GetVar('grid_name');
- $grids = $this->Application->getUnitOption($event->Prefix, 'Grids');
- $search_fields = array_keys($grids[$grid_name]['Fields']);
+ $grid = $event->getUnitConfig()->getGridByName($grid_name);
+ $search_fields = array_keys($grid['Fields']);
$search_filter = Array();
@@ -464,7 +464,8 @@
}
$object = $event->getObject(); // don't recall it each time in getCustomFilterSearchClause
- $grid_info = $this->Application->getUnitOption($event->Prefix.'.'.$grid_name, 'Grids');
+ $grid_info = $event->getUnitConfig()->getGridByName($grid_name);
+
foreach ($custom_filter as $field_name => $field_options) {
list ($filter_type, $field_options) = each($field_options);
$field_options['grid_options'] = $grid_info['Fields'][$field_name];
\ No newline at end of file
Index: core/kernel/application.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/application.php (revision 15682)
+++ core/kernel/application.php (revision )
@@ -565,9 +565,11 @@
if ( $language_info === false ) {
// cache primary language info first
- $table = $this->getUnitOption('lang', 'TableName');
- $id_field = $this->getUnitOption('lang', 'IDField');
+ $language_config = $this->getUnitConfig('lang');
+ $table = $language_config->getTableName();
+ $id_field = $language_config->getIDField();
+
$this->Conn->nextQueryCachable = true;
$sql = 'SELECT ' . $id_field . ', IF(AdminInterfaceLang, "Admin", "Front") AS LanguageKey
FROM ' . $table . '
@@ -622,8 +624,10 @@
if ( $theme_id === false ) {
$this->Conn->nextQueryCachable = true;
- $sql = 'SELECT ' . $this->getUnitOption('theme', 'IDField') . '
- FROM ' . $this->getUnitOption('theme', 'TableName') . '
+ $theme_config = $this->getUnitConfig('theme');
+
+ $sql = 'SELECT ' . $theme_config->getIDField() . '
+ FROM ' . $theme_config->getTableName() . '
WHERE (PrimaryTheme = 1) AND (Enabled = 1)';
$theme_id = $this->Conn->GetOne($sql);
@@ -654,7 +658,7 @@
$currency_id = $this->siteDomainField('PrimaryCurrencyId');
$sql = 'SELECT ISO
- FROM ' . $this->getUnitOption('curr', 'TableName') . '
+ FROM ' . $this->getUnitConfig('curr')->getTableName() . '
WHERE ' . ($currency_id > 0 ? 'CurrencyId = ' . $currency_id : 'IsPrimary = 1');
$currency_iso = $this->Conn->GetOne($sql);
}
@@ -728,6 +732,7 @@
$this->registerClass('kOpenerStack', KERNEL_PATH . '/utility/opener_stack.php');
$this->registerClass('kLogger', KERNEL_PATH . '/utility/logger.php');
+ $this->registerClass('kUnitConfig', KERNEL_PATH . '/utility/unit_config.php');
$this->registerClass('kUnitConfigReader', KERNEL_PATH . '/utility/unit_config_reader.php');
$this->registerClass('PasswordHash', KERNEL_PATH . '/utility/php_pass.php');
@@ -2308,46 +2313,19 @@
}
/**
- * Reads unit (specified by $prefix)
- * option specified by $option
+ * Returns unit config for given prefix
*
* @param string $prefix
- * @param string $option
- * @param mixed $default
- * @return string
+ * @return kUnitConfig
* @access public
*/
- public function getUnitOption($prefix, $option, $default = false)
+ public function getUnitConfig($prefix)
{
- return $this->UnitConfigReader->getUnitOption($prefix, $option, $default);
+ return $this->UnitConfigReader->getUnitConfig($prefix);
}
- /**
- * Set's new unit option value
- *
- * @param string $prefix
- * @param string $option
- * @param string $value
- * @access public
- */
- public function setUnitOption($prefix, $option, $value)
- {
- $this->UnitConfigReader->setUnitOption($prefix,$option,$value);
- }
/**
- * Read all unit with $prefix options
- *
- * @param string $prefix
- * @return Array
- * @access public
- */
- public function getUnitOptions($prefix)
- {
- return $this->UnitConfigReader->getUnitOptions($prefix);
- }
-
- /**
* Returns true if config exists and is allowed for reading
*
* @param string $prefix
@@ -2438,7 +2416,7 @@
{
// 1. get genealogical tree of $current_prefix
$prefixes = Array ($current_prefix);
- while ($parent_prefix = $this->getUnitOption($current_prefix, 'ParentPrefix')) {
+ while ($parent_prefix = $this->getUnitConfig($current_prefix)->getParentPrefix()) {
if ( !$this->prefixRegistred($parent_prefix) ) {
// stop searching, when parent prefix is not registered
break;
Index: core/units/images/image_tag_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/images/image_tag_processor.php (revision 15682)
+++ core/units/images/image_tag_processor.php (revision )
@@ -32,7 +32,7 @@
return ;
}
- $parent_prefix = $this->Application->getUnitOption($object->Prefix, 'ParentPrefix');
+ $parent_prefix = $object->getUnitConfig()->getParentPrefix();
$parent_item = $this->Application->recallObject($parent_prefix);
/* @var $parent_item kDBItem */
@@ -53,7 +53,7 @@
*/
protected function getItemTitle(&$object)
{
- $title_field = $this->Application->getUnitOption($object->Prefix, 'TitleField');
+ $title_field = $object->getUnitConfig()->getTitleField();
return $object->GetField($title_field);
}
@@ -121,8 +121,9 @@
}
}
else { // if requested image is not primary thumbnail - load it directly
- $id_field = $this->Application->getUnitOption($this->Prefix, 'ForeignKey');
- $parent_table_key = $this->Application->getUnitOption($this->Prefix, 'ParentTableKey');
+ $config = $this->getUnitConfig();
+ $id_field = $config->getForeignKey();
+ $parent_table_key = $config->getParentTableKey();
$keys[$id_field] = $parent_item->GetDBField($parent_table_key);
@@ -182,7 +183,7 @@
if (!$ret) {
return $ret;
}
- $parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix');
+ $parent_prefix = $this->getUnitConfig()->getParentPrefix();
if ($ret == 'thumbnail') {
$ret = $this->Application->ConfigValue($parent_prefix.'_ThumbnailImage'.$type);
\ No newline at end of file
Index: core/units/forms/form_submissions/form_submission_tp.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/forms/form_submissions/form_submission_tp.php (revision 15682)
+++ core/units/forms/form_submissions/form_submission_tp.php (revision )
@@ -51,10 +51,10 @@
$formatted = !(array_key_exists('db', $params) && $params['db']);
$format = $formatted ? (array_key_exists('format', $params) ? $params['format'] : null) : null;
- if (array_key_exists('role', $params)) {
+ if ( array_key_exists('role', $params) ) {
return $form_submission_helper->getFieldByRole($object, $params['role'], $formatted, $format);
}
- return $form_submission_helper->getFieldByName($params['name'], $formatted, $format);
+ return $form_submission_helper->getFieldByName($object, $params['name'], $formatted, $format);
}
}
Index: core/units/categories/categories_item.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/categories/categories_item.php (revision 15682)
+++ core/units/categories/categories_item.php (revision )
@@ -43,7 +43,7 @@
}
$sql = 'SELECT ' . implode(', ', $select_fields) . '
- FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . '
+ FROM ' . $this->getUnitConfig()->getTableName() . '
WHERE CategoryId = ' . $parent_id;
$parent_cache[$parent_id] = $this->Conn->GetRow($sql);
}
@@ -221,7 +221,7 @@
public function IsNewItem()
{
if ( $this->IsRoot() && $this->Prefix == 'c' ) {
- $title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField');
+ $title_field = $this->getUnitConfig()->getTitleField();
$category_name = $this->Application->Phrase(($this->Application->isAdmin ? 'la_' : 'lu_') . 'rootcategory_name');
$this->SetDBField($title_field, $category_name);
@@ -243,7 +243,7 @@
public function NameCopy($master=null, $foreign_key=null, $title_field=null, $format='Copy %1$s of %2$s')
{
if (!isset($title_field)) {
- $title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField');
+ $title_field = $this->getUnitConfig()->getTitleField();
if (!$title_field || isset($this->CalculatedFields[$title_field]) ) return;
}
\ No newline at end of file
Index: core/units/helpers/controls/minput_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/controls/minput_helper.php (revision 15682)
+++ core/units/helpers/controls/minput_helper.php (revision )
@@ -26,7 +26,7 @@
*/
protected function getTable($prefix, $temp = false)
{
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
+ $table_name = $this->Application->getUnitConfig($prefix)->getTableName();
return $temp ? $this->Application->GetTempName($table_name, 'prefix:' . $prefix) : $table_name;
}
@@ -146,7 +146,7 @@
$sub_item = $this->Application->recallObject($sub_prefix, null, Array('skip_autoload' => true));
/* @var $sub_item kDBItem */
- $foreign_key = $this->Application->getUnitOption($sub_prefix, 'ForeignKey');
+ $foreign_key = $this->Application->getUnitConfig($sub_prefix)->getForeignKey();
$sql = 'SELECT *
FROM '.$this->getTable($sub_prefix, $object->IsTempTable()).'
@@ -196,7 +196,7 @@
/* @var $object kDBItem */
$sub_table = $object->TableName;
- $foreign_key = $this->Application->getUnitOption($sub_event->Prefix, 'ForeignKey');
+ $foreign_key = $sub_event->getUnitConfig()->getForeignKey();
$sql = 'DELETE FROM '.$sub_table.'
WHERE '.$foreign_key.' = '.$main_object->GetID();
\ No newline at end of file
Index: core/units/logs/session_logs/session_log_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/logs/session_logs/session_log_eh.php (revision 15682)
+++ core/units/logs/session_logs/session_log_eh.php (revision )
@@ -87,11 +87,11 @@
if ( $event->Name == 'OnMassDelete' && $type == 'before' ) {
$ids = $event->getEventParam('ids');
if ( $ids ) {
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $config = $event->getUnitConfig();
+ $id_field = $config->getIDField();
$sql = 'SELECT ' . $id_field . '
- FROM ' . $table_name . '
+ FROM ' . $config->getTableName() . '
WHERE ' . $id_field . ' IN (' . implode(',', $ids) . ') AND Status <> ' . SESSION_LOG_ACTIVE;
$allowed_ids = $this->Conn->GetCol($sql);
@@ -114,8 +114,10 @@
$object = $event->getObject();
/* @var $object kDBItem */
- $sql = 'SELECT ' . $this->Application->getUnitOption('change-log', 'IDField') . '
- FROM ' . $this->Application->getUnitOption('change-log', 'TableName') . '
+ $change_logs_config = $this->Application->getUnitConfig('change-log');
+
+ $sql = 'SELECT ' . $change_logs_config->getIDField() . '
+ FROM ' . $change_logs_config->getTableName() . '
WHERE SessionLogId = ' . $object->GetID();
$related_ids = $this->Conn->GetCol($sql);
\ No newline at end of file
Index: core/units/stylesheets/stylesheets_item.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/stylesheets/stylesheets_item.php (revision 15682)
+++ core/units/stylesheets/stylesheets_item.php (revision )
@@ -22,7 +22,7 @@
$selector_item = $this->Application->recallObject('selectors.item', 'selectors', Array('live_table'=>true, 'skip_autoload' => true) );
/* @var $selector_item SelectorsItem */
- $parent_field = $this->Application->getUnitOption($selector_item->Prefix, 'ForeignKey');
+ $parent_field = $selector_item->getUnitConfig()->getForeignKey();
$sql_template = 'SELECT '.$selector_item->IDField.' FROM '.$selector_item->TableName.' WHERE '.$parent_field.' = %s ORDER BY SelectorName ASC';
\ No newline at end of file
Index: core/units/config_search/config_search_tag_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/config_search/config_search_tag_processor.php (revision 15682)
+++ core/units/config_search/config_search_tag_processor.php (revision )
@@ -26,7 +26,7 @@
function PrintList($params)
{
$list =& $this->GetList($params);
- $id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
+ $id_field = $this->getUnitConfig()->getIDField();
$list->Query();
$o = '';
\ No newline at end of file
Index: core/kernel/db/dbitem.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/db/dbitem.php (revision 15682)
+++ core/kernel/db/dbitem.php (revision )
@@ -90,7 +90,7 @@
public function initValidator()
{
if ( !is_object($this->validator) ) {
- $validator_class = $this->Application->getUnitOption($this->Prefix, 'ValidatorClass', 'kValidator');
+ $validator_class = $this->getUnitConfig()->getValidatorClass('kValidator');
$this->validator = $this->Application->makeClass($validator_class);
}
@@ -397,7 +397,7 @@
if ( isset($id_field_name) ) {
// restore original IDField from unit config
- $this->IDField = $this->Application->getUnitOption($this->Prefix, 'IDField');
+ $this->IDField = $this->getUnitConfig()->getIDField();
}
if (($id === false) || !$keys_sql) {
@@ -1012,45 +1012,52 @@
*/
public function NameCopy($master=null, $foreign_key=null, $title_field=null, $format='Copy %1$s of %2$s')
{
- if (!isset($title_field)) {
+ if ( !isset($title_field) ) {
- $title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField');
- if (!$title_field || isset($this->CalculatedFields[$title_field]) ) return;
+ $title_field = $this->getUnitConfig()->getTitleField();
+
+ if ( !$title_field || isset($this->CalculatedFields[$title_field]) ) {
+ return;
- }
+ }
+ }
- $new_name = $this->GetDBField($title_field);
$original_checked = false;
+ $new_name = $this->GetDBField($title_field);
+
do {
- if ( preg_match('/'.sprintf($format, '([0-9]*) *', '(.*)').'/', $new_name, $regs) ) {
+ if ( preg_match('/' . sprintf($format, '([0-9]*) *', '(.*)') . '/', $new_name, $regs) ) {
- $new_name = sprintf($format, ($regs[1]+1), $regs[2]);
+ $new_name = sprintf($format, ($regs[1] + 1), $regs[2]);
}
- elseif ($original_checked) {
+ elseif ( $original_checked ) {
$new_name = sprintf($format, '', $new_name);
}
// if we are cloning in temp table this will look for names in temp table,
// since object' TableName contains correct TableName (for temp also!)
// if we are cloning live - look in live
- $query = 'SELECT '.$title_field.' FROM '.$this->TableName.'
+ $sql = 'SELECT ' . $title_field . '
+ FROM ' . $this->TableName . '
- WHERE '.$title_field.' = '.$this->Conn->qstr($new_name);
+ WHERE ' . $title_field . ' = ' . $this->Conn->qstr($new_name);
$foreign_key_field = getArrayValue($master, 'ForeignKey');
- $foreign_key_field = is_array($foreign_key_field) ? $foreign_key_field[ $master['ParentPrefix'] ] : $foreign_key_field;
+ $foreign_key_field = is_array($foreign_key_field) ? $foreign_key_field[$master['ParentPrefix']] : $foreign_key_field;
- if ($foreign_key_field && isset($foreign_key)) {
+ if ( $foreign_key_field && isset($foreign_key) ) {
- $query .= ' AND '.$foreign_key_field.' = '.$foreign_key;
+ $sql .= ' AND ' . $foreign_key_field . ' = ' . $foreign_key;
}
- $res = $this->Conn->GetOne($query);
+ $res = $this->Conn->GetOne($sql);
- /*// if not found in live table, check in temp table if applicable
- if ($res === false && $object->Special == 'temp') {
- $query = 'SELECT '.$name_field.' FROM '.$this->GetTempName($master['TableName']).'
+ // if not found in live table, check in temp table if applicable
+ /*if ( $res === false && $this->Special == 'temp' ) {
+ $sql = 'SELECT ' . $name_field . '
+ FROM ' . $this->Application->GetTempName($master['TableName']) . '
- WHERE '.$name_field.' = '.$this->Conn->qstr($new_name);
+ WHERE ' . $name_field . ' = ' . $this->Conn->qstr($new_name);
- $res = $this->Conn->GetOne($query);
+ $res = $this->Conn->GetOne($sql);
}*/
$original_checked = true;
- } while ($res !== false);
+ } while ( $res !== false );
+
$this->SetDBField($title_field, $new_name);
}
@@ -1087,43 +1094,47 @@
*/
public function setTempID()
{
- $new_id = (int)$this->Conn->GetOne('SELECT MIN('.$this->IDField.') FROM '.$this->TableName);
+ $new_id = (int)$this->Conn->GetOne('SELECT MIN(' . $this->IDField . ') FROM ' . $this->TableName);
- if($new_id > 0) $new_id = 0;
+
+ if ( $new_id > 0 ) {
+ $new_id = 0;
+ }
+
--$new_id;
- $this->Conn->Query('UPDATE '.$this->TableName.' SET `'.$this->IDField.'` = '.$new_id.' WHERE `'.$this->IDField.'` = '.$this->GetID());
+ $this->Conn->Query('UPDATE ' . $this->TableName . ' SET `' . $this->IDField . '` = ' . $new_id . ' WHERE `' . $this->IDField . '` = ' . $this->GetID());
- if ($this->ShouldLogChanges(true)) {
+ if ( $this->ShouldLogChanges(true) ) {
// Updating TempId in ChangesLog, if changes are disabled
$ses_var_name = $this->Application->GetTopmostPrefix($this->Prefix) . '_changes_' . $this->Application->GetTopmostWid($this->Prefix);
$changes = $this->Application->RecallVar($ses_var_name);
$changes = $changes ? unserialize($changes) : Array ();
- if ($changes) {
+ if ( $changes ) {
foreach ($changes as $key => $rec) {
- if ($rec['Prefix'] == $this->Prefix && $rec['ItemId'] == $this->GetID()) {
+ if ( $rec['Prefix'] == $this->Prefix && $rec['ItemId'] == $this->GetID() ) {
// change log for record, that's ID was just updated -> update in change log record too
$changes[$key]['ItemId'] = $new_id;
}
- if ($rec['MasterPrefix'] == $this->Prefix && $rec['MasterId'] == $this->GetID()) {
+ if ( $rec['MasterPrefix'] == $this->Prefix && $rec['MasterId'] == $this->GetID() ) {
// master item id was changed
$changes[$key]['MasterId'] = $new_id;
}
- if (in_array($this->Prefix, $rec['ParentPrefix']) && $rec['ParentId'][$this->Prefix] == $this->GetID()) {
+ if ( in_array($this->Prefix, $rec['ParentPrefix']) && $rec['ParentId'][$this->Prefix] == $this->GetID() ) {
// change log record of given item's sub item -> update changed id's in dependent fields
$changes[$key]['ParentId'][$this->Prefix] = $new_id;
- if (array_key_exists('DependentFields', $rec)) {
+ if ( array_key_exists('DependentFields', $rec) ) {
// these are fields from table of $rec['Prefix'] table!
- // when one of dependent fields goes into idfield of it's parent item, that was changed
+ // when one of dependent fields goes into id field of it's parent item, that was changed
- $parent_table_key = $this->Application->getUnitOption($rec['Prefix'], 'ParentTableKey');
- $parent_table_key = is_array($parent_table_key) ? $parent_table_key[$this->Prefix] : $parent_table_key;
+ $config = $this->Application->getUnitConfig($rec['Prefix']);
+ $parent_table_key = $config->getParentTableKey($this->Prefix);
+
- if ($parent_table_key == $this->IDField) {
+ if ( $parent_table_key == $this->IDField ) {
- $foreign_key = $this->Application->getUnitOption($rec['Prefix'], 'ForeignKey');
- $foreign_key = is_array($foreign_key) ? $foreign_key[$this->Prefix] : $foreign_key;
+ $foreign_key = $config->getForeignKey($this->Prefix);
$changes[$key]['DependentFields'][$foreign_key] = $new_id;
}
@@ -1170,12 +1181,14 @@
*/
public function ShouldLogChanges($log_changes = null)
{
+ $config = $this->getUnitConfig();
+
- if (!isset($log_changes)) {
+ if ( !isset($log_changes) ) {
// specific logging mode no forced -> use global logging settings
- $log_changes = $this->Application->getUnitOption($this->Prefix, 'LogChanges') || $this->Application->ConfigValue('UseChangeLog');
+ $log_changes = $config->getLogChanges() || $this->Application->ConfigValue('UseChangeLog');
}
- return $log_changes && !$this->Application->getUnitOption($this->Prefix, 'ForceDontLogChanges');
+ return $log_changes && !$config->getForceDontLogChanges();
}
protected function LogChanges($main_prefix, $mode)
@@ -1205,7 +1218,8 @@
else {
// sub item
// collect foreign key values (for serial reset)
- $foreign_keys = $this->Application->getUnitOption($this->Prefix, 'ForeignKey', Array ());
+ $config = $this->getUnitConfig();
+ $foreign_keys = $config->getForeignKey(null, Array ());
$dependent_fields = $fields_hash['ParentId'] = $fields_hash['ParentPrefix'] = Array ();
/* @var $foreign_keys Array */
@@ -1218,7 +1232,7 @@
}
else {
$dependent_fields[$foreign_keys] = $this->GetDBField($foreign_keys);
- $fields_hash['ParentPrefix'] = Array ( $this->Application->getUnitOption($this->Prefix, 'ParentPrefix') );
+ $fields_hash['ParentPrefix'] = Array ( $config->getParentPrefix() );
$fields_hash['ParentId'][ $fields_hash['ParentPrefix'][0] ] = $this->getParentId('auto');
}
@@ -1272,51 +1286,51 @@
{
$current_id = $this->GetID();
$current_prefix = $this->Prefix;
+ $current_config = $this->Application->getUnitConfig($current_prefix);
- if ($parent_prefix == 'auto') {
+ if ( $parent_prefix == 'auto' ) {
- $parent_prefix = $this->Application->getUnitOption($current_prefix, 'ParentPrefix');
+ $parent_prefix = $current_config->getParentPrefix();
}
- if (!$parent_prefix) {
+ if ( !$parent_prefix ) {
return $current_id;
}
do {
// field in this table
- $foreign_key = $this->Application->getUnitOption($current_prefix, 'ForeignKey');
- $foreign_key = is_array($foreign_key) ? $foreign_key[$parent_prefix] : $foreign_key;
+ $foreign_key = $current_config->getForeignKey($parent_prefix);
// get foreign key value for $current_prefix
- if ($current_prefix == $this->Prefix) {
+ if ( $current_prefix == $this->Prefix ) {
$foreign_key_value = $this->GetDBField($foreign_key);
}
else {
- $id_field = $this->Application->getUnitOption($current_prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($current_prefix, 'TableName');
+ $table_name = $current_config->getTableName();
- if ($this->IsTempTable()) {
+ if ( $this->IsTempTable() ) {
$table_name = $this->Application->GetTempName($table_name, 'prefix:' . $current_prefix);
}
$sql = 'SELECT ' . $foreign_key . '
FROM ' . $table_name . '
- WHERE ' . $id_field . ' = ' . $current_id;
+ WHERE ' . $current_config->getIDField() . ' = ' . $current_id;
$foreign_key_value = $this->Conn->GetOne($sql);
}
// field in parent table
- $parent_table_key = $this->Application->getUnitOption($current_prefix, 'ParentTableKey');
- $parent_table_key = is_array($parent_table_key) ? $parent_table_key[$parent_prefix] : $parent_table_key;
+ $parent_table_key = $current_config->getParentTableKey($parent_prefix);
- $parent_id_field = $this->Application->getUnitOption($parent_prefix, 'IDField');
- $parent_table_name = $this->Application->getUnitOption($parent_prefix, 'TableName');
+ $parent_config = $this->Application->getUnitConfig($parent_prefix);
+ $parent_id_field = $parent_config->getIDField();
+ $parent_table_name = $parent_config->getTableName();
+
- if ($this->IsTempTable()) {
+ if ( $this->IsTempTable() ) {
$parent_table_name = $this->Application->GetTempName($parent_table_name, 'prefix:' . $current_prefix);
}
- if ($parent_id_field == $parent_table_key) {
+ if ( $parent_id_field == $parent_table_key ) {
- // sub-item is related by parent item idfield
+ // sub-item is related by parent item id field
$current_id = $foreign_key_value;
}
else {
@@ -1328,11 +1342,12 @@
}
$current_prefix = $parent_prefix;
+ $current_config = $this->Application->getUnitConfig($current_prefix);
- if (!$top_most) {
+ if ( !$top_most ) {
break;
}
- } while ( $parent_prefix = $this->Application->getUnitOption($current_prefix, 'ParentPrefix') );
+ } while ( $parent_prefix = $current_config->getParentPrefix() );
return $current_id;
}
@@ -1344,10 +1359,11 @@
*/
public function GetTitleField()
{
- $title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField');
+ $title_field = $this->getUnitConfig()->getTitleField();
- if ($title_field) {
+ if ( $title_field ) {
$value = $this->GetField($title_field);
+
return $value ? Array ($title_field => $value) : Array ();
}
@@ -1544,18 +1560,4 @@
{
$this->Loaded = $is_loaded;
}
-
- /**
- * Returns item's first status field
- *
- * @return string
- * @access public
- */
- public function getStatusField()
- {
- $status_fields = $this->Application->getUnitOption($this->Prefix, 'StatusField');
-
- return array_shift($status_fields);
- }
-
}
\ No newline at end of file
Index: core/kernel/event_manager.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/event_manager.php (revision 15682)
+++ core/kernel/event_manager.php (revision )
@@ -290,7 +290,7 @@
if ( $event_mapping === false ) {
$this->Conn->nextQueryCachable = true;
$sql = 'SELECT TemplateId, TemplateName, Type, BindToSystemEvent
- FROM ' . $this->Application->getUnitOption('email-template', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('email-template')->getTableName() . '
WHERE BindToSystemEvent <> ""';
$event_mapping = $this->Conn->Query($sql, 'BindToSystemEvent');
@@ -336,7 +336,7 @@
if ( $object->isLoaded() ) {
$item_id = $object->GetID();
- $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $parent_prefix = $event->getUnitConfig()->getParentPrefix();
if ( $parent_prefix ) {
$parent_item_id = $object->getParentId($parent_prefix);
\ No newline at end of file
Index: core/units/helpers/cron_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/cron_helper.php (revision 15682)
+++ core/units/helpers/cron_helper.php (revision )
@@ -202,26 +202,28 @@
*/
public function initUnit($prefix, $field_prefix = '')
{
- $virtual_fields = $this->Application->getUnitOption($prefix, 'VirtualFields', Array ());
+ $config = $this->Application->getUnitConfig($prefix);
- $virtual_fields[$field_prefix . 'CommonHints'] = Array (
+ $config->addVirtualFields(Array (
+ $field_prefix . 'CommonHints' => Array (
- 'type' => 'string',
- 'formatter' => 'kOptionsFormatter', 'options' => $this->getOptions(self::COMMON),
- 'default' => ''
+ 'type' => 'string',
+ 'formatter' => 'kOptionsFormatter', 'options' => $this->getOptions(self::COMMON),
+ 'default' => ''
- );
+ ),
+ ));
foreach ($this->fieldTypes as $field_type) {
$field_name = $this->_getFieldNameByType($field_type, $field_prefix);
- $virtual_fields[$field_name] = Array ('type' => 'string', 'max_len' => 30, 'default' => '*');
- $virtual_fields[$field_name . 'Hints'] = Array (
+ $config->addVirtualFields(Array (
+ $field_name => Array ('type' => 'string', 'max_len' => 30, 'default' => '*'),
+ $field_name . 'Hints' => Array (
- 'type' => 'string',
- 'formatter' => 'kOptionsFormatter', 'options' => $this->getOptions($field_type),
- 'default' => ''
+ 'type' => 'string',
+ 'formatter' => 'kOptionsFormatter', 'options' => $this->getOptions($field_type),
+ 'default' => ''
- );
+ ),
+ ));
}
-
- $this->Application->setUnitOption($prefix, 'VirtualFields', $virtual_fields);
}
/**
\ No newline at end of file
Index: core/units/reviews/reviews_tag_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/reviews/reviews_tag_processor.php (revision 15682)
+++ core/units/reviews/reviews_tag_processor.php (revision )
@@ -28,8 +28,10 @@
/* @var $object kDBList */
$item_prefix = $this->Application->findModule('Name', $object->GetDBField('Module'), 'Var');
- $edit_template = $this->Application->getUnitOption($item_prefix, 'AdminTemplatePath') . '/' . $this->Application->getUnitOption($item_prefix, 'AdminTemplatePrefix') . 'edit';
+ $item_config = $this->Application->getUnitConfig($item_prefix);
+ $edit_template = $item_config->getAdminTemplatePath() . '/' . $item_config->getAdminTemplatePrefix() . 'edit';
+
$url_params = Array (
'm_opener' => 'd',
$item_prefix.'_mode' => 't',
@@ -48,7 +50,8 @@
$object = $this->getObject($params);
/* @var $object kDBItem */
- $parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix');
+ $parent_prefix = $this->getUnitConfig()->getParentPrefix();
+
$params['events[' . $parent_prefix . ']'] = 'OnReviewHelpful';
$params['review_id'] = $object->GetID();
@@ -68,7 +71,7 @@
$object = $this->getObject($params);
/* @var $object kDBItem */
- $parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix');
+ $parent_prefix = $this->getUnitConfig()->getParentPrefix();
$main_object = $this->Application->recallObject($parent_prefix);
/* @var $main_object kCatDBItem */
@@ -136,7 +139,8 @@
function AlreadyReviewed($params)
{
- $parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix');
+ $parent_prefix = $this->getUnitConfig()->getParentPrefix();
+
$main_object = $this->Application->recallObject($parent_prefix);
/* @var $main_object kCatDBItem */
\ No newline at end of file
Index: core/units/configuration/configuration_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/configuration/configuration_event_handler.php (revision 15682)
+++ core/units/configuration/configuration_event_handler.php (revision )
@@ -247,7 +247,7 @@
$field_values = $this->Application->GetVar($event->getPrefixSpecial(true));
$sql = 'SELECT VariableId
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ FROM ' . $event->getUnitConfig()->getTableName() . '
WHERE VariableName = ' . $this->Conn->qstr($state_country_hash[$variable_name]);
$country_variable_id = $this->Conn->GetOne($sql);
@@ -255,7 +255,7 @@
}
/**
- * Does custom password setting processong
+ * Does custom password setting processing
*
* @param kEvent $event
* @return void
@@ -502,7 +502,7 @@
}
$sql = 'SELECT DISTINCT ' . $field . ', ModuleOwner
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ FROM ' . $event->getUnitConfig()->getTableName() . '
WHERE ' . $field . ' LIKE ' . $this->Conn->qstr('%' . $cur_value . '%') . '
ORDER BY ' . $field . ' ASC';
$raw_suggestions = $this->Conn->Query($sql);
@@ -560,8 +560,10 @@
}
}
- $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+ $config = $event->getUnitConfig();
+
+ $fields = $config->getFields();
$fields['ModuleOwner']['options'] = $options;
- $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+ $config->setFields($fields);
}
}
\ No newline at end of file
Index: core/units/visits/visits_tag_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/visits/visits_tag_processor.php (revision 15682)
+++ core/units/visits/visits_tag_processor.php (revision )
@@ -73,9 +73,11 @@
$date_limit = str_replace($list->TableName, 'vis', $this->getDateLimitClause('VisitDate') );
- $affil_table = $this->Application->getUnitOption('affil', 'TableName');
- $affil_idfield = $this->Application->getUnitOption('affil', 'IDField');
- $sql = 'SELECT '.$affil_idfield.' FROM '.$affil_table.' WHERE PortalUserId = '.$this->Application->RecallVar('user_id');
+ $affiliates_config = $this->Application->getUnitConfig('affil');
+
+ $sql = 'SELECT '. $affiliates_config->getIDField() .'
+ FROM '. $affiliates_config->getTableName() .'
+ WHERE PortalUserId = '.$this->Application->RecallVar('user_id');
$affiliate_id = $this->Conn->GetOne($sql);
$sql = 'SELECT COUNT(ord.OrderId) AS OrderCount
\ No newline at end of file
Index: core/units/promo_blocks/promo_block_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/promo_blocks/promo_block_eh.php (revision 15682)
+++ core/units/promo_blocks/promo_block_eh.php (revision )
@@ -322,7 +322,8 @@
$category_helper = $this->Application->recallObject('CategoryHelper');
/* @var $category_helper CategoryHelper */
- $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+ $config = $event->getUnitConfig();
+ $fields = $config->getFields();
$fields['CategoryId']['options'] = $category_helper->getStructureTreeAsOptions();
@@ -346,6 +347,6 @@
$fields['l' . $this->Application->GetDefaultLanguageId() . '_Image']['required'] = 1;
- $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+ $config->setFields($fields);
}
}
Index: core/units/categories/categories_tag_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/categories/categories_tag_processor.php (revision 15682)
+++ core/units/categories/categories_tag_processor.php (revision )
@@ -75,46 +75,47 @@
function ItemIcon($params)
{
- $grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
- $grid = $grids[ $params['grid'] ];
+ $grid = $this->getUnitConfig()->getGridByName($params['grid']);
- if (!array_key_exists('Icons', $grid)) {
+ if ( !array_key_exists('Icons', $grid) ) {
return '';
}
$icons = $grid['Icons'];
- $icon_prefix = array_key_exists('icon_prefix', $params)? $params['icon_prefix'] : 'icon16_';
+ $icon_prefix = array_key_exists('icon_prefix', $params) ? $params['icon_prefix'] : 'icon16_';
- if (array_key_exists('name', $params)) {
+ if ( array_key_exists('name', $params) ) {
$icon_name = $params['name'];
+
return array_key_exists($icon_name, $icons) ? $icons[$icon_name] : '';
}
$object = $this->getObject($params);
/* @var $object kDBList */
- if ($object->GetDBField('ThemeId') > 0) {
+ if ( $object->GetDBField('ThemeId') > 0 ) {
- if (!$object->GetDBField('IsMenu')) {
+ if ( !$object->GetDBField('IsMenu') ) {
return $icon_prefix . 'section_menuhidden_system.png';
}
+
return $icon_prefix . 'section_system.png';
}
$status = $object->GetDBField('Status');
- if ($status == STATUS_DISABLED) {
+ if ( $status == STATUS_DISABLED ) {
return $icon_prefix . 'section_disabled.png';
}
- if (!$object->GetDBField('IsMenu')) {
+ if ( !$object->GetDBField('IsMenu') ) {
return $icon_prefix . 'section_menuhidden.png';
}
- if ($status == STATUS_PENDING) {
+ if ( $status == STATUS_PENDING ) {
return $icon_prefix . 'section_pending.png';
}
- if ($object->GetDBField('IsNew') && ($icon_prefix == 'icon16_')) {
+ if ( $object->GetDBField('IsNew') && ($icon_prefix == 'icon16_') ) {
return $icon_prefix . 'section_new.png'; // show gris icon only in grids
}
@@ -126,7 +127,7 @@
$object = $this->getObject($params);
/* @var $object kDBItem */
- $ci_table = $this->Application->getUnitOption('ci', 'TableName');
+ $ci_table = $this->Application->getUnitConfig('ci')->getTableName();
$module_prefixes = implode(',', $this->Conn->qstrArray($this->_getModulePrefixes()));
@@ -265,8 +266,9 @@
$cache = $this->Application->getCache($cache_key);
if ($cache === false) {
- $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $config = $this->getUnitConfig();
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
// get symlinked categories, that are not yet deleted
$this->Conn->nextQueryCachable = true;
@@ -497,9 +499,11 @@
$category_id = $this->Application->GetVar('m_cat_id');
if ($category_id != $parent_id) {
+ $config = $this->getUnitConfig();
+
$sql = 'SELECT ParentId
- FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . '
- WHERE ' . $this->Application->getUnitOption($this->Prefix, 'IDField') . ' = ' . $category_id;
+ FROM ' . $config->getTableName() . '
+ WHERE ' . $config->getIDField() . ' = ' . $category_id;
$parent_id = $this->Conn->GetOne($sql);
}
@@ -901,19 +905,19 @@
$sym_category_id = $object->GetDBField('SymLinkCategoryId');
- if (is_null($sym_category_id))
- {
+ if ( is_null($sym_category_id) ) {
return false;
}
- $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $config = $this->getUnitConfig();
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
- $sql = 'SELECT '.$id_field.'
+ $sql = 'SELECT ' . $id_field . '
- FROM '.$table_name.'
+ FROM ' . $table_name . '
- WHERE '.$id_field.' = '.$sym_category_id;
+ WHERE ' . $id_field . ' = ' . $sym_category_id;
- return $this->Conn->GetOne($sql)? true : false;
+ return $this->Conn->GetOne($sql) ? true : false;
}
/**
@@ -958,7 +962,8 @@
*/
protected function SpellingSuggestions($params)
{
- $keywords = htmlspecialchars_decode( trim($this->Application->GetVar('keywords')) );
+ $keywords = htmlspecialchars_decode(trim($this->Application->GetVar('keywords')));
+
if ( !$keywords ) {
return '';
}
@@ -971,7 +976,7 @@
return $suggestion;
}
- $table_name = $this->Application->getUnitOption('spelling-dictionary', 'TableName');
+ $table_name = $this->Application->getUnitConfig('spelling-dictionary')->getTableName();
// 2. search suggestion in database
$this->Conn->nextQueryCachable = true;
@@ -993,7 +998,7 @@
$curl_helper = $this->Application->recallObject('CurlHelper');
/* @var $curl_helper kCurlHelper */
- $xml_data = $curl_helper->Send( $url . urlencode($keywords) );
+ $xml_data = $curl_helper->Send($url . urlencode($keywords));
$xml_helper = $this->Application->recallObject('kXMLHelper');
/* @var $xml_helper kXMLHelper */
@@ -1991,25 +1996,24 @@
$category_ids = explode('|', substr($object->GetDBField('ParentPath'), 1, -1));
- $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
-
+ $config = $this->getUnitConfig();
$language = (int)$this->Application->GetVar('m_lang');
- if (!$language) {
+ if ( !$language ) {
$language = 1;
}
- $sql = 'SELECT l'.$language.'_Name AS Name, NamedParentPath
+ $sql = 'SELECT l' . $language . '_Name AS Name, NamedParentPath
- FROM '.$table_name.'
- WHERE '.$id_field.' IN ('.implode(',', $category_ids).')';
+ FROM ' . $config->getTableName() . '
+ WHERE ' . $config->getIDField() . ' IN (' . implode(',', $category_ids) . ')';
$categories_data = $this->Conn->Query($sql);
$ret = '';
foreach ($categories_data as $index => $category_data) {
- if ($category_data['Name'] == 'Content') {
+ if ( $category_data['Name'] == 'Content' ) {
continue;
}
+
$block_params['title'] = $category_data['Name'];
$block_params['template'] = preg_replace('/^Content\//i', '', $category_data['NamedParentPath']);
$block_params['is_first'] = $index == 1; // because Content is 1st element
@@ -2058,15 +2062,17 @@
function ModifyUnitConfig($params)
{
$root_category = $this->Application->RecallVar('IsRootCategory_' . $this->Application->GetVar('m_wid'));
+
- if (!$root_category) {
+ if ( !$root_category ) {
- return ;
+ return;
}
- $edit_tab_presets = $this->Application->getUnitOption($this->Prefix, 'EditTabPresets');
- $edit_tab_presets['Default'] = Array (
- 'permissions' => $edit_tab_presets['Default']['permissions'],
- );
- $this->Application->setUnitOption($this->Prefix, 'EditTabPresets', $edit_tab_presets);
+ $config = $this->getUnitConfig();
+ $edit_tab_preset = $config->getEditTabPresetByName('Default');
+
+ $config->addEditTabPresets(Array (
+ 'Default' => Array ('permissions' => $edit_tab_preset['permissions'])
+ ));
}
/**
@@ -2077,22 +2083,19 @@
*/
function PrintCatalogExportTemplates($params)
{
+ $ret = Array ();
$prefixes = explode(',', $params['prefixes']);
- $ret = Array ();
foreach ($prefixes as $prefix) {
- if ($this->Application->prefixRegistred($prefix)) {
+ if ( $this->Application->prefixRegistred($prefix) ) {
- $module_path = $this->Application->getUnitOption($prefix, 'ModuleFolder') . '/';
+ $module_path = $this->Application->getUnitConfig($prefix)->getModuleFolder() . '/';
$module_name = $this->Application->findModule('Path', $module_path, 'Name');
$ret[$prefix] = mb_strtolower($module_name) . '/export';
}
}
- $json_helper = $this->Application->recallObject('JSONHelper');
- /* @var $json_helper JSONHelper */
-
- return $json_helper->encode($ret);
+ return json_encode($ret);
}
/**
@@ -2120,7 +2123,8 @@
$object = $this->getObject($params);
/* @var $object kDBList */
- $edit_template = $this->Application->getUnitOption($this->Prefix, 'AdminTemplatePath') . '/' . $this->Application->getUnitOption($this->Prefix, 'AdminTemplatePrefix') . 'edit';
+ $config = $this->getUnitConfig();
+ $edit_template = $config->getAdminTemplatePath() . '/' . $config->getAdminTemplatePrefix() . 'edit';
$url_params = Array (
'm_opener' => 'd',
@@ -2176,7 +2180,7 @@
$perm_helper = $this->Application->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
- $perm_prefix = $this->Application->getUnitOption($this->Prefix, 'PermItemPrefix');
+ $perm_prefix = $this->getUnitConfig()->getPermItemPrefix();
$categories = $perm_helper->getPermissionCategories($perm_prefix . '.' . ($object->IsNewItem() ? 'ADD' : 'MODIFY'));
}
@@ -2227,7 +2231,7 @@
$object = $this->Application->recallObject($module_prefix);
/* @var $object kCatDBItem */
- $title_field = $this->Application->getUnitOption($module_prefix, 'TitleField');
+ $title_field = $this->Application->getUnitConfig($module_prefix)->getTitleField();
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $params['render_as'];
\ No newline at end of file
Index: core/units/helpers/site_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/site_helper.php (revision 15682)
+++ core/units/helpers/site_helper.php (revision )
@@ -50,7 +50,7 @@
if (!isset($cache)) {
$sql = 'SELECT CountryStateId, IsoCode
- FROM ' . $this->Application->getUnitOption('country-state', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('country-state')->getTableName() . '
WHERE Type = ' . DESTINATION_TYPE_COUNTRY;
$cache = $this->Conn->GetCol($sql, 'IsoCode');
}
Index: core/units/custom_fields/custom_fields_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/custom_fields/custom_fields_event_handler.php (revision 15682)
+++ core/units/custom_fields/custom_fields_event_handler.php (revision )
@@ -26,11 +26,11 @@
public function CheckPermission(kEvent $event)
{
$sql = 'SELECT Prefix
- FROM '.TABLE_PREFIX.'ItemTypes
+ FROM ' . TABLE_PREFIX . 'ItemTypes
- WHERE ItemType = '.$this->Conn->qstr( $this->Application->GetVar('cf_type') );
+ WHERE ItemType = ' . $this->Conn->qstr($this->Application->GetVar('cf_type'));
$main_prefix = $this->Conn->GetOne($sql);
- $section = $this->Application->getUnitOption($main_prefix.'.custom', 'PermSection');
+ $section = $this->Application->getUnitConfig($main_prefix)->getPermSectionByName('custom');
$event->setEventParam('PermSection', $section);
return parent::CheckPermission($event);
@@ -52,9 +52,10 @@
/* @var $object kDBList */
$item_type = $this->Application->GetVar('cf_type');
+
if ( !$item_type ) {
$prefix = $event->getEventParam('SourcePrefix');
- $item_type = $this->Application->getUnitOption($prefix, 'ItemType');
+ $item_type = $this->Application->getUnitConfig($prefix)->getItemType();
}
if ( $event->Special == 'general' ) {
@@ -85,10 +86,11 @@
function _getSourcePrefix($event)
{
$prefix = $event->getEventParam('SourcePrefix');
+
- if (!$prefix) {
+ if ( !$prefix ) {
$sql = 'SELECT Prefix
FROM ' . TABLE_PREFIX . 'ItemTypes
- WHERE ItemType = ' . $this->Conn->qstr( $this->Application->GetVar('cf_type') );
+ WHERE ItemType = ' . $this->Conn->qstr($this->Application->GetVar('cf_type'));
$prefix = $this->Conn->GetOne($sql);
}
@@ -104,17 +106,15 @@
*/
protected function _getHiddenFields($event)
{
- $prefix = $this->_getSourcePrefix($event);
-
$hidden_fields = Array ();
- $virtual_fields = $this->Application->getUnitOption($prefix, 'VirtualFields', Array ());
- $custom_fields = $this->Application->getUnitOption($prefix, 'CustomFields', Array ());
- /* @var $custom_fields Array */
+ $config = $this->Application->getUnitConfig($this->_getSourcePrefix($event));
- foreach ($custom_fields as $custom_field) {
+ foreach ($config->getCustomFields(Array ()) as $custom_field) {
$check_field = 'cust_' . $custom_field;
- $show_mode = array_key_exists('show_mode', $virtual_fields[$check_field]) ? $virtual_fields[$check_field]['show_mode'] : true;
+ $field_options = $config->getVirtualFieldByName($check_field);
+ $show_mode = array_key_exists('show_mode', $field_options) ? $field_options['show_mode'] : true;
+
if ( ($show_mode === false) || (($show_mode === smDEBUG) && !(defined('DEBUG_MODE') && DEBUG_MODE)) ) {
$hidden_fields[] = $custom_field;
}
@@ -138,7 +138,7 @@
/* @var $object kDBItem */
$sql = 'SELECT COUNT(*)
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ FROM ' . $event->getUnitConfig()->getTableName() . '
WHERE FieldName = ' . $this->Conn->qstr($object->GetDBField('FieldName')) . ' AND Type = ' . $object->GetDBField('Type');
$found = $this->Conn->GetOne($sql);
@@ -169,7 +169,7 @@
/* @var $ml_helper kMultiLanguageHelper */
// call main item config to clone cdata table
- $this->Application->getUnitOption($main_prefix, 'TableName');
+ $this->Application->getUnitConfig($main_prefix)->getTableName();
$ml_helper->deleteField($main_prefix . '-cdata', $event->getEventParam('id'));
}
@@ -212,7 +212,7 @@
// call main item config to clone cdata table
define('CUSTOM_FIELD_ADDED', 1); // used in cdata::scanCustomFields method
- $this->Application->getUnitOption($main_prefix, 'TableName');
+ $this->Application->getUnitConfig($main_prefix)->getTableName();
$ml_helper->createFields($main_prefix . '-cdata');
}
\ No newline at end of file
Index: core/units/selectors/selectors_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/selectors/selectors_event_handler.php (revision 15682)
+++ core/units/selectors/selectors_event_handler.php (revision )
@@ -332,10 +332,14 @@
$object = $event->getObject();
$parent_info = $object->getLinkedInfo();
- $title_field = $this->Application->getUnitOption($event->Prefix,'TitleField');
- $sql = 'SELECT '.$title_field.', '.$object->IDField.' FROM '.$object->TableName.' WHERE Type = 1 AND StylesheetId = '.$parent_info['ParentId'].' ORDER BY '.$title_field;
+ $title_field = $event->getUnitConfig()->getTitleField();
+ $sql = 'SELECT '.$title_field.', '.$object->IDField.'
+ FROM '.$object->TableName.'
+ WHERE Type = 1 AND StylesheetId = '.$parent_info['ParentId'].'
+ ORDER BY '.$title_field;
$options = $this->Conn->GetCol($sql,$object->IDField);
+
$object->SetFieldOption('ParentId', 'options', $options);
}
\ No newline at end of file
Index: core/units/helpers/permissions_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/permissions_helper.php (revision 15682)
+++ core/units/helpers/permissions_helper.php (revision )
@@ -25,7 +25,7 @@
function LoadPermissions($group_id, $cat_id, $type = 1, $prefix = '')
{
- $perm_table = $this->Application->getUnitOption('perm', 'TableName');
+ $perm_table = $this->Application->getUnitConfig('perm')->getTableName();
$perm_table = $this->Application->GetTempName($perm_table, 'prefix:'.$prefix);
$sql = 'SELECT *
FROM '.$perm_table.'
@@ -147,19 +147,18 @@
if (is_array($ids)) {
$ids = implode(',', $ids);
}
- $id_field = $this->Application->getUnitOption($prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
- $ci_table = $this->Application->getUnitOption('ci', 'TableName');
+ $config = $this->Application->getUnitConfig($prefix);
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
+ $ci_table = $this->Application->getUnitConfig('ci')->getTableName();
+
if ($temp_mode) {
$table_name = $this->Application->GetTempName($table_name, 'prefix:' . $prefix);
$ci_table = $this->Application->GetTempName($ci_table, 'prefix:' . $prefix);
}
- $owner_field = $this->Application->getUnitOption($prefix, 'OwnerField');
- if (!$owner_field) {
- $owner_field = 'CreatedById';
- }
+ $owner_field = $config->getOwnerField('CreatedById');
$sql = 'SELECT item_table.'.$id_field.', item_table.'.$owner_field.' AS CreatedById, ci.CategoryId
FROM '.$table_name.' item_table
@@ -247,7 +246,8 @@
return true;
}
- $item_prefix = $this->Application->getUnitOption($top_prefix, 'PermItemPrefix');
+ $item_prefix = $this->Application->getUnitConfig($top_prefix)->getPermItemPrefix();
+
foreach ($check_perms as $perm_name) {
// check if at least one of required permissions is set
if ( !isset($perm_mapping[$perm_name]) ) {
@@ -456,21 +456,21 @@
*/
function getPrimaryCategory($prefix)
{
- $id_field = $this->Application->getUnitOption($prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
$id = $this->Application->GetVar($prefix.'_id');
if (!$id) {
return $this->Application->GetVar('m_cat_id');
}
+ $config = $this->Application->getUnitConfig($prefix);
+
$sql = 'SELECT ResourceId
- FROM '.$table_name.'
- WHERE '.$id_field.' = '.(int)$id;
+ FROM '. $config->getTableName() .'
+ WHERE '. $config->getIDField() .' = '.(int)$id;
$resource_id = $this->Conn->GetOne($sql);
$sql = 'SELECT CategoryId
- FROM '.$this->Application->getUnitOption('ci', 'TableName').'
+ FROM '.$this->Application->getUnitConfig('ci')->getTableName().'
WHERE ItemResourceId = '.$resource_id.' AND PrimaryCat = 1';
return $this->Conn->GetOne($sql);
}
@@ -662,7 +662,7 @@
}
else {
$sql = 'SELECT ParentPath
- FROM ' . $this->Application->getUnitOption('c', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('c')->getTableName() . '
WHERE CategoryId = ' . $cat_id;
$cat_hierarchy = $this->Conn->GetOne($sql);
if ( $cat_hierarchy === false ) {
@@ -758,7 +758,7 @@
*/
function ModifyCheckPermission($owner_id, $category_id, $prefix)
{
- $perm_prefix = $this->Application->getUnitOption($prefix, 'PermItemPrefix');
+ $perm_prefix = $this->Application->getUnitConfig($prefix)->getPermItemPrefix();
$live_modify = $this->CheckPermission($perm_prefix.'.MODIFY', ptCATEGORY, $category_id);
if ($live_modify) {
@@ -792,7 +792,7 @@
*/
function DeleteCheckPermission($owner_id, $category_id, $prefix)
{
- $perm_prefix = $this->Application->getUnitOption($prefix, 'PermItemPrefix');
+ $perm_prefix = $this->Application->getUnitConfig($prefix)->getPermItemPrefix();
$live_delete = $this->CheckPermission($perm_prefix.'.DELETE', ptCATEGORY, $category_id);
if ($live_delete) {
@@ -819,7 +819,7 @@
*/
function AddCheckPermission($category_id, $prefix)
{
- $perm_prefix = $this->Application->getUnitOption($prefix, 'PermItemPrefix');
+ $perm_prefix = $this->Application->getUnitConfig($prefix)->getPermItemPrefix();
$live_add = $this->CheckPermission($perm_prefix.'.ADD', ptCATEGORY, $category_id);
if ($live_add) {
\ No newline at end of file
Index: core/units/helpers/count_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/count_helper.php (revision 15682)
+++ core/units/helpers/count_helper.php (revision )
@@ -124,47 +124,47 @@
*/
function CategoryItemCount($prefix, $params, $count_sql = null)
{
- if (!$this->Application->findModule('Var', $prefix)) {
+ if ( !$this->Application->findModule('Var', $prefix) ) {
// this is not module item
return $this->Application->ProcessParsedTag($prefix, 'CategoryItemCount', $params);
}
// 1. get root category for counting
$category_id = isset($params['cat_id']) ? $params['cat_id'] : false;
- if (!is_numeric($category_id)) {
+ if ( !is_numeric($category_id) ) {
$category_id = $this->Application->GetVar('m_cat_id');
}
- if (!isset($count_sql)) {
+ if ( !isset($count_sql) ) {
$count_sql = 'COUNT(*)';
}
$where_clauses = Array ();
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
+ $table_name = $this->Application->getUnitConfig($prefix)->getTableName();
// 1. count category items
- $sql = 'SELECT '.$count_sql.'
+ $sql = 'SELECT ' . $count_sql . '
- FROM '.$table_name.' item_table
+ FROM ' . $table_name . ' item_table
- INNER JOIN '.TABLE_PREFIX.'CategoryItems ci ON (ci.ItemResourceId = item_table.ResourceId)
+ INNER JOIN ' . TABLE_PREFIX . 'CategoryItems ci ON (ci.ItemResourceId = item_table.ResourceId)
- INNER JOIN '.TABLE_PREFIX.'Categories c ON (ci.CategoryId = c.CategoryId)';
+ INNER JOIN ' . TABLE_PREFIX . 'Categories c ON (ci.CategoryId = c.CategoryId)';
// 2. count items from subcategories
- if ($category_id > 0) {
+ if ( $category_id > 0 ) {
// get subcategories of required category
$tmp_sql = 'SELECT TreeLeft, TreeRight
- FROM '.TABLE_PREFIX.'Categories
+ FROM ' . TABLE_PREFIX . 'Categories
- WHERE CategoryId = '.$category_id;
+ WHERE CategoryId = ' . $category_id;
$tree_info = $this->Conn->GetRow($tmp_sql);
- $where_clauses[] = 'c.TreeLeft BETWEEN '.$tree_info['TreeLeft'].' AND '.$tree_info['TreeRight'];
+ $where_clauses[] = 'c.TreeLeft BETWEEN ' . $tree_info['TreeLeft'] . ' AND ' . $tree_info['TreeRight'];
}
- $where_clauses[] = 'item_table.Status = '.STATUS_ACTIVE;
+ $where_clauses[] = 'item_table.Status = ' . STATUS_ACTIVE;
- if (isset($params['today']) && $params['today']) {
+ if ( isset($params['today']) && $params['today'] ) {
- $today = adodb_mktime(0,0,0, adodb_date('m'), adodb_date('d'), adodb_date('Y'));
+ $today = adodb_mktime(0, 0, 0, adodb_date('m'), adodb_date('d'), adodb_date('Y'));
- $where_clauses[] = 'item_table.CreatedOn >= '.$today;
+ $where_clauses[] = 'item_table.CreatedOn >= ' . $today;
}
- $sql .= ' WHERE ('.implode(') AND (', $where_clauses).')';
+ $sql .= ' WHERE (' . implode(') AND (', $where_clauses) . ')';
return (int)$this->Conn->GetOne($sql);
}
@@ -179,29 +179,32 @@
*/
function ItemCount($prefix, $today = false, $count_sql = null)
{
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
+ $table_name = $this->Application->getUnitConfig($prefix)->getTableName();
- if (!isset($count_sql)) {
+ if ( !isset($count_sql) ) {
- $count_sql = 'COUNT(*)';
- }
+ $count_sql = 'COUNT(*)';
+ }
- $sql = 'SELECT '.$count_sql.'
+ $sql = 'SELECT ' . $count_sql . '
- FROM '.$table_name.' item_table
+ FROM ' . $table_name . ' item_table
- INNER JOIN '.TABLE_PREFIX.'CategoryItems ci ON ci.ItemResourceId = item_table.ResourceId
+ INNER JOIN ' . TABLE_PREFIX . 'CategoryItems ci ON ci.ItemResourceId = item_table.ResourceId
- INNER JOIN '.TABLE_PREFIX.'Categories c ON c.CategoryId = ci.CategoryId
+ INNER JOIN ' . TABLE_PREFIX . 'Categories c ON c.CategoryId = ci.CategoryId
- INNER JOIN '.TABLE_PREFIX.'CategoryPermissionsCache perm_cache ON ci.CategoryId = perm_cache.CategoryId';
+ INNER JOIN ' . TABLE_PREFIX . 'CategoryPermissionsCache perm_cache ON ci.CategoryId = perm_cache.CategoryId';
- list ($view_perm, $view_filter) = $this->GetPermissionClause($prefix, 'perm_cache');
+ list ($view_perm, $view_filter) = $this->GetPermissionClause($prefix, 'perm_cache');
+
- $where_clauses = Array (
+ $where_clauses = Array (
- $view_filter, 'perm_cache.PermId = '.$view_perm, 'ci.PrimaryCat = 1', 'c.Status = '.STATUS_ACTIVE,
+ $view_filter, 'perm_cache.PermId = ' . $view_perm,
+ 'ci.PrimaryCat = 1',
+ 'c.Status = ' . STATUS_ACTIVE,
);
- if ($today) {
+ if ( $today ) {
- $today_date = adodb_mktime(0, 0, 0, adodb_date('m'), adodb_date('d'), adodb_date('Y'));
+ $today_date = adodb_mktime(0, 0, 0, adodb_date('m'), adodb_date('d'), adodb_date('Y'));
- $where_clauses[] = 'item_table.CreatedOn >= '.$today_date;
+ $where_clauses[] = 'item_table.CreatedOn >= ' . $today_date;
- }
+ }
- $sql .= ' WHERE ('.implode(') AND (', $where_clauses).')';
+ $sql .= ' WHERE (' . implode(') AND (', $where_clauses) . ')';
return (int)$this->Conn->GetOne($sql);
}
@@ -214,42 +217,42 @@
*/
function CategoryCount($today = false)
{
- $cache_key = 'category_count[%CSerial%]';
+ $cache_key = 'category_count[%CSerial%]';
- if ($today) {
+ if ( $today ) {
- $today_date = adodb_mktime(0, 0, 0, adodb_date('m'), adodb_date('d'), adodb_date('Y'));
- $cache_key .= ':date=' . $today_date;
- }
+ $today_date = adodb_mktime(0, 0, 0, adodb_date('m'), adodb_date('d'), adodb_date('Y'));
+ $cache_key .= ':date=' . $today_date;
+ }
- $count = $this->Application->getCache($cache_key);
+ $count = $this->Application->getCache($cache_key);
- if ($count === false) {
+ if ( $count === false ) {
$sql = 'SELECT COUNT(*)
- FROM ' . $this->Application->getUnitOption('c', 'TableName') . ' c
+ FROM ' . $this->Application->getUnitConfig('c')->getTableName() . ' c
INNER JOIN ' . TABLE_PREFIX . 'CategoryPermissionsCache perm_cache ON c.CategoryId = perm_cache.CategoryId';
- list ($view_perm, $view_filter) = $this->GetPermissionClause('c', 'perm_cache');
+ list ($view_perm, $view_filter) = $this->GetPermissionClause('c', 'perm_cache');
- $where_clauses = Array (
- $view_filter,
- 'perm_cache.PermId = ' . $view_perm,
- 'c.Status = ' . STATUS_ACTIVE,
+ $where_clauses = Array (
+ $view_filter,
+ 'perm_cache.PermId = ' . $view_perm,
+ 'c.Status = ' . STATUS_ACTIVE,
);
- if ($today) {
+ if ( $today ) {
- $where_clauses[] = 'c.CreatedOn >= ' . $today_date;
- }
+ $where_clauses[] = 'c.CreatedOn >= ' . $today_date;
+ }
- $sql .= ' WHERE ('.implode(') AND (', $where_clauses).')';
+ $sql .= ' WHERE (' . implode(') AND (', $where_clauses) . ')';
$count = $this->Conn->GetOne($sql);
- if ($count !== false) {
+ if ( $count !== false ) {
$this->Application->setCache($cache_key, $count);
}
- }
+ }
- return $count;
+ return $count;
}
/**
@@ -263,24 +266,24 @@
{
$permissions_ids = $this->Application->getCache(__CLASS__ . '::' . __FUNCTION__);
- if ($permissions_ids === false) {
+ if ( $permissions_ids === false ) {
$this->Conn->nextQueryCachable = true;
$sql = 'SELECT PermissionConfigId, PermissionName
- FROM '.TABLE_PREFIX.'CategoryPermissionsConfig
+ FROM ' . TABLE_PREFIX . 'CategoryPermissionsConfig
WHERE PermissionName LIKE "%.VIEW"';
$permissions_ids = $this->Conn->GetCol($sql, 'PermissionName');
$this->Application->setCache(__CLASS__ . '::' . __FUNCTION__, $permissions_ids);
}
- $permission_prefix = $this->Application->getUnitOption($prefix, 'PermItemPrefix');
+ $permission_prefix = $this->Application->getUnitConfig($prefix)->getPermItemPrefix();
$view_perm = $permissions_ids[$permission_prefix . '.VIEW'];
$groups = explode(',', $this->Application->RecallVar('UserGroups'));
foreach ($groups as $group) {
- $view_filters[] = 'FIND_IN_SET('.$group.', '.$table_alias.'.acl)';
+ $view_filters[] = 'FIND_IN_SET(' . $group . ', ' . $table_alias . '.acl)';
}
$view_filter = implode(' OR ', $view_filters);
\ No newline at end of file
Index: core/units/helpers/modules_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/modules_helper.php (revision 15682)
+++ core/units/helpers/modules_helper.php (revision )
@@ -432,7 +432,7 @@
if ( is_null($modules) ) {
$sql = 'SELECT LOWER(Name)
- FROM ' . $this->Application->getUnitOption('mod', 'TableName');
+ FROM ' . $this->Application->getUnitConfig('mod')->getTableName();
$modules = $this->Conn->GetCol($sql);
}
\ No newline at end of file
Index: core/units/system_event_subscriptions/system_event_subscription_tp.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/system_event_subscriptions/system_event_subscription_tp.php (revision 15682)
+++ core/units/system_event_subscriptions/system_event_subscription_tp.php (revision )
@@ -129,7 +129,7 @@
{
foreach ($this->_subscriptions as $subscription) {
$prefix = $this->_getPrefix();
- $parent_prefix = $this->Application->getUnitOption($prefix, 'ParentPrefix');
+ $parent_prefix = $this->Application->getUnitConfig($prefix)->getParentPrefix();
$this->_addIdToPrefix($prefix, 'ItemId');
$this->_addIdToPrefix($parent_prefix, 'ParentItemId');
@@ -168,10 +168,11 @@
protected function _queryItemTitles()
{
foreach ($this->_prefixToIdsMap as $prefix => $ids) {
- $id_field = $this->Application->getUnitOption($prefix, 'IDField');
+ $config = $this->Application->getUnitConfig($prefix);
+ $id_field = $config->getIDField();
$sql = 'SELECT ' . $this->_getTitleField($prefix) . ', ' . $id_field . '
- FROM ' . $this->Application->getUnitOption($prefix, 'TableName') . '
+ FROM ' . $config->getTableName() . '
WHERE ' . $id_field . ' IN (' . implode(',', $ids) . ')';
$this->_itemTitles[$prefix] = $this->Conn->GetCol($sql, $id_field);
}
@@ -239,7 +240,8 @@
protected function _getTitleField($prefix)
{
$lang_prefix = '';
- $title_field = $this->Application->getUnitOption($prefix, 'TitleField');
+ $config = $this->Application->getUnitConfig($prefix);
+ $title_field = $config->getTitleField();
if ( preg_match('/^(l[\d]+_)(.*)/', $title_field, $regs) ) {
// object was initialized and we have lang prefix in unit config
@@ -248,9 +250,9 @@
}
else {
// object wasn't initialized -> check other way OR not ml title field
- $fields = $this->Application->getUnitOption($prefix, 'Fields');
+ $field_options = $config->getFieldByName($title_field);
- if ( isset($fields[$title_field]['formatter']) && $fields[$title_field]['formatter'] == 'kMultiLanguage' ) {
+ if ( isset($field_options['formatter']) && $field_options['formatter'] == 'kMultiLanguage' ) {
$lang_prefix = 'l' . $this->Application->GetVar('m_lang') . '_';
}
}
\ No newline at end of file
Index: core/units/logs/system_logs/system_log_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/logs/system_logs/system_log_eh.php (revision 15682)
+++ core/units/logs/system_logs/system_log_eh.php (revision )
@@ -104,8 +104,10 @@
return;
}
- $sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . '
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ $config = $event->getUnitConfig();
+
+ $sql = 'SELECT ' . $config->getIDField() . '
+ FROM ' . $config->getTableName() . '
WHERE ' . TIMENOW . ' - LogTimestamp > ' . $rotation_interval . '
LIMIT 0,50';
$ids = $this->Conn->GetCol($sql);
Index: core/units/helpers/navigation_bar.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/navigation_bar.php (revision 15682)
+++ core/units/helpers/navigation_bar.php (revision )
@@ -283,12 +283,12 @@
$navbar_field = $ml_formatter->LangFieldName($category_title);
- $id_field = $this->Application->getUnitOption('c', 'IDField');
- $table_name = $this->Application->getUnitOption('c', 'TableName');
+ $config = $this->Application->getUnitConfig('c');
+ $id_field = $config->getIDField();
$this->Conn->nextQueryCachable = true;
$sql = 'SELECT ' . $navbar_field . ', ' . $id_field . '
- FROM ' . $table_name . '
+ FROM ' . $config->getTableName() . '
WHERE ' . $id_field . ' IN (' . implode(',', $parent_path) . ')';
$category_names = $this->Conn->GetCol($sql, $id_field);
@@ -327,10 +327,12 @@
return $parent_path;
}
+ $config = $this->Application->getUnitConfig('c');
+
$this->Conn->nextQueryCachable = true;
$sql = 'SELECT ParentPath
- FROM ' . $this->Application->getUnitOption('c', 'TableName') . '
- WHERE ' . $this->Application->getUnitOption('c', 'IDField') . ' = ' . $category_id;
+ FROM ' . $config->getTableName() . '
+ WHERE ' . $config->getIDField() . ' = ' . $category_id;
$parent_path = $this->Conn->GetOne($sql);
$this->Application->setCache($cache_key, $parent_path);
\ No newline at end of file
Index: core/units/user_profile/user_profile_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/user_profile/user_profile_eh.php (revision 15682)
+++ core/units/user_profile/user_profile_eh.php (revision )
@@ -54,7 +54,7 @@
$public_profile_add = Array ();
$public_profile_remove = Array ();
- $profile_mapping = $this->Application->getUnitOption('u', 'UserProfileMapping');
+ $profile_mapping = $this->Application->getUnitConfig('u')->getUserProfileMapping();
foreach ($field_values as $variable_name => $variable_value) {
if (array_key_exists($variable_name, $profile_mapping)) {
\ No newline at end of file
Index: core/kernel/event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/event_handler.php (revision 15682)
+++ core/kernel/event_handler.php (revision )
@@ -219,7 +219,7 @@
protected function OnGetEventSubscribersQuery(kEvent $event)
{
$sql = 'SELECT SubscriberEmail, UserId
- FROM ' . $this->Application->getUnitOption('system-event-subscription', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('system-event-subscription')->getTableName() . '
WHERE (' . implode(') AND (', $event->getEventParam('where_clause')) . ')';
$event->setEventParam('sql', $sql);
}
\ No newline at end of file
Index: core/kernel/utility/http_query.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/utility/http_query.php (revision 15682)
+++ core/kernel/utility/http_query.php (revision )
@@ -170,7 +170,7 @@
*/
protected function getQueryString($prefix)
{
- $ret = $this->Application->getUnitOption($prefix, 'QueryString', Array ());
+ $ret = $this->Application->getUnitConfig($prefix)->getQueryString(Array ());
if ( !$ret && preg_match('/(.*?)-(.*)/', $prefix, $regs) ) {
// "#prefix" (new format), "prefix" (old format)
@@ -189,7 +189,7 @@
private function _getQueryString($prefix)
{
if ( $this->Application->prefixRegistred($prefix) ) {
- return $this->Application->getUnitOption($prefix, 'QueryString');
+ return $this->Application->getUnitConfig($prefix)->getQueryString();
}
return substr($prefix, 0, 1) == '#' ? $this->_getQueryString( substr($prefix, 1) ) : Array ();
Index: core/units/helpers/menu_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/menu_helper.php (revision 15682)
+++ core/units/helpers/menu_helper.php (revision )
@@ -280,7 +280,7 @@
{
// 1. get parent paths of leaf categories, that are in menu (across all themes)
$sql = 'SELECT ParentPath, CategoryId
- FROM ' . $this->Application->getUnitOption('c', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('c')->getTableName() . '
WHERE IsMenu = 1 AND Status = ' . STATUS_ACTIVE;
$this->parentPaths = $this->Conn->GetCol($sql ,'CategoryId');
Index: core/units/related_searches/related_searches_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/related_searches/related_searches_event_handler.php (revision 15682)
+++ core/units/related_searches/related_searches_event_handler.php (revision )
@@ -32,8 +32,8 @@
$table_info = $object->getLinkedInfo();
- $source_itemtype = $this->Application->getUnitOption($table_info['ParentPrefix'], 'ItemType');
- $object->SetDBField('ItemType', $source_itemtype);
+ $source_item_type = $this->Application->getUnitConfig($table_info['ParentPrefix'])->getItemType();
+ $object->SetDBField('ItemType', $source_item_type);
}
}
\ No newline at end of file
Index: core/units/helpers/recursive_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/recursive_helper.php (revision 15682)
+++ core/units/helpers/recursive_helper.php (revision )
@@ -18,11 +18,11 @@
function DeleteCategory($category_id, $prefix='c')
{
- $id_field = $this->Application->getUnitOption($prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
+ $config = $this->Application->getUnitConfig($prefix);
+ $id_field = $config->getIDField();
$sql = 'SELECT '.$id_field.'
- FROM '.$table_name.'
+ FROM '. $config->getTableName() .'
WHERE ParentId = '.$category_id;
$sub_categories = $this->Conn->GetCol($sql);
@@ -32,7 +32,8 @@
}
}
- $ci_table = $this->Application->getUnitOption('ci', 'TableName');
+ $ci_table = $this->Application->getUnitConfig('ci')->getTableName();
+
// 1. remove category items from this category if it is supplemental (non-primary) category to them
$sql = 'DELETE FROM '.$ci_table.'
WHERE ('.$id_field.' = '.$category_id.') AND (PrimaryCat = 0)';
@@ -72,35 +73,35 @@
return Array();
}
- $id_field = $this->Application->getUnitOption($prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
+ $config = $this->Application->getUnitConfig($prefix);
- $sql = 'SELECT '.$id_field.'
- FROM '.$table_name.'
+ $sql = 'SELECT '. $config->getIDField() .'
+ FROM '. $config->getTableName() .'
WHERE ResourceId IN ('.implode(',', $resource_ids).')';
return $this->Conn->GetCol($sql);
}
// moves selected categories to destination category
- function MoveCategories($category_ids, $dest_category_id)
+ function MoveCategories($category_ids, $dst_category_id)
{
if (!$category_ids) return ;
- $id_field = $this->Application->getUnitOption('c', 'IDField');
- $table_name = $this->Application->getUnitOption('c', 'TableName');
+ $categories_config = $this->Application->getUnitConfig('c');
+ $id_field = $categories_config->getIDField();
+ $table_name = $categories_config->getTableName();
// do not move categories into their children
$sql = 'SELECT ParentPath
FROM '.$table_name.'
- WHERE '.$id_field.' = '.$dest_category_id;
- $dest_parent_path = explode('|', substr($this->Conn->GetOne($sql), 1, -1));
+ WHERE '.$id_field.' = '.$dst_category_id;
+ $dst_parent_path = explode('|', substr($this->Conn->GetOne($sql), 1, -1));
- $child_categories = array_intersect($dest_parent_path, $category_ids); // get categories, then can't be moved
+ $child_categories = array_intersect($dst_parent_path, $category_ids); // get categories, then can't be moved
$category_ids = array_diff($category_ids, $child_categories); // remove them from movable categories list
if ($category_ids) {
$sql = 'UPDATE '.$table_name.'
- SET ParentId = '.$dest_category_id.'
+ SET ParentId = '.$dst_category_id.'
WHERE '.$id_field.' IN ('.implode(',', $category_ids).')';
$this->Conn->Query($sql);
}
@@ -131,9 +132,6 @@
$new_category_id = array_pop($temp_handler->CloneItems($prefix, '', Array ($category_id)));
$this->Application->SetVar('m_cat_id', $new_category_id);
- $id_field = $this->Application->getUnitOption($prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
-
// 2. assign supplemental items to current category to new category
$paste_ids = $this->getCategoryItems($category_id, false);
@@ -167,9 +165,11 @@
$temp_handler->CloneItems($item_prefix, '', $item_ids);
}
+ $config = $this->Application->getUnitConfig($prefix);
+
// 4. do same stuff for each subcategory
- $sql = 'SELECT ' . $id_field . '
- FROM ' . $table_name . '
+ $sql = 'SELECT ' . $config->getIDField() . '
+ FROM ' . $config->getTableName() . '
WHERE ParentId = ' . $category_id;
$sub_categories = $this->Conn->GetCol($sql);
@@ -191,7 +191,7 @@
*/
function getCategoryItems($category_id, $item_primary_category = true)
{
- $ci_table = $this->Application->getUnitOption('ci', 'TableName');
+ $ci_table = $this->Application->getUnitConfig('ci')->getTableName();
$sql = 'SELECT ItemPrefix, ItemResourceId
FROM '.$ci_table.'
\ No newline at end of file
Index: core/units/phrases/phrase_tp.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/phrases/phrase_tp.php (revision 15682)
+++ core/units/phrases/phrase_tp.php (revision )
@@ -40,7 +40,7 @@
if (!isset($cache)) {
$sql = 'SELECT COUNT(*), Module
- FROM ' . $this->Application->getUnitOption($this->Prefix, 'TableName') . '
+ FROM ' . $this->getUnitConfig()->getTableName() . '
GROUP BY Module';
$cache = $this->Conn->GetCol($sql, 'Module');
}
@@ -61,9 +61,9 @@
{
static $cache = null;
- if ( !isset($cache) ) {
+ if (!isset($cache)) {
$sql = 'SELECT COUNT(*), IF(Module LIKE "Core:%", "Core", Module) AS Module
- FROM ' . $this->Application->getUnitOption('email-template', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('email-template')->getTableName() . '
GROUP BY Module';
$cache = $this->Conn->GetCol($sql, 'Module');
}
\ No newline at end of file
Index: core/kernel/db/db_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/db/db_event_handler.php (revision 15682)
+++ core/kernel/db/db_event_handler.php (revision )
@@ -222,7 +222,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, $event->getEventParam('list'), $event->Special == 'next', $select_clause);
}
@@ -236,8 +236,7 @@
$main_object = $this->Application->recallObject($regs[1]);
/* @var $main_object kDBItem */
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- return $main_object->GetDBField($id_field);
+ return $main_object->GetDBField($event->getUnitConfig()->getIDField());
}
// 1. get id from post (used in admin)
@@ -311,8 +310,10 @@
// get selected ids from post & save them to session
$items_info = $this->Application->GetVar($event->getPrefixSpecial(true));
+
if ( $items_info ) {
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
+ $id_field = $event->getUnitConfig()->getIDField();
+
foreach ($items_info as $id => $field_values) {
if ( getArrayValue($field_values, $id_field) ) {
array_push($ids, $id);
@@ -409,14 +410,15 @@
protected function getRequestProtectedFields($hash)
{
// by default don't allow changing ID or foreign key from request
+ $config = $this->getUnitConfig();
+
$fields = Array ();
- $fields[] = $this->Application->getUnitOption($this->Prefix, 'IDField');
+ $fields[] = $config->getIDField();
- $parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix');
+ $parent_prefix = $config->getParentPrefix();
if ( $parent_prefix && !$this->Application->isAdmin ) {
- $foreign_key = $this->Application->getUnitOption($this->Prefix, 'ForeignKey');
- $fields[] = is_array($foreign_key) ? $foreign_key[$parent_prefix] : $foreign_key;
+ $fields[] = $config->getForeignKey($parent_prefix);
}
return $fields;
@@ -467,7 +469,7 @@
$form_name = (string)getArrayValue($request_forms, $object->getPrefixSpecial());
}
- $object->Configure($event->getEventParam('populate_ml_fields') || $this->Application->getUnitOption($event->Prefix, 'PopulateMlFields'), $form_name);
+ $object->Configure($event->getEventParam('populate_ml_fields') || $event->getUnitConfig()->getPopulateMlFields(), $form_name);
$this->PrepareObject($object, $event);
$parent_event = $event->getEventParam('parent_event');
@@ -498,13 +500,12 @@
*/
protected function checkItemStatus(kEvent $event)
{
- $status_fields = $this->Application->getUnitOption($event->Prefix, 'StatusField');
- if ( !$status_fields ) {
+ $status_field = $event->getUnitConfig()->getStatusField(true);
+
+ if ( !$status_field ) {
return true;
}
- $status_field = array_shift($status_fields);
-
if ( $status_field == 'Status' || $status_field == 'Enabled' ) {
$object = $event->getObject();
/* @var $object kDBItem */
@@ -571,7 +572,7 @@
$object->setSelectSQL($sql);
// 2. loads if allowed
- $auto_load = $this->Application->getUnitOption($event->Prefix,'AutoLoad');
+ $auto_load = $event->getUnitConfig()->getAutoLoad();
$skip_autoload = $event->getEventParam('skip_autoload');
if ( $auto_load && !$skip_autoload ) {
@@ -970,7 +971,7 @@
if ( $per_page ) {
// per-page is passed as tag parameter to PrintList, InitList, etc.
- $config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
+ $config_mapping = $event->getUnitConfig()->getConfigMapping();
// 2. per-page setting is stored in configuration variable
if ( $config_mapping ) {
@@ -1138,22 +1139,22 @@
*/
protected function _getDefaultSorting(kEvent $event)
{
- $list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings', Array ());
- $sorting_prefix = array_key_exists($event->Special, $list_sortings) ? $event->Special : '';
- $sorting_configs = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
+ $config = $event->getUnitConfig();
+ $sorting_configs = $config->getConfigMapping();
+ $list_sortings = $config->getListSortingsBySpecial($event);
if ( $sorting_configs && array_key_exists('DefaultSorting1Field', $sorting_configs) ) {
// sorting defined in configuration variables overrides one from unit config
- $list_sortings[$sorting_prefix]['Sorting'] = Array (
+ $list_sortings['Sorting'] = Array (
$this->Application->ConfigValue($sorting_configs['DefaultSorting1Field']) => $this->Application->ConfigValue($sorting_configs['DefaultSorting1Dir']),
$this->Application->ConfigValue($sorting_configs['DefaultSorting2Field']) => $this->Application->ConfigValue($sorting_configs['DefaultSorting2Dir']),
);
// TODO: lowercase configuration variable values in db, instead of here
- $list_sortings[$sorting_prefix]['Sorting'] = array_map('strtolower', $list_sortings[$sorting_prefix]['Sorting']);
+ $list_sortings['Sorting'] = array_map('strtolower', $list_sortings['Sorting']);
}
- return isset($list_sortings[$sorting_prefix]) ? $list_sortings[$sorting_prefix] : Array ();
+ return $list_sortings ? $list_sortings : Array ();
}
/**
@@ -1268,7 +1269,7 @@
$temp_filter = $this->Application->makeClass('kMultipleFilter');
/* @var $temp_filter kMultipleFilter */
- $filter_menu = $this->Application->getUnitOption($event->Prefix, 'FilterMenu');
+ $filter_menu = $event->getUnitConfig()->getFilterMenu();
$group_key = 0;
$group_count = count($filter_menu['Groups']);
@@ -1323,7 +1324,7 @@
);
$sql = 'SELECT *
- FROM ' . $this->Application->getUnitOption('item-filter', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('item-filter')->getTableName() . '
WHERE (' . implode(') AND (', $where_clause) . ')';
$filters = $this->Conn->Query($sql, 'FilterField');
@@ -1681,8 +1682,10 @@
*/
protected function OnDeleteAll(kEvent $event)
{
- $sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . '
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $config = $event->getUnitConfig();
+
+ $sql = 'SELECT ' . $config->getIDField() . '
+ FROM ' . $config->getTableName();
$ids = $this->Conn->GetCol($sql);
if ( $ids ) {
@@ -1977,19 +1980,19 @@
}
// save changes to database
- $sesion_log_id = $this->Application->RecallVar('_SessionLogId_');
+ $session_log_id = $this->Application->RecallVar('_SessionLogId_');
- if (!$save || !$sesion_log_id) {
+ if (!$save || !$session_log_id) {
// saving changes to database disabled OR related session log missing
return ;
}
$add_fields = Array (
'PortalUserId' => $this->Application->RecallVar('user_id'),
- 'SessionLogId' => $sesion_log_id,
+ 'SessionLogId' => $session_log_id,
);
- $change_log_table = $this->Application->getUnitOption('change-log', 'TableName');
+ $change_log_table = $this->Application->getUnitConfig('change-log')->getTableName();
foreach ($changes as $rec) {
$this->Conn->doInsert(array_merge($rec, $add_fields), $change_log_table);
@@ -1997,9 +2000,9 @@
$this->Application->incrementCacheSerial('change-log');
- $sql = 'UPDATE ' . $this->Application->getUnitOption('session-log', 'TableName') . '
+ $sql = 'UPDATE ' . $this->Application->getUnitConfig('session-log')->getTableName() . '
SET AffectedItems = AffectedItems + ' . count($changes) . '
- WHERE SessionLogId = ' . $sesion_log_id;
+ WHERE SessionLogId = ' . $session_log_id;
$this->Conn->Query($sql);
$this->Application->incrementCacheSerial('session-log');
@@ -2256,8 +2259,9 @@
$ids = $this->StoreSelectedIDs($event);
if ( $ids ) {
- $status_field = $object->getStatusField();
- $order_field = $this->Application->getUnitOption($event->Prefix, 'OrderField');
+ $config = $event->getUnitConfig();
+ $status_field = $config->getStatusField(true);
+ $order_field = $config->getOrderField();
if ( !$order_field ) {
$order_field = 'Priority';
@@ -2481,11 +2485,8 @@
// 1. delete direct subscriptions to item, that was deleted
$this->_deleteSubscriptions($event->Prefix, 'ItemId', $object->GetID());
- $sub_items = $this->Application->getUnitOption($event->Prefix, 'SubItems', Array ());
- /* @var $sub_items Array */
-
// 2. delete this item sub-items subscriptions, that reference item, that was deleted
- foreach ($sub_items as $sub_prefix) {
+ foreach ($event->getUnitConfig()->getSubItems(Array ()) as $sub_prefix) {
$this->_deleteSubscriptions($sub_prefix, 'ParentItemId', $object->GetID());
}
}
@@ -2502,7 +2503,7 @@
protected function _deleteSubscriptions($prefix, $field, $value)
{
$sql = 'SELECT TemplateId
- FROM ' . $this->Application->getUnitOption('email-template', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('email-template')->getTableName() . '
WHERE BindToSystemEvent REGEXP "' . $this->Conn->escape($prefix) . '(\\\\.[^:]*:.*|:.*)"';
$email_template_ids = $this->Conn->GetCol($sql);
@@ -2788,7 +2789,7 @@
protected function FilterAction(kEvent $event)
{
$view_filter = Array ();
- $filter_menu = $this->Application->getUnitOption($event->Prefix, 'FilterMenu');
+ $filter_menu = $event->getUnitConfig()->getFilterMenu();
switch ($event->Name) {
case 'OnRemoveFilters':
@@ -3159,11 +3160,8 @@
}
$field_name = $this->Application->GetVar('field');
- $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
- $virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields');
- $field_options = array_key_exists($field_name, $fields) ? $fields[$field_name] : $virtual_fields[$field_name];
+ $field_options = $this->_getUploadFieldDefinition($event, $field_name);
- $upload_dir = $field_options['upload_dir'];
$storage_format = array_key_exists('storage_format', $field_options) ? $field_options['storage_format'] : false;
if ( !is_writable($tmp_path) ) {
@@ -3202,6 +3200,26 @@
}
/**
+ * Returns upload field definition
+ *
+ * @param kEvent $event
+ * @param string $field_name
+ * @return Array
+ * @access protected
+ */
+ protected function _getUploadFieldDefinition(kEvent $event, $field_name)
+ {
+ $config = $event->getUnitConfig();
+ $ret = $config->getFieldByName($field_name);
+
+ if ( !$ret ) {
+ $ret = $config->getVirtualFieldByName($field_name);
+ }
+
+ return $ret;
+ }
+
+ /**
* Delete temporary files, that won't be used for sure
*
* @param string $path
@@ -3457,7 +3475,6 @@
$field = $this->Application->GetVar('field');
$cur_value = $this->Application->GetVar('cur_value');
- $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
$object = $event->getObject();
@@ -3471,7 +3488,7 @@
}
$sql = 'SELECT DISTINCT ' . $field . '
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ FROM ' . $event->getUnitConfig()->getTableName() . '
WHERE ' . $field . ' LIKE ' . $this->Conn->qstr($cur_value . '%') . '
ORDER BY ' . $field . '
LIMIT 0,' . $limit;
@@ -3536,11 +3553,11 @@
*/
protected function OnCloneSubItem(kEvent $event)
{
- $clones = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'Clones');
+ $sub_item_prefix = $event->Prefix . '-' . preg_replace('/^#/', '', $event->MasterEvent->Prefix);
- $subitem_prefix = $event->Prefix . '-' . preg_replace('/^#/', '', $event->MasterEvent->Prefix);
- $clones[$subitem_prefix] = Array ('ParentPrefix' => $event->Prefix);
- $this->Application->setUnitOption($event->MasterEvent->Prefix, 'Clones', $clones);
+ $event->MasterEvent->getUnitConfig()->addClones(Array (
+ $sub_item_prefix => Array ('ParentPrefix' => $event->Prefix),
+ ));
}
/**
\ No newline at end of file
Index: core/install/upgrades.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/install/upgrades.php (revision 15682)
+++ core/install/upgrades.php (revision )
@@ -618,8 +618,9 @@
*/
function _removeDuplicatePhrases()
{
- $id_field = $this->Application->getUnitOption('phrases', 'IDField');
- $table_name = $this->Application->getUnitOption('phrases', 'TableName');
+ $config = $this->Application->getUnitConfig('phrases');
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
$sql = 'SELECT LanguageId, Phrase, MIN(LastChanged) AS LastChanged, COUNT(*) AS DupeCount
FROM ' . $table_name . '
@@ -1852,7 +1853,7 @@
private function _renameTables($key)
{
foreach ($this->renamedTables as $prefix => $table_info) {
- $this->Application->setUnitOption($prefix, 'TableName', TABLE_PREFIX . $table_info[$key]);
+ $this->Application->getUnitConfig($prefix)->setTableName(TABLE_PREFIX . $table_info[$key]);
}
}
@@ -1955,7 +1956,7 @@
$delete_ids = Array ();
$ml_helper->createFields('phrases');
$languages = $ml_helper->getLanguages();
- $phrase_table = $this->Application->getUnitOption('phrases', 'TableName');
+ $phrase_table = $this->Application->getUnitConfig('phrases')->getTableName();
foreach ($source_phrases as $phrase_key => $phrase_info) {
$target_phrase_key = $target_prefix . substr($phrase_key, strlen($source_prefix));
@@ -1996,7 +1997,7 @@
protected function getPhrasesByMask($mask)
{
$sql = 'SELECT *
- FROM ' . $this->Application->getUnitOption('phrases', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('phrases')->getTableName() . '
WHERE PhraseKey LIKE ' . $this->Conn->qstr($mask);
return $this->Conn->Query($sql, 'PhraseKey');
@@ -2054,8 +2055,9 @@
*/
private function _splitEmailBody()
{
- $id_field = $this->Application->getUnitOption('email-template', 'IDField');
- $table_name = $this->Application->getUnitOption('email-template', 'TableName');
+ $config = $this->Application->getUnitConfig('email-template');
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
$fields = $this->Conn->Query('DESCRIBE ' . $table_name, 'Field');
if ( !isset($fields['l1_Body']) ) {
@@ -2111,7 +2113,7 @@
$languages = $ml_helper->getLanguages();
- $event_table = $this->Application->getUnitOption('email-template', 'TableName');
+ $event_table = $this->Application->getUnitConfig('email-template')->getTableName();
$sql = 'SELECT *
FROM ' . $event_table . '
@@ -2123,7 +2125,7 @@
}
$primary_language_id = $this->Application->GetDefaultLanguageId();
- $table_name = $this->Application->getUnitOption('lang', 'TableName');
+ $table_name = $this->Application->getUnitConfig('lang')->getTableName();
foreach ($languages as $language_id) {
$is_primary = $language_id == $primary_language_id;
@@ -2175,7 +2177,7 @@
// make some promo block fields translatable
$ml_helper->createFields('promo-block');
- $table_name = $this->Application->getUnitOption('promo-block', 'TableName');
+ $table_name = $this->Application->getUnitConfig('promo-block')->getTableName();
$table_structure = $this->Conn->Query('DESCRIBE ' . $table_name, 'Field');
if ( isset($table_structure['Title']) ) {
@@ -2189,7 +2191,7 @@
// fix e-mail event translations
$languages = $ml_helper->getLanguages();
- $table_name = $this->Application->getUnitOption('email-template', 'TableName');
+ $table_name = $this->Application->getUnitConfig('email-template')->getTableName();
$change_fields = Array ('Subject', 'HtmlBody', 'PlainTextBody');
@@ -2220,7 +2222,7 @@
return;
}
- $table_name = $this->Application->getUnitOption('c', 'TableName');
+ $table_name = $this->Application->getUnitConfig('c')->getTableName();
$sql = 'SELECT NamedParentPath, CachedTemplate, CategoryId
FROM ' . $table_name;
@@ -2253,8 +2255,9 @@
protected function _updateScheduledTaskRunSchedule()
{
// minute hour day_of_month month day_of_week
- $id_field = $this->Application->getUnitOption('scheduled-task', 'IDField');
- $table_name = $this->Application->getUnitOption('scheduled-task', 'TableName');
+ $config = $this->Application->getUnitConfig('scheduled-task');
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
$sql = 'SELECT RunInterval, ' . $id_field . '
FROM ' . $table_name;
@@ -2312,7 +2315,7 @@
protected function _updateUserPasswords()
{
- $user_table = $this->Application->getUnitOption('u', 'TableName');
+ $user_table = $this->Application->getUnitConfig('u')->getTableName();
$sql = 'SELECT Password, PortalUserId
FROM ' . $user_table . '
@@ -2338,7 +2341,7 @@
$this->Conn->doUpdate($fields_hash, TABLE_PREFIX . 'Users', 'PortalUserId = ' . $user_id);
}
}
-
+
/**
* Update to 5.3.0-B1
*
\ No newline at end of file
Index: core/units/helpers/mod_rewrite_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/mod_rewrite_helper.php (revision 15682)
+++ core/units/helpers/mod_rewrite_helper.php (revision )
@@ -212,9 +212,11 @@
if ($filename === false) {
$this->Conn->nextQueryCachable = true;
+ $config = $this->Application->getUnitConfig($prefix);
+
$sql = 'SELECT ResourceId
- FROM ' . $this->Application->getUnitOption($prefix, 'TableName') . '
- WHERE ' . $this->Application->getUnitOption($prefix, 'IDField') . ' = ' . $this->Conn->qstr($id);
+ FROM ' . $config->getTableName() . '
+ WHERE ' . $config->getIDField() . ' = ' . $this->Conn->qstr($id);
$resource_id = $this->Conn->GetOne($sql);
$this->Conn->nextQueryCachable = true;
@@ -275,10 +277,10 @@
$item_template = $rewrite_processor->GetItemTemplate($cat_item, $module_prefix, $vars['m_theme']);
// converting ResourceId to corresponding Item id
- $module_config = $this->Application->getUnitOptions($module_prefix);
+ $module_config = $this->Application->getUnitConfig($module_prefix);
- $sql = 'SELECT ' . $module_config['IDField'] . '
- FROM ' . $module_config['TableName'] . '
+ $sql = 'SELECT ' . $module_config->getIDField() . '
+ FROM ' . $module_config->getTableName() . '
WHERE ResourceId = ' . $cat_item['ItemResourceId'];
$item_id = $this->Conn->GetOne($sql);
Index: core/kernel/db/dblist.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/db/dblist.php (revision 15682)
+++ core/kernel/db/dblist.php (revision )
@@ -552,22 +552,22 @@
*/
protected function CalculateTotals()
{
- $fields = Array();
+ $fields = Array ();
- $this->Totals = Array();
+ $this->Totals = Array ();
- if ($this->gridName) {
+ if ( $this->gridName ) {
- $grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
- $grid_fields = $grids[$this->gridName]['Fields'];
+ $grid = $this->getUnitConfig()->getGridByName($this->gridName);
+ $grid_fields = $grid['Fields'];
}
else {
$grid_fields = $this->Fields;
}
foreach ($grid_fields as $field_name => $field_options) {
- if ($this->gridName && array_key_exists('totals', $field_options) && $field_options['totals']) {
+ if ( $this->gridName && array_key_exists('totals', $field_options) && $field_options['totals'] ) {
$totals = $field_options['totals'];
}
- elseif (array_key_exists('totals', $this->Fields[$field_name]) && $this->Fields[$field_name]['totals']) {
+ elseif ( array_key_exists('totals', $this->Fields[$field_name]) && $this->Fields[$field_name]['totals'] ) {
$totals = $this->Fields[$field_name]['totals'];
}
else {
@@ -577,38 +577,37 @@
$calculated_field = array_key_exists($field_name, $this->CalculatedFields) && array_key_exists($field_name, $this->VirtualFields);
$db_field = !array_key_exists($field_name, $this->VirtualFields);
- if ($calculated_field || $db_field) {
+ if ( $calculated_field || $db_field ) {
- $field_expression = $calculated_field ? $this->CalculatedFields[$field_name] : '`'.$this->TableName.'`.`'.$field_name.'`';
+ $field_expression = $calculated_field ? $this->CalculatedFields[$field_name] : '`' . $this->TableName . '`.`' . $field_name . '`';
- $fields[$field_name] = $totals.'('.$field_expression.') AS '.$field_name.'_'.$totals;
+ $fields[$field_name] = $totals . '(' . $field_expression . ') AS ' . $field_name . '_' . $totals;
}
}
- if (!$fields) {
+ if ( !$fields ) {
- return ;
+ return;
}
$sql = $this->GetSelectSQL(true, false);
$fields = str_replace('%1$s', $this->TableName, implode(', ', $fields));
- if ( preg_match("/DISTINCT(.*?\s)FROM(?!_)/is",$sql,$regs ) )
- {
+ if ( preg_match("/DISTINCT(.*?\s)FROM(?!_)/is", $sql, $regs) ) {
- $sql = preg_replace("/^\s*SELECT DISTINCT(.*?\s)FROM(?!_)/is", 'SELECT '.$fields.' FROM', $sql);
+ $sql = preg_replace("/^\s*SELECT DISTINCT(.*?\s)FROM(?!_)/is", 'SELECT ' . $fields . ' FROM', $sql);
}
- else
- {
+ else {
- $sql = preg_replace("/^\s*SELECT(.*?\s)FROM(?!_)/is", 'SELECT '.$fields.' FROM ', $sql);
+ $sql = preg_replace("/^\s*SELECT(.*?\s)FROM(?!_)/is", 'SELECT ' . $fields . ' FROM ', $sql);
}
$totals = $this->Conn->Query($sql);
- foreach($totals as $totals_row)
- {
- foreach($totals_row as $total_field => $field_value)
- {
- if(!isset($this->Totals[$total_field])) $this->Totals[$total_field] = 0;
+ foreach ($totals as $totals_row) {
+ foreach ($totals_row as $total_field => $field_value) {
+ if ( !isset($this->Totals[$total_field]) ) {
+ $this->Totals[$total_field] = 0;
+ }
$this->Totals[$total_field] += $field_value;
}
}
+
$this->TotalsCalculated = true;
}
@@ -636,18 +635,18 @@
function getTotalFunction($field)
{
- if ($this->gridName) {
+ if ( $this->gridName ) {
- $grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
- $field_options = $grids[$this->gridName]['Fields'][$field];
+ $grid = $this->getUnitConfig()->getGridByName($this->gridName);
+ $field_options = $grid['Fields'][$field];
}
else {
$field_options = $this->Fields[$field];
}
- if ($this->gridName && array_key_exists('totals', $field_options) && $field_options['totals']) {
+ if ( $this->gridName && array_key_exists('totals', $field_options) && $field_options['totals'] ) {
return $field_options['totals'];
}
- elseif (array_key_exists('totals', $this->Fields[$field]) && $this->Fields[$field]['totals']) {
+ elseif ( array_key_exists('totals', $this->Fields[$field]) && $this->Fields[$field]['totals'] ) {
return $this->Fields[$field]['totals'];
}
@@ -1298,24 +1297,25 @@
*/
public function linkToParent($special)
{
- $parent_prefix = $this->Application->getUnitOption($this->Prefix, 'ParentPrefix');
+ $config = $this->getUnitConfig();
+ $parent_prefix = $config->getParentPrefix();
+
- if ($parent_prefix) {
+ if ( $parent_prefix ) {
- $parent_table_key = $this->Application->getUnitOption($this->Prefix, 'ParentTableKey');
- if (is_array($parent_table_key)) $parent_table_key = getArrayValue($parent_table_key, $parent_prefix);
- $foreign_key_field = $this->Application->getUnitOption($this->Prefix, 'ForeignKey');
- if (is_array($foreign_key_field)) $foreign_key_field = getArrayValue($foreign_key_field, $parent_prefix);
+ $parent_table_key = $config->getParentTableKey($parent_prefix);
+ $foreign_key_field = $config->getForeignKey($parent_prefix);
- if (!$parent_table_key || !$foreign_key_field) {
+ if ( !$parent_table_key || !$foreign_key_field ) {
- return ;
+ return;
}
- $parent_object = $this->Application->recallObject($parent_prefix.'.'.$special);
+ $parent_object = $this->Application->recallObject($parent_prefix . '.' . $special);
/* @var $parent_object kDBItem */
- if (!$parent_object->isLoaded()) {
+ if ( !$parent_object->isLoaded() ) {
$this->addFilter('parent_filter', 'FALSE');
- trigger_error('Parent ID not found (prefix: "' . rtrim($parent_prefix.'.'.$special, '.') . '"; sub-prefix: "' . $this->getPrefixSpecial() . '")', E_USER_NOTICE);
+ trigger_error('Parent ID not found (prefix: "' . rtrim($parent_prefix . '.' . $special, '.') . '"; sub-prefix: "' . $this->getPrefixSpecial() . '")', E_USER_NOTICE);
+
- return ;
+ return;
}
// only for list in this case
\ No newline at end of file
Index: core/units/user_profile/user_profile_tp.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/user_profile/user_profile_tp.php (revision 15682)
+++ core/units/user_profile/user_profile_tp.php (revision )
@@ -19,7 +19,7 @@
function Field($params)
{
$field = $this->SelectParam($params, 'name,field');
- $profile_mapping = $this->Application->getUnitOption('u', 'UserProfileMapping');
+ $profile_mapping = $this->Application->getUnitConfig('u')->getUserProfileMapping();
$user_field = array_key_exists($field, $profile_mapping) ? $profile_mapping[$field] : false;
if (array_key_exists('profile_field', $params) && $params['profile_field']) {
\ No newline at end of file
Index: core/units/reviews/reviews_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/reviews/reviews_event_handler.php (revision 15682)
+++ core/units/reviews/reviews_event_handler.php (revision )
@@ -46,7 +46,8 @@
$perm_helper = $this->Application->recallObject('PermissionsHelper');
/* @var $perm_helper kPermissionsHelper */
- $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $parent_prefix = $event->getUnitConfig()->getParentPrefix();
+
$main_object = $this->Application->recallObject($parent_prefix);
/* @var $main_object kCatDBItem */
@@ -142,15 +143,17 @@
$resource_id = $this->Conn->GetOne($sql);
// 2. set main item id (for permission checks)
- $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
- $sql = 'SELECT ' . $this->Application->getUnitOption($parent_prefix, 'IDField') .'
- FROM ' . $this->Application->getUnitOption($parent_prefix, 'TableName') .'
+ $parent_prefix = $event->getUnitConfig()->getParentPrefix();
+ $parent_config = $this->Application->getUnitConfig($parent_prefix);
+
+ $sql = 'SELECT ' . $parent_config->getIDField() .'
+ FROM ' . $parent_config->getTableName() .'
WHERE ResourceId = ' . $resource_id;
$this->Application->SetVar($parent_prefix . '_id', $this->Conn->GetOne($sql));
// 3. get main item category
$sql = 'SELECT CategoryId
- FROM ' . $this->Application->getUnitOption('ci', 'TableName') .'
+ FROM ' . $this->Application->getUnitConfig('ci')->getTableName() .'
WHERE ItemResourceId = ' . $resource_id .' AND PrimaryCat = 1';
return $this->Conn->GetOne($sql);
}
@@ -165,7 +168,7 @@
$main_prefix = $this->Application->GetTopmostPrefix($event->Prefix, true);
// this will return LINK for l, ARTICLE for n, TOPIC for bb, PRODUCT for p
- return $this->Application->getUnitOption($main_prefix, 'PermItemPrefix');
+ return $this->Application->getUnitConfig($main_prefix)->getPermItemPrefix();
}
/**
@@ -209,7 +212,7 @@
if ( preg_match('/(.*)-rev/', $event->Prefix, $regs) ) {
// "Structure & Data" -> "Reviews" (section in K4)
- $item_type = $this->Application->getUnitOption($regs[1], 'ItemType');
+ $item_type = $this->Application->getUnitConfig($regs[1])->getItemType();
$object->addFilter('itemtype_filter', '%1$s.ItemType = ' . $item_type);
if ( $this->Application->isAdmin ) {
@@ -242,7 +245,8 @@
*/
function getReviewStatus($event)
{
- $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $parent_prefix = $event->getUnitConfig()->getParentPrefix();
+
$main_object = $this->Application->recallObject($parent_prefix);
/* @var $main_object kCatDBItem */
@@ -273,7 +277,7 @@
/* @var $object kDBItem */
$parent_info = $object->getLinkedInfo();
- $item_type = $this->Application->getUnitOption($parent_info['ParentPrefix'], 'ItemType');
+ $item_type = $this->Application->getUnitConfig($parent_info['ParentPrefix'])->getItemType();
$object->SetDBField('IPAddress', $this->Application->getClientIp());
$object->SetDBField('ItemType', $item_type);
@@ -350,7 +354,7 @@
$parent_info = $object->getLinkedInfo();
- $config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
+ $config_mapping = $event->getUnitConfig()->getConfigMapping();
$review_settings = $config_mapping['ReviewDelayValue'] . ':' . $config_mapping['ReviewDelayInterval'];
$spam_helper->InitHelper($parent_info['ParentId'], 'Review', $review_settings);
@@ -407,14 +411,13 @@
$object = $event->getObject();
/* @var $object kDBItem */
- $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
- $parent_table_key = $this->Application->getUnitOption($event->Prefix, 'ParentTableKey');
- $foreign_key = $this->Application->getUnitOption($event->Prefix, 'ForeignKey');
+ $config = $event->getUnitConfig();
+ $parent_prefix = $config->getParentPrefix();
$main_object = $this->Application->recallObject($parent_prefix, null, Array ('skip_autoload' => true));
/* @var $main_object kDBItem */
- $main_object->Load($object->GetDBField($foreign_key), $parent_table_key);
+ $main_object->Load($object->GetDBField($config->getForeignKey()), $config->getParentTableKey());
}
/**
@@ -432,8 +435,8 @@
$object = $event->getObject();
/* @var $object kDBItem */
- $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
- $parent_table = $this->Application->getUnitOption($parent_prefix, 'TableName');
+ $parent_prefix = $event->getUnitConfig()->getParentPrefix();
+ $parent_table = $this->Application->getUnitConfig($parent_prefix)->getTableName();
if ( $object->IsTempTable() ) {
$parent_table = $this->Application->GetTempName($parent_table, 'prefix:' . $object->Prefix);
@@ -560,7 +563,7 @@
$next_template = $object->GetDBField('Status') == STATUS_ACTIVE ? 'success_template' : 'success_pending_template';
$event->redirect = $this->Application->GetVar($next_template);
- $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $parent_prefix = $event->getUnitConfig()->getParentPrefix();
$event->SetRedirectParam('pass', 'm,'.$parent_prefix);
}
}
@@ -579,21 +582,24 @@
if (preg_match('/(.*)-rev/', $event->Prefix, $regs) && $this->Application->prefixRegistred($regs[1])) {
// "Structure & Data" -> "Reviews" (section in K4)
+ $config = $event->getUnitConfig();
+ $item_config = $this->Application->getUnitConfig($regs[1]);
+
// 1. add join to items table (for "Structure & Data" -> "Reviews" section)
- $item_table = $this->Application->getUnitOption($regs[1], 'TableName');
- $ci_table = $this->Application->getUnitOption('ci', 'TableName');
+ $item_table = $item_config->getTableName();
+ $ci_table = $this->Application->getUnitConfig('ci')->getTableName();
- $list_sqls = $this->Application->getUnitOption($event->Prefix, 'ListSQLs');
- $list_sqls[''] .= ' LEFT JOIN '.$item_table.' item_table ON item_table.ResourceId = %1$s.ItemId';
- $list_sqls[''] .= ' LEFT JOIN '.$ci_table.' ci ON item_table.ResourceId = ci.ItemResourceId AND ci.PrimaryCat = 1';
- $this->Application->setUnitOption($event->Prefix, 'ListSQLs', $list_sqls);
+ $list_sql = $config->getListSQLsBySpecial('');
+ $list_sql .= ' LEFT JOIN '.$item_table.' item_table ON item_table.ResourceId = %1$s.ItemId';
+ $list_sql .= ' LEFT JOIN '.$ci_table.' ci ON item_table.ResourceId = ci.ItemResourceId AND ci.PrimaryCat = 1';
+ $config->setListSQLsBySpecial('', $list_sql);
// 2. add calculated field
- $calculated_fields = $this->Application->getUnitOption($event->Prefix, 'CalculatedFields');
- $calculated_fields['']['CatalogItemName'] = 'item_table.' . $this->getTitleField($regs[1]);
- $calculated_fields['']['CatalogItemId'] = 'item_table.' . $this->Application->getUnitOption($regs[1], 'IDField');
- $calculated_fields['']['CatalogItemCategory'] = 'ci.CategoryId';
- $this->Application->setUnitOption($event->Prefix, 'CalculatedFields', $calculated_fields);
+ $config->addCalculatedFieldsBySpecial('', Array (
+ 'CatalogItemName' => 'item_table.' . $this->getTitleField($regs[1]),
+ 'CatalogItemId' => 'item_table.' . $item_config->getIDField(),
+ 'CatalogItemCategory' => 'ci.CategoryId',
+ ));
}
}
@@ -605,15 +611,18 @@
*/
function getTitleField($prefix)
{
+ $config = $this->Application->getUnitConfig($prefix);
$lang_prefix = 'l'.$this->Application->GetVar('m_lang').'_';
- $title_field = $this->Application->getUnitOption($prefix, 'TitleField');
- $field_options = $this->Application->getUnitOption($prefix.'.'.$title_field, 'Fields');
+ $title_field = $config->getTitleField();
+ $field_options = $config->getFieldByName($title_field);
$formatter_class = isset($field_options['formatter']) ? $field_options['formatter'] : '';
+
if ($formatter_class == 'kMultiLanguage' && !isset($field_options['master_field'])) {
$title_field = $lang_prefix.$title_field;
}
+
return $title_field;
}
@@ -628,7 +637,7 @@
{
parent::OnSetPerPage($event);
- $parent_prefix = $event->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $parent_prefix = $event->getUnitConfig()->getParentPrefix();
$event->SetRedirectParam('pass', 'm,' . $event->getPrefixSpecial() . ',' . $parent_prefix);
}
}
\ No newline at end of file
Index: core/units/favorites/favorites_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/favorites/favorites_eh.php (revision 15682)
+++ core/units/favorites/favorites_eh.php (revision )
@@ -41,32 +41,35 @@
*/
function OnFavoriteToggle($event)
{
- $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $config = $event->getUnitConfig();
+ $parent_prefix = $config->getParentPrefix();
+
$parent_object = $this->Application->recallObject($parent_prefix);
/* @var $parent_object kDBItem */
- if (!$parent_object->isLoaded() || !$this->Application->CheckPermission('FAVORITES', 0, $parent_object->GetDBField('ParentPath'))) {
+ if ( !$parent_object->isLoaded() || !$this->Application->CheckPermission('FAVORITES', 0, $parent_object->GetDBField('ParentPath')) ) {
$event->status = kEvent::erPERM_FAIL;
+
- return ;
+ return;
}
$user_id = $this->Application->RecallVar('user_id');
$sql = 'SELECT FavoriteId
- FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
+ FROM ' . $config->getTableName() . '
- WHERE (PortalUserId = '.$user_id.') AND (ResourceId = '.$parent_object->GetDBField('ResourceId').')';
+ WHERE (PortalUserId = ' . $user_id . ') AND (ResourceId = ' . $parent_object->GetDBField('ResourceId') . ')';
$favorite_id = $this->Conn->GetOne($sql);
- $object = $event->getObject(Array('skip_autoload' => true));
+ $object = $event->getObject(Array ('skip_autoload' => true));
/* @var $object kDBItem */
- if ($favorite_id) {
+ if ( $favorite_id ) {
$object->Delete($favorite_id);
}
else {
$object->Create();
}
- $event->SetRedirectParam('pass', 'm,'.$parent_prefix);
+ $event->SetRedirectParam('pass', 'm,' . $parent_prefix);
}
/**
@@ -86,25 +89,27 @@
$user_id = $this->Application->RecallVar('user_id');
$object->SetDBField('PortalUserId', $user_id);
- $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $parent_prefix = $event->getUnitConfig()->getParentPrefix();
+
$parent_object = $this->Application->recallObject($parent_prefix);
/* @var $parent_object kDBItem */
$object->SetDBField('ResourceId', $parent_object->GetDBField('ResourceId'));
- $object->SetDBField('ItemTypeId', $this->Application->getUnitOption($parent_prefix, 'ItemType'));
+ $object->SetDBField('ItemTypeId', $this->Application->getUnitConfig($parent_prefix)->getItemType());
}
/**
- * [HOOK] Deletes favorite record to item, that is beeing deleted
+ * [HOOK] Deletes favorite record to item, that is being deleted
*
* @param kEvent $event
*/
function OnDeleteFavoriteItem($event)
{
$main_object = $event->MasterEvent->getObject();
+ /* @var $main_object kDBItem */
- $sql = 'DELETE FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
+ $sql = 'DELETE FROM ' . $event->getUnitConfig()->getTableName() . '
- WHERE ResourceId = '.$main_object->GetDBField('ResourceId');
+ WHERE ResourceId = ' . $main_object->GetDBField('ResourceId');
$this->Conn->Query($sql);
}
\ No newline at end of file
Index: core/kernel/utility/temp_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/utility/temp_handler.php (revision 15682)
+++ core/kernel/utility/temp_handler.php (revision )
@@ -162,28 +162,31 @@
function BuildTables($prefix, $ids)
{
+ $this->TableIdCounter = 0;
$this->WindowID = $this->Application->GetVar('m_wid');
- $this->TableIdCounter = 0;
+ $config = $this->Application->getUnitConfig($prefix);
+
$tables = Array(
- 'TableName' => $this->Application->getUnitOption($prefix, 'TableName'),
- 'IdField' => $this->Application->getUnitOption($prefix, 'IDField'),
+ 'TableName' => $config->getTableName(),
+ 'IdField' => $config->getIDField(),
'IDs' => $ids,
'Prefix' => $prefix,
'TableId' => $this->TableIdCounter++,
);
- /*$parent_prefix = $this->Application->getUnitOption($prefix, 'ParentPrefix');
+ /*$config = $this->Application->getUnitConfig($prefix);
+ $parent_prefix = $config->getParentPrefix();
+
- if ($parent_prefix) {
+ if ( $parent_prefix ) {
- $tables['ForeignKey'] = $this->Application->getUnitOption($prefix, 'ForeignKey');
+ $tables['ForeignKey'] = $config->getForeignKey();
$tables['ParentPrefix'] = $parent_prefix;
- $tables['ParentTableKey'] = $this->Application->getUnitOption($prefix, 'ParentTableKey');
+ $tables['ParentTableKey'] = $config->getParentTableKey();
}*/
$this->FinalRefs[ $tables['TableName'] ] = $tables['TableId']; // don't forget to add main table to FinalRefs too
- $sub_items = $this->Application->getUnitOption($prefix, 'SubItems', Array ());
- /* @var $sub_items Array */
+ $sub_items = $this->Application->getUnitConfig($prefix)->getSubItems(Array ());
if ( is_array($sub_items) ) {
foreach ($sub_items as $prefix) {
@@ -230,28 +233,30 @@
return ;
}
+ $config = $this->Application->getUnitConfig($prefix);
+
$tmp = Array(
- 'TableName' => $this->Application->getUnitOption($prefix,'TableName'),
- 'IdField' => $this->Application->getUnitOption($prefix,'IDField'),
- 'ForeignKey' => $this->Application->getUnitOption($prefix,'ForeignKey'),
- 'ParentPrefix' => $this->Application->getUnitOption($prefix, 'ParentPrefix'),
- 'ParentTableKey' => $this->Application->getUnitOption($prefix,'ParentTableKey'),
+ 'TableName' => $config->getTableName(),
+ 'IdField' => $config->getIDField(),
+ 'ForeignKey' => $config->getForeignKey(),
+ 'ParentPrefix' => $config->getParentPrefix(),
+ 'ParentTableKey' => $config->getParentTableKey(),
'Prefix' => $prefix,
- 'AutoClone' => $this->Application->getUnitOption($prefix,'AutoClone'),
- 'AutoDelete' => $this->Application->getUnitOption($prefix,'AutoDelete'),
+ 'AutoClone' => $config->getAutoClone(),
+ 'AutoDelete' => $config->getAutoDelete(),
'TableId' => $this->TableIdCounter++,
);
$this->FinalRefs[ $tmp['TableName'] ] = $tmp['TableId'];
- $constrain = $this->Application->getUnitOption($prefix, 'Constrain');
+ $constrain = $config->getConstrain();
+
if ( $constrain ) {
$tmp['Constrain'] = $constrain;
$this->FinalRefs[ $tmp['TableName'] . $tmp['Constrain'] ] = $tmp['TableId'];
}
- $sub_items = $this->Application->getUnitOption($prefix, 'SubItems', Array ());
- /* @var $sub_items Array */
+ $sub_items = $config->getSubItems(Array ());
if ( is_array($sub_items) ) {
foreach ($sub_items as $prefix) {
@@ -771,12 +776,12 @@
if (array_key_exists('DependentFields', $rec)) {
// these are fields from table of $rec['Prefix'] table!
// when one of dependent fields goes into idfield of it's parent item, that was changed
- $parent_table_key = $this->Application->getUnitOption($rec['Prefix'], 'ParentTableKey');
- $parent_table_key = is_array($parent_table_key) ? $parent_table_key[$prefix] : $parent_table_key;
+ $config = $this->Application->getUnitConfig($rec['Prefix']);
+ $parent_table_key = $config->getParentTableKey($prefix);
+
if ($parent_table_key == $master['IdField']) {
- $foreign_key = $this->Application->getUnitOption($rec['Prefix'], 'ForeignKey');
- $foreign_key = is_array($foreign_key) ? $foreign_key[$prefix] : $foreign_key;
+ $foreign_key = $config->getForeignKey($prefix);
$changes[$key]['DependentFields'][$foreign_key] = $live_id;
}
@@ -861,7 +866,7 @@
$event_key = $prefix . ($special ? '.' : '') . $special . ':' . $name;
$event = new kEvent($event_key);
$event->MasterEvent = $this->parentEvent;
-
+
if ( isset($foreign_key) ) {
$event->setEventParam('foreign_key', $foreign_key);
}
@@ -905,7 +910,8 @@
function PrepareEdit()
{
$this->DoCopyLiveToTemp($this->Tables, $this->Tables['IDs']);
- if ($this->Application->getUnitOption($this->Tables['Prefix'],'CheckSimulatniousEdit')) {
+
+ if ($this->Application->getUnitConfig($this->Tables['Prefix'])->getCheckSimulatniousEdit()) {
$this->CheckSimultaniousEdit();
}
}
\ No newline at end of file
Index: core/units/helpers/image_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/image_helper.php (revision 15682)
+++ core/units/helpers/image_helper.php (revision )
@@ -609,8 +609,8 @@
return ;
}
- $table_name = $this->Application->getUnitOption('img', 'TableName');
- $max_image_count = $this->Application->getUnitOption($object->Prefix, 'ImageCount'); // $this->Application->ConfigValue($object->Prefix.'_MaxImageCount');
+ $table_name = $this->Application->getUnitConfig('img')->getTableName();
+ $max_image_count = $object->getUnitConfig()->getImageCount(); // $this->Application->ConfigValue($object->Prefix.'_MaxImageCount');
$i = 0;
while ($i < $max_image_count) {
\ No newline at end of file
Index: core/units/helpers/form_submission_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/form_submission_helper.php (revision 15682)
+++ core/units/helpers/form_submission_helper.php (revision )
@@ -36,39 +36,51 @@
* @param bool $formatted
* @param string $format
* @return string
+ * @access public
*/
- function getFieldByRole(&$form_submission, $role, $formatted = false, $format = null)
+ public function getFieldByRole(&$form_submission, $role, $formatted = false, $format = null)
{
- static $cache = Array ();
-
$form_id = $form_submission->GetDBField('FormId');
+ $field_name = $this->getFieldNameByRole($form_id, $role);
+ if ( $field_name ) {
+ return $formatted ? $form_submission->GetField($field_name, $format) : $form_submission->GetDBField($field_name);
+ }
+
+ return false;
+ }
+
+ /**
+ * Returns submission field name based on given role
+ *
+ * @param int $form_id
+ * @param string $role
+ * @return string
+ * @access public
+ */
+ public function getFieldNameByRole($form_id, $role)
+ {
+ static $cache = Array ();
+
- if (!array_key_exists($form_id, $cache)) {
+ if ( !array_key_exists($form_id, $cache) ) {
- $id_field = $this->Application->getUnitOption('formflds', 'IDField');
- $table_name = $this->Application->getUnitOption('formflds', 'TableName');
+ $config = $this->Application->getUnitConfig('formflds');
- $sql = 'SELECT ' . $id_field . ', EmailCommunicationRole
- FROM ' . $table_name . '
+ $sql = 'SELECT ' . $config->getIDField() . ', EmailCommunicationRole
+ FROM ' . $config->getTableName() . '
WHERE FormId = ' . $form_id . ' AND EmailCommunicationRole <> 0';
$cache[$form_id] = $this->Conn->GetCol($sql, 'EmailCommunicationRole');
}
// convert string representation of role to numeric
- if (!is_numeric($role)) {
+ if ( !is_numeric($role) ) {
$role = strtolower($role);
$role = array_key_exists($role, $this->roleNames) ? $this->roleNames[$role] : false;
}
- // get field by role
- $field_id = array_key_exists($role, $cache[$form_id]) ? $cache[$form_id][$role] : false;
-
- if ($field_id) {
- return $formatted ? $form_submission->GetField('fld_' . $field_id, $format) : $form_submission->GetDBField('fld_' . $field_id);
+ // get field name by role
+ return array_key_exists($role, $cache[$form_id]) ? 'fld_' . $cache[$form_id][$role] : false;
- }
+ }
- return false;
- }
-
/**
* Returns submission field based on given name
*
@@ -85,17 +97,19 @@
$form_id = $form_submission->GetDBField('FormId');
- if (!array_key_exists($form_id, $cache)) {
+ if ( !array_key_exists($form_id, $cache) ) {
- $id_field = $this->Application->getUnitOption('formflds', 'IDField');
- $table_name = $this->Application->getUnitOption('formflds', 'TableName');
+ $config = $this->Application->getUnitConfig('formflds');
- $sql = 'SELECT ' . $id_field . ', FieldName
- FROM ' . $table_name . '
+ $sql = 'SELECT ' . $config->getIDField() . ', FieldName
+ FROM ' . $config->getTableName() . '
WHERE FormId = ' . $form_id;
$cache[$form_id] = $this->Conn->GetCol($sql, 'FieldName');
}
+
+ // get field by name
+ $field_id = array_key_exists($name, $cache[$form_id]) ? $cache[$form_id][$name] : false;
- if ($field_id) {
+ if ( $field_id ) {
return $formatted ? $form_submission->GetField('fld_' . $field_id, $format) : $form_submission->GetDBField('fld_' . $field_id);
}
\ No newline at end of file
Index: core/units/forms/forms/forms_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/forms/forms/forms_eh.php (revision 15682)
+++ core/units/forms/forms/forms_eh.php (revision )
@@ -35,50 +35,50 @@
$this->permMapping = array_merge($this->permMapping, $permissions);
}
- function OnCreateSubmissionNodes($event)
+ protected function OnCreateSubmissionNodes(kEvent $event)
{
- if (defined('IS_INSTALL') && IS_INSTALL) {
+ if ( defined('IS_INSTALL') && IS_INSTALL ) {
// skip any processing, because Forms table doesn't exists until install is finished
- return ;
+ return;
}
$forms = $this->getForms();
- if (!$forms) {
+ if ( !$forms ) {
- return ;
+ return;
}
- $form_subsection = Array(
+ $form_subsection = Array (
- 'parent' => 'in-portal:forms',
+ 'parent' => 'in-portal:forms',
- 'icon' => 'form_submission',
+ 'icon' => 'form_submission',
- 'label' => '',
+ 'label' => '',
- 'url' => Array('t' => 'submissions/submissions_list', 'pass' => 'm,form'),
+ 'url' => Array ('t' => 'submissions/submissions_list', 'pass' => 'm,form'),
- 'permissions' => Array('view', 'add', 'edit', 'delete'),
+ 'permissions' => Array ('view', 'add', 'edit', 'delete'),
- 'priority' => 1,
+ 'priority' => 1,
- 'type' => stTREE,
+ 'type' => stTREE,
);
$priority = 1;
- $sections = $this->Application->getUnitOption($event->Prefix, 'Sections');
+ $config = $event->getUnitConfig();
foreach ($forms as $form_id => $form_name) {
$this->Application->Phrases->AddCachedPhrase('form_sub_label_'.$form_id, $form_name);
$this->Application->Phrases->AddCachedPhrase('la_description_in-portal:submissions:'.$form_id, $form_name.' Submissions');
+
$form_subsection['label'] = 'form_sub_label_'.$form_id;
$form_subsection['url']['form_id'] = $form_id;
$form_subsection['priority'] = $priority++;
- $sections['in-portal:submissions:'.$form_id] = $form_subsection;
- }
- $this->Application->setUnitOption($event->Prefix, 'Sections', $sections);
+ $config->addSections($form_subsection, 'in-portal:submissions:' . $form_id);
- }
+ }
+ }
- function getForms()
+ protected function getForms()
{
$cache_key = 'forms[%FormSerial%]';
$forms = $this->Application->getCache($cache_key);
- if ($forms === false) {
+ if ( $forms === false ) {
$this->Conn->nextQueryCachable = true;
$sql = 'SELECT Title, FormId
FROM ' . TABLE_PREFIX . 'Forms
@@ -184,11 +184,11 @@
$object = $event->getObject();
/* @var $object kDBItem */
- $fields = explode(',',$this->Application->GetVar('fields'));
+ $fields = explode(',', $this->Application->GetVar('fields'));
$required_fields = explode(',', $this->Application->GetVar('required_fields'));
$fields_params = $this->Application->GetVar('fields_params');
- $virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields');
+ $virtual_fields = $event->getUnitConfig()->getVirtualFields();
foreach ($fields as $field) {
$virtual_fields[$field] = Array ();
@@ -218,7 +218,7 @@
$checkboxes = explode(',', $this->Application->GetVar('checkbox_fields')); // MailingList,In-Link,In-Newz,In-Bulletin
foreach ($checkboxes as $checkbox) {
- if (isset($field_values[$checkbox])) {
+ if ( isset($field_values[$checkbox]) ) {
$field_values[$checkbox] = 1;
}
else {
@@ -415,15 +415,13 @@
*/
function _processMailbox($event, $bounce_mode = false)
{
+ $config = $event->getUnitConfig();
$this->Application->SetVar('client_mode', 1);
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
-
$sql = 'SELECT *
- FROM ' . $table_name . '
+ FROM ' . $config->getTableName() . '
WHERE EnableEmailCommunication = 1';
- $forms = $this->Conn->Query($sql, $id_field);
+ $forms = $this->Conn->Query($sql, $config->getIDField());
$mailbox_helper = $this->Application->recallObject('MailboxHelper');
/* @var $mailbox_helper MailboxHelper */
@@ -433,7 +431,7 @@
foreach ($forms as $form_id => $form_info) {
$recipient_email = $bounce_mode ? $form_info['BounceEmail'] : $form_info['ReplyFromEmail'];
- if (!$recipient_email) {
+ if ( !$recipient_email ) {
continue;
}
@@ -487,13 +485,13 @@
function processEmail($params, &$fields_hash)
{
- if ($params['bounce_mode']) {
+ if ( $params['bounce_mode'] ) {
// mark original message as bounced
$mailbox_helper = $this->Application->recallObject('MailboxHelper');
/* @var $mailbox_helper MailboxHelper */
- if (!array_key_exists('attachments', $mailbox_helper->parsedMessage)) {
+ if ( !array_key_exists('attachments', $mailbox_helper->parsedMessage) ) {
// for now only parse bounces based on attachments, skip other bounce types
return false;
}
@@ -501,13 +499,13 @@
for ($i = 0; $i < count($mailbox_helper->parsedMessage['attachments']); $i++) {
$attachment =& $mailbox_helper->parsedMessage['attachments'][$i];
- switch ($attachment['headers']['content-type']) {
+ switch ( $attachment['headers']['content-type'] ) {
case 'message/delivery-status':
// save as BounceInfo
$mime_decode_helper = $this->Application->recallObject('MimeDecodeHelper');
/* @var $mime_decode_helper MimeDecodeHelper */
- $charset = $mailbox_helper->parsedMessage[ $fields_hash['MessageType'] ][0]['charset'];
+ $charset = $mailbox_helper->parsedMessage[$fields_hash['MessageType']][0]['charset'];
$fields_hash['Message'] = $mime_decode_helper->convertEncoding($charset, $attachment['data']);
break;
@@ -519,21 +517,23 @@
}
}
- if (!preg_match('/^(.*) #verify(.*)$/', $fields_hash['Subject'], $regs)) {
+ if ( !preg_match('/^(.*) #verify(.*)$/', $fields_hash['Subject'], $regs) ) {
// incorrect subject, no verification code
$form_info = $params['form_info'];
- if ($form_info['ProcessUnmatchedEmails'] && ($fields_hash['FromEmail'] != $params['recipient_email'])) {
+ if ( $form_info['ProcessUnmatchedEmails'] && ($fields_hash['FromEmail'] != $params['recipient_email']) ) {
// it's requested to convert unmatched emails to new submissions
$form_id = $form_info['FormId'];
$this->Application->SetVar('form_id', $form_id);
- $sql = 'SELECT ' . $this->Application->getUnitOption('formsubs', 'IDField') . '
- FROM ' . $this->Application->getUnitOption('formsubs', 'TableName') . '
+ $form_submission_config = $this->Application->getUnitConfig('formsubs');
+
+ $sql = 'SELECT ' . $form_submission_config->getIDField() . '
+ FROM ' . $form_submission_config->getTableName() . '
WHERE MessageId = ' . $this->Conn->qstr($fields_hash['MessageId']);
$found = $this->Conn->GetOne($sql);
- if ($found) {
+ if ( $found ) {
// don't process same message twice
return false;
}
@@ -554,12 +554,12 @@
$submission_fields = Array ();
foreach ($role_mapping as $role => $email_field) {
- if (array_key_exists($role, $form_fields)) {
+ if ( array_key_exists($role, $form_fields) ) {
- $submission_fields[ 'fld_' . $form_fields[$role]['FormFieldId'] ] = $fields_hash[$email_field];
+ $submission_fields['fld_' . $form_fields[$role]['FormFieldId']] = $fields_hash[$email_field];
}
}
- if ($submission_fields) {
+ if ( $submission_fields ) {
// remove object, because it's linked to single form upon creation forever
$this->Application->removeObject('formsubs.-item');
@@ -574,6 +574,7 @@
$form_submission->SetDBField('SubmissionTime_date', adodb_mktime());
$form_submission->SetDBField('SubmissionTime_time', adodb_mktime());
$form_submission->SetDBField('ReferrerURL', $this->Application->Phrase('la_Text_Email'));
+
return $form_submission->Create();
}
}
@@ -581,12 +582,14 @@
return false;
}
- $sql = 'SELECT ' . $this->Application->getUnitOption('submission-log', 'IDField') . '
- FROM ' . $this->Application->getUnitOption('submission-log', 'TableName') . '
+ $submission_log_config = $this->Application->getUnitConfig('submission-log');
+
+ $sql = 'SELECT ' . $submission_log_config->getIDField() . '
+ FROM ' . $submission_log_config->getTableName() . '
WHERE MessageId = ' . $this->Conn->qstr($fields_hash['MessageId']);
$found = $this->Conn->GetOne($sql);
- if ($found) {
+ if ( $found ) {
// don't process same message twice
return false;
}
@@ -595,12 +598,13 @@
/* @var $reply_to kDBItem */
$reply_to->Load($regs[2], 'VerifyCode');
+
- if (!$reply_to->isLoaded()) {
+ if ( !$reply_to->isLoaded() ) {
// fake verification code OR feedback, containing submission log was deleted
return false;
}
- if ($params['bounce_mode']) {
+ if ( $params['bounce_mode'] ) {
// mark original message as bounced
$reply_to->SetDBField('BounceInfo', $fields_hash['Message']);
$reply_to->SetDBField('BounceDate_date', TIMENOW);
\ No newline at end of file
Index: core/units/files/file_tp.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/files/file_tp.php (revision 15682)
+++ core/units/files/file_tp.php (revision )
@@ -18,8 +18,8 @@
function DownloadFileLink($params)
{
- $params[$this->getPrefixSpecial().'_event'] = 'OnDownloadFile';
+ $params[$this->getPrefixSpecial() . '_event'] = 'OnDownloadFile';
- $params['pass'] = 'm,'.$this->Application->getUnitOption($this->Prefix, 'ParentPrefix').','.$this->getPrefixSpecial();
+ $params['pass'] = 'm,' . $this->getUnitConfig()->getParentPrefix() . ',' . $this->getPrefixSpecial();
return $this->ItemLink($params);
}
\ No newline at end of file
Index: core/units/forms/form_submissions/form_submissions_eh.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/forms/form_submissions/form_submissions_eh.php (revision 15682)
+++ core/units/forms/form_submissions/form_submissions_eh.php (revision )
@@ -81,14 +81,16 @@
return $mapping[$element_type];
}
- function OnBuildFormFields($event)
+ protected function OnBuildFormFields(kEvent $event)
{
$form_id = $this->Application->GetVar('form_id');
- if (!$form_id) return ;
- $conf_fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
- $conf_grids = $this->Application->getUnitOption($event->Prefix, 'Grids');
+ if ( !$form_id ) {
+ return;
+ }
+ $config = $event->getUnitConfig();
+
$helper = $this->Application->recallObject('InpCustomFieldsHelper');
/* @var $helper InpCustomFieldsHelper */
@@ -103,57 +105,59 @@
foreach ($fields as $field_id => $options) {
$field_visible = $check_visibility ? $options['Visibility'] == SubmissionFormField::VISIBILITY_EVERYONE : true;
- $field_options = Array('type' => 'string', 'default' => $options['DefaultValue']);
+ $field_options = Array ('type' => 'string', 'default' => $options['DefaultValue']);
- if ($options['Required'] && $field_visible) {
+ if ( $options['Required'] && $field_visible ) {
$field_options['required'] = 1;
}
- if ($options['Validation'] == 1) {
+ if ( $options['Validation'] == 1 ) {
$field_options['formatter'] = 'kFormatter';
$field_options['regexp'] = '/^(' . REGEX_EMAIL_USER . '@' . REGEX_EMAIL_DOMAIN . ')$/i';
}
- if ($options['DisplayInGrid']) {
+ if ( $options['DisplayInGrid'] ) {
$title = $options['Prompt'];
- if (substr($title, 0, 1) == '+') {
+ if ( substr($title, 0, 1) == '+' ) {
$this->Application->Phrases->AddCachedPhrase('form_col_title' . $field_id, substr($title, 1));
$title = 'form_col_title' . $field_id;
}
- $conf_grids['Default']['Fields']['fld_' . $field_id] = Array (
+ $grid_field_options = Array (
'title' => $title, 'no_special' => 1, 'nl2br' => 1, 'first_chars' => 200,
'filter_block' => $this->_getFilterBlock($options['ElementType'])
);
- if ($options['ElementType'] == 'upload') {
+ if ( $options['ElementType'] == 'upload' ) {
- $conf_grids['Default']['Fields']['fld_' . $field_id]['data_block'] = 'grid_upload_td';
+ $grid_field_options['data_block'] = 'grid_upload_td';
}
- if ($options['Validation'] == 1) {
+ if ( $options['Validation'] == 1 ) {
- $conf_grids['Default']['Fields']['fld_' . $field_id]['data_block'] = 'grid_email_td';
+ $grid_field_options['data_block'] = 'grid_email_td';
}
+
+ $config->addGridFields('Default', $grid_field_options, 'fld_' . $field_id);
}
- if ($options['ElementType'] == 'checkbox' && !$options['ValueList']) {
+ if ( $options['ElementType'] == 'checkbox' && !$options['ValueList'] ) {
// fix case, when user haven't defined any options for checkbox
$options['ValueList'] = '1=la_Yes||0=la_No';
}
- if (in_array($options['ElementType'], $use_options) && $options['ValueList']) {
+ if ( in_array($options['ElementType'], $use_options) && $options['ValueList'] ) {
// field type can have options and user have defined them too
- $field_options['options'] = $helper->GetValuesHash( $options['ValueList'] );
+ $field_options['options'] = $helper->GetValuesHash($options['ValueList']);
$field_options['formatter'] = 'kOptionsFormatter';
}
- if ($options['ElementType'] == 'password') {
+ if ( $options['ElementType'] == 'password' ) {
$field_options['formatter'] = 'kPasswordFormatter';
$field_options['hashing_method'] = PasswordHashingMethod::NONE;
$field_options['verify_field'] = 'fld_' . $field_id . '_verify';
}
- if ($options['ElementType'] == 'upload') {
+ if ( $options['ElementType'] == 'upload' ) {
$field_options['formatter'] = 'kUploadFormatter';
$field_options['upload_dir'] = WRITEBALE_BASE . DIRECTORY_SEPARATOR . 'user_files' . DIRECTORY_SEPARATOR . 'form_submissions';
@@ -166,11 +170,8 @@
}
}
- $conf_fields['fld_' . $field_id] = $field_options;
+ $config->addFields($field_options, 'fld_' . $field_id);
}
-
- $this->Application->setUnitOption($event->Prefix, 'Fields', $conf_fields);
- $this->Application->setUnitOption($event->Prefix, 'Grids', $conf_grids);
}
/**
@@ -406,7 +407,7 @@
/* @var $object kDBItem */
$form_id = $object->GetDBField('FormId');
- $email_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_EMAIL);
+ $email_field = $this->getFieldNameByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_EMAIL);
if (!$email_field) {
return ;
@@ -427,8 +428,8 @@
$options = Array ();
- $name_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_NAME);
- $subject_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_SUBJECT);
+ $name_field = $this->getFieldNameByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_NAME);
+ $subject_field = $this->getFieldNameByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_SUBJECT);
$language = $this->Application->recallObject('lang.current');
/* @var $language kDBItem */
@@ -465,25 +466,16 @@
* @param int $form_id
* @param string $role
* @return string
+ * @see FormSubmissionHelper::getFieldByRole()
*/
- function getFieldByRole($form_id, $role)
+ function getFieldNameByRole($form_id, $role)
{
- static $cache = Array ();
+ $form_submission_helper = $this->Application->recallObject('FormSubmissionHelper');
+ /* @var $form_submission_helper FormSubmissionHelper */
- if (!array_key_exists($form_id, $cache)) {
- $id_field = $this->Application->getUnitOption('formflds', 'IDField');
- $table_name = $this->Application->getUnitOption('formflds', 'TableName');
-
- $sql = 'SELECT ' . $id_field . ', EmailCommunicationRole
- FROM ' . $table_name . '
- WHERE FormId = ' . $form_id . ' AND EmailCommunicationRole <> 0';
- $cache[$form_id] = $this->Conn->GetCol($sql, 'EmailCommunicationRole');
+ return $form_submission_helper->getFieldNameByRole($form_id, $role);
- }
+ }
- // get field name by role
- return array_key_exists($role, $cache[$form_id]) ? 'fld_' . $cache[$form_id][$role] : false;
- }
-
/**
* Performs submission merge
*
@@ -515,9 +507,9 @@
$reply = $this->Application->recallObject('submission-log.merge', null, Array ('skip_autoload' => true));
/* @var $reply kDBItem */
- $email_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_EMAIL);
- $subject_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_SUBJECT);
- $body_field = $this->getFieldByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_BODY);
+ $email_field = $this->getFieldNameByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_EMAIL);
+ $subject_field = $this->getFieldNameByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_SUBJECT);
+ $body_field = $this->getFieldNameByRole($form_id, SubmissionFormField::COMMUNICATION_ROLE_BODY);
$reply->SetDBField('FormSubmissionId', $merge_to);
\ No newline at end of file
Index: core/units/images/image_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/images/image_event_handler.php (revision 15682)
+++ core/units/images/image_event_handler.php (revision )
@@ -347,7 +347,7 @@
$object->removeFilter('parent_filter');
$sql = 'SELECT ResourceId
- FROM ' . $this->Application->getUnitOption('p', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('p')->getTableName() . '
WHERE ProductId = ' . $product_id;
$resource_id = (int)$this->Conn->GetOne($sql);
@@ -389,7 +389,7 @@
function OnCleanImages($event)
{
// 1. get images, that are currently in use
- $active_images = $this->_getActiveImages( $this->Application->getUnitOption('img', 'TableName') );
+ $active_images = $this->_getActiveImages( $this->Application->getUnitConfig('img')->getTableName() );
$active_images[] = 'noimage.gif';
// 2. get images on disk
\ No newline at end of file
Index: core/units/helpers/country_states_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/country_states_helper.php (revision 15682)
+++ core/units/helpers/country_states_helper.php (revision )
@@ -25,8 +25,8 @@
{
static $cache = null;
- if (!isset($cache)) {
+ if ( !isset($cache) ) {
- $table_name = $this->Application->getUnitOption('country-state', 'TableName');
+ $table_name = $this->Application->getUnitConfig('country-state')->getTableName();
$sql = 'SELECT DISTINCT cname.IsoCode, cid.StateCountryId
FROM ' . $table_name . ' cid
@@ -106,7 +106,7 @@
$primary_language = $this->Application->GetDefaultLanguageId();
$sql = 'SELECT IF(l' . $current_language . '_Name = "", l' . $primary_language . '_Name, l' . $current_language . '_Name) AS Name, IsoCode
- FROM ' . $this->Application->getUnitOption('country-state', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('country-state')->getTableName() . '
WHERE (Type = ' . DESTINATION_TYPE_STATE . ') AND (StateCountryId = ' . $country_id . ')
ORDER BY Name ASC';
@@ -122,11 +122,11 @@
*/
function getStateIso($state_name, $country_iso)
{
- if (!$this->CountryHasStates($country_iso)) {
+ if ( !$this->CountryHasStates($country_iso) ) {
return $state_name;
}
- $table_name = $this->Application->getUnitOption('country-state', 'TableName');
+ $table_name = $this->Application->getUnitConfig('country-state')->getTableName();
$country_id = $this->getCountryStateId($country_iso, DESTINATION_TYPE_COUNTRY);
// don't use GetVar('m_lang') since it's always equals to default language on editing form in admin
@@ -140,7 +140,7 @@
(IsoCode = %2$s) OR (UPPER(l%3$s_Name) = %2$s) OR (UPPER(l%4$s_Name) = %2$s)
)';
- $state_name = trim( mb_strtoupper($state_name) );
+ $state_name = trim(mb_strtoupper($state_name));
$sql = sprintf($sql, $country_id, $this->Conn->qstr($state_name), $current_language, $primary_language);
return $this->Conn->GetOne($sql);
@@ -191,8 +191,10 @@
*/
function getCountryStateId($iso_code, $type)
{
- $sql = 'SELECT ' . $this->Application->getUnitOption('country-state', 'IDField') . '
- FROM ' . $this->Application->getUnitOption('country-state', 'TableName') . '
+ $config = $this->Application->getUnitConfig('country-state');
+
+ $sql = 'SELECT ' . $config->getIDField() . '
+ FROM ' . $config->getTableName() . '
WHERE (Type = ' . $type . ') AND (IsoCode = ' . $this->Conn->qstr($iso_code) . ')';
return (int)$this->Conn->GetOne($sql);
\ No newline at end of file
Index: core/units/relationship/relationship_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/relationship/relationship_event_handler.php (revision 15682)
+++ core/units/relationship/relationship_event_handler.php (revision )
@@ -51,8 +51,8 @@
$table_info = $object->getLinkedInfo();
$object->SetDBField('SourceId', $table_info['ParentId']);
- $source_itemtype = $this->Application->getUnitOption($table_info['ParentPrefix'], 'ItemType');
- $object->SetDBField('SourceType', $source_itemtype);
+ $source_item_type = $this->Application->getUnitConfig($table_info['ParentPrefix'])->getItemType();
+ $object->SetDBField('SourceType', $source_item_type);
$object->SetDBField('TargetId', $this->Application->GetVar('target_id'));
$object->SetDBField('TargetType', $this->Application->GetVar('target_type'));
@@ -89,11 +89,13 @@
return;
}
+ $target_config = $this->Application->getUnitConfig($target_prefix);
+
$sql = 'SELECT ResourceId
- FROM ' . $this->Application->getUnitOption($target_prefix, 'TableName') . '
- WHERE ' . $this->Application->getUnitOption($target_prefix, 'IDField') . ' IN (' . $target_id . ')';
+ FROM ' . $target_config->getTableName() . '
+ WHERE ' . $target_config->getIDField() . ' IN (' . $target_id . ')';
$target_id = $this->Conn->GetOne($sql);
- $target_type = $this->Application->getUnitOption($target_prefix, 'ItemType');
+ $target_type = $target_config->getItemType();
// don't add same relation twice
$table_info = $object->getLinkedInfo();
@@ -106,8 +108,8 @@
if ( !$duplicate_relation ) {
// place correct template in opener stack
- $source_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
- $template = $this->Application->getUnitOption($source_prefix, 'AdminTemplatePath') . '/relations_edit';
+ $source_prefix = $event->getUnitConfig()->getParentPrefix();
+ $template = $this->Application->getUnitConfig($source_prefix)->getAdminTemplatePath() . '/relations_edit';
$redirect_params = Array (
$event->Prefix . '_event' => 'OnNew',
@@ -142,13 +144,13 @@
$sql = 'SELECT Prefix
FROM ' . TABLE_PREFIX . 'ItemTypes
WHERE ItemType = ' . $object->GetDBField('TargetType');
- $target_prefix = $this->Conn->GetOne($sql);
+ $target_config = $this->Application->getUnitConfig($this->Conn->GetOne($sql));
- $title_field = $this->getTitleField($target_prefix);
- $title_phrase = $this->Application->getUnitOption($target_prefix, 'TitlePhrase');
+ $title_field = $this->getTitleField($target_config);
+ $title_phrase = $target_config->getTitlePhrase();
$sql = 'SELECT ' . $title_field . '
- FROM ' . $this->Application->getUnitOption($target_prefix, 'TableName') . '
+ FROM ' . $target_config->getTableName() . '
WHERE ResourceId = ' . $object->GetDBField('TargetId');
$object->SetDBField('ItemName', $this->Conn->GetOne($sql));
@@ -193,7 +195,7 @@
*/
function BaseQuery($event, $sql_field)
{
- $sqls = $this->Application->getUnitOption($event->Prefix,$sql_field);
+ $sqls = $event->getUnitConfig()->getSetting($sql_field);
$sql = isset($sqls[$event->Special]) ? $sqls[$event->Special] : $sqls[''];
$configs = $this->extractModulesInfo();
@@ -203,25 +205,23 @@
$sql_templates['TableJoin'] = 'LEFT JOIN %1$s ON %1$s.ResourceId = rel.TargetId';
$sql_templates['TargetName'] = 'IF(rel.TargetType = %s, \'%s\', %s)';
- $sql_parts = Array();
+ $sql_parts = Array ();
$sql_parts['TargetName'] = "''";
- foreach ($configs as $prefix => $config_data) {
- $title_field = $this->getTitleField($prefix);
- $sql_parts['ItemName'][] = sprintf($sql_templates['ItemName'], $config_data['TableName'], $title_field);
- $sql_parts['TableJoin'][] = sprintf($sql_templates['TableJoin'], $config_data['TableName']);
+ foreach ($configs as $config) {
+ $title_field = $this->getTitleField($config);
- $sql_parts['TargetName'] = sprintf( $sql_templates['TargetName'],
- $config_data['ItemType'],
- '!'.$config_data['TitlePhrase'].'!',
- $sql_parts['TargetName']);
+ $sql_parts['ItemName'][] = sprintf($sql_templates['ItemName'], $config->getTableName(), $title_field);
+ $sql_parts['TableJoin'][] = sprintf($sql_templates['TableJoin'], $config->getTableName());
+
+ $sql_parts['TargetName'] = sprintf($sql_templates['TargetName'], $config->getItemType(), '!' . $config->getTitlePhrase() . '!', $sql_parts['TargetName']);
- $sql_parts['TargetName'] = str_replace('rel','%1$s',$sql_parts['TargetName']);
+ $sql_parts['TargetName'] = str_replace('rel', '%1$s', $sql_parts['TargetName']);
}
$object = $event->getObject();
- $vars = Array('#ITEM_NAMES#', '#ITEM_TYPES#');
+ $vars = Array ('#ITEM_NAMES#', '#ITEM_TYPES#');
- $replacements = Array( implode(', ',$sql_parts['ItemName']), $sql_parts['TargetName'] );
+ $replacements = Array (implode(', ', $sql_parts['ItemName']), $sql_parts['TargetName']);
$calculated_fields = $object->getCalculatedFields();
@@ -231,8 +231,8 @@
$object->setCalculatedFields($calculated_fields);
- $sql = str_replace('#ITEM_JOIN#', implode(' ',$sql_parts['TableJoin']), $sql);
+ $sql = str_replace('#ITEM_JOIN#', implode(' ', $sql_parts['TableJoin']), $sql);
- $sql = str_replace('rel.','%1$s.',$sql);
+ $sql = str_replace('rel.', '%1$s.', $sql);
return $sql;
}
@@ -240,48 +240,58 @@
/**
* Convert TitleField field of kMultiLanguage formatter used for it
*
- * @param string $prefix
+ * @param kUnitConfig $config
* @return string
*/
- function getTitleField($prefix)
+ function getTitleField(kUnitConfig $config)
{
- $lang_prefix = 'l'.$this->Application->GetVar('m_lang').'_';
+ $lang_prefix = 'l' . $this->Application->GetVar('m_lang') . '_';
- $title_field = $this->Application->getUnitOption($prefix, 'TitleField');
- $field_options = $this->Application->getUnitOption($prefix.'.'.$title_field, 'Fields');
+ $title_field = $config->getTitleField();
+ $field_options = $config->getFieldByName($title_field);
$formatter_class = isset($field_options['formatter']) ? $field_options['formatter'] : '';
+
- if ($formatter_class == 'kMultiLanguage' && !isset($field_options['master_field'])) {
+ if ( $formatter_class == 'kMultiLanguage' && !isset($field_options['master_field']) ) {
- $title_field = $lang_prefix.$title_field;
+ $title_field = $lang_prefix . $title_field;
}
+
return $title_field;
}
/**
* Get configs from modules installed
*
- * @return Array
+ * @return Array|kUnitConfig[]
* @access private
*/
function extractModulesInfo()
{
// get installed modules & their config info
// maybe we should leave only prefixes, that have "view" permission
- $configs = Array();
- foreach ($this->Application->ModuleInfo as $module_name => $module_data) {
+ $ret = Array ();
+
+ foreach ($this->Application->ModuleInfo as $module_data) {
$prefix = $module_data['Var'];
+
- if ($prefix == 'm') {
+ if ( $prefix == 'm' ) {
$prefix = 'c';
}
- if (!$this->Application->prefixRegistred($prefix)) continue;
- $configs[$prefix] = $this->Application->getUnitOptions($prefix);
- if($configs[$prefix] === false) unset($configs[$prefix]);
- if(!isset($configs[$prefix]['CatalogItem']) || !$configs[$prefix]['CatalogItem']) unset($configs[$prefix]);
+ if ( !$this->Application->prefixRegistred($prefix) ) {
+ continue;
- }
+ }
- return $configs;
+
+ $config = $this->Application->getUnitConfig($prefix);
+
+ if ( $config->getCatalogItem() ) {
+ $ret[$prefix] = $config;
- }
+ }
+ }
+ return $ret;
+ }
+
/**
* Deletes relations to hooked item from other items
*
@@ -292,7 +302,7 @@
$main_object = $event->MasterEvent->getObject();
/* @var $main_object kDBItem */
- $sql = 'DELETE FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ $sql = 'DELETE FROM ' . $event->getUnitConfig()->getTableName() . '
WHERE TargetId = ' . $main_object->GetDBField('ResourceId');
$this->Conn->Query($sql);
}
\ No newline at end of file
Index: core/units/helpers/controls/edit_picker_helper.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/helpers/controls/edit_picker_helper.php (revision 15682)
+++ core/units/helpers/controls/edit_picker_helper.php (revision )
@@ -16,11 +16,11 @@
class EditPickerHelper extends kHelper {
-
- function getTable($prefix, $temp=false)
+ function getTable($prefix, $temp = false)
{
- $table_name = $this->Application->getUnitOption($prefix, 'TableName');
+ $table_name = $this->Application->getUnitConfig($prefix)->getTableName();
+
- return $temp ? $this->Application->GetTempName($table_name, 'prefix:'.$prefix) : $table_name;
+ return $temp ? $this->Application->GetTempName($table_name, 'prefix:' . $prefix) : $table_name;
}
/**
@@ -78,7 +78,7 @@
/* @var $object kDBItem */
list ($sub_prefix, $sub_prefix_field) = explode('.', $source_field);
- $foreign_key = $this->Application->getUnitOption($sub_prefix, 'ForeignKey');
+ $foreign_key = $this->Application->getUnitConfig($sub_prefix)->getForeignKey();
$sql = 'SELECT '.$sub_prefix_field.'
FROM '.$this->getTable($sub_prefix, $object->IsTempTable()).'
@@ -112,7 +112,7 @@
/* @var $object kDBItem */
$sub_table = $object->TableName;
- $foreign_key = $this->Application->getUnitOption($sub_event->Prefix, 'ForeignKey');
+ $foreign_key = $sub_event->getUnitConfig()->getForeignKey();
// 1. get previous values from db
$sql = 'SELECT ' . $sub_prefix_field . '
\ No newline at end of file
Index: core/units/thesaurus/thesaurus_tp.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/thesaurus/thesaurus_tp.php (revision 15682)
+++ core/units/thesaurus/thesaurus_tp.php (revision )
@@ -31,7 +31,7 @@
function _getThesaurusRecords()
{
$keywords = htmlspecialchars_decode( trim($this->Application->GetVar('keywords')) );
- $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $table_name = $this->getUnitConfig()->getTableName();
$sql = 'SELECT *
FROM ' . $table_name . '
Index: core/units/categories/categories_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/categories/categories_event_handler.php (revision 15682)
+++ core/units/categories/categories_event_handler.php (revision )
@@ -187,8 +187,9 @@
function _getPermissionCheckInfo($event)
{
// when saving data from temp table to live table check by data from temp table
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $config = $event->getUnitConfig();
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
if ($event->Name == 'OnSave') {
$table_name = $this->Application->GetTempName($table_name, 'prefix:' . $event->Prefix);
@@ -360,6 +361,8 @@
$except_types = $event->getEventParam('except');
$except_types = $except_types ? explode(',', $except_types) : Array ();
+ $config = $event->getUnitConfig();
+
if (in_array('related', $types) || in_array('related', $except_types)) {
$related_to = $event->getEventParam('related_to');
if (!$related_to) {
@@ -372,8 +375,8 @@
$related_prefix = $this->Conn->GetOne($sql);
}
- $rel_table = $this->Application->getUnitOption('rel', 'TableName');
- $item_type = (int)$this->Application->getUnitOption($event->Prefix, 'ItemType');
+ $rel_table = $this->Application->getUnitConfig('rel')->getTableName();
+ $item_type = (int)$config->getItemType();
if ($item_type == 0) {
trigger_error('ItemType not defined for prefix ' . $event->Prefix . '', E_USER_WARNING);
@@ -451,7 +454,7 @@
if (in_array('category_related', $type_clauses)) {
$object->removeFilter('parent_filter');
$resource_id = $this->Conn->GetOne('
- SELECT ResourceId FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
+ SELECT ResourceId FROM '.$config->getTableName().'
WHERE CategoryId = '.$parent_cat_id
);
@@ -482,18 +485,24 @@
$object->removeFilter('parent_filter');
$product_id = $event->getEventParam('product_id') ? $event->getEventParam('product_id') : $this->Application->GetVar('p_id');
- $resource_id = $this->Conn->GetOne('
- SELECT ResourceId FROM '.$this->Application->getUnitOption('p', 'TableName').'
- WHERE ProductId = '.$product_id
- );
- $sql = 'SELECT DISTINCT(TargetId) FROM '.TABLE_PREFIX.'CatalogRelationships
+ $sql = 'SELECT ResourceId
+ FROM ' . $this->Application->getUnitConfig('p')->getTableName() . '
+ WHERE ProductId = ' . $product_id;
+ $resource_id = $this->Conn->GetOne($sql);
+
+ $sql = 'SELECT DISTINCT(TargetId)
+ FROM ' . TABLE_PREFIX . 'CatalogRelationships
WHERE SourceId = '.$resource_id.' AND TargetType = 1';
$related_cats = $this->Conn->GetCol($sql);
+
$related_cats = is_array($related_cats) ? $related_cats : Array();
- $sql = 'SELECT DISTINCT(SourceId) FROM '.TABLE_PREFIX.'CatalogRelationships
+
+ $sql = 'SELECT DISTINCT(SourceId)
+ FROM ' . TABLE_PREFIX . 'CatalogRelationships
WHERE TargetId = '.$resource_id.' AND SourceType = 1 AND Type = 1';
$related_cats2 = $this->Conn->GetCol($sql);
+
$related_cats2 = is_array($related_cats2) ? $related_cats2 : Array();
$related_cats = array_unique( array_merge( $related_cats2, $related_cats ) );
@@ -617,10 +626,11 @@
// bug: when template contains "-" symbols (or others, that stripDisallowed will replace) it's not found
if ( !array_key_exists($template, $page_by_template) ) {
+ $config = $event->getUnitConfig();
$template_crc = kUtil::crc32(mb_strtolower($template));
- $sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . '
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ $sql = 'SELECT ' . $config->getIDField() . '
+ FROM ' . $config->getTableName() . '
WHERE
(
(NamedParentPathHash = ' . $template_crc . ') OR
@@ -907,12 +917,14 @@
*/
function _getCategoryStatus($category_ids)
{
- $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $config = $this->getUnitConfig();
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
$sql = 'SELECT Status, ' . $id_field . '
FROM ' . $table_name . '
WHERE ' . $id_field . ' IN (' . implode(',', $category_ids) . ')';
+
return $this->Conn->GetCol($sql, $id_field);
}
@@ -1194,8 +1206,9 @@
// 1. get ParentId of moved category(-es) before it gets updated!!!)
$source_category_id = 0;
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $config = $event->getUnitConfig();
+ $id_field = $config->getIDField();
+ $table_name = $config->getTableName();
if ( $clipboard_data['cut'] ) {
$sql = 'SELECT ParentId
@@ -1290,12 +1303,14 @@
if($inp_clipboard[0] == 'COPY')
{
- $saved_cat_id = $this->Application->GetVar('m_cat_id');
+ $config = $event->getUnitConfig();
$cat_ids = $event->getEventParam('cat_ids');
+ $saved_cat_id = $this->Application->GetVar('m_cat_id');
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $table = $this->Application->getUnitOption($event->Prefix, 'TableName');
- $ids_sql = 'SELECT '.$id_field.' FROM '.$table.' WHERE ResourceId IN (%s)';
+ $ids_sql = 'SELECT ' . $config->getIDField() . '
+ FROM ' . $config->getTableName() . '
+ WHERE ResourceId IN (%s)';
+
$resource_ids_sql = 'SELECT ItemResourceId FROM '.TABLE_PREFIX.'CategoryItems WHERE CategoryId = %s AND PrimaryCat = 1';
$object = $this->Application->recallObject($event->Prefix.'.item', $event->Prefix, Array('skip_autoload' => true));
@@ -1447,7 +1462,7 @@
$event->SetRedirectParam('opener', 's');
// send email events
- $perm_prefix = $this->Application->getUnitOption($event->Prefix, 'PermItemPrefix');
+ $perm_prefix = $event->getUnitConfig()->getPermItemPrefix();
$event_suffix = $is_active ? 'ADD' : 'ADD.PENDING';
$this->Application->emailAdmin($perm_prefix . '.' . $event_suffix);
@@ -1527,8 +1542,8 @@
$ids = $this->StoreSelectedIDs($event);
if ( $ids ) {
- $status_field = $object->getStatusField();
$propagate_category_status = $this->Application->GetVar('propagate_category_status');
+ $status_field = $event->getUnitConfig()->getStatusField(true);
foreach ($ids as $id) {
$object->Load($id);
@@ -1644,14 +1659,13 @@
*/
protected function _removeForcedSortings(kEvent $event)
{
- $list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings', Array ());
- /* @var $list_sortings Array */
+ $config = $event->getUnitConfig();
- foreach ($list_sortings as $special => $sortings) {
- unset($list_sortings[$special]['ForcedSorting']);
+ foreach ($config->getListSortingSpecials() as $special) {
+ $list_sortings = $config->getListSortingsBySpecial($special);
+ unset($list_sortings['ForcedSorting']);
+ $config->setListSortingsBySpecial('', $list_sortings);
}
-
- $this->Application->setUnitOption($event->Prefix, 'ListSortings', $list_sortings);
}
/**
@@ -2059,8 +2073,9 @@
static $themes = null;
if (!isset($themes)) {
- $id_field = $this->Application->getUnitOption('theme', 'IDField');
- $table_name = $this->Application->getUnitOption('theme', 'TableName');
+ $theme_config = $this->Application->getUnitConfig('theme');
+ $id_field = $theme_config->getIDField();
+ $table_name = $theme_config->getTableName();
$sql = 'SELECT Name, ' . $id_field . '
FROM ' . $table_name . '
@@ -2130,26 +2145,25 @@
$root_category = $this->Application->getBaseCategory();
- // set root category
- $section_adjustments = $this->Application->getUnitOption($event->Prefix, 'SectionAdjustments');
+ $config = $event->getUnitConfig();
- $section_adjustments['in-portal:browse'] = Array (
+ // set root category
+ $config->addSectionAdjustments(Array (
+ 'in-portal:browse' => Array (
'url' => Array ('m_cat_id' => $root_category),
'late_load' => Array ('m_cat_id' => $root_category),
'onclick' => 'checkCatalog(' . $root_category . ')',
- );
-
- $section_adjustments['in-portal:browse_site'] = Array (
+ ),
+ 'in-portal:browse_site' => Array (
'url' => Array ('editing_mode' => $settings['default_editing_mode']),
- );
+ )
+ ));
- $this->Application->setUnitOption($event->Prefix, 'SectionAdjustments', $section_adjustments);
-
// prepare structure dropdown
$category_helper = $this->Application->recallObject('CategoryHelper');
/* @var $category_helper CategoryHelper */
- $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
+ $fields = $config->getFields();
$fields['ParentId']['default'] = (int)$this->Application->GetVar('m_cat_id');
$fields['ParentId']['options'] = $category_helper->getStructureTreeAsOptions();
@@ -2163,33 +2177,32 @@
// adds "Inherit From Parent" option to "Template" field
$fields['Template']['options'] = Array (CATEGORY_TEMPLATE_INHERIT => $this->Application->Phrase('la_opt_InheritFromParent'));
- $this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
+ $config->setFields($fields);
if ($this->Application->isAdmin) {
// don't sort by Front-End sorting fields
- $config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
+ $config_mapping = $config->getConfigMapping();
$remove_keys = Array ('DefaultSorting1Field', 'DefaultSorting2Field', 'DefaultSorting1Dir', 'DefaultSorting2Dir');
+
foreach ($remove_keys as $remove_key) {
unset($config_mapping[$remove_key]);
}
- $this->Application->setUnitOption($event->Prefix, 'ConfigMapping', $config_mapping);
+
+ $config->setConfigMapping($config_mapping);
}
else {
// sort by parent path on Front-End only
- $list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings', Array ());
- $list_sortings['']['ForcedSorting'] = Array ("CurrentSort" => 'asc');
- $this->Application->setUnitOption($event->Prefix, 'ListSortings', $list_sortings);
+ $config->setListSortingsBySpecial('', Array (
+ 'ForcedSorting' => Array ('CurrentSort' => 'asc'),
+ ));
}
// add grids for advanced view (with primary category column)
- $grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
- $process_grids = Array ('Default', 'Radio');
- foreach ($process_grids as $process_grid) {
- $grid_data = $grids[$process_grid];
+ foreach (Array ('Default', 'Radio') as $process_grid) {
+ $grid_data = $config->getGridByName($process_grid);
$grid_data['Fields']['CachedNavbar'] = Array ('title' => 'la_col_Path', 'data_block' => 'grid_parent_category_td', 'filter_block' => 'grid_like_filter');
- $grids[$process_grid . 'ShowAll'] = $grid_data;
+ $config->addGrids($grid_data, $process_grid . 'ShowAll');
}
- $this->Application->setUnitOption($this->Prefix, 'Grids', $grids);
}
/**
@@ -2230,14 +2243,16 @@
// remove this category & it's children from dropdown
$sql = 'SELECT ' . $object->IDField . '
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ FROM ' . $event->getUnitConfig()->getTableName() . '
WHERE ParentPath LIKE "' . $object->GetDBField('ParentPath') . '%"';
$remove_categories = $this->Conn->GetCol($sql);
$options = $object->GetFieldOption('ParentId', 'options');
+
foreach ($remove_categories as $remove_category) {
unset($options[$remove_category]);
}
+
$object->SetFieldOption('ParentId', 'options', $options);
}
@@ -2402,13 +2417,15 @@
$object = $event->getObject();
/* @var $object kDBList */
+ $config = $event->getUnitConfig();
+
$this->Application->SetVar($event->getPrefixSpecial().'_Page', 1);
$lang = $this->Application->GetVar('m_lang');
- $items_table = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $items_table = $config->getTableName();
$module_name = 'In-Portal';
$sql = 'SELECT *
- FROM ' . $this->Application->getUnitOption('confs', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('confs')->getTableName() . '
WHERE ModuleName = ' . $this->Conn->qstr($module_name) . ' AND SimpleSearch = 1';
$search_config = $this->Conn->Query($sql, 'FieldName');
@@ -2421,9 +2438,9 @@
$alias_counter = 0;
- $custom_fields = $this->Application->getUnitOption($event->Prefix, 'CustomFields');
+ $custom_fields = $config->getCustomFields();
if ($custom_fields) {
- $custom_table = $this->Application->getUnitOption($event->Prefix.'-cdata', 'TableName');
+ $custom_table = $this->Application->getUnitConfig($event->Prefix . '-cdata')->getTableName();
$join_clauses[] = ' LEFT JOIN '.$custom_table.' custom_data ON '.$items_table.'.ResourceId = custom_data.ResourceId';
}
@@ -2590,7 +2607,7 @@
$revelance_parts = array_unique($revelance_parts);
- $conf_postfix = $this->Application->getUnitOption($event->Prefix, 'SearchConfigPostfix');
+ $conf_postfix = $config->getSearchConfigPostfix();
$rel_keywords = $this->Application->ConfigValue('SearchRel_Keyword_'.$conf_postfix) / 100;
$rel_pop = $this->Application->ConfigValue('SearchRel_Pop_'.$conf_postfix) / 100;
$rel_rating = $this->Application->ConfigValue('SearchRel_Rating_'.$conf_postfix) / 100;
@@ -2616,17 +2633,17 @@
$select_intro = 'CREATE TABLE '.$search_table.' AS ';
}
- $edpick_clause = $this->Application->getUnitOption($event->Prefix.'.EditorsPick', 'Fields') ? $items_table.'.EditorsPick' : '0';
+ $edpick_clause = $config->getFieldByName('EditorsPick') ? $items_table.'.EditorsPick' : '0';
$sql = $select_intro.' SELECT '.$relevance_clause.' AS Relevance,
- '.$items_table.'.'.$this->Application->getUnitOption($event->Prefix, 'IDField').' AS ItemId,
+ '.$items_table.'.'.$config->getIDField().' AS ItemId,
'.$items_table.'.ResourceId,
- '.$this->Application->getUnitOption($event->Prefix, 'ItemType').' AS ItemType,
+ '.$config->getItemType().' AS ItemType,
'.$edpick_clause.' AS EdPick
FROM '.$object->TableName.'
'.implode(' ', $join_clauses).'
WHERE '.$where_clause.'
- GROUP BY '.$items_table.'.'.$this->Application->getUnitOption($event->Prefix, 'IDField').' ORDER BY Relevance DESC';
+ GROUP BY '.$items_table.'.'.$config->getIDField().' ORDER BY Relevance DESC';
$this->Conn->Query($sql);
@@ -2653,7 +2670,7 @@
$sql = 'SHOW TABLES LIKE "' . $search_table . '"';
if ( $this->Conn->Query($sql) ) {
- $item_type = $this->Application->getUnitOption($event->Prefix, 'ItemType');
+ $item_type = $event->getUnitConfig()->getItemType();
// 1. get ids to be used as search bounds
$sql = 'SELECT DISTINCT ResourceId
\ No newline at end of file
Index: core/kernel/managers/url_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/managers/url_processor.php (revision 15682)
+++ core/kernel/managers/url_processor.php (revision )
@@ -74,7 +74,7 @@
foreach ($pass_info as $prefix) {
list ($prefix_only,) = explode('.', $prefix, 2);
- $sorted[$prefix] = $this->Application->getUnitOption($prefix_only, 'RewritePriority', 0);
+ $sorted[$prefix] = $this->Application->getUnitConfig($prefix_only)->getRewritePriority(0);
}
asort($sorted, SORT_NUMERIC);
\ No newline at end of file
Index: core/units/configuration/configuration_tag_processor.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/configuration/configuration_tag_processor.php (revision 15682)
+++ core/units/configuration/configuration_tag_processor.php (revision )
@@ -33,7 +33,7 @@
function PrintList($params)
{
$list =& $this->GetList($params);
- $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
+ $id_field = $this->getUnitConfig()->getIDField();
$list->Query();
$o = '';
@@ -107,29 +107,28 @@
function getModuleItemName()
{
$module = $this->Application->GetVar('module');
- $table = $this->Application->getUnitOption('confs', 'TableName');
+ $table = $this->Application->getUnitConfig('confs')->getTableName();
$sql = 'SELECT ConfigHeader
- FROM '.$table.'
+ FROM ' . $table . '
- WHERE ModuleName = '.$this->Conn->qstr($module);
+ WHERE ModuleName = ' . $this->Conn->qstr($module);
+
return $this->Conn->GetOne($sql);
}
function PrintConfList($params)
{
$list =& $this->GetList($params);
- $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
$list->Query();
- $o = '';
$list->GoFirst();
- $tmp_row = Array();
+ $tmp_row = Array ();
- while (!$list->EOL()) {
+ while ( !$list->EOL() ) {
$rec = $list->getCurrentRecord();
$tmp_row[0][$rec['VariableName']] = $rec['VariableValue'];
- $tmp_row[0][$rec['VariableName'].'_prompt'] = $rec['Prompt'];
+ $tmp_row[0][$rec['VariableName'] . '_prompt'] = $rec['Prompt'];
$list->GoNext();
}
@@ -242,13 +241,13 @@
static $cached_ids = Array ();
$var_name = $params['name'];
+
- if (!isset($cached_ids[$var_name])) {
+ if ( !isset($cached_ids[$var_name]) ) {
- $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $config = $this->getUnitConfig();
- $sql = 'SELECT '.$id_field.'
- FROM '.$table_name.'
+ $sql = 'SELECT ' . $config->getIDField() . '
+ FROM ' . $config->getTableName() . '
- WHERE VariableName = '.$this->Conn->qstr($params['name']);
+ WHERE VariableName = ' . $this->Conn->qstr($params['name']);
$cached_ids[$var_name] = $this->Conn->GetOne($sql);
}
@@ -260,13 +259,11 @@
static $cached_sections = Array ();
$var_name = $params['name'];
- if (!isset($cached_sections[$var_name])) {
- $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField');
- $table_name = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ if ( !isset($cached_sections[$var_name]) ) {
$sql = 'SELECT Section
- FROM '.$table_name.'
+ FROM ' . $this->getUnitConfig()->getTableName() . '
- WHERE VariableName = '.$this->Conn->qstr($params['name']);
+ WHERE VariableName = ' . $this->Conn->qstr($params['name']);
$cached_sections[$var_name] = $this->Conn->GetOne($sql);
}
\ No newline at end of file
Index: core/kernel/db/cat_event_handler.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/db/cat_event_handler.php (revision 15682)
+++ core/kernel/db/cat_event_handler.php (revision )
@@ -64,7 +64,7 @@
$actions->Set($event->getPrefixSpecial() . '_id', $object->GetID());
- $use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing');
+ $use_pending_editing = $event->getUnitConfig()->getUsePendingEditing();
if ( $use_pending_editing && $event->Special != 'original' ) {
$this->Application->SetVar($event->Prefix . '.original_id', $object->GetDBField('OrgId'));
@@ -409,13 +409,15 @@
$type_clauses['displayed']['include'] = '';
$displayed = $this->Application->GetVar($event->Prefix.'_displayed_ids');
+
if ($displayed) {
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
+ $id_field = $event->getUnitConfig()->getIDField();
$type_clauses['displayed']['except'] = '%1$s.'.$id_field.' NOT IN ('.$displayed.')';
}
else {
$type_clauses['displayed']['except'] = '';
}
+
$type_clauses['displayed']['having_filter'] = false;
if (in_array('search', $types) || in_array('search', $except_types)) {
@@ -440,8 +442,8 @@
$object = $event->getObject();
/* @var $object kDBList */
- $search_sql = ' FROM ' . TABLE_PREFIX . 'ses_' . $this->Application->GetSID() . '_' . TABLE_PREFIX . 'Search
- search_result JOIN %1$s ON %1$s.ResourceId = search_result.ResourceId';
+ $search_sql = ' FROM ' . TABLE_PREFIX . 'ses_' . $this->Application->GetSID() . '_' . TABLE_PREFIX . 'Search search_result
+ JOIN %1$s ON %1$s.ResourceId = search_result.ResourceId';
$sql = str_replace('FROM %1$s', $search_sql, $object->GetPlainSelectSQL());
$object->SetSelectSQL($sql);
@@ -454,8 +456,8 @@
}
if (in_array('related', $types) || in_array('related', $except_types)) {
-
$related_to = $event->getEventParam('related_to');
+
if (!$related_to) {
$related_prefix = $event->Prefix;
}
@@ -466,8 +468,8 @@
$related_prefix = $this->Conn->GetOne($sql);
}
- $rel_table = $this->Application->getUnitOption('rel', 'TableName');
- $item_type = (int)$this->Application->getUnitOption($event->Prefix, 'ItemType');
+ $rel_table = $this->Application->getUnitConfig('rel')->getTableName();
+ $item_type = (int)$event->getUnitConfig()->getItemType();
if ($item_type == 0) {
trigger_error('ItemType not defined for prefix ' . $event->Prefix . '', E_USER_WARNING);
@@ -475,11 +477,13 @@
// process case, then this list is called inside another list
$prefix_special = $event->getEventParam('PrefixSpecial');
+
if (!$prefix_special) {
$prefix_special = $this->Application->Parser->GetParam('PrefixSpecial');
}
$id = false;
+
if ($prefix_special !== false) {
$processed_prefix = $this->Application->processPrefix($prefix_special);
if ($processed_prefix['prefix'] == $related_prefix) {
@@ -538,14 +542,16 @@
$type_clauses['related']['include'] = '0';
$type_clauses['related']['except'] = '1';
}
+
$type_clauses['related']['having_filter'] = false;
}
if (in_array('favorites', $types) || in_array('favorites', $except_types)) {
$sql = 'SELECT ResourceId
- FROM '.$this->Application->getUnitOption('fav', 'TableName').'
+ FROM ' . $this->Application->getUnitConfig('fav')->getTableName() . '
WHERE PortalUserId = '.$this->Application->RecallVar('user_id');
$favorite_ids = $this->Conn->GetCol($sql);
+
if ($favorite_ids) {
$type_clauses['favorites']['include'] = '%1$s.ResourceId IN ('.implode(',', $favorite_ids).') AND PrimaryCat = 1';
$type_clauses['favorites']['except'] = '%1$s.ResourceId NOT IN ('.implode(',', $favorite_ids).') AND PrimaryCat = 1';
@@ -554,6 +560,7 @@
$type_clauses['favorites']['include'] = 0;
$type_clauses['favorites']['except'] = 1;
}
+
$type_clauses['favorites']['having_filter'] = false;
}
@@ -685,7 +692,7 @@
function applyItemStatusFilter(&$object, $types)
{
// Link1 (before modifications) [Status = 1, OrgId = NULL], Link2 (after modifications) [Status = -2, OrgId = Link1_ID]
- $pending_editing = $this->Application->getUnitOption($object->Prefix, 'UsePendingEditing');
+ $pending_editing = $object->getUnitConfig()->getUsePendingEditing();
if (!$this->Application->isAdminUser) {
$types = explode(',', $types);
@@ -765,17 +772,15 @@
function prepareItemStatuses($event)
{
$object = $event->getObject( Array('skip_autoload' => true) );
+ $property_map = $event->getUnitConfig()->getItemPropertyMappings();
- $property_map = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings');
if (!$property_map) {
return ;
}
// new items
$object->addCalculatedField('IsNew', ' IF(%1$s.NewItem = 2,
- IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - '.
- $this->Application->ConfigValue($property_map['NewDays']).
- '*3600*24), 1, 0),
+ IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - ' . $this->Application->ConfigValue($property_map['NewDays']) . '*3600*24), 1, 0),
%1$s.NewItem
)');
@@ -799,11 +804,7 @@
// popular items
$object->addCalculatedField('IsPop', ' IF(%1$s.PopItem = 2,
- IF(%1$s.CachedVotesQty >= '.
- $this->Application->ConfigValue($property_map['MinPopVotes']).
- ' AND %1$s.CachedRating >= '.
- $this->Application->ConfigValue($property_map['MinPopRating']).
- ', 1, 0),
+ IF(%1$s.CachedVotesQty >= ' . $this->Application->ConfigValue($property_map['MinPopVotes']) . ' AND %1$s.CachedRating >= ' . $this->Application->ConfigValue($property_map['MinPopRating']) . ', 1, 0),
%1$s.PopItem)');
}
@@ -817,7 +818,8 @@
*/
protected function CalculateHotLimit($event)
{
- $property_map = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings');
+ $config = $event->getUnitConfig();
+ $property_map = $config->getItemPropertyMappings();
if ( !$property_map ) {
return 0.00;
@@ -827,7 +829,7 @@
$last_hot = $this->Application->ConfigValue($property_map['MaxHotNumber']) - 1;
$sql = 'SELECT ' . $click_field . '
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ FROM ' . $config->getTableName() . '
ORDER BY ' . $click_field . ' DESC
LIMIT ' . $last_hot . ', 1';
$res = $this->Conn->GetCol($sql);
@@ -859,13 +861,15 @@
/* @var $object kCatDBItem */
// update hits field
- $property_map = $this->Application->getUnitOption($event->Prefix, 'ItemPropertyMappings');
+ $config = $event->getUnitConfig();
+ $property_map = $config->getUserProfileMapping();
+
if ( $property_map ) {
$click_field = $property_map['ClickField'];
if ( $this->Application->isAdminUser && ($this->Application->GetVar($click_field . '_original') !== false) && floor($this->Application->GetVar($click_field . '_original')) != $object->GetDBField($click_field) ) {
$sql = 'SELECT MAX(' . $click_field . ')
- FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . '
+ FROM ' . $config->getTableName() . '
WHERE FLOOR(' . $click_field . ') = ' . $object->GetDBField($click_field);
$hits = ($res = $this->Conn->GetOne($sql)) ? $res + 0.000001 : $object->GetDBField($click_field);
@@ -875,6 +879,7 @@
// change category
$target_category = $object->GetDBField('CategoryId');
+
if ( $object->GetOriginalField('CategoryId') != $target_category ) {
$object->MoveToCat($target_category);
}
@@ -995,7 +1000,7 @@
if ( $this->Application->isAdminUser && $recycle_bin ) {
$sql = 'SELECT CategoryId
- FROM ' . $this->Application->getUnitOption('ci', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('ci')->getTableName() . '
WHERE ItemResourceId = ' . $object->GetDBField('ResourceId') . ' AND PrimaryCat = 1';
$primary_category = $this->Conn->GetOne($sql);
@@ -1116,13 +1121,15 @@
$object = $event->getObject();
/* @var $object kDBList */
+ $config = $event->getUnitConfig();
+
$this->Application->SetVar($event->getPrefixSpecial().'_Page', 1);
$lang = $this->Application->GetVar('m_lang');
- $items_table = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $items_table = $config->getTableName();
$module_name = $this->Application->findModule('Var', $event->Prefix, 'Name');
$sql = 'SELECT *
- FROM ' . $this->Application->getUnitOption('confs', 'TableName') . '
+ FROM ' . $this->Application->getUnitConfig('confs')->getTableName() . '
WHERE ModuleName = ' . $this->Conn->qstr($module_name) . ' AND SimpleSearch = 1';
$search_config = $this->Conn->Query($sql, 'FieldName');
@@ -1135,9 +1142,9 @@
$alias_counter = 0;
- $custom_fields = $this->Application->getUnitOption($event->Prefix, 'CustomFields');
+ $custom_fields = $config->getCustomFields();
if ($custom_fields) {
- $custom_table = $this->Application->getUnitOption($event->Prefix.'-cdata', 'TableName');
+ $custom_table = $this->Application->getUnitConfig($event->Prefix . '-cdata')->getTableName();
$join_clauses[] = ' LEFT JOIN '.$custom_table.' custom_data ON '.$items_table.'.ResourceId = custom_data.ResourceId';
}
@@ -1276,7 +1283,7 @@
// making relevance clause
$positive_words = $search_helper->getPositiveKeywords($keywords);
$this->Application->StoreVar('highlight_keywords', serialize($positive_words));
- $revelance_parts = Array();
+ $relevance_parts = Array();
reset($search_config);
foreach ($positive_words as $keyword_index => $positive_word) {
@@ -1297,25 +1304,25 @@
$weight = $config_elem['Priority'];
// search by whole words only ([[:<:]] - word boundary)
- /*$revelance_parts[] = 'IF('.$field.' REGEXP "[[:<:]]('.implode(' ', $positive_words).')[[:>:]]", '.$weight.', 0)';
+ /*$relevance_parts[] = 'IF('.$field.' REGEXP "[[:<:]]('.implode(' ', $positive_words).')[[:>:]]", '.$weight.', 0)';
foreach ($positive_words as $keyword) {
- $revelance_parts[] = 'IF('.$field.' REGEXP "[[:<:]]('.$keyword.')[[:>:]]", '.$weight.', 0)';
+ $relevance_parts[] = 'IF('.$field.' REGEXP "[[:<:]]('.$keyword.')[[:>:]]", '.$weight.', 0)';
}*/
// search by partial word matches too
- $revelance_parts[] = 'IF('.$field.' LIKE "%'.implode(' ', $positive_words).'%", '.$weight_sum.', 0)';
+ $relevance_parts[] = 'IF('.$field.' LIKE "%'.implode(' ', $positive_words).'%", '.$weight_sum.', 0)';
foreach ($positive_words as $keyword) {
- $revelance_parts[] = 'IF('.$field.' LIKE "%'.$keyword.'%", '.$weight.', 0)';
+ $relevance_parts[] = 'IF('.$field.' LIKE "%'.$keyword.'%", '.$weight.', 0)';
}
}
- $revelance_parts = array_unique($revelance_parts);
+ $relevance_parts = array_unique($relevance_parts);
- $conf_postfix = $this->Application->getUnitOption($event->Prefix, 'SearchConfigPostfix');
+ $conf_postfix = $config->getSearchConfigPostfix();
$rel_keywords = $this->Application->ConfigValue('SearchRel_Keyword_'.$conf_postfix) / 100;
$rel_pop = $this->Application->ConfigValue('SearchRel_Pop_'.$conf_postfix) / 100;
$rel_rating = $this->Application->ConfigValue('SearchRel_Rating_'.$conf_postfix) / 100;
- $relevance_clause = '('.implode(' + ', $revelance_parts).') / '.$weight_sum.' * '.$rel_keywords;
+ $relevance_clause = '('.implode(' + ', $relevance_parts).') / '.$weight_sum.' * '.$rel_keywords;
if ($rel_pop && $object->isField('Hits')) {
$relevance_clause .= ' + (Hits + 1) / (MAX(Hits) + 1) * '.$rel_pop;
}
@@ -1337,17 +1344,17 @@
$select_intro = 'CREATE TABLE '.$search_table.' AS ';
}
- $edpick_clause = $this->Application->getUnitOption($event->Prefix.'.EditorsPick', 'Fields') ? $items_table.'.EditorsPick' : '0';
+ $edpick_clause = $config->getFieldByName('EditorsPick') ? $items_table.'.EditorsPick' : '0';
$sql = $select_intro.' SELECT '.$relevance_clause.' AS Relevance,
- '.$items_table.'.'.$this->Application->getUnitOption($event->Prefix, 'IDField').' AS ItemId,
+ '.$items_table.'.'.$config->getIDField().' AS ItemId,
'.$items_table.'.ResourceId,
- '.$this->Application->getUnitOption($event->Prefix, 'ItemType').' AS ItemType,
+ '.$config->getItemType().' AS ItemType,
'.$edpick_clause.' AS EdPick
FROM '.$object->TableName.'
'.implode(' ', $join_clauses).'
WHERE '.$where_clause.'
- GROUP BY '.$items_table.'.'.$this->Application->getUnitOption($event->Prefix, 'IDField').' ORDER BY Relevance DESC';
+ GROUP BY '.$items_table.'.'.$config->getIDField().' ORDER BY Relevance DESC';
$this->Conn->Query($sql);
@@ -1374,7 +1381,7 @@
$sql = 'SHOW TABLES LIKE "' . $search_table . '"';
if ( $this->Conn->Query($sql) ) {
- $item_type = $this->Application->getUnitOption($event->Prefix, 'ItemType');
+ $item_type = $event->getUnitConfig()->getItemType();
// 1. get ids to be used as search bounds
$sql = 'SELECT DISTINCT ResourceId
@@ -1414,7 +1421,7 @@
$module_name = $this->Application->findModule('Var', $event->Prefix, 'Name');
$sql = 'SELECT *
- FROM '.$this->Application->getUnitOption('confs', 'TableName').'
+ FROM '.$this->Application->getUnitConfig('confs')->getTableName().'
WHERE (ModuleName = '.$this->Conn->qstr($module_name).') AND (AdvancedSearch = 1)';
$search_config = $this->Conn->Query($sql);
@@ -1425,7 +1432,8 @@
$object->SetPage(1);
- $items_table = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $config = $event->getUnitConfig();
+ $items_table = $config->getTableName();
$search_keywords = $this->Application->GetVar('value'); // will not be changed
@@ -1443,9 +1451,9 @@
$alias_counter = 0;
- $custom_fields = $this->Application->getUnitOption($event->Prefix, 'CustomFields');
+ $custom_fields = $config->getCustomFields();
if ($custom_fields) {
- $custom_table = $this->Application->getUnitOption($event->Prefix.'-cdata', 'TableName');
+ $custom_table = $this->Application->getUnitConfig($event->Prefix . '-cdata')->getTableName();
$join_clauses[] = ' LEFT JOIN '.$custom_table.' custom_data ON '.$items_table.'.ResourceId = custom_data.ResourceId';
}
@@ -1567,7 +1575,7 @@
// making relevance clause
if($relevance_parts)
{
- $conf_postfix = $this->Application->getUnitOption($event->Prefix, 'SearchConfigPostfix');
+ $conf_postfix = $config->getSearchConfigPostfix();
$rel_keywords = $this->Application->ConfigValue('SearchRel_Keyword_'.$conf_postfix) / 100;
$rel_pop = $this->Application->ConfigValue('SearchRel_Pop_'.$conf_postfix) / 100;
$rel_rating = $this->Application->ConfigValue('SearchRel_Rating_'.$conf_postfix) / 100;
@@ -1614,9 +1622,8 @@
$this->Conn->Query('DROP TABLE IF EXISTS '.$search_table);
- $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
- $fields = $this->Application->getUnitOption($event->Prefix, 'Fields');
- $pick_field = isset($fields['EditorsPick']) ? $items_table.'.EditorsPick' : '0';
+ $id_field = $config->getIDField();
+ $pick_field = $config->getFieldByName('EditorsPick') ? $items_table.'.EditorsPick' : '0';
$sql = ' CREATE TABLE '.$search_table.'
SELECT '.$relevance_clause.' AS Relevance,
@@ -1680,8 +1687,9 @@
case 'boolean':
if ($keywords[$field] != -1) {
- $property_mappings = $this->Application->getUnitOption($this->Prefix, 'ItemPropertyMappings');
- $items_table = $this->Application->getUnitOption($this->Prefix, 'TableName');
+ $config = $this->getUnitConfig();
+ $items_table = $config->getTableName();
+ $property_mappings = $config->getItemPropertyMappings();
switch ($field) {
case 'HotItem':
@@ -2175,8 +2183,23 @@
/* @var $object kDBItem */
$object->SetDBField($cached_field, $object->GetField($id_field));
+ $options = $object->GetFieldOptions($id_field);
+
+ if ( isset($options['options'][$user_id]) ) {
+ $object->SetDBField($cached_field, $options['options'][$user_id]);
- }
+ }
+ else {
+ $user_config = $this->Application->getUnitConfig('u');
+ $id_field = $user_config->getIDField();
+ $table_name = $user_config->getTableName();
+ $sql = 'SELECT Username
+ FROM ' . $table_name . '
+ WHERE ' . $id_field . ' = ' . $user_id;
+ $object->SetDBField($cached_field, $this->Conn->GetOne($sql));
+ }
+ }
+
/**
* Saves edited item into temp table
* If there is no id, new item is created in temp table
@@ -2189,7 +2212,7 @@
{
parent::OnPreSave($event);
- $use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing');
+ $use_pending_editing = $event->getUnitConfig()->getUsePendingEditing();
if ( $event->status == kEvent::erSUCCESS && $use_pending_editing ) {
// decision: clone or not clone
@@ -2354,7 +2377,7 @@
*/
function setItemStatusByPermission($event)
{
- $use_pending_editing = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing');
+ $use_pending_editing = $event->getUnitConfig()->getUsePendingEditing();
if (!$use_pending_editing) {
return ;
@@ -2458,7 +2481,7 @@
*/
protected function OnUpdate(kEvent $event)
{
- $use_pending = $this->Application->getUnitOption($event->Prefix, 'UsePendingEditing');
+ $use_pending = $event->getUnitConfig()->getUsePendingEditing();
if ($this->Application->isAdminUser || !$use_pending) {
parent::OnUpdate($event);
$this->SetFrontRedirectTemplate($event, 'modify');
@@ -2500,7 +2523,7 @@
$object->SetFieldsFromHash($field_values, $this->getRequestProtectedFields($field_values));
// 1a. delete record from CategoryItems (about cloned item) that was automatically created during call of Create method of kCatDBItem
- $ci_table = $this->Application->getUnitOption('ci', 'TableName');
+ $ci_table = $this->Application->getUnitConfig('ci')->getTableName();
$sql = 'DELETE FROM '.$ci_table.'
WHERE ItemResourceId = '.$object->GetDBField('ResourceId').' AND PrimaryCat = 1';
$this->Conn->Query($sql);
@@ -2566,7 +2589,7 @@
$event->SetRedirectParam('opener', 's');
// send email events
- $perm_prefix = $this->Application->getUnitOption($event->Prefix, 'PermItemPrefix');
+ $perm_prefix = $event->getUnitConfig()->getPermItemPrefix();
$owner_field = $this->getOwnerField($event->Prefix);
$owner_id = $object->GetDBField($owner_field);
@@ -2745,14 +2768,13 @@
*/
protected function _removeForcedSortings(kEvent $event)
{
- $list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings', Array ());
- /* @var $list_sortings Array */
+ $config = $event->getUnitConfig();
- foreach ($list_sortings as $special => $sortings) {
- unset($list_sortings[$special]['ForcedSorting']);
+ foreach ($config->getListSortingSpecials() as $special) {
+ $list_sortings = $config->getListSortingsBySpecial($special);
+ unset($list_sortings['ForcedSorting']);
+ $config->setListSortingsBySpecial('', $list_sortings);
}
-
- $this->Application->setUnitOption($event->Prefix, 'ListSortings', $list_sortings);
}
/**
@@ -2795,7 +2817,7 @@
*/
protected function getOwnerField($prefix)
{
- return $this->Application->getUnitOption($prefix, 'OwnerField', 'CreatedById');
+ return $this->Application->getUnitConfig($prefix)->getOwnerField('CreatedById');
}
/**
@@ -2824,34 +2846,32 @@
$this->changeSortings($event);
// add grids for advanced view (with primary category column)
- $grids = $this->Application->getUnitOption($this->Prefix, 'Grids');
- $process_grids = Array ('Default', 'Radio');
- foreach ($process_grids as $process_grid) {
- $grid_data = $grids[$process_grid];
+ $config = $event->getUnitConfig();
+
+ foreach (Array ('Default', 'Radio') as $process_grid) {
+ $grid_data = $config->getGridByName($process_grid);
$grid_data['Fields']['CachedNavbar'] = Array ('title' => 'la_col_Path', 'data_block' => 'grid_primary_category_td', 'filter_block' => 'grid_like_filter');
- $grids[$process_grid . 'ShowAll'] = $grid_data;
+ $config->addGrids($grid_data, $process_grid . 'ShowAll');
}
- $this->Application->setUnitOption($this->Prefix, 'Grids', $grids);
// add options for CategoryId field (quick way to select item's primary category)
$category_helper = $this->Application->recallObject('CategoryHelper');
/* @var $category_helper CategoryHelper */
- $virtual_fields = $this->Application->getUnitOption($event->Prefix, 'VirtualFields');
-
+ $virtual_fields = $config->getVirtualFields();
$virtual_fields['CategoryId']['default'] = (int)$this->Application->GetVar('m_cat_id');
$virtual_fields['CategoryId']['options'] = $category_helper->getStructureTreeAsOptions();
-
- $this->Application->setUnitOption($event->Prefix, 'VirtualFields', $virtual_fields);
+ $config->setVirtualFields($virtual_fields);
}
- function changeSortings($event)
+ function changeSortings(kEvent $event)
{
$remove_sortings = Array ();
+ $config = $event->getUnitConfig();
if ( !$this->Application->isAdmin ) {
// remove Pick sorting on Front-end, when not required
- $config_mapping = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping', Array ());
+ $config_mapping = $config->getConfigMapping(Array ());
if ( !isset($config_mapping['ForceEditorPick']) || !$this->Application->ConfigValue($config_mapping['ForceEditorPick']) ) {
$remove_sortings[] = 'EditorsPick';
@@ -2866,17 +2886,16 @@
return;
}
- $list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings', Array ());
- /* @var $list_sortings Array */
+ foreach ($config->getListSortingSpecials() as $special) {
+ $list_sortings = $config->getListSortingsBySpecial($special);
- foreach ($list_sortings as $special => $sorting_fields) {
foreach ($remove_sortings as $sorting_field) {
- unset($list_sortings[$special]['ForcedSorting'][$sorting_field]);
+ unset($list_sortings['ForcedSorting'][$sorting_field]);
}
- }
- $this->Application->setUnitOption($event->Prefix, 'ListSortings', $list_sortings);
+ $config->setListSortingsBySpecial('', $list_sortings);
- }
+ }
+ }
/**
* Returns file contents associated with item
@@ -2952,9 +2971,11 @@
$spam_helper->InitHelper($review_id, 'ReviewHelpful', strtotime('+1 month') - strtotime('now'));
$field = (int)$this->Application->GetVar('helpful') ? 'HelpfulCount' : 'NotHelpfulCount';
+ $review_config = $this->Application->getUnitConfig('rev');
+
$sql = 'SELECT ' . $field . '
- FROM ' . $this->Application->getUnitOption('rev', 'TableName') . '
- WHERE ' . $this->Application->getUnitOption('rev', 'IDField') . ' = ' . $review_id;
+ FROM ' . $review_config->getTableName() . '
+ WHERE ' . $review_config->getIDField() . ' = ' . $review_id;
$count = $this->Conn->GetOne($sql);
if ( $spam_helper->InSpamControl() ) {
@@ -2965,9 +2986,9 @@
return;
}
- $sql = 'UPDATE ' . $this->Application->getUnitOption('rev', 'TableName') . '
+ $sql = 'UPDATE ' . $review_config->getTableName() . '
SET ' . $field . ' = ' . $field . ' + 1
- WHERE ' . $this->Application->getUnitOption('rev', 'IDField') . ' = ' . $review_id;
+ WHERE ' . $review_config->getIDField() . ' = ' . $review_id;
$this->Conn->Query($sql);
if ( $this->Conn->getAffectedRows() ) {
@@ -2992,13 +3013,15 @@
parent::OnCloneSubItem($event);
if ( $event->MasterEvent->Prefix == 'fav' ) {
- $clones = $this->Application->getUnitOption($event->MasterEvent->Prefix, 'Clones');
- $subitem_prefix = $event->Prefix . '-' . $event->MasterEvent->Prefix;
+ $master_config = $event->MasterEvent->getUnitConfig();
- $clones[$subitem_prefix]['ParentTableKey'] = 'ResourceId';
- $clones[$subitem_prefix]['ForeignKey'] = 'ResourceId';
+ $clones = $master_config->getClones();
+ $sub_item_prefix = $event->Prefix . '-' . $event->MasterEvent->Prefix;
- $this->Application->setUnitOption($event->MasterEvent->Prefix, 'Clones', $clones);
+ $clones[$sub_item_prefix]['ParentTableKey'] = 'ResourceId';
+ $clones[$sub_item_prefix]['ForeignKey'] = 'ResourceId';
+
+ $master_config->setClones($clones);
}
}
\ No newline at end of file
Index: core/kernel/db/cat_dbitem.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/kernel/db/cat_dbitem.php (revision 15682)
+++ core/kernel/db/cat_dbitem.php (revision )
@@ -61,7 +61,7 @@
{
parent::Init($prefix, $special);
- $this->usePendingEditing = $this->Application->getUnitOption($this->Prefix, 'UsePendingEditing');
+ $this->usePendingEditing = $this->getUnitConfig()->getUsePendingEditing();
}
/**
@@ -151,7 +151,7 @@
*/
public function NameCopy($master=null, $foreign_key=null, $title_field=null, $format='Copy %1$s of %2$s')
{
- $title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField');
+ $title_field = $this->getUnitConfig()->getTitleField();
if (!$title_field) return;
$new_name = $this->GetDBField($title_field);
@@ -262,9 +262,9 @@
*/
function DeleteFromCategories($delete_category_ids)
{
- $id_field = $this->Application->getUnitOption($this->Prefix, 'IDField'); // because item was loaded before by ResourceId
+ $id_field = $this->getUnitConfig()->getIDField(); // because item was loaded before by ResourceId
- $ci_table = $this->Application->getUnitOption($this->Prefix . '-ci', 'TableName');
+ $ci_table = $this->Application->getUnitConfig($this->Prefix . '-ci')->getTableName();
$resource_id = $this->GetDBField('ResourceId');
$item_cats_sql = ' SELECT CategoryId
@@ -341,7 +341,7 @@
return ;
}
- $title_field = $this->Application->getUnitOption($this->Prefix, 'TitleField');
+ $title_field = $this->getUnitConfig()->getTitleField();
if ( preg_match('/l([\d]+)_(.*)/', $title_field, $regs) ) {
// if title field is multilingual, then use it's name from primary language
@@ -473,9 +473,9 @@
function ChangeStatus($new_status, $pending_editing = false)
{
- $status_field = $this->getStatusField();
+ $status_field = $this->getUnitConfig()->getStatusField(true);
- if ( $new_status != $this->GetDBField($status_field) ) {
+ if ($new_status != $this->GetDBField($status_field)) {
// status was changed
$this->sendEmails($new_status, $pending_editing);
}
@@ -487,12 +487,11 @@
function sendEmails($new_status, $pending_editing = false)
{
- $owner_field = $this->Application->getUnitOption($this->Prefix, 'OwnerField');
- if (!$owner_field) {
- $owner_field = 'CreatedById';
- }
+ $config = $this->getUnitConfig();
- $event_name = $this->Application->getUnitOption($this->Prefix, 'PermItemPrefix');
+ $owner_field = $config->getOwnerField('CreatedById');
+ $event_name = $config->getPermItemPrefix();
+
if ($pending_editing) {
$event_name .= '.MODIFY';
}
@@ -563,10 +562,12 @@
$id = $this->GetID();
if (!in_array($id, $already_viewed)) {
- $property_map = $this->Application->getUnitOption($this->Prefix, 'ItemPropertyMappings');
+ $property_map = $this->getUnitConfig()->getItemPropertyMappings(Array ());
+
if (!$property_map) {
return ;
}
+
$hits_field = $property_map['ClickField'];
$new_hits = $this->GetDBField($hits_field) + 1;
@@ -574,13 +575,12 @@
FROM '.$this->TableName.'
WHERE FLOOR('.$hits_field.') = '.$new_hits;
$max_hits = $this->Conn->GetOne($sql);
+
if ($max_hits) {
$new_hits = $max_hits + 0.000001;
}
- $fields_hash = Array (
- $hits_field => $new_hits,
- );
+ $fields_hash = Array ($hits_field => $new_hits,);
$this->Conn->doUpdate($fields_hash, $this->TableName, $this->IDField.' = '.$id);
array_push($already_viewed, $id);
@@ -605,7 +605,7 @@
// for item with many categories makes primary to load
$ci_table = TABLE_PREFIX . 'CategoryItems';
- if ( $this->IsTempTable() ) {
+ if ($this->IsTempTable()) {
$ci_table = $this->Application->GetTempName($ci_table, 'prefix:' . $this->Prefix);
}
\ No newline at end of file
Index: core/units/email_templates/email_template_tp.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- core/units/email_templates/email_template_tp.php (revision 15682)
+++ core/units/email_templates/email_template_tp.php (revision )
@@ -24,8 +24,8 @@
function ModifyUnitConfig($params)
{
if ( !$this->Application->isDebugMode() ) {
- $grids = $this->Application->getUnitOption($this->Prefix, 'Grids', Array ());
- /* @var $grids Array */
+ $config = $this->getUnitConfig();
+ $grids = $config->getGrids(Array ());
foreach ($grids as $grid_name => $grid_data) {
if ( array_key_exists('Enabled', $grid_data['Fields']) ) {
@@ -33,7 +33,7 @@
}
}
- $this->Application->setUnitOption($this->Prefix, 'Grids', $grids);
+ $config->setGrids($grids);
}
}
@@ -93,8 +93,9 @@
/* @var $object kDBItem */
$field_options = $object->GetFieldOptions('RecipientType');
- $virtual_fields = $this->Application->getUnitOption($this->Prefix, 'VirtualFields');
- $field_options['options'] = $virtual_fields['RecipientType']['options'];
+ $virtual_field_options = $this->getUnitConfig()->getVirtualFieldByName('RecipientType');
+
+ $field_options['options'] = $virtual_field_options['options'];
$object->SetFieldOptions('RecipientType', $field_options);
}
\ No newline at end of file