PageRenderTime 37ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/exchange/code/trunk/administrator/components/com_exchange/models/transforms/field.php

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 75 lines | 39 code | 6 blank | 30 comment | 8 complexity | 7254472222ccb7a57eb9d2475257e114 MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: field.php 280 2010-09-18 02:14:15Z eddieajau $
  4. * @package NewLifeInIT
  5. * @subpackage com_exchange
  6. * @copyright Copyright 2005 - 2010 New Life in IT Pty Ltd. All rights reserved.
  7. * @license GNU General Public License version 2 or later.
  8. * @link http://www.theartofjoomla.com
  9. */
  10. // no direct access
  11. defined('_JEXEC') or die;
  12. /**
  13. * @package NewLifeInIT
  14. * @subpackage com_exchange
  15. */
  16. class XMLTransformField extends XMLIterator
  17. {
  18. /**
  19. * Evaluates an expression
  20. *
  21. * Has the attributes name, required, from, value
  22. *
  23. * @param object The tag node
  24. * @param mixed The value of the field
  25. */
  26. function iterate(&$node, &$value)
  27. {
  28. $name = (string) $node['name'];
  29. $required = XMLHelper::isBool($node['required']);
  30. //$model = &$this->getModel();
  31. //$debug = $model->getOption('debug_mode');
  32. // $result[0] contains the name of the field being iterated
  33. // $result[1] contains the value of the field being iterated
  34. // $result[2] indicates a required field which is empty
  35. $result = array();
  36. $result[0] = $name;
  37. $result[1] = null;
  38. $result[2] = false;
  39. if ($v = (string) $node['value'])
  40. {
  41. $result[1] = $node['value'];
  42. }
  43. else
  44. {
  45. $from = (string) $node['from'];
  46. // this is the case for expression
  47. if ($test = parent::iterate($node, $value)) {
  48. if ($required and !$test[0]) {
  49. $result[2] = true;
  50. } else {
  51. $result[1] = $test[0];
  52. }
  53. }
  54. else if ($from)
  55. {
  56. if ($required and !$value[$from]) {
  57. $result[2] = true;
  58. }
  59. else {
  60. //if ($debug AND !isset($value[$from])) {
  61. // ExchangeLog::add(200, '(' . (string) $node . ")\n= (".$result.')');
  62. //}
  63. $result[1] = $value[$from];
  64. }
  65. }
  66. }
  67. return $result;
  68. }
  69. }