Author: liu21st (liu21st@gmail.com)
Inheritance: extends Base
Example #1
1
 /**
  * Handles a Request to convert it to a Response.
  *
  * When $catch is true, the implementation must catch all exceptions
  * and do its best to convert them to a Response instance.
  *
  * @param Request $request A Request instance
  * @param int     $type    The type of the request
  *                         (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST)
  * @param bool    $catch   Whether to catch exceptions or not
  *
  * @return Response A Response instance
  *
  * @throws \Exception When an Exception occurs during processing
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     try {
         $match = $this->routeMatch;
         if (!$match) {
             $match = $this->router->match($request->getPathInfo());
         }
         if ($match) {
             list($module, $controller, $action) = $this->processRoute($match);
             $request->attributes->add(['_module' => $module, '_controller' => $controller, '_action' => $action]);
             $response = $this->dispatcher->dispatch($match['target'], $match['params']);
         } else {
             $response = $this->dispatcher->dispatch('Home#error', ['message' => 'Halaman tidak ditemukan: ' . $request->getPathInfo()]);
             $response->setStatusCode(Response::HTTP_NOT_FOUND);
         }
     } catch (HttpException $e) {
         if (!$catch) {
             throw $e;
         }
         $response = $this->dispatcher->dispatch('Home#error', ['message' => '[' . $e->getCode() . '] ' . $e->getMessage()]);
         $response->setStatusCode($e->getStatusCode());
     } catch (Exception $e) {
         if (!$catch) {
             throw $e;
         }
         $response = $this->dispatcher->dispatch('Home#error', ['message' => '[' . $e->getCode() . '] ' . $e->getMessage()]);
         $response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);
     }
     //$response->setMaxAge(300);
     return $response;
 }
Example #2
0
function _main_()
{
    $ph = new PluginHandler();
    $ph->register(new MyPlugin());
    $sd = new Dispatcher($ph);
    $sd->dispatch();
}
Example #3
0
function __autoload($className)
{
    $dispatcher = new Dispatcher($className);
    if (class_exists($className)) {
        return;
    }
    if ($dispatcher->isBom()) {
        require_once Configuration::getModelBomPath() . $className . '.php';
    }
    if ($dispatcher->isDao()) {
        require_once Configuration::getModelDaoPath() . $className . '.php';
    }
    if ($dispatcher->isCoreInterface()) {
        require_once Configuration::getInterfacePath() . $className . ".interface.php";
    }
    if ($dispatcher->isCoreController()) {
        require_once Configuration::getControllersPath() . $className . ".php";
    }
    if ($dispatcher->isCoreBom()) {
        require_once Configuration::getBusinessObjectModelsPath() . $className . ".php";
    }
    if ($dispatcher->isCoreDao()) {
        require_once Configuration::getDatabaseAccessObjectPath() . $className . '.php';
    }
    if ($dispatcher->isCoreConstant()) {
        require_once Configuration::getConstantsPath() . $className . ".constants.php";
    }
    if ($dispatcher->isCoreHelper()) {
        require_once Configuration::getHelpersPath() . $className . ".helper.php";
    }
    if ($dispatcher->isCoreAbstract()) {
        require_once Configuration::getAbstractPath() . $className . '.abstract.php';
    }
}
Example #4
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $this->object = new Controller();
     $dispatcher = new Dispatcher(new View());
     $dispatcher->setBootstrap(new Bootstrap());
     $this->object->setParams(array('dispatcher' => $dispatcher));
 }
Example #5
0
 private function getAjaxTemplate()
 {
     foreach ($this->vars->isPost() as $key => $value) {
         $data[$key] = $value;
     }
     $dispatcher = new Dispatcher();
     $controller = $dispatcher->setController($data);
     // Assign variables for the template
     if ($controller['vars']) {
         foreach ($controller['vars'] as $key => $value) {
             $this->smarty->assign($key, $value);
         }
     }
     if (isset($data['response'])) {
         if ($data['response'] == 'html') {
             return array('response' => 'html', 'data' => $dispatcher->loadTemplate());
         } elseif ($data['response'] == 'json') {
             return array('response' => 'json', 'data' => json_encode($controller['vars']));
         } else {
             throw new Exception('Ajax dataType must be html or json');
         }
     } else {
         throw new Exception('response data must be given');
     }
 }
 /**
  * If RequestURI is proper URI and does not contain QueryParam then it will return proper o/p 
  */
 function testServiceDispatchingUriRawUrlWithoutQueryParam()
 {
     $_SERVER[ODataConstants::HTTPREQUEST_HEADER_METHOD] = ODataConstants::HTTP_METHOD_GET;
     $_SERVER[ODataConstants::HTTPREQUEST_HEADER_PROTOCOL] = ODataConstants::HTTPREQUEST_HEADER_PROTOCOL_HTTP;
     $_SERVER[ODataConstants::HTTPREQUEST_HEADER_HOST] = "localhost:8086";
     $_SERVER[ODataConstants::HTTPREQUEST_HEADER_URI] = "/NorthWind.svc/Customers";
     $_SERVER[ODataConstants::HTTPREQUEST_HEADER_QUERY_STRING] = null;
     try {
         $exceptionThrown = false;
         $dispatcher = new Dispatcher();
         //Service dispatched
         $dispatcher->dispatch();
         $contents = ob_get_contents();
         ob_end_clean();
         $this->assertContains("<feed xml:base=\"http://localhost:8086/NorthWind.svc", $contents);
         $this->assertContains("<id>http://localhost:8086/NorthWind.svc/Customers</id>", $contents);
         $absoluteUri = $dispatcher->getHost()->getAbsoluteRequestUriAsString();
         $this->assertEquals("http://localhost:8086/NorthWind.svc/Customers", $absoluteUri);
         $rawUrl = $dispatcher->getHost()->getWebOperationContext()->IncomingRequest()->getRawUrl();
         $this->assertEquals("http://localhost:8086/NorthWind.svc/Customers", $rawUrl);
     } catch (\Exception $exception) {
         if (ob_get_length()) {
             ob_end_clean();
         }
         $exceptionThrown = true;
         $this->fail('Without Query Params - An unexpected exception  has been thrown:' . $exception->getMessage());
     }
     if (!$exceptionThrown) {
         $this->assertTrue(TRUE);
     }
     $dispatcher->getHost()->getWebOperationContext()->resetWebContextInternal();
 }
Example #7
0
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     $match = $this->router->match($request->getPathInfo());
     $route = substr($request->getPathInfo(), strlen(rtrim($this->config['baseDir'], '/')));
     if ($match) {
         $tokenValid = false;
         $jwtCookie = $this->config['jwt']['cookieName'];
         $jwtKey = $this->config['jwt']['key'];
         // check token from cookie
         if ($request->cookies->has($jwtCookie)) {
             $jwt = $request->cookies->get($jwtCookie);
             try {
                 $decoded = JWT::decode($jwt, $jwtKey, ['HS256']);
                 if ($decoded->e > time()) {
                     $tokenValid = true;
                     $this->auth->init($decoded->uid);
                 }
             } catch (\Exception $e) {
                 $tokenValid = false;
                 if (!$catch) {
                     throw $e;
                 }
                 $response = $this->dispatcher->dispatch('Home#error', ['message' => '[' . $e->getCode() . '] ' . $e->getMessage() . '<pre>' . $e->getTraceAsString() . '</pre>']);
                 $response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);
                 return $response;
             }
         }
         $allowed = false;
         $isPublic = false;
         foreach ($this->config['publicArea'] as $publicRoute) {
             if (preg_match('/^' . addcslashes($publicRoute, '/') . '/', $route)) {
                 $isPublic = true;
                 break;
             }
         }
         if ($match['name'] == 'home') {
             $isPublic = true;
         }
         if ($isPublic) {
             if ($route == '/login' && $tokenValid) {
                 return new RedirectResponse($this->router->generate('dashboard'));
             }
             $allowed = true;
         } else {
             $allowed = $tokenValid;
         }
         if ($allowed) {
             $this->app->setRouteMatch($match);
             return $this->app->handle($request, $type, $catch);
         } else {
             $this->flash->warning('Sesi Anda telah habis atau Anda tidak berhak mengakses halaman ini, silakan login terlebih dahulu!');
             $response = $this->dispatcher->dispatch('User#login', []);
             $response->setStatusCode(Response::HTTP_UNAUTHORIZED);
             return $response;
         }
     }
     $response = $this->dispatcher->dispatch('Home#error', ['message' => 'Halaman tidak ditemukan: ' . $route]);
     $response->setStatusCode(Response::HTTP_NOT_FOUND);
     return $response;
 }
Example #8
0
 /**
  *  T' the high seas! Garrr!
  */
 public function setSail()
 {
     $request = new Request($_GET, $_POST, $_COOKIE, $_SERVER);
     $router = new Router($request);
     $response = new Response();
     $dispatcher = new Dispatcher($router->dispatch(), $response);
     $dispatcher->fireCannons();
 }
Example #9
0
 public function testDispatchNotFoundRoute()
 {
     $dispatcher = new Dispatcher($this->router);
     $response = $dispatcher->dispatch('GET', '/not-found');
     assertThat($response, is(anInstanceOf('Rootr\\Response')));
     assertThat($this->readAttribute($response, 'status'), is(equalTo(404)));
     assertThat($this->readAttribute($response, 'body'), is(equalTo('Not Found')));
 }
 /**
  * Redirects user to action in application with validated response data available as POST data retrievable at
  * $this->request->data` at your app's controller.
  *
  * @param string $url Url in application to dispatch to
  * @param array $data A list with post data
  * @return void
  */
 protected function _dispatch($url, $data)
 {
     $CakeRequest = new CakeRequest($url);
     $CakeRequest->data = $data;
     $Dispatcher = new Dispatcher();
     $Dispatcher->dispatch($CakeRequest, new CakeResponse());
     $this->_stop();
 }
Example #11
0
 public function __construct(Dispatcher $dispatcher, $fd, $what, $arg = null)
 {
     $this->dispatcher = $dispatcher;
     $this->base = $dispatcher->getBase();
     $this->fd = $fd;
     $this->what = $what;
     $this->argument = $arg;
     $this->callback = [$this->dispatcher, Dispatcher::FORWARD_METHOD_NAME];
 }
 /**
  * @desc Redirect the request to the right controller using the url controller mappes list
  * @param UrlControllerMapper[] $url_controller_mappers the url controllers mapper list
  */
 public static function dispatch($url_controller_mappers)
 {
     try {
         $dispatcher = new Dispatcher($url_controller_mappers);
         $dispatcher->dispatch();
     } catch (NoUrlMatchException $ex) {
         self::handle_dispatch_exception($ex);
     }
 }
Example #13
0
 /**
  */
 public function testRemoveListener()
 {
     $eventName = 'test';
     $dispatcher = new Dispatcher();
     $listener = new Listener($eventName);
     $dispatcher->addListener($eventName, $listener);
     $dispatcher->removeListener($eventName, $listener);
     $this->assertEmpty($dispatcher->getListeners());
 }
 /** @test */
 public function should_register_new_user()
 {
     $this->repository->shouldReceive('userOfEmail')->andReturn(null);
     $this->repository->shouldReceive('userOfUsername')->andReturn(null);
     $this->repository->shouldReceive('nextIdentity')->andReturn($this->uuid);
     $this->hashing->shouldReceive('hash')->andReturn($this->password);
     $this->repository->shouldReceive('add');
     $this->dispatcher->shouldReceive('dispatch');
     $user = $this->service->registerUser('*****@*****.**', 'username', 'password');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\User', $user);
 }
Example #15
0
 /**
  * Get content from listeners
  */
 public function getAuthenticationContent()
 {
     $content = '';
     if ($this->dispatcher->hasListeners(UserEvents::USER_AUTHENTICATION_CONTENT)) {
         $event = new AuthenticationContentEvent($this->request);
         $this->dispatcher->dispatch(UserEvents::USER_AUTHENTICATION_CONTENT, $event);
         $content = $event->getContent();
         // Remove post_logout session after content has been generated
         $this->request->getSession()->remove('post_logout');
     }
     return $content;
 }
Example #16
0
 protected function registerEventListeners()
 {
     $registrationModel = $this->config->get('auth::registration_strategy');
     switch ($registrationModel) {
         case 'single_opt_in':
             $this->event->listen('Ipunkt.Auth.*', 'Ipunkt\\Auth\\Listeners\\SingleOptInListener');
             break;
         case 'double_opt_in':
             $this->event->listen('Ipunkt.Auth.*', 'Ipunkt\\Auth\\Listeners\\DoubleOptInListener');
             break;
         default:
     }
 }
Example #17
0
 /**
  * Intercept redirect and render amf response
  *
  * @param object $controller
  * @return void
  */
 function beforeRedirect(&$controller, $url, $status = null, $exit = true)
 {
     if ($controller->isAmf && $this->autoRedirect) {
         if (is_array($url)) {
             $url = Router::url($url);
         }
         $Dispatcher = new Dispatcher();
         $Dispatcher->dispatch($url);
         if ($exit) {
             exit;
         }
     }
 }
Example #18
0
 public static function dispatch(Request $request = null, Response $response = null)
 {
     if ($request === null) {
         $request = new Request();
     }
     if ($response === null) {
         $response = new Response();
     }
     $app = self::instance();
     $app->setRequest($request);
     $dispatcher = new Dispatcher(APP_CONTROLLERS_DIR);
     $dispatcher->dispatch($request, $response);
     $response->send();
 }
Example #19
0
 public function testDispatching()
 {
     $dispatcher = new Dispatcher(['index', 'blog', 'projects', '_drafts/blog']);
     $dispatcher->map('blog', 'bloge');
     $dispatcher->alias('projects', 'projectos');
     $dispatcher->ignore('_drafts/blog');
     $this->assertEquals('blog', $dispatcher->dispatch('bloge'));
     $this->assertEquals('projects', $dispatcher->dispatch('projectos'));
     $this->assertEquals('projects', $dispatcher->dispatch('projects'));
     $this->assertEquals('', $dispatcher->dispatch('_drafts/blog'));
     $this->assertEquals('foobar', $dispatcher->dispatch('foobar'));
 }
Example #20
0
 protected function _prepareHook($params)
 {
     $languages = Language::getLanguages(true, $this->context->shop->id);
     if (!count($languages)) {
         return false;
     }
     $link = new Link();
     if ((int) Configuration::get('PS_REWRITING_SETTINGS')) {
         $default_rewrite = array();
         if (Dispatcher::getInstance()->getController() == 'product' && ($id_product = (int) Tools::getValue('id_product'))) {
             $rewrite_infos = Product::getUrlRewriteInformations((int) $id_product);
             foreach ($rewrite_infos as $infos) {
                 $default_rewrite[$infos['id_lang']] = $link->getProductLink((int) $id_product, $infos['link_rewrite'], $infos['category_rewrite'], $infos['ean13'], (int) $infos['id_lang']);
             }
         }
         if (Dispatcher::getInstance()->getController() == 'category' && ($id_category = (int) Tools::getValue('id_category'))) {
             $rewrite_infos = Category::getUrlRewriteInformations((int) $id_category);
             foreach ($rewrite_infos as $infos) {
                 $default_rewrite[$infos['id_lang']] = $link->getCategoryLink((int) $id_category, $infos['link_rewrite'], $infos['id_lang']);
             }
         }
         if (Dispatcher::getInstance()->getController() == 'cms' && (($id_cms = (int) Tools::getValue('id_cms')) || ($id_cms_category = (int) Tools::getValue('id_cms_category')))) {
             $rewrite_infos = isset($id_cms) && !isset($id_cms_category) ? CMS::getUrlRewriteInformations($id_cms) : CMSCategory::getUrlRewriteInformations($id_cms_category);
             foreach ($rewrite_infos as $infos) {
                 $arr_link = isset($id_cms) && !isset($id_cms_category) ? $link->getCMSLink($id_cms, $infos['link_rewrite'], null, $infos['id_lang']) : $link->getCMSCategoryLink($id_cms_category, $infos['link_rewrite'], $infos['id_lang']);
                 $default_rewrite[$infos['id_lang']] = $arr_link;
             }
         }
         $this->smarty->assign('lang_rewrite_urls', $default_rewrite);
     }
     return true;
 }
Example #21
0
 /**
  * Loads routes and resets if the test case dictates it should
  *
  * @return void
  */
 protected function _loadRoutes()
 {
     parent::_loadRoutes();
     if (!$this->loadRoutes) {
         Router::reload();
     }
 }
Example #22
0
 /**
  * 应用程序初始化
  * @access public
  * @return void
  */
 public static function init()
 {
     // 加载动态应用公共文件和配置
     load_ext_file(COMMON_PATH);
     // 定义当前请求的系统常量
     define('NOW_TIME', $_SERVER['REQUEST_TIME']);
     define('REQUEST_METHOD', $_SERVER['REQUEST_METHOD']);
     define('IS_GET', REQUEST_METHOD == 'GET' ? true : false);
     define('IS_POST', REQUEST_METHOD == 'POST' ? true : false);
     define('IS_PUT', REQUEST_METHOD == 'PUT' ? true : false);
     define('IS_DELETE', REQUEST_METHOD == 'DELETE' ? true : false);
     define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' || !empty($_POST[C('VAR_AJAX_SUBMIT')]) || !empty($_GET[C('VAR_AJAX_SUBMIT')]) ? true : false);
     // URL调度
     Dispatcher::dispatch();
     if (C('REQUEST_VARS_FILTER')) {
         // 全局安全过滤
         array_walk_recursive($_GET, 'think_filter');
         array_walk_recursive($_POST, 'think_filter');
         array_walk_recursive($_REQUEST, 'think_filter');
     }
     // URL调度结束标签
     Hook::listen('url_dispatch');
     // 日志目录转换为绝对路径
     C('LOG_PATH', realpath(LOG_PATH) . '/' . MODULE_NAME . '/');
     // TMPL_EXCEPTION_FILE 改为绝对地址
     C('TMPL_EXCEPTION_FILE', realpath(C('TMPL_EXCEPTION_FILE')));
     return;
 }
Example #23
0
 /**
  * 运行应用实例 入口文件使用的快捷方法
  * @access public
  * @return void
  */
 public static function run()
 {
     // 设置系统时区
     date_default_timezone_set(C('DEFAULT_TIMEZONE'));
     // 加载动态项目公共文件和配置
     load_ext_file();
     // 项目初始化标签
     tag('app_init');
     // URL调度
     Dispatcher::dispatch();
     // 项目开始标签
     tag('app_begin');
     // Session初始化 支持其他客户端
     if (isset($_REQUEST[C("VAR_SESSION_ID")])) {
         session_id($_REQUEST[C("VAR_SESSION_ID")]);
     }
     if (C('SESSION_AUTO_START')) {
         session_start();
     }
     // 记录应用初始化时间
     if (C('SHOW_RUN_TIME')) {
         G('initTime');
     }
     App::exec();
     // 项目结束标签
     tag('app_end');
     // 保存日志记录
     if (C('LOG_RECORD')) {
         Log::save();
     }
     return;
 }
 public function w3tc_ajax_extension_cloudflare_zones_done()
 {
     $email = $_REQUEST['email'];
     $key = $_REQUEST['key'];
     $zone_id = Util_Request::get('zone_id');
     if (empty($zone_id)) {
         return $this->_render_extension_cloudflare_zones(array('email' => $email, 'key' => $key, 'error_message' => 'Please select zone'));
     }
     $zone_name = '';
     // get zone name
     try {
         $api = new Extension_CloudFlare_Api(array('email' => $email, 'key' => $key));
         $zone = $api->zone($zone_id);
         $zone_name = $zone['name'];
     } catch (\Exception $ex) {
         $details['error_message'] = 'Can\'t authenticate: ' . $ex->getMessage();
         include W3TC_DIR . '/Extension_CloudFlare_Popup_View_Intro.php';
         exit;
     }
     $c = Dispatcher::config();
     $c->set(array('cloudflare', 'email'), $email);
     $c->set(array('cloudflare', 'key'), $key);
     $c->set(array('cloudflare', 'zone_id'), $zone_id);
     $c->set(array('cloudflare', 'zone_name'), $zone_name);
     $c->save();
     delete_transient('w3tc_cloudflare_stats');
     $postfix = Util_Admin::custom_message_id(array(), array('extension_cloudflare_configuration_saved' => 'CloudFlare credentials are saved successfully'));
     echo 'Location admin.php?page=w3tc_extensions&extension=cloudflare&' . 'action=view&' . $postfix;
     exit;
 }
Example #25
0
 /**
  * undocumented function
  *
  * @param string $id
  * @return void
  * @access public
  */
 function delete($id = null)
 {
     $comment = $this->Comment->find('first', array('conditions' => array('Comment.id' => $id)));
     Assert::true(Comment::isOwn($comment));
     if (!$this->Comment->delete($id)) {
         if ($this->isAjax()) {
             $msg = __('There are problems with the form.', true);
             return $this->Json->error($msg, array('profile' => true));
         }
         $dispatcher = new Dispatcher();
         $dispatcher->dispatch($this->referer(), array('formerror' => true, 'formerror-msg' => __('There are problems with the form.', true)));
         exit;
     }
     $msg = __('Successfully deleted!', true);
     $this->Message->add($msg, 'ok', true, $this->referer());
 }
Example #26
0
 /**
  * initialize()
  * 
  * Este método é responsável pela inicialização da aplicação.
  * 
  * Primeiro ajusta as variáveis de sistema verificando qual é a aplicação
  * atual. Depois consolida a aplicação atual.
  * 
  * Depois verifica na app atual o Routing. Uma app pode redirecionar para outra.
  * 
  * 
  */
 function initialize()
 {
     /* Define endereços iniciais */
     $this->setWEBROOT();
     /* App padrão */
     $this->getAppDir();
     $_GET['url'] = $this->url;
     include CORE_CLASS_DIR . "Dispatcher.php";
     $dispatcher = new Dispatcher();
     $dispatcher->app = $this->appDir;
     $dispatcher->appPublicDir = $this->_getSystemPublicDir();
     $dispatcher->initialize();
     if (defined('CORE_ENGINE_DIR')) {
         include CORE_ENGINE_DIR . 'app_engine.php';
     }
 }
Example #27
0
 /**
  * 应用程序初始化
  *
  * @access public
  * @return void
  */
 public static function init()
 {
     // 加载动态应用公共文件和配置
     load_ext_file(COMMON_PATH);
     // 定义当前请求的系统常量
     define('NOW_TIME', $_SERVER['REQUEST_TIME']);
     define('REQUEST_METHOD', $_SERVER['REQUEST_METHOD']);
     define('IS_GET', REQUEST_METHOD == 'GET' ? true : false);
     define('IS_POST', REQUEST_METHOD == 'POST' ? true : false);
     define('IS_PUT', REQUEST_METHOD == 'PUT' ? true : false);
     define('IS_DELETE', REQUEST_METHOD == 'DELETE' ? true : false);
     // URL调度
     Dispatcher::dispatch();
     // URL调度结束标签
     Hook::listen('url_dispatch');
     define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' || !empty($_POST[C('VAR_AJAX_SUBMIT')]) || !empty($_GET[C('VAR_AJAX_SUBMIT')]) ? true : false);
     // 日志目录转换为绝对路径
     C('LOG_PATH', realpath(LOG_PATH) . '/' . MODULE_NAME . '/');
     // TMPL_EXCEPTION_FILE 改为绝对地址
     C('TMPL_EXCEPTION_FILE', realpath(C('TMPL_EXCEPTION_FILE')));
     // 泛域名支持
     if (C('DIV_DOMAIN')) {
         $top_domain = top_domain();
         C('COOKIE_DOMAIN', $top_domain);
         C('SESSION_OPTIONS', array('domain' => $top_domain));
     }
     return;
 }
Example #28
0
 public function &getInstance()
 {
     if (self::$instance === false) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * Referrer tab
  *
  * @return void
  */
 function view()
 {
     $groups = $this->_config->get_array('referrer.rgroups');
     $w3_referrer = Dispatcher::component('Mobile_Referrer');
     $themes = $w3_referrer->get_themes();
     include W3TC_INC_DIR . '/options/referrer.php';
 }
 /**
  * Print JS required by the support nag.
  */
 function admin_head()
 {
     $state = Dispatcher::config_state_master();
     // support us
     $support_reminder = $state->get_integer('common.support_us_invitations') < 3 && $state->get_integer('common.install') < time() - W3TC_SUPPORT_US_TIMEOUT && $state->get_integer('common.next_support_us_invitation') < time() && $this->_config->get_string('common.support') == '' && !$this->_config->get_boolean('common.tweeted');
     if ($support_reminder) {
         $state->set('common.next_support_us_invitation', time() + W3TC_SUPPORT_US_TIMEOUT);
         $state->set('common.support_us_invitations', $state->get_integer('common.support_us_invitations') + 1);
         $state->save();
         do_action('w3tc_message_action_generic_support_us');
     }
     // edge mode
     $edge_reminder = !$support_reminder && !Util_Environment::is_w3tc_edge($this->_config) && $state->get_integer('common.edge_invitations') < 3 && $state->get_integer('common.install') < time() - W3TC_EDGE_TIMEOUT && $state->get_integer('common.next_edge_invitation') < time();
     if ($edge_reminder) {
         if ($state->get_integer('common.edge_invitations') > 1) {
             $next = time() + 30 * 24 * 60 * 60;
         } else {
             $next = time() + W3TC_EDGE_TIMEOUT;
         }
         $state->set('common.next_edge_invitation', $next);
         $state->set('common.edge_invitations', $state->get_integer('common.edge_invitations') + 1);
         $state->save();
         do_action('w3tc_message_action_generic_edge');
     }
 }