Example #1
0
 /**
  * Logout, revoke access token and redirect to location
  * @return void or bool
  */
 public function logout($redirect = '/', $token = null)
 {
     $current_token = $token ?: $this->parseToken();
     if ($redirect and $current_token) {
         $this->session->forget('googleapi_token');
         $this->client->revokeToken($current_token);
         return $this->redirect->to($redirect);
     }
     return false;
 }
Example #2
0
 /**
  * Render the component.
  *
  * @param   string  $option  The component option.
  * @param   array   $params  The component parameters
  * @return  object
  */
 public function render($option, $params = array())
 {
     // Load template language files.
     $lang = $this->app['language'];
     if ($this->app->has('template')) {
         $template = $this->app['template']->template;
         $lang->load('tpl_' . $template, JPATH_BASE, null, false, true);
         $lang->load('tpl_' . $template, JPATH_THEMES . DS . $template, null, false, true);
     }
     if (empty($option)) {
         // Throw 404 if no component
         $this->app->abort(404, $lang->translate('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'));
     }
     $option = $this->canonical($option);
     // Record the scope
     $scope = $this->app->has('scope') ? $this->app->get('scope') : null;
     // Set scope to component name
     $this->app->set('scope', $option);
     // Build the component path.
     $file = substr($option, 4);
     $client = isset($this->app['client']->alias) ? $this->app['client']->alias : $this->app['client']->name;
     // Get component path
     if (is_dir(PATH_APP . DS . 'components' . DS . $option . DS . $client)) {
         // Set path and constants for combined components
         define('JPATH_COMPONENT', PATH_APP . DS . 'components' . DS . $option . DS . $client);
         define('JPATH_COMPONENT_SITE', PATH_APP . DS . 'components' . DS . $option . DS . 'site');
         define('JPATH_COMPONENT_ADMINISTRATOR', PATH_APP . DS . 'components' . DS . $option . DS . 'admin');
     } else {
         // Set path and constants for combined components
         define('JPATH_COMPONENT', PATH_CORE . DS . 'components' . DS . $option . DS . $client);
         define('JPATH_COMPONENT_SITE', PATH_CORE . DS . 'components' . DS . $option . DS . 'site');
         define('JPATH_COMPONENT_ADMINISTRATOR', PATH_CORE . DS . 'components' . DS . $option . DS . 'admin');
     }
     $path = JPATH_COMPONENT . DS . $file . '.php';
     // If component is disabled throw error
     if (!$this->isEnabled($option) || !file_exists($path)) {
         $this->app->abort(404, $lang->translate('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'));
     }
     // Load common and local language files.
     $lang->load($option, JPATH_COMPONENT, null, false, true) || $lang->load($option, JPATH_BASE, null, false, true);
     // Handle template preview outlining.
     $contents = null;
     // Execute the component.
     $contents = $this->execute($path);
     // Revert the scope
     $this->app->forget('scope');
     $this->app->set('scope', $scope);
     return $contents;
 }
Example #3
0
 /**
  * Test removing item from cache
  *
  * @return  void
  */
 public function testForget()
 {
     $this->assertTrue($this->cache->forget('key'));
 }
Example #4
0
 /**
  * Render the module.
  *
  * @param   object  $module   A module object.
  * @param   array   $attribs  An array of attributes for the module (probably from the XML).
  * @return  string  The HTML content of the module output.
  */
 public function render($module, $attribs = array())
 {
     static $chrome;
     if (null !== $this->profiler) {
         $this->profiler->mark('beforeRenderModule ' . $module->module . ' (' . $module->title . ')');
     }
     // Record the scope.
     $scope = $this->app->has('scope') ? $this->app->get('scope') : null;
     // Set scope to component name
     $this->app->set('scope', $module->module);
     // Get module parameters
     $params = new Registry($module->params);
     if (isset($attribs['params'])) {
         $customparams = new Registry(html_entity_decode($attribs['params'], ENT_COMPAT, 'UTF-8'));
         $params->merge($customparams);
         $module->params = $params->toString();
     }
     // Get module path
     $module->module = preg_replace('/[^A-Z0-9_\\.-]/i', '', $module->module);
     $path = PATH_CORE . DS . 'modules' . DS . $module->module . DS . $module->module . '.php';
     // Load the module
     // $module->user is a check for 1.0 custom modules and is deprecated refactoring
     if (file_exists($path)) {
         $this->app['language']->load($module->module, PATH_APP . DS . 'bootstrap' . DS . $this->app['client']->name, null, false, true) || $this->app['language']->load($module->module, dirname($path), null, false, true);
         $content = '';
         ob_start();
         include $path;
         $module->content = ob_get_contents() . $content;
         ob_end_clean();
     }
     // Load the module chrome functions
     if (!$chrome) {
         $chrome = array();
     }
     include_once PATH_CORE . DS . 'templates' . DS . 'system' . DS . 'html' . DS . 'modules.php';
     $chromePath = $this->app['template']->path . DS . 'html' . DS . 'modules.php';
     if (!isset($chrome[$chromePath])) {
         if (file_exists($chromePath)) {
             include_once $chromePath;
         }
         $chrome[$chromePath] = true;
     }
     // Make sure a style is set
     if (!isset($attribs['style'])) {
         $attribs['style'] = 'none';
     }
     // Dynamically add outline style
     if ($this->outline()) {
         $attribs['style'] .= ' outline';
     }
     foreach (explode(' ', $attribs['style']) as $style) {
         $chromeMethod = 'modChrome_' . $style;
         // Apply chrome and render module
         if (function_exists($chromeMethod)) {
             $module->style = $attribs['style'];
             ob_start();
             $chromeMethod($module, $params, $attribs);
             $module->content = ob_get_contents();
             ob_end_clean();
         }
     }
     // Revert the scope
     $this->app->forget('scope');
     $this->app->set('scope', $scope);
     if (null !== $this->profiler) {
         $this->profiler->mark('afterRenderModule ' . $module->module . ' (' . $module->title . ')');
     }
     return $module->content;
 }
 /**
  * Test removing item from cache
  *
  * @dataProvider dataProvider
  *
  * @param   string    $key
  * @param   mixed     $value
  * @param   int|null  $ttl
  * @return  void
  */
 public function testForget($key, $value, $ttl)
 {
     $this->cache->put($key, $value, $ttl);
     $this->assertTrue($this->cache->forget($key));
     $this->assertFalse($this->cache->has($key));
 }
Example #6
0
 /**
  * Render the component.
  *
  * @param   string  $option  The component option.
  * @param   array   $params  The component parameters
  * @return  object
  */
 public function render($option, $params = array())
 {
     // Load template language files.
     $lang = $this->app['language'];
     if ($this->app->has('template')) {
         $template = $this->app['template']->template;
         $lang->load('tpl_' . $template, JPATH_BASE, null, false, true);
         $lang->load('tpl_' . $template, JPATH_THEMES . DS . $template, null, false, true);
     }
     if (empty($option)) {
         // Throw 404 if no component
         $this->app->abort(404, $lang->translate('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'));
     }
     $option = $this->canonical($option);
     // Record the scope
     $scope = $this->app->has('scope') ? $this->app->get('scope') : null;
     // Set scope to component name
     $this->app->set('scope', $option);
     // Build the component path.
     $file = substr($option, 4);
     $client = isset($this->app['client']->alias) ? $this->app['client']->alias : $this->app['client']->name;
     // Get component path
     if (is_dir(PATH_APP . DS . 'components' . DS . $option . DS . $client)) {
         // Set path and constants for combined components
         define('JPATH_COMPONENT', PATH_APP . DS . 'components' . DS . $option . DS . $client);
         define('JPATH_COMPONENT_SITE', PATH_APP . DS . 'components' . DS . $option . DS . 'site');
         define('JPATH_COMPONENT_ADMINISTRATOR', PATH_APP . DS . 'components' . DS . $option . DS . 'admin');
     } else {
         // Set path and constants for combined components
         define('JPATH_COMPONENT', PATH_CORE . DS . 'components' . DS . $option . DS . $client);
         define('JPATH_COMPONENT_SITE', PATH_CORE . DS . 'components' . DS . $option . DS . 'site');
         define('JPATH_COMPONENT_ADMINISTRATOR', PATH_CORE . DS . 'components' . DS . $option . DS . 'admin');
     }
     $path = JPATH_COMPONENT . DS . $file . '.php';
     $namespace = '\\Components\\' . ucfirst(substr($option, 4)) . '\\' . ucfirst($client) . '\\Bootstrap';
     $found = false;
     // Make sure the component is enabled
     if ($this->isEnabled($option)) {
         // Check to see if the class is autoload-able
         if (class_exists($namespace)) {
             $found = true;
             $path = $namespace;
             // Infer the appropriate language path and load from there
             $file = with(new \ReflectionClass($namespace))->getFileName();
             $bits = explode(DS, $file);
             $local = implode(DS, array_slice($bits, 0, -1));
             // Load local language files
             $lang->load($option, $local, null, false, true);
         } else {
             if (file_exists($path)) {
                 $found = true;
                 // Load local language files
                 $lang->load($option, JPATH_COMPONENT, null, false, true);
             }
         }
     }
     // Make sure we found something
     if (!$found) {
         $this->app->abort(404, $lang->translate('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND_OR_ENABLED'));
     }
     // Load base language file
     $lang->load($option, JPATH_BASE, null, false, true);
     // Handle template preview outlining.
     $contents = null;
     // Execute the component.
     $contents = $this->execute($path);
     // Revert the scope
     $this->app->forget('scope');
     $this->app->set('scope', $scope);
     return $contents;
 }