示例#1
0
/**
 * Initializes the resources essential.
 * 
 * @return void
 */
function resources_init()
{
    global $CONFIG;
    $GLOBALS["loaded_modules"]['skins'] = __FILE__;
    $GLOBALS["loaded_modules"]['javascript'] = __FILE__;
    if (!isset($CONFIG['resources'])) {
        $CONFIG['resources'] = array();
    }
    if (!isset($CONFIG['resources_system_url_root']) || !$CONFIG['resources_system_url_root']) {
        $CONFIG['resources_system_url_root'] = can_rewrite() ? $CONFIG['system']['url_root'] . 'WdfResource/' : $CONFIG['system']['url_root'] . '?wdf_route=WdfResource/';
    }
    foreach ($CONFIG['resources'] as $i => $conf) {
        if (substr($conf['url'], 0, 4) == 'http') {
            continue;
        }
        if (substr($conf['url'], 0, 2) == '//') {
            continue;
        }
        if (substr($conf['url'], 0, 2) == './') {
            continue;
        }
        $CONFIG['resources'][$i]['url'] = $CONFIG['system']['url_root'] . $conf['url'];
    }
    $CONFIG['resources'][] = array('ext' => 'js', 'path' => realpath(__DIR__ . '/../js/'), 'url' => $CONFIG['resources_system_url_root'] . 'js/', 'append_nc' => true);
    $CONFIG['resources'][] = array('ext' => 'css|png|jpg|jpeg|gif|htc|ico|less', 'path' => realpath(__DIR__ . '/../skin/'), 'url' => $CONFIG['resources_system_url_root'] . 'skin/', 'append_nc' => true);
    $CONFIG['class_path']['system'][] = __DIR__ . '/resources/';
}
示例#2
0
/**
 * Builds a request.
 * 
 * This is quite basic and used very often. It will return an URL to the given controller.
 * It checks if the routing features are enabled and ensures the the URLs are working!
 * @param mixed $controller The page to be loaded (can be <Renderable> or string)
 * @param string $event The event to be executed
 * @param array|string $data Optional data to be passed
 * @param string $url_root Optional root, will use system-wide detected/set one if not given
 * @return string A complete Request (for use as HREF)
 */
function buildQuery($controller, $event = "", $data = "", $url_root = false)
{
    global $CONFIG;
    if ($controller instanceof Renderable) {
        $controller = $controller->_storage_id;
    }
    if (substr($controller, 0, 4) == "http") {
        return $controller;
    }
    // allow buildQuery('controller/method')
    if (is_string($controller) && $event == "" && $data == "" && !$url_root) {
        if (preg_match('|^([a-z0-9]+)/([a-z0-9]+)$|i', $controller)) {
            list($controller, $event) = explode("/", $controller);
        }
    }
    if ($controller != "") {
        $route = "{$controller}/";
    } else {
        $route = "";
    }
    if ($event != "") {
        $route .= $event;
        if ('#' != substr($event, 0, 1)) {
            $route .= '/';
        }
    }
    /**
     * data can contain a # to jump to named anchors i.e. on redirect
     */
    $hash = false;
    if (is_array($data)) {
        if (isset($data['#'])) {
            $hash = $data['#'];
            unset($data['#']);
        }
        $data = http_build_query($data);
    }
    if (!can_rewrite()) {
        $data = http_build_query(array('wdf_route' => $route)) . ($data ? "&{$data}" : "");
        $route = "";
    }
    if (isDev() && isset($_REQUEST["XDEBUG_PROFILE"])) {
        $data .= ($data ? "&" : "") . "XDEBUG_PROFILE";
    }
    if (!$url_root) {
        $url_root = $CONFIG['system']['url_root'];
    }
    return $url_root . $route . ($data ? "?{$data}" : "") . ($hash ? '#' . $hash : '');
}
示例#3
0
/**
 * Builds a request.
 * 
 * This is quite basic and used very often. It will return an URL to the given controller.
 * It checks if the routing features are enabled and ensures the the URLs are working!
 * @param mixed $controller The page to be loaded (can be <Renderable> or string)
 * @param string $event The event to be executed
 * @param array|string $data Optional data to be passed
 * @param string $url_root Optional root, will use system-wide detected/set one if not given
 * @return string A complete Request (for use as HREF)
 */
function buildQuery($controller, $event = "", $data = "", $url_root = false)
{
    global $CONFIG;
    if ($controller instanceof Renderable) {
        $controller = $controller->_storage_id;
    }
    if (substr($controller, 0, 4) == "http") {
        return $controller;
    }
    if ($controller != "") {
        $route = "{$controller}/";
    } else {
        $route = "";
    }
    if ($event != "") {
        $route .= $event;
        if ('#' != substr($event, 0, 1)) {
            $route .= '/';
        }
    }
    if (is_array($data)) {
        $data = http_build_query($data);
    }
    if (!can_rewrite()) {
        $data = http_build_query(array('wdf_route' => $route)) . ($data ? "&{$data}" : "");
        $route = "";
    }
    if (isDev() && isset($_REQUEST["XDEBUG_PROFILE"])) {
        $data .= ($data ? "&" : "") . "XDEBUG_PROFILE";
    }
    if (!$url_root) {
        $url_root = $CONFIG['system']['url_root'];
    }
    //log_debug($url_root,$route,($data?"?$data":""));
    return $url_root . $route . ($data ? "?{$data}" : "");
}