Skip to content

Commit

Permalink
Skip the "Links" column inside the orphaned pages table (Closes #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
lupo49 committed Nov 25, 2012
1 parent 16ddee6 commit 032e374
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function orphan_pages($params_array) {
$result = '';
$data = array();
search($data,$conf['datadir'], array($this, 'orph_callback_search_wanted'), array('ns' => $ns));
$result .= $this->orph_report_table($data, true, false,$params_array);
$result .= $this->orph_report_table($data, true, false, $params_array, 'orphan');

return $result;
}
Expand All @@ -165,7 +165,7 @@ function wanted_pages($params_array) {
$result = '';
$data = array();
search($data,$conf['datadir'], array($this, 'orph_callback_search_wanted'), array('ns' => $ns));
$result .= $this->orph_report_table($data, false, true,$params_array);
$result .= $this->orph_report_table($data, false, true, $params_array, 'wanted');

return $result;
}
Expand All @@ -175,7 +175,7 @@ function valid_pages($params_array) {
$result = '';
$data = array();
search($data,$conf['datadir'], array($this, 'orph_callback_search_wanted'), array('ns' => $ns));
$result .= $this->orph_report_table($data, true, true, $params_array);
$result .= $this->orph_report_table($data, true, true, $params_array, 'valid');

return $result;
}
Expand All @@ -187,17 +187,17 @@ function all_pages($params_array) {
search($data,$conf['datadir'], array($this, 'orph_callback_search_wanted') , array('ns' => $ns));

$result .= "</p><p>Orphans</p><p>";
$result .= $this->orph_report_table($data, true, false,$params_array);
$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);
$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);
$result .= $this->orph_report_table($data, true, true, $params_array, 'valid');


return $result;
}

function orph_report_table($data, $page_exists, $has_links, $params_array) {
function orph_report_table($data, $page_exists, $has_links, $params_array, $caller = null) {
global $conf;

$show_heading = ($page_exists && $conf['useheading']) ? true : false ;
Expand All @@ -211,16 +211,15 @@ function orph_report_table($data, $page_exists, $has_links, $params_array) {
// 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>' : '' )
. '<th>Links</th></tr>'
."\n" ;
. ($show_heading ? '<th>Title</th>' : '' )
. ($caller != "orphan" ? '<th>Links</th>' : '')
. '</tr>'
. "\n" ;

arsort($data);

foreach($data as $id=>$item) {
if( ! (($item['exists'] == $page_exists) and (($item['links'] <> 0)== $has_links)) ) {
continue ;
}
if( ! (($item['exists'] == $page_exists) 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);
Expand All @@ -247,16 +246,16 @@ function orph_report_table($data, $page_exists, $has_links, $params_array) {

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>' : '' )
. '<td>' . $item['links']
. ($has_links
? "&nbsp;:&nbsp;<a href=\"". wl($id, 'do=backlink') ."\" class=\"wikilink1\">Show&nbsp;backlinks</a>"
: ''
)
. "</td></tr>\n";

. "\" 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++;
}
}
Expand Down

0 comments on commit 032e374

Please sign in to comment.