Commit e7750252 authored by vermeul's avatar vermeul

added page attributes to search results

parent de0c3cdf
......@@ -256,15 +256,9 @@ class YATA {
$table .= '([' . $title->getFullURL() . '?action=purge' . ' refresh page]):';
if ($dbr->numRows($annotations) > 0) {
$table .= '
<table class="wikitable sortable jquery-tablesorter">
<tr>
<th class="headerSort headerSortUp" tabindex="0" role="columnheader button" title="Sort descending"> Category </th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending"> Comment </th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending"> Link </th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending"> Annotated text </th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending"> Page Attributes </th>
</tr>';
$page_attributes = array();
$column_no = 0;
$table_rows = array();
# compose the wiki table
foreach($annotations as $annotation) {
......@@ -297,22 +291,54 @@ class YATA {
. base64_encode($rendered_wikitext)
. ' END_ENCODED_YATA_CONTENT';
$table .= "<tr><td>".$cat
."</td><td>".$annotation->comment
."</td><td>". $link
."</td><td>". $rendered_wikitext
."</td>";
$table_row = array(
"category" => $cat,
"comment" => $annotation->comment,
"link" => $link,
"annot" => $rendered_wikitext,
);
$p_annotations = self::get_page_annotations($dbr, $annotation->page_id);
$td = "<td>";
foreach ($p_annotations as $p_annotation) {
$td .= $p_annotation->name . ": ". $p_annotation->value . "<br/>";
if (! in_array($p_annotation->name, $page_attributes)) {
array_push($page_attributes, $p_annotation->name);
}
$table_row[$p_annotation->name] = $p_annotation->value;
}
$td .= "</td>";
$table .= $td;
$table .= "</tr>\n";
array_push($table_rows, $table_row);
}
$new_table = $table . '<table class="wikitable sortable jquery-tablesorter">';
$table_header = '
<tr>
<th class="headerSort headerSortUp" tabindex="0" role="columnheader button" title="Sort descending"> Category </th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending"> Comment </th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending"> Link </th>
<th class="headerSort" tabindex="0" role="columnheader button" title="Sort ascending"> Annotated text </th>';
$build_th = function($val){
return "<th>" . $val . "</th>";
};
$build_td = function($val) {
return "<td>" . $val . "</td>";
};
$all_columns = array_merge(['category','comment','link','annot'],$page_attributes);
$table_header .= join("", array_map($build_th, $page_attributes));
$table_header .= "</tr>";
$table .= $new_table . $table_header;
$rows_rendered = "";
foreach($table_rows as $table_row) {
$rows_rendered .= "<tr>";
foreach($all_columns as $column) {
$rows_rendered .= "<td>" . $table_row[$column] . "</td>";
}
$rows_rendered .= "</tr>";
}
$table .= $rows_rendered;
$table .= "</table>";
}
else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment