" . $title . "";
$c .= "
";
}
// materials
if ($keyword) {
// sort options
$sort_val = "date"; //default sort term
$sort_opts = array(
/*translation:Date*/
elgg_echo('koolielu:sortby_Date'),
/*translation:Download*/
elgg_echo('koolielu:sortby_Download'),
/*translation:Favorites*/
elgg_echo('koolielu:sortby_Favorites'),
/*translation:Title*/
elgg_echo('koolielu:sortby_Title')
); // selection on sort terms
$sort_vals = array('created', 'download', 'favorites', 'title'); // need because of its different from last row
$sort = "";
if ( get_input('sortValue') ) {
$sort_val = get_input('sortValue');
$_SESSION['sortingTerm'] = $sort_val;
} else if ( $_SESSION['sortingTerm'] ) {
$sort_val = $_SESSION['sortingTerm'];
}
if ( in_array($sort_val, array("created", "title")) ) {
$sort = "<_sort>".$sort_val."";
}
$q = '';
$q .= "" . $keyword . "";
$q .= '*';
$q .= $sort;
$q .= "";
/*translation:Keyword*/
$c .= "" . elgg_echo('koolielu:heading_waramu_keyword'). ": " . $keyword . "
";
$resp = $w->listIdentifiers("", $q);
$idefs = $resp['identifiers'][0]['id'];
$ids = array();
$array_for_sort = array();
foreach($idefs as $ri) {
if ( $sort_val == "favorites" ) {
$fav_nr = get_data_row("SELECT COUNT(ID) as num FROM {$CONFIG->dbprefix}koolielu_favorite_resources WHERE waramu_id = '{$ri[0]}'");
$array_for_sort[$ri[0]] = $fav_nr->num;
} else if ( $sort_val == "download" ) {
$dow_nr = get_data_row("SELECT url_stat FROM {$CONFIG->dbprefix}koolielu_resource_stats WHERE waramu_id='{$ri[0]}'");
$array_for_sort[$ri[0]] = $dow_nr->url_stat;
} else {
$ids[] = $ri[0];
}
}
if ( $array_for_sort ) {
arsort($array_for_sort);
foreach ($array_for_sort as $aaf => $aav) {
$ids[] = $aaf;
}
}
// in case sorting for date, then displaying newest before
if ( $sort_val == "created" )
$ids = array_reverse($ids);
/*translation:Waramu has*/
$c .= "".elgg_echo("koolielu:waramu_has").": ".count($ids)."
";
// show sort options
/*translation:Sorted by*/
$c .= "".elgg_echo("koolielu:sortedby")."
";
$c .= "";
$d_f = "";
$c .= elgg_view('input/form', array('action' => "", "body" => $d_f, "internalname" => "sortform"));
$soi = 0;
foreach ($sort_opts as $so) {
$c .= "".$so." ";
$soi++;
}
$c .= waramu_list_resources($ids);
}
$body = elgg_view_layout('two_column_left_sidebar', "", $c);
page_draw($title, $body);
?>