Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/turnermm/dokuwiki into pull…
Browse files Browse the repository at this point in the history
…-request-2044

* 'master' of git://github.com/turnermm/dokuwiki:
  using $options->getCmd to retrieve show-pages parameter
  added option to wantedpages.php to show or not show pages where broken links occur
  show pages where broken links occur: page_id => broken_link
  • Loading branch information
splitbrain committed Jul 28, 2017
2 parents c6162b5 + 964efa9 commit ebd3919
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions bin/wantedpages.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class WantedPagesCLI extends DokuCLI {
const DIR_CONTINUE = 1;
const DIR_NS = 2;
const DIR_PAGE = 3;

private $show_pages = false;
/**
* Register options and arguments on the given $options object
*
Expand All @@ -28,6 +28,11 @@ protected function setup(DokuCLI_Options $options) {
'The namespace to lookup. Defaults to root namespace',
false
);
$options->registerCommand(
'show-pages',
'Show wiki pages on which broken links (i.e. wanted pages) are found, listed as: wiki_page=>broken_link'
);

}

/**
Expand All @@ -45,6 +50,11 @@ protected function main(DokuCLI_Options $options) {
} else {
$startdir = dirname(wikiFN('xxx'));
}

$cmd = $options->getCmd();
if($cmd == 'show-pages') {
$this->show_pages = true;
}

$this->info("searching $startdir");

Expand Down Expand Up @@ -134,13 +144,17 @@ function internal_links($page) {
$links = array();
$cns = getNS($page['id']);
$exists = false;
$pid = $page['id'];
foreach($instructions as $ins) {
if($ins[0] == 'internallink' || ($conf['camelcase'] && $ins[0] == 'camelcaselink')) {
$mid = $ins[1][0];
resolve_pageid($cns, $mid, $exists);
if(!$exists) {
list($mid) = explode('#', $mid); //record pages without hashs
$links[] = $mid;
if($this->show_pages) {
$links[] = "$pid => $mid";
}
else $links[] = $mid;
}
}
}
Expand Down

0 comments on commit ebd3919

Please sign in to comment.