Пример #1
0
/**
 * Set content, priority, and/or due date values on a sigle todo item from request values
 *
 * The passed item should already have all the possible fields filled, this function just modifies
 * the ones that can be set directly from the API
 *
 * @param array $item A single todo item
 * @throws Exception If the content field was not included in the request
 * @throws Exception If the priority field was not an integer
 * @throws Exception If the due date field cannot be parsed by DateTime
 * @return array Todo item with new value(s) set
 */
function setItemProp(array $item)
{
    $content = requestValue('content');
    if (!empty($content)) {
        $item['content'] = $content;
    } else {
        throw new Exception('Missing required field "content".');
    }
    $priority = requestValue('priority');
    if (isset($priority)) {
        if (is_int($priority) && $priority >= 0 || ctype_digit($priority)) {
            $item['priority'] = $priority;
        } else {
            throw new Exception('Priority must be a positive integer.');
        }
    }
    $dueDate = requestValue('due_date');
    if (isset($dueDate)) {
        try {
            $item['due_date'] = new DateTime($dueDate);
        } catch (Exception $e) {
            $msg = "Due date must be a valid date string; could not parse " . requestValue('due_date') . ".";
            throw new Exception($msg, 400, $e);
        }
    }
    return $item;
}
?>
</span>
</CENTER>
<?php 
traceHide($sql);
traceHide("menunum/linenum=" . $thisMenu . "/" . $thisLine);
$selectStmt = pdoData($row, "select_stmt");
if (queryHasParams($selectStmt)) {
    $paramStr = explode(cParamDelimiter, $selectStmt);
    //step through the parameters and create corresponding form inputs
    //these are called '_n', where n is their index within array
    //splitParamStrArray
    $formInputsStr = "";
    for ($i = 1; $i < count($paramStr); $i += 2) {
        traceHide("requestName=" . $paramStr[$i]);
        $formInputsStr = $formInputsStr . "<TR><TD class=\"ahParam\">" . $paramStr[$i] . "</TD>" . "<TD class=\"ahParam\"><INPUT TYPE=\"text\" NAME=\"" . $paramStr[$i] . "\" VALUE=\"" . requestValue($paramStr[$i]) . "\" class=\"text\"></TD><TD>&nbsp;</TD></TR>";
    }
}
pdoDisconnect($connAdHoc);
?>
<FORM ACTION="adHocQuery.php" NAME="InputForm" METHOD="POST">
<CENTER>
<TABLE cellpadding="2">
<?php 
echo $formInputsStr;
?>
<TR>
  <TD>&nbsp;</TD>
  <TD>&nbsp;</TD>
  <TD class="ahParam" valign="bottom">
     &nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:doInputForm()">next...</a>