/** * * Check the length of certain input elements * @param array $inputArray Input Array with search elements * @return array $resultArray Input Array with elements of right length */ function isLengthOfElementRight($inputArray) { $elementLength = GR4PHP_Template::checkLengthOfElements(); $resultArray = $inputArray; foreach ((array) $inputArray as $element => $value) { if (array_key_exists($element, $elementLength)) { if (strlen($value) > $elementLength[$element]) { $resultArray[$element] = substr($value, 0, $elementLength[$element]); } } } return $resultArray; }
/** * * Check the allowed using of SELECT elements in a function * @param array $selectArray SELECT Array with search elements * @param string $function Currently function * @return ErrorException */ public static function isPossibleSelectElementOfFunction($selectArray, $function) { $elements = GR4PHP_Template::getSelectPartsByFunction($function); // get SELECT-part (here:general-part) $selectPartDefault = GR4PHP_Template::getSelectPartsByFunction("general"); $possibleElements = array_merge($selectPartDefault, $elements); try { foreach ((array) $selectArray as $element) { if (!in_array("?" . $element, $possibleElements)) { throw new GR4PHP_Exception("The SELECT-element -" . $element . "- is not allowed in function: " . $function . ". Please check the manual!"); } } } catch (GR4PHP_Exception $e) { echo "<b>Error: " . $e->getMessage() . "</b>"; exit; } }
<br /><br /> <b>Selected Elements: </b><i><?php print_r($wantedElements); ?> </i> <br /><br /> <?php } $resultArray = (array) getFunction($endpoint, $function, $inputArray, $wantedElements, $mode, (int) $_POST["limit"]); echo "<center><b>---- Query ----- </b></center> <br />" . "\n"; echo str_replace("#>", "#><br />", $resultArray[1]); //echo $resultArray[1]; echo "<br /><br />" . "\n"; echo "<center><b>---- Result ----- </b></center> <br />" . "\n"; $selectPartspec = (array) GR4PHP_Template::getSelectPartsByFunction($_POST["function"]); $selectPartDefault = (array) GR4PHP_Template::getSelectPartsByFunction("general"); $selectPartComplete = array_merge($selectPartDefault, $selectPartspec); echo "<center><table border='1'>" . "\n"; echo "<tr>" . "\n"; if ($wantedElements != NULL) { $selectPartComplete = getWantedElements($wantedElements, $selectPartComplete); } $selectWithout = array(); foreach ($selectPartComplete as $spc) { $name = str_replace("?", "", $spc); echo "<th>" . $name . "</th>" . "\n"; $selectWithout[] = $name; } echo "</tr>" . "\n"; foreach ((array) $resultArray[0] as $ar) { echo "<tr>" . "\n";