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);
|
$asPages = array_values($this->asMasks);
|
||||||
foreach($asPages as $sPage)
|
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;
|
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())
|
public static function getJsonResult($bSuccess, $sDesc, $asVars=array())
|
||||||
{
|
{
|
||||||
header('Content-type: application/json');
|
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() {
|
public static function goTo403() {
|
||||||
|
|||||||
@@ -35,7 +35,11 @@ class Translator extends PhpObject
|
|||||||
$this->sLang = ($sLang=='')?ToolBox::getUserLanguage($this->asLanguages, $this->sDefaultLang):$sLang;
|
$this->sLang = ($sLang=='')?ToolBox::getUserLanguage($this->asLanguages, $this->sDefaultLang):$sLang;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTranslation($sTransKey='', $sLang='')
|
public function getLanguage() {
|
||||||
|
return $this->sLang;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTranslation($sTransKey='', $asParams=array(), $sLang='')
|
||||||
{
|
{
|
||||||
$oTransText = false;
|
$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.'"');
|
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;
|
return $oTransText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user