Location: PHPKode > scripts > XML Sapiens Processor > xml-sapiens-processor/mvc/view/sapiexpressions.php
<?PHP
/**
 * XML Sapiens Expressions
 *
 * PHP versions 4 
 *
 * LICENSE: This source file is subject to version 3.0 of the PHP license
 * that is available through the world-wide-web at the following URI:
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
 * the PHP License and are unable to obtain it through the web, please
 * send a note to hide@address.com so we can mail you a copy immediately.
 *
 * @category   Processor
 * @package    SAPIPROCESSOR
 * @author     Max Baryshnikov <hide@address.com>
 * @author     Dmitry Sheiko <hide@address.com>
 * @copyright  2004-2005 XML Sapiens Team
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
 * @version    CVS: $Id:$
 * @link       http://pear.php.net/package/PackageName
 * @see        nothing
 * @since      File available since Release 1.0.0
 * @deprecated File deprecated in Release 1.0.0
 */

 /**
 * @return BOOL
 * @params int value,  int value, ..
 * @desc Compare a few values (A < B)
 */
 
function lt($a1=false, $a2=false, $a3=false, $a4=false, $a5=false, $a6=false, $a7=false, $a8=false, $a9=false, $a10=false) {
	if($a10 AND $a10<=$a9) return false;
	if($a9 AND $a9<=$a8) return false;
	if($a8 AND $a8<=$a7) return false;
	if($a7 AND $a7<=$a6) return false;
	if($a6 AND $a6<=$a5) return false;
	if($a5 AND $a5<=$a4) return false;
	if($a4 AND $a4<=$a3) return false;
	if($a3 AND $a3<=$a2) return false;
	if($a2>$a1) return true; else return false;
}

/**
 * @return BOOL
 * @params int value,  int value, ..
 * @desc Compare a few values (A <= B)
 */
 
function leq($a1=false, $a2=false, $a3=false, $a4=false, $a5=false, $a6=false, $a7=false, $a8=false, $a9=false, $a10=false) {
	if($a10 AND $a10<$a9) return false;
	if($a9 AND $a9<$a8) return false;
	if($a8 AND $a8<$a7) return false;
	if($a7 AND $a7<$a6) return false;
	if($a6 AND $a6<$a5) return false;
	if($a5 AND $a5<$a4) return false;
	if($a4 AND $a4<$a3) return false;
	if($a3 AND $a3<$a2) return false;
	if($a2>=$a1) return true; else return false;
}

/**
 * @return BOOL
 * @params int value,  int value, ..
 * @desc Compare a few values (A > B)
 */
 
function gt($a1=false, $a2=false, $a3=false, $a4=false, $a5=false, $a6=false, $a7=false, $a8=false, $a9=false, $a10=false) {
	if($a10 AND $a10>=$a9) return false;
	if($a9 AND $a9>=$a8) return false;
	if($a8 AND $a8>=$a7) return false;
	if($a7 AND $a7>=$a6) return false;
	if($a6 AND $a6>=$a5) return false;
	if($a5 AND $a5>=$a4) return false;
	if($a4 AND $a4>=$a3) return false;
	if($a3 AND $a3>=$a2) return false;
	if($a2<$a1) return true; else return false;
}

/**
 * @return BOOL
 * @params int value,  int value, ..
 * @desc Compare a few values (A >= B)
 */
 
function geq($a1=false, $a2=false, $a3=false, $a4=false, $a5=false, $a6=false, $a7=false, $a8=false, $a9=false, $a10=false) {
	if($a10 AND $a10>$a9) return false;
	if($a9 AND $a9>$a8) return false;
	if($a8 AND $a8>$a7) return false;
	if($a7 AND $a7>$a6) return false;
	if($a6 AND $a6>$a5) return false;
	if($a5 AND $a5>$a4) return false;
	if($a4 AND $a4>$a3) return false;
	if($a3 AND $a3>$a2) return false;
	if($a2<=$a1) return true; else return false;
}

/**
 * @return BOOL
 * @params int value,  int value, ..
 * @desc Compare a few values (A == B)
 */
 
function eq($a1=false, $a2=false, $a3=false, $a4=false, $a5=false, $a6=false, $a7=false, $a8=false, $a9=false, $a10=false) {
	if($a10 AND $a10!=$a9) return false;
	if($a9 AND $a9!=$a8) return false;
	if($a8 AND $a8!=$a7) return false;
	if($a7 AND $a7!=$a6) return false;
	if($a6 AND $a6!=$a5) return false;
	if($a5 AND $a5!=$a4) return false;
	if($a4 AND $a4!=$a3) return false;
	if($a3 AND $a3!=$a2) return false;
	if($a2==$a1) return true; else return false;
}

/**
 * @return BOOL
 * @params int value,  int value, ..
 * @desc Compare a few values (A != B)
 */
 
function neq($a1=false, $a2=false, $a3=false, $a4=false, $a5=false, $a6=false, $a7=false, $a8=false, $a9=false, $a10=false) {
	if($a10 AND $a10==$a9) return false;
	if($a9 AND $a9==$a8) return false;
	if($a8 AND $a8==$a7) return false;
	if($a7 AND $a7==$a6) return false;
	if($a6 AND $a6==$a5) return false;
	if($a5 AND $a5==$a4) return false;
	if($a4 AND $a4==$a3) return false;
	if($a3 AND $a3==$a2) return false;
	if($a2!=$a1) return true; else return false;
}

/**
 * @return BOOL
 * @params int/string value,  int/string value, ..
 * @desc Sum of a few values 
 */
 
function add($a1=false, $a2=false, $a3=false, $a4=false, $a5=false, $a6=false, $a7=false, $a8=false, $a9=false, $a10=false) {
	if(gettype($a1)=="string"){
		$res="";
		if($a1) $res.=$a1;
		if($a2) $res.=$a2;
		if($a3) $res.=$a3;
		if($a4) $res.=$a4;
		if($a5) $res.=$a5;
		if($a6) $res.=$a6;
		if($a7) $res.=$a7;
		if($a8) $res.=$a8;
		if($a9) $res.=$a9;
		if($a10) $res.=$a10;
	}else{
		$res=0;
		if($a10) $res+=$a10;
		if($a9) $res+=$a9;
		if($a8) $res+=$a8;
		if($a7) $res+=$a7;
		if($a6) $res+=$a6;
		if($a5) $res+=$a5;
		if($a4) $res+=$a4;
		if($a3) $res+=$a3;
		if($a2) $res+=$a2;
		if($a1) $res+=$a1;
	}
	return $res;
}

/**
 * @return BOOL
 * @params int value,  int value, ..
 * @desc Difference of a few values 
 */
function subtract($a1=false, $a2=false, $a3=false, $a4=false, $a5=false, $a6=false, $a7=false, $a8=false, $a9=false, $a10=false) {
	$res=0;
	if($a1) $res=$a1;
	if($a10) $res-=$a10;
	if($a9) $res-=$a9;
	if($a8) $res-=$a8;
	if($a7) $res-=$a7;
	if($a6) $res-=$a6;
	if($a5) $res-=$a5;
	if($a4) $res-=$a4;
	if($a3) $res-=$a3;
	if($a2) $res-=$a2;
	return $res;
}

/**
 * @return BOOL
 * @params int value,  int value, ..
 * @desc Multiply a few values 
 */
 
function multiply($a1=false, $a2=false, $a3=false, $a4=false, $a5=false, $a6=false, $a7=false, $a8=false, $a9=false, $a10=false) {
	$res=1;
	if($a10) $res*=$a10;
	if($a9) $res*=$a9;
	if($a8) $res*=$a8;
	if($a7) $res*=$a7;
	if($a6) $res*=$a6;
	if($a5) $res*=$a5;
	if($a4) $res*=$a4;
	if($a3) $res*=$a3;
	if($a2) $res*=$a2;
	if($a1) $res*=$a1;
	return $res;
}

/**
 * @return BOOL
 * @params int value,  int value, ..
 * @desc Divide a few values 
 */
 
function divide($a1=false, $a2=false, $a3=false, $a4=false, $a5=false, $a6=false, $a7=false, $a8=false, $a9=false, $a10=false) {
	$res=1;
	if($a1) $res=$a1;
	if($a10) $res=$res/$a10;
	if($a9) $res=$res/$a9;
	if($a8) $res=$res/$a8;
	if($a7) $res=$res/$a7;
	if($a6) $res=$res/$a6;
	if($a5) $res=$res/$a5;
	if($a4) $res=$res/$a4;
	if($a3) $res=$res/$a3;
	if($a2) $res=$res/$a2;
	return $res;
}

/**
 * @return void
 * @params int array
 * @desc Tracer  
 */

function d($var)
{
	ob_end_clean();
	echo '<pre style="font-size: 10px;  color: Maroon; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;">';
	print_r($var);
	echo '</pre>';
}
?>
Return current item: XML Sapiens Processor