summaryrefslogtreecommitdiff
path: root/bin/striplangs.php
diff options
context:
space:
mode:
Diffstat (limited to 'bin/striplangs.php')
-rwxr-xr-xbin/striplangs.php45
1 files changed, 24 insertions, 21 deletions
diff --git a/bin/striplangs.php b/bin/striplangs.php
index 8567551ec..6335bc84c 100755
--- a/bin/striplangs.php
+++ b/bin/striplangs.php
@@ -1,10 +1,13 @@
#!/usr/bin/php
<?php
-if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__) . '/../') . '/');
+if(!defined('DOKU_INC')) define('DOKU_INC', realpath(dirname(__FILE__).'/../').'/');
define('NOSESSION', 1);
-require_once(DOKU_INC . 'inc/init.php');
+require_once(DOKU_INC.'inc/init.php');
+/**
+ * Remove unwanted languages from a DokuWiki install
+ */
class StripLangsCLI extends DokuCLI {
/**
@@ -16,19 +19,19 @@ class StripLangsCLI extends DokuCLI {
protected function setup(DokuCLI_Options $options) {
$options->setHelp(
- 'Remove all languages from the installation, besides the ones specified. English language ' .
- 'is never removed!'
+ 'Remove all languages from the installation, besides the ones specified. English language '.
+ 'is never removed!'
);
$options->registerOption(
- 'keep',
- 'Comma separated list of languages to keep in addition to English.',
- 'k'
+ 'keep',
+ 'Comma separated list of languages to keep in addition to English.',
+ 'k'
);
$options->registerOption(
- 'english-only',
- 'Remove all languages except English',
- 'e'
+ 'english-only',
+ 'Remove all languages except English',
+ 'e'
);
}
@@ -52,16 +55,16 @@ class StripLangsCLI extends DokuCLI {
}
// Kill all language directories in /inc/lang and /lib/plugins besides those in $langs array
- $this->stripDirLangs(realpath(dirname(__FILE__) . '/../inc/lang'), $keep);
- $this->processExtensions(realpath(dirname(__FILE__) . '/../lib/plugins'), $keep);
- $this->processExtensions(realpath(dirname(__FILE__) . '/../lib/tpl'), $keep);
+ $this->stripDirLangs(realpath(dirname(__FILE__).'/../inc/lang'), $keep);
+ $this->processExtensions(realpath(dirname(__FILE__).'/../lib/plugins'), $keep);
+ $this->processExtensions(realpath(dirname(__FILE__).'/../lib/tpl'), $keep);
}
/**
* Strip languages from extensions
*
- * @param string $path path to plugin or template dir
- * @param array $keep_langs languages to keep
+ * @param string $path path to plugin or template dir
+ * @param array $keep_langs languages to keep
*/
protected function processExtensions($path, $keep_langs) {
if(is_dir($path)) {
@@ -69,9 +72,9 @@ class StripLangsCLI extends DokuCLI {
foreach($entries as $entry) {
if($entry != "." && $entry != "..") {
- if(is_dir($path . '/' . $entry)) {
+ if(is_dir($path.'/'.$entry)) {
- $plugin_langs = $path . '/' . $entry . '/lang';
+ $plugin_langs = $path.'/'.$entry.'/lang';
if(is_dir($plugin_langs)) {
$this->stripDirLangs($plugin_langs, $keep_langs);
@@ -85,17 +88,17 @@ class StripLangsCLI extends DokuCLI {
/**
* Strip languages from path
*
- * @param string $path path to lang dir
- * @param array $keep_langs languages to keep
+ * @param string $path path to lang dir
+ * @param array $keep_langs languages to keep
*/
protected 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)) {
- io_rmdir($path . '/' . $cur_dir, true);
+ io_rmdir($path.'/'.$cur_dir, true);
}
}
}