PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/redirect/code/trunk/administrator/components/com_redirect/libraries/jxtended/form/rules/equals.php

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 51 lines | 19 code | 6 blank | 26 comment | 3 complexity | 636f54e80d4f4e89f4fb81f1af8dc820 MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: equals.php 390 2010-11-05 11:35:33Z eddieajau $
  4. * @package JXtended.Libraries
  5. * @subpackage Form
  6. * @copyright Copyright 2005 - 2010 New Life in IT Pty Ltd. All rights reserved.
  7. * @license GNU General Public License
  8. * @link http://www.theartofjoomla.com
  9. */
  10. defined('JPATH_BASE') or die;
  11. juimport('jxtended.form.formrule');
  12. /**
  13. * Form Rule class for JXtended Libraries.
  14. *
  15. * @package JXtended.Libraries
  16. * @subpackage Form
  17. * @since 1.1
  18. */
  19. class JFormRuleEquals extends JFormRule
  20. {
  21. /**
  22. * Method to test if two values are equal. To use this rule, the form
  23. * XML needs a validate attribute of equals and a field attribute
  24. * that is equal to the field to test against.
  25. *
  26. * @param object $field A reference to the form field.
  27. * @param mixed $values The values to test for validiaty.
  28. * @return mixed JException on invalid rule, true if the value is valid, false otherwise.
  29. */
  30. public function test(&$field, &$values)
  31. {
  32. $return = false;
  33. $field1 = $field->attributes('name');
  34. $field2 = $field->attributes('field');
  35. // Check the rule.
  36. if (!$field2) {
  37. return new JException('Invalid Form Rule :: '.get_class($this));
  38. }
  39. // Test the two values against each other.
  40. if ($values[$field1] == $values[$field2]) {
  41. $return = true;
  42. }
  43. return $return;
  44. }
  45. }