File manager - Edit - /home/verseaumee/ptitsanes/plugins/system/amlang/amlang.php
Back
<?php /** * Class plg System AmLang * @author Maxim Resh (arenam.ru) * @author mail srvice@arenam.ru * @website http://arenam.ru/ * copyright Copyright © 2018 - All rights reserved. * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html **/ // No direct access defined( '_JEXEC' ) or die; jimport( 'joomla.plugin.plugin' ); jimport('joomla.language.helper'); class plgSystemAmlang extends JPlugin { public function onAfterRender() { // Not work in the admin panel if (\JFactory::getApplication()->isAdmin()) { return true; } else { $user = \JFactory::getUser(); $body = \JResponse::getBody(); // To check whether there is language operators if ( \JString::strpos( $body, '{lang' ) == false ) { return true; } $lang = \JFactory::getLanguage(); $lang_codes = \JLanguageHelper::getLanguages('lang_code'); if (isset($lang_codes[$lang->getTag()])) { // Current language $current_lang = $lang_codes[$lang->getTag()]; // Show text for the current language $regex = "#{lang ".$current_lang->sef."}(.*?){\/lang}#is"; $body = preg_replace($regex,'$1',$body); // Do not show text for the current language $regex = "#{lang \!".$current_lang->sef."}(.*?){\/lang}#is"; $body = preg_replace($regex, '', $body); // Show text for the current language for registered users only if (!$user->guest) { $regex = "#{lang \*".$current_lang->sef."}(.*?){\/lang}#is"; $body = preg_replace($regex, '$1', $body); } else { if ($this->params->get('noregmess') == 1) { $regex = "#{lang \*".$current_lang->sef."}(.*?){\/lang}#is"; $mess = '<div class="alert alert-info">Log in with your username to see this text<div>'; $body = preg_replace($regex, $mess, $body); } } } // Hide other languages $regex = "#{lang \![^}]+}(.*?){\/lang}#is"; $body = preg_replace($regex, '$1', $body); $regex = "#{lang [^{]+}[^}]+{\/lang}#is"; $body = preg_replace($regex,'',$body); $regex = "#{lang \*[^{]+}[^}]+{\/lang}#is"; $body = preg_replace($regex,'',$body); // Check if ( \JString::strpos( $body, '{lang' ) == true ) { $regex = "#{lang(.*?)}#is"; $body = preg_replace($regex, '', $body); } // Set body \JResponse::setBody($body); unset($body, $regex, $current_lang, $mess); return true; } } }
| ver. 1.4 |
Github
|
.
| PHP 8.5.7 | Generation time: 0 |
proxy
|
phpinfo
|
Settings