1<?php 2/* 3 * This work is hereby released into the Public Domain. 4 * To view a copy of the public domain dedication, 5 * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to 6 * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. 7 * 8 */ 9 10/* 11 * Get the minimum of an array and ignore non numeric values 12 */ 13function array_min($array) { 14 15 if(is_array($array) and count($array) > 0) { 16 17 do { 18 $min = array_pop($array); 19 if(is_numeric($min === FALSE)) { 20 $min = NULL; 21 } 22 } while(count($array) > 0 and $min === NULL); 23 24 if($min !== NULL) { 25 $min = (float)$min; 26 } 27 28 foreach($array as $value) { 29 if(is_numeric($value) and (float)$value < $min) { 30 $min = (float)$value; 31 } 32 } 33 34 return $min; 35 36 } 37 38 return NULL; 39 40} 41 42/* 43 * Get the maximum of an array and ignore non numeric values 44 */ 45function array_max($array) { 46 47 if(is_array($array) and count($array) > 0) { 48 49 do { 50 $max = array_pop($array); 51 if(is_numeric($max === FALSE)) { 52 $max = NULL; 53 } 54 } while(count($array) > 0 and $max === NULL); 55 56 if($max !== NULL) { 57 $max = (float)$max; 58 } 59 60 foreach($array as $value) { 61 if(is_numeric($value) and (float)$value > $max) { 62 $max = (float)$value; 63 } 64 } 65 66 return $max; 67 68 } 69 70 return NULL; 71 72} 73 74/* 75 * Register a class with the prefix in configuration file 76 */ 77function registerClass($class, $abstract = FALSE) { 78 79 if(ARTICHOW_PREFIX === 'aw') { 80 return; 81 } 82 83 /* <php5> */ 84 if($abstract) { 85 $abstract = 'abstract'; 86 } else { 87 $abstract = ''; 88 } 89 /* </php5> */ 90 /* <php4> -- 91 $abstract = ''; 92 -- </php4> */ 93 94 eval($abstract." class ".ARTICHOW_PREFIX.$class." extends aw".$class." { }"); 95 96} 97 98/* 99 * Register an interface with the prefix in configuration file 100 */ 101function registerInterface($interface) { 102 103 if(ARTICHOW_PREFIX === 'aw') { 104 return; 105 } 106 107 /* <php5> */ 108 eval("interface ".ARTICHOW_PREFIX.$interface." extends aw".$interface." { }"); 109 /* </php5> */ 110 111} 112?> 113