From ca28040c390344e5fd22b6dfab2ef8160bb9ada3 Mon Sep 17 00:00:00 2001 From: Stephan Dekker Date: Tue, 13 Aug 2013 10:58:09 +1000 Subject: [PATCH] Fixed some bugs --- syntax.php | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/syntax.php b/syntax.php index 66f4d7d..c93d205 100644 --- a/syntax.php +++ b/syntax.php @@ -16,6 +16,7 @@ define('DEBUG', 0); function revision_callback_search_wanted(&$data,$base,$file,$type,$lvl,$opts) { + global $conf; if($type == 'd'){ return true; // recurse all directories, but we don't store namespaces @@ -35,18 +36,23 @@ function revision_callback_search_wanted(&$data,$base,$file,$type,$lvl,$opts) { $revision_frequency = get_revision_frequency($file); - // try to avoid making duplicate entries for forms and pages + // try to avoid making duplicate entries for forms and pages $item = &$data["$id"]; if(! isset($item)) { - // Create a new entry - $filename = DOKU_INC.'data/pages/'.$file; - $last_modifed = filemtime($filename); - - $revision_date = $last_modifed + (intval($revision_frequency) * 86400); + // Create a new entry + $filename = $conf['datadir'].$file; + $last_modified = filemtime($filename); + + $revision_date = $last_modified + (intval($revision_frequency) * 86400); if ($revision_date < time()) { - $data["$id"]=array('revision' => $last_modifed, + $data["$id"]=array('revision' => $last_modified, 'frequency' => $revision_frequency, 'revision_date' => $revision_date ); + } + else + { + // The item is actually already added to the array! We need to remove it if we don't need it. + unset($data["$id"]); } } @@ -60,25 +66,24 @@ function revision_string($revision) { } function get_revision_frequency($file) { + global $conf; - $filename = DOKU_INC.'data/pages/'.$file; + $filename = $conf['datadir'].$file; $body = @file_get_contents($filename); - $pattern = '/\-?\d+<\/revision_frequency>/i'; $count = preg_match($pattern, $body, $matches); $result = htmlspecialchars($matches[0]); $result = str_replace(htmlspecialchars(''), "", $result); $result = str_replace(htmlspecialchars(''), "", $result); - return $result; } function date_compare($a, $b) { - if ($a['revision'] == $b['revision']) { - return 0; - } - return ($a['revision'] < $b['revision']) ? -1 : 1; + if ($a['revision_date'] == $b['revision_date']) { + return 0; + } + return ($a['revision_date'] < $b['revision_date']) ? -1 : 1; } @@ -185,6 +190,7 @@ function all_pages($params_array, $mandatory_revisions = true ) { $result = ''; $data = array(); search($data,$conf['datadir'],'revision_callback_search_wanted',array('ns' => $ns)); + $result .= $this->revision_report_table($data, $mandatory_revisions); return $result; @@ -199,7 +205,7 @@ function revision_report_table( $data, $mandatory_revisions = true ) // for valid html - need to close the

that is feed before this $output .= '

'; - $output .= ''."\n" ; + $output .= '
# TitleRevisedFrequencyrevision_date
'."\n" ; uasort($data, 'date_compare'); @@ -209,7 +215,7 @@ function revision_report_table( $data, $mandatory_revisions = true ) continue ; } - if ($mandatory_revisions === false and $item['frequency'] === '' ) { + if ($mandatory_revisions === false and ($item['frequency'] === '' or !isset($item['frequency']))) { continue ; } @@ -243,6 +249,8 @@ function revision_report_table( $data, $mandatory_revisions = true ) $frequency = $item['frequency']; $revision_date = $item['revision_date']; +// msg('Creating teable for:'.$id.' was modified: '.date ("F d Y H:i:s.", $revision)); + $output .= "
# TitleLast RevisionFrequencyNext Revision Date
$count"