Index: trunk/core/kernel/db/db_tag_processor.php
===================================================================
diff -u -N -r5096 -r5340
--- trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 5096)
+++ trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 5340)
@@ -147,7 +147,7 @@
return count($grid_config);
}
-
+
/**
* Prints list content using block specified
*
@@ -296,9 +296,9 @@
$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');
-
+
if ($columns>1 && $direction=="V") {
$list->Records = $this->LinearToVertical($list->Records, $columns, $list->GetPerPage());
$list->SelectedCount=count($list->Records);
@@ -313,10 +313,10 @@
$block_params['column_width'] = 100 / $columns;
$block_start_row_params=$this->prepareTagParams($params);
$block_start_row_params['name'] = $this->SelectParam($params, 'row_start_render_as,block_row_start,row_start_block');
-
+
$block_end_row_params=$this->prepareTagParams($params);
$block_end_row_params['name'] = $this->SelectParam($params, 'row_end_render_as,block_row_end,row_end_block');
-
+
$block_empty_cell_params = $this->prepareTagParams($params);
$block_empty_cell_params['name'] = $this->SelectParam($params, 'empty_cell_render_as,block_empty_cell,empty_cell_block');
@@ -338,7 +338,7 @@
else {
$column_number++;
}
-
+
$block_params['column_number'] = $column_number;
$o.= $this->Application->ParseBlock($block_params, 1);
array_push($displayed, $list->GetDBField($id_field));
@@ -351,19 +351,19 @@
$list->GoNext();
$i++;
}
-
+
// append empty cells in place of missing cells in last row
while ($i % $columns != 0) {
// until next cell will be in new row append empty cells
$o .= $block_empty_cell_params['name'] ? $this->Application->ParseBlock($block_empty_cell_params, 1) : '
| ';
-
+
if (($i+1) % $columns == 0) {
// record in next iteration is first in row too, then close this row
$o .= $block_end_row_params['name'] ? $this->Application->ParseBlock($block_end_row_params, 1) : '';
}
$i++;
}
-
+
$cur_displayed = $this->Application->GetVar($this->Prefix.'_displayed_ids');
if (!$cur_displayed) {
$cur_displayed = Array();
@@ -413,7 +413,7 @@
if (isset($params['page'])) {
$this->Application->SetVar($this->getPrefixSpecial().'_Page', $params['page']);
}
-
+
// $http_query =& $this->Application->recallObject('HTTPQuery');
// $get = $http_query->getRedirectParams();
$pass = Array('pass' => 'all,'.$this->getPrefixSpecial());
@@ -443,7 +443,7 @@
$list =& $this->GetList($tag_params);
$this->Init($list->Prefix, $list->Special);
}*/
-
+
$ret = $tag_params;
$ret['Prefix'] = $this->Prefix;
$ret['Special'] = $this->Special;
@@ -502,9 +502,9 @@
$field = $this->SelectParam($params, 'name,field');
if( !$this->Application->IsAdmin() ) $params['no_special'] = 'no_special';
-
+
$object =& $this->getObject($params);
-
+
if ( $this->HasParam($params, 'db') )
{
$value = $object->GetDBField($field);
@@ -577,19 +577,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
@@ -629,7 +629,7 @@
if ($params['field'] == 'any')
{
$object =& $this->getObject($params);
-
+
$skip_fields = getArrayValue($params, 'except');
$skip_fields = $skip_fields ? explode(',', $skip_fields) : Array();
@@ -653,7 +653,7 @@
{
$field = $params['field'];
$object =& $this->getObject($params);;
-
+
$options = $object->GetFieldOptions($field);
return getArrayValue($options,'required');
}
@@ -662,7 +662,7 @@
{
$field = $params['field'];
$object =& $this->getObject($params);
-
+
$value = $object->GetDBField($field);
$options = $object->GetFieldOptions($field);
if( $this->HasParam($params,'has_empty') )
@@ -718,7 +718,7 @@
$object =& $this->getObject($params);
$field = $params['field'];
$saved_value = $object->GetDBField($field);
-
+
$custom_filters = $this->Application->RecallVar( $this->getPrefixSpecial().'_custom_filters');
if ($custom_filters) {
$custom_filters = unserialize($custom_filters);
@@ -732,16 +732,16 @@
$object->SetDBField($field, $saved_value);
return $ret;
}
-
+
function Format($params)
{
$field = $params['field'];
$object =& $this->getObject($params);
-
+
$options = $object->GetFieldOptions($field);
$format = $options[ $this->SelectParam($params, 'input_format') ? 'input_format' : 'format' ];
-
+
$formatter_class = getArrayValue($options,'formatter');
if($formatter_class)
{
@@ -777,7 +777,7 @@
$prefix_special = $list->getPrefixSpecial();
$total_pages = $list->GetTotalPages();
- if ($total_pages) $this->Application->Parser->DataExists = true;
+ if ($total_pages > 1) $this->Application->Parser->DataExists = true;
if($total_pages == 0) $total_pages = 1; // display 1st page as selected in case if we have no pages at all
$o = '';
@@ -883,9 +883,9 @@
function PaginationBar($params)
{
return $this->PrintPages($params);
- }
-
-
+ }
+
+
/**
* Returns field name (processed by kMultiLanguage formatter
* if required) and item's id from it's IDField or field required
@@ -898,21 +898,21 @@
{
$field = $this->SelectParam($params, 'name,field');
$object =& $this->getObject($params);
-
+
$formatter_class = getArrayValue($object->Fields, $field, 'formatter');
if ($formatter_class == 'kMultiLanguage')
{
- $formatter =& $this->Application->recallObject($formatter_class);
+ $formatter =& $this->Application->recallObject($formatter_class);
$field = $formatter->LangFieldName($field);
}
-
+
$id_field = getArrayValue($params, 'IdField');
$id = $id_field ? $object->GetDBField($id_field) : $object->GetID();
-
+
return Array($id, $field);
}
-
-
+
+
/**
* Returns input field name to
* be placed on form (for correct
@@ -925,12 +925,12 @@
function InputName($params)
{
list($id, $field) = $this->prepareInputName($params);
-
+
$ret = $this->getPrefixSpecial().'['.$id.']['.$field.']';
if( getArrayValue($params, 'as_preg') ) $ret = preg_quote($ret, '/');
return $ret;
}
-
+
/**
* Allows to override various field options through hidden fields with specific names in submit.
* This tag generates this special names
@@ -942,12 +942,12 @@
function FieldModifier($params)
{
list($id, $field) = $this->prepareInputName($params);
-
+
$ret = 'field_modifiers['.$this->getPrefixSpecial().']['.$field.']['.$params['type'].']';
if( getArrayValue($params, 'as_preg') ) $ret = preg_quote($ret, '/');
return $ret;
}
-
+
/**
* Returns index where 1st changable sorting field begins
*
@@ -1063,9 +1063,9 @@
{
$object =& $this->getObject($params);
$ids = explode(',', $this->Application->RecallVar($this->getPrefixSpecial().'_selected_ids'));
-
+
$cur_id = $object->GetID();
-
+
$i = array_search($cur_id, $ids);
if ($i !== false) {
return $i < count($ids) - 1 ? $ids[$i + 1] : '';
@@ -1077,9 +1077,9 @@
{
$object =& $this->getObject($params);
$ids = explode(',', $this->Application->RecallVar($this->getPrefixSpecial().'_selected_ids'));
-
+
$cur_id = $object->GetID();
-
+
$i = array_search($cur_id, $ids);
if ($i !== false) {
return $i > 0 ? $ids[$i - 1] : '';
@@ -1119,7 +1119,7 @@
function ItemIcon($params)
{
$object =& $this->getObject($params);
-
+
$grids = $this->Application->getUnitOption($this->Prefix,'Grids');
$icons =& $grids[ $params['grid'] ]['Icons'];
@@ -1271,12 +1271,12 @@
$object->SetFieldOptions($field, $field_options);
break;
+ case 'text':
case 'textarea':
$params['field_params'] = $helper->ParseConfigSQL($object->GetDBField($params['value_list_field']));
break;
case 'password':
- case 'text':
case 'checkbox':
default:
break;
@@ -1300,7 +1300,7 @@
function CustomFieldLabel($params)
{
$object =& $this->getObject($params);
-
+
$field = $this->SelectParam($params, 'name,field');
$sql = 'SELECT FieldLabel
@@ -1361,7 +1361,7 @@
$temp_tables = $this->Application->GetVar($top_prefix.'_mode') == 't';
$modified = $this->Application->RecallVar($top_prefix.'_modified');
-
+
if ($temp_tables && $modified) {
$block_params = $this->prepareTagParams($params);
$block_params['name'] = $this->SelectParam($params, 'render_as,name');
@@ -1395,7 +1395,7 @@
{
$field = $this->SelectParam($params, 'field,name');
$append = getArrayValue($params, 'type') ? '_'.$params['type'] : '';
-
+
return 'custom_filters['.$this->getPrefixSpecial().']['.$field.$append.']';
}
@@ -1421,11 +1421,11 @@
{
$field = $params['field'];
$object =& $this->GetList($params);
-
+
$options = $object->GetFieldOptions($field);
$format = $options[ $this->SelectParam($params, 'input_format') ? 'input_format' : 'format' ];
-
+
$formatter_class = getArrayValue($options,'formatter');
if($formatter_class)
{
@@ -1457,15 +1457,15 @@
{
$field = $this->SelectParam($params, 'field,name');
-
-
+
+
$error_var_name = $this->getPrefixSpecial().'_'.$field.'_'.$params['type'].'_error';
$error_msg = $this->Application->RecallVar($error_var_name);
if($error_msg)
{
$this->Application->StoreVar($error_var_name, '');
}
-
+
$object =& $this->Application->recallObject($this->Prefix.'.'.$this->Special.'-item', null, Array('skip_autoload' => true));
return $object->ErrorMsgs[$error_msg];
}
@@ -1487,15 +1487,15 @@
else {
$force_module = strtolower($force_module);
}
-
+
$module_folder = trim( $this->Application->findModule('Name', $force_module, 'Path'), '/');
}
else {
$module_folder = $this->Application->getUnitOption($this->Prefix, 'ModuleFolder');
}
return '../../'.$module_folder.'/admin_templates/';
}
-
+
/**
* Returns object used in tag processor
*
@@ -1507,7 +1507,7 @@
$object =& $this->Application->recallObject($this->getPrefixSpecial(), $this->Prefix, $params);
return $object;
}
-
+
/**
* Checks if object propery value matches value passed
*
@@ -1520,7 +1520,7 @@
$property_name = $this->SelectParam($params, 'name,var,property');
return $object->$property_name == $params['value'];
}
-
+
/**
* Group list records by header, saves internal order in group
*
@@ -1535,7 +1535,7 @@
$sorted[ $records[$i][$heading_field] ][] = $records[$i];
$i++;
}
-
+
$records = Array();
foreach ($sorted as $heading => $heading_records) {
$records = array_merge_recursive($records, $heading_records);
Index: trunk/kernel/admin_templates/index.tpl
===================================================================
diff -u -N -r5173 -r5340
--- trunk/kernel/admin_templates/index.tpl (.../index.tpl) (revision 5173)
+++ trunk/kernel/admin_templates/index.tpl (.../index.tpl) (revision 5340)
@@ -10,11 +10,11 @@
-
+
-
+
" name="head" scrolling="no" noresize>
Index: trunk/core/units/general/helpers/mod_rewrite_helper.php
===================================================================
diff -u -N -r4806 -r5340
--- trunk/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 4806)
+++ trunk/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 5340)
@@ -103,7 +103,7 @@
WHERE NamedParentPath = '.$this->Conn->qstr($category_path);
array_push($category_stack, $this->Conn->GetOne($sql) );
}
-
+
$category_found = end($category_stack);
if ($category_found !== false) $url_part = array_shift($url_parts);
@@ -287,7 +287,7 @@
$passed[] = $module_prefix;
$module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => $url_parts) );
if ($process_module) {
- $this->Application->HandleEvent($module_event);
+ $this->Application->HandleEvent($module_event);
}
$item_id = $this->HTTPQuery->Get($module_prefix.'_id');
$module_params = Array($module_prefix.'_id' => $item_id ? $item_id : '0' );
Index: trunk/core/kernel/db/dbitem.php
===================================================================
diff -u -N -r4758 -r5340
--- trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 4758)
+++ trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 5340)
@@ -54,6 +54,7 @@
$this->ErrorMsgs['value_out_of_range'] = '!la_err_value_out_of_range!'; //'Field is out of range, possible values from %s to %s';
$this->ErrorMsgs['length_out_of_range'] = '!la_err_length_out_of_range!'; //'Field is out of range';
$this->ErrorMsgs['bad_type'] = '!la_err_bad_type!'; //'Incorrect data format, please use %s';
+ $this->ErrorMsgs['invalid_format'] = '!la_err_invalid_format!'; //'Incorrect data format, please use %s';
$this->ErrorMsgs['bad_date_format'] = '!la_err_bad_date_format!'; //'Incorrect date format, please use (%s) ex. (%s)';
$this->ErrorMsgs['primary_lang_required'] = '!la_err_primary_lang_required!';
}
Index: trunk/kernel/units/general/helpers/mod_rewrite_helper.php
===================================================================
diff -u -N -r4806 -r5340
--- trunk/kernel/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 4806)
+++ trunk/kernel/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 5340)
@@ -103,7 +103,7 @@
WHERE NamedParentPath = '.$this->Conn->qstr($category_path);
array_push($category_stack, $this->Conn->GetOne($sql) );
}
-
+
$category_found = end($category_stack);
if ($category_found !== false) $url_part = array_shift($url_parts);
@@ -287,7 +287,7 @@
$passed[] = $module_prefix;
$module_event = new kEvent($module_prefix.':ParseEnv', Array('url_parts' => $url_parts) );
if ($process_module) {
- $this->Application->HandleEvent($module_event);
+ $this->Application->HandleEvent($module_event);
}
$item_id = $this->HTTPQuery->Get($module_prefix.'_id');
$module_params = Array($module_prefix.'_id' => $item_id ? $item_id : '0' );
Index: trunk/core/units/images/image_tag_processor.php
===================================================================
diff -u -N -r4303 -r5340
--- trunk/core/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 4303)
+++ trunk/core/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 5340)
@@ -5,6 +5,7 @@
function Image($params)
{
$params['img_path'] = $this->ImageSrc($params);
+ if ($params['img_path'] === false) return ;
$params['img_size'] = $this->ImageSize($params);
if (!$params['img_size']){
$params['img_size'] = ' width="'.getArrayValue($params, 'DefaultWidth').'"';
@@ -116,7 +117,8 @@
if ( $object->GetDBField('LocalImage') && !file_exists(FULL_PATH.'/'.$object->GetDBField('LocalPath')) ) $ret = '';
}
- return ($ret && $ret != PROTOCOL.SERVER_NAME.BASE_PATH && $ret != PROTOCOL.SERVER_NAME.BASE_PATH.'/') ? $ret : PROTOCOL.SERVER_NAME.BASE_PATH.THEMES_PATH.'/'.$this->SelectParam($params, 'default_image,DefaultImage');
+ $default_image = $this->SelectParam($params, 'default_image,DefaultImage');
+ return ($ret && $ret != PROTOCOL.SERVER_NAME.BASE_PATH && $ret != PROTOCOL.SERVER_NAME.BASE_PATH.'/') ? $ret : ($default_image ? PROTOCOL.SERVER_NAME.BASE_PATH.THEMES_PATH.'/'.$default_image : false);
}
function GetFullPath($path)
Index: trunk/kernel/units/images/image_tag_processor.php
===================================================================
diff -u -N -r4303 -r5340
--- trunk/kernel/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 4303)
+++ trunk/kernel/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 5340)
@@ -5,6 +5,7 @@
function Image($params)
{
$params['img_path'] = $this->ImageSrc($params);
+ if ($params['img_path'] === false) return ;
$params['img_size'] = $this->ImageSize($params);
if (!$params['img_size']){
$params['img_size'] = ' width="'.getArrayValue($params, 'DefaultWidth').'"';
@@ -116,7 +117,8 @@
if ( $object->GetDBField('LocalImage') && !file_exists(FULL_PATH.'/'.$object->GetDBField('LocalPath')) ) $ret = '';
}
- return ($ret && $ret != PROTOCOL.SERVER_NAME.BASE_PATH && $ret != PROTOCOL.SERVER_NAME.BASE_PATH.'/') ? $ret : PROTOCOL.SERVER_NAME.BASE_PATH.THEMES_PATH.'/'.$this->SelectParam($params, 'default_image,DefaultImage');
+ $default_image = $this->SelectParam($params, 'default_image,DefaultImage');
+ return ($ret && $ret != PROTOCOL.SERVER_NAME.BASE_PATH && $ret != PROTOCOL.SERVER_NAME.BASE_PATH.'/') ? $ret : ($default_image ? PROTOCOL.SERVER_NAME.BASE_PATH.THEMES_PATH.'/'.$default_image : false);
}
function GetFullPath($path)
Index: trunk/kernel/units/general/helpers/sections_helper.php
===================================================================
diff -u -N -r4996 -r5340
--- trunk/kernel/units/general/helpers/sections_helper.php (.../sections_helper.php) (revision 4996)
+++ trunk/kernel/units/general/helpers/sections_helper.php (.../sections_helper.php) (revision 5340)
@@ -40,6 +40,7 @@
return ;
}
$this->Application->UnitConfigReader->includeConfigFiles(MODULES_PATH);
+ $this->Application->UnitConfigReader->AfterConfigRead();
$this->Tree = Array();
if (!$unit_config_reader) {
@@ -69,15 +70,15 @@
$section_params['url']['module'] = $module_name;
}
}
-
+
if (!isset($section_params['url']['t'])) {
$section_params['url']['t'] = 'index';
}
if (!isset($section_params['onclick'])) {
$section_params['onclick'] = 'checkEditMode()';
}
-
+
$current_data = isset($this->Tree[$section_name]) ? $this->Tree[$section_name] : Array();
$this->Tree[$section_name] = array_merge_recursive2($current_data, $section_params);
Index: trunk/core/kernel/parser/tags.php
===================================================================
diff -u -N -r5219 -r5340
--- trunk/core/kernel/parser/tags.php (.../tags.php) (revision 5219)
+++ trunk/core/kernel/parser/tags.php (.../tags.php) (revision 5340)
@@ -311,6 +311,11 @@
if ($echo) $code[] = '$o = '."'';\n";
switch ( $this->Tag ) {
+ case 'DefaultParam':
+ foreach ($this->NP as $key => $val) {
+ $code[] = '$'.$key.' = $'.$key.' ? $'.$key.' : \''.$val.'\';';
+ }
+ return $code;
case 'param':
$code[] = '$o .= $params["'.$this->NP['name'].'"];';
return $code;
Index: trunk/core/admin_templates/incs/custom_blocks.tpl
===================================================================
diff -u -N -r4284 -r5340
--- trunk/core/admin_templates/incs/custom_blocks.tpl (.../custom_blocks.tpl) (revision 4284)
+++ trunk/core/admin_templates/incs/custom_blocks.tpl (.../custom_blocks.tpl) (revision 5340)
@@ -9,7 +9,7 @@
- ">
+ ">
Index: trunk/core/units/general/helpers/sections_helper.php
===================================================================
diff -u -N -r4996 -r5340
--- trunk/core/units/general/helpers/sections_helper.php (.../sections_helper.php) (revision 4996)
+++ trunk/core/units/general/helpers/sections_helper.php (.../sections_helper.php) (revision 5340)
@@ -40,6 +40,7 @@
return ;
}
$this->Application->UnitConfigReader->includeConfigFiles(MODULES_PATH);
+ $this->Application->UnitConfigReader->AfterConfigRead();
$this->Tree = Array();
if (!$unit_config_reader) {
@@ -69,15 +70,15 @@
$section_params['url']['module'] = $module_name;
}
}
-
+
if (!isset($section_params['url']['t'])) {
$section_params['url']['t'] = 'index';
}
if (!isset($section_params['onclick'])) {
$section_params['onclick'] = 'checkEditMode()';
}
-
+
$current_data = isset($this->Tree[$section_name]) ? $this->Tree[$section_name] : Array();
$this->Tree[$section_name] = array_merge_recursive2($current_data, $section_params);
Index: trunk/kernel/admin_templates/incs/custom_blocks.tpl
===================================================================
diff -u -N -r4284 -r5340
--- trunk/kernel/admin_templates/incs/custom_blocks.tpl (.../custom_blocks.tpl) (revision 4284)
+++ trunk/kernel/admin_templates/incs/custom_blocks.tpl (.../custom_blocks.tpl) (revision 5340)
@@ -9,7 +9,7 @@
- ">
+ ">
Index: trunk/kernel/include/item.php
===================================================================
diff -u -N -r4077 -r5340
--- trunk/kernel/include/item.php (.../item.php) (revision 4077)
+++ trunk/kernel/include/item.php (.../item.php) (revision 5340)
@@ -21,7 +21,7 @@
var $ReviewPerPageVar;
var $TitleField = '';
-
+
function clsItem($FullItem=FALSE)
{
$this->clsParsedItem();
@@ -77,7 +77,7 @@
function &AddReview($createdBy,$reviewText,$isPending,$ip=NULL,$ForceIP=0, $Module="", $CreatedOn = 0)
{
$this->Reviews->itemID=$this->Get("ResourceId");
-
+
if($ip == NULL)
$ip = $_SERVER["REMOTE_ADDR"];
@@ -111,7 +111,7 @@
}
function DeleteReviews()
- {
+ {
$res_id = $this->Get("ResourceId");
if($res_id)
{
@@ -125,7 +125,7 @@
/* item custom fields */
function LoadCustomFields($force = null, $temp_table = false)
- {
+ {
if ((!is_null($force) || !$this->CustomLoaded) && $this->Get('ResourceId')>0) {
$this->FieldClass = new clsCustomFieldList();
$this->FieldClass->Type = $this->type;
@@ -135,25 +135,26 @@
if (strlen($f->Get("ValueList") && (($f->Get("ElementType") == "select") || ($f->Get("ElementType") == "radio"))))
{
if ($f->HasField('Value'))
- {
- $ValueList = explode(",", $f->Get("ValueList"));
+ {
+ $objConfigDummy = new clsConfigAdminItem();
+ $ValueList = explode(",", $objConfigDummy->replace_sql($f->Get("ValueList")));
if (is_array($ValueList))
{
foreach ($ValueList as $curr => $value)
{
$c_data = explode("=", $value);
if ($c_data[0] == $f->Get('Value'))
{
- $this->CustomFields[$f->Get("FieldName")]['value'] = $f->Get('Value');
- $this->CustomFields[$f->Get("FieldName")]['lang_value'] = language($c_data[1]);
+ $this->CustomFields[$f->Get("FieldName")]['value'] = $f->Get('Value');
+ $this->CustomFields[$f->Get("FieldName")]['lang_value'] = language($c_data[1]);
}
}
}
else
{
- $this->CustomFields[$f->Get("FieldName")]['value'] = $f->HasField('Value') ? $f->Get('Value') : '';
- $this->CustomFields[$f->Get("FieldName")]['lang_value'] = null;
- }
+ $this->CustomFields[$f->Get("FieldName")]['value'] = $f->HasField('Value') ? $f->Get('Value') : '';
+ $this->CustomFields[$f->Get("FieldName")]['lang_value'] = null;
+ }
}
else
{
@@ -165,13 +166,13 @@
{
$this->CustomFields[$f->Get("FieldName")]['value'] = strlen($f->HasField('Value')) ? $f->Get('Value') : '';
$this->CustomFields[$f->Get("FieldName")]['lang_value'] = null;
-
+
}
}
$this->CustomLoaded = 1;
}
}
-
+
function SetCustomField($fieldname,$value)
{
// echo "Setting CF [$fieldname] = [$value]
";
@@ -223,26 +224,26 @@
return $ret;
}
*/
-
+
function GetCustomFieldValue($fieldname, $default = '', $ListValue = 0, $temp_table = false)
{
if (!$this->CustomLoaded) {
- $this->LoadCustomFields(null, $temp_table);
+ $this->LoadCustomFields(null, $temp_table);
}
elseif (is_array($this->CustomFields) && empty($this->CustomFields)) {
- $this->LoadCustomFields(1, $temp_table);
+ $this->LoadCustomFields(1, $temp_table);
}
-
+
$fieldname = strtolower($fieldname);
foreach($this->CustomFields as $k => $v) {
if (strtolower($k) == $fieldname) {
return $ListValue? $v['lang_value'] : $v['value'];
- }
+ }
}
-
- return $default;
+
+ return $default;
}
-
+
function DeleteCustomData()
{
$cdata = new clsCustomDataList();
@@ -252,7 +253,7 @@
function Delete($RecordOnly=FALSE)
{
global $objFavorites;
-
+
if($RecordOnly==FALSE)
{
$this->DeleteReviews();
@@ -291,7 +292,7 @@
}
function DeleteRelations()
- {
+ {
$res_id = $this->Get("ResourceId");
if($res_id)
{
@@ -332,7 +333,7 @@
}
return $result;
}
-
+
function HighlightText($text)
{
global $objConfig;
@@ -569,7 +570,7 @@
{
return $this->Images->GetDefaultImage($this->Get("ResourceId"));
}
-
+
function &GetAvatarImage()
{
return $this->Images->GetAvatarImage($this->Get("ResourceId"));
@@ -591,10 +592,10 @@
global $objSession, $objFavorites;
$res = FALSE;
-
+
// user can be added to favorites, but they have no primary category :)
$category_id = method_exists($this, 'GetPrimaryCategory') ? $this->GetPrimaryCategory() : $GLOBALS['m_var_list']['cat'];
-
+
if( $objSession->HasCatPermission("FAVORITES", $category_id) )
{
if(!$PortalUserId)
@@ -616,7 +617,7 @@
// user can be added to favorites, but they have no primary category :)
$category_id = method_exists($this, 'GetPrimaryCategory') ? $this->GetPrimaryCategory() : $GLOBALS['m_var_list']['cat'];
-
+
if( $objSession->HasCatPermission("FAVORITES", $category_id) )
{
if(!$PortalUserId)
@@ -736,7 +737,7 @@
}
function Delete($RecordOnly=FALSE)
- {
+ {
global $objFavorites;
parent::Delete($RecordOnly);
@@ -885,7 +886,7 @@
function RemoveFromCategory($CatId,$SourceTable="",$Force=0)
{
- if(!is_numeric($CatId)) return;
+ if(!is_numeric($CatId)) return;
global $objSession, $objCatList;
if(strlen($SourceTable)==0)
$SourceTable = GetTablePrefix()."CategoryItems";
@@ -919,18 +920,18 @@
}
function DeleteCategoryItems($CatId,$SourceTable = "")
- {
+ {
if(strlen($SourceTable)==0)
$SourceTable = GetTablePrefix()."CategoryItems";
$CatCount = $this->CategoryMemberCount($SourceTable);
if($CatCount>1)
- {
+ {
$this->RemoveFromCategory($CatId,$SourceTable);
$this->ClearCacheData();
}
else
- {
+ {
$this->Delete();
$sql = "DELETE FROM $SourceTable WHERE CategoryId=$CatId AND ItemResourceId=".$this->Get("ResourceId");
if($this->debuglevel)
@@ -940,7 +941,7 @@
}
}
function RemoveFromAllCategories($SourceTable = "")
- {
+ {
if(strlen($SourceTable)==0)
$SourceTable = GetTablePrefix()."CategoryItems";
@@ -1061,60 +1062,60 @@
$this->SetPrimaryCategory($TargetCat); // 2 updates
}
}
-
+
function refreshLastUpdate($cat_id = null)
{
$db =& GetADODBConnection();
$prefix = GetTablePrefix();
-
+
// 1,2,3,4 - set lastupdate date to item's primary category as recent
// change date of all items in this category of same type as this item
-
+
// 1. get item category or use passed one
if(!isset($cat_id)) $cat_id = $this->GetPrimaryCategory();
if($cat_id == 0) return false;
-
+
// 2. get all item ResourceIds in that category
$sql = 'SELECT ItemResourceId FROM '.$prefix.'CategoryItems WHERE CategoryId = '.$cat_id;
$item_rids = $db->GetCol($sql);
if($item_rids)
{
$item_rids = implode(',',$item_rids);
-
+
// 2a. get LastUpdate date based on all item in $cat_id category
$sql = 'SELECT MAX(IF(Modified=0,CreatedOn,Modified)) FROM '.$this->tablename.' WHERE ResourceId IN ('.$item_rids.')';
$item_last_update = $db->GetOne($sql);
}
- else
+ else
{
$item_last_update = 0;
}
-
+
// 3. get LastUpdate date based on all $cat_id subcategories
$sql = 'SELECT MAX(IF(Modified=0,CreatedOn,Modified)) FROM '.$prefix.'Category WHERE ParentId = '.$cat_id;
$cat_last_update = $db->GetOne($sql);
-
+
$last_update = max($item_last_update,$cat_last_update);
-
+
// 4. set $last_update date to $cat_id category
$sql = 'UPDATE '.$prefix.'Category SET Modified = '.$last_update.' WHERE CategoryId = '.$cat_id;
$db->Execute($sql);
-
+
// 5. get $cat_id parent CategoryId
$sql = 'SELECT ParentId FROM '.$prefix.'Category WHERE CategoryId = '.$cat_id;
if($cat_id > 0) $this->refreshLastUpdate( $db->GetOne($sql) );
}
-
+
function StripDisallowed($string)
{
$not_allowed = Array( ' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|', '`',
'~', '!', '@', '#', '$', '%', '^', '&', '(', ')', '~',
'+', '=', '-', '{', '}', ']', '[', "'", ';', '.', ',');
-
+
$string = str_replace($not_allowed, '_', $string);
$string = preg_replace('/(_+)/', '_', $string);
$string = $this->checkAutoFilename($string);
-
+
return $string;
}
@@ -1126,7 +1127,7 @@
$sql = 'SELECT '.$this->IdField().' FROM '.$this->tablename.' WHERE Filename = '.$db->qstr($filename);
$found_item_ids = $db->GetCol($sql);
$has_page = preg_match('/(.*)_([\d]+)([a-z]*)$/', $filename, $rets);
-
+
$duplicates_found = (count($found_item_ids) > 1) || ($found_item_ids && $found_item_ids[0] != $this->UniqueId());
if ($duplicates_found || $has_page) // other category has same filename as ours OR we have filename, that ends with _number
{
@@ -1161,25 +1162,25 @@
$name = $this->Get($this->TitleField);
}
$name = $this->StripDisallowed($name);
-
+
if ( $name != $this->Get('Filename') ) $this->Set('Filename', $name);
}
-
+
function Update($UpdatedBy = null)
{
parent::Update($UpdatedBy);
-
+
$this->GenerateFilename();
parent::Update($UpdatedBy);
-
+
}
function Create()
{
parent::Create();
-
+
$this->GenerateFilename();
-
+
parent::Update();
}
Index: trunk/kernel/units/general/cat_event_handler.php
===================================================================
diff -u -N -r5219 -r5340
--- trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5219)
+++ trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5340)
@@ -1191,6 +1191,7 @@
// get PerPage (forced -> session -> config -> 10)
$per_page = $this->getPerPage($event);
+
$object =& $event->getObject();
$object->SetPerPage($per_page);
$this->Application->StoreVarDefault($event->getPrefixSpecial().'_Page', 1);
Index: trunk/core/kernel/application.php
===================================================================
diff -u -N -r5027 -r5340
--- trunk/core/kernel/application.php (.../application.php) (revision 5027)
+++ trunk/core/kernel/application.php (.../application.php) (revision 5340)
@@ -612,7 +612,7 @@
$this->LinkVar('return_template'); // template to go, when something was coosen from popup (from finalizePopup)
$this->LinkVar('return_m'); // main env part to restore after popup will be closed (from finalizePopup)
}
-
+
if ($this->GetVar('ajax') == 'yes') {
// hide debug output from ajax requests automatically
define('DBG_SKIP_REPORTING', 1);
@@ -1032,6 +1032,7 @@
$no_rewrite = true;
unset($params['__NO_REWRITE__']);
}
+
if ($this->RewriteURLs($ssl) && !$no_rewrite)
{
$session =& $this->recallObject('Session');
@@ -1122,6 +1123,7 @@
$ret = $this->BuildModuleEnv_NEW('m', $params, $pass_events).$ret;
$ret = trim($ret, '/').'.html';
+// $ret = trim($ret, '/').'/';
if($env) $params[ENV_VAR_NAME] = ltrim($env, ':');
}
@@ -1320,10 +1322,10 @@
// redirects to the same template as current
$params['ajax'] = 'yes';
}
-
+
$params['__URLENCODE__'] = 1;
$location = $this->HREF($t, $prefix, $params, $index_file);
-
+
$a_location = $location;
$location = "Location: $location";
//echo " location : $location
";
@@ -2052,6 +2054,12 @@
}
}
+ function TimeZoneAdjustment($time_zone=null)
+ {
+ $target_zone = isset($time_zone) ? $time_zone : $this->ConfigValue('Config_Site_Time');
+ return 3600 * ($target_zone - $this->ConfigValue('Config_Server_Time'));
+ }
+
}
?>
\ No newline at end of file
Index: trunk/core/units/general/cat_event_handler.php
===================================================================
diff -u -N -r5219 -r5340
--- trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5219)
+++ trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 5340)
@@ -1191,6 +1191,7 @@
// get PerPage (forced -> session -> config -> 10)
$per_page = $this->getPerPage($event);
+
$object =& $event->getObject();
$object->SetPerPage($per_page);
$this->Application->StoreVarDefault($event->getPrefixSpecial().'_Page', 1);
Index: trunk/core/kernel/utility/formatters/left_formatter.php
===================================================================
diff -u -N -r4758 -r5340
--- trunk/core/kernel/utility/formatters/left_formatter.php (.../left_formatter.php) (revision 4758)
+++ trunk/core/kernel/utility/formatters/left_formatter.php (.../left_formatter.php) (revision 5340)
@@ -24,6 +24,7 @@
$db =& $this->Application->GetADODBConnection();
$sql = sprintf($options['left_sql'],$options['left_title_field'],$options['left_key_field'],$value);
$options['options'][$value] = $db->GetOne($sql);
+ if ($options['options'][$value] === false) return $value;
}
return $options['options'][$value];
}
Index: trunk/core/kernel/db/db_event_handler.php
===================================================================
diff -u -N -r5185 -r5340
--- trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 5185)
+++ trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 5340)
@@ -64,8 +64,8 @@
return true;
}
}
-
-
+
+
$section = $event->getSection();
if (!preg_match('/^CATEGORY:(.*)/', $section)) {
// only if not category item events
@@ -96,7 +96,7 @@
parent::mapPermissions();
$permissions = Array(
'OnLoad' => Array('self' => 'view', 'subitem' => 'view'),
-
+
'OnNew' => Array('self' => 'add', 'subitem' => 'add|edit'),
'OnCreate' => Array('self' => 'add', 'subitem' => 'add|edit'),
'OnUpdate' => Array('self' => 'edit', 'subitem' => 'add|edit'),
@@ -1399,12 +1399,12 @@
$t = $this->Application->RecallVar('return_template');
$this->Application->RemoveVar('return_template');
-
+
// restore original "m" prefix all params, that have values before opening selector
$return_m = $this->Application->RecallVar('return_m');
$this->Application->RemoveVar('return_m');
$this->Application->HttpQuery->parseEnvPart($return_m);
-
+
$pass_events = $event->getEventParam('pass_events');
$redirect_params = array_merge_recursive2($event->redirect_params, Array('m_opener' => 'u', '__URLENCODE__' => 1));
@@ -1672,13 +1672,13 @@
$object =& $event->getObject();
$this->RemoveRequiredFields($object);
$event->CallSubEvent('OnPreSave');
-
+
if ($event->status == erSUCCESS) {
-
+
$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()) {
@@ -1687,7 +1687,7 @@
}
$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(),
@@ -1696,14 +1696,14 @@
'trans_field' => $this->Application->GetVar('translator_field'),
'trans_multi_line' => $this->Application->GetVar('translator_multi_line'),
);
-
+
// 1. SAVE LAST TEMPLATE TO SESSION (really needed here, because of tweaky redirect)
$last_template = $this->Application->RecallVar('last_template');
preg_match('/index4\.php\|'.$this->Application->GetSID().'-(.*):/U', $last_template, $rets);
$this->Application->StoreVar('return_template', $this->Application->GetVar('t'));
}
}
-
+
function RemoveRequiredFields(&$object)
{
// making all field non-required to achieve successful presave
@@ -1715,7 +1715,7 @@
}
}
}
-
+
/**
* Dynamically fills customdata config
*
@@ -1741,7 +1741,7 @@
// config doesn't have custom fields
return false;
}
-
+
// 2. create fields (for customdata item)
$fields = $this->Application->getUnitOption($event->Prefix, 'Fields', Array());
$field_options = Array('type' => 'string', 'formatter' => 'kMultiLanguage', 'not_null' => 1, 'db_type' => 'text', 'default' => '');
@@ -1753,7 +1753,7 @@
// 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());
-
+
$cf_helper =& $this->Application->recallObject('InpCustomFieldsHelper');
$field_options = Array('type' => 'string', 'not_null' => 1, 'default' => '');
$ml_formatter =& $this->Application->recallObject('kMultiLanguage');
@@ -1766,7 +1766,7 @@
else {
unset($field_options['options'], $field_options['formatter']);
}
-
+
$custom_name = $custom_params['FieldName'];
$calculated_fields['cust_'.$custom_name] = 'cust.'.$ml_formatter->LangFieldName('cust_'.$custom_id);
if (!isset($virtual_fields['cust_'.$custom_name])) {
Index: trunk/core/kernel/utility/unit_config_reader.php
===================================================================
diff -u -N -r4899 -r5340
--- trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 4899)
+++ trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 5340)
@@ -17,6 +17,8 @@
var $ProcessAllConfigs = false;
var $FinalStage = false;
+ var $StoreCache = false;
+ var $AfterConfigProcessed = array();
/**
* Scan kernel and user classes
@@ -72,6 +74,8 @@
$conn =& $this->Application->GetADODBConnection();
$conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("configs_parsed", '.$conn->qstr(serialize($cache)).', '.adodb_mktime().')');
+ $conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("config_files", '.$conn->qstr(serialize($this->configFiles)).', '.adodb_mktime().')');
+ unset($this->configFiles);
}
function RestoreParsedData()
@@ -124,7 +128,7 @@
// disable config caching during installation
$cache = false;
}
-
+
if ($cache) {
$restored = $this->RestoreParsedData();
if ($restored) return;
@@ -134,14 +138,10 @@
$this->includeConfigFiles($folderPath, $cache);
$this->ParseConfigs();
-
- if ($cache) {
- $this->CacheParsedData();
- $conn =& $this->Application->GetADODBConnection();
- $conn->Query('REPLACE '.TABLE_PREFIX.'Cache (VarName, Data, Cached) VALUES ("config_files", '.$conn->qstr(serialize($this->configFiles)).', '.adodb_mktime().')');
- }
- unset($this->configFiles);
+ // tell AfterConfigRead to store cache if neede
+ // can't store it here beacuse AfterConfigRead needs ability to change config data
+ $this->StoreCache = $cache;
}
function findConfigFiles($folderPath)
@@ -211,8 +211,11 @@
// if (!$this->ProcessAllConfigs) return ;
$this->FinalStage = true;
foreach ($this->configData as $prefix => $config) {
+ if (in_array($prefix, $this->AfterConfigProcessed)) continue;
$this->Application->HandleEvent( new kEvent($prefix.':OnAfterConfigRead') );
+ $this->AfterConfigProcessed[] = $prefix;
}
+ if ($this->StoreCache) $this->CacheParsedData();
}
/**
@@ -314,7 +317,7 @@
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', E_USER_NOTICE);
}
-
+
if ($aggregate_tag['AggregateTo'] == '#PARENT#') {
$aggregate_tag['AggregateTo'] = $config['ParentPrefix'];
}
@@ -441,7 +444,7 @@
if (isset($config) && $config) {
// config file is included for 1st time -> save it's content for future processing
$prefix = isset($config['Prefix']) ? $config['Prefix'] : '';
-
+
preg_match('/\/(.*)\//U', $filename, $rets);
$config['ModuleFolder'] = $rets[1];
$config['BasePath'] = dirname(FULL_PATH.$filename);
@@ -594,7 +597,7 @@
// at installation start no modules in db and kernel configs could not be read
return true;
}
-
+
$module_found = false;
if (!$this->Application->ModuleInfo) return false;
Index: trunk/core/kernel/utility/formatters/date_formatter.php
===================================================================
diff -u -N -r4758 -r5340
--- trunk/core/kernel/utility/formatters/date_formatter.php (.../date_formatter.php) (revision 4758)
+++ trunk/core/kernel/utility/formatters/date_formatter.php (.../date_formatter.php) (revision 5340)
@@ -52,7 +52,7 @@
if ( !isset($object->CalculatedFields) || !is_array($object->CalculatedFields) ) {
$object->CalculatedFields = Array();
}
- $object->CalculatedFields[$field_name.'_formatted'] = 'FROM_UNIXTIME('.'`%1$s`.'.$field_name.', \''.$this->SQLFormat($field_options['format']).'\')';
+ $object->CalculatedFields[$field_name.'_formatted'] = 'FROM_UNIXTIME('.'`%1$s`.'.$field_name.' + '.$this->Application->TimeZoneAdjustment().', \''.$this->SQLFormat($field_options['format']).'\')';
$opts['format'] = $field_options['format'];
$opts['required'] = 0;
unset($opts['master_field']);
@@ -109,7 +109,7 @@
$options = $object->GetFieldOptions($field_name);
if ( isset($format) ) $options['format'] = $format;
- return adodb_date($options['format'], $value);
+ return adodb_date($options['format'], $value + $this->Application->TimeZoneAdjustment());
}
function HumanFormat($format)
@@ -323,7 +323,7 @@
return $value;
}
// echo "day: $day, month: $month, year: $year, hour: $hour, minute: $minute
";
- return adodb_mktime($hour, $minute, $second, $month, $day, $year);
+ return adodb_mktime($hour, $minute, $second, $month, $day, $year) - $this->Application->TimeZoneAdjustment();
}
function GetSample($field, &$options, &$object)