helpers class updated!
--HG-- branch : quitta-gsoc-2013
This commit is contained in:
parent
9101cd2f6e
commit
0ec8e76d8e
1 changed files with 23 additions and 12 deletions
|
@ -3,27 +3,28 @@
|
||||||
class Helpers{
|
class Helpers{
|
||||||
|
|
||||||
|
|
||||||
public static function loadTemplate( $template, $vars = array (), $forcelibrender = false )
|
public static function loadTemplate( $template, $vars = array (), $returnHTML = false )
|
||||||
{
|
{
|
||||||
|
|
||||||
global $AMS_LIB;
|
global $AMS_LIB;
|
||||||
global $SITEBASE;
|
global $SITEBASE;
|
||||||
global $AMS_TRANS;
|
global $AMS_TRANS;
|
||||||
global $INGAME_LAYOUT;
|
global $INGAME_LAYOUT;
|
||||||
define('SMARTY_SPL_AUTOLOAD',1);
|
//define('SMARTY_SPL_AUTOLOAD',1);
|
||||||
require_once $AMS_LIB . '/smarty/libs/Smarty.class.php';
|
require_once $AMS_LIB . '/smarty/libs/Smarty.class.php';
|
||||||
spl_autoload_register('__autoload');
|
spl_autoload_register('__autoload');
|
||||||
|
|
||||||
$smarty = new Smarty;
|
$smarty = new Smarty;
|
||||||
|
$smarty->setCompileDir($SITEBASE.'/templates_c/');
|
||||||
|
$smarty->setCacheDir($SITEBASE.'/cache/');
|
||||||
|
$smarty -> setConfigDir($SITEBASE . '/configs/' );
|
||||||
// turn smarty debugging on/off
|
// turn smarty debugging on/off
|
||||||
$smarty -> debugging = false;
|
$smarty -> debugging = false;
|
||||||
// caching must be disabled for multi-language support
|
// caching must be disabled for multi-language support
|
||||||
$smarty -> caching = false;
|
$smarty -> caching = false;
|
||||||
$smarty -> cache_lifetime = 120;
|
$smarty -> cache_lifetime = 120;
|
||||||
|
|
||||||
helpers :: create_folders ();
|
helpers :: create_folders ();
|
||||||
|
|
||||||
if ( helpers::check_if_game_client() or $forcelibrender = false ){
|
if ( helpers::check_if_game_client() or $forcelibrender = false ){
|
||||||
$smarty -> template_dir = $AMS_LIB . '/ingame_templates/';
|
$smarty -> template_dir = $AMS_LIB . '/ingame_templates/';
|
||||||
$smarty -> setConfigDir( $AMS_LIB . '/configs' );
|
$smarty -> setConfigDir( $AMS_LIB . '/configs' );
|
||||||
|
@ -45,7 +46,7 @@ class Helpers{
|
||||||
foreach ( $variables[$template] as $key => $value ){
|
foreach ( $variables[$template] as $key => $value ){
|
||||||
$smarty -> assign( $key, $value );
|
$smarty -> assign( $key, $value );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( isset($vars['permission']) && $vars['permission'] == 3 ){
|
if( isset($vars['permission']) && $vars['permission'] == 3 ){
|
||||||
$inherited = "extends:layout_admin.tpl|";
|
$inherited = "extends:layout_admin.tpl|";
|
||||||
}else if( isset($vars['permission']) && $vars['permission'] == 2){
|
}else if( isset($vars['permission']) && $vars['permission'] == 2){
|
||||||
|
@ -55,9 +56,15 @@ class Helpers{
|
||||||
}else{
|
}else{
|
||||||
$inherited ="";
|
$inherited ="";
|
||||||
}
|
}
|
||||||
// extends:' . $inherited .'|register.tpl
|
|
||||||
$smarty -> display( $inherited . $template . '.tpl' );
|
|
||||||
}
|
|
||||||
|
if($returnHTML == true){
|
||||||
|
return $smarty ->fetch($inherited . $template . '.tpl' );
|
||||||
|
}else{
|
||||||
|
$smarty -> display( $inherited . $template . '.tpl' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static public function create_folders(){
|
static public function create_folders(){
|
||||||
global $AMS_LIB;
|
global $AMS_LIB;
|
||||||
|
@ -72,8 +79,9 @@ class Helpers{
|
||||||
);
|
);
|
||||||
foreach ( $arr as & $value ){
|
foreach ( $arr as & $value ){
|
||||||
if ( !file_exists( $value ) ){
|
if ( !file_exists( $value ) ){
|
||||||
echo $value;
|
//echo $value;
|
||||||
mkdir( $value);
|
print($value);
|
||||||
|
drupal_mkdir($value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -133,6 +141,9 @@ class Helpers{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_SESSION['Language'] == ""){
|
||||||
|
$_SESSION['Language'] = $DEFAULT_LANGUAGE;
|
||||||
|
}
|
||||||
return parse_ini_file( $AMS_TRANS . '/' . $_SESSION['Language'] . '.ini', true );
|
return parse_ini_file( $AMS_TRANS . '/' . $_SESSION['Language'] . '.ini', true );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue