Index: branches/RC/core/units/images/image_tag_processor.php
===================================================================
diff -u -N -r8929 -r9256
--- branches/RC/core/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 8929)
+++ branches/RC/core/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 9256)
@@ -173,31 +173,15 @@
if ($object->GetDBField('SameImages') && $object->GetDBField('ThumbPath')) {
// we can auto-resize image, when source image available & we use same image for thumbnail & full image in admin
- $image_helper =& $this->Application->recallObject('ImageHelper');
- /* @var $image_helper ImageHelper */
-
$max_width = $this->getImageDimension('Width', $params);
$max_height = $this->getImageDimension('Height', $params);
if ($max_width > 0 || $max_height > 0) {
- // image auto-resize is required
- $src_image = FULL_PATH.$object->GetDBField('ThumbPath');
- list ($max_width, $max_height, $resized) = $image_helper->GetImageDimensions($src_image, $max_width, $max_height);
+ $image_helper =& $this->Application->recallObject('ImageHelper');
+ /* @var $image_helper ImageHelper */
- if ($resized) {
- $src_path = FULL_PATH.($this->Application->IsAdmin() ? IMAGES_PENDING_PATH : IMAGES_PATH);
- $dst_image = preg_replace('/^'.preg_quote($src_path, '/').'(.*)\.(.*)$/', $src_path.'resized/\\1_'.$max_width.'x'.$max_height.'.\\2', $src_image);
- if (!file_exists($dst_image) || filemtime($src_image) > filemtime($dst_image)) {
- // resized image not available OR should be recreated due source image change
- $image_resized = $image_helper->ScaleImage($src_image, $dst_image, $max_width, $max_height);
- if (!$image_resized) {
- // resize failed, because of server error
- $dst_image = $src_image;
- }
- }
-
- return preg_replace('/^'.preg_quote(FULL_PATH, '/').'(.*)/', $base_url.'\\1', $dst_image);
- }
+ $src_image = FULL_PATH.$object->GetDBField('ThumbPath');
+ return $image_helper->ResizeImage($src_image, $max_width, $max_height);
}
}
Index: branches/RC/core/units/general/helpers/image_helper.php
===================================================================
diff -u -N -r9252 -r9256
--- branches/RC/core/units/general/helpers/image_helper.php (.../image_helper.php) (revision 9252)
+++ branches/RC/core/units/general/helpers/image_helper.php (.../image_helper.php) (revision 9256)
@@ -3,6 +3,40 @@
class ImageHelper extends kHelper {
/**
+ * Resized given image to required dimensions & saves resized image to "resized" subfolder in source image folder
+ *
+ * @param string $src_image full path to image (on server)
+ * @param mixed $max_width maximal allowed resized image width or false if no limit
+ * @param mixed $max_height maximal allowed resized image height or false if no limit
+ * @return string direct url to resized image
+ */
+ function ResizeImage($src_image, $max_width, $max_height)
+ {
+ if ($max_width > 0 || $max_height > 0) {
+ list ($max_width, $max_height, $needs_resize) = $this->GetImageDimensions($src_image, $max_width, $max_height);
+
+ if ($needs_resize) {
+ $src_path = dirname($src_image);
+ $dst_image = preg_replace('/^'.preg_quote($src_path, '/').'(.*)\.(.*)$/', $src_path.'/resized\\1_'.$max_width.'x'.$max_height.'.\\2', $src_image);
+ if (!file_exists($dst_image) || filemtime($src_image) > filemtime($dst_image)) {
+ // resized image not available OR should be recreated due source image change
+ $image_resized = $this->ScaleImage($src_image, $dst_image, $max_width, $max_height);
+ if (!$image_resized) {
+ // resize failed, because of server error
+ $dst_image = $src_image;
+ }
+ }
+
+ // resize ok
+ $src_image = $dst_image;
+ }
+ }
+
+ $base_url = rtrim($this->Application->BaseURL(), '/');
+ return preg_replace('/^'.preg_quote(FULL_PATH, '/').'(.*)/', $base_url.'\\1', $src_image);
+ }
+
+ /**
* Proportionally resizes given image to destination dimensions
*
* @param string $src_image full path to source image (already existing)
Index: branches/RC/kernel/units/images/image_tag_processor.php
===================================================================
diff -u -N -r8929 -r9256
--- branches/RC/kernel/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 8929)
+++ branches/RC/kernel/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 9256)
@@ -173,31 +173,15 @@
if ($object->GetDBField('SameImages') && $object->GetDBField('ThumbPath')) {
// we can auto-resize image, when source image available & we use same image for thumbnail & full image in admin
- $image_helper =& $this->Application->recallObject('ImageHelper');
- /* @var $image_helper ImageHelper */
-
$max_width = $this->getImageDimension('Width', $params);
$max_height = $this->getImageDimension('Height', $params);
if ($max_width > 0 || $max_height > 0) {
- // image auto-resize is required
- $src_image = FULL_PATH.$object->GetDBField('ThumbPath');
- list ($max_width, $max_height, $resized) = $image_helper->GetImageDimensions($src_image, $max_width, $max_height);
+ $image_helper =& $this->Application->recallObject('ImageHelper');
+ /* @var $image_helper ImageHelper */
- if ($resized) {
- $src_path = FULL_PATH.($this->Application->IsAdmin() ? IMAGES_PENDING_PATH : IMAGES_PATH);
- $dst_image = preg_replace('/^'.preg_quote($src_path, '/').'(.*)\.(.*)$/', $src_path.'resized/\\1_'.$max_width.'x'.$max_height.'.\\2', $src_image);
- if (!file_exists($dst_image) || filemtime($src_image) > filemtime($dst_image)) {
- // resized image not available OR should be recreated due source image change
- $image_resized = $image_helper->ScaleImage($src_image, $dst_image, $max_width, $max_height);
- if (!$image_resized) {
- // resize failed, because of server error
- $dst_image = $src_image;
- }
- }
-
- return preg_replace('/^'.preg_quote(FULL_PATH, '/').'(.*)/', $base_url.'\\1', $dst_image);
- }
+ $src_image = FULL_PATH.$object->GetDBField('ThumbPath');
+ return $image_helper->ResizeImage($src_image, $max_width, $max_height);
}
}
Index: branches/RC/core/admin_templates/incs/form_blocks.tpl
===================================================================
diff -u -N -r8929 -r9256
--- branches/RC/core/admin_templates/incs/form_blocks.tpl (.../form_blocks.tpl) (revision 8929)
+++ branches/RC/core/admin_templates/incs/form_blocks.tpl (.../form_blocks.tpl) (revision 9256)
@@ -551,6 +551,26 @@
+
+
+
+
+
+
Index: branches/RC/core/kernel/db/db_tag_processor.php
===================================================================
diff -u -N -r9238 -r9256
--- branches/RC/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 9238)
+++ branches/RC/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 9256)
@@ -1939,6 +1939,94 @@
return $list->getPrefixSpecial().'_'.$params['type'];
}
+
+ /**
+ * Returns edit tabs by specified preset name or false in case of error
+ *
+ * @param string $preset_name
+ * @return mixed
+ */
+ function getEditTabs($preset_name)
+ {
+ $presets = $this->Application->getUnitOption($this->Prefix, 'EditTabPresets');
+
+ if (!$presets || !isset($presets[$preset_name]) || count($presets[$preset_name]) == 0) {
+ return false;
+ }
+
+ return $presets[$preset_name];
+ }
+
+ /**
+ * Detects if specified preset has tabs in it
+ *
+ * @param Array $params
+ * @return bool
+ */
+ function HasEditTabs($params)
+ {
+ return $this->getEditTabs($params['preset_name']) ? true : false;
+ }
+
+ /**
+ * Sorts edit tabs based on their priority
+ *
+ * @param Array $tab_a
+ * @param Array $tab_b
+ * @return int
+ */
+ function sortEditTabs($tab_a, $tab_b)
+ {
+ if ($tab_a['priority'] == $tab_b['priority']) {
+ return 0;
+ }
+
+ return $tab_a['priority'] < $tab_b['priority'] ? -1 : 1;
+ }
+
+ /**
+ * Prints edit tabs based on preset name specified
+ *
+ * @param Array $params
+ * @return string
+ */
+ function PrintEditTabs($params)
+ {
+ $edit_tabs = $this->getEditTabs($params['preset_name']);
+ if (!$edit_tabs) {
+ return ;
+ }
+ usort($edit_tabs, Array (&$this, 'sortEditTabs'));
+
+ $ret = '';
+ $block_params = $this->prepareTagParams($params);
+ $block_params['name'] = $params['render_as'];
+
+ foreach ($edit_tabs as $tab_info) {
+ $block_params['title'] = $tab_info['title'];
+ $block_params['template'] = $tab_info['t'];
+ $ret .= $this->Application->ParseBlock($block_params);
+ }
+
+ return $ret;
+ }
+
+ /**
+ * Performs image resize to required dimensions and returns resulting url (cached resized image)
+ *
+ * @param Array $params
+ * @return string
+ */
+ /*function ImageSrc($params)
+ {
+ $max_width = isset($params['MaxWidth']) ? $params['MaxWidth'] : false;
+ $max_height = isset($params['MaxHeight']) ? $params['MaxHeight'] : false;
+
+ $object =& $this->getObject($params);
+
+ $field = $this->SelectParam($params, 'name,field');
+ return $object->GetField($field, 'resize:'.$max_width.'x'.$max_height);
+ }*/
}
?>
\ No newline at end of file
Index: branches/RC/core/kernel/utility/formatters/upload_formatter.php
===================================================================
diff -u -N -r9253 -r9256
--- branches/RC/core/kernel/utility/formatters/upload_formatter.php (.../upload_formatter.php) (revision 9253)
+++ branches/RC/core/kernel/utility/formatters/upload_formatter.php (.../upload_formatter.php) (revision 9256)
@@ -216,7 +216,10 @@
$upload_dir = isset($options['upload_dir']) ? $options['upload_dir'] : $this->DestinationPath;
if (preg_match('/resize:([\d]*)x([\d]*)/', $format, $regs)) {
- return $this->resizeImage(FULL_PATH.$upload_dir.$value, $regs[1], $regs[2]);
+ $image_helper =& $this->Application->recallObject('ImageHelper');
+ /* @var $image_helper ImageHelper */
+
+ return $image_helper->ResizeImage(FULL_PATH.$upload_dir.$value, $regs[1], $regs[2]);
}
switch ($format) {
@@ -246,35 +249,6 @@
return sprintf($format, $value);
}
- function resizeImage($src_image, $max_width, $max_height)
- {
- if ($max_width > 0 || $max_height > 0) {
- $image_helper =& $this->Application->recallObject('ImageHelper');
- /* @var $image_helper ImageHelper */
-
- list ($max_width, $max_height, $resized) = $image_helper->GetImageDimensions($src_image, $max_width, $max_height);
-
- if ($resized) {
- $src_path = dirname($src_image);
- $dst_image = preg_replace('/^'.preg_quote($src_path, '/').'(.*)\.(.*)$/', $src_path.'/resized\\1_'.$max_width.'x'.$max_height.'.\\2', $src_image);
- if (!file_exists($dst_image) || filemtime($src_image) > filemtime($dst_image)) {
- // resized image not available OR should be recreated due source image change
- $image_resized = $image_helper->ScaleImage($src_image, $dst_image, $max_width, $max_height);
- if (!$image_resized) {
- // resize failed, because of server error
- $dst_image = $src_image;
- }
- }
-
- // resize ok
- $src_image = $dst_image;
- }
- }
-
- $base_url = rtrim($this->Application->BaseURL(), '/');
- return preg_replace('/^'.preg_quote(FULL_PATH, '/').'(.*)/', $base_url.'\\1', $src_image);
- }
-
function ValidateFileName($path, $name)
{
$parts = pathinfo($name);