" value="" />
- ">
-
+
+
+
+
+
-
+
">
-
+
-
- ">
-
+
+
-
+
-
- " name="" value="">
- " type="checkbox" id="_cb_" name="_cb_" class="" onclick="update_checkbox(this, document.getElementById(''))">
-
+
+ ">
+ " type="checkbox" id="_cb_" name="_cb_" class="" onclick="update_checkbox(this, document.getElementById(''))">
+
-
- " >
-
+
+ >
+
-
- name="" id="_" value="">_">
-
+
+ name="" id="_" value="">">
+
-
-
-
+
+
+
-
+
-
-
+ " id="" value="">
+ " id="" value="">
+
-
\ No newline at end of file
+-->
\ No newline at end of file
Index: trunk/core/units/categories/categories_event_handler.php
===================================================================
diff -u -N -r3445 -r4029
--- trunk/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 3445)
+++ trunk/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 4029)
@@ -230,6 +230,25 @@
$this->Application->StoreVar('PermCache_UpdateRequired', 1);
$event->SetRedirectParam('index_file', 'category/category_maint.php');
}
+
+ /**
+ * Adds calculates fields for item statuses
+ *
+ * @param kCatDBItem $object
+ * @param kEvent $event
+ */
+ function prepareObject(&$object, &$event)
+ {
+ $object =& $event->getObject( Array('skip_autoload' => true) );
+
+ $object->addCalculatedField('IsNew', ' IF(%1$s.NewItem = 2,
+ IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - '.
+ $this->Application->ConfigValue('Category_DaysNew').
+ '*3600*24), 1, 0),
+ %1$s.NewItem
+ )');
+
+ }
}
?>
\ No newline at end of file
Index: trunk/core/units/translator/translator_event_handler.php
===================================================================
diff -u -N -r3723 -r4029
--- trunk/core/units/translator/translator_event_handler.php (.../translator_event_handler.php) (revision 3723)
+++ trunk/core/units/translator/translator_event_handler.php (.../translator_event_handler.php) (revision 4029)
@@ -7,24 +7,14 @@
{
$field = $this->Application->GetVar($event->getPrefixSpecial(true).'_field');
- if( strpos($field,':') !== false )
- {
+ if (strpos($field,':') !== false) {
list($obj_prefix,$field) = explode(':', $field);
}
- else
- {
+ else {
$obj_prefix = $this->Application->GetVar($event->getPrefixSpecial(true).'_prefix');
}
$object =& $this->Application->recallObject($obj_prefix);
-
- /*$items_info = $this->Application->GetVar( $obj_prefix );
- if($items_info) $field_values = array_shift($items_info);
- $object->SetFieldsFromHash($field_values);
- $object->Update();*/
-
-
-
$translator =& $this->Application->recallObject($event->getPrefixSpecial());
$def_lang = $this->Application->GetDefaultLanguageId();
@@ -37,8 +27,7 @@
}*/
$this->Application->StoreVar('trans_lang', $current_lang); //remember translation language for user friendlyness
-
- $translator->SetId(1);
+ $translator->SetID(1);
$translator->SetDBField('Original', $object->GetDBField('l'.$this->Application->GetVar('m_lang').'_'.$field));
$translator->SetDBField('Language', $current_lang);
$translator->SetDBField('SwitchLanguage', $current_lang);
Index: trunk/core/units/general/cat_event_handler.php
===================================================================
diff -u -N -r3852 -r4029
--- trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 3852)
+++ trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 4029)
@@ -112,42 +112,36 @@
$object =& $event->getObject();
$this->RemoveRequiredFields($object);
$event->CallSubEvent('OnPreSave');
+
if ($event->status == erSUCCESS) {
-// $url = $this->Application->HREF($t, '', Array('pass'=>'all', $event->getPrefixSpecial(true).'_id' => $object->GetId()));
-// $field = $this->Application->GetVar('translator_field');
- $cf_id = $this->Application->GetVar('translator_cf_id');
- if($cf_id)
- {
- $cv =& $this->Application->recallObject('cv.-item', null, Array('skip_autoload' => true) );
- $load_params = Array('CustomFieldId' => $cf_id, 'ResourceId'=> $object->GetDBField('ResourceId') );
- if( !$cv->Load($load_params) )
- {
- $cv->SetFieldsFromHash($load_params);
- $cv->Create();
+
+ $resource_id = $this->Application->GetVar('translator_resource_id');
+ if ($resource_id) {
+ $t_prefixes = explode(',', $this->Application->GetVar('translator_prefixes'));
+
+ $cdata =& $this->Application->recallObject($t_prefixes[1], null, Array('skip_autoload' => true));
+ $cdata->Load($resource_id, 'ResourceId');
+ if (!$cdata->isLoaded()) {
+ $cdata->SetDBField('ResourceId', $resource_id);
+ $cdata->Create();
}
- $this->Application->SetVar('cv_id', $cv->getID() );
+ $this->Application->SetVar($cdata->getPrefixSpecial().'_id', $cdata->GetID());
}
$event->redirect = $this->Application->GetVar('translator_t');
$event->redirect_params = Array('pass'=>'all,trans,'.$this->Application->GetVar('translator_prefixes'),
- $event->getPrefixSpecial(true).'_id' => $object->GetId(),
- 'trans_event'=>'OnLoad',
- 'trans_prefix'=> $this->Application->GetVar('translator_prefixes'),
- 'trans_field'=>$this->Application->GetVar('translator_field'),
- 'trans_multi_line'=>$this->Application->GetVar('translator_multi_line'),
+ $event->getPrefixSpecial(true).'_id' => $object->GetID(),
+ 'trans_event' => 'OnLoad',
+ 'trans_prefix' => $this->Application->GetVar('translator_prefixes'),
+ 'trans_field' => $this->Application->GetVar('translator_field'),
+ 'trans_multi_line' => $this->Application->GetVar('translator_multi_line'),
);
// 1. SAVE LAST TEMPLATE TO SESSION
$last_template = $this->Application->RecallVar('last_template');
preg_match('/index4\.php\|'.$this->Application->GetSID().'-(.*):/U', $last_template, $rets);
-// $this->Application->StoreVar('return_template', $rets[1]);
$this->Application->StoreVar('return_template', $this->Application->GetVar('t'));
-
- //$after_script = "openTranslator('".$event->getPrefixSpecial()."', '".$field."', '".$url."', '".$wnd_name."')";
}
-
-// $this->Application->SetVar('after_script', $after_script);
-// $event->redirect = false;
}
/**
Index: trunk/core/units/custom_data/custom_data_config.php
===================================================================
diff -u -N -r4016 -r4029
--- trunk/core/units/custom_data/custom_data_config.php (.../custom_data_config.php) (revision 4016)
+++ trunk/core/units/custom_data/custom_data_config.php (.../custom_data_config.php) (revision 4029)
@@ -10,6 +10,11 @@
'ParentPrefix' => 'u',
),
+ 'c-cdata' => Array(
+ 'TableName' => TABLE_PREFIX.'CategoryCustomData',
+ 'ParentPrefix' => 'c',
+ ),
+
'l-cdata' => Array(
'TableName' => TABLE_PREFIX.'LinkCustomData',
'ParentPrefix' => 'l',
@@ -31,7 +36,11 @@
),
),
-
+ 'QueryString' => Array(
+ 1 => 'id',
+ 2 => 'event',
+ ),
+
'ItemClass' => Array('class' => 'kDBItem', 'file' => '','build_event' => 'OnItemBuild'),
'ListClass' => Array('class' => 'kDBList', 'file' => '','build_event' => 'OnListBuild'),
'EventHandlerClass' => Array('class' => 'kDBEventHandler', 'file' => '', 'build_event' => 'OnBuild'),
Index: trunk/admin/install/inportal_schema.sql
===================================================================
diff -u -N -r4010 -r4029
--- trunk/admin/install/inportal_schema.sql (.../inportal_schema.sql) (revision 4010)
+++ trunk/admin/install/inportal_schema.sql (.../inportal_schema.sql) (revision 4029)
@@ -712,4 +712,10 @@
ResourceId int(10) unsigned NOT NULL default '0',
PRIMARY KEY (CustomDataId)
)
-# --------------------------------------------------------
\ No newline at end of file
+# --------------------------------------------------------
+CREATE TABLE CategoryCustomData (
+ CustomDataId int(11) NOT NULL auto_increment,
+ ResourceId int(10) unsigned NOT NULL default '0',
+ PRIMARY KEY (`CustomDataId`)
+)
+# --------------------------------------------------------
Index: trunk/kernel/units/users/users_config.php
===================================================================
diff -u -N -r3907 -r4029
--- trunk/kernel/units/users/users_config.php (.../users_config.php) (revision 3907)
+++ trunk/kernel/units/users/users_config.php (.../users_config.php) (revision 4029)
@@ -50,10 +50,14 @@
'ItemType' => 6, // used for custom fields only (on user's case)
'TableName' => TABLE_PREFIX.'PortalUser',
- 'ListSQLs' => Array( ''=>'SELECT * FROM %s',
- ), // key - special, value - list select sql
- 'ItemSQLs' => Array( ''=>'SELECT * FROM %s',
- ),
+ 'ListSQLs' => Array( '' => ' SELECT %1$s.* %2$s FROM %1$s
+ LEFT JOIN '.TABLE_PREFIX.'%3$sPortalUserCustomData cust ON %1$s.ResourceId = cust.ResourceId',
+ ),
+
+ 'ItemSQLs' => Array( '' => ' SELECT %1$s.* %2$s FROM %1$s
+ LEFT JOIN '.TABLE_PREFIX.'%3$sPortalUserCustomData cust ON %1$s.ResourceId = cust.ResourceId',
+ ),
+
'ListSortings' => Array(
'' => Array(
'Sorting' => Array('Login' => 'asc'),
Index: trunk/kernel/admin/include/navmenu.php
===================================================================
diff -u -N -r2388 -r4029
--- trunk/kernel/admin/include/navmenu.php (.../navmenu.php) (revision 2388)
+++ trunk/kernel/admin/include/navmenu.php (.../navmenu.php) (revision 4029)
@@ -52,8 +52,8 @@
NULL,"in-portal:site", "in-portal:configuration_search", "in-portal:configuration_custom",0,"",1,
NULL,NULL,NULL,$admin."/icons/icon46_list_settings_email.gif","la_updating_config");
-$objSections->AddSection("in-portal:configuration_custom","la_tab_ConfigCustom","la_tab_ConfigCustom",$admin."/config/",
- "edit_customfields.php?§ion=in-portal:configuration_custom&DataType=1",
+$objSections->AddSection("in-portal:configuration_custom","la_tab_ConfigCustom","la_tab_ConfigCustom",$admin.'/index4.php',
+ 'kernel4:custom_fields/custom_fields_list:cf----1-',
$admin."/icons/icon46_settings_custom.gif",$admin."/icons/icon24_settings_custom.gif",
NULL, "in-portal:site", "in-portal:configuration_email", NULL,0,"",1,NULL,NULL,NULL,$admin."/icons/icon46_list_settings_custom.gif","la_updating_config");
@@ -219,8 +219,8 @@
NULL,"in-link", "in-portal:configure_users", "in-portal:user_custom",0,"",1,
NULL,NULL,NULL,$admin."/icons/icon46_list_settings_email.gif","la_updating_config");
-$objSections->AddSection("in-portal:user_custom","la_tab_ConfigCustom","la_tab_ConfigCustom",$admin."/config/",
- "edit_customfields.php?§ion=in-portal:user_custom&DataType=6",
+$objSections->AddSection("in-portal:user_custom","la_tab_ConfigCustom","la_tab_ConfigCustom",$admin.'/index4.php',
+ 'kernel4:custom_fields/custom_fields_list:cf----6-',
$admin."/icons/icon46_settings_custom.gif",$admin."/icons/icon24_settings_custom.gif",
NULL, "in-portal:users", "in-portal:user_email", "in-portal:user_banlist",0,"",1,
NULL,NULL,NULL,$admin."/icons/icon46_list_settings_custom.gif","la_updating_config");
Index: trunk/core/kernel/db/db_event_handler.php
===================================================================
diff -u -N -r4008 -r4029
--- trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 4008)
+++ trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 4029)
@@ -1579,6 +1579,9 @@
WHERE Type = '.$item_type.'
ORDER BY CustomFieldId';
$custom_fields = $this->Conn->GetCol($sql, 'CustomFieldId');
+ if (!$custom_fields) {
+ return false;
+ }
// 2. create fields (for customdata item)
$fields = $this->Application->getUnitOption($event->Prefix, 'Fields', Array());
@@ -1587,12 +1590,20 @@
$fields['cust_'.$custom_id] = $field_options;
}
$this->Application->setUnitOption($event->Prefix, 'Fields', $fields);
-
-
- /*// 3. create virtual & calculated fields (for main item)
+
+ // 3. create virtual & calculated fields (for main item)
$calculated_fields = $this->Application->getUnitOption($main_prefix.'.', 'CalculatedFields', Array());
- $virtual_fields = $this->Application->getUnitOption($main_prefix, 'VirtualFields', Array());*/
+ $virtual_fields = $this->Application->getUnitOption($main_prefix, 'VirtualFields', Array());
+ $ml_formatter =& $this->Application->recallObject('kMultiLanguage');
+ $field_options = Array('type' => 'string', 'not_null' => 1, 'default' => '');
+ foreach ($custom_fields as $custom_id => $custom_name) {
+ $calculated_fields['cust_'.$custom_name] = 'cust.'.$ml_formatter->LangFieldName('cust_'.$custom_id);
+ $virtual_fields['cust_'.$custom_name] = $field_options;
+ }
+ $this->Application->setUnitOption($main_prefix, 'CustomFields', $custom_fields);
+ $this->Application->setUnitOption($main_prefix.'.', 'CalculatedFields', $calculated_fields);
+ $this->Application->setUnitOption($main_prefix, 'VirtualFields', $virtual_fields);
}
}
Index: trunk/kernel/units/custom_fields/custom_fields_config.php
===================================================================
diff -u -N -r4000 -r4029
--- trunk/kernel/units/custom_fields/custom_fields_config.php (.../custom_fields_config.php) (revision 4000)
+++ trunk/kernel/units/custom_fields/custom_fields_config.php (.../custom_fields_config.php) (revision 4029)
@@ -5,7 +5,7 @@
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'CustomFieldsEventHandler','file'=>'custom_fields_event_handler.php','build_event'=>'OnBuild'),
- 'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'),
+ 'TagProcessorClass' => Array('class'=>'CustomFieldsTagProcessor','file'=>'custom_fields_tag_processor.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
'hooks' => Array(),
'QueryString' => Array(
@@ -57,10 +57,15 @@
), // key - special, value - list select sql
'ListSortings' => Array(
- '' => Array(
- 'ForcedSorting' => Array('DisplayOrder' => 'asc'),
- 'Sorting' => Array('FieldName' => 'asc'),
- )
+ '' => Array(
+ 'ForcedSorting' => Array('DisplayOrder' => 'asc'),
+ 'Sorting' => Array('FieldName' => 'asc'),
+ ),
+
+ 'general' => Array(
+ 'Sorting' => Array('DisplayOrder' => 'asc')
+ ),
+
),
'ItemSQLs' => Array( ''=>'SELECT * FROM %s',
@@ -79,7 +84,9 @@
'DisplayOrder' => Array('type' => 'int','not_null' => '1','default' => '0'),
'OnGeneralTab' => Array('type' => 'int','not_null' => '1','default' => '0'),
),
- 'VirtualFields' => Array(),
+ 'VirtualFields' => Array(
+ 'Value' => Array('type' => 'string', 'default' => ''),
+ ),
'Grids' => Array(
'Default' => Array(
@@ -92,6 +99,15 @@
),
),
+ 'SeparateTab' => Array(
+ 'Icons' => Array('default'=>'icon16_custom.gif'),
+ 'Fields' => Array(
+ 'FieldName' => Array( 'title'=>'la_col_FieldName', 'data_block' => 'grid_icon_td'),
+ 'Prompt' => Array( 'title'=>'la_col_Prompt', 'data_block' => 'grid_data_label_ml_td' ),
+ 'Value' => Array( 'title'=>'la_col_Value', 'data_block' => 'edit_custom_td'),
+ ),
+ ),
+
),
);
Index: trunk/kernel/admin_templates/incs/grid_blocks.tpl
===================================================================
diff -u -N -r3863 -r4029
--- trunk/kernel/admin_templates/incs/grid_blocks.tpl (.../grid_blocks.tpl) (revision 3863)
+++ trunk/kernel/admin_templates/incs/grid_blocks.tpl (.../grid_blocks.tpl) (revision 4029)
@@ -150,9 +150,9 @@
:
- , 1);" title="">
+ ,-cdata', '-cdata:cust_', 'popups/translator', , 1);" title="">
- );" title="">
+ ,-cdata', '-cdata:cust_', 'popups/translator', );" title="">
|
@@ -236,10 +236,12 @@
-
+
@@ -273,7 +275,7 @@
-
+
Index: trunk/core/kernel/utility/formatters.php
===================================================================
diff -u -N -r3983 -r4029
--- trunk/core/kernel/utility/formatters.php (.../formatters.php) (revision 3983)
+++ trunk/core/kernel/utility/formatters.php (.../formatters.php) (revision 4029)
@@ -742,7 +742,7 @@
$this->Application->setUnitOption($object->Prefix, 'VirtualFields', $virtual_fields);
//substitude grid fields
- $grids = $this->Application->getUnitOption($object->Prefix, 'Grids');
+ $grids = $this->Application->getUnitOption($object->Prefix, 'Grids', Array());
foreach ($grids as $name => $grid) {
if ( getArrayValue($grid, 'Fields', $field_name) ) {
array_rename_key($grids[$name]['Fields'], $field_name, $lang_field_name);
@@ -751,7 +751,7 @@
$this->Application->setUnitOption($object->Prefix, 'Grids', $grids);
//substitude default sortings
- $sortings = $this->Application->getUnitOption($object->Prefix, 'ListSortings');
+ $sortings = $this->Application->getUnitOption($object->Prefix, 'ListSortings', Array());
foreach ($sortings as $special => $the_sortings) {
if (isset($the_sortings['ForcedSorting'])) {
array_rename_key($sortings[$special]['ForcedSorting'], $field_name, $lang_field_name);
Index: trunk/core/units/general/helpers/multilanguage.php
===================================================================
diff -u -N -r4017 -r4029
--- trunk/core/units/general/helpers/multilanguage.php (.../multilanguage.php) (revision 4017)
+++ trunk/core/units/general/helpers/multilanguage.php (.../multilanguage.php) (revision 4029)
@@ -185,7 +185,12 @@
}
}
}
- $ret .= 'ADD COLUMN '.sprintf($field_mask, $start_index).' AFTER `'.$prev_field.'`, ';
+
+ $field_expression = sprintf($field_mask, $start_index);
+ $ret .= 'ADD COLUMN '.$field_expression.' AFTER `'.$prev_field.'`, ';
+
+ list($field_name, $field_params) = explode(' ', $field_expression, 2);
+ $ret .= 'ADD INDEX (`'.$field_name.'` (5) ), ';
$start_index++;
}
return preg_replace('/, $/',';',$ret);
Index: trunk/core/kernel/db/db_tag_processor.php
===================================================================
diff -u -N -r3983 -r4029
--- trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 3983)
+++ trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 4029)
@@ -553,7 +553,19 @@
return $value;
}
-
+
+ function SetField($params)
+ {
+ //
+
+ $object =& $this->getObject($params);
+ $dst_field = $this->SelectParam($params, 'name,field');
+
+ list($prefix_special, $src_field) = explode(':', $params['src']);
+ $src_object =& $this->Application->recallObject($prefix_special);
+ $object->SetDBField($dst_field, $src_object->GetDBField($src_field));
+ }
+
/**
* Checks if parameter is passed
* Note: works like Tag and line simple method too
@@ -860,7 +872,7 @@
*/
function prepareInputName($params)
{
- $field = $params['field'];
+ $field = $this->SelectParam($params, 'name,field');
$object =& $this->getObject($params);
$formatter_class = getArrayValue($object->Fields, $field, 'formatter');
@@ -1257,28 +1269,19 @@
*/
function CustomField($params)
{
- $object =& $this->getObject($params);
-
- $field = $this->SelectParam($params, 'name,field');
-
- $lang_id = $this->Application->GetVar('m_lang');
-
- $sql = ' SELECT cv.l'.$lang_id.'_Value FROM '.TABLE_PREFIX.'CustomField cf
- LEFT JOIN '.TABLE_PREFIX.'CustomMetaData cv
- ON cf.CustomFieldId = cv.CustomFieldId
- WHERE cf.Type = '.$this->Application->getUnitOption($this->Prefix, 'ItemType').'
- AND cv.ResourceId = '.$object->GetDBField('ResourceId').'
- AND cf.FieldName = "'.$field.'"';
- return $this->Conn->GetOne($sql);
+ $params['name'] = 'cust_'.$this->SelectParam($params, 'name,field');
+ return $this->Field($params);
}
function CustomFieldLabel($params)
{
- $object =& $this->Application->recallObject($this->Prefix); // not using Special here (for what purpose ?)
+ $object =& $this->getObject($params);
$field = $this->SelectParam($params, 'name,field');
- $sql = ' SELECT FieldLabel FROM '.TABLE_PREFIX.'CustomField WHERE FieldName = "'.$field.'"';
+ $sql = 'SELECT FieldLabel
+ FROM '.$this->Application->getUnitOption('cf', 'TableName').'
+ WHERE FieldName = '.$this->Conn->qstr($field);
return $this->Application->Phrase($this->Conn->GetOne($sql));
}
Index: trunk/kernel/units/custom_data/custom_data_event_handler.php
===================================================================
diff -u -N
--- trunk/kernel/units/custom_data/custom_data_event_handler.php (revision 0)
+++ trunk/kernel/units/custom_data/custom_data_event_handler.php (revision 4029)
@@ -0,0 +1,7 @@
+
\ No newline at end of file
Index: trunk/core/units/custom_fields/custom_fields_event_handler.php
===================================================================
diff -u -N -r4017 -r4029
--- trunk/core/units/custom_fields/custom_fields_event_handler.php (.../custom_fields_event_handler.php) (revision 4017)
+++ trunk/core/units/custom_fields/custom_fields_event_handler.php (.../custom_fields_event_handler.php) (revision 4029)
@@ -12,9 +12,19 @@
{
$object =& $event->getObject();
- $item_type=$this->Application->GetVar('cf_type');
- $object->addFilter('itemtype_filter', '%1$s.Type = '.$item_type);
- //$object->AddOrderField('DisplayOrder', 'ASC');
+ $item_type = $this->Application->GetVar('cf_type');
+ if (!$item_type) {
+ $prefix = $event->getEventParam('SourcePrefix');
+ $item_type = $this->Application->getUnitOption($prefix, 'ItemType');
+ }
+
+ if ($event->Special == 'general') {
+ $object->addFilter('generaltab_filter', '%1$s.OnGeneralTab = 1');
+ }
+
+ if ($item_type) {
+ $object->addFilter('itemtype_filter', '%1$s.Type = '.$item_type);
+ }
}
/**
Index: trunk/kernel/units/categories/categories_config.php
===================================================================
diff -u -N -r3787 -r4029
--- trunk/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 3787)
+++ trunk/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 4029)
@@ -21,7 +21,7 @@
),
'IDField' => 'CategoryId',
'TitleField' => 'Name', // field, used in bluebar when editing existing item
- 'ItemType' => 0, // this is used when relation to product is added from in-portal and via-versa
+ 'ItemType' => 1, // used for custom fields only
'TableName' => TABLE_PREFIX.'Category',
'ViewMenuPhrase' => 'la_text_Categories',
@@ -31,18 +31,14 @@
),
- 'ListSQLs' => Array( ''=> 'SELECT %1$s.* %2$s,
- IF(%1$s.NewItem = 2,
- IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - 10*3600*24), 1, 0),
- %1$s.NewItem) AS IsNew '. // 10 - Category_NewDays value from ConfigurationValues table
- 'FROM %1$s
- LEFT JOIN '.TABLE_PREFIX.'PermCache ON '.TABLE_PREFIX.'PermCache.CategoryId = %1$s.CategoryId'),
- // key - special, value - list select sql
- 'ItemSQLs' => Array( ''=> 'SELECT *,
- IF(%1$s.NewItem = 2,
- IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - 10*3600*24), 1, 0),
- %1$s.NewItem) AS IsNew '. // 10 - Category_NewDays value from ConfigurationValues table
- 'FROM %s'),
+ 'ListSQLs' => Array( ''=> ' SELECT %1$s.* %2$s
+ FROM %1$s
+ LEFT JOIN '.TABLE_PREFIX.'PermCache ON '.TABLE_PREFIX.'PermCache.CategoryId = %1$s.CategoryId
+ LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryCustomData cust ON %1$s.ResourceId = cust.ResourceId'),
+
+ 'ItemSQLs' => Array( ''=> ' SELECT %1$s.* %2$s
+ FROM %1$s
+ LEFT JOIN '.TABLE_PREFIX.'%3$sCategoryCustomData cust ON %1$s.ResourceId = cust.ResourceId'),
'ListSortings' => Array(
'' => Array(
@@ -87,6 +83,7 @@
'VirtualFields' => Array(
'CurrentSort' => Array('type' => 'string', 'default' => ''),
+ 'IsNew' => Array('type' => 'int', 'default' => 0),
),
'Grids' => Array(
Index: trunk/core/units/custom_fields/custom_fields_tag_processor.php
===================================================================
diff -u -N
--- trunk/core/units/custom_fields/custom_fields_tag_processor.php (revision 0)
+++ trunk/core/units/custom_fields/custom_fields_tag_processor.php (revision 4029)
@@ -0,0 +1,90 @@
+getObject($params);
+ $parent_item =& $this->Application->recallObject($params['SourcePrefix']);
+
+ $field = $this->SelectParam($params, 'name,field');
+ return $parent_item->GetField('cust_'.$object->GetField($field));
+ }
+
+ function CustomInputName($params)
+ {
+ $object =& $this->getObject($params);
+ $source_prefix = $this->Application->Parser->GetParam('SourcePrefix');
+
+ $source_tp =& $this->Application->recallTagProcessor($source_prefix);
+ $params['name'] = 'cust_'.$object->GetDBField('FieldName');
+ return $source_tp->InputName($params);
+ }
+
+ /**
+ * Prints list content using block specified
+ *
+ * @param Array $params
+ * @return string
+ * @access public
+ */
+ function PrintList($params)
+ {
+ $list =& $this->GetList($params);
+ $id_field = $this->Application->getUnitOption($this->Prefix,'IDField');
+
+ $list->Query();
+ $o = '';
+ $list->GoFirst();
+
+ $block_params=$this->prepareTagParams($params);
+ $block_params['name'] = $this->SelectParam($params, 'render_as,block');
+ $block_params['pass_params'] = 'true';
+
+ $prev_heading = '';
+ $source_prefix = getArrayValue($params, 'SourcePrefix');
+ if ($source_prefix) {
+ $source_object =& $this->Application->recallObject($source_prefix);
+ }
+
+ if ($this->Special == 'general') {
+ $this->sortCustomFields($list->Records);
+ }
+
+ while (!$list->EOL())
+ {
+ $this->Application->SetVar( $this->getPrefixSpecial().'_id', $list->GetDBField($id_field) ); // for edit/delete links using GET
+
+ if ($source_prefix) {
+ $list->SetDBField($params['value_field'], $source_object->GetDBField('cust_'.$list->GetDBField('FieldName')));
+ $block_params['show_heading'] = ($prev_heading != $list->GetDBField('Heading') ) ? 1 : 0;
+ }
+
+ $o.= $this->Application->ParseBlock($block_params, 1);
+ $prev_heading = $list->GetDBField('Heading');
+ $list->GoNext();
+ }
+
+ $this->Application->SetVar( $this->getPrefixSpecial().'_id', '');
+ return $o;
+ }
+
+
+
+ function sortCustomFields(&$records)
+ {
+ $sorted = Array();
+ $i = 0; $record_count = count($records);
+ while ($i < $record_count) {
+ $sorted[ $records[$i]['Heading'] ][] = $records[$i];
+ $i++;
+ }
+
+ $records = Array();
+ foreach ($sorted as $heading => $heading_records) {
+ $records = array_merge_recursive($records, $heading_records);
+ }
+ }
+ }
+
+?>
\ No newline at end of file
Index: trunk/core/admin_templates/incs/custom_blocks.tpl
===================================================================
diff -u -N -r2716 -r4029
--- trunk/core/admin_templates/incs/custom_blocks.tpl (.../custom_blocks.tpl) (revision 2716)
+++ trunk/core/admin_templates/incs/custom_blocks.tpl (.../custom_blocks.tpl) (revision 4029)
@@ -1,46 +1,44 @@
-
- " value="" />
-
+
+ " />
+
-
- " id="" value="" />
- " id="verify_" value="" />
- ">
-
+
+
+
+
+
-
+
">
-
+
-
- ">
-
+
+
-
+
-
- " name="" value="">
- " type="checkbox" id="_cb_" name="_cb_" class="" onclick="update_checkbox(this, document.getElementById(''))">
-
+
+ ">
+ " type="checkbox" id="_cb_" name="_cb_" class="" onclick="update_checkbox(this, document.getElementById(''))">
+
-
- " >
-
+
+ >
+
-
- name="" id="_" value="">_">
-
+
+ name="" id="_" value="">">
+
-
-
-
+
+
+
-
+
-
-
+ " id="" value="">
+ " id="" value="">
+
-
\ No newline at end of file
+-->
\ No newline at end of file
Index: trunk/kernel/units/translator/translator_event_handler.php
===================================================================
diff -u -N -r3723 -r4029
--- trunk/kernel/units/translator/translator_event_handler.php (.../translator_event_handler.php) (revision 3723)
+++ trunk/kernel/units/translator/translator_event_handler.php (.../translator_event_handler.php) (revision 4029)
@@ -7,24 +7,14 @@
{
$field = $this->Application->GetVar($event->getPrefixSpecial(true).'_field');
- if( strpos($field,':') !== false )
- {
+ if (strpos($field,':') !== false) {
list($obj_prefix,$field) = explode(':', $field);
}
- else
- {
+ else {
$obj_prefix = $this->Application->GetVar($event->getPrefixSpecial(true).'_prefix');
}
$object =& $this->Application->recallObject($obj_prefix);
-
- /*$items_info = $this->Application->GetVar( $obj_prefix );
- if($items_info) $field_values = array_shift($items_info);
- $object->SetFieldsFromHash($field_values);
- $object->Update();*/
-
-
-
$translator =& $this->Application->recallObject($event->getPrefixSpecial());
$def_lang = $this->Application->GetDefaultLanguageId();
@@ -37,8 +27,7 @@
}*/
$this->Application->StoreVar('trans_lang', $current_lang); //remember translation language for user friendlyness
-
- $translator->SetId(1);
+ $translator->SetID(1);
$translator->SetDBField('Original', $object->GetDBField('l'.$this->Application->GetVar('m_lang').'_'.$field));
$translator->SetDBField('Language', $current_lang);
$translator->SetDBField('SwitchLanguage', $current_lang);
Index: trunk/kernel/units/general/cat_event_handler.php
===================================================================
diff -u -N -r3852 -r4029
--- trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 3852)
+++ trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 4029)
@@ -112,42 +112,36 @@
$object =& $event->getObject();
$this->RemoveRequiredFields($object);
$event->CallSubEvent('OnPreSave');
+
if ($event->status == erSUCCESS) {
-// $url = $this->Application->HREF($t, '', Array('pass'=>'all', $event->getPrefixSpecial(true).'_id' => $object->GetId()));
-// $field = $this->Application->GetVar('translator_field');
- $cf_id = $this->Application->GetVar('translator_cf_id');
- if($cf_id)
- {
- $cv =& $this->Application->recallObject('cv.-item', null, Array('skip_autoload' => true) );
- $load_params = Array('CustomFieldId' => $cf_id, 'ResourceId'=> $object->GetDBField('ResourceId') );
- if( !$cv->Load($load_params) )
- {
- $cv->SetFieldsFromHash($load_params);
- $cv->Create();
+
+ $resource_id = $this->Application->GetVar('translator_resource_id');
+ if ($resource_id) {
+ $t_prefixes = explode(',', $this->Application->GetVar('translator_prefixes'));
+
+ $cdata =& $this->Application->recallObject($t_prefixes[1], null, Array('skip_autoload' => true));
+ $cdata->Load($resource_id, 'ResourceId');
+ if (!$cdata->isLoaded()) {
+ $cdata->SetDBField('ResourceId', $resource_id);
+ $cdata->Create();
}
- $this->Application->SetVar('cv_id', $cv->getID() );
+ $this->Application->SetVar($cdata->getPrefixSpecial().'_id', $cdata->GetID());
}
$event->redirect = $this->Application->GetVar('translator_t');
$event->redirect_params = Array('pass'=>'all,trans,'.$this->Application->GetVar('translator_prefixes'),
- $event->getPrefixSpecial(true).'_id' => $object->GetId(),
- 'trans_event'=>'OnLoad',
- 'trans_prefix'=> $this->Application->GetVar('translator_prefixes'),
- 'trans_field'=>$this->Application->GetVar('translator_field'),
- 'trans_multi_line'=>$this->Application->GetVar('translator_multi_line'),
+ $event->getPrefixSpecial(true).'_id' => $object->GetID(),
+ 'trans_event' => 'OnLoad',
+ 'trans_prefix' => $this->Application->GetVar('translator_prefixes'),
+ 'trans_field' => $this->Application->GetVar('translator_field'),
+ 'trans_multi_line' => $this->Application->GetVar('translator_multi_line'),
);
// 1. SAVE LAST TEMPLATE TO SESSION
$last_template = $this->Application->RecallVar('last_template');
preg_match('/index4\.php\|'.$this->Application->GetSID().'-(.*):/U', $last_template, $rets);
-// $this->Application->StoreVar('return_template', $rets[1]);
$this->Application->StoreVar('return_template', $this->Application->GetVar('t'));
-
- //$after_script = "openTranslator('".$event->getPrefixSpecial()."', '".$field."', '".$url."', '".$wnd_name."')";
}
-
-// $this->Application->SetVar('after_script', $after_script);
-// $event->redirect = false;
}
/**
Index: trunk/kernel/units/categories/categories_event_handler.php
===================================================================
diff -u -N -r3445 -r4029
--- trunk/kernel/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 3445)
+++ trunk/kernel/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 4029)
@@ -230,6 +230,25 @@
$this->Application->StoreVar('PermCache_UpdateRequired', 1);
$event->SetRedirectParam('index_file', 'category/category_maint.php');
}
+
+ /**
+ * Adds calculates fields for item statuses
+ *
+ * @param kCatDBItem $object
+ * @param kEvent $event
+ */
+ function prepareObject(&$object, &$event)
+ {
+ $object =& $event->getObject( Array('skip_autoload' => true) );
+
+ $object->addCalculatedField('IsNew', ' IF(%1$s.NewItem = 2,
+ IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - '.
+ $this->Application->ConfigValue('Category_DaysNew').
+ '*3600*24), 1, 0),
+ %1$s.NewItem
+ )');
+
+ }
}
?>
\ No newline at end of file
Index: trunk/core/units/users/users_config.php
===================================================================
diff -u -N -r3907 -r4029
--- trunk/core/units/users/users_config.php (.../users_config.php) (revision 3907)
+++ trunk/core/units/users/users_config.php (.../users_config.php) (revision 4029)
@@ -50,10 +50,14 @@
'ItemType' => 6, // used for custom fields only (on user's case)
'TableName' => TABLE_PREFIX.'PortalUser',
- 'ListSQLs' => Array( ''=>'SELECT * FROM %s',
- ), // key - special, value - list select sql
- 'ItemSQLs' => Array( ''=>'SELECT * FROM %s',
- ),
+ 'ListSQLs' => Array( '' => ' SELECT %1$s.* %2$s FROM %1$s
+ LEFT JOIN '.TABLE_PREFIX.'%3$sPortalUserCustomData cust ON %1$s.ResourceId = cust.ResourceId',
+ ),
+
+ 'ItemSQLs' => Array( '' => ' SELECT %1$s.* %2$s FROM %1$s
+ LEFT JOIN '.TABLE_PREFIX.'%3$sPortalUserCustomData cust ON %1$s.ResourceId = cust.ResourceId',
+ ),
+
'ListSortings' => Array(
'' => Array(
'Sorting' => Array('Login' => 'asc'),
Index: trunk/kernel/units/custom_data/custom_data_config.php
===================================================================
diff -u -N -r4016 -r4029
--- trunk/kernel/units/custom_data/custom_data_config.php (.../custom_data_config.php) (revision 4016)
+++ trunk/kernel/units/custom_data/custom_data_config.php (.../custom_data_config.php) (revision 4029)
@@ -10,6 +10,11 @@
'ParentPrefix' => 'u',
),
+ 'c-cdata' => Array(
+ 'TableName' => TABLE_PREFIX.'CategoryCustomData',
+ 'ParentPrefix' => 'c',
+ ),
+
'l-cdata' => Array(
'TableName' => TABLE_PREFIX.'LinkCustomData',
'ParentPrefix' => 'l',
@@ -31,7 +36,11 @@
),
),
-
+ 'QueryString' => Array(
+ 1 => 'id',
+ 2 => 'event',
+ ),
+
'ItemClass' => Array('class' => 'kDBItem', 'file' => '','build_event' => 'OnItemBuild'),
'ListClass' => Array('class' => 'kDBList', 'file' => '','build_event' => 'OnListBuild'),
'EventHandlerClass' => Array('class' => 'kDBEventHandler', 'file' => '', 'build_event' => 'OnBuild'),
Index: trunk/core/units/custom_fields/custom_fields_config.php
===================================================================
diff -u -N -r4000 -r4029
--- trunk/core/units/custom_fields/custom_fields_config.php (.../custom_fields_config.php) (revision 4000)
+++ trunk/core/units/custom_fields/custom_fields_config.php (.../custom_fields_config.php) (revision 4029)
@@ -5,7 +5,7 @@
'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
'EventHandlerClass' => Array('class'=>'CustomFieldsEventHandler','file'=>'custom_fields_event_handler.php','build_event'=>'OnBuild'),
- 'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'),
+ 'TagProcessorClass' => Array('class'=>'CustomFieldsTagProcessor','file'=>'custom_fields_tag_processor.php','build_event'=>'OnBuild'),
'AutoLoad' => true,
'hooks' => Array(),
'QueryString' => Array(
@@ -57,10 +57,15 @@
), // key - special, value - list select sql
'ListSortings' => Array(
- '' => Array(
- 'ForcedSorting' => Array('DisplayOrder' => 'asc'),
- 'Sorting' => Array('FieldName' => 'asc'),
- )
+ '' => Array(
+ 'ForcedSorting' => Array('DisplayOrder' => 'asc'),
+ 'Sorting' => Array('FieldName' => 'asc'),
+ ),
+
+ 'general' => Array(
+ 'Sorting' => Array('DisplayOrder' => 'asc')
+ ),
+
),
'ItemSQLs' => Array( ''=>'SELECT * FROM %s',
@@ -79,7 +84,9 @@
'DisplayOrder' => Array('type' => 'int','not_null' => '1','default' => '0'),
'OnGeneralTab' => Array('type' => 'int','not_null' => '1','default' => '0'),
),
- 'VirtualFields' => Array(),
+ 'VirtualFields' => Array(
+ 'Value' => Array('type' => 'string', 'default' => ''),
+ ),
'Grids' => Array(
'Default' => Array(
@@ -92,6 +99,15 @@
),
),
+ 'SeparateTab' => Array(
+ 'Icons' => Array('default'=>'icon16_custom.gif'),
+ 'Fields' => Array(
+ 'FieldName' => Array( 'title'=>'la_col_FieldName', 'data_block' => 'grid_icon_td'),
+ 'Prompt' => Array( 'title'=>'la_col_Prompt', 'data_block' => 'grid_data_label_ml_td' ),
+ 'Value' => Array( 'title'=>'la_col_Value', 'data_block' => 'edit_custom_td'),
+ ),
+ ),
+
),
);
Index: trunk/core/kernel/processors/main_processor.php
===================================================================
diff -u -N -r3664 -r4029
--- trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 3664)
+++ trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 4029)
@@ -179,6 +179,22 @@
}
/**
+ * Gets value of specified field from specified prefix_special and set it as parser param
+ *
+ * @param Array $params
+ */
+ /*function SetParam($params)
+ {
+ //
+ list($prefix_special, $field_name) = explode(':', $params['src']);
+
+ $object =& $this->Application->recallObject($prefix_special);
+ $name = $this->SelectParam($params, 'param,name,var');
+
+ $this->Application->Parser->SetParam($name, $object->GetField($field_name) );
+ }*/
+
+ /**
* Compares block parameter with value specified
*
* @param Array $params
Index: trunk/kernel/units/general/helpers/multilanguage.php
===================================================================
diff -u -N -r4017 -r4029
--- trunk/kernel/units/general/helpers/multilanguage.php (.../multilanguage.php) (revision 4017)
+++ trunk/kernel/units/general/helpers/multilanguage.php (.../multilanguage.php) (revision 4029)
@@ -185,7 +185,12 @@
}
}
}
- $ret .= 'ADD COLUMN '.sprintf($field_mask, $start_index).' AFTER `'.$prev_field.'`, ';
+
+ $field_expression = sprintf($field_mask, $start_index);
+ $ret .= 'ADD COLUMN '.$field_expression.' AFTER `'.$prev_field.'`, ';
+
+ list($field_name, $field_params) = explode(' ', $field_expression, 2);
+ $ret .= 'ADD INDEX (`'.$field_name.'` (5) ), ';
$start_index++;
}
return preg_replace('/, $/',';',$ret);
Index: trunk/core/kernel/kbase.php
===================================================================
diff -u -N -r3840 -r4029
--- trunk/core/kernel/kbase.php (.../kbase.php) (revision 3840)
+++ trunk/core/kernel/kbase.php (.../kbase.php) (revision 4029)
@@ -149,15 +149,22 @@
* @var Array
* @access private
*/
- var $Fields=Array();
+ var $Fields = Array();
/**
+ * Holds custom field names for item
+ *
+ * @var Array
+ */
+ var $customFields = Array();
+
+ /**
* All virtual field names
*
* @var Array
* @access private
*/
- var $VirtualFields=Array();
+ var $VirtualFields = Array();
/**
* Fields that need to be queried using custom expression, e.g. IF(...) AS value
@@ -245,10 +252,14 @@
$this->SelectClause = $sql;
}
- function GetSelectSQL($base_query=null)
+ function GetSelectSQL($base_query = null)
{
- if( !isset($base_query) ) $base_query = $this->SelectClause;
- return $q = str_replace( Array('%1$s','%s'), $this->TableName, $base_query);
+ if (!isset($base_query)) {
+ $base_query = $this->SelectClause;
+ }
+ $query = str_replace( Array('%1$s','%s'), $this->TableName, $base_query);
+ $query = $this->replaceModePrefix($query);
+ return $query;
}
/**
@@ -277,6 +288,19 @@
}
/**
+ * Allows substables to be in same mode as main item (e.g. LEFT JOINED ones)
+ *
+ * @param string $query
+ * @return string
+ */
+ function replaceModePrefix($query)
+ {
+ $live_table = substr(kTempTablesHandler::GetLiveName($this->TableName), strlen(TABLE_PREFIX));
+ preg_match('/'.preg_quote(TABLE_PREFIX, '/').'(.*)'.preg_quote($live_table, '/').'/', $this->TableName, $rets);
+ return str_replace('%3$s', $rets[1], $query);
+ }
+
+ /**
* Adds calculated field declaration to object.
*
* @param string $name
@@ -319,6 +343,7 @@
function defineFields()
{
$this->setConfigFields( $this->Application->getUnitOption($this->Prefix, 'Fields') );
+ $this->setCustomFields( $this->Application->getUnitOption($this->Prefix, 'CustomFields', Array()) );
$this->setVirtualFields( $this->Application->getUnitOption($this->Prefix, 'VirtualFields') );
$this->setCalculatedFields( $this->Application->getUnitOption($this->Prefix, 'CalculatedFields') );
}
@@ -335,6 +360,18 @@
* @param Array $fields
* @access public
*/
+ function setCustomFields($fields)
+ {
+ $this->customFields = $fields;
+ }
+
+ /**
+ * Set's field names from table
+ * from config
+ *
+ * @param Array $fields
+ * @access public
+ */
function setConfigFields($fields)
{
$this->Fields = $fields;