Use mask class on every page & add paramaters to translations
This commit is contained in:
12
inc/main.php
12
inc/main.php
@@ -125,7 +125,9 @@ abstract class Main extends PhpObject
|
||||
$asPages = array_values($this->asMasks);
|
||||
foreach($asPages as $sPage)
|
||||
{
|
||||
$sPageContent = $this->getPageContent($sPage);
|
||||
//$sPageContent = $this->getPageContent($sPage);
|
||||
$oMask = new Mask($sPage, $this->oLang);
|
||||
$sPageContent = $oMask->getMask();
|
||||
if($sPage!=$sMainPage) $asGlobalVars['consts']['pages'][$sPage] = $sPageContent;
|
||||
}
|
||||
|
||||
@@ -160,7 +162,13 @@ abstract class Main extends PhpObject
|
||||
public static function getJsonResult($bSuccess, $sDesc, $asVars=array())
|
||||
{
|
||||
header('Content-type: application/json');
|
||||
return json_encode(array('result'=>$bSuccess?self::SUCCESS:self::ERROR, 'desc'=>$sDesc, 'data'=>$asVars));
|
||||
$asResult = self::getResult($bSuccess, $sDesc, $asVars);
|
||||
$asResult['result'] = $asResult['result']?self::SUCCESS:self::ERROR;
|
||||
return json_encode($asResult);
|
||||
}
|
||||
|
||||
public static function getResult($bSuccess, $sDesc, $asVars) {
|
||||
return array('result'=>$bSuccess, 'desc'=>$sDesc, 'data'=>$asVars);
|
||||
}
|
||||
|
||||
public static function goTo403() {
|
||||
|
||||
@@ -34,8 +34,12 @@ class Translator extends PhpObject
|
||||
$this->sDefaultLang = $sDefaultLang;
|
||||
$this->sLang = ($sLang=='')?ToolBox::getUserLanguage($this->asLanguages, $this->sDefaultLang):$sLang;
|
||||
}
|
||||
|
||||
public function getLanguage() {
|
||||
return $this->sLang;
|
||||
}
|
||||
|
||||
public function getTranslation($sTransKey='', $sLang='')
|
||||
public function getTranslation($sTransKey='', $asParams=array(), $sLang='')
|
||||
{
|
||||
$oTransText = false;
|
||||
|
||||
@@ -55,6 +59,11 @@ class Translator extends PhpObject
|
||||
}
|
||||
else $this->addWarning($bAllTrans?'Missing language "'.$sLang.'"':'Missing translation in "'.$sLang.'" for the key "'.$sTransKey.'"');
|
||||
|
||||
if(is_string($asParams)) $asParams = array($asParams);
|
||||
if($oTransText && !$bAllTrans && !empty($asParams)) {
|
||||
foreach($asParams as $iIndex=>$sParam) $oTransText = str_replace('$'.$iIndex, $sParam, $oTransText);
|
||||
}
|
||||
|
||||
return $oTransText;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user