summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2010-11-29 20:41:17 +0100
committerAndreas Gohr <andi@splitbrain.org>2010-11-29 20:41:17 +0100
commit79e197ef89cfb21cb763883243e6338d92ab28c7 (patch)
tree435001693dea8d368888bcf98d5f9dee0a3bfe2e /bin
parentc0470665eec5d52d0e7da72e5ba8fd76b931247d (diff)
downloadrpg-79e197ef89cfb21cb763883243e6338d92ab28c7.tar.gz
rpg-79e197ef89cfb21cb763883243e6338d92ab28c7.tar.bz2
use forward slashes as path separator in striplangs.php
Diffstat (limited to 'bin')
-rw-r--r--bin/striplangs.php43
1 files changed, 24 insertions, 19 deletions
diff --git a/bin/striplangs.php b/bin/striplangs.php
index a53fe580f..288859c6a 100644
--- a/bin/striplangs.php
+++ b/bin/striplangs.php
@@ -1,5 +1,10 @@
#!/usr/bin/php
<?php
+/**
+ * Strip unwanted languages from the DokuWiki install
+ *
+ * @author Martin 'E.T.' Misuth <et.github@ethome.sk>
+ */
if ('cli' != php_sapi_name()) die();
#------------------------------------------------------------------------------
@@ -16,20 +21,20 @@ function usage($show_examples = false) {
OPTIONS
-h, --help get this help
-x, --examples get also usage examples
- -k, --keep comma separated list of languages, -e is always implied
+ -k, --keep comma separated list of languages, -e is always implied
-e, --english keeps english, dummy to use without -k";
if ( $show_examples ) {
print "\n
EXAMPLES
- Strips all languages, but keeps 'en' and 'de':
+ Strips all languages, but keeps 'en' and 'de':
striplangs -k de
Strips all but 'en','ca-valencia','cs','de','is','sk':
striplangs --keep ca-valencia,cs,de,is,sk
-
+
Strips all but 'en':
striplangs -e
-
+
No option specified, prints usage and throws error:
striplangs\n";
}
@@ -49,16 +54,16 @@ function processPlugins($path, $keep_langs) {
foreach ($entries as $entry) {
if ($entry != "." && $entry != "..") {
- if ( is_dir($path.'\\'.$entry) ) {
-
- $plugin_langs = $path.'\\'.$entry.'\\lang';
-
+ if ( is_dir($path.'/'.$entry) ) {
+
+ $plugin_langs = $path.'/'.$entry.'/lang';
+
if ( is_dir( $plugin_langs ) ) {
stripDirLangs($plugin_langs, $keep_langs);
}
}
}
- }
+ }
}
}
@@ -66,15 +71,15 @@ function stripDirLangs($path, $keep_langs) {
$dir = dir($path);
while(($cur_dir = $dir->read()) !== false) {
- if( $cur_dir != '.' and $cur_dir != '..' and is_dir($path.'\\'.$cur_dir)) {
+ if( $cur_dir != '.' and $cur_dir != '..' and is_dir($path.'/'.$cur_dir)) {
if ( !in_array($cur_dir, $keep_langs, true ) ) {
- killDir($path.'\\'.$cur_dir);
+ killDir($path.'/'.$cur_dir);
}
}
}
$dir->close();
-}
+}
function killDir($dir) {
if (is_dir($dir)) {
@@ -82,13 +87,13 @@ function killDir($dir) {
foreach ($entries as $entry) {
if ($entry != "." && $entry != "..") {
- if ( is_dir($dir.'\\'.$entry) ) {
- killDir($dir.'\\'.$entry);
+ if ( is_dir($dir.'/'.$entry) ) {
+ killDir($dir.'/'.$entry);
} else {
- unlink($dir.'\\'.$entry);
+ unlink($dir.'/'.$entry);
}
}
- }
+ }
reset($entries);
rmdir($dir);
}
@@ -119,11 +124,11 @@ if ( $OPTS->has('h') or $OPTS->has('help') ) {
if ( $OPTS->has('k') or $OPTS->has('keep') ) {
$preserved_langs = getSuppliedArgument($OPTS,'k','keep');
$langs = explode(',', $preserved_langs);
-
+
// ! always enforce 'en' lang when using '--keep' (DW relies on it)
if ( !isset($langs['en']) ) {
$langs[]='en';
- }
+ }
} elseif ( $OPTS->has('e') or $OPTS->has('english') ) {
// '--english' was specified strip everything besides 'en'
$langs = array ('en');
@@ -140,4 +145,4 @@ if ( $OPTS->has('k') or $OPTS->has('keep') ) {
// Kill all language directories in /inc/lang and /lib/plugins besides those in $langs array
stripDirLangs(realpath(dirname(__FILE__).'/../inc/lang'), $langs);
-processPlugins(realpath(dirname(__FILE__).'/../lib/plugins'), $langs); \ No newline at end of file
+processPlugins(realpath(dirname(__FILE__).'/../lib/plugins'), $langs);