Compatibility with MSSTI Quick Language

The phpbb SEO Website Forum : How to use this Site, Moderations Rules, Guidelines and Suggestions.

Moderator: Moderators

Compatibility with MSSTI Quick Language

Postby Leinad4Mind » Thu Nov 15, 2012 11:12 pm

Hi there, I've MSSTI Quick Language 1.0.2-PL1 Installed, in phpBB SEO 3.0.11 premod version and I am on this url:

/your-first-forum/topic7.html

And if I change the language, the url becomes like this:

/.%2Fviewtopic.php%3Fforum_uri%3Dyour-first-forum%26t%3D7%26start%3D

How can I fix that problem between them?

The phpbb SEO 3.0.11 works like a charm, and its well configured (I think so)

The only problem I've is when I change the language... because I think that the quick language cant parse the new url as it should be.
If Im on the root, it works great...

And I had already this on functions_quick_language:
Code: Select all
            // Fix for www.phpBB-SEO.com SEO TOOLKIT - Start
            if (class_exists('phpbb_seo'))
            {
               $quick_language_url       = (!empty($_SERVER['HTTP_REFERER'])) ? trim($_SERVER['HTTP_REFERER']) : trim(getenv('HTTP_REFERER'));
               $quick_language_redirect = (!$user->page['page']) ? $quick_language_url : '&quick_language_redirect=' . urlencode(str_replace('&', '&', $phpbb_root_path . $user->page['page']));
               $quick_language_action    = $phpbb_root_path . "ucp." . $phpEx . "?i=prefs&mode=personal" . $quick_language_redirect;
            }
            else
            {
               $quick_language_redirect = ($user->page['page_dir']) ? '' : '&quick_language_redirect=' . urlencode(str_replace('&', '&', build_url(array('_f_', 'quick_language'))));
               $quick_language_action    = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=prefs&mode=personal' . $quick_language_redirect);
            }
            // Fix for www.phpBB-SEO.com SEO TOOLKIT - End


ALL FILE:
Code: Select all
<?php
/**
* @package: phpBB 3.0.7-PL1 :: MSSTI Quick Language -> root/includes/
* @version: $Id: function_quick_language.php, v 1.0.2-PL1 2010/04/30 10:04:30 leviatan21 Exp $
* @copyright: leviatan21 < info@mssti.com > (Gabriel) http://www.mssti.com/phpbb3/
* @license: http://opensource.org/licenses/gpl-license.php GNU Public License
* @author: leviatan21 - http://www.phpbb.com/community/memberlist.php?mode=viewprofile&u=345763
*
**/

/**
* @ignore
**/
if (!defined('IN_PHPBB'))
{
   exit;
}

$quick_language = new quick_language();

global $quick_language;

/**
* Class
**/
class quick_language
{
   /**
   * Constructor
   **/
   function quick_language()
   {
      define('IN_QUICK_LANGUAGE', true);

      /**
      * Options
      **/
      define('QUICK_LANGUAGE_ENABLED',   true);   // Enable this MOD ? Default true
      define('QUICK_LANGUAGE_GUEST',      true);   // Allow guests to switch language ? Default true
      define('QUICK_LANGUAGE_USER',      true);   // Allow registered users to switch language ? Default true
      define('QUICK_LANGUAGE_FORCE',      true);   // force guests and users to switch to the forum language ? Default true
   }

   /**
   * Pick a language, any available language ...
   * Called from : root/includes/function.php
   *
   * @param string      $quick_lang      the user language
   * @return srting   $quick_lang      the new language
   **/
   function quick_language_select($quick_lang)
   {
      global $user;

      $quick_language_guest   = (QUICK_LANGUAGE_GUEST && $user->data['user_id'] == ANONYMOUS) ? 1 : 0;
      $quick_language_user   = (QUICK_LANGUAGE_USER  && $user->data['user_id'] != ANONYMOUS) ? 1 : 0;

      /**
      * Description :
      *   Don't continue :
      *      If the mod is disabled
      *      Or if the mod is disabled for guest and you're ono of them
      *      Or if the mod is disabled for users and you're ono of them
      **/
      if (QUICK_LANGUAGE_ENABLED && ($quick_language_guest || $quick_language_user))
      {
         // Get and set the selected language
         $quick_language_temp = quick_language::quick_language_switch($quick_lang);

         // Build the dropdown
         $quick_language_options = language_select($quick_language_temp);

         if (substr_count($quick_language_options, '<option') > 1)
         {
            global $template, $phpbb_root_path, $phpEx;

            // Fix for www.phpBB-SEO.com SEO TOOLKIT - Start
            if (class_exists('phpbb_seo'))
            {
               $quick_language_url       = (!empty($_SERVER['HTTP_REFERER'])) ? trim($_SERVER['HTTP_REFERER']) : trim(getenv('HTTP_REFERER'));
               $quick_language_redirect = (!$user->page['page']) ? $quick_language_url : '&amp;quick_language_redirect=' . urlencode(str_replace('&amp;', '&', $phpbb_root_path . $user->page['page']));
               $quick_language_action    = $phpbb_root_path . "ucp." . $phpEx . "?i=prefs&amp;mode=personal" . $quick_language_redirect;
            }
            else
            {
               $quick_language_redirect = ($user->page['page_dir']) ? '' : '&amp;quick_language_redirect=' . urlencode(str_replace('&amp;', '&', build_url(array('_f_', 'quick_language'))));
               $quick_language_action    = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=prefs&amp;mode=personal' . $quick_language_redirect);
            }
            // Fix for www.phpBB-SEO.com SEO TOOLKIT - End

            $template->assign_vars(array(
               'S_QUICK_LANGUAGE'      => QUICK_LANGUAGE_ENABLED,
               'L_QUICK_LANGUAGE'      => (isset($user->lang['QUICK_LANGUAGE'])) ? $user->lang['QUICK_LANGUAGE'] : 'Language',
               'S_QUICK_LANG_ACTION'   => $quick_language_action,
               'S_QUICK_LANG_OPTIONS'   => $quick_language_options,
            ));
         }
      }

      return $quick_lang;
   }

   /**
   * Get and set the selected language
   * Called from : root/ucp.php
   **/
   function quick_language_switch(&$quick_language_temp)
   {
      global $user;

      $quick_language_guest   = (QUICK_LANGUAGE_GUEST && $user->data['user_id'] == ANONYMOUS) ? 1 : 0;
      $quick_language_user   = (QUICK_LANGUAGE_USER  && $user->data['user_id'] != ANONYMOUS) ? 1 : 0;
      $quick_lang            = basename(request_var('quick_language', $quick_language_temp));
      $ucp_lang            = basename(request_var('lang', ''));

      /**
      * Description :
      *   Don't continue :
      *      If the mod is disabled
      *      Or if the mod is disabled for guest and you're ono of them
      *      Or if the mod is disabled for users and you're ono of them
      *      Or there are no selected language
      **/
      if (QUICK_LANGUAGE_ENABLED && ($quick_language_guest || $quick_language_user))
      {
         global $db, $phpbb_root_path, $phpEx;

         if ($quick_language_user)
         {
            // Adjust the language if the user change it from the UCP Dropdown
            $quick_lang = ($ucp_lang) ? $ucp_lang : $quick_lang;
            $sql = 'UPDATE ' . USERS_TABLE . ' SET user_lang = "' . $db->sql_escape($quick_lang) . '" WHERE user_id = ' . $user->data['user_id'];
            $db->sql_query($sql);
         }
         else
         {
            // Save the value into a cookie
            $user->set_cookie('quick_language', $quick_lang, 0);
         }

         if ($quick_language_redirect = request_var('quick_language_redirect', ''))
         {
            redirect($quick_language_redirect);
         }
      }
      return $quick_lang;
   }

   /**
   * Read and/or update the actual language
   * Called from : root/includes/session.php
   *
   * @param string      $quick_lang      the user language
   * @param int      $user_id      the user id
   * @param string      $cookie_name   the name of the cookie
   * @return srting   $quick_lang      the new language
   **/
   function quick_language_setlang(&$user)
   {
      global $config, $phpEx;

      $quick_language_guest   = (QUICK_LANGUAGE_GUEST && $user->data['user_id'] == ANONYMOUS) ? 1 : 0;
      $quick_language_user   = (QUICK_LANGUAGE_USER  && $user->data['user_id'] != ANONYMOUS) ? 1 : 0;
      $quick_lang            = $user->lang_name;

      /**
      * Description :
      *   Don't continue :
      *      If the mod is disabled
      *      Or if the mod is disabled for guest and you're one of them
      *      Or if the mod is disabled for users and you're one of them
      **/
      if (QUICK_LANGUAGE_ENABLED && ($quick_language_guest || $quick_language_user || QUICK_LANGUAGE_FORCE))
      {
         if ($quick_language_guest)
         {
            // Read the value from the cookie and eventually update
            $quick_lang = basename(request_var($config['cookie_name'] . '_quick_language', $quick_lang, false, true));
         }

         // Look if the we need to force the language
         if (QUICK_LANGUAGE_FORCE)
         {
            // Find the forum language settings and eventually update
            $quick_lang = quick_language::quick_language_forum($quick_lang);
         }

         // Check if the language still available
         $quick_lang = (@file_exists($user->lang_path . $quick_lang . "/common.$phpEx")) ? $quick_lang : basename($config['default_lang']);
      }

      return $quick_lang;
   }

   /**
   * Description :
   *   Get the forum language value from the database
   *   As this mod can be installed after all forum was defined,
   *   we not always got a value, so check for it and eventually update
   *
   * Called from : quick_language_setlang()
   *
   * @param string      $quick_lang   a default language value
   * @return string   $quick_lang an updated language value
   **/
   function quick_language_forum($quick_lang)
   {
      global $db;

      // Get some values
      $ql_forum_id = request_var('f', 0);
      $ql_topic_id = request_var('t', 0);
      $ql_post_id    = request_var('p', 0);

      /**
      * Description :
      * Not always got id's, we can be in index, ucp or another place )
      *   Don't continue
      *      If there are no forum id
      *      Or if there are no topic id
      *      Or if there are no post id
      **/
      if ($ql_forum_id || $ql_topic_id || $ql_post_id)
      {
         /**
         * If there are no forum_id or no topic_id, but have a post_id, get for it forum_id
         * for pages like viewtopic.php?p=n#pn
         **/
         if ($ql_post_id && (!$ql_forum_id || !$ql_topic_id ))
         {
            $sql = 'SELECT forum_id
               FROM ' . POSTS_TABLE . "
               WHERE post_id = $ql_post_id";
            $result = $db->sql_query_limit($sql, 1);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            $ql_forum_id = $row['forum_id'];
         }

         /**
         * If there are no forum_id or no post_id, but have a topic_id, get for it forum_id
         * for pages like viewtopic.php?t=n
         **/
         if ($ql_topic_id && (!$ql_forum_id || !$ql_post_id ))
         {
            $sql = 'SELECT forum_id
               FROM ' . TOPICS_TABLE . "
               WHERE topic_id = $ql_topic_id";
            $result = $db->sql_query_limit($sql, 1);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            $ql_forum_id = $row['forum_id'];
         }

         /**
         * Once we have a value for the forum_id, look at the language
         **/
         if ($ql_forum_id)
         {
            $sql = 'SELECT forum_lang
               FROM ' . FORUMS_TABLE . "
               WHERE forum_id = $ql_forum_id";
            $result = $db->sql_query_limit($sql, 1);
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);

            // Check if this forum was set up with some language, update it
            if ($row['forum_lang'] != '')
            {
               $quick_lang = $row['forum_lang'];
            }
         }
      }
      return $quick_lang;
   }
}
// End class

?>


Thanks

PS: For now I will use:

Code: Select all
<!-- IF SCRIPT_NAME eq index --><!-- IF not S_IS_BOT and S_QUICK_LANGUAGE --><!-- INCLUDE ucp_quick_language.html --><!-- ENDIF --><!-- ENDIF -->


Because it works well on index. But I hope someone can make a fix for it ^^ Cheers!
Leinad4Mind
 
Posts: 3
Joined: Thu Jan 26, 2012 3:23 pm

Advertisement

Return to The phpBB SEO Website

 


  • Related topics
    Replies
    Views
    Last post

Who is online

Users browsing this forum: No registered users and 4 guests