primo commit
This commit is contained in:
1
plugins/system/multilanguagesck/index.html
Normal file
1
plugins/system/multilanguagesck/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body></body></html>
|
||||
@ -0,0 +1 @@
|
||||
<html><body></body></html>
|
||||
@ -0,0 +1,10 @@
|
||||
; @copyright Copyright (C) 2010 Cédric KEIFLIN alias ced1870
|
||||
; http://www.joomlack.fr
|
||||
; @license GNU/GPL
|
||||
; Double quotes in the values have to be formatted as "_QQ_"
|
||||
|
||||
|
||||
PLG_MULTILANGUAGESCK_XML_DESC ="<p>Mulilanguages CK helps you translate your website anywhere in the page just by using some language tags.</p><p>Example of use :</p><p>{langck=fr-FR}french text to show{/langck}{langck=en-GB}english text to show{/langck}</p>"
|
||||
PLG_MULTILANGUAGESCK_XML_NAME="System - Multi Languages CK"
|
||||
PLG_MULTILANGUAGESCK_DEBUG_LABEL="Use debug mode"
|
||||
PLG_MULTILANGUAGESCK_DEBUG_DESC="Display a message with the current language tag used in the page"
|
||||
@ -0,0 +1,8 @@
|
||||
; @copyright Copyright (C) 2010 Cédric KEIFLIN alias ced1870
|
||||
; http://www.joomlack.fr
|
||||
; @license GNU/GPL
|
||||
; Double quotes in the values have to be formatted as "_QQ_"
|
||||
|
||||
|
||||
PLG_MULTILANGUAGESCK_XML_DESC ="<p>Mulilanguages CK helps you translate your website anywhere in the page just by using some language tags.</p><p>Example of use :</p><p>{langck=fr-FR}french text to show{/langck}{langck=en-GB}english text to show{/langck}</p>"
|
||||
PLG_MULTILANGUAGESCK_XML_NAME="System - Multi Languages CK"
|
||||
@ -0,0 +1 @@
|
||||
<html><body></body></html>
|
||||
@ -0,0 +1,10 @@
|
||||
; @copyright Copyright (C) 2010 Cédric KEIFLIN alias ced1870
|
||||
; http://www.joomlack.fr
|
||||
; @license GNU/GPL
|
||||
; Double quotes in the values have to be formatted as "_QQ_"
|
||||
|
||||
|
||||
PLG_MULTILANGUAGESCK_XML_DESC ="<p>Mulilanguages CK vous permet de traduire votre site à n'importe quel endroit juste en utilisant des tags de langue.</p><p>Exemple d'utilisation: :</p><p>{langck=fr-FR}Texte francais à afficher{/langck}{langck=en-GB}Texte anglais à afficher{/langck}</p>"
|
||||
PLG_MULTILANGUAGESCK_XML_NAME="Système - Multi Languages CK"
|
||||
PLG_MULTILANGUAGESCK_DEBUG_LABEL="Activer le débogage"
|
||||
PLG_MULTILANGUAGESCK_DEBUG_DESC="Affiche un message avec le tag de langue courant utilisé sur la page"
|
||||
@ -0,0 +1,8 @@
|
||||
; @copyright Copyright (C) 2010 Cédric KEIFLIN alias ced1870
|
||||
; http://www.joomlack.fr
|
||||
; @license GNU/GPL
|
||||
; Double quotes in the values have to be formatted as "_QQ_"
|
||||
|
||||
|
||||
PLG_MULTILANGUAGESCK_XML_DESC ="<p>Mulilanguages CK vous permet de traduire votre site à n'importe quel endroit juste en utilisant des tags de langue.</p><p>Exemple d'utilisation: :</p><p>{langck=fr-FR}Texte francais à afficher{/langck}{langck=en-GB}Texte anglais à afficher{/langck}</p>"
|
||||
PLG_MULTILANGUAGESCK_XML_NAME="Système - Multi Languages CK"
|
||||
1
plugins/system/multilanguagesck/language/index.html
Normal file
1
plugins/system/multilanguagesck/language/index.html
Normal file
@ -0,0 +1 @@
|
||||
<html><body></body></html>
|
||||
94
plugins/system/multilanguagesck/multilanguagesck.php
Normal file
94
plugins/system/multilanguagesck/multilanguagesck.php
Normal file
@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @copyright Copyright (C) 2012 Cédric KEIFLIN alias ced1870
|
||||
* http://www.joomlack.fr
|
||||
* @license GNU/GPL
|
||||
* Version 1.0
|
||||
* */
|
||||
// No direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
class plgSystemMultilanguagesck extends CMSPlugin {
|
||||
|
||||
public function onAfterRender() {
|
||||
$app = Factory::getApplication();
|
||||
$document = Factory::getDocument();
|
||||
$doctype = $document->getType();
|
||||
$input = $app->input;
|
||||
|
||||
// si pas en frontend, on sort
|
||||
if ($app->isClient('administrator')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// si pas HTML, on sort
|
||||
if ($doctype !== 'html') {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($input->get('layout') == 'edit') {
|
||||
return;
|
||||
}
|
||||
|
||||
// renvoie les données dans la page
|
||||
// récupère les données de la page
|
||||
if (version_compare(JVERSION, '4') >= 0) {
|
||||
$body = Factory::getApplication()->getBody();
|
||||
} else {
|
||||
$body = JResponse::getBody();
|
||||
}
|
||||
|
||||
// debug mode
|
||||
// get attribute from system plugin params
|
||||
$plugin = PluginHelper::getPlugin('system', 'multilanguagesck');
|
||||
$pluginParams = new Registry($plugin->params);
|
||||
if ($pluginParams->get('debugmode') == '1') {
|
||||
// get the language
|
||||
$lang = Factory::getLanguage();
|
||||
$langtag = $lang->getTag(); // returns fr-FR or en-GB
|
||||
$debugmessage = '<p style="font-size:14px;color:red;">The actual language tag is : ' . $langtag . '</p>';
|
||||
$body = str_replace("<body", $debugmessage . "<body", $body);
|
||||
}
|
||||
|
||||
$regex = "#{langck(.*?){/langck}#s"; // masque de recherche
|
||||
$body = preg_replace_callback($regex, array($this, 'checklanguageck'), $body);
|
||||
|
||||
if (version_compare(JVERSION, '4') >= 0) {
|
||||
Factory::getApplication()->setBody($body);
|
||||
} else {
|
||||
JResponse::setBody($body);
|
||||
}
|
||||
}
|
||||
|
||||
function checklanguageck($matches) {
|
||||
|
||||
// découpe l'expression pour récupérer les textes
|
||||
$patterns = "#{langck(.*)}(.*){/langck}#Uis";
|
||||
$result = preg_match($patterns, $matches[0], $results);
|
||||
|
||||
// vérifie si des paramètres personnalisés existent
|
||||
$params = explode('=', $results[1]);
|
||||
|
||||
// si pas de langue définie on sort
|
||||
if (!isset($params[1]))
|
||||
return $matches[0];
|
||||
|
||||
$lang = Factory::getLanguage();
|
||||
$langtag = $lang->getTag(); // returns fr-FR or en-GB
|
||||
// vérifie si ça colle avec la langue active
|
||||
if (($params[1] == $langtag) AND isset($results[2])) {
|
||||
$return = $results[2];
|
||||
} else {
|
||||
$return = '';
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
}
|
||||
47
plugins/system/multilanguagesck/multilanguagesck.xml
Normal file
47
plugins/system/multilanguagesck/multilanguagesck.xml
Normal file
@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension version="2.5" type="plugin" group="system" method="upgrade">
|
||||
<name>PLG_MULTILANGUAGESCK_XML_NAME</name>
|
||||
<ckpro>0</ckpro>
|
||||
<variant>free</variant>
|
||||
<author>Cédric KEIFLIN</author>
|
||||
<creationDate>mars 2012</creationDate>
|
||||
<copyright>Cédric KEIFLIN</copyright>
|
||||
<license>GNU/GPL 3 http://www.gnu.org/licenses/gpl.html</license>
|
||||
<authorEmail>ced1870@gmail.com</authorEmail>
|
||||
<authorUrl>https://www.joomlack.fr</authorUrl>
|
||||
<version>1.2.0</version>
|
||||
<description>PLG_MULTILANGUAGESCK_XML_DESC</description>
|
||||
|
||||
<files>
|
||||
<filename plugin="multilanguagesck">multilanguagesck.php</filename>
|
||||
<filename>index.html</filename>
|
||||
<folder>language</folder>
|
||||
</files>
|
||||
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB/plg_system_multilanguagesck.ini</language>
|
||||
<language tag="en-GB">en-GB/plg_system_multilanguagesck.sys.ini</language>
|
||||
<language tag="fr-FR">fr-FR/plg_system_multilanguagesck.ini</language>
|
||||
<language tag="fr-FR">fr-FR/plg_system_multilanguagesck.sys.ini</language>
|
||||
</languages>
|
||||
<updateservers>
|
||||
<server type="extension" priority="1" name="Multilanguages CK Update">https://update.joomlack.fr/multilanguagesck_light_update.xml</server>
|
||||
</updateservers>
|
||||
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="debugmode"
|
||||
type="radio"
|
||||
default="0"
|
||||
label="PLG_MULTILANGUAGESCK_DEBUG_LABEL"
|
||||
description="PLG_MULTILANGUAGESCK_DEBUG_DESC">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
|
||||
</extension>
|
||||
Reference in New Issue
Block a user