Page 1 of 2

international alias plugin - problem polish letters

Posted: 02 Oct 2009, 11:39
by jacek_arwal
Something is incorrect with this plugin ( or maybe my page ? ) with polish letters. I made a title : ąćęłńóżź and I received alias : aeo .

Please check it

Re: international alias plugin - problem polish letters

Posted: 05 Oct 2009, 16:51
by Jan
Hi, is the plugin installed and ENABLED? do you use php5?

Re: international alias plugin - problem polish letters

Posted: 07 Oct 2009, 15:23
by jacek_arwal
Yes , it installed and enabled , yes I am using php5 .

Re: international alias plugin - problem polish letters

Posted: 07 Oct 2009, 18:24
by Jan
No idea what can be wrong there :-(, this is the polish function in this addon:

Code: Select all

// POLISH
        if ($plLang == 1) {
            $plLangFrom     = array('ą','ć','ę','ł','ń','ó','ś','ź','ż','Ą','Ć','Ę','Ł','Ń','Ó','Ś','Ź','Ż');
            $plLangTo         = array('a','c','e','l','n','o','s','z','z','a','c','e','l','n','o','s','z','z');
            $langFrom        = array_merge ($langFrom, $plLangFrom);
            $langTo            = array_merge ($langTo, $plLangTo);
        } 
Did you save the article after you have enabled the plugin, did you save the article while the alias input field was empty?

Re: international alias plugin - problem polish letters

Posted: 09 Oct 2009, 12:24
by jacek_arwal
The code looks OK, so I don't know what's the problem.
I checked some other languages and here are results

Croatian
title : čćđšž
plugin enabled alias : csz
plugin diabled alias : 2009-10-09-10-09-56

Czech
title : áčďéěíňóřšťúůýž
plugin enabled alias : aceiosuyz
plugin disabled alias : aeiouy

Polish :
title : ąćęłńóżź
plugin enabled alias : aeo
plugin disabled alias : o

plugin settings : all languages allowed ( I tried also with only polish allowed )

I tried always with alias field empty.

Re: international alias plugin - problem polish letters

Posted: 11 Oct 2009, 22:00
by Jan
:( seems like is other problem on the site. Maybe the plugin works not correctly (seems like it is not enabled or the functionality is somehow ignored :idea: )

Jan

Re: international alias plugin - problem polish letters

Posted: 12 Oct 2009, 17:48
by jacek_arwal
I checked your plugin on 2 sites ( both are hosted on my own own server , maybe here is a problem ) , I tried another plugin , and this plugin works good .

Re: international alias plugin - problem polish letters

Posted: 16 Oct 2009, 23:13
by Jan
Ok

Re: international alias plugin - problem polish letters

Posted: 08 Sep 2010, 00:08
by Jan
Hmmh, really no idea what can be wrong there, this plugin is fact very easy, only replace function, so if the php5 is enabled then there should not be any problem to run it :-( :-(

international alias plugin bug - problem polish, slovak...

Posted: 13 Oct 2010, 00:02
by pitu
Hi,
First problem is that parameter for LITHUANIAN language is missing in phocainternationalalias.xml file:

Code: Select all

<param name="lithuanian-lang" type="radio" default="1" label="Lithuanian" description="Lithuanian Language">
	<option value="1">Yes</option>
	<option value="0">No</option>
</param>
Lithuanian radio button not appears in backend also not storing phocainternationalalias plugin parameter and its value for Lithuanian language ('lithuanian-lang'=value) in database after click on apply/save button ( or after plugin installation) without code above.
This problem fire phocainternationalalias plugin support for Lithuanian language automaticaly in both versions 1.0.0 and 1.0.1.
I think, correct code for phocainternationalalias.xml (version 1.0.1) is:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE install SYSTEM "http://dev.joomla.org/xml/1.5/plugin-install.dtd">
<install type="plugin" group="system" version="1.5.0" method="upgrade" >
    <name>Phoca International Alias Plugin</name>
    <creationDate>04/10/2010</creationDate>
    <author>Jan Pavelka (www.phoca.cz)</author>
    <authorEmail>info@phoca.cz</authorEmail>
    <authorUrl>www.phoca.cz</authorUrl>
    <copyright>Jan Pavelka</copyright>
    <license>GNU/GPL</license>
    <version>1.0.1</version>
    <!-- The description is optional and defaults to the name -->
    <description>Phoca International Alias - creates correct alias from title (Languages: Croatian, Czech, Hungarian, Icelandic, Lithuanian, Polish, Slovak, Slovenian)</description>

    <!-- Main File Copy Section -->
    <files>
        <filename plugin="phocainternationalalias">phocainternationalalias.php</filename>
        <filename plugin="phocainternationalalias">phocainternationalalias.xml</filename>
    </files>
    
    <params>
        
        <param name="croatian-lang" type="radio" default="1" label="Croatian" description="Croatian Language">
            <option value="1">Yes</option>
            <option value="0">No</option>
        </param>
        
        <param name="czech-lang" type="radio" default="1" label="Czech" description="Czech Language">
            <option value="1">Yes</option>
            <option value="0">No</option>
        </param>
        
        <param name="hungarian-lang" type="radio" default="1" label="Hungarian" description="Hungarian Language">
            <option value="1">Yes</option>
            <option value="0">No</option>
        </param>
        
        <param name="icelandic-lang" type="radio" default="1" label="Icelandic" description="Icelandic Language">
            <option value="1">Yes</option>
            <option value="0">No</option>
        </param>

        <param name="lithuanian-lang" type="radio" default="1" label="Lithuanian" description="Lithuanian Language">
            <option value="1">Yes</option>
            <option value="0">No</option>
        </param>
        
        <param name="polish-lang" type="radio" default="1" label="Polish" description="Polish Language">
            <option value="1">Yes</option>
            <option value="0">No</option>
        </param>
        
        <param name="slovak-lang" type="radio" default="1" label="Slovak" description="Slovak Language">
            <option value="1">Yes</option>
            <option value="0">No</option>
        </param>
        
        <param name="slovenian-lang" type="radio" default="1" label="Slovenian" description="Slovenian Language">
            <option value="1">Yes</option>
            <option value="0">No</option>
        </param>
    </params>
</install>
Second problem:
if was set phocainternationalalias plugin support for LITHUANIAN or ICELANDIC language chars in backend, then different conversion's chars for other active phocainternationalalias plugin languages will be always remove (chars are not merged) - rows 162-176, function stringURLSafe($string) in phocainternationalalias.php file (version 1.0.1)

Code: Select all

		// LITHUANIAN
		if ($ltLang == 1) {
			$ltLangFrom 	= array('ą','č','ę','ė','į','š','ų','ū','ž','Ą','Č','Ę','Ė','Į','Š','Ų','Ū','Ž');
			$ltLangTo 		= array('a','c','e','e','i','s','u','u','z','A','C','E','E','I','S','U','U','Z');
			$langFrom		= $ltLangFrom;
			$langTo			= $ltLangTo;
		}
		
		// ICELANDIC		
		if ($isLang == 1) {
			$isLangFrom 	= array('þ', 'æ', 'ð', 'ö', 'í', 'ó', 'é', 'á', 'ý', 'ú', 'Þ', 'Æ', 'Ð', 'Ö', 'Í', 'Ó', 'É', 'Á', 'Ý', 'Ú');
			$isLangTo 		= array('th','ae','d', 'o', 'i', 'o', 'e', 'a', 'y', 'u', 'Th','Ae','D', 'O', 'I', 'O', 'E', 'A', 'Y', 'U');
			$langFrom		= $isLangFrom;
			$langTo			= $isLangTo;
		}
I think, correct code is:

Code: Select all

         // LITHUANIAN
        if ($ltLang == 1) {
            $ltLangFrom     = array('ą','č','ę','ė','į','š','ų','ū','ž','Ą','Č','Ę','Ė','Į','Š','Ų','Ū','Ž');
            $ltLangTo         = array('a','c','e','e','i','s','u','u','z','A','C','E','E','I','S','U','U','Z');
            $langFrom        = array_merge ($langFrom, $ltLangFrom);
            $langTo            = array_merge ($langTo, $ltLangTo);
        }
        
        // ICELANDIC        
        if ($isLang == 1) {
            $isLangFrom     = array('þ', 'æ', 'ð', 'ö', 'í', 'ó', 'é', 'á', 'ý', 'ú', 'Þ', 'Æ', 'Ð', 'Ö', 'Í', 'Ó', 'É', 'Á', 'Ý', 'Ú');
            $isLangTo         = array('th','ae','d', 'o', 'i', 'o', 'e', 'a', 'y', 'u', 'Th','Ae','D', 'O', 'I', 'O', 'E', 'A', 'Y', 'U');
            $langFrom        = array_merge ($langFrom, $isLangFrom);
            $langTo            = array_merge ($langTo, $isLangTo);
        }
Then full code for phocainternationalalias.php (version 1.0.1) is

Code: Select all

<?php
/**
 * @version        $Id:output.php 6961 2007-03-15 16:06:53Z tcp $
 * @package        Joomla.Framework
 * @subpackage    Filter
 * @copyright    Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
 * @copyright    Copyright (C) 2008 Protos Extensions
 * @copyright    Copyright (C) 2008 Phoca ( www.phoca.cz ) 
 * @license        GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant to the
 * GNU General Public License, and as distributed it includes or is derivative
 * of works licensed under the GNU General Public License or other free or open
 * source software licenses. See COPYRIGHT.php for copyright notices and
 * details.
 */
 
/**
 * JFilterOutput
 *
 * @static
 * @package     Joomla.Framework
 * @subpackage    Filter
 * @since        1.5
 */
 
class JFilterOutput
{
    /**
    * Makes an object safe to display in forms
    *
    * Object parameters that are non-string, array, object or start with underscore
    * will be converted
    *
    * @static
    * @param object An object to be parsed
    * @param int The optional quote style for the htmlspecialchars function
    * @param string|array An optional single field name or array of field names not
    *                     to be parsed (eg, for a textarea)
    * @since 1.5
    */
    
    function objectHTMLSafe( &$mixed, $quote_style=ENT_QUOTES, $exclude_keys='' )
    {
        if (is_object( $mixed ))
        {
            foreach (get_object_vars( $mixed ) as $k => $v)
            {
                if (is_array( $v ) || is_object( $v ) || $v == NULL || substr( $k, 1, 1 ) == '_' ) {
                    continue;
                }

                if (is_string( $exclude_keys ) && $k == $exclude_keys) {
                    continue;
                } else if (is_array( $exclude_keys ) && in_array( $k, $exclude_keys )) {
                    continue;
                }

                $mixed->$k = htmlspecialchars( $v, $quote_style, 'UTF-8' );
            }
        }
    }

    /**
     * This method processes a string and replaces all instances of & with & in links only
     *
     * @static
     * @param    string    $input    String to process
     * @return    string    Processed string
     * @since    1.5
     */
    function linkXHTMLSafe($input)
    {
        $regex = 'href="([^"]*(&(amp;){0})[^"]*)*?"';
        return preg_replace_callback( "#$regex#i", array('JFilterOutput', '_ampReplaceCallback'), $input );
    }

    /**
     * This method processes a string and replaces all accented UTF-8 characters by unaccented
     * ASCII-7 "equivalents", whitespaces are replaced by hyphens and the string is lowercased.
     *
     * @static
     * @param    string    $input    String to process
     * @return    string    Processed string
     * @since    1.5
     */
    function stringURLSafe($string)
    {
    
        
        
    /**
    * Jan: the czech version use the same code as bulgarian from Ivo but with different characters    
    * iapostolov: Now let's start overwriting the core class for alias replacing
    * Joomla! 1.5 checks if a class is already loaded so we can load the whole class and overwrite it :)
    */
        
    //    jimport('joomla.plugin.helper');
        $plugin = JPluginHelper::getPlugin('system','phocainternationalalias');
        
        $paramsP    = new JParameter( $plugin->params );
        $hrLang        = $paramsP->get( 'croatian-lang',1);
        $czLang        = $paramsP->get( 'czech-lang',1);
        $huLang        = $paramsP->get( 'hungarian-lang',1);
        $plLang        = $paramsP->get( 'polish-lang',1);
        $skLang        = $paramsP->get( 'slovak-lang',1);
        $slLang        = $paramsP->get( 'slovenian-lang',1);
        $ltLang        = $paramsP->get( 'lithuanian-lang',1);
        $isLang        = $paramsP->get( 'icelandic-lang',1);
        $langFrom    = array();
        $langTo        = array();
        
        
        // CZECH
        if ($czLang == 1) {
            $czLangFrom     = array('á','č','ď','é','ě','í','ň','ó','ř','š','ť','ú','ů','ý','ž','Á','Č','Ď','É','Ě','Í','Ň','Ó','Ř','Š','Ť','Ú','Ů','Ý','Ž');
            $czLangTo         = array('a','c','d','e','e','i','n','o','r','s','t','u','u','y','z','a','c','d','e','e','i','ň','o','r','s','t','u','u','y','z');
            $langFrom        = $czLangFrom;
            $langTo            = $czLangTo;
        }
        
        // CROATIAN
        if ($hrLang == 1) {
            $hrLangFrom     = array('č','ć','đ','š','ž','Č','Ć','Đ','Š','Ž');
            $hrLangTo         = array('c','c','d','s','z','c','c','d','s','z');
            $langFrom        = array_merge ($langFrom, $hrLangFrom);
            $langTo            = array_merge ($langTo, $hrLangTo);
        }
        
        // HUNGARIAN
        if ($huLang == 1) {
            $huLangFrom     = array('á','é','ë','í','ó','ö','ő','ú','ü','ű','Á','É','Ë','Í','Ó','Ö','Ő','Ú','Ü','Ű');
            $huLangTo         = array('a','e','e','i','o','o','o','u','u','u','a','e','e','i','o','o','o','u','u','u');
            $langFrom        = array_merge ($langFrom, $huLangFrom);
            $langTo            = array_merge ($langTo, $huLangTo);
        }
        
        
        // POLISH
        if ($plLang == 1) {
            $plLangFrom     = array('ą','ć','ę','ł','ń','ó','ś','ź','ż','Ą','Ć','Ę','Ł','Ń','Ó','Ś','Ź','Ż');
            $plLangTo         = array('a','c','e','l','n','o','s','z','z','a','c','e','l','n','o','s','z','z');
            $langFrom        = array_merge ($langFrom, $plLangFrom);
            $langTo            = array_merge ($langTo, $plLangTo);
        }
        
        // SLOVAK
        if ($skLang == 1) {
            $skLangFrom     = array('á','ä','č','ď','é','í','ľ','ĺ','ň','ó','ô','ŕ','š','ť','ú','ý','ž','Á','Ä','Č','Ď','É','Í','Ľ','Ĺ','Ň','Ó','Ô','Ŕ','Š','Ť','Ú','Ý','Ž');
            $skLangTo         = array('a','a','c','d','e','i','l','l','n','o','o','r','s','t','u','y','z','a','a','c','d','e','i','l','l','n','o','o','r','s','t','u','y','z');
            $langFrom        = array_merge ($langFrom, $skLangFrom);
            $langTo            = array_merge ($langTo, $skLangTo);
        }
        
        // SLOVENIAN
        if ($slLang == 1) {
            $slLangFrom     = array('č','š','ž','Č','Š','Ž');
            $slLangTo         = array('c','s','z','c','s','z');
            $langFrom        = array_merge ($langFrom, $slLangFrom);
            $langTo            = array_merge ($langTo, $slLangTo);
        }
        
        // LITHUANIAN
        if ($ltLang == 1) {
            $ltLangFrom     = array('ą','č','ę','ė','į','š','ų','ū','ž','Ą','Č','Ę','Ė','Į','Š','Ų','Ū','Ž');
            $ltLangTo         = array('a','c','e','e','i','s','u','u','z','A','C','E','E','I','S','U','U','Z');
            $langFrom        = array_merge ($langFrom, $ltLangFrom);
            $langTo            = array_merge ($langTo, $ltLangTo);
        }
        
        // ICELANDIC        
        if ($isLang == 1) {
            $isLangFrom     = array('þ', 'æ', 'ð', 'ö', 'í', 'ó', 'é', 'á', 'ý', 'ú', 'Þ', 'Æ', 'Ð', 'Ö', 'Í', 'Ó', 'É', 'Á', 'Ý', 'Ú');
            $isLangTo         = array('th','ae','d', 'o', 'i', 'o', 'e', 'a', 'y', 'u', 'Th','Ae','D', 'O', 'I', 'O', 'E', 'A', 'Y', 'U');
            $langFrom        = array_merge ($langFrom, $isLangFrom);
            $langTo            = array_merge ($langTo, $isLangTo);
        }

        // GERMAN - because of german names used in Czech, Hungarian, Polish or Slovak (because of possible
        // match - e.g. German ä => ae, but Slovak ä => a ... we can use only one, so we use:
        // a not ae, u not ue, o not oe, ß will be ss
        
        $deLangFrom     = array('ä','ö','ü','ß','Ä','Ö','Ü');
        $deLangTo         = array('a','o','u','ss','a','o','u');
        //$deLangTo         = array('ae','oe','ue','ss','ae','oe','ue');
        
        $langFrom        = array_merge ($langFrom, $deLangFrom);
        $langTo            =  array_merge ($langTo, $deLangTo);

                
        $string = JString::strtolower($string);
        $string = JString::str_ireplace($langFrom, $langTo, $string);
        
        //remove any '-' from the string they will be used as concatonater
        $str = str_replace('-', ' ', $string);

        $lang =& JFactory::getLanguage();
        $str = $lang->transliterate($str);

        // remove any duplicate whitespace, and ensure all characters are alphanumeric
        $str = preg_replace(array('/\s+/','/[^A-Za-z0-9\-]/'), array('-',''), $str);

        // lowercase and trim
        $str = trim(strtolower($str));
        return $str;
    }

    /**
    * Replaces & with & for xhtml compliance
    *
    * @todo There must be a better way???
    *
    * @static
    * @since 1.5
    */
    function ampReplace( $text )
    {
        $text = str_replace( '&&', '*--*', $text );
        $text = str_replace( '&#', '*-*', $text );
        $text = str_replace( '&', '&', $text );
        $text = preg_replace( '|&(?![\w]+;)|', '&', $text );
        $text = str_replace( '*-*', '&#', $text );
        $text = str_replace( '*--*', '&&', $text );

        return $text;
    }

    /**
     * Callback method for replacing & with & in a string
     *
     * @static
     * @param    string    $m    String to process
     * @return    string    Replaced string
     * @since    1.5
     */
    function _ampReplaceCallback( $m )
    {
         $rx = '&(?!amp;)';
         return preg_replace( '#'.$rx.'#', '&', $m[0] );
    }

    /**
    * Cleans text of all formating and scripting code
    */
    function cleanText ( &$text )
    {
        $text = preg_replace( "'<script[^>]*>.*?</script>'si", '', $text );
        $text = preg_replace( '/<a\s+.*?href="([^"]+)"[^>]*>([^<]+)<\/a>/is', '\2 (\1)', $text );
        $text = preg_replace( '/<!--.+?-->/', '', $text );
        $text = preg_replace( '/{.+?}/', '', $text );
        $text = preg_replace( '/&nbsp;/', ' ', $text );
        $text = preg_replace( '/&/', ' ', $text );
        $text = preg_replace( '/"/', ' ', $text );
        $text = strip_tags( $text );
        $text = htmlspecialchars( $text );
        return $text;
    }
}