Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Update widgets & validators
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon committed Oct 27, 2011
1 parent 1772ba5 commit c481cca
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 61 deletions.
4 changes: 1 addition & 3 deletions lib/validator/sfValidatorDateCustom.class.php
@@ -1,7 +1,5 @@
<?php
/**
*
*/

class sfValidatorDateCustom extends sfValidatorDate
{
const DEFAULT_BIRTHDATE_VALID_PATTERN = '~(?P<day>\d{2})/(?P<month>\d{1,2})/(?P<year>\d{4})~';
Expand Down
4 changes: 1 addition & 3 deletions lib/validator/sfValidatorHourCustom.class.php
@@ -1,7 +1,5 @@
<?php
/**
*
*/

class sfValidatorHourCustom extends sfValidatorTime
{
protected function doClean($value) {
Expand Down
1 change: 1 addition & 0 deletions lib/validator/sfValidatorMultiple.class.php
@@ -1,4 +1,5 @@
<?php

class sfValidatorMultiple extends sfValidatorBase
{
protected function configure($options = array(), $messages = array())
Expand Down
16 changes: 0 additions & 16 deletions lib/validator/sfValidatorUrlCustom.class.php
@@ -1,21 +1,5 @@
<?php

/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* 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 <fabien.potencier@symfony-project.com>
* @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";
Expand Down
4 changes: 0 additions & 4 deletions lib/widget/sfWidgetFormDateJQueryUI.class.php
@@ -1,9 +1,5 @@
<?php

/**
* @author Artur Rozek
* @version 1.0.0
*/
class sfWidgetFormDateJQueryUI extends sfWidgetFormInputText
{

Expand Down
3 changes: 2 additions & 1 deletion lib/widget/sfWidgetFormInputAutocomplete.class.php
@@ -1,4 +1,5 @@
<?php

class sfWidgetFormInputAutocomplete extends sfWidgetFormInputText
{
/**
Expand Down Expand Up @@ -82,7 +83,7 @@ public function render($name, $value = null, $attributes = array(), $errors = ar
return;
}
EOF
, $this->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);
Expand Down
8 changes: 7 additions & 1 deletion lib/widget/sfWidgetFormInputCkeditor.class.php
Expand Up @@ -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())
Expand All @@ -20,13 +22,17 @@ public function render($name, $value = null, $attributes = array(), $errors = ar
<script type="text/javascript">
CKEDITOR.replace('%s', {
width: %s,
height: %s
height: %s,
filebrowserBrowseUrl: "/sfEPFactoryFormPlugin/ckeditor/filemanager/index.html?path=%s",
toolbar: "%s"
});
</script>
EOF
, $this->generateId($name, $value)
, $this->getOption('width')
, $this->getOption('height')
, $this->getOption('filemanager_path')
, $this->getOption("toolbar")
);
}

Expand Down
1 change: 1 addition & 0 deletions lib/widget/sfWidgetFormInputDoctrineAutocomplete.class.php
@@ -1,4 +1,5 @@
<?php

class sfWidgetFormInputDoctrineAutocomplete extends sfWidgetFormInputAutocomplete
{
/**
Expand Down
51 changes: 51 additions & 0 deletions lib/widget/sfWidgetFormInputFilemanager.class.php
@@ -0,0 +1,51 @@
<?php

class sfWidgetFormInputFilemanager extends sfWidgetFormInputText
{
protected function configure($options = array(), $attributes = array())
{
parent::configure($options, $attributes);
$this->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(<<<EOF
%s
%s
<script type="text/javascript">
$(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");
});
});
</script>
EOF
, $this->getOption('is_image') ? image_tag($value)."<br />" : 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')
);
}
}
16 changes: 1 addition & 15 deletions lib/widget/sfWidgetFormInputPlain.class.php
@@ -1,19 +1,5 @@
<?php
/*
* This file is part of the HLW package.
* (c) Daniel Santiago <daniel.santiago@highlevelwebs.com>
*
* 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 <daniel.santiago@highlevelwebs.com>
* @version SVN: $Id: sfWidgetFormInputPlain.class.php 68 2009-06-19 04:33:41Z hlwebs $
*/

class sfWidgetFormInputPlain extends sfWidgetFormInputHidden
{
/**
Expand Down
1 change: 1 addition & 0 deletions lib/widget/sfWidgetFormInputStarEvaluation.class.php
@@ -1,4 +1,5 @@
<?php

/**
* sfWidgetFormInputStarEvaluation represents an evaluation with stars
*
Expand Down
6 changes: 6 additions & 0 deletions lib/widget/sfWidgetFormInputUploadify.class.php
Expand Up @@ -123,6 +123,10 @@ public function getScript($name)
if(%s) {
$('#' + $(event.target).attr('id') + ID).addClass('hasThumbnail').prepend('<img src="' + response + '" class="thumbnail" />');
}
// 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('<span style="display: none" class="value">' + response + '</span>');
}
Expand Down Expand Up @@ -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')))
Expand Down
17 changes: 0 additions & 17 deletions lib/widget/sfWidgetFormKeyboard.class.php
@@ -1,22 +1,5 @@
<?php

/**
* sfWidgetFormKeyboard represents a virtual keyboard.
*
* Available options:
*
* * layout: Keyboard layout (default: "arabic-azerty")
* * maxLength: Input max length (default: "false")
* * renderer_class: Widget rendering (default: "sfWidgetFormInputText")
* * renderer_options: Widget options (default: array())
* * theme: jQuery path to css theme (default: "/sfEPFactoryFormPlugin/jqueryui/smoothness/jquery-ui.css")
* * url: Url for autocomplete
*
* @package symfony
* @subpackage widget
* @author Daniel Santiago <daniel.santiago@highlevelwebs.com>
* @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()) {
Expand Down
Expand Up @@ -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);
Expand Down

0 comments on commit c481cca

Please sign in to comment.