Beispiel #1
0
 /**
  * Method to remove root in global configuration.
  *
  * @return  boolean  True on success.
  *
  * @since   3.2
  */
 public function execute()
 {
     // Check for request forgeries.
     if (!JSession::checkToken('get')) {
         $this->app->enqueueMessage(JText::_('JINVALID_TOKEN'));
         $this->app->redirect('index.php');
     }
     // Check if the user is authorized to do this.
     if (!JFactory::getUser()->authorise('core.admin')) {
         $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
         $this->app->redirect('index.php');
     }
     // Initialise model.
     $model = new ConfigModelApplication();
     // Attempt to save the configuration and remove root.
     try {
         $model->removeroot();
     } catch (RuntimeException $e) {
         // Save failed, go back to the screen and display a notice.
         $this->app->enqueueMessage(JText::sprintf('JERROR_SAVE_FAILED', $e->getMessage()), 'error');
         $this->app->redirect(JRoute::_('index.php', false));
     }
     // Set the redirect based on the task.
     $this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
     $this->app->redirect(JRoute::_('index.php', false));
 }
Beispiel #2
0
 /**
  * Execute the controller.
  *
  * @return  boolean  True if controller finished execution, false if the controller did not
  *                   finish execution. A controller might return false if some precondition for
  *                   the controller to run has not been satisfied.
  *
  * @since   12.1
  * @throws  LogicException
  * @throws  RuntimeException
  */
 public function execute()
 {
     $model = new MonitorModelIssue();
     $id = $this->input->getInt('id');
     $user = JFactory::getUser();
     // Get the params
     // TODO: may be removed when new MVC is implemented completely
     $this->app = JFactory::getApplication();
     if ($this->app instanceof JApplicationSite) {
         $params = $this->app->getParams();
     }
     if (!$model->canEdit($user, $id)) {
         if ($user->guest && isset($params) && $params->get('redirect_login', 1)) {
             $this->app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error');
             $this->app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode(JUri::getInstance()->toString()), '403'));
         } else {
             throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
         }
     }
     if ($id) {
         $model->setIssueId($id);
     }
     $model->loadForm();
     $view = new MonitorViewIssueHtml($model);
     $view->setLayout('edit');
     $view->loadForm();
     echo $view->render();
     return true;
 }
Beispiel #3
0
 public function onUserLoginFailure($response)
 {
     var_dump($response);
     if ($response['status'] === 4 && $response['error_message'] == "suspended") {
         $this->app->redirect(JRoute::_('account-suspended', false));
     }
     //die();
 }
Beispiel #4
0
 /**
  * Method to save global configuration.
  *
  * @return  boolean  True on success.
  *
  * @since   3.2
  */
 public function execute()
 {
     // Check for request forgeries.
     if (!JSession::checkToken()) {
         $this->app->enqueueMessage(JText::_('JINVALID_TOKEN'));
         $this->app->redirect('index.php');
     }
     // Check if the user is authorized to do this.
     if (!JFactory::getUser()->authorise('core.admin')) {
         $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
         $this->app->redirect('index.php');
     }
     // Set FTP credentials, if given.
     JClientHelper::setCredentialsFromRequest('ftp');
     $model = new ConfigModelConfig();
     $form = $model->getForm();
     $data = $this->input->post->get('jform', array(), 'array');
     // Validate the posted data.
     $return = $model->validate($form, $data);
     // Check for validation errors.
     if ($return === false) {
         /*
          * The validate method enqueued all messages for us, so we just need to redirect back.
          */
         // Save the data in the session.
         $this->app->setUserState('com_config.config.global.data', $data);
         // Redirect back to the edit screen.
         $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
     }
     // Attempt to save the configuration.
     $data = $return;
     // Access back-end com_config
     JLoader::registerPrefix('Config', JPATH_ADMINISTRATOR . '/components/com_config');
     $saveClass = new ConfigControllerApplicationSave();
     // Get a document object
     $document = JFactory::getDocument();
     // Set back-end required params
     $document->setType('json');
     // Execute back-end controller
     $return = $saveClass->execute();
     // Reset params back after requesting from service
     $document->setType('html');
     // Check the return value.
     if ($return === false) {
         /*
          * The save method enqueued all messages for us, so we just need to redirect back.
          */
         // Save the data in the session.
         $this->app->setUserState('com_config.config.global.data', $data);
         // Save failed, go back to the screen and display a notice.
         $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
     }
     // Redirect back to com_config display
     $this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
     $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
     return true;
 }
 /**
  * Execute the controller.
  *
  * @return  boolean  True if controller finished execution, false if the controller did not
  *                   finish execution. A controller might return false if some precondition for
  *                   the controller to run has not been satisfied.
  *
  * @since   12.1
  * @throws  LogicException
  * @throws  RuntimeException
  */
 public function execute()
 {
     $id = $this->input->getInt('id');
     $user = JFactory::getUser();
     if ($user->guest) {
         $this->app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error');
     } else {
         $model = new MonitorModelSubscription();
         if ($model->isSubscriberIssue($id, $user->id)) {
             $model->unsubscribeIssue($id, $user->id);
             $this->app->enqueueMessage(JText::_('COM_MONITOR_SUBSCRIPTION_ISSUE_UNSUBSCRIBED'), 'message');
         }
     }
     $this->app->redirect(JRoute::_('index.php?option=com_monitor&view=issue&id=' . $id, false));
 }
Beispiel #6
0
 /**
  * Re-route Gantry templates to Gantry Administration component.
  */
 private function onAfterRouteAdmin()
 {
     $input = $this->app->input;
     $option = $input->getCmd('option');
     $task = $input->getCmd('task');
     if (in_array($option, ['com_templates', 'com_advancedtemplates']) && $task && strpos($task, 'style') === 0) {
         // Get all ids.
         $cid = $input->post->get('cid', (array) $input->getInt('id'), 'array');
         if ($cid) {
             $styles = $this->getStyles();
             $selected = array_intersect(array_keys($styles), $cid);
             // If no Gantry templates were selected, just let com_templates deal with the request.
             if (!$selected) {
                 return;
             }
             // Special handling for tasks coming from com_template.
             if ($task == 'style.edit') {
                 $id = (int) array_shift($cid);
                 if (isset($styles[$id])) {
                     $token = JSession::getFormToken();
                     $this->app->redirect("index.php?option=com_gantry5&view=configurations/{$id}/styles&style={$id}&{$token}=1");
                 }
             }
         }
     }
 }
Beispiel #7
0
 /**
  * Method to refresh help in global configuration.
  *
  * @return  boolean  True on success.
  *
  * @since   3.2
  */
 public function execute()
 {
     jimport('joomla.filesystem.file');
     // Set FTP credentials, if given
     JClientHelper::setCredentialsFromRequest('ftp');
     if (($data = file_get_contents('http://help.joomla.org/helpsites.xml')) === false) {
         $this->app->enqueueMessage(JText::_('COM_CONFIG_ERROR_HELPREFRESH_FETCH'), 'error');
         $this->app->redirect(JRoute::_('index.php?option=com_config', false));
     } elseif (!JFile::write(JPATH_BASE . '/help/helpsites.xml', $data)) {
         $this->app->enqueueMessage(JText::_('COM_CONFIG_ERROR_HELPREFRESH_ERROR_STORE'), 'error');
         $this->app->redirect(JRoute::_('index.php?option=com_config', false));
     } else {
         $this->app->enqueueMessage(JText::_('COM_CONFIG_HELPREFRESH_SUCCESS'), 'error');
         $this->app->redirect(JRoute::_('index.php?option=com_config', false));
     }
 }
Beispiel #8
0
 /**
  * Converting the site URL to fit to the HTTP request
  */
 public function onAfterRoute()
 {
     $params = JComponentHelper::getParams('com_userxtd');
     if ($params->get('CoreRegistration_Redirect', 0)) {
         $option = $this->input->get('option');
         $view = $this->input->get('view');
         $layout = $this->input->get('layout', 'default');
         $id = $this->input->get('id', JFactory::getUser()->id);
         if ($option == 'com_users') {
             $this->initComponent();
             if ($view == 'registration' && $layout == 'default') {
                 $this->app->redirect(Route::_('register'));
             }
             if ($view == 'profile' && $layout == 'default') {
                 if ($id) {
                     $this->app->redirect(Route::_('user_id', array('id' => $id)));
                 } else {
                     $this->app->redirect(Route::_('user'));
                 }
             }
             if ($view == 'profile' && $layout == 'edit') {
                 $this->app->redirect(Route::_('user_layout', array('task' => 'user.edit.edit', 'layout' => 'edit', 'id' => $id)));
             }
         }
     }
 }
Beispiel #9
0
 /**
  * Force to SSL
  * 
  * @param   JRouterSite  &$router  Router object
  * @param   JUri         &$uri     URI object to process
  *
  * @return  void
  * 
  * @since   4.0
  */
 public function parseCheckSSL(&$router, &$uri)
 {
     if (strtolower($uri->getScheme()) != 'https') {
         // Forward to https
         $uri->setScheme('https');
         $this->app->redirect((string) $uri, 301);
     }
 }
Beispiel #10
0
 /**
  * Function to convert a route to an internal URI
  *
  * @param   JUri  &$uri  The uri.
  *
  * @return  array
  *
  * @since   1.5
  */
 public function parse(&$uri)
 {
     $vars = array();
     if ($this->app->get('force_ssl') == 2 && strtolower($uri->getScheme()) != 'https') {
         // Forward to https
         $uri->setScheme('https');
         $this->app->redirect((string) $uri, 301);
     }
     // Get the path
     // Decode URL to convert percent-encoding to unicode so that strings match when routing.
     $path = urldecode($uri->getPath());
     // Remove the base URI path.
     $path = substr_replace($path, '', 0, strlen(JUri::base(true)));
     // Check to see if a request to a specific entry point has been made.
     if (preg_match("#.*?\\.php#u", $path, $matches)) {
         // Get the current entry point path relative to the site path.
         $scriptPath = realpath($_SERVER['SCRIPT_FILENAME'] ? $_SERVER['SCRIPT_FILENAME'] : str_replace('\\\\', '\\', $_SERVER['PATH_TRANSLATED']));
         $relativeScriptPath = str_replace('\\', '/', str_replace(JPATH_SITE, '', $scriptPath));
         // If a php file has been found in the request path, check to see if it is a valid file.
         // Also verify that it represents the same file from the server variable for entry script.
         if (file_exists(JPATH_SITE . $matches[0]) && $matches[0] == $relativeScriptPath) {
             // Remove the entry point segments from the request path for proper routing.
             $path = str_replace($matches[0], '', $path);
         }
     }
     // Identify format
     if ($this->_mode == JROUTER_MODE_SEF) {
         if ($this->app->get('sef_suffix') && !(substr($path, -9) == 'index.php' || substr($path, -1) == '/')) {
             if ($suffix = pathinfo($path, PATHINFO_EXTENSION)) {
                 $vars['format'] = $suffix;
             }
         }
     }
     // Set the route
     $uri->setPath(trim($path, '/'));
     // Set the parsepreprocess components methods
     $components = JComponentHelper::getComponents();
     foreach ($components as $component) {
         $componentRouter = $this->getComponentRouter($component->option);
         if (method_exists($componentRouter, 'parsepreprocess')) {
             $this->attachParseRule(array($componentRouter, 'parsepreprocess'), static::PROCESS_BEFORE);
         }
     }
     $vars += parent::parse($uri);
     return $vars;
 }
Beispiel #11
0
 /**
  * Execute the controller.
  *
  * @return  boolean  True if controller finished execution, false if the controller did not
  *                   finish execution. A controller might return false if some precondition for
  *                   the controller to run has not been satisfied.
  *
  * @since   12.1
  * @throws  LogicException
  * @throws  RuntimeException
  */
 public function execute()
 {
     $id = $this->input->getInt('id');
     $user = JFactory::getUser();
     if ($user->guest) {
         $this->app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error');
     } else {
         $model = new MonitorModelSubscription();
         if (!$model->isSubscriberProject($id, $user->id)) {
             $model->subscribeProject($id, $user->id);
             $this->app->enqueueMessage(JText::_('COM_MONITOR_SUBSCRIPTION_PROJECT'), 'message');
         }
     }
     $return = base64_decode($this->app->input->get('return', '', 'BASE64'));
     if (!JUri::isInternal($return)) {
         $return = 'index.php?option=com_monitor&view=project&id=' . $id;
     }
     $this->app->redirect(JRoute::_($return, false));
 }
Beispiel #12
0
 /**
  * Execute the controller.
  *
  * @return  boolean  True if controller finished execution, false if the controller did not
  *                   finish execution. A controller might return false if some precondition for
  *                   the controller to run has not been satisfied.
  *
  * @since   12.1
  * @throws  LogicException
  * @throws  RuntimeException
  */
 public function execute()
 {
     if (!JFactory::getUser()->authorise('attachment.delete', 'com_monitor')) {
         throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
     }
     $app = JFactory::getApplication();
     $model = new MonitorModelAttachments($app);
     $id = $app->input->getInt('id');
     if (!$id) {
         throw new Exception(JText::_('JERROR_NO_ITEMS_SELECTED'), 404);
     }
     $model->delete(array($id));
     $app->enqueueMessage(JText::_('COM_MONITOR_ATTACHMENT_DELETED'));
     $return = base64_decode($this->app->input->get('return', '', 'BASE64'));
     if (!JUri::isInternal($return)) {
         $return = 'index.php?option=com_monitor&view=projects';
     }
     $this->app->redirect(JRoute::_($return, false));
     return true;
 }
Beispiel #13
0
 /**
  * Method to save global configuration.
  *
  * @return  mixed  Calls $app->redirect()
  *
  * @since   3.2
  */
 public function execute()
 {
     // Check for request forgeries.
     if (!JSession::checkToken()) {
         $this->app->enqueueMessage(JText::_('JINVALID_TOKEN'));
         $this->app->redirect('index.php');
     }
     // Set FTP credentials, if given.
     JClientHelper::setCredentialsFromRequest('ftp');
     $model = new ConfigModelComponent();
     $form = $model->getForm();
     $data = $this->input->get('jform', array(), 'array');
     $id = $this->input->getInt('id');
     $option = $this->input->get('component');
     // Check if the user is authorized to do this.
     if (!JFactory::getUser()->authorise('core.admin', $option)) {
         $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
         $this->app->redirect('index.php');
     }
     $returnUri = $this->input->post->get('return', null, 'base64');
     $redirect = '';
     if (!empty($returnUri)) {
         $redirect = '&return=' . urlencode($returnUri);
     }
     // Validate the posted data.
     $return = $model->validate($form, $data);
     // Check for validation errors.
     if ($return === false) {
         /*
          * The validate method enqueued all messages for us, so we just need to redirect back.
          */
         // Save the data in the session.
         $this->app->setUserState('com_config.config.global.data', $data);
         // Redirect back to the edit screen.
         $this->app->redirect(JRoute::_('index.php?option=com_config&view=component&component=' . $option . $redirect, false));
     }
     // Attempt to save the configuration.
     $data = array('params' => $return, 'id' => $id, 'option' => $option);
     try {
         $model->save($data);
     } catch (RuntimeException $e) {
         // Save the data in the session.
         $this->app->setUserState('com_config.config.global.data', $data);
         // Save failed, go back to the screen and display a notice.
         $this->app->enqueueMessage(JText::sprintf('JERROR_SAVE_FAILED', $e->getMessage()), 'error');
         $this->app->redirect(JRoute::_('index.php?option=com_config&view=component&component=' . $option . $redirect, false));
     }
     // Set the redirect based on the task.
     switch ($this->options[3]) {
         case 'apply':
             $this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
             $this->app->redirect(JRoute::_('index.php?option=com_config&view=component&component=' . $option . $redirect, false));
             break;
         case 'save':
         default:
             $redirect = 'index.php?option=' . $option;
             if (!empty($returnUri)) {
                 $redirect = base64_decode($returnUri);
             }
             $this->app->redirect(JRoute::_($redirect, false));
             break;
     }
     return true;
 }
Beispiel #14
0
 /**
  * Method to handle cancel
  *
  * @return  boolean  True on success.
  *
  * @since   3.2
  */
 public function execute()
 {
     // Redirect back to home(base) page
     $this->app->redirect(JUri::base());
 }
Beispiel #15
0
 /**
  * Method to save global configuration.
  *
  * @return  mixed  Calls $app->redirect() for all cases except JSON
  *
  * @since   3.2
  */
 public function execute()
 {
     // Check for request forgeries.
     if (!JSession::checkToken()) {
         $this->app->enqueueMessage(JText::_('JINVALID_TOKEN'));
         $this->app->redirect('index.php');
     }
     // Check if the user is authorized to do this.
     if (!JFactory::getUser()->authorise('core.admin')) {
         $this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
         $this->app->redirect('index.php');
     }
     // Set FTP credentials, if given.
     JClientHelper::setCredentialsFromRequest('ftp');
     $model = new ConfigModelApplication();
     $data = $this->input->post->get('jform', array(), 'array');
     // Complete data array if needed
     $oldData = $model->getData();
     $data = array_replace($oldData, $data);
     // Get request type
     $saveFormat = JFactory::getDocument()->getType();
     // Handle service requests
     if ($saveFormat == 'json') {
         return $model->save($data);
     }
     // Must load after serving service-requests
     $form = $model->getForm();
     // Validate the posted data.
     $return = $model->validate($form, $data);
     // Check for validation errors.
     if ($return === false) {
         /*
          * The validate method enqueued all messages for us, so we just need to redirect back.
          */
         // Save the data in the session.
         $this->app->setUserState('com_config.config.global.data', $data);
         // Redirect back to the edit screen.
         $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.application', false));
     }
     // Attempt to save the configuration.
     $data = $return;
     $return = $model->save($data);
     // Check the return value.
     if ($return === false) {
         /*
          * The save method enqueued all messages for us, so we just need to redirect back.
          */
         // Save the data in the session.
         $this->app->setUserState('com_config.config.global.data', $data);
         // Save failed, go back to the screen and display a notice.
         $this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.application', false));
     }
     // Set the success message.
     $this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
     // Set the redirect based on the task.
     switch ($this->options[3]) {
         case 'apply':
             $this->app->redirect(JRoute::_('index.php?option=com_config', false));
             break;
         case 'save':
         default:
             $this->app->redirect(JRoute::_('index.php', false));
             break;
     }
 }
Beispiel #16
0
 /**
  * Add parse rule to router.
  *
  * @param   JRouter  &$router  JRouter object.
  * @param   JUri     &$uri     JUri object.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function parseRule(&$router, &$uri)
 {
     // Did we find the current and existing language yet?
     $found = false;
     // Are we in SEF mode or not?
     if ($this->mode_sef) {
         $path = $uri->getPath();
         $parts = explode('/', $path);
         $sef = $parts[0];
         // If the default prefix should be removed and the SEF prefix is not among those
         // that we have in our system, its the default language and we "found" the right language
         if ($this->params->get('remove_default_prefix', 0) && !isset($this->sefs[$sef])) {
             $found = true;
             $lang_code = JComponentHelper::getParams('com_languages')->get('site', 'en-GB');
         } else {
             // If the language prefix should always be present or it is indeed , we can now look it up in our array
             if (isset($this->sefs[$sef])) {
                 // We found our language
                 $found = true;
                 $lang_code = $this->sefs[$sef]->lang_code;
             }
             // If we found our language, but its the default language and we don't want a prefix for that, we are on a wrong URL
             if ($this->params->get('remove_default_prefix', 0) && $lang_code == JComponentHelper::getParams('com_languages')->get('site', 'en-GB')) {
                 $found = false;
                 array_shift($parts);
                 $path = implode('/', $parts);
             }
             // We have found our language and the first part of our URL is the language prefix
             if ($found) {
                 array_shift($parts);
                 $uri->setPath(implode('/', $parts));
             }
         }
     } else {
         // We are not in SEF mode
         $lang = $uri->getVar('lang');
         if (isset($this->sefs[$lang])) {
             // We found our language
             $found = true;
             $lang_code = $this->sefs[$lang]->lang_code;
         }
     }
     // We are called via POST. We don't care about the language
     // and simply set the default language as our current language.
     if ($this->app->input->getMethod() == "POST" || count($this->app->input->post) > 0 || count($this->app->input->files) > 0) {
         $found = true;
         $lang_code = $this->app->input->cookie->getString(JApplicationHelper::getHash('language'));
         if ($this->params->get('detect_browser', 1) && !$lang_code) {
             $lang_code = JLanguageHelper::detectLanguage();
         }
         if (!isset($this->lang_codes[$lang_code])) {
             $lang_code = JComponentHelper::getParams('com_languages')->get('site', 'en-GB');
         }
     }
     // We have not found the language and thus need to redirect
     if (!$found) {
         // Lets find the default language for this user
         if (!isset($lang_code) || !isset($this->lang_codes[$lang_code])) {
             $lang_code = false;
             if ($this->params->get('detect_browser', 1)) {
                 $lang_code = JLanguageHelper::detectLanguage();
                 if (!isset($this->lang_codes[$lang_code])) {
                     $lang_code = false;
                 }
             }
             if (!$lang_code) {
                 $lang_code = JComponentHelper::getParams('com_languages')->get('site', 'en-GB');
             }
             // Either we detected the language via the browser or we got it from the cookie. In worst case
             // we fall back to the application setting
             $lang_code = $this->app->input->cookie->getString(JApplicationHelper::getHash('language'), $lang_code);
         }
         if ($this->mode_sef) {
             // Use the current language sef or the default one.
             if (!$this->params->get('remove_default_prefix', 0) || $lang_code != JComponentHelper::getParams('com_languages')->get('site', 'en-GB')) {
                 $path = $this->lang_codes[$lang_code]->sef . '/' . $path;
             }
             $uri->setPath($path);
             if (!$this->app->get('sef_rewrite')) {
                 $uri->setPath('index.php/' . $uri->getPath());
             }
             $this->app->redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment')));
         } else {
             $uri->setVar('lang', $this->lang_codes[$lang_code]->sef);
             $this->app->redirect($uri->base() . 'index.php?' . $uri->getQuery());
         }
     }
     // We have found our language and now need to set the cookie and the language value in our system
     $array = array('lang' => $lang_code);
     $this->default_lang = $lang_code;
     // Set the request var.
     $this->app->input->set('language', $lang_code);
     $this->app->set('language', $lang_code);
     $language = JFactory::getLanguage();
     if ($language->getTag() != $lang_code) {
         $newLang = JLanguage::getInstance($lang_code);
         foreach ($language->getPaths() as $extension => $files) {
             $newLang->load($extension);
         }
         JFactory::$language = $newLang;
         $this->app->loadLanguage($newLang);
     }
     // Create a cookie.
     if ($this->app->input->cookie->getString(JApplicationHelper::getHash('language')) != $lang_code) {
         $cookie_domain = $this->app->get('cookie_domain');
         $cookie_path = $this->app->get('cookie_path', $uri->base(true));
         $this->app->input->cookie->set(JApplicationHelper::getHash('language'), $lang_code, $this->getLangCookieTime(), $cookie_path, $cookie_domain);
     }
     return $array;
 }
Beispiel #17
0
 /**
  * Ajax get record specified by row id
  *
  * @param   string  $mode  mode
  *
  * @return  string  json encoded row
  */
 public function xRecord($mode = 'table')
 {
     $input = $this->app->input;
     $package = $this->app->getUserState('com_fabrik.package', 'fabrik');
     $fabrikDb = $this->getDb();
     $cursor = $input->getInt('cursor', 1);
     $this->outputFormat = 'json';
     $nav = $this->getPagination(1, $cursor, 1);
     if ($mode == 'table') {
         $query = $this->buildQuery();
         $this->setBigSelects();
         $fabrikDb->setQuery($query, $this->limitStart, $this->limitLength);
         $data = $fabrikDb->loadObjectList();
     } else {
         // Get the row id
         $table = $this->getTable();
         $query = $fabrikDb->getQuery(true);
         $query->select($table->db_primary_key)->from($table->db_table_name);
         $query = $this->buildQueryJoin($query);
         $query = $this->buildQueryOrder($query);
         $fabrikDb->setQuery($query, $nav->limitstart, $nav->limit);
         $rowId = $fabrikDb->loadResult();
         $input->set('rowid', $rowId);
         $formId = $input->getInt('formid');
         $this->app->redirect('index.php?option=' . $package . '&view=form&formid=' . $formId . '&rowid=' . $rowId . '&format=raw');
     }
     return json_encode($data);
 }
Beispiel #18
0
 /**
  * Add parse rule to router.
  *
  * @param   JRouter  &$router  JRouter object.
  * @param   JUri     &$uri     JUri object.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function parseRule(&$router, &$uri)
 {
     // Did we find the current and existing language yet?
     $found = false;
     $lang_code = false;
     // Are we in SEF mode or not?
     if ($this->mode_sef) {
         $path = $uri->getPath();
         $parts = explode('/', $path);
         $sef = $parts[0];
         // Do we have a URL Language Code ?
         if (!isset($this->sefs[$sef])) {
             // Check if remove default url language code is set
             if ($this->params->get('remove_default_prefix', 0)) {
                 if ($parts[0]) {
                     // We load a default site language page
                     $lang_code = $this->default_lang;
                 } else {
                     // We check for an existing language cookie
                     $lang_code = $this->getLanguageCookie();
                 }
             } else {
                 $lang_code = $this->getLanguageCookie();
             }
             // No language code. Try using browser settings or default site language
             if (!$lang_code && $this->params->get('detect_browser', 0) == 1) {
                 $lang_code = JLanguageHelper::detectLanguage();
             }
             if (!$lang_code) {
                 $lang_code = $this->default_lang;
             }
             if ($this->params->get('remove_default_prefix', 0) && $lang_code == $this->default_lang) {
                 $found = true;
             }
         } else {
             // We found our language
             $found = true;
             $lang_code = $this->sefs[$sef]->lang_code;
             // If we found our language, but its the default language and we don't want a prefix for that, we are on a wrong URL.
             // Or we try to change the language back to the default language. We need a redirect to the proper URL for the default language.
             if ($this->params->get('remove_default_prefix', 0) && $lang_code == $this->default_lang) {
                 // Create a cookie.
                 $this->setLanguageCookie($lang_code);
                 $found = false;
                 array_shift($parts);
                 $path = implode('/', $parts);
             }
             // We have found our language and the first part of our URL is the language prefix
             if ($found) {
                 array_shift($parts);
                 $uri->setPath(implode('/', $parts));
             }
         }
     } else {
         $lang_code = $this->getLanguageCookie();
         if ($this->params->get('detect_browser', 1) && !$lang_code) {
             $lang_code = JLanguageHelper::detectLanguage();
         }
         if (!isset($this->lang_codes[$lang_code])) {
             $lang_code = $this->default_lang;
         }
     }
     $lang = $uri->getVar('lang', $lang_code);
     if (isset($this->sefs[$lang])) {
         // We found our language
         $found = true;
         $lang_code = $this->sefs[$lang]->lang_code;
     }
     // We are called via POST. We don't care about the language
     // and simply set the default language as our current language.
     if ($this->app->input->getMethod() == "POST" || count($this->app->input->post) > 0 || count($this->app->input->files) > 0) {
         $found = true;
         if (!isset($lang_code)) {
             $lang_code = $this->getLanguageCookie();
         }
         if ($this->params->get('detect_browser', 1) && !$lang_code) {
             $lang_code = JLanguageHelper::detectLanguage();
         }
         if (!isset($this->lang_codes[$lang_code])) {
             $lang_code = $this->default_lang;
         }
     }
     // We have not found the language and thus need to redirect
     if (!$found) {
         // Lets find the default language for this user
         if (!isset($lang_code) || !isset($this->lang_codes[$lang_code])) {
             $lang_code = false;
             if ($this->params->get('detect_browser', 1)) {
                 $lang_code = JLanguageHelper::detectLanguage();
                 if (!isset($this->lang_codes[$lang_code])) {
                     $lang_code = false;
                 }
             }
             if (!$lang_code) {
                 $lang_code = $this->default_lang;
             }
         }
         if ($this->mode_sef) {
             // Use the current language sef or the default one.
             if (!$this->params->get('remove_default_prefix', 0) || $lang_code != $this->default_lang) {
                 $path = $this->lang_codes[$lang_code]->sef . '/' . $path;
             }
             $uri->setPath($path);
             if (!$this->app->get('sef_rewrite')) {
                 $uri->setPath('index.php/' . $uri->getPath());
             }
             $this->app->redirect($uri->base() . $uri->toString(array('path', 'query', 'fragment')), 301);
         } else {
             $uri->setVar('lang', $this->lang_codes[$lang_code]->sef);
             $this->app->redirect($uri->base() . 'index.php?' . $uri->getQuery(), 301);
         }
     }
     // We have found our language and now need to set the cookie and the language value in our system
     $array = array('lang' => $lang_code);
     $this->current_lang = $lang_code;
     // Set the request var.
     $this->app->input->set('language', $lang_code);
     $this->app->set('language', $lang_code);
     $language = JFactory::getLanguage();
     if ($language->getTag() != $lang_code) {
         $newLang = JLanguage::getInstance($lang_code);
         foreach ($language->getPaths() as $extension => $files) {
             $newLang->load($extension);
         }
         JFactory::$language = $newLang;
         $this->app->loadLanguage($newLang);
     }
     // Create a cookie.
     if ($this->getLanguageCookie() != $lang_code) {
         $this->setLanguageCookie($lang_code);
     }
     return $array;
 }
Beispiel #19
0
 /**
  * Add parse rule to router.
  *
  * @param   JRouter  &$router  JRouter object.
  * @param   JUri     &$uri     JUri object.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function parseRule(&$router, &$uri)
 {
     // Did we find the current and existing language yet?
     $found = false;
     $lang_code = false;
     // Are we in SEF mode or not?
     if ($this->mode_sef) {
         $path = $uri->getPath();
         $parts = explode('/', $path);
         $sef = $parts[0];
         // Do we have a URL Language Code ?
         if (!isset($this->sefs[$sef])) {
             // Check if remove default url language code is set
             if ($this->params->get('remove_default_prefix', 0)) {
                 if ($parts[0]) {
                     // We load a default site language page
                     $lang_code = $this->default_lang;
                 } else {
                     // We check for an existing language cookie
                     $lang_code = $this->getLanguageCookie();
                 }
             } else {
                 $lang_code = $this->getLanguageCookie();
             }
             // No language code. Try using browser settings or default site language
             if (!$lang_code && $this->params->get('detect_browser', 0) == 1) {
                 $lang_code = JLanguageHelper::detectLanguage();
             }
             if (!$lang_code) {
                 $lang_code = $this->default_lang;
             }
             if ($this->params->get('remove_default_prefix', 0) && $lang_code == $this->default_lang) {
                 $found = true;
             }
         } else {
             // We found our language
             $found = true;
             $lang_code = $this->sefs[$sef]->lang_code;
             // If we found our language, but its the default language and we don't want a prefix for that, we are on a wrong URL.
             // Or we try to change the language back to the default language. We need a redirect to the proper URL for the default language.
             if ($this->params->get('remove_default_prefix', 0) && $lang_code == $this->default_lang) {
                 // Create a cookie.
                 $this->setLanguageCookie($lang_code);
                 $found = false;
                 array_shift($parts);
                 $path = implode('/', $parts);
             }
             // We have found our language and the first part of our URL is the language prefix
             if ($found) {
                 array_shift($parts);
                 $uri->setPath(implode('/', $parts));
             }
         }
     } else {
         $lang_code = $this->getLanguageCookie();
         if ($this->params->get('detect_browser', 1) && !$lang_code) {
             $lang_code = JLanguageHelper::detectLanguage();
         }
         if (!isset($this->lang_codes[$lang_code])) {
             $lang_code = $this->default_lang;
         }
     }
     $lang = $uri->getVar('lang', $lang_code);
     if (isset($this->sefs[$lang])) {
         // We found our language
         $found = true;
         $lang_code = $this->sefs[$lang]->lang_code;
     }
     // We are called via POST. We don't care about the language
     // and simply set the default language as our current language.
     if ($this->app->input->getMethod() == "POST" || count($this->app->input->post) > 0 || count($this->app->input->files) > 0) {
         $found = true;
         if (!isset($lang_code)) {
             $lang_code = $this->getLanguageCookie();
         }
         if ($this->params->get('detect_browser', 1) && !$lang_code) {
             $lang_code = JLanguageHelper::detectLanguage();
         }
         if (!isset($this->lang_codes[$lang_code])) {
             $lang_code = $this->default_lang;
         }
     }
     // We have not found the language and thus need to redirect
     if (!$found) {
         // Lets find the default language for this user
         if (!isset($lang_code) || !isset($this->lang_codes[$lang_code])) {
             $lang_code = false;
             if ($this->params->get('detect_browser', 1)) {
                 $lang_code = JLanguageHelper::detectLanguage();
                 if (!isset($this->lang_codes[$lang_code])) {
                     $lang_code = false;
                 }
             }
             if (!$lang_code) {
                 $lang_code = $this->default_lang;
             }
         }
         if ($this->mode_sef) {
             // Use the current language sef or the default one.
             if (!$this->params->get('remove_default_prefix', 0) || $lang_code != $this->default_lang) {
                 $path = $this->lang_codes[$lang_code]->sef . '/' . $path;
             }
             $uri->setPath($path);
             if (!$this->app->get('sef_rewrite')) {
                 $uri->setPath('index.php/' . $uri->getPath());
             }
             $redirectUri = $uri->base() . $uri->toString(array('path', 'query', 'fragment'));
         } else {
             $uri->setVar('lang', $this->lang_codes[$lang_code]->sef);
             $redirectUri = $uri->base() . 'index.php?' . $uri->getQuery();
         }
         // Set redirect HTTP code to "302 Found".
         $redirectHttpCode = 302;
         // If selected language is the default language redirect code is "301 Moved Permanently".
         if ($lang_code === $this->default_lang) {
             $redirectHttpCode = 301;
             // We cannot cache this redirect in browser. 301 is cachable by default so we need to force to not cache it in browsers.
             $this->app->setHeader('Expires', 'Wed, 17 Aug 2005 00:00:00 GMT', true);
             $this->app->setHeader('Last-Modified', gmdate('D, d M Y H:i:s') . ' GMT', true);
             $this->app->setHeader('Cache-Control', 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false);
             $this->app->setHeader('Pragma', 'no-cache');
             $this->app->sendHeaders();
         }
         // Redirect to language.
         $this->app->redirect($redirectUri, $redirectHttpCode);
     }
     // We have found our language and now need to set the cookie and the language value in our system
     $array = array('lang' => $lang_code);
     $this->current_lang = $lang_code;
     // Set the request var.
     $this->app->input->set('language', $lang_code);
     $this->app->set('language', $lang_code);
     $language = JFactory::getLanguage();
     if ($language->getTag() != $lang_code) {
         $newLang = JLanguage::getInstance($lang_code);
         foreach ($language->getPaths() as $extension => $files) {
             $newLang->load($extension);
         }
         JFactory::$language = $newLang;
         $this->app->loadLanguage($newLang);
     }
     // Create a cookie.
     if ($this->getLanguageCookie() != $lang_code) {
         $this->setLanguageCookie($lang_code);
     }
     return $array;
 }