Author: Krapulator
Date: 2010-02-26 01:37:52 +0100 (Fri, 26 Feb 2010)
New Revision: 28300
Removed:
plugins/sfJqueryFormValidationPlugin/lib/helper/
Modified:
plugins/sfJqueryFormValidationPlugin/lib/sfJqueryFormValidationRules.class.php
plugins/sfJqueryFormValidationPlugin/package.xml
Log:
Continued work on new, updated version.
Modified:
plugins/sfJqueryFormValidationPlugin/lib/sfJqueryFormValidationRules.class.php
===================================================================
---
plugins/sfJqueryFormValidationPlugin/lib/sfJqueryFormValidationRules.class.php
2010-02-25 19:44:55 UTC (rev 28299)
+++
plugins/sfJqueryFormValidationPlugin/lib/sfJqueryFormValidationRules.class.php
2010-02-26 00:37:52 UTC (rev 28300)
@@ -18,6 +18,12 @@
'sfValidatorFile' => array(
'rules' => array('accept' => true),
'keymap' => array('mime_types' => 'accept'),
+ 'msgmap' => array('mime_types' => 'accept'),
+ 'valmap' => array(
+ 'mime_types' => array(
+ 'web_images' => 'jpg|jpeg|png|gif'
+ ),
+ ),
),
'sfValidatorRegex' => array(
@@ -80,7 +86,7 @@
{
$message = sizeof($this->messages) > 0 ?
stripslashes(json_encode($this->messages)) : '{}';
// this is a nasty hack to return a javascript function as an unquoted
value
- // see line 229 for the matching hackery
+ // see line 247 for the matching hackery
$message = str_replace('"[[', 'function(a, elem)', $message);
$message = str_replace(']]"', '', $message);
$message = str_replace('\" +', '" +', $message);
@@ -145,6 +151,19 @@
$val = str_replace('/', '',
$field_options[$matches[1]]);
}
+ // if there is value replacements for this field,
action them now
+ if(!$original_key =
$this->getOriginalFieldKey($widget_name, $key))
+ {
+ $original_key = $key;
+ }
+ if(isset($field_options[$original_key]))
+ {
+
if(isset($properties['valmap'][$original_key][$field_options[$original_key]]))
+ {
+ $val =
$properties['valmap']['mime_types'][$field_options[$original_key]];
+ }
+ }
+
// add the validation rule
$this->addRule($validation_name, $key, $val);
@@ -225,7 +244,7 @@
$val = addslashes($val);
// replace any placeholder values
- // this is a nasty hack (see line 81 for the matching hackery)
+ // this is a nasty hack (see line 88 for the matching hackery)
if(strpos($val, '%value%') !== false)
{
$val = '[[{ return \'' . str_replace('%value%', "' + $(elem).val() +
'", $val) . '\';}]]';
@@ -287,27 +306,47 @@
{
if($pv = $form->getValidatorSchema()->getPostValidator())
{
- $post_validators[] = $this->parseValidator($pv);
+ $post_validators[] = $this->parsePostValidator($form,
$pv);
}
}
return sizeof($post_validators) > 0 ? $post_validators : null;
}
- private function parseValidator(sfValidatorBase $validator)
+ private function parsePostValidator(sfForm $form, sfValidatorBase
$validator)
{
- switch(get_class($validator))
+ $options = $validator->getOptions();
+ $messages = $validator->getMessages();
+ $left_field = '#' . $form->getName() . '_' . $options['left_field'];
+ $right_field = '#' . $form->getName() . '_' . $options['right_field'];
+ $rules = array();
+ switch(get_class($validator))
{
- /*
case 'sfValidatorSchemaCompare':
- return $js = '$("#' . $name . '_' .
$options['right_field'] . '").rules("add", {
- equalTo: "#' . $name . '_' . $options['left_field'] . '",
- messages: {
- equalTo: "' . $messages['invalid'] . '"
- }
- });';
+ if($options['operator'] == '==')
+ {
+ $rules['equalTo'] = $right_field;
+ $rules['messages'] = array(
+ 'equalTo' => $messages['invalid'],
+ );
+ return "$('$left_field').rules('add', " .
stripslashes(json_encode($rules)) . ");";
+ }
break;
- */
}
}
+
+ private function getOriginalFieldKey($widget_name, $key)
+ {
+ if($keymap = self::$widgets[$widget_name]['keymap'])
+ {
+ foreach(self::$widgets[$widget_name]['keymap'] as $orig_key =>
$val)
+ {
+ if($key == $val)
+ {
+ return $orig_key;
+ }
+ }
+ }
+ return false;
+ }
}
\ No newline at end of file
Modified: plugins/sfJqueryFormValidationPlugin/package.xml
===================================================================
--- plugins/sfJqueryFormValidationPlugin/package.xml 2010-02-25 19:44:55 UTC
(rev 28299)
+++ plugins/sfJqueryFormValidationPlugin/package.xml 2010-02-26 00:37:52 UTC
(rev 28300)
@@ -12,11 +12,11 @@
<email>[email protected]</email>
<active>yes</active>
</lead>
- <date>2009-08-29</date>
+ <date>2010-02-26</date>
<time>09:37:00</time>
<version>
- <release>1.0.0</release>
- <api>1.0.0</api>
+ <release>1.1.0</release>
+ <api>1.1.0</api>
</version>
<stability>
<release>stable</release>
@@ -37,14 +37,11 @@
<!-- model classes -->
<file role="data" name="sfJqueryFormValidationFilter.class.php" />
</dir>
- <dir name="helper">
- <!-- tasks -->
- <file role="data" name="JqueryFormValHelper.php" />
- </dir>
<dir name="routing">
<!-- validators -->
<file role="data" name="sfJqueryFormValRouting.php" />
</dir>
+ <file role="data" name="sfJqueryFormValidationRules.class.php"
/>
</dir>
<dir name="modules">
<dir name="sfJqueryFormVal">
@@ -59,7 +56,7 @@
<dependencies>
<required>
<php>
- <min>5.1.0</min>
+ <min>5.2.0</min>
</php>
<pearinstaller>
<min>1.4.1</min>
@@ -67,8 +64,8 @@
<package>
<name>symfony</name>
<channel>pear.symfony-project.com</channel>
- <min>1.2.0</min>
- <max>1.3.0</max>
+ <min>1.2</min>
+ <max>1.4</max>
</package>
</required>
</dependencies>
@@ -188,5 +185,21 @@
Made javascript head include urls more flexible. Fixed a number of
other small bugs.
</notes>
</release>
+ <release>
+ <version>
+ <release>1.1.0</release>
+ <api>1.1.0</api>
+ </version>
+ <stability>
+ <release>stable</release>
+ <api>stable</api>
+ </stability>
+ <license uri="http://www.symfony-project.com/license">MIT
license</license>
+ <date>2010-02-26</date>
+ <license>MIT</license>
+ <notes>
+ Rewrote to make better use of OO and native JSON functionality in PHP.
Added support for embedded forms. Added support for Symfony 1.3/1.4.
+ </notes>
+ </release>
</changelog>
</package>
\ No newline at end of file
--
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.