svn: /web/doc-editor/trunk/ js/login.js php/ExtJsController.php php/RepositoryManager.php php/TranslationStatistic.php php/TranslatorStatistic.php scripts/cron/check_build.php

[email protected] (Yannick Torres)
Newsgroups php.doc.web
Message-ID <[email protected]>
yannick                                  Sat, 19 Dec 2009 12:12:04 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=292328

Log:
Extract all language from login.js to RepositoryManager to make it reusable later

Changed paths:
    U   web/doc-editor/trunk/js/login.js
    U   web/doc-editor/trunk/php/ExtJsController.php
    U   web/doc-editor/trunk/php/RepositoryManager.php
    U   web/doc-editor/trunk/php/TranslationStatistic.php
    U   web/doc-editor/trunk/php/TranslatorStatistic.php
    U   web/doc-editor/trunk/scripts/cron/check_build.php
svn-diffs-292328.txt (text/x-diff, 12 KB)
Modified: web/doc-editor/trunk/js/login.js
===================================================================
--- web/doc-editor/trunk/js/login.js	2009-12-19 12:05:56 UTC (rev 292327)
+++ web/doc-editor/trunk/js/login.js	2009-12-19 12:12:04 UTC (rev 292328)
@@ -5,8 +5,36 @@

     return {

+        storeLang : '',
+
         init : function()
         {
+            // Load all available language
+            this.storeLang = new Ext.data.Store({
+                autoLoad : true,
+                proxy    : new Ext.data.HttpProxy({
+                    url : './do/getAvailableLanguage'
+                }),
+                reader   : new Ext.data.JsonReader(
+                    {
+                        root          : 'Items',
+                        totalProperty : 'nbItems',
+                        id            : 'code'
+                    }, Ext.data.Record.create([
+                        {
+                            name    : 'code',
+                            mapping : 'code'
+                        }, {
+                            name    : 'iconCls',
+                            mapping : 'iconCls'
+                        }, {
+                            name    : 'name',
+                            mapping : 'name'
+                        }
+                    ])
+                )
+            });
+
             this.drawForm();
         },

@@ -84,52 +112,16 @@
                             xtype      : 'combo',
                             width      : 235,
                             fieldLabel : 'Translate module',
-                            store      : new Ext.data.SimpleStore({
-                                fields : ['countryCode', 'countryName', 'countryFlag'],
-                                data   : [
-                                    ['ar', 'Arabic', 'flag-ar'],
-                                    ['pt_BR', 'Brazilian Portuguese', 'flag-pt_BR'],
-                                    ['bg', 'Bulgarian', 'flag-bg'],
-                                    ['zh', 'Chinese (Simplified)', 'flag-zh'],
-                                    ['hk', 'Chinese (Hong Kong Cantonese)', 'flag-hk'],
-                                    ['tw', 'Chinese (Traditional)', 'flag-tw'],
-                                    ['cs', 'Czech', 'flag-cs'],
-                                    ['da', 'Danish', 'flag-da'],
-                                    ['nl', 'Dutch', 'flag-nl'],
-                                    ['en', 'English', 'flag-en'],
-                                    ['fi', 'Finnish', 'flag-fi'],
-                                    ['fr', 'French', 'flag-fr'],
-                                    ['de', 'Germany', 'flag-de'],
-                                    ['el', 'Greek', 'flag-el'],
-                                    ['he', 'Hebrew', 'flag-he'],
-                                    ['hu', 'Hungarian', 'flag-hu'],
-                                    ['it', 'Italian', 'flag-it'],
-                                    ['ja', 'Japanese', 'flag-ja'],
-                                    ['kr', 'Korean', 'flag-kr'],
-                                    ['no', 'Norwegian', 'flag-no'],
-                                    ['fa', 'Persian', 'flag-fa'],
-                                    ['pl', 'Polish', 'flag-pl'],
-                                    ['pt', 'Portuguese', 'flag-pt'],
-                                    ['ro', 'Romanian', 'flag-ro'],
-                                    ['ru', 'Russian', 'flag-ru'],
-                                    ['se', 'Serbian', 'flag-se'],
-                                    ['sk', 'Slovak', 'flag-sk'],
-                                    ['sl', 'Slovenian', 'flag-sl'],
-                                    ['es', 'Spanish', 'flag-es'],
-                                    ['sv', 'Swedish', 'flag-fi'],
-                                    ['tr', 'Turkish', 'flag-tr']
-                                ]
-                            }),
+                            store      : this.storeLang,
                             plugins       : new Ext.ux.plugins.IconCombo(),
-                            valueField    : 'countryCode',
+                            valueField    : 'code',
                             listWidth     : 235,
                             maxHeight     : 150,
                             editable      : true,
-                            value         : 'ar',
                             id            : 'login-form-lang',
                             name          : 'langDisplay',
-                            displayField  : 'countryName',
-                            iconClsField  : 'countryFlag',
+                            displayField  : 'name',
+                            iconClsField  : 'iconCls',
                             triggerAction : 'all',
                             mode          : 'local'
                         }]

Modified: web/doc-editor/trunk/php/ExtJsController.php
===================================================================
--- web/doc-editor/trunk/php/ExtJsController.php	2009-12-19 12:05:56 UTC (rev 292327)
+++ web/doc-editor/trunk/php/ExtJsController.php	2009-12-19 12:12:04 UTC (rev 292328)
@@ -118,6 +118,23 @@
     }

     /**
+     * Get all available language
+     */
+    public function getAvailableLanguage()
+    {
+
+        $r = RepositoryManager::getInstance()->getAvailableLanguage();
+
+        return JsonResponseBuilder::success(
+            array(
+                'nbItems' => count($r),
+                'Items'   => $r
+            )
+        );
+
+    }
+
+    /**
      * Apply all tools on the documentation
      */
     public function applyTools()

Modified: web/doc-editor/trunk/php/RepositoryManager.php
===================================================================
--- web/doc-editor/trunk/php/RepositoryManager.php	2009-12-19 12:05:56 UTC (rev 292327)
+++ web/doc-editor/trunk/php/RepositoryManager.php	2009-12-19 12:12:04 UTC (rev 292328)
@@ -22,18 +22,48 @@
     }

     public $availableLang = array(
-        'ar', 'bg', 'zh', 'hk','pt_BR',
-        'tw', 'cs', 'da', 'nl', 'fi',
-        'fr', 'de', 'el', 'he', 'hu',
-        'it', 'ja', 'kr', 'no', 'fa',
-        'pl', 'pt', 'ro', 'ru', 'se',
-        'sk', 'sl', 'es', 'sv', 'tr'
+         0 => Array('code' => 'ar',    'iconCls' => 'flag-ar',    'name' => 'Arabic'),
+         1 => Array('code' => 'pt_BR', 'iconCls' => 'flag-pt_BR', 'name' => 'Brazilian Portuguese'),
+         2 => Array('code' => 'bg',    'iconCls' => 'flag-bg',    'name' => 'Bulgarian'),
+         3 => Array('code' => 'zh',    'iconCls' => 'flag-zh',    'name' => 'Chinese (Simplified)'),
+         4 => Array('code' => 'hk',    'iconCls' => 'flag-hk',    'name' => 'Chinese (Hong Kong Cantonese)'),
+         5 => Array('code' => 'tw',    'iconCls' => 'flag-tw',    'name' => 'Chinese (Traditional)'),
+         6 => Array('code' => 'cs',    'iconCls' => 'flag-cs',    'name' => 'Czech'),
+         7 => Array('code' => 'da',    'iconCls' => 'flag-da',    'name' => 'Danish'),
+         8 => Array('code' => 'nl',    'iconCls' => 'flag-nl',    'name' => 'Dutch'),
+         9 => Array('code' => 'en',    'iconCls' => 'flag-en',    'name' => 'English'),
+        10 => Array('code' => 'fi',    'iconCls' => 'flag-fi',    'name' => 'Finnish'),
+        11 => Array('code' => 'fr',    'iconCls' => 'flag-fr',    'name' => 'French'),
+        12 => Array('code' => 'de',    'iconCls' => 'flag-de',    'name' => 'Germany'),
+        13 => Array('code' => 'el',    'iconCls' => 'flag-el',    'name' => 'Greek'),
+        14 => Array('code' => 'he',    'iconCls' => 'flag-he',    'name' => 'Hebrew'),
+        15 => Array('code' => 'hu',    'iconCls' => 'flag-hu',    'name' => 'Hungarian'),
+        16 => Array('code' => 'it',    'iconCls' => 'flag-it',    'name' => 'Italian'),
+        17 => Array('code' => 'ja',    'iconCls' => 'flag-ja',    'name' => 'Japanese'),
+        18 => Array('code' => 'kr',    'iconCls' => 'flag-kr',    'name' => 'Korean'),
+        19 => Array('code' => 'no',    'iconCls' => 'flag-no',    'name' => 'Norwegian'),
+        20 => Array('code' => 'fa',    'iconCls' => 'flag-fa',    'name' => 'Persian'),
+        21 => Array('code' => 'pl',    'iconCls' => 'flag-pl',    'name' => 'Polish'),
+        22 => Array('code' => 'pt',    'iconCls' => 'flag-pt',    'name' => 'Portuguese'),
+        23 => Array('code' => 'ro',    'iconCls' => 'flag-ro',    'name' => 'Romanian'),
+        24 => Array('code' => 'ru',    'iconCls' => 'flag-ru',    'name' => 'Russian'),
+        25 => Array('code' => 'se',    'iconCls' => 'flag-se',    'name' => 'Serbian'),
+        26 => Array('code' => 'sk',    'iconCls' => 'flag-sk',    'name' => 'Slovak'),
+        27 => Array('code' => 'sl',    'iconCls' => 'flag-sl',    'name' => 'Slovenian'),
+        28 => Array('code' => 'es',    'iconCls' => 'flag-es',    'name' => 'Spanish'),
+        29 => Array('code' => 'sv',    'iconCls' => 'flag-fi',    'name' => 'Swedish'),
+        30 => Array('code' => 'tr',    'iconCls' => 'flag-tr',    'name' => 'Turkish')
     );

     private function __construct()
     {
     }

+    public function getAvailableLanguage()
+    {
+        return $this->availableLang;
+    }
+
     /**
      * Checkout the phpdoc-all repository.
      * This method must be call ONLY by the /firstRun.php script.
@@ -587,6 +617,8 @@

         foreach ($this->availableLang as $lang) {

+            $lang = $lang["code"];
+
             // Path to find translation.xml file, set default values,
             // in case we can't find the translation file
             $translation_xml = new File($lang, '/', 'translation.xml');
@@ -673,7 +705,7 @@
     public function updateNotInEN()
     {
         foreach ($this->availableLang as $lang) {
-            $this->doUpdateNotInEN('/', $lang);
+            $this->doUpdateNotInEN('/', $lang["code"]);
         }
     }
     /**
@@ -786,6 +818,8 @@

                 foreach($this->availableLang as $lang) {

+                    $lang = $lang["code"];
+
                     $lang_file = new File($lang, $f->path, $f->name);

                     if (is_file($lang_file->full_path)) {

Modified: web/doc-editor/trunk/php/TranslationStatistic.php
===================================================================
--- web/doc-editor/trunk/php/TranslationStatistic.php	2009-12-19 12:05:56 UTC (rev 292327)
+++ web/doc-editor/trunk/php/TranslationStatistic.php	2009-12-19 12:12:04 UTC (rev 292328)
@@ -208,11 +208,13 @@
         if( $lang == 'all' ) {
             $hereLang = RepositoryManager::getInstance()->availableLang;
         } else {
-            $hereLang = array($lang);
+            $hereLang = array(0 => Array("code" => $lang));
         }

         foreach( $hereLang as $lang ) {

+            $lang = $lang["code"];
+
             $summary = array();

             $summary[0]['id']            = 1;

Modified: web/doc-editor/trunk/php/TranslatorStatistic.php
===================================================================
--- web/doc-editor/trunk/php/TranslatorStatistic.php	2009-12-19 12:05:56 UTC (rev 292327)
+++ web/doc-editor/trunk/php/TranslatorStatistic.php	2009-12-19 12:12:04 UTC (rev 292328)
@@ -148,11 +148,13 @@
         if( $lang == 'all' ) {
             $hereLang = RepositoryManager::getInstance()->availableLang;
         } else {
-            $hereLang = array($lang);
+            $hereLang = array(0 => Array("code" => $lang));
         }

         foreach( $hereLang as $lang ) {

+            $lang = $lang["code"];
+
             $i=0; $persons=array();
             foreach ($translators[$lang] as $nick => $data) {
                 $persons[$i]              = $data;

Modified: web/doc-editor/trunk/scripts/cron/check_build.php
===================================================================
--- web/doc-editor/trunk/scripts/cron/check_build.php	2009-12-19 12:05:56 UTC (rev 292327)
+++ web/doc-editor/trunk/scripts/cron/check_build.php	2009-12-19 12:12:04 UTC (rev 292328)
@@ -18,6 +18,8 @@
 // For all language, we check the build
 foreach (RepositoryManager::getInstance()->availableLang as $lang) {

+    $lang = $lang["code"];
+
     $return = RepositoryManager::getInstance()->checkBuild($lang);

     // What we must do when the build failed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.