From c481ccafe9b86c4008a500a18bec211a5412eacb Mon Sep 17 00:00:00 2001 From: Vincent CHALAMON Date: Thu, 27 Oct 2011 17:31:38 +0200 Subject: [PATCH] Update widgets & validators --- lib/validator/sfValidatorDateCustom.class.php | 4 +- lib/validator/sfValidatorHourCustom.class.php | 4 +- lib/validator/sfValidatorMultiple.class.php | 1 + lib/validator/sfValidatorUrlCustom.class.php | 16 ------ lib/widget/sfWidgetFormDateJQueryUI.class.php | 4 -- .../sfWidgetFormInputAutocomplete.class.php | 3 +- .../sfWidgetFormInputCkeditor.class.php | 8 ++- ...getFormInputDoctrineAutocomplete.class.php | 1 + .../sfWidgetFormInputFilemanager.class.php | 51 +++++++++++++++++++ lib/widget/sfWidgetFormInputPlain.class.php | 16 +----- .../sfWidgetFormInputStarEvaluation.class.php | 1 + .../sfWidgetFormInputUploadify.class.php | 6 +++ lib/widget/sfWidgetFormKeyboard.class.php | 17 ------- .../lib/BasesfEPFactoryFormActions.class.php | 2 +- 14 files changed, 73 insertions(+), 61 deletions(-) create mode 100644 lib/widget/sfWidgetFormInputFilemanager.class.php diff --git a/lib/validator/sfValidatorDateCustom.class.php b/lib/validator/sfValidatorDateCustom.class.php index c933885..d1672e9 100644 --- a/lib/validator/sfValidatorDateCustom.class.php +++ b/lib/validator/sfValidatorDateCustom.class.php @@ -1,7 +1,5 @@ \d{2})/(?P\d{1,2})/(?P\d{4})~'; diff --git a/lib/validator/sfValidatorHourCustom.class.php b/lib/validator/sfValidatorHourCustom.class.php index b8837f7..4bf19a4 100644 --- a/lib/validator/sfValidatorHourCustom.class.php +++ b/lib/validator/sfValidatorHourCustom.class.php @@ -1,7 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * sfValidatorUrl validates Urls. - * - * @package symfony - * @subpackage validator - * @author Fabien Potencier - * @version SVN: $Id: sfValidatorUrl.class.php 22149 2009-09-18 14:09:53Z Kris.Wallsmith $ - */ class sfValidatorUrlCustom extends sfValidatorRegex { const REGEX_URL_FORMAT = "~^(/([A-z\d\_\-/#]+)?)|(@[A-z\_\-\d]+)|([A-z\_\-\d]+/[A-z\_\-\d]+)|((%s)://(([a-z0-9-]+\.)+[a-z]{2,6}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(:[0-9]+)?(/?|/\S+))$~ix"; diff --git a/lib/widget/sfWidgetFormDateJQueryUI.class.php b/lib/widget/sfWidgetFormDateJQueryUI.class.php index 627eb73..b73e487 100644 --- a/lib/widget/sfWidgetFormDateJQueryUI.class.php +++ b/lib/widget/sfWidgetFormDateJQueryUI.class.php @@ -1,9 +1,5 @@ generateId($name, $value), $this->generateId($name, $value)) : null + , $this->generateId($name, $value), $this->generateId($name, $value)) : null , $this->getOption("url") , $this->getOption('caching') ? sprintf('cache_%s[value] = datas;', $this->generateId($name, $value)) : null ).parent::render($name, $value, $attributes, $errors); diff --git a/lib/widget/sfWidgetFormInputCkeditor.class.php b/lib/widget/sfWidgetFormInputCkeditor.class.php index bb769bd..843a28f 100644 --- a/lib/widget/sfWidgetFormInputCkeditor.class.php +++ b/lib/widget/sfWidgetFormInputCkeditor.class.php @@ -6,6 +6,8 @@ protected function configure($options = array(), $attributes = array()) { parent::configure($options, $attributes); $this->addOption('width', 635); $this->addOption('height', 400); + $this->addOption('filemanager_path', "/uploads"); + $this->addOption('toolbar', "Custom"); } public function render($name, $value = null, $attributes = array(), $errors = array()) @@ -20,13 +22,17 @@ public function render($name, $value = null, $attributes = array(), $errors = ar EOF , $this->generateId($name, $value) , $this->getOption('width') , $this->getOption('height') + , $this->getOption('filemanager_path') + , $this->getOption("toolbar") ); } diff --git a/lib/widget/sfWidgetFormInputDoctrineAutocomplete.class.php b/lib/widget/sfWidgetFormInputDoctrineAutocomplete.class.php index 636be1b..1e7c2bf 100644 --- a/lib/widget/sfWidgetFormInputDoctrineAutocomplete.class.php +++ b/lib/widget/sfWidgetFormInputDoctrineAutocomplete.class.php @@ -1,4 +1,5 @@ addOption('path', '/uploads'); + $this->addOption('button_label', 'Parcourir'); + $this->addOption('is_image', false); + $this->addOption('width', 900); + $this->addOption('height', 500); + $this->addOption('returnFunction'); + } + + /** + * Renders the widget. + * + * @param string $name The element name + * @param string $value The value displayed in this widget + * @param array $attributes An array of HTML attributes to be merged with the default HTML attributes + * @param array $errors An array of errors for the field + * + * @return string An HTML tag string + * + * @see sfWidgetForm + */ + public function render($name, $value = null, $attributes = array(), $errors = array()) + { + return parent::render($name, $value, $attributes, $errors).sprintf(<< + $(document).ready(function(){ + $('#%s_filemanager').click(function(){ + window.open("/sfEPFactoryFormPlugin/ckeditor/filemanager/index.html?path=%s&returnId=%s%s", "Gestionnaire de fichiers", "width=%s,height=%s"); + }); + }); + +EOF + , $this->getOption('is_image') ? image_tag($value)."
" : null + , $this->renderTag("input", array('type' => 'button', 'value' => $this->getOption('button_label'), 'id' => $this->generateId($name, $value).'_filemanager')) + , $this->generateId($name, $value) + , $this->getOption('path') + , $this->generateId($name, $value) + , $this->getOption('returnFunction') ? "&returnFunction=".$this->getOption('returnFunction') : null + , $this->getOption('width') + , $this->getOption('height') + ); + } +} diff --git a/lib/widget/sfWidgetFormInputPlain.class.php b/lib/widget/sfWidgetFormInputPlain.class.php index a732837..5c196e6 100644 --- a/lib/widget/sfWidgetFormInputPlain.class.php +++ b/lib/widget/sfWidgetFormInputPlain.class.php @@ -1,19 +1,5 @@ - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -/** - * sfWidgetFormInputPlain represents a hidden HTML input tag with a span element with the value. - * - * @package symfony - * @subpackage widget - * @author Daniel Santiago - * @version SVN: $Id: sfWidgetFormInputPlain.class.php 68 2009-06-19 04:33:41Z hlwebs $ - */ + class sfWidgetFormInputPlain extends sfWidgetFormInputHidden { /** diff --git a/lib/widget/sfWidgetFormInputStarEvaluation.class.php b/lib/widget/sfWidgetFormInputStarEvaluation.class.php index fd75cf2..ccbaa1e 100644 --- a/lib/widget/sfWidgetFormInputStarEvaluation.class.php +++ b/lib/widget/sfWidgetFormInputStarEvaluation.class.php @@ -1,4 +1,5 @@ '); } + // S'il n'est pas multiple, qu'il est éditable et qu'il a déjà une valeur : supprimer la div correspondante + if(%s && %s && $(event.target).val().length) { + $('#' + $(event.target).attr('id') + '_listQueue_custom .uploadifyQueueItem .cancel a').click(); + } $(event.target).val(%s ? $(event.target).val() + ($(event.target).val().length ? ";" : "") + response : response); $('#' + $(event.target).attr('id') + ID).append(''); } @@ -163,6 +167,8 @@ public function getScript($name) , $this->getOption('max') , $this->getOption('alertFunction') , $this->getOption('is_image') ? 'true' : 'false' + , $this->getOption('multi') ? 'false' : 'true' + , $this->getOption('editable') ? 'true' : 'false' , $this->getOption('multi') ? 'true' : 'false' , $this->getOption('alertFunction') , str_ireplace("'", "\'", str_ireplace('%%max%%', $this->getOption('max'), $this->getOption('fullMessage'))) diff --git a/lib/widget/sfWidgetFormKeyboard.class.php b/lib/widget/sfWidgetFormKeyboard.class.php index 1b3717b..913e1c8 100644 --- a/lib/widget/sfWidgetFormKeyboard.class.php +++ b/lib/widget/sfWidgetFormKeyboard.class.php @@ -1,22 +1,5 @@ - * @version SVN: $Id: sfWidgetFormInputPlain.class.php 68 2009-06-19 04:33:41Z hlwebs $ - */ class sfWidgetFormKeyboard extends sfWidgetForm { protected function configure($options = array(), $attributes = array()) { diff --git a/modules/sfEPFactoryForm/lib/BasesfEPFactoryFormActions.class.php b/modules/sfEPFactoryForm/lib/BasesfEPFactoryFormActions.class.php index 7483110..8075ff7 100644 --- a/modules/sfEPFactoryForm/lib/BasesfEPFactoryFormActions.class.php +++ b/modules/sfEPFactoryForm/lib/BasesfEPFactoryFormActions.class.php @@ -2,7 +2,7 @@ class BasesfEPFactoryFormActions extends sfActions { - public function executeUploadify($request) + public function executeUploadify(sfWebRequest $request) { $this->forward404Unless($request->isMethod("post")); sfConfig::set('sf_web_debug', false);