Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
912bd30
Restructuring / added helper.php
Jul 3, 2012
40a52fb
Support for non-Latin letters
Jul 3, 2012
5148580
Prevent caching of pages where the plugin is active
Jul 3, 2012
281aa16
Removed obsolete comments
Jul 3, 2012
3f38e4f
Fixed issue with code and file blocks
Nov 11, 2012
f2ca838
Merge pull request #2 from ilium007/master
Nov 11, 2012
16ddee6
helper.php: Removed superseded JS function svchk() / Closes #5
Nov 25, 2012
032e374
Skip the "Links" column inside the orphaned pages table (Closes #4)
Nov 25, 2012
9eba54f
Update plugin.info.txt
Nov 25, 2012
92a5ff7
Merge HEAD, branch 'master' of github.com:lupo49/dokuwiki-plugin-orph…
Dec 5, 2012
736de08
Use DokuWikis debug setting ($conf['allowdebug']) for debug outputs
Dec 5, 2012
81cf0f2
Added Configuration Manager option to ignore pages in every output
Dec 5, 2012
d5d9d3f
Updated version info
Dec 5, 2012
eb2732b
added PLUGIN_ORPHANS_WANTED_PROCESS_PAGE event
Mar 11, 2013
8af890f
Merge pull request #10 from dom-mel/master
Mar 29, 2013
70a5486
Strip parameters from found links
RockyRoad29 Feb 12, 2014
eaa1782
Fixed whitespace
Sep 2, 2015
9577bab
Fixed compatability with DokuWiki_Syntax_Plugin::handle() and DokuWik…
Sep 2, 2015
2acfc1d
Check if LINK_PATTERN constant is already defined
Sep 7, 2015
f315874
Whitespace
Sep 7, 2015
b74237a
Get namespace with getNS instead of $ns
Sep 7, 2015
a242594
Adjust method signatures to match parent
splitbrain Feb 2, 2016
b371762
Added ignored patterns and fixed case-insensitive patterns
jaller94 Mar 5, 2016
71fd22b
Merge pull request #25 from splitbrain-forks/php7-signature
Mar 5, 2016
c7889fd
Fixed detection of blocks starting with 2 spaces or a tab
jaller94 Mar 7, 2016
acf5084
Merge pull request #27 from jaller94/master
jaller94 Mar 7, 2016
6a6667a
Merge pull request #22 from mariusvw/master
jaller94 Mar 7, 2016
d5c6447
Merge pull request #16 from RockyRoad29/master
jaller94 Mar 7, 2016
ef15339
Fix false wanted of implied start pages like [[wiki:]]
jaller94 Mar 7, 2016
9169bc6
Allow the character to be in the syntax pattern
jaller94 Mar 7, 2016
bb00354
Update version info
jaller94 Jun 16, 2016
d41d752
Ignore pages hidden by the global configuration config:hidepages; sol…
jaller94 Jun 27, 2016
27b1429
Update version info
jaller94 Jun 27, 2016
0d2b65e
Hotfix: Stop exposing IDs of hidden pages
jaller94 Jul 5, 2016
5085610
Always sort namespaces but don't sort for links when listing orphans.
jaller94 Jun 25, 2017
163625f
Adapted the commit a1d1970 of @rikblok implementing @include. Fixes #8
jaller94 Jun 25, 2017
1f76ce5
Merge pull request #32 from lupo49/sorting
jaller94 Jun 25, 2017
65db50f
Merge pull request #33 from lupo49/include
jaller94 Jun 25, 2017
a057218
Update README
jaller94 Jun 25, 2017
b0cf017
Update README
jaller94 Jun 25, 2017
3bd865f
Make sure is lowercase. Fixes #35
ThomasChr Nov 7, 2017
625b950
Merge pull request #36 from ThomasChr/master
jaller94 Nov 7, 2017
ef490c7
Use indexer to find all links
alexdraconian Jan 2, 2022
50b49d4
error fix
alexdraconian Jan 2, 2022
d209e09
error fix
alexdraconian Jan 2, 2022
5775dcd
Fix bug with non-exist page
alexdraconian Jan 3, 2022
f4ee5bc
Delete mis-inserted line
alexdraconian Jan 22, 2022
de66ba1
Merge pull request #44 from alexdraconian/master
jaller94 May 30, 2023
ed253b9
Don't import syntax.php, it's autoloaded
jaller94 May 30, 2023
59f33fb
Update README.md
jaller94 May 30, 2023
ef94f81
Fix unknown array key errors; Add alexdraconian as an author
jaller94 May 30, 2023
0e35d1f
2023-05-30
jaller94 May 30, 2023
e6dff5c
Remove noreply e-mail address
jaller94 May 30, 2023
54262be
Remove noreply e-mail address 2
jaller94 May 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions README

This file was deleted.

15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Orphanswanted Plugin for DokuWiki

All documentation for the Orphanswanted Plugin is available online at:

* http://dokuwiki.org/plugin:orphanswanted

(c) 2006-2008 Doug Edmunds
(c) 2008-2009 Andy Webber
(c) 2009 Federico Ariel Castagnini
(c) 2010 Cyrille37 <cyrille37@gmail.com>
(c) 2011 Rik Blok <rik dot blok at ubc dot ca>
(c) 2016-2023 Christian Paul <christian at chrpaul dot de>
(c) 2022 alexdraconian

See COPYING for license info.
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

9 changes: 9 additions & 0 deletions conf/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
/**
* Options for the Orphanswanted Plugin
*
* @author Matthias Schulte <dokuwiki@lupo49.de>
*/
$conf['ignoredpages'] = ''; // The plugin will doesn't list the given pages

//Setup VIM: ex: et ts=2 :
10 changes: 10 additions & 0 deletions conf/metadata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/**
* Metadata for configuration manager plugin
* Additions for the Orphanswanted Plugin
*
* @author Matthias Schulte <dokuwiki@lupo49.de>
*/
$meta['ignoredpages'] = array('string');

//Setup VIM: ex: et ts=2 :
205 changes: 205 additions & 0 deletions helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
<?php
/**
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author <dae@douglasedmunds.com>
* @author Andy Webber <dokuwiki at andywebber dot com>
* @author Federico Ariel Castagnini
* @author Cyrille37 <cyrille37@gmail.com>
* @author Matthias Schulte <dokuwiki@lupo49.de>
* @author Rik Blok <rik dot blok at ubc dot ca>
* @author Christian Paul <christian at chrpaul dot de>
* @author alexdraconian
*/
// must be run within Dokuwiki
if(!defined('DOKU_INC')) die();
if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');

require_once(DOKU_INC.'inc/search.php');

class helper_plugin_orphanswanted extends DokuWiki_Plugin {

// three choices
// $params_array used to extract excluded namespaces for report
// orphans = orph_report_table($data, true, false, $params_array);
// wanted = orph_report_table($data, false, true), $params_array;
// valid = orph_report_table($data, true, true, $params_array);

/**
* Find all page list with wiki's internal indexer.
*/
function _get_page_data() {
$all_pages = idx_get_indexer()->getPages();
$pages = array();
foreach($all_pages as $pageid) {
$pages[$pageid] = array("exists"=>page_exists($pageid), "links"=>0);
}

foreach($all_pages as $pageid) {

if (!page_exists($pageid)) continue;

$relation_data = p_get_metadata($pageid, 'relation references', METADATA_DONT_RENDER);
if (!is_null($relation_data)) {
foreach($relation_data as $name => $exists) {
$pages[$name]['exists'] = $exists;
$pages[$name]['links'] = isset($pages[$name]['links']) ? $pages[$name]['links'] + 1 : 1;
}
}
}

return $pages;
}

function orphan_pages($params_array) {
$data = $this->_get_page_data();

$result = '';
$result .= $this->orph_report_table($data, true, false, $params_array, 'orphan');

return $result;
}

function wanted_pages($params_array) {
$data = $this->_get_page_data();

$result = '';
$result .= $this->orph_report_table($data, false, true, $params_array, 'wanted');

return $result;
}

function valid_pages($params_array) {
$data = $this->_get_page_data();

$result = '';
$result .= $this->orph_report_table($data, true, true, $params_array, 'valid');

return $result;
}

function all_pages($params_array) {
$data = $this->_get_page_data();

$result = '';
$result .= "</p><p>Orphans</p><p>";
$result .= $this->orph_report_table($data, true, false, $params_array, 'orphan');
$result .= "</p><p>Wanted</p><p>";
$result .= $this->orph_report_table($data, false, true, $params_array, 'wanted');
$result .= "</p><p>Valid</p><p>";
$result .= $this->orph_report_table($data, true, true, $params_array, 'valid');

return $result;
}

function orph_report_table($data, $page_exists, $has_links, $params_array, $caller = null) {
global $conf;
$ignoredPages = $this->getConf('ignoredpages'); // Fetch pages which shouldn't be listed
if($ignoredPages != '') {
$ignoredPages = explode(';', $ignoredPages);
} else {
$ignoredPages = null;
}

$show_heading = ($page_exists && $conf['useheading']) ? true : false ;
//take off $params_array[0];
$include_array = $params_array[1];
$exclude_array = $params_array[2];

$count = 1;
$output = '';

// for valid html - need to close the <p> that is feed before this
$output .= '</p>';
$output .= '<table class="inline"><tr><th> # </th><th> ID </th>'
. ($show_heading ? '<th>Title</th>' : '' )
. ($caller != "orphan" ? '<th>Links</th>' : '')
. '</tr>'
. "\n" ;

// Sort by namespace and name
ksort($data);

// Sort descending by existing links.
// This does not make sense for orphans since they don't have links.
if ($caller != "orphan") {
arsort($data);
}

foreach($data as $id=>$item) {

if( ! ((array_key_exists('exists', $item)) and ($item['exists'] == $page_exists) and (array_key_exists('links', $item)) and (($item['links'] <> 0)== $has_links)) ) continue ;

// $id is a string, looks like this: page, namespace:page, or namespace:<subspaces>:page
$match_array = explode(":", $id);
//remove last item in array, the page identifier
$match_array = array_slice($match_array, 0, -1);
//put it back together
$page_namespace = implode (":", $match_array);
//add a trailing :
$page_namespace = $page_namespace . ':';

if (empty($include_array)) {
// if inclusion list is empty then show all namespaces
$show_it = true;
} else {
// otherwise only show if in inclusion list
$show_it = false;
foreach ($include_array as $include_item) {
//add a trailing : to each $item too
$include_item = $include_item . ":";
// need === to avoid boolean false
// strpos(haystack, needle)
// if exclusion is beginning of page's namespace, block it
if (strpos($page_namespace, $include_item) === 0) {
//there is a match, so show it and move on
$show_it = true;
break;
}
}
}

if(!is_null($ignoredPages) && in_array($id, $ignoredPages)) {
if ($conf['allowdebug']) echo "Skipped page (global ignored): " . $id . "<br />";
$show_it = false;
} elseif(isHiddenPage($id)) {
if ($conf['allowdebug']) echo "Skipped page (global hidden): " . $id . "<br />";
$show_it = false;
} elseif ( $show_it ) {
//check if blocked by exclusion list
foreach ($exclude_array as $exclude_item) {
//add a trailing : to each $item too
$exclude_item = $exclude_item . ":";
// need === to avoid boolean false
// strpos(haystack, needle)
// if exclusion is beginning of page's namespace , block it
if (strpos($page_namespace, $exclude_item) === 0) {
//there is a match, so block it and move on
$show_it = false;
break;
}
}
}

if($show_it) {
$output .= "<tr><td>$count</td><td><a href=\"". wl($id)
. "\" class=\"" . ($page_exists ? "wikilink1" : "wikilink2") . "\" >"
. $id .'</a></td>'
. ($show_heading ? '<td>' . hsc(p_get_first_heading($id)) .'</td>' : '' );

if($caller != "orphan") { // Skip "link" column if user wants orphan pages only
$output .= '<td>' . $item['links']
. ($has_links ? "&nbsp;:&nbsp;<a href=\"". wl($id, 'do=backlink')
. "\" class=\"wikilink1\">Show&nbsp;backlinks</a>" : '') . "</td>";
}
$output .= "</tr>\n";
$count++;
}
}

$output .= "</table>\n";
//for valid html = need to reopen a <p>
$output .= '<p>';

return $output;
}
}
10 changes: 10 additions & 0 deletions lang/de-informal/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/**
* english language file
*
* @author Matthias Schulte <dokuwiki@lupo49.de>
*/

$lang['ignoredpages'] = 'Diese Seiten nie in den Ausgaben anzeigen (Trennzeichen: Semikolon)';

//Setup VIM: ex: et ts=2 :
10 changes: 10 additions & 0 deletions lang/de/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/**
* english language file
*
* @author Matthias Schulte <dokuwiki@lupo49.de>
*/

$lang['ignoredpages'] = 'Diese Seiten nie in den Ausgaben anzeigen (Trennzeichen: Semikolon)';

//Setup VIM: ex: et ts=2 :
10 changes: 10 additions & 0 deletions lang/en/settings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/**
* english language file
*
* @author Matthias Schulte <dokuwiki@lupo49.de>
*/

$lang['ignoredpages'] = 'Always skip these pages in the output table (Delimiter: Semicolon)';

//Setup VIM: ex: et ts=2 :
7 changes: 7 additions & 0 deletions plugin.info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
base orphanswanted
author Doug Edmunds, Cyrille37, Federico Ariel Castagnini, Andy Webber, Matthias Schulte, Christian Paul, alexdraconian
email dokuwiki@lupo49.de
date 2023-05-30
name orphanswanted plugin
desc Display Orphans, Wanteds and Valid link tables
url http://dokuwiki.org/plugin:orphanswanted
Loading