# HG changeset patch # User Dan # Date 1194413662 18000 # Node ID a7d0f2711df125a2a622548988c72fcb08635827 # Parent c671f3bb8aed2b2da2e71d80f3ab42be394b9e26 Installer localization started. Welcome, License, and SysReqs pages are fully localized. diff -r c671f3bb8aed -r a7d0f2711df1 includes/lang.php --- a/includes/lang.php Tue Nov 06 16:22:43 2007 -0500 +++ b/includes/lang.php Wed Nov 07 00:34:22 2007 -0500 @@ -71,8 +71,8 @@ if ( defined('IN_ENANO_INSTALL') ) { // special case for the Enano installer: it will load its own strings from a JSON file and just use this API for fetching and templatizing them. - $this->lang_id = LANG_DEFAULT; - $this->lang_code = 'neutral'; + $this->lang_id = 1; + $this->lang_code = $lang; return true; } if ( is_string($lang) ) @@ -186,6 +186,77 @@ } /** + * Loads a JSON language file and parses the strings into RAM. Will use the cache if possible, but stays far away from the database, + * which we assume doesn't exist yet. + */ + + function load_file($file) + { + global $db, $session, $paths, $template, $plugins; // Common objects + + if ( !file_exists($file) ) + $db->_die('lang.php - requested JSON file doesn\'t exist'); + + $contents = trim(@file_get_contents($file)); + if ( empty($contents) ) + $db->_die('lang.php - empty language file...'); + + // Trim off all text before and after the starting and ending braces + $contents = preg_replace('/^([^{]+)\{/', '{', $contents); + $contents = preg_replace('/\}([^}]+)$/', '}', $contents); + $contents = trim($contents); + + if ( empty($contents) ) + $db->_die('lang.php - no meat to the language file...'); + + $checksum = md5($contents); + if ( file_exists("./cache/lang_json_{$checksum}.php") ) + { + $this->load_cache_file("./cache/lang_json_{$checksum}.php"); + } + else + { + $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); + $langdata = $json->decode($contents); + + if ( !is_array($langdata) ) + $db->_die('lang.php - invalid language file'); + + if ( !isset($langdata['categories']) || !isset($langdata['strings']) ) + $db->_die('lang.php - language file does not contain the proper items'); + + $this->merge($langdata['strings']); + + $lang_file = "./cache/lang_json_{$checksum}.php"; + + $handle = @fopen($lang_file, 'w'); + if ( !$handle ) + // Couldn't open the file. Silently fail and let the strings come from RAM. + return false; + + // The file's open, that means we should be good. + fwrite($handle, 'var_export_string($this->strings); + if ( empty($exported) ) + // Ehh, that's not good + $db->_die('lang.php - load_file(): var_export_string() failed'); + + fwrite($handle, $exported . '; ?>'); + + // Clean up + unset($exported, $langdata); + + // Done =) + fclose($handle); + } + } + + /** * Merges a standard language assoc array ($arr[cat][stringid]) with the master in RAM. * @param array */ @@ -195,7 +266,7 @@ // This is stupidly simple. foreach ( $strings as $cat_id => $contents ) { - if ( !is_array($this->strings[$cat_id]) ) + if ( !isset($this->strings[$cat_id]) || ( isset($this->strings[$cat_id]) && !is_array($this->strings[$cat_id]) ) ) $this->strings[$cat_id] = array(); foreach ( $contents as $string_id => $string ) { @@ -364,6 +435,10 @@ if ( !$found ) { // Ehh, the string wasn't found. Rerun fetch() and try again. + if ( defined('IN_ENANO_INSTALL') ) + { + return $string_id; + } $this->fetch(); if ( isset($this->strings[$category]) && isset($this->strings[$category][$string_name]) ) { @@ -428,7 +503,7 @@ $subs[$key] = strval($value); $string = str_replace("%{$key}%", "{$subs[$key]}", $string); } - return "L $string"; + return "{$string}*"; } } // class Language diff -r c671f3bb8aed -r a7d0f2711df1 includes/template.php --- a/includes/template.php Tue Nov 06 16:22:43 2007 -0500 +++ b/includes/template.php Wed Nov 07 00:34:22 2007 -0500 @@ -1894,13 +1894,14 @@ { global $sideinfo; global $this_page; + global $lang; global $db, $session, $paths, $template, $plugins; // Common objects $tplvars = $this->extract_vars('elements.tpl'); $tb = ''; // Get the "article" button text (depends on namespace) - if(defined('IN_ENANO_INSTALL')) $ns = 'installation page'; + if(defined('IN_ENANO_INSTALL')) $ns = $lang->get('meta_btn_article'); else $ns = 'system error page'; - $t = str_replace('{FLAGS}', 'onclick="if ( !KILL_SWITCH ) { return false; }" title="Hey! A button that doesn\'t do anything. Clever..." accesskey="a"', $tplvars['toolbar_button']); + $t = str_replace('{FLAGS}', 'onclick="return false;" title="Hey! A button that doesn\'t do anything. Clever..." accesskey="a"', $tplvars['toolbar_button']); $t = str_replace('{HREF}', '#', $t); $t = str_replace('{TEXT}', $ns, $t); $tb .= $t; @@ -1923,22 +1924,28 @@ $title = ( is_object($paths) ) ? $paths->page : 'Critical error'; + $headers = ''; + if ( defined('IN_ENANO_INSTALL') ) + { + $headers .= ''; + } + // The rewritten template engine will process all required vars during the load_template stage instead of (cough) re-processing everything each time around. $tpl_strings = Array( 'PAGE_NAME'=>$this_page, 'PAGE_URLNAME'=>'Null', - 'SITE_NAME'=>'Enano Installation', + 'SITE_NAME'=>$lang->get('meta_site_name'), 'USERNAME'=>'admin', - 'SITE_DESC'=>'Install Enano on your server.', + 'SITE_DESC'=>$lang->get('meta_site_desc'), 'TOOLBAR'=>$tb, 'SCRIPTPATH'=>scriptPath, 'CONTENTPATH'=>contentPath, 'ADMIN_SID_QUES'=>$asq, 'ADMIN_SID_AMP'=>$asa, 'ADMIN_SID_AMP_HTML'=>'', - 'ADDITIONAL_HEADERS'=>'', + 'ADDITIONAL_HEADERS'=>$headers, 'SIDEBAR_EXTRA'=>'', - 'COPYRIGHT'=>'Enano and all of its code, graphics, and more code is copyright © 2006 Dan Fuhry.
This program is Free Software; see the file "GPL" included with this package for details.', + 'COPYRIGHT'=>$lang->get('meta_enano_copyright'), 'TOOLBAR_EXTRAS'=>'', 'REQUEST_URI'=>( isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '' ).$_SERVER['REQUEST_URI'], 'STYLE_LINK'=>$slink, @@ -1947,7 +1954,7 @@ 'TEMPLATE_DIR'=>scriptPath.'/themes/'.$this->theme, 'THEME_ID'=>$this->theme, 'STYLE_ID'=>$this->style, - 'JS_DYNAMIC_VARS'=>'', + 'JS_DYNAMIC_VARS'=>'', 'SIDEBAR_RIGHT'=>'', ); $this->tpl_strings = array_merge($tpl_strings, $this->tpl_strings); @@ -1964,7 +1971,7 @@ } $p = $this->makeParserText($tplvars['sidebar_section']); $p->assign_vars(Array( - 'TITLE'=>'Installation progress', + 'TITLE'=>$lang->get('meta_sidebar_heading'), 'CONTENT'=>$sidebar, )); $sidebar = $p->run(); diff -r c671f3bb8aed -r a7d0f2711df1 install.php --- a/install.php Tue Nov 06 16:22:43 2007 -0500 +++ b/install.php Wed Nov 07 00:34:22 2007 -0500 @@ -25,6 +25,7 @@ define('IN_ENANO_INSTALL', 'true'); define('ENANO_VERSION', '1.1.1'); +define('ENANO_CODE_NAME', 'Germination'); // In beta versions, define ENANO_BETA_VERSION here // This is required to make installation work right @@ -65,14 +66,18 @@ require('includes/constants.php'); require('includes/rijndael.php'); require('includes/functions.php'); +require('includes/dbal.php'); +require('includes/lang.php'); +require('includes/json.php'); strip_magic_quotes_gpc(); -$neutral_color = 'C'; // // INSTALLER LIBRARY // +$neutral_color = 'C'; + function run_installer_stage($stage_id, $stage_name, $function, $failure_explanation, $allow_skip = true) { static $resumed = false; @@ -657,22 +662,37 @@ if($val) { if($cv) $color='CCFFCC'; else $color='AAFFAA'; - echo "$descTest passed"; + echo "$descTest passed"; } elseif(!$val && $warn) { if($cv) $color='FFFFCC'; else $color='FFFFAA'; - echo "$desc
$extended_descTest passed with warning"; + echo "$desc
$extended_descTest passed with warning"; $warned = true; } else { if($cv) $color='FFCCCC'; else $color='FFAAAA'; - echo "$desc
$extended_descTest failed"; + echo "$desc
$extended_descTest failed"; $failed = true; } } -function is_apache() { $r = strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? true : false; return $r; } +function is_apache() +{ + return strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') ? true : false; +} require_once('includes/template.php'); -if(!isset($_GET['mode'])) $_GET['mode'] = 'welcome'; +// +// Startup localization +// + +// We need $db just for the _die function +$db = new mysql(); + +$lang = new Language('eng'); +$lang->load_file('./language/english/install.json'); + +if ( !isset($_GET['mode']) ) + $_GET['mode'] = 'welcome'; + switch($_GET['mode']) { case 'mysql_test': @@ -802,6 +822,20 @@ EOF; exit; break; + case 'langjs': + header('Content-type: text/javascript'); + $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); + $lang_js = $json->encode($lang->strings); + // use EEOF here because jEdit misinterprets "typ'eof'" + echo <<load_theme('stpatty', 'shamrock', false); $modestrings = Array( - 'welcome' => 'Welcome', - 'license' => 'License Agreement', - 'sysreqs' => 'Server requirements', - 'database'=> 'Database information', - 'website' => 'Website configuration', - 'login' => 'Administration login', - 'confirm' => 'Confirm installation', - 'install' => 'Database installation', - 'finish' => 'Installation complete' + 'welcome' => $lang->get('welcome_modetitle'), + 'license' => $lang->get('license_modetitle'), + 'sysreqs' => $lang->get('sysreqs_modetitle'), + 'database'=> $lang->get('database_modetitle'), + 'website' => $lang->get('website_modetitle'), + 'login' => $lang->get('login_modetitle'), + 'confirm' => $lang->get('confirm_modetitle'), + 'install' => $lang->get('install_modetitle'), + 'finish' => $lang->get('finish_modetitle') ); $sideinfo = ''; @@ -852,6 +886,26 @@ exit; } +if ( defined('ENANO_IS_STABLE') ) + $branch = 'stable'; +else if ( defined('ENANO_IS_UNSTABLE') ) + $branch = 'unstable'; +else +{ + $version = explode('.', ENANO_VERSION); + if ( !isset($version[1]) ) + // unknown branch, really + $branch = 'unstable'; + else + { + $version[1] = intval($version[1]); + if ( $version[1] % 2 == 1 ) + $branch = 'unstable'; + else + $branch = 'stable'; + } +} + $template->header(); if(!isset($_GET['mode'])) $_GET['mode'] = 'license'; switch($_GET['mode']) @@ -861,63 +915,71 @@ ?>
[ Enano CMS Project logo ] -

Welcome to Enano

-

version 1.1.1 – unstable

+

get('welcome_heading'); ?>

+

+ get("welcome_branch_$branch"); + + $v_string = sprintf('%s %s – %s', $lang->get('welcome_version'), ENANO_VERSION, $branch_l); + echo $v_string; + ?> +

You are about to install a NIGHTLY BUILD of Enano.
Nightly builds are NOT upgradeable and may contain serious flaws, security problems, or extraneous debugging information. Installing this version of Enano on a production site is NOT recommended.
'; - } + if ( defined('ENANO_CODE_NAME') ) + { + echo '

'; + echo $lang->get('welcome_aka', array( + 'codename' => strtolower(ENANO_CODE_NAME) + )); + echo '

'; + } ?>
- +
-

Welcome to the Enano installer.

-

Thank you for choosing Enano as your CMS. You've selected the finest in design, the strongest in security, and the latest in Web 2.0 toys. Trust us, you'll like it.

-

To get started, please read and accept the following license agreement. You've probably seen it before.

+

get('license_heading'); ?>

+

get('license_blurb_thankyou'); ?>

+

get('license_blurb_pleaseread'); ?>

-

GNU General Public License

-

Declaration of license usage

-

Enano is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

-

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License (below) for more details.

-

By clicking the button below or otherwise continuing the installation, you indicate your acceptance of this license agreement.

-

Human-readable version

-

Enano is distributed under certain licensing terms that we believe make it of the greatest possible use to the public. The license we distribute it under, the GNU General Public License, provides certain terms and conditions that, rather than limit your use of Enano, allow you to get the most out of it. If you would like to read the full text, it can be found below. Here is a human-readable version that we think is a little easier to understand.

- -

You may exercise the freedoms specified here provided that you comply with the express conditions of this license. The principal conditions are:

- -

Disclaimer: The above text is not a license. It is simply a handy reference for understanding the Legal Code (the full license) – it is a human-readable expression of some of its key terms. Think of it as the user-friendly interface to the Legal Code beneath. The above text itself has no legal value, and its contents do not appear in the actual license.
Text copied from the Creative Commons GPL Deed page

-

Notice for prerelease versions

-

This version of Enano is designed only for testing and evaluation purposes. It is not yet completely stable, and should not be used on production websites. As with any Enano version, Dan Fuhry and the Enano team cannot be responsible for any damage, physical or otherwise, to any property as a result of the use of Enano. While security is a number one priority, sometimes things slip through.

+

get('license_info_unstable_title'); ?>

+

get('license_info_unstable_body'); ?>

-

Lawyer-readable version

+

get('license_section_gpl_heading'); ?>

+ lang_code != 'eng' ): ?> +

get('license_gpl_blurb_inenglish'); ?>

+