Example #1
0
/**
 * Returns an uri segments.
 * @return array
 */
function uriSegments()
{
    return Router::getSegments();
}
Example #2
0
 /**
  * Automatically loads a view based on the currently called controller method.
  *
  * The views are searched for and loaded in the following order.
  *
  * 0. views/<current_url_path>.php
  * 1. views/module/controller_method.php
  * 2. views/module/controller.php
  * 3. views/module_controller_method.php
  * 4. views/module_controller.php
  * 5. views/module.php
  * 6. views/index.php
  *
  * @param string $module The module name
  * @param string $controller The module controller name
  * @param string $method The method within the controller
  */
 public static function load($module, $controller, $method)
 {
     $module = strtolower($module);
     $method = strtolower($method);
     // Clean controller name
     $conBits = explode('_', strtolower($controller), 2);
     // Only explode module off, leave other underscores
     $controller = str_replace('controller', '', $conBits[1]);
     // Give other modules a chance to override view loading functionality
     Event::trigger('view.load', array($module, $controller, $method), array('View', 'setLoadOverride'));
     // If the load module was overriden, reset back to false (incase something else is loaded) and return
     if (self::$_loadOverride) {
         self::$_loadOverride = false;
         return;
     }
     $checks = array(sprintf('%s/%s_%s' . EXT, $module, $controller, $method), sprintf('%s/%s' . EXT, $module, $controller), sprintf('%s_%s_%s' . EXT, $module, $controller, $method), sprintf('%s_%s' . EXT, $module, $controller), sprintf('%s' . EXT, $module), Config::get('view.index'));
     $urlCheck = str_replace('-', '_', strtolower(implode('_', Router::getSegments())) . EXT);
     // Only allow url based view if the view file doesn't match any of the default view checks
     if (!in_array($urlCheck, $checks)) {
         array_unshift($checks, $urlCheck);
     }
     foreach ($checks as $file) {
         $filePath = self::getPath() . $file;
         Log::debug('view', 'Checking for view: ' . $filePath);
         if (file_exists($filePath)) {
             Log::debug('view', 'Loading view: ' . $filePath);
             self::$_views[] = $filePath;
             return;
         }
     }
 }