Datei: plugins/example.encoding.php
Quellcode
Darstellung:
-
<?php
- /**
- * Plugin example: Encoding conversion
- *
- */
- class EncodingExample extends BMPlugin
- {
- function EncodingExample()
- {
- $this->name = 'Encoding conversion example';
- $this->author = 'B1G Software';
- $this->web = 'http://www.b1g.de';
- $this->mail = 'info@b1g.de';
- $this->version = '1.0';
- $this->designedfor = '7.2.0';
- $this->type = BMPLUGIN_DEFAULT;
-
- $this->admin_pages = true;
- $this->admin_page_title = 'Encoding example';
- }
-
- function OnReadLang(&$lang_user, &$lang_client, &$lang_custom, &$lang_admin, $lang)
- {
- $_lang_admin = array(
- 'encex_test1' => 'Umlaute: äöü ÄÖÜ',
- 'encex_test2' => 'Noch ein Test: 12,34 €'
- );
-
- // convert charset
- global $currentCharset;
- $arrays = array('admin', 'client', 'user', 'custom');
- foreach($arrays as $array)
- {
- $destArray = sprintf('lang_%s', $array);
- $srcArray = '_' . $destArray;
-
- if(!isset($$srcArray))
- continue;
-
- foreach($$srcArray as $key=>$val)
- {
- if(function_exists('CharsetDecode') && !in_array(strtolower($currentCharset), array('iso-8859-1', 'iso-8859-15')))
- $val = CharsetDecode($val, 'iso-8859-15');
- ${$destArray}[$key] = $val;
- }
- }
- }
-
- function AdminHandler()
- {
- global $tpl;
-
- $tabs = array(
- 0 => array(
- 'title' => 'Encoding conversion example',
- 'link' => $this->_adminLink() . '&',
- 'active' => true
- )
- );
-
- $tpl->assign('tabs', $tabs);
- $tpl->assign('page', $this->_templatePath('encex.admin.tpl'));
- }
- }
-
- /**
- * register plugin
- */
- $plugins->registerPlugin('EncodingExample');
- ?>