getProject($ebc_project) )
{
JError::raiseWarning(100, JText::sprintf('Unable to load the project %s', $ebc_project));
ecrHTML::easyFormEnd();
return;
}
$task = JRequest::getVar('task');
$hideLangs = JRequest::getVar('hide_langs', array());
$scope = JRequest::getVar('scope', 'admin');
if( ! $scope )
{
$scope = 'admin';
}
$this->assignRef('project', $project);
$this->assignRef('scope', $scope);
if( ! count($project->langs))
{
$this->easyLanguage = false;
}
else
{
JLoader::import('helpers.language', JPATH_COMPONENT);
$this->easyLanguage = new EasyLanguage($project, $scope, $hideLangs);
if( JRequest::getCmd('tmpl', '') != 'component' )
{
//--Draw h1 header
ecrHTML::header(JText::_('Languages'), $project);
//--draw selector
echo $this->easyLanguage->drawLanguageMenu($project);
}
}
/**
* Handle the 'task' value -> call a function
* Softly exit on undefined
*/
if( in_array($task, get_class_methods($this)) )
{
//--Execute the task
$this->$task();
}
else if( $task )
{
echo 'UNDEFINED: '.$task.'
';
ecrHTML::easyFormEnd();
return;
}
parent::display($tpl);
ecrHTML::easyFormEnd();
}// function
/*
* Task methods
*/
function languages()
{
if( $this->project->langs)
{
$this->prepareTranslation();
$this->default_file = $this->easyLanguage->getDefaultFile();
}
$this->setLayout('languages');
}//function
function searchfiles()
{
$this->prepareTranslation();
$this->setLayout('searchfiles');;
}
private function prepareTranslation()
{
switch( $this->scope )
{
case 'admin':
case 'menu':
$workPath = JPATH_ADMINISTRATOR;
break;
case 'site':
$workPath = JPATH_SITE;
break;
default:
JError::raiseWarning(100, 'wrong scope..');
return;
break;
}//SWITCH
$this->showCore = JRequest::getVar('showCore', '');
$this->easyLanguage->_readStrings($workPath);
if( $this->showCore )
{
$this->easyLanguage->_readStrings($workPath, true);
}
$this->languages = $this->easyLanguage->getLanguages();
$this->hideLangs = $this->easyLanguage->getHideLangs();
$this->definitions = $this->easyLanguage->getDefinitions();
$this->strings = $this->easyLanguage->getStrings();
$this->coreStrings = $this->easyLanguage->getCoreStrings();
}
function langcorrectorder()
{
$sel_language = JRequest::getVar('sel_language', '');
if($sel_language == 'en-GB')
{
$sel_language = '';
}
$default_language = array();
$translated_language = array();
if( $sel_language )
{
$fileName = JPATH_ROOT;
$fileName .=( $this->scope == 'admin' || $this->scope == 'menu' ) ? DS.'administrator' : '';
$menu =( $this->scope == 'menu' ) ? '.menu' : '';
$fileNameDef = $fileName.DS.'language'.DS.'en-GB'.DS.'en-GB.'.$this->project->com_com_name.$menu.'.ini';
$fileName .= DS.'language'.DS.$sel_language.DS.$sel_language.'.'.$this->project->com_com_name.$menu.'.ini';
$default_language = $this->easyLanguage->parseFile($fileNameDef);
$translated_language = $this->easyLanguage->parseFile($fileName);
$corrected_language = $this->easyLanguage->correctTranslation( $default_language, $translated_language);
}
$this->assignRef('default_language', $default_language);
$this->assignRef('translated_language', $translated_language);
$this->assignRef('corrected_language', $corrected_language);
$this->assignRef('sel_language', $sel_language);
$this->setLayout('ordertranslation');
}//function
function langcorrectdeforder()
{
$fileName = JPATH_ROOT;
$fileName .=( $this->scope == 'admin' || $this->scope == 'menu' ) ? DS.'administrator' : '';
$menu =( $this->scope == 'menu' ) ? '.menu' : '';
$fileNameDef = $fileName.DS.'language'.DS.'en-GB'.DS.'en-GB.'.$this->project->com_com_name.$menu.'.ini';
$default_language = $this->easyLanguage->parseFile($fileNameDef);
$this->assignRef('default_language', $default_language);
$this->setLayout('orderdefault');
}//function
function translate()
{
$trans_lang = JRequest::getVar('trans_lang', '');
$trans_key = JRequest::getVar('trans_key', '');
if( $trans_lang != 'en-GB' )
{
$trans_default = $this->easyLanguage->getTranslation('en-GB', $trans_key);
$this->assignRef('trans_default', $trans_default);
}
$translation = $this->easyLanguage->getTranslation($trans_lang, $trans_key);
$this->assignRef('trans_lang', $trans_lang);
$this->assignRef('trans_key', $trans_key);
$this->assignRef('translation', $translation);
$this->setLayout('translator');
}//function
function show_versions()
{
$this->show_version();
}//function
function show_version()
{
$sel_language = JRequest::getVar('sel_language', '');
$selected_version = JRequest::getInt('selected_version', 0);
if( $sel_language )
{
$versions = $this->easyLanguage->getVersions($sel_language);
$this->assignRef('versions', $versions);
}
$this->assignRef('sel_language', $sel_language);
$this->assignRef('selected_version', $selected_version);
$this->setLayout('versions');
}//function
function language_check()
{
if( $this->easyLanguage )
{
$this->languages = $this->easyLanguage->getLanguages();
}
$this->setLayout('check');
}//function
}// class