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

https://bitbucket.org/eddieajau/the-art-of-joomla-archive · PHP · 45 lines · 23 code · 4 blank · 18 comment · 2 complexity · efea488a71fbc5e5d3b91fb77cfacab8 MD5 · raw file

  1. <?php
  2. /**
  3. * @version $Id: expression.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 XMLTransformExpression extends XMLIterator
  17. {
  18. /**
  19. * Evaluates an expression
  20. * @param object The tag node
  21. * @param mixed The value of the field
  22. */
  23. function iterate(&$node, &$value)
  24. {
  25. $model = &$this->getModel();
  26. $debug = $model->getOption('debug_mode');
  27. $name = (string) $node->parent['name'];
  28. if ($name) {
  29. $self = $value[$name];
  30. }
  31. foreach ($value as $k => $v) {
  32. $$k = $v;
  33. }
  34. $code = 'return (' . (string) $node . ');';
  35. $result = eval($code);
  36. if ($debug) {
  37. ExchangeLog::add(200, '(' . (string) $node . ")\n= (".$result.')');
  38. }
  39. return $result;
  40. }
  41. }