Exemplo n.º 1
0
 public static function routes()
 {
     $route = '_status';
     Router::add($route, new Route($route, function ($request) {
         // ignore this transaction
         Transaction::ignore();
         // load a config
         $conf = Config::load('newrelic-ping');
         // ping the urls
         $pinger = new Pinger($conf['urls'], $conf['base_host']);
         $res = $pinger->ping();
         // add path to lookup view
         Finder::instance()->add_path(realpath(rtrim(__DIR__, '/') . '/../'));
         // build a response and return it
         return new Response(View::forge('_newrelic-status', ['result' => $res]), $res->getResultStatusCode());
     }));
 }
Exemplo n.º 2
0
 public function before()
 {
     $parentReturn = parent::before();
     \Fuel\Core\Lang::load("global");
     \Fuel\Core\Lang::load("share");
     $this->template->jsVars = new JsVars();
     $this->template->jsVars->addVar("wsUrl", rtrim(Router::get("ws_" . $this->lang), "/") . "/");
     $this->template->jsVars->addVar("baseUrl", \Fuel\Core\Uri::base(FALSE));
     $this->template->css = array("fonts.css", "normalize.css", "definitions.css", "template.css", "sprites/generic.css");
     $this->template->js = array("libs/jquery-2.1.3.min.js", "libs/jquery-ui.min.js", "libs/mustache.js", "template.js");
     $this->template->header = "front_header";
     $this->template->set_global(array("menu_selected" => ""));
     $this->template->footer = "front_footer";
     $this->template->footer_options = array();
     $fbShare = array("share" => FALSE, "siteName" => '', "title" => '', "description" => '', "image" => '');
     $this->template->fbShare = $fbShare;
     return $parentReturn;
 }
Exemplo n.º 3
0
 /**
  * confirm reverser_route
  *
  * @return void
  */
 public function test_reverse_route()
 {
     // add router, can reverse
     \Fuel\Core\Router::add('sample', 'hoge/fuga');
     $this->assertEquals(\Seo\Route::reverse_route('hoge/fuga'), 'sample');
     // delete router, can't reverse
     \Fuel\Core\Router::delete('sample');
     $this->assertEquals(\Seo\Route::reverse_route('hoge/fuga'), 'hoge/fuga');
     // high level reverse routing
     \Fuel\Core\Router::add('cat/(:num)', 'hoge/category/$1');
     $this->assertEquals(\Seo\Route::reverse_route('hoge/category/35'), 'cat/35');
     // no num no matched
     $this->assertEquals(\Seo\Route::reverse_route('hoge/category/hoge'), 'hoge/category/hoge');
     \Fuel\Core\Router::delete('cat/(:num)');
     // multiple value reverse routing
     \Fuel\Core\Router::add('cat/(:num)/(:alpha)', 'a/i/$2/$1');
     $this->assertEquals(\Seo\Route::reverse_route('a/i/u/1'), 'cat/1/u');
     \Fuel\Core\Router::delete('cat/(:num)/(:alpha)');
     \Fuel\Core\Router::add('cat/(:num)/(:alpha)/(:alnum)', 'a/i/$3/$1/$2');
     $this->assertEquals(\Seo\Route::reverse_route('a/i/0a2/33/str'), 'cat/33/str/0a2');
     \Fuel\Core\Router::delete('cat/(:num)/(:alpha)/(:alnum)');
 }
Exemplo n.º 4
0
 public static function switch_language($other_lang)
 {
     $url = \Fuel\Core\Router::get('home_en') . '/';
     $switch_page = '';
     $params = array();
     $current_lang = \Fuel\Core\Lang::get_lang();
     // Loop through routes
     foreach (\Fuel\Core\Router::$routes as $key => $route) {
         // If there's segments in route (weird, but that tells us that it's the current route...!)
         if (count($route->segments) > 0) {
             if (strpos($key, '_' . $current_lang, strlen($key) - strlen('_' . $current_lang)) !== false) {
                 $switch_page = str_replace('_' . $current_lang, '_' . $other_lang, $key);
                 $params = $route->method_params;
             }
             $url = rtrim(\Fuel\Core\Router::get($switch_page, $route->named_params), "/") . "/";
             foreach ($params as $param) {
                 if ($param != $current_lang && $param != $other_lang) {
                     $url .= $param . '/';
                 }
             }
         }
     }
     return $url;
 }