#!/usr/bin/php pathID(substr($dir.'/'.$entry,$trunclen)), 'file'=> $dir.'/'.$entry, ); $pages[] = $page; } } closedir($dh); return $pages; } #------------------------------------------------------------------------------ function dw_internal_links($page) { global $conf; $instructions = p_get_instructions(file_get_contents($page['file'])); $links = array(); $cns = getNS($page['id']); $exists = false; 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; } } } return $links; } #------------------------------------------------------------------------------ $OPTS = Doku_Cli_Opts::getOptions(__FILE__,'h',array('help')); if ( $OPTS->isError() ) { fwrite( STDERR, $OPTS->getMessage() . "\n"); exit(1); } if ( $OPTS->has('h') or $OPTS->has('help') ) { usage(); exit(0); } $START_DIR = $conf['datadir']; if ( $OPTS->numArgs() == 1 ) { $START_DIR .= '/' . $OPTS->arg(0); } #------------------------------------------------------------------------------ $WANTED_PAGES = array(); foreach ( dw_get_pages($START_DIR) as $WIKI_PAGE ) { $WANTED_PAGES = array_merge($WANTED_PAGES,dw_internal_links($WIKI_PAGE)); } $WANTED_PAGES = array_unique($WANTED_PAGES); sort($WANTED_PAGES); foreach ( $WANTED_PAGES as $WANTED_PAGE ) { print $WANTED_PAGE."\n"; } exit(0);