示例#1
0
    // with an underscore can be called via the URI.
    if (array_key_exists(strtolower($method), Core::libraries()) || substr($method, 0, 1) == '_') {
        Core::error404($uri);
    }
    // instantiate the controller (and run its constructor)
    $class = Core::controller($class);
    // Call the remapping function if it's present in the controller
    if (method_exists($class, '_remap')) {
        call_user_func(array($class, '_remap'));
    } else {
        if (!method_exists($class, $method)) {
            Core::error404($uri);
        }
        // Call the requested method. Any URI segments present
        // (besides the controller/action) will be passed to the method for convenience
        call_user_func_array(array($class, $method), array_slice(Uri::routedsegments(), 2));
    }
    // send final output
    Output::display();
}
// -------------------------------------------------------------  Support Functions
function urlpath($url)
{
    return str_replace(URL, ROOT, $url);
}
function rmroot($path)
{
    return str_replace(ROOT, '', $path);
}
function error($msg)
{
示例#2
0
 /**
  *  SET THE ROUTE
  *  This function takes an array of URI segments as
  *  input, and sets the current class/method
  **/
 private static function _set($segments = false)
 {
     // we check the segments array
     $segments = self::_validate($segments);
     if (count($segments) == 0) {
         return;
     }
     self::$_CLS = $segments[0];
     // Set the corresponding method.
     if (isset($segments[1])) {
         self::$_MTD = $segments[1];
     } else {
         self::$_MTD = $segments[1] = 'index';
     }
     // Update the routed segments array
     // if there's no custom routing this will be the same as Uri::segments();
     Uri::routedsegments($segments);
 }