]> git.sur5r.net Git - bacula/bacula/commitdiff
bacula-web: New folder utils
authorDavide Franco <bacula-dev@dflc.ch>
Mon, 29 Nov 2010 10:25:41 +0000 (11:25 +0100)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:39:41 +0000 (14:39 +0200)
 - Moved tsmarty2c.php into utils folder

gui/bacula-web/tsmarty2c.php [deleted file]
gui/bacula-web/utils/tsmarty2c.php [new file with mode: 0755]

diff --git a/gui/bacula-web/tsmarty2c.php b/gui/bacula-web/tsmarty2c.php
deleted file mode 100755 (executable)
index 32cb89f..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/usr/bin/php -qn
-<?php
-/**
- * tsmarty2c.php - rips gettext strings from smarty template
- *
- * ------------------------------------------------------------------------- *
- * This library is free software; you can redistribute it and/or             *
- * modify it under the terms of the GNU Lesser General Public                *
- * License as published by the Free Software Foundation; either              *
- * version 2.1 of the License, or (at your option) any later version.        *
- *                                                                           *
- * This library 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         *
- * Lesser General Public License for more details.                           *
- *                                                                           *
- * You should have received a copy of the GNU Lesser General Public          *
- * License along with this library; if not, write to the Free Software       *
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *
- * ------------------------------------------------------------------------- *
- *
- * This command line script rips gettext strings from smarty file, and prints them to stdout in C format, 
- * that can later be used with the standard gettext tools.
- *
- * Usage:
- * ./tsmarty2c.php <filename or directory> <file2> <..> > smarty.c
- *
- * If a parameter is a directory, the template files within will be parsed.
- *
- * @package    smarty_gettext
- * @version    0.9
- * @link       http://www.boom.org.il/smarty/gettext/
- * @author     Sagi Bashari <sagi@boom.org.il>
- * @copyright 2004 Sagi Bashari
- */
-
-// smarty open tag
-$ldq = preg_quote('{');
-
-// smarty close tag
-$rdq = preg_quote('}');
-
-// smarty command
-$cmd = preg_quote('t');
-
-// extensions of smarty files, used when going through a directory
-$extensions = array('tpl');
-
-// "fix" string - strip slashes, escape and convert new lines to \n
-function fs($str)
-{
-       $str = stripslashes($str);
-       $str = str_replace('"', '\"', $str);
-       $str = str_replace("\n", '\n', $str);
-       return $str;
-}
-
-// rips gettext strings from $file and prints them in C format
-function do_file($file)
-{
-       $content = @file_get_contents($file);
-
-       if (empty($content)) {
-               return;
-       }
-
-       global $ldq, $rdq, $cmd;
-
-       preg_match_all("/{$ldq}\s*({$cmd})\s*([^{$rdq}]*){$rdq}([^{$ldq}]*){$ldq}\/\\1{$rdq}/", $content, $matches);
-       
-       for ($i=0; $i < count($matches[0]); $i++) {
-               if (preg_match('/plural\s*=\s*["\']?\s*(.[^\"\']*)\s*["\']?/', $matches[2][$i], $match)) {
-                       print 'ngettext("'.fs($matches[3][$i]).'","'.fs($match[1]).'",x);'."\n";
-               } else {
-                       print 'gettext("'.fs($matches[3][$i]).'");'."\n";
-               }
-       }
-}
-
-// go through a directory
-function do_dir($dir)
-{
-       $d = dir($dir);
-
-       while (false !== ($entry = $d->read())) {
-               if ($entry == '.' || $entry == '..') {
-                       continue;
-               }
-
-               $entry = $dir.'/'.$entry;
-
-               if (is_dir($entry)) { // if a directory, go through it
-                       do_dir($entry);
-               } else { // if file, parse only if extension is matched
-                       $pi = pathinfo($entry);
-                       
-                       if (in_array($pi['extension'], $GLOBALS['extensions'])) {
-                               do_file($entry);
-                       }
-               }
-       }
-
-       $d->close();
-}
-
-for ($ac=1; $ac < $_SERVER['argc']; $ac++) {
-       if (is_dir($_SERVER['argv'][$ac])) { // go through directory
-               do_dir($_SERVER['argv'][$ac]);
-       } else { // do file
-               do_file($_SERVER['argv'][$ac]);
-       }
-}
-
-?>
diff --git a/gui/bacula-web/utils/tsmarty2c.php b/gui/bacula-web/utils/tsmarty2c.php
new file mode 100755 (executable)
index 0000000..32cb89f
--- /dev/null
@@ -0,0 +1,114 @@
+#!/usr/bin/php -qn
+<?php
+/**
+ * tsmarty2c.php - rips gettext strings from smarty template
+ *
+ * ------------------------------------------------------------------------- *
+ * This library is free software; you can redistribute it and/or             *
+ * modify it under the terms of the GNU Lesser General Public                *
+ * License as published by the Free Software Foundation; either              *
+ * version 2.1 of the License, or (at your option) any later version.        *
+ *                                                                           *
+ * This library 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         *
+ * Lesser General Public License for more details.                           *
+ *                                                                           *
+ * You should have received a copy of the GNU Lesser General Public          *
+ * License along with this library; if not, write to the Free Software       *
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA *
+ * ------------------------------------------------------------------------- *
+ *
+ * This command line script rips gettext strings from smarty file, and prints them to stdout in C format, 
+ * that can later be used with the standard gettext tools.
+ *
+ * Usage:
+ * ./tsmarty2c.php <filename or directory> <file2> <..> > smarty.c
+ *
+ * If a parameter is a directory, the template files within will be parsed.
+ *
+ * @package    smarty_gettext
+ * @version    0.9
+ * @link       http://www.boom.org.il/smarty/gettext/
+ * @author     Sagi Bashari <sagi@boom.org.il>
+ * @copyright 2004 Sagi Bashari
+ */
+
+// smarty open tag
+$ldq = preg_quote('{');
+
+// smarty close tag
+$rdq = preg_quote('}');
+
+// smarty command
+$cmd = preg_quote('t');
+
+// extensions of smarty files, used when going through a directory
+$extensions = array('tpl');
+
+// "fix" string - strip slashes, escape and convert new lines to \n
+function fs($str)
+{
+       $str = stripslashes($str);
+       $str = str_replace('"', '\"', $str);
+       $str = str_replace("\n", '\n', $str);
+       return $str;
+}
+
+// rips gettext strings from $file and prints them in C format
+function do_file($file)
+{
+       $content = @file_get_contents($file);
+
+       if (empty($content)) {
+               return;
+       }
+
+       global $ldq, $rdq, $cmd;
+
+       preg_match_all("/{$ldq}\s*({$cmd})\s*([^{$rdq}]*){$rdq}([^{$ldq}]*){$ldq}\/\\1{$rdq}/", $content, $matches);
+       
+       for ($i=0; $i < count($matches[0]); $i++) {
+               if (preg_match('/plural\s*=\s*["\']?\s*(.[^\"\']*)\s*["\']?/', $matches[2][$i], $match)) {
+                       print 'ngettext("'.fs($matches[3][$i]).'","'.fs($match[1]).'",x);'."\n";
+               } else {
+                       print 'gettext("'.fs($matches[3][$i]).'");'."\n";
+               }
+       }
+}
+
+// go through a directory
+function do_dir($dir)
+{
+       $d = dir($dir);
+
+       while (false !== ($entry = $d->read())) {
+               if ($entry == '.' || $entry == '..') {
+                       continue;
+               }
+
+               $entry = $dir.'/'.$entry;
+
+               if (is_dir($entry)) { // if a directory, go through it
+                       do_dir($entry);
+               } else { // if file, parse only if extension is matched
+                       $pi = pathinfo($entry);
+                       
+                       if (in_array($pi['extension'], $GLOBALS['extensions'])) {
+                               do_file($entry);
+                       }
+               }
+       }
+
+       $d->close();
+}
+
+for ($ac=1; $ac < $_SERVER['argc']; $ac++) {
+       if (is_dir($_SERVER['argv'][$ac])) { // go through directory
+               do_dir($_SERVER['argv'][$ac]);
+       } else { // do file
+               do_file($_SERVER['argv'][$ac]);
+       }
+}
+
+?>