summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2014-05-16 09:11:15 +0200
committerAndreas Gohr <andi@splitbrain.org>2014-05-16 09:11:15 +0200
commit1c36b3d86f90185519cadaad85251922dc771fe1 (patch)
tree30701dd933a5c86f99bd3eb0ca9292a8fa65a3c8 /bin
parente82b082ef3300c5b2d8f03f74873ef31f0b57933 (diff)
downloadrpg-1c36b3d86f90185519cadaad85251922dc771fe1.tar.gz
rpg-1c36b3d86f90185519cadaad85251922dc771fe1.tar.bz2
code reformat
Diffstat (limited to 'bin')
-rwxr-xr-xbin/gittool.php84
-rwxr-xr-xbin/indexer.php25
-rwxr-xr-xbin/render.php18
-rwxr-xr-xbin/striplangs.php45
-rwxr-xr-xbin/wantedpages.php29
5 files changed, 105 insertions, 96 deletions
diff --git a/bin/gittool.php b/bin/gittool.php
index fca76768d..6944dde57 100755
--- a/bin/gittool.php
+++ b/bin/gittool.php
@@ -1,8 +1,8 @@
#!/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');
/**
* Easily manage DokuWiki git repositories
@@ -19,51 +19,51 @@ class GitToolCLI extends DokuCLI {
*/
protected function setup(DokuCLI_Options $options) {
$options->setHelp(
- "Manage git repositories for DokuWiki and its plugins and templates.\n\n" .
- "$> ./bin/gittool.php clone gallery template:ach\n" .
- "$> ./bin/gittool.php repos\n" .
- "$> ./bin/gittool.php origin -v"
+ "Manage git repositories for DokuWiki and its plugins and templates.\n\n".
+ "$> ./bin/gittool.php clone gallery template:ach\n".
+ "$> ./bin/gittool.php repos\n".
+ "$> ./bin/gittool.php origin -v"
);
$options->registerArgument(
- 'command',
- 'Command to execute. See below',
- true
+ 'command',
+ 'Command to execute. See below',
+ true
);
$options->registerCommand(
- 'clone',
- 'Tries to install a known plugin or template (prefix with template:) via git. Uses the DokuWiki.org ' .
- 'plugin repository to find the proper git repository. Multiple extensions can be given as parameters'
+ 'clone',
+ 'Tries to install a known plugin or template (prefix with template:) via git. Uses the DokuWiki.org '.
+ 'plugin repository to find the proper git repository. Multiple extensions can be given as parameters'
);
$options->registerArgument(
- 'extension',
- 'name of the extension to install, prefix with \'template:\' for templates',
- true,
- 'clone'
+ 'extension',
+ 'name of the extension to install, prefix with \'template:\' for templates',
+ true,
+ 'clone'
);
$options->registerCommand(
- 'install',
- 'The same as clone, but when no git source repository can be found, the extension is installed via ' .
- 'download'
+ 'install',
+ 'The same as clone, but when no git source repository can be found, the extension is installed via '.
+ 'download'
);
$options->registerArgument(
- 'extension',
- 'name of the extension to install, prefix with \'template:\' for templates',
- true,
- 'install'
+ 'extension',
+ 'name of the extension to install, prefix with \'template:\' for templates',
+ true,
+ 'install'
);
$options->registerCommand(
- 'repos',
- 'Lists all git repositories found in this DokuWiki installation'
+ 'repos',
+ 'Lists all git repositories found in this DokuWiki installation'
);
$options->registerCommand(
- '*',
- 'Any unknown commands are assumed to be arguments to git and will be executed in all repositories ' .
- 'found within this DokuWiki installation'
+ '*',
+ 'Any unknown commands are assumed to be arguments to git and will be executed in all repositories '.
+ 'found within this DokuWiki installation'
);
}
@@ -81,7 +81,7 @@ class GitToolCLI extends DokuCLI {
switch($command) {
case '':
- echo $options->help('foo');
+ echo $options->help();
break;
case 'clone':
$this->cmd_clone($options->args);
@@ -123,8 +123,8 @@ class GitToolCLI extends DokuCLI {
}
echo "\n";
- if($succeeded) $this->success('successfully cloned the following extensions: ' . join(', ', $succeeded));
- if($errors) $this->error('failed to clone the following extensions: ' . join(', ', $errors));
+ if($succeeded) $this->success('successfully cloned the following extensions: '.join(', ', $succeeded));
+ if($errors) $this->error('failed to clone the following extensions: '.join(', ', $errors));
}
/**
@@ -156,8 +156,8 @@ class GitToolCLI extends DokuCLI {
}
echo "\n";
- if($succeeded) $this->success('successfully installed the following extensions: ' . join(', ', $succeeded));
- if($errors) $this->error('failed to install the following extensions: ' . join(', ', $errors));
+ if($succeeded) $this->success('successfully installed the following extensions: '.join(', ', $succeeded));
+ if($errors) $this->error('failed to install the following extensions: '.join(', ', $errors));
}
/**
@@ -246,9 +246,9 @@ class GitToolCLI extends DokuCLI {
*/
private function cloneExtension($ext, $repo) {
if(substr($ext, 0, 9) == 'template:') {
- $target = fullpath(tpl_incdir() . '../' . substr($ext, 9));
+ $target = fullpath(tpl_incdir().'../'.substr($ext, 9));
} else {
- $target = DOKU_PLUGIN . $ext;
+ $target = DOKU_PLUGIN.$ext;
}
$this->info("cloning $ext from $repo to $target");
@@ -273,15 +273,15 @@ class GitToolCLI extends DokuCLI {
private function findRepos() {
$this->info('Looking for .git directories');
$data = array_merge(
- glob(DOKU_INC . '.git', GLOB_ONLYDIR),
- glob(DOKU_PLUGIN . '*/.git', GLOB_ONLYDIR),
- glob(fullpath(tpl_incdir() . '../') . '/*/.git', GLOB_ONLYDIR)
+ glob(DOKU_INC.'.git', GLOB_ONLYDIR),
+ glob(DOKU_PLUGIN.'*/.git', GLOB_ONLYDIR),
+ glob(fullpath(tpl_incdir().'../').'/*/.git', GLOB_ONLYDIR)
);
if(!$data) {
$this->error('Found no .git directories');
} else {
- $this->success('Found ' . count($data) . ' .git directories');
+ $this->success('Found '.count($data).' .git directories');
}
$data = array_map('fullpath', array_map('dirname', $data));
return $data;
@@ -306,7 +306,7 @@ class GitToolCLI extends DokuCLI {
if(preg_match('/github\.com\/([^\/]+)\/([^\/]+)/i', $repourl, $m)) {
$user = $m[1];
$repo = $m[2];
- return 'https://github.com/' . $user . '/' . $repo . '.git';
+ return 'https://github.com/'.$user.'/'.$repo.'.git';
}
// match gitorious repos
@@ -315,14 +315,14 @@ class GitToolCLI extends DokuCLI {
$repo = $m[2];
if(!$repo) $repo = $user;
- return 'https://git.gitorious.org/' . $user . '/' . $repo . '.git';
+ return 'https://git.gitorious.org/'.$user.'/'.$repo.'.git';
}
// match bitbucket repos - most people seem to use mercurial there though
if(preg_match('/bitbucket\.org\/([^\/]+)\/([^\/]+)/i', $repourl, $m)) {
$user = $m[1];
$repo = $m[2];
- return 'https://bitbucket.org/' . $user . '/' . $repo . '.git';
+ return 'https://bitbucket.org/'.$user.'/'.$repo.'.git';
}
return false;
diff --git a/bin/indexer.php b/bin/indexer.php
index 76269f95a..13895c36a 100755
--- a/bin/indexer.php
+++ b/bin/indexer.php
@@ -1,9 +1,12 @@
#!/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');
+/**
+ * Update the Search Index from command line
+ */
class IndexerCLI extends DokuCLI {
private $quiet = false;
@@ -17,19 +20,19 @@ class IndexerCLI extends DokuCLI {
*/
protected function setup(DokuCLI_Options $options) {
$options->setHelp(
- 'Updates the searchindex by indexing all new or changed pages. When the -c option is ' .
- 'given the index is cleared first.'
+ 'Updates the searchindex by indexing all new or changed pages. When the -c option is '.
+ 'given the index is cleared first.'
);
$options->registerOption(
- 'clear',
- 'clear the index before updating',
- 'c'
+ 'clear',
+ 'clear the index before updating',
+ 'c'
);
$options->registerOption(
- 'quiet',
- 'don\'t produce any output',
- 'q'
+ 'quiet',
+ 'don\'t produce any output',
+ 'q'
);
}
@@ -58,7 +61,7 @@ class IndexerCLI extends DokuCLI {
$data = array();
$this->quietecho("Searching pages... ");
search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true));
- $this->quietecho(count($data) . " pages found.\n");
+ $this->quietecho(count($data)." pages found.\n");
foreach($data as $val) {
$this->index($val['id']);
diff --git a/bin/render.php b/bin/render.php
index 01fd16cdd..672993223 100755
--- a/bin/render.php
+++ b/bin/render.php
@@ -1,8 +1,8 @@
#!/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');
/**
@@ -14,7 +14,7 @@ require_once(DOKU_INC . 'inc/init.php');
* DokuWiki markup
*
* @license GPL2
- * @author Andreas Gohr <andi@splitbrain.org>
+ * @author Andreas Gohr <andi@splitbrain.org>
*/
class RenderCLI extends DokuCLI {
@@ -26,11 +26,11 @@ class RenderCLI extends DokuCLI {
*/
protected function setup(DokuCLI_Options $options) {
$options->setHelp(
- 'A simple commandline tool to render some DokuWiki syntax with a given renderer.' .
- "\n\n" .
- 'This may not work for plugins that expect a certain environment to be ' .
- 'set up before rendering, but should work for most or even all standard ' .
- 'DokuWiki markup'
+ 'A simple commandline tool to render some DokuWiki syntax with a given renderer.'.
+ "\n\n".
+ 'This may not work for plugins that expect a certain environment to be '.
+ 'set up before rendering, but should work for most or even all standard '.
+ 'DokuWiki markup'
);
$options->registerOption('renderer', 'The renderer mode to use. Defaults to xhtml', 'r', 'mode');
}
@@ -49,7 +49,7 @@ class RenderCLI extends DokuCLI {
// do the action
$source = stream_get_contents(STDIN);
- $info = array();
+ $info = array();
$result = p_render($renderer, p_get_instructions($source), $info);
if(is_null($result)) throw new DokuCLI_Exception("No such renderer $renderer");
echo $result;
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);
}
}
}
diff --git a/bin/wantedpages.php b/bin/wantedpages.php
index 879291957..8fc4ba74f 100755
--- a/bin/wantedpages.php
+++ b/bin/wantedpages.php
@@ -1,9 +1,12 @@
#!/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');
+/**
+ * Find wanted pages
+ */
class WantedPagesCLI extends DokuCLI {
const DIR_CONTINUE = 1;
@@ -18,12 +21,12 @@ class WantedPagesCLI extends DokuCLI {
*/
protected function setup(DokuCLI_Options $options) {
$options->setHelp(
- 'Outputs a list of wanted pages (pages which have internal links but do not yet exist).'
+ 'Outputs a list of wanted pages (pages which have internal links but do not yet exist).'
);
$options->registerArgument(
- 'namespace',
- 'The namespace to lookup. Defaults to root namespace',
- false
+ 'namespace',
+ 'The namespace to lookup. Defaults to root namespace',
+ false
);
}
@@ -38,7 +41,7 @@ class WantedPagesCLI extends DokuCLI {
protected function main(DokuCLI_Options $options) {
if($options->args) {
- $startdir = dirname(wikiFN($options->args[0] . ':xxx'));
+ $startdir = dirname(wikiFN($options->args[0].':xxx'));
} else {
$startdir = dirname(wikiFN('xxx'));
}
@@ -54,7 +57,7 @@ class WantedPagesCLI extends DokuCLI {
sort($wanted_pages);
foreach($wanted_pages as $page) {
- print $page . "\n";
+ print $page."\n";
}
}
@@ -62,7 +65,7 @@ class WantedPagesCLI extends DokuCLI {
if($entry == '.' || $entry == '..') {
return WantedPagesCLI::DIR_CONTINUE;
}
- if(is_dir($basepath . '/' . $entry)) {
+ if(is_dir($basepath.'/'.$entry)) {
if(strpos($entry, '_') === 0) {
return WantedPagesCLI::DIR_CONTINUE;
}
@@ -78,7 +81,7 @@ class WantedPagesCLI extends DokuCLI {
static $trunclen = null;
if(!$trunclen) {
global $conf;
- $trunclen = strlen($conf['datadir'] . ':');
+ $trunclen = strlen($conf['datadir'].':');
}
if(!is_dir($dir)) {
@@ -92,11 +95,11 @@ class WantedPagesCLI extends DokuCLI {
if($status == WantedPagesCLI::DIR_CONTINUE) {
continue;
} else if($status == WantedPagesCLI::DIR_NS) {
- $pages = array_merge($pages, $this->get_pages($dir . '/' . $entry));
+ $pages = array_merge($pages, $this->get_pages($dir.'/'.$entry));
} else {
$page = array(
- 'id' => pathID(substr($dir . '/' . $entry, $trunclen)),
- 'file' => $dir . '/' . $entry,
+ 'id' => pathID(substr($dir.'/'.$entry, $trunclen)),
+ 'file' => $dir.'/'.$entry,
);
$pages[] = $page;
}