Exemplo n.º 1
0
<?php

require 'queries/pageQueries.php';
$PAGE->id = 'pageMenuGet';
//setup for query
$stmt = getPageMenu($DB);
if (!$stmt->execute()) {
    return errorHandler("failed to get this list {$stmt->errno}: {$stmt->error}");
}
//format results
$data = array();
$stmt->bind_result($data['pageId'], $data['menuName']);
/* fetch values */
$listResults = array();
while ($stmt->fetch()) {
    $row = arrayCopy($data);
    array_push($listResults, $row);
}
echo json_encode($listResults);
function arrayCopy(array $array)
{
    $result = array();
    foreach ($array as $key => $val) {
        if (is_array($val)) {
            $result[$key] = arrayCopy($val);
        } elseif (is_object($val)) {
            $result[$key] = clone $val;
        } else {
            $result[$key] = $val;
        }
    }
Exemplo n.º 2
0
/**
 * Renders a template.
 *
 * @param string $__name
 * @param array $__args
 */
function template($__name, $__args = array(), $noLayout = false, $noQuote = false)
{
    // Assign variables available everywhere.
    $__args['menu'] = getPageMenu();
    $__args['tagsSubmenu'] = getTagsSubmenu();
    $__args['base'] = preg_replace("{/[^/]*\$}s", "/", getSetting("index_url"));
    if (!$noQuote) {
        $t0 = microtime(true);
        $__args = htmlspecialchars_recursive($__args);
        //		echo sprintf("Quoting took %d ms<br>", (microtime(true) - $t0) * 1000);
    }
    extract($__args);
    // Process the template.
    $__cwd = getcwd();
    chdir(dirname(__FILE__) . "/tpl");
    if (!$noLayout) {
        require "_header.php";
    }
    $t0 = microtime(true);
    require "{$__name}.php";
    //	echo sprintf("Templating of %s took %d ms<br>", $__name, (microtime(true) - $t0) * 1000);
    if (!$noLayout) {
        require "_footer.php";
    }
    chdir($__cwd);
}