Select Git revision
plugins_renderer.class.php
-
Hahn Axel (hahn) authoredHahn Axel (hahn) authored
plugins_renderer.class.php 3.83 KiB
<?php
require_once('plugins.class.php');
/**
* WIP
* base class for all plugin types to read available plugins
* and its metadata
*
* @example
* $CI_plugins=new ciplugins();
* print_r($CI_plugins->getPluginTypes());
*
* // $CI_plugins->setType('build');
* // print_r($CI_plugins->getPlugins());
* print_r($CI_plugins->getPlugins('build'));
*
* $CI_plugins->setPlugin('tgz', 'build'); // plugin name + type
*
*
* @author axel
*/
class plugin_renderer extends ciplugins {
// ---------------------------------------------------------------
//
// BELOW ARE METHODS FOR A SET SPECIFIC PLUGIN AND TYPE
//
// ---------------------------------------------------------------
// ---------------------------------------------------------------
// LANGUAGE TEXTS (needed in ui only)
// ---------------------------------------------------------------
/**
* get a translated text from lang_XX.json in plugin dir;
* If the key is missed it returns "[KEY :: LANG]"
*
* @see setLang()
* @param string $sKey key to find in lang file
* @return string
*/
protected function _t($sKey){
return (isset($this->_aLang[$sKey]) && $this->_aLang[$sKey])
? $this->_aLang[$sKey]
: "[ $sKey :: $this->_sLang ]"
;
}
/**
* set language for output of formdata and other texts.
* This method loads the language file into a hash. The output of
* translated texts can be done with $this->_t("your_key")
*
* @see _t()
* @param string $sLang language code, i.e. "de"
* @return boolean
*/
public function setLang($sLang=false){
$this->_sLang=$sLang ? $sLang : $this->_sLang;
$oReflection=new ReflectionClass($this);
$sFile=dirname($oReflection->getFileName()) . '/lang_'.$this->_sLang.'.json';
$this->_aLang=(file_exists($sFile)) ? json_decode(file_get_contents($sFile), 1) : $this->_aLang;
return true;
}
// ---------------------------------------------------------------
// SETTER
// ---------------------------------------------------------------