Index: trunk/core/kernel/db/db_tag_processor.php
===================================================================
diff -u -r8460 -r8472
--- trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 8460)
+++ trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 8472)
@@ -282,6 +282,12 @@
return $ret;
}
+ /**
+ * Prepares name for field with event in it (used only on front-end)
+ *
+ * @param Array $params
+ * @return string
+ */
function SubmitName($params)
{
$list =& $this->GetList($params);
Index: trunk/core/units/general/helpers/helpers_config.php
===================================================================
diff -u -r8067 -r8472
--- trunk/core/units/general/helpers/helpers_config.php (.../helpers_config.php) (revision 8067)
+++ trunk/core/units/general/helpers/helpers_config.php (.../helpers_config.php) (revision 8472)
@@ -20,5 +20,7 @@
Array('pseudo'=>'PriorityHelper','class'=>'kPriorityHelper','file'=>'priority_helper.php','build_event'=>'','require_classes'=>'kHelper'),
Array('pseudo' => 'CurlHelper', 'class' => 'kCurlHelper','file' => 'curl_helper.php', 'build_event' => '', 'require_classes' => Array('kHelper')),
Array('pseudo'=>'CountHelper','class'=>'kCountHelper','file'=>'count_helper.php','build_event'=>'','require_classes'=>'kHelper'),
+
+ Array('pseudo'=>'ImageHelper','class'=>'ImageHelper','file'=>'image_helper.php','build_event'=>'','require_classes'=>'kHelper'),
),
);
\ No newline at end of file
Index: trunk/core/units/categories/categories_event_handler.php
===================================================================
diff -u -r8452 -r8472
--- trunk/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 8452)
+++ trunk/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 8472)
@@ -673,6 +673,21 @@
$this->Application->EmailEventAdmin($perm_prefix.'.'.$event_suffix);
$this->Application->EmailEventUser($perm_prefix.'.'.$event_suffix, $object->GetDBField('CreatedById'));
}
+
+ /**
+ * Returns current per-page setting for list
+ *
+ * @param kEvent $event
+ * @return int
+ */
+ function getPerPage(&$event)
+ {
+ if (!$this->Application->IsAdmin()) {
+ $event->setEventParam('same_special', true);
+ }
+
+ return parent::getPerPage($event);
+ }
}
?>
\ No newline at end of file
Index: trunk/core/units/general/cat_event_handler.php
===================================================================
diff -u -r8460 -r8472
--- trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 8460)
+++ trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 8472)
@@ -2083,72 +2083,11 @@
*/
function SetSorting(&$event)
{
- if ($this->Application->IsAdmin()) {
- parent::SetSorting($event);
- return ;
+ if (!$this->Application->IsAdmin()) {
+ $event->setEventParam('same_special', true);
}
- $event->setPseudoClass('_List');
- $object =& $event->getObject();
-
- $cur_sort1 = $this->Application->RecallVar($event->Prefix.'_Sort1');
- $cur_sort1_dir = $this->Application->RecallVar($event->Prefix.'_Sort1_Dir');
- $cur_sort2 = $this->Application->RecallVar($event->Prefix.'_Sort2');
- $cur_sort2_dir = $this->Application->RecallVar($event->Prefix.'_Sort2_Dir');
-
-
- $sorting_configs = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
- $list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings');
- $sorting_prefix = getArrayValue($list_sortings, $event->Special) ? $event->Special : '';
-
- $tag_sort_by = $event->getEventParam('sort_by');
- if ($tag_sort_by) {
- if ($tag_sort_by == 'random') {
- $by = 'RAND()';
- $dir = '';
- }
- else {
- list($by, $dir) = explode(',', $tag_sort_by);
- }
- $object->AddOrderField($by, $dir);
- }
-
- if ($sorting_configs && isset ($sorting_configs['DefaultSorting1Field'])){
- $list_sortings[$sorting_prefix]['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']),
- );
- }
-
- // Use default if not specified
- if ( !$cur_sort1 || !$cur_sort1_dir)
- {
- if ( $sorting = getArrayValue($list_sortings, $sorting_prefix, 'Sorting') ) {
- reset($sorting);
- $cur_sort1 = key($sorting);
- $cur_sort1_dir = current($sorting);
- if (next($sorting)) {
- $cur_sort2 = key($sorting);
- $cur_sort2_dir = current($sorting);
- }
- }
- }
-
- if ( $forced_sorting = getArrayValue($list_sortings, $sorting_prefix, 'ForcedSorting') ) {
- foreach ($forced_sorting as $field => $dir) {
- $object->AddOrderField($field, $dir);
- }
- }
-
- if($cur_sort1 != '' && $cur_sort1_dir != '')
- {
- $object->AddOrderField($cur_sort1, $cur_sort1_dir);
- }
-
- if($cur_sort2 != '' && $cur_sort2_dir != '')
- {
- $object->AddOrderField($cur_sort2, $cur_sort2_dir);
- }
+ parent::SetSorting($event);
}
/**
@@ -2159,16 +2098,11 @@
*/
function getPerPage(&$event)
{
- if ($this->Application->IsAdmin()) {
- return parent::getPerPage($event);
+ if (!$this->Application->IsAdmin()) {
+ $event->setEventParam('same_special', true);
}
- $special = $event->Special;
- $event->Init($event->Prefix);
- $per_page = parent::getPerPage($event);
- $event->Init($event->Prefix, $special);
-
- return $per_page;
+ return parent::getPerPage($event);
}
}
Index: trunk/core/units/images/image_tag_processor.php
===================================================================
diff -u -r8391 -r8472
--- trunk/core/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 8391)
+++ trunk/core/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 8472)
@@ -15,13 +15,13 @@
if (!$image_url) {
return ;
}
-
+
$block_params['img_path'] = $image_url;
$image_dimensions = $this->ImageSize($block_params);
$block_params['img_size'] = $image_dimensions ? $image_dimensions : ' width="'.$block_params['DefaultWidth'].'"';
$block_params['alt'] = htmlspecialchars($object->GetField('AltName')); // really used ?
}
-
+
/**
* [AGGREGATED TAG] works as
*
@@ -62,10 +62,10 @@
function LoadItemImage($params)
{
$parent_item =& $this->Application->recallObject($params['PrefixSpecial']);
-
+
$object =& $this->Application->recallObject($this->getPrefixSpecial(), null, Array('skip_autoload' => true));
/* @var $object kDBItem */
-
+
$object->Clear();
// if we need primary thumbnail which is preloaded with products list
@@ -116,9 +116,9 @@
function ImageSrc($params)
{
$object =& $this->getObject($params);
-
+
$base_url = rtrim($this->Application->BaseURL(), '/');
-
+
$ret = '';
// if we need thumb, or full image is same as thumb
if ( $this->SelectParam($params, 'thumbnail,Thumbnail') || $object->GetDBField('SameImages') )
@@ -169,38 +169,15 @@
{
$img_path = $this->getFullPath($params['img_path']);
- if (!file_exists($img_path)) {
+ $image_helper =& $this->Application->recallObject('ImageHelper');
+ /* @var $image_helper ImageHelper */
+
+ $image_dimensions = $image_helper->GetImageDimensions($img_path, getArrayValue($params, 'MaxWidth'), getArrayValue($params, 'MaxHeight'));
+ if (!$image_dimensions) {
return false;
}
-
- $image_info = @getimagesize($img_path);
- if (!$image_info) {
- trigger_error('Image '.$img_path.' missing or invalid', E_USER_WARNING);
- return false;
- }
- $orig_width = getArrayValue($image_info, 0);
- $orig_height = getArrayValue($image_info, 1);
- $max_width = getArrayValue($params, 'MaxWidth');
- $max_height = getArrayValue($params, 'MaxHeight');
-
- $too_large = is_numeric($max_width) ? ($orig_width > $max_width) : false;
- $too_large = $too_large || (is_numeric($max_height) ? ($orig_height > $max_height) : false);
-
- if ($too_large) {
- $width_ratio = $max_width ? $max_width / $orig_width : 1;
- $height_ratio = $max_height ? $max_height / $orig_height : 1;
- $ratio = min($width_ratio, $height_ratio);
-
- $width = ceil($orig_width * $ratio);
- $height = ceil($orig_height * $ratio);
- }
- else {
- $width = $orig_width;
- $height = $orig_height;
- }
-
- return ' width="'.$width.'" height="'.$height.'"';
+ return ' width="'.$image_dimensions[0].'" height="'.$image_dimensions[1].'"';
}
/**
@@ -215,7 +192,7 @@
if (!$image_url) {
return ;
}
-
+
$object =& $this->getObject($params);
$params['img_path'] = $image_url;
$image_dimensions = $this->ImageSize($params);
@@ -225,8 +202,8 @@
return $this->Application->ParseBlock($params);
}
-
-
+
+
/**
* Returns url for image in case when image source is url (for admin)
*
Index: trunk/core/kernel/db/db_event_handler.php
===================================================================
diff -u -r8460 -r8472
--- trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 8460)
+++ trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 8472)
@@ -675,11 +675,13 @@
if (!$per_page) {
// per-page is stored to persistent session
$view_name = $this->Application->RecallVar($event->getPrefixSpecial().'_current_view');
- $per_page = $this->Application->RecallPersistentVar($event->getPrefixSpecial().'_PerPage.'.$view_name);
+ $storage_prefix = $event->getEventParam('same_special') ? $event->Prefix : $event->getPrefixSpecial();
+ $per_page = $this->Application->RecallPersistentVar($storage_prefix.'_PerPage.'.$view_name);
+
if (!$per_page) {
// per-page is stored to current session
- $per_page = $this->Application->RecallVar($event->getPrefixSpecial().'_PerPage');
+ $per_page = $this->Application->RecallVar($storage_prefix.'_PerPage');
}
if (!$per_page) {
@@ -712,12 +714,12 @@
$event->setPseudoClass('_List');
$object =& $event->getObject();
- $cur_sort1 = $this->Application->RecallVar($event->Prefix_Special.'_Sort1');
- $cur_sort1_dir = $this->Application->RecallVar($event->Prefix_Special.'_Sort1_Dir');
- $cur_sort2 = $this->Application->RecallVar($event->Prefix_Special.'_Sort2');
- $cur_sort2_dir = $this->Application->RecallVar($event->Prefix_Special.'_Sort2_Dir');
+ $storage_prefix = $event->getEventParam('same_special') ? $event->Prefix : $event->Prefix_Special;
+ $cur_sort1 = $this->Application->RecallVar($storage_prefix.'_Sort1');
+ $cur_sort1_dir = $this->Application->RecallVar($storage_prefix.'_Sort1_Dir');
+ $cur_sort2 = $this->Application->RecallVar($storage_prefix.'_Sort2');
+ $cur_sort2_dir = $this->Application->RecallVar($storage_prefix.'_Sort2_Dir');
-
$sorting_configs = $this->Application->getUnitOption($event->Prefix, 'ConfigMapping');
$list_sortings = $this->Application->getUnitOption($event->Prefix, 'ListSortings');
$sorting_prefix = getArrayValue($list_sortings, $event->Special) ? $event->Special : '';
Index: trunk/kernel/units/images/image_tag_processor.php
===================================================================
diff -u -r8391 -r8472
--- trunk/kernel/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 8391)
+++ trunk/kernel/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 8472)
@@ -15,13 +15,13 @@
if (!$image_url) {
return ;
}
-
+
$block_params['img_path'] = $image_url;
$image_dimensions = $this->ImageSize($block_params);
$block_params['img_size'] = $image_dimensions ? $image_dimensions : ' width="'.$block_params['DefaultWidth'].'"';
$block_params['alt'] = htmlspecialchars($object->GetField('AltName')); // really used ?
}
-
+
/**
* [AGGREGATED TAG] works as
*
@@ -62,10 +62,10 @@
function LoadItemImage($params)
{
$parent_item =& $this->Application->recallObject($params['PrefixSpecial']);
-
+
$object =& $this->Application->recallObject($this->getPrefixSpecial(), null, Array('skip_autoload' => true));
/* @var $object kDBItem */
-
+
$object->Clear();
// if we need primary thumbnail which is preloaded with products list
@@ -116,9 +116,9 @@
function ImageSrc($params)
{
$object =& $this->getObject($params);
-
+
$base_url = rtrim($this->Application->BaseURL(), '/');
-
+
$ret = '';
// if we need thumb, or full image is same as thumb
if ( $this->SelectParam($params, 'thumbnail,Thumbnail') || $object->GetDBField('SameImages') )
@@ -169,38 +169,15 @@
{
$img_path = $this->getFullPath($params['img_path']);
- if (!file_exists($img_path)) {
+ $image_helper =& $this->Application->recallObject('ImageHelper');
+ /* @var $image_helper ImageHelper */
+
+ $image_dimensions = $image_helper->GetImageDimensions($img_path, getArrayValue($params, 'MaxWidth'), getArrayValue($params, 'MaxHeight'));
+ if (!$image_dimensions) {
return false;
}
-
- $image_info = @getimagesize($img_path);
- if (!$image_info) {
- trigger_error('Image '.$img_path.' missing or invalid', E_USER_WARNING);
- return false;
- }
- $orig_width = getArrayValue($image_info, 0);
- $orig_height = getArrayValue($image_info, 1);
- $max_width = getArrayValue($params, 'MaxWidth');
- $max_height = getArrayValue($params, 'MaxHeight');
-
- $too_large = is_numeric($max_width) ? ($orig_width > $max_width) : false;
- $too_large = $too_large || (is_numeric($max_height) ? ($orig_height > $max_height) : false);
-
- if ($too_large) {
- $width_ratio = $max_width ? $max_width / $orig_width : 1;
- $height_ratio = $max_height ? $max_height / $orig_height : 1;
- $ratio = min($width_ratio, $height_ratio);
-
- $width = ceil($orig_width * $ratio);
- $height = ceil($orig_height * $ratio);
- }
- else {
- $width = $orig_width;
- $height = $orig_height;
- }
-
- return ' width="'.$width.'" height="'.$height.'"';
+ return ' width="'.$image_dimensions[0].'" height="'.$image_dimensions[1].'"';
}
/**
@@ -215,7 +192,7 @@
if (!$image_url) {
return ;
}
-
+
$object =& $this->getObject($params);
$params['img_path'] = $image_url;
$image_dimensions = $this->ImageSize($params);
@@ -225,8 +202,8 @@
return $this->Application->ParseBlock($params);
}
-
-
+
+
/**
* Returns url for image in case when image source is url (for admin)
*
Index: trunk/core/kernel/parser/tags.php
===================================================================
diff -u -r8374 -r8472
--- trunk/core/kernel/parser/tags.php (.../tags.php) (revision 8374)
+++ trunk/core/kernel/parser/tags.php (.../tags.php) (revision 8472)
@@ -419,7 +419,7 @@
// $code[] = '$o .= $application->CachedProcessors["'.$this->getPrefixSpecial().'"]->ProcessParsedTag(\''.$tag_func.'\', '.$to_pass.', "'.$this->Processor.'");'."\n";
- $code[] = '$o .= $p->ProcessParsedTag(\''.$tag_func.'\', '.$to_pass.', "'.$this->Processor.'");'."\n";
+ $code[] = '$o .= $p->ProcessParsedTag(\''.$tag_func.'\', '.$to_pass.', "'.$prefix.'");'."\n"; // $this->Processor
/*$code = ' $processor =& $application->recallObject(\''.$this->Processor.'_TagProcessor\');
$o .= $processor->ProcessParsedTag(\''.$this->Tag.'\', unserialize(\''.serialize($this->NP).'\'));';*/
Index: trunk/core/units/general/cat_tag_processor.php
===================================================================
diff -u -r8460 -r8472
--- trunk/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 8460)
+++ trunk/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 8472)
@@ -323,6 +323,12 @@
return $list->PerPage == $params['per_page'] ? $params['selected'] : '';
}
+ /**
+ * Prepares name for field with event in it (used only on front-end)
+ *
+ * @param Array $params
+ * @return string
+ */
function SubmitName($params)
{
return 'events['.$this->Prefix.']['.$params['event'].']';
Index: trunk/core/units/categories/categories_tag_processor.php
===================================================================
diff -u -r8451 -r8472
--- trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 8451)
+++ trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 8472)
@@ -549,6 +549,23 @@
$params['cat_id'] = $object->isLoaded() ? $object->GetDBField('ParentPath') : $this->Application->GetVar('m_cat_id');
return $perm_helper->TagPermissionCheck($params, $this->getPrefixSpecial().'_HasPermission');
}
+
+ function PerPageSelected($params)
+ {
+ $list =& $this->GetList($params);
+ return $list->PerPage == $params['per_page'] ? $params['selected'] : '';
+ }
+
+ /**
+ * Prepares name for field with event in it (used only on front-end)
+ *
+ * @param Array $params
+ * @return string
+ */
+ function SubmitName($params)
+ {
+ return 'events['.$this->Prefix.']['.$params['event'].']';
+ }
}