[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-14419-g06bb1d9

Michal Čihař nijel at users.sourceforge.net
Thu Aug 11 11:58:01 CEST 2011


The branch, master has been updated
       via  06bb1d9e9ed7c9cec93852e9fca92c664e0caca7 (commit)
       via  ad488d9d1c1d771a7d4a7a87467502f85465a432 (commit)
      from  ac1d116c1ccf547e50f36dd622c47220a649c4e4 (commit)


- Log -----------------------------------------------------------------
commit 06bb1d9e9ed7c9cec93852e9fca92c664e0caca7
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 11 11:57:46 2011 +0200

    Convertor of advisor rules to PHP for gettext use

commit ad488d9d1c1d771a7d4a7a87467502f85465a432
Author: Michal Čihař <mcihar at suse.cz>
Date:   Thu Aug 11 11:56:55 2011 +0200

    Factor out justification splitting

-----------------------------------------------------------------------

Summary of changes:
 libraries/advisor.class.php |   16 ++++++++++++++--
 scripts/advisor2php         |   28 ++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+), 2 deletions(-)
 create mode 100644 scripts/advisor2php

diff --git a/libraries/advisor.class.php b/libraries/advisor.class.php
index df7178e..bea2aca 100644
--- a/libraries/advisor.class.php
+++ b/libraries/advisor.class.php
@@ -81,14 +81,26 @@ class Advisor
         return true;
     }
 
+    /**
+     * Splits justification to text and formula.
+     */
+    function splitJustification($rule)
+    {
+        $jst = preg_split('/\s*\|\s*/', $rule['justification'], 2);
+        if(count($jst) > 1) {
+            $jst[0] = preg_replace('/%( |,|\.|$)/','%%\1',$jst[0]);
+            return array($jst[0], $jst[1]);
+       }
+        return array($rule['justification']);
+    }
+
     // Adds a rule to the result list
     function addRule($type, $rule) {
         switch($type) {
             case 'notfired':
             case 'fired':
-                    $jst = preg_split('/\s*\|\s*/',$rule['justification'],2);
+                    $jst = Advisor::splitJustification($rule['justification']);
                     if(count($jst) > 1) {
-                        $jst[0] = preg_replace('/%( |,|\.|$)/','%%\1',$jst[0]);
                         try {
                             $str = $this->ruleExprEvaluate(
                                 'sprintf("'.$jst[0].'",'.$jst[1].')',
diff --git a/scripts/advisor2php b/scripts/advisor2php
new file mode 100644
index 0000000..5607f6e
--- /dev/null
+++ b/scripts/advisor2php
@@ -0,0 +1,28 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4 ft=php: */
+/**
+ * Script to parse advisor rules and output them as PHP code which can be used 
+ * by gettext for generating po(t) files.
+ */
+
+if (!file_exists('./libraries/advisor.class.php')) {
+    chdir('..');
+}
+include './libraries/advisor.class.php';
+
+$rules = Advisor::parseRulesFile();
+
+echo "<?php\n";
+echo "/* DO NOT EDIT! */\n";
+echo "/* This is automatically generated file from libraries/advisory_rules.txt */\n";
+
+foreach($rules['rules'] as $rule) {
+    echo "\n";
+    echo "echo __('" . $rule['name'] . "');\n";
+    echo "echo __('" . $rule['issue'] . "');\n";
+    echo "echo __('" . $rule['recommendation'] . "');\n";
+    $jst = Advisor::splitJustification($rule);
+    echo "echo __('" . $jst[0] . "');\n";
+}
+
+?>


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list