Index: trunk/core/kernel/db/db_tag_processor.php
===================================================================
diff -u -r8472 -r8474
--- trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 8472)
+++ trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 8474)
@@ -1066,6 +1066,13 @@
$ret = 'field_modifiers['.$this->getPrefixSpecial().']['.$field.']['.$params['type'].']';
if( getArrayValue($params, 'as_preg') ) $ret = preg_quote($ret, '/');
+
+ if (isset($params['value'])) {
+ $object =& $this->getObject($params);
+ $field_modifiers[$field][$params['type']] = $params['value'];
+ $object->ApplyFieldModifiers($field_modifiers);
+ }
+
return $ret;
}
Index: trunk/core/units/images/image_tag_processor.php
===================================================================
diff -u -r8472 -r8474
--- trunk/core/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 8472)
+++ trunk/core/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 8474)
@@ -31,19 +31,7 @@
function ItemImage($params)
{
$this->LoadItemImage($params);
- $params['img_path'] = $this->ImageSrc($params);
- $params['img_size'] = $this->ImageSize($params);
- if (!$params['img_size']){
- if (isset($params['DefaultWidth'])) {
- $params['img_size'] = ' width="'.getArrayValue($params, 'DefaultWidth').'"';
- }
- }
- $params['name'] = $this->SelectParam($params, 'render_as,block');
- $object =& $this->getObject($params);
- if ( !$object->isLoaded() && !$this->SelectParam($params, 'default_image,DefaultImage') ) return false;
-
- $params['alt'] = htmlspecialchars($object->GetField('AltName'));
- return $this->Application->ParseBlock($params);
+ return $this->Image($params);
}
function LargeImageExists($params)
@@ -200,6 +188,10 @@
$params['alt'] = htmlspecialchars($object->GetField('AltName')); // really used ?
$params['name'] = $this->SelectParam($params, 'block,render_as');
+ if (!$object->isLoaded() && !$this->SelectParam($params, 'default_image,DefaultImage')) {
+ return false;
+ }
+
return $this->Application->ParseBlock($params);
}
Index: trunk/core/units/general/helpers/image_helper.php
===================================================================
diff -u
--- trunk/core/units/general/helpers/image_helper.php (revision 0)
+++ trunk/core/units/general/helpers/image_helper.php (revision 8474)
@@ -0,0 +1,77 @@
+ HTML tag)
+ *
+ * @param string $src_image full path to source image (already existing)
+ * @param int $dst_width destination image width (in pixels)
+ * @param int $dst_height destination image height (in pixels)
+ * @return Array resized image dimensions (0 - width, 1 - height)
+ */
+ function GetImageDimensions($src_image, $dst_width, $dst_height)
+ {
+ $image_info = $this->getImageInfo($src_image);
+ if (!$image_info) {
+ return false;
+ }
+
+ $orig_width = $image_info[0];
+ $orig_height = $image_info[1];
+
+ $too_large = is_numeric($dst_width) ? ($orig_width > $dst_width) : false;
+ $too_large = $too_large || (is_numeric($dst_height) ? ($orig_height > $dst_height) : false);
+
+ if ($too_large) {
+ $width_ratio = $dst_width ? $dst_width / $orig_width : 1;
+ $height_ratio = $dst_height ? $dst_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 Array ($width, $height);
+ }
+
+ /**
+ * Returns image dimensions + checks if given file is existing image
+ *
+ * @param string $src_image full path to source image (already existing)
+ * @return mixed
+ */
+ function getImageInfo($src_image)
+ {
+ if (!file_exists($src_image)) {
+ return false;
+ }
+
+ $image_info = @getimagesize($src_image);
+ if (!$image_info) {
+ trigger_error('Image '.$src_image.' missing or invalid', E_USER_WARNING);
+ return false;
+ }
+
+ return $image_info;
+ }
+ }
+
+?>
\ No newline at end of file
Index: trunk/kernel/units/images/image_tag_processor.php
===================================================================
diff -u -r8472 -r8474
--- trunk/kernel/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 8472)
+++ trunk/kernel/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 8474)
@@ -31,19 +31,7 @@
function ItemImage($params)
{
$this->LoadItemImage($params);
- $params['img_path'] = $this->ImageSrc($params);
- $params['img_size'] = $this->ImageSize($params);
- if (!$params['img_size']){
- if (isset($params['DefaultWidth'])) {
- $params['img_size'] = ' width="'.getArrayValue($params, 'DefaultWidth').'"';
- }
- }
- $params['name'] = $this->SelectParam($params, 'render_as,block');
- $object =& $this->getObject($params);
- if ( !$object->isLoaded() && !$this->SelectParam($params, 'default_image,DefaultImage') ) return false;
-
- $params['alt'] = htmlspecialchars($object->GetField('AltName'));
- return $this->Application->ParseBlock($params);
+ return $this->Image($params);
}
function LargeImageExists($params)
@@ -200,6 +188,10 @@
$params['alt'] = htmlspecialchars($object->GetField('AltName')); // really used ?
$params['name'] = $this->SelectParam($params, 'block,render_as');
+ if (!$object->isLoaded() && !$this->SelectParam($params, 'default_image,DefaultImage')) {
+ return false;
+ }
+
return $this->Application->ParseBlock($params);
}
Index: trunk/core/kernel/kbase.php
===================================================================
diff -u -r8428 -r8474
--- trunk/core/kernel/kbase.php (.../kbase.php) (revision 8428)
+++ trunk/core/kernel/kbase.php (.../kbase.php) (revision 8474)
@@ -434,18 +434,25 @@
* @access private
* @author Alex
*/
- function ApplyFieldModifiers()
+ function ApplyFieldModifiers($field_modifiers = null)
{
-// $this->Application->APCalled[] = $this->getPrefixSpecial();
-
$allowed_modifiers = Array('required');
- $field_modifiers = $this->Application->GetVar('field_modifiers');
- if(!$field_modifiers) return false;
+ if (!isset($field_modifiers)) {
+ $field_modifiers = $this->Application->GetVar('field_modifiers');
+ if (!$field_modifiers) {
+ // no field modifiers
+ return false;
+ }
- $field_modifiers = getArrayValue($field_modifiers, $this->getPrefixSpecial());
- if(!$field_modifiers) return false;
+ $field_modifiers = getArrayValue($field_modifiers, $this->getPrefixSpecial());
+ }
+ if (!$field_modifiers) {
+ // no field modifiers for current prefix_special
+ return false;
+ }
+
foreach ($field_modifiers as $field => $field_options)
{
foreach ($field_options as $option_name => $option_value)