From 524e338f685fb819141ddd69242602dac292e232 Mon Sep 17 00:00:00 2001 From: Botanic Date: Thu, 6 Jun 2013 22:59:11 -0700 Subject: [PATCH] cleaned up templates and got languages working --HG-- branch : rc-botanic-webdev --- .../ryzom_ams/ams_lib/autoload/helpers.php | 38 +++++++-- .../ryzom_ams/ams_lib/configs/ams_lib.conf | 2 - .../ams_lib/ingame_templates/register.phtml | 1 - .../ingame_templates/register.tpl} | 16 ++-- .../ryzom_ams/ams_lib/translations/en.ini | 8 ++ .../ryzom_ams/ams_lib/translations/fr.ini | 8 ++ .../tools/server/ryzom_ams/www/config.php | 10 ++- .../tools/server/ryzom_ams/www/html/index.php | 6 +- .../ryzom_ams/www/html/templates/footer.phtml | 4 - .../ryzom_ams/www/html/templates/footer.tpl | 2 - .../ryzom_ams/www/html/templates/header.phtml | 11 --- .../ryzom_ams/www/html/templates/header.tpl | 5 -- .../ryzom_ams/www/html/templates/home.phtml | 1 - .../ryzom_ams/www/html/templates/index.tpl | 82 ------------------- 14 files changed, 65 insertions(+), 129 deletions(-) rename code/ryzom/tools/server/ryzom_ams/{www/html/templates/register.phtml => ams_lib/ingame_templates/register.tpl} (83%) create mode 100644 code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini create mode 100644 code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini delete mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/templates/footer.phtml delete mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/templates/footer.tpl delete mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/templates/header.phtml delete mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/templates/header.tpl delete mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/templates/home.phtml delete mode 100644 code/ryzom/tools/server/ryzom_ams/www/html/templates/index.tpl diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php index 7675320a5..195b3e02c 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/helpers.php @@ -4,21 +4,43 @@ class Helpers{ public function loadTemplate( $template, $vars = array () ) { global $AMS_LIB; - global $NELTOOL_SITEBASE; + global $SITEBASE; + global $AMS_TRANS; require_once $AMS_LIB . '/smarty/libs/Smarty.class.php'; $smarty = new Smarty; - $smarty -> debugging = true; - $smarty -> caching = true; + // turn smarty debugging on/off + $smarty -> debugging = false; + // caching must be disabled for multi-language support + $smarty -> caching = false; $smarty -> cache_lifetime = 120; if ( !helpers :: check_if_game_client () ){ - $smarty -> template_dir = $AMS_LIB . '/templates/'; - $smarty->setConfigDir($AMS_LIB .'/config'); + $smarty -> template_dir = $AMS_LIB . '/ingame_templates/'; + $smarty -> setConfigDir( $AMS_LIB . '/configs' ); }else{ - $smarty -> template_dir = $NELTOOL_SITEBASE . '/templates/'; - $smarty->setConfigDir($NELTOOL_SITEBASE .'/config'); + $smarty -> template_dir = $SITEBASE . '/templates/'; + $smarty -> setConfigDir( $SITEBASE . '/configs' ); + } + + foreach ( $vars as $key => $value ){ + $smarty -> assign( $key, $value ); + } + if ( isset( $_GET["language"] ) ){ + $language = $_GET["language"]; + if ( file_exists( $AMS_TRANS . '/' . $language . '.ini' ) ){ + + }else{ + global $DEFAULT_LANGUAGE; + $language = $DEFAULT_LANGUAGE; + } + }else{ + global $DEFAULT_LANGUAGE; + $language = $DEFAULT_LANGUAGE; + } + $variables = parse_ini_file( $AMS_TRANS . '/' . $language . '.ini', true ); + foreach ( $variables[$template] as $key => $value ){ + $smarty -> assign( $key, $value ); } - $smarty -> assign( "option_selected", "NE" ); $smarty -> display( $template . '.tpl' ); } diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/configs/ams_lib.conf b/code/ryzom/tools/server/ryzom_ams/ams_lib/configs/ams_lib.conf index 5eac748ec..b9e919045 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/configs/ams_lib.conf +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/configs/ams_lib.conf @@ -1,5 +1,3 @@ title = Welcome to Smarty! cutoff_size = 40 -[setup] -bold = true diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/register.phtml b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/register.phtml index 08a6835bd..dd1efbef8 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/register.phtml +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/ingame_templates/register.phtml @@ -5,7 +5,6 @@
-{The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
- RYZOM CORE INGAME REGISTRATION + {$title}
- + {$welcome_message}
- + - + @@ -99,7 +100,8 @@
5-12 lower-case characters and numbers. The login (username) you create here will be your login name. The name of your game characters will be chosen later on. -
+ +
5-20 characters. diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini new file mode 100644 index 000000000..1b43e7ffc --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/en.ini @@ -0,0 +1,8 @@ +; This is a sample configuration file +; Comments start with ';', as in php.ini + +[register] +title = "RYZOM CORE INGAME REGISTRATION" +welcome_message = "Welcome! Please fill in the following fields to get your new Ryzom Core account:" +username_tag = "Desired Username:" +username_tooltip = "5-12 lower-case characters and numbers. The login (username) you create here will be your login name. The name of your game characters will be chosen later on." \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini new file mode 100644 index 000000000..348b44b69 --- /dev/null +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/translations/fr.ini @@ -0,0 +1,8 @@ +; This is a sample configuration file +; Comments start with ';', as in php.ini + +[register] +title = "RYZOM base dans ENREGISTREMENT DU JEU" +welcome_message = "Bienvenue! S'il vous plaît remplissez les champs ci-dessous pour obtenir votre nouveau compte de base de Ryzom:" +username_tag = "Nom d'utilisateur désiré:" +username_tooltip = "5-12 caractères et de chiffres minuscules. Le login (nom d'utilisateur) que vous créez ici sera votre nom de connexion. Le nom de vos personnages de jeu sera choisi plus tard." \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/config.php b/code/ryzom/tools/server/ryzom_ams/www/config.php index b1a549ad2..ce924369f 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/config.php +++ b/code/ryzom/tools/server/ryzom_ams/www/config.php @@ -30,7 +30,9 @@ $CREATE_RING = true ; // site paths definitions $AMS_LIB = dirname(dirname( __FILE__ )) . '/ams_lib'; -$NELTOOL_SITEBASE = dirname( __FILE__ ) . '/html/' ; +$AMS_TRANS = $AMS_LIB . '/translations'; +$AMS_CACHEDIR = $AMS_LIB . '/cache'; +$SITEBASE = dirname( __FILE__ ) . '/html/' ; $NELTOOL_SYSTEMBASE = dirname( dirname( __FILE__ ) ) . '/admin/' ; $NELTOOL_LOGBASE = $NELTOOL_SYSTEMBASE . '/logs/' ; $NELTOOL_IMGBASE = $NELTOOL_SYSTEMBASE . '/imgs/' ; @@ -38,7 +40,7 @@ $NELTOOL_SITEBASE = dirname( __FILE__ ) . '/html/' ; $NELTOOL_RRDTOOL = '/usr/bin/rrdtool' ; $NELTOOL_RRDSYSBASE = $NELTOOL_SYSTEMBASE . 'graphs_output/' ; - $NELTOOL_RRDWEBBASE = $NELTOOL_SITEBASE . 'graphs_output/' ; + $NELTOOL_RRDWEBBASE = $SITEBASE . 'graphs_output/' ; // SQL table names $NELDB_PREFIX = 'neltool_' ; @@ -79,7 +81,7 @@ $NELDB_CONFIG_TABLE = $NELDB_PREFIX . 'config'; $HARDWARE_REFRESH = 600 ; $LOCK_TIMEOUT = 1800 ; $BG_IMG = 'imgs/bg_live.png' ; - $GAME_NAME = 'Ryzom Core'; -$WELCOME_MESSAGE = 'Welcome! Please fill in the following fields to get your new '.$GAME_NAME.' account:'; + + $DEFAULT_LANGUAGE = 'en'; $TEMPLATE_DIR = ""; \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/index.php b/code/ryzom/tools/server/ryzom_ams/www/html/index.php index e426921c8..069323d1b 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/index.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/index.php @@ -16,5 +16,7 @@ $page = 'home'; if (isset($_GET["page"])) { $page = $_GET["page"]; } - -helpers::loadTemplate( 'register' ); \ No newline at end of file +$pageElements = array(); +$pageElements['USERNAME_ERROR'] = 'TRUE'; +$pageElements['Username'] = 'testuser'; +helpers::loadTemplate( 'register' , $pageElements); \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/footer.phtml b/code/ryzom/tools/server/ryzom_ams/www/html/templates/footer.phtml deleted file mode 100644 index 0488ede51..000000000 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/footer.phtml +++ /dev/null @@ -1,4 +0,0 @@ -
-This is a footer - - diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/footer.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/footer.tpl deleted file mode 100644 index e04310fdd..000000000 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/footer.tpl +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/header.phtml b/code/ryzom/tools/server/ryzom_ams/www/html/templates/header.phtml deleted file mode 100644 index 9cb70a8a7..000000000 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/header.phtml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - This is a header - -
\ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/header.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/header.tpl deleted file mode 100644 index 783210a18..000000000 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/header.tpl +++ /dev/null @@ -1,5 +0,0 @@ - - -{$title} - {$Name} - - diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/home.phtml b/code/ryzom/tools/server/ryzom_ams/www/html/templates/home.phtml deleted file mode 100644 index 45c6825a5..000000000 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/home.phtml +++ /dev/null @@ -1 +0,0 @@ -mainpage welcome! \ No newline at end of file diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/index.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/index.tpl deleted file mode 100644 index dafd2f854..000000000 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/index.tpl +++ /dev/null @@ -1,82 +0,0 @@ -{config_load file="ams_lib.conf" section="setup"} -{include file="header.tpl" title=foo} - -
-
-{* bold and title are read from the config file *}
-{if #bold#}{/if}
-{* capitalize the first letters of each word of the title *}
-Title: {#title#|capitalize}
-{if #bold#}{/if}
-
-The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
-
-The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
-
-Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
-
-The value of {ldelim}$Name{rdelim} is {$Name}
-
-variable modifier example of {ldelim}$Name|upper{rdelim}
-
-{$Name|upper}
-
-
-An example of a section loop:
-
-{section name=outer 
-loop=$FirstName}
-{if $smarty.section.outer.index is odd by 2}
-	{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
-{else}
-	{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
-{/if}
-{sectionelse}
-	none
-{/section}
-
-An example of section looped key values:
-
-{section name=sec1 loop=$contacts}
-	phone: {$contacts[sec1].phone}
- fax: {$contacts[sec1].fax}
- cell: {$contacts[sec1].cell}
-{/section} -

- -testing strip tags -{strip} -

id="caption-Username">Desired Username: {$username_tag} + "javascript:showTooltip('{$username_tooltip}', this);" /> width="42%">{if isset($Username)}{$Username}{/if}
- - - -
- - This is a test - -
-{/strip} - - - -This is an example of the html_select_date function: - - -{html_select_date start_year=1998 end_year=2010} -
- -This is an example of the html_select_time function: - -
-{html_select_time use_24_hours=false} -
- -This is an example of the html_options function: - -
- -
- -{include file="footer.tpl"}