コード例 #1
0
 /**
  * Get menu
  *
  * @param string $category Category name
  */
 public static function get($category = '')
 {
     // Get menu table
     $menu = new Table('menu');
     // Display view
     View::factory('box/menu/views/frontend/index')->assign('items', $menu->select('[category="' . $category . '"]', 'all', null, array('id', 'name', 'link', 'target', 'order', 'category'), 'order', 'ASC'))->assign('uri', Uri::segments())->assign('defpage', Option::get('defaultpage'))->display();
 }
コード例 #2
0
 /**
  * Get slider
  *
  * @param string $category Category name
  */
 public static function get($category = '')
 {
     if ($category == 'default') {
         $category = '';
     }
     // Get slider table
     $slider = new Table('slider');
     // Display view
     View::factory('slider/views/frontend/index')->assign('items', $slider->select('[category="' . $category . '"]', 'all', null, null, 'order', 'ASC'))->assign('uri', Uri::segments())->assign('defpage', Option::get('defaultpage'))->display();
 }
コード例 #3
0
 public function before()
 {
     // Set template
     $this->theme = \Theme::instance();
     $this->theme->set_template($this->template);
     // Load translation
     \Lang::load('blog');
     //  Get current segments
     $segments = \Uri::segments();
     empty($segments) and $segments[0] = 'home';
     $this->dataGlobal['segments'] = $segments;
     // If ajax or content_only, set a theme with an empty layout
     if (\Input::is_ajax()) {
         return parent::before();
     }
     // Don't re-set Media if is an HMVC request
     !\Request::is_hmvc() and $this->setMedia();
 }
コード例 #4
0
ファイル: breadcrumb.php プロジェクト: ClixLtd/pccupload
 /**
  * Init
  *
  * Initialise breadcrumb based on URI segments
  *
  * @access	protected
  * @return	void
  */
 protected static function initialise()
 {
     $home = \Config::get('breadcrumb.home', static::$home);
     $use_lang = \Config::get('breadcrumb.use_lang', static::$use_lang);
     static::set($home['name'], $home['link']);
     $segments = \Uri::segments();
     $link = '';
     foreach ($segments as $segment) {
         if (preg_match('/^([0-9])+$/', $segment) > 0 or $segment === 'index') {
             continue;
         }
         $link .= '/' . $segment;
         if ($use_lang === true) {
             static::set(\Lang::get($segment), $link);
         } else {
             static::set(\Str::ucwords(str_replace('_', ' ', $segment)), $link);
         }
     }
 }
コード例 #5
0
ファイル: router.php プロジェクト: hectormenendez/h23
 /**
  *  PARSE ROUTES
  *  This function matches any routes that may exist
  *  to determine if the class/method needs to be remapped.
  **/
 private static function _parsecustom()
 {
     $seg = Uri::segments();
     // Are there any custom routes?
     if (count(self::$_RTR) == 0) {
         self::_set($seg);
         return;
     }
     // Turn the segment array into an URI string
     $uri = implode('/', $seg);
     $num = count($seg);
     // return if literal match is found.
     if (isset(self::$_RTR[$uri])) {
         self::_set(explode('/', self::$_RTR[$uri]));
         return;
     }
     // Get the available wildcards from the library
     $wc = Core::config('routing_wildcards');
     if (!is_array($wc)) {
         Core::error('ARRTYP', 'LIBTIT', array(__CLASS__, 'routing_wildcards'));
     }
     // Search through the segment array for wild-cards
     foreach (self::$_RTR as $key => $val) {
         // convert wild cards to regex
         if (count($wc) > 0) {
             foreach ($wc as $k => $v) {
                 $key = str_replace($k, $v, $key);
             }
         }
         // check for regex matches
         if (preg_match('#^' . $key . '$#', $uri)) {
             // do we have a back-reference
             if (strpos($val, '$') !== false && strpos($key, '(') !== false) {
                 $val = preg_replace('#^' . $key . '$#', $val, $uri);
             }
             self::_set(explode('/', $val));
             return;
         }
     }
     // there was no matching route follow default route
     self::_set($seg);
 }
コード例 #6
0
ファイル: base.php プロジェクト: ClixLtd/pccupload
 public function before()
 {
     parent::before();
     \Session::set("current_page", \Uri::string());
     $segments = implode(\Uri::segments());
     if (Auth::check() || $segments == 'userlogin') {
         list($driver, $user_id) = Auth::get_user_id();
         $this->current_user = Model_User::find($user_id);
     } else {
         if ($segments != 'userlogin') {
             Session::set("lastpage", implode("/", \Uri::segments()));
         }
         $this->current_user = null;
         Response::redirect('user/login');
     }
     if ($segments != 'userlogin') {
         View::set_global('group_name', Auth_Group_SimpleGroup::instance()->get_name($this->current_user->group));
         View::set_global('current_user', $this->current_user);
     }
 }
コード例 #7
0
ファイル: force.php プロジェクト: ClixLtd/pccupload
 public function before()
 {
     $this->template = $this->newIntranet() ? "templates/layout" : "template";
     \Session::set("current_page", \Uri::string());
     $segments = implode(\Uri::segments());
     if (\Auth::check() || $segments == 'userlogin') {
         list($driver, $user_id) = \Auth::get_user_id();
         $this->current_user = \Model_User::find($user_id);
     } else {
         if ($segments != 'userlogin') {
             \Session::set("lastpage", implode("/", \Uri::segments()));
         }
         $this->current_user = null;
         \Response::redirect('user/login');
     }
     if ($segments != 'userlogin') {
         \View::set_global('group_name', \Auth_Group_SimpleGroup::instance()->get_name($this->current_user->group));
         \View::set_global('current_user', $this->current_user);
     }
     parent::before();
     // Remove when login implemented
 }
コード例 #8
0
ファイル: nav.php プロジェクト: niceboy120/crude
 /**
  * Match configured triggers with current URI.
  */
 private static function match_trigger($triggers)
 {
     // get uri segments
     $current_uri = \Uri::segments();
     // try to match a trigger with the current uri segments
     foreach ($triggers as $trigger) {
         // create array of this trigger
         $trigger_uri = explode('/', $trigger);
         // slice trigger array at the wildcard (*)
         $pos = array_search('*', $trigger_uri);
         if ($pos !== false) {
             // slice arrays to equal size
             $current_uri = array_slice($current_uri, 0, $pos);
             $trigger_uri = array_slice($trigger_uri, 0, $pos);
         }
         // compare arrays
         if ($trigger_uri == $current_uri) {
             return true;
         }
     }
     return false;
 }
コード例 #9
0
ファイル: app.php プロジェクト: ratiw/petro
 private function render_breadcrumbs()
 {
     $uri = \Uri::segments();
     $base = \Config::get('petro.breadcrumb.base', 'Home');
     $link = \Uri::base();
     $sep = \Config::get('petro.breadcrumb.separator', '/');
     $out = '<span class="breadcrumb">' . PHP_EOL;
     $out .= '<a href="#">' . $base . '</a><span class="breadcrumb_sep">' . $sep . '</span>';
     for ($i = 0; $i < count($uri) - 1; $i++) {
         $link .= $uri[$i] . $sep;
         $out .= '<a href="' . $link . '">' . $uri[$i] . '</a>';
         $out .= '<span class="breadcrumb_sep">' . $sep . '</span>' . PHP_EOL;
     }
     $out .= '</span>' . PHP_EOL;
     return $out;
 }
コード例 #10
0
 /**
  * Page loader
  *
  * @param  boolean $return_data data
  * @return array
  */
 public static function pageLoader($return_data = true)
 {
     $requested_page = Pages::lowLoader(Uri::segments());
     Pages::$requested_page = $requested_page;
     return Pages::$pages->select('[slug="' . $requested_page . '"]', null);
 }
コード例 #11
0
ファイル: request.php プロジェクト: rysk92/fuelphpbase
 /**
  * Creates the new Request object by getting a new URI object, then parsing
  * the uri with the Route class.
  *
  * Usage:
  *
  *     $request = new Request('foo/bar');
  *
  * @param   string  the uri string
  * @param   bool    whether or not to route the URI
  * @param   string  request method
  * @return  void
  */
 public function __construct($uri, $route = true, $method = null)
 {
     $this->uri = new \Uri($uri);
     $this->method = $method;
     logger(\Fuel::L_INFO, 'Creating a new Request with URI = "' . $uri . '"', __METHOD__);
     // check if a module was requested
     if (count($this->uri->segments()) and $module_path = \Module::exists($this->uri->get_segment(0))) {
         // check if the module has routes
         if (is_file($module_path .= 'config/routes.php')) {
             $module = $this->uri->segments[0];
             // load and add the module routes
             $module_routes = \Fuel::load($module_path);
             $prepped_routes = array();
             foreach ($module_routes as $name => $_route) {
                 if ($name === '_root_') {
                     $name = $module;
                 } elseif (strpos($name, $module . '/') !== 0 and $name != $module and $name !== '_404_') {
                     $name = $module . '/' . $name;
                 }
                 $prepped_routes[$name] = $_route;
             }
             // update the loaded list of routes
             \Router::add($prepped_routes, null, true);
         }
     }
     $this->route = \Router::process($this, $route);
     if (!$this->route) {
         return;
     }
     $this->module = $this->route->module;
     $this->controller = $this->route->controller;
     $this->action = $this->route->action;
     $this->method_params = $this->route->method_params;
     $this->named_params = $this->route->named_params;
     if ($this->route->module !== null) {
         $this->add_path(\Module::exists($this->module));
     }
 }
コード例 #12
0
ファイル: router.php プロジェクト: prwhitehead/meagr
 /**
  * map individual routes
  *
  * @return mixed[object|void]
  */
 function filterRoute(Route $object)
 {
     //now we have everything in place, run any closures passed from the config
     $object = $object->filter(Uri::segments(), null);
     return $object;
 }
コード例 #13
0
 /**
  *	Get uri parammeters
  *
  *  <code>
  *      $params = Uri::params();
  *  </code>
  *
  *  @return array
  */
 public static function params()
 {
     //Init data array
     $data = array();
     // Get URI
     $uri = Uri::segments();
     // http://site.com/ and http://site.com/index.php same main home pages
     if (!isset($uri[0])) {
         $uri[0] = '';
     }
     // param1/param2
     if ($uri[0] !== Uri::$default_component) {
         if (isset($uri[1])) {
             foreach ($uri as $part) {
                 $data[] = $part;
             }
         } else {
             // default
             $data[0] = $uri[0];
         }
     } else {
         // This is good for box plugin Pages
         // parent/child
         if (isset($uri[2])) {
             $data[0] = $uri[1];
             $data[1] = $uri[2];
         } else {
             // default
             $data[0] = $uri[1];
         }
     }
     return $data;
 }
コード例 #14
0
ファイル: image.php プロジェクト: soundintheory/fuel-cmf
 /**
  * Get the current base path, stopping at the given segment number
  */
 protected function getImagePath($startSegment)
 {
     $segments = \Uri::segments();
     $startSegment = min($startSegment, count($segments));
     return implode('/', array_slice($segments, $startSegment)) . '.' . \Input::extension();
 }