Author: uncleringo
Date: 2010-01-19 17:47:08 +0100 (Tue, 19 Jan 2010)
New Revision: 26887
Modified:
plugins/sfDoctrineJCroppablePlugin/trunk/lib/widget/sfWidgetFormInputImageJCroppable.class.php
Log:
Displays 'No image' when there's no image uploaded yet
Doesn't display the delete image link when there's no image uploaded yet
Modified:
plugins/sfDoctrineJCroppablePlugin/trunk/lib/widget/sfWidgetFormInputImageJCroppable.class.php
===================================================================
---
plugins/sfDoctrineJCroppablePlugin/trunk/lib/widget/sfWidgetFormInputImageJCroppable.class.php
2010-01-19 15:51:04 UTC (rev 26886)
+++
plugins/sfDoctrineJCroppablePlugin/trunk/lib/widget/sfWidgetFormInputImageJCroppable.class.php
2010-01-19 16:47:08 UTC (rev 26887)
@@ -8,6 +8,7 @@
*/
class sfWidgetFormInputFileInputImageJCroppable extends sfWidgetFormInputFile
{
+ private $hasImage = false;
/**
* Constructor.
*
@@ -45,7 +46,7 @@
$this->addRequiredOption('file_src');
$this->addOption('with_delete', true);
- $this->addOption('delete_label', 'remove the current file');
+ $this->addOption('delete_label', 'remove the current image');
$this->addOption('image_field', null);
$this->addOption('image_ratio', null);
$this->addOption('invoker', null);
@@ -74,12 +75,15 @@
return $input;
}
+ $this->hasImage = (false !== $this->getOption('file_src')
+ && substr($this->getOption('file_src'), -1) != '/');
+
if (class_exists('sfJSLibManager'))
{
sfJSLibManager::addLib('jcrop');
}
- if ($this->getOption('with_delete'))
+ if ($this->hasImage && $this->getOption('with_delete'))
{
$deleteName = ']' == substr($name, -1) ? substr($name, 0, -1).'_delete]'
: $name.'_delete';
$form = $this->getOption('form');
@@ -108,7 +112,7 @@
{
$id = $this->getIdStub() . '_img';
- return false !== $this->getOption('file_src')
+ return $this->hasImage
?
$this->renderTag(
'img',
@@ -121,7 +125,7 @@
)
)
:
- '';
+ '<span>No image</span>';
}
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.