/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
- <?php
- /**
- * @version $Id: field.php 280 2010-09-18 02:14:15Z eddieajau $
- * @package NewLifeInIT
- * @subpackage com_exchange
- * @copyright Copyright 2005 - 2010 New Life in IT Pty Ltd. All rights reserved.
- * @license GNU General Public License version 2 or later.
- * @link http://www.theartofjoomla.com
- */
- // no direct access
- defined('_JEXEC') or die;
- /**
- * @package NewLifeInIT
- * @subpackage com_exchange
- */
- class XMLTransformField extends XMLIterator
- {
- /**
- * Evaluates an expression
- *
- * Has the attributes name, required, from, value
- *
- * @param object The tag node
- * @param mixed The value of the field
- */
- function iterate(&$node, &$value)
- {
- $name = (string) $node['name'];
- $required = XMLHelper::isBool($node['required']);
- //$model = &$this->getModel();
- //$debug = $model->getOption('debug_mode');
- // $result[0] contains the name of the field being iterated
- // $result[1] contains the value of the field being iterated
- // $result[2] indicates a required field which is empty
- $result = array();
- $result[0] = $name;
- $result[1] = null;
- $result[2] = false;
- if ($v = (string) $node['value'])
- {
- $result[1] = $node['value'];
- }
- else
- {
- $from = (string) $node['from'];
- // this is the case for expression
- if ($test = parent::iterate($node, $value)) {
- if ($required and !$test[0]) {
- $result[2] = true;
- } else {
- $result[1] = $test[0];
- }
- }
- else if ($from)
- {
- if ($required and !$value[$from]) {
- $result[2] = true;
- }
- else {
- //if ($debug AND !isset($value[$from])) {
- // ExchangeLog::add(200, '(' . (string) $node . ")\n= (".$result.')');
- //}
- $result[1] = $value[$from];
- }
- }
- }
- return $result;
- }
- }