// This is a micro-optimization, it is fast for non-nested keys, but fails for null values
    if (count($keys) === 1 && isset($array[$keys[0]])) {
        return $array[$keys[0]];
    }
    $current = $array;
    foreach ($keys as $key) {
        if (!array_key_exists($key, $current)) {
            return $default;
        }
        $current = $current[$key];
    }
    return $current;
}
// Global debug setup allows for debug querying.
$global_debug;
if (get_in($_GET, ['debug']) == 1 || !empty($global_debug)) {
    $global_debug = true;
} else {
    $global_debug = false;
}
// put full path to Smarty.class.php
require $app['_web_root'] . '/app/smarty/Smarty.class.php';
$smarty = new Smarty();
// Set up Smarty directories
$smarty->setTemplateDir($app['_web_root'] . '/app/smarty/templates');
$smarty->setCompileDir($app['_web_root'] . '/app/smarty/templates_c');
$smarty->setCacheDir($app['_web_root'] . '/app/smarty/cache');
$smarty->setConfigDir($app['_web_root'] . '/app/smarty/configs');
$smarty->error_reporting = E_ALL ^ E_NOTICE;
// Check that the smarty directories are writeable
if (!is_writeable($smarty->compile_dir)) {
Example #2
0
 /** @dataProvider provideGetIn */
 function testGetIn($expected, $array, $keys, $default = null)
 {
     $this->assertSame($expected, get_in($array, $keys, $default));
 }
Example #3
0
 /**
 		Returns the put data associated with the request at $key.
 
 		If $key is not present in the put data, $fallback is returned. If $key is
 		not specified or null, an associative array of all put data key, value pairs
 		is returned.
 */
 function put_data($key = null, $fallback = null)
 {
     if (is_null($this->put_data)) {
         parse_str(file_get_contents("php://input"), $this->put_data);
     }
     return get_in($this->put_data, $key, $fallback);
 }
<?php

/*
*  Routing script runs on any page request part of the cms and not directory based. 
*/
include 'init_page.php';
$reqURI = $_SERVER["REQUEST_URI"];
$urlComponents = explode("?", $reqURI);
$curPage = $urlComponents[0];
// remove working directory from relative url
$curPage = trim($curPage, $app['_working_dir']);
if (empty($curPage)) {
    $curPage = '/';
}
$getVars = get_in($urlComponents, [1]);
if (!empty($getVars)) {
    $vars = explode("&", $getVars);
    foreach ($vars as $var) {
        $hash = explode("=", $var);
        $_GET[$hash[0]] = $hash[1];
    }
}
$template = str_replace("/", "__", $curPage);
if (empty($app['page_list'][$curPage]) or !$smarty->templateExists($template . ".tpl")) {
    include '404.php';
}
include 'display_begin.php';
$smarty->display('page.tpl');
include 'end_page.php';
Example #5
0
 /**
   	Returns the metatdata value for $key.
 
 		If no metadata is present with the corresponding $key then null
 		is returned. If no key is specified or a null value is passed as
 		$key then an associative array of all $key, $value metadata pairs
 		is returned.
 */
 function metadata($key = null)
 {
     return get_in($this->metadata, $key);
 }