diff --git a/e107_admin/search.php b/e107_admin/search.php index 237c591e1..c2ac44205 100644 --- a/e107_admin/search.php +++ b/e107_admin/search.php @@ -79,7 +79,7 @@ if (vartrue($save_search)) // $serialpref = addslashes(serialize($search_prefs)); // $serialpref = e107::getArrayStorage()->writeArray($search_prefs, true); // $sql -> db_Update("core", "e107_value='".$serialpref."' WHERE e107_name='search_prefs'"); - e107::getConfig('search')->setPref($search_prefs)->save(false,true); + e107::getConfig('search')->setPref($search_prefs)->save(false,true,false); $admin_log->log_event('SEARCH_03','',E_LOG_INFORMATIVE,''); } diff --git a/e107_plugins/download/e_search.php b/e107_plugins/download/e_search.php new file mode 100644 index 000000000..e33fc5dbb --- /dev/null +++ b/e107_plugins/download/e_search.php @@ -0,0 +1,121 @@ + 'all', 'title' => LAN_SEARCH_51); + + if ($sql ->gen("SELECT download_category_id, download_category_name FROM #download_category WHERE download_category_parent != 0 AND download_category_class IN (".USERCLASS_LIST.")")) + { + while($row = $sql->fetch()) + { + $catList[] = array('id' => $row['download_category_id'], 'title' => $row['download_category_name']); + // $advanced_caption['title'][$row['category_id']] = 'News -> '.$row['category_name']; + } + } + + + $search = array( + 'name' => LAN_PLUGIN_DOWNLOAD_NAME, + 'table' => 'download AS d LEFT JOIN #download_category AS c ON d.download_category = c.download_category_id', + + 'advanced' => array( + 'cat' => array('type' => 'dropdown', 'text' => LAN_SEARCH_55, 'list'=>$catList), + 'date' => array('type' => 'date', 'text' => LAN_SEARCH_50), + 'author'=> array('type' => 'author', 'text' => LAN_SEARCH_61) + ), + + 'return_fields' => array('d.download_id', 'd.download_category', 'download_category_id', 'd.download_name', 'd.download_description', 'd.download_author', 'd.download_author_website', 'd.download_datestamp', 'd.download_class', 'c.download_category_name', 'c.download_category_class'), + 'search_fields' => array('d.download_name'=> '1.2', 'd.download_url' => '0.9', 'd.download_description'=>'0.6', 'd.download_author'=>'0.6', 'd.download_author_website'=>'0.4'), // fields and weights. + + 'order' => array('download_datestamp' => DESC), + 'refpage' => e_PLUGIN_ABS.'download/download.php' + ); + + + return $search; + } + + + + /* Compile Database data for output */ + function compile($row) + { + $tp = e107::getParser(); + + //TODO SEF URLs for list below. + //TODO Remove html from pre_summary and use additional vars instead. + + $res = array(); + + $datestamp = $tp -> toDate($row['download_datestamp'], "long"); + + $res['link'] = e107::getUrl()->create('download/view/item', array('id'=>$row['download_id'],'name'=>vartrue($row['download_sef'],'--no-sef-set--'))); + $res['pre_title'] = $tp->toHtml($row['download_category_name'],false,'TITLE_PLAIN')." | "; + $res['title'] = $row['download_name']; + $res['pre_summary'] = "
".LAN_197." -> ".$row['download_category_name']."
"; + $res['summary'] = $row['download_description']; + $res['detail'] = LAN_SEARCH_15." ".$row['download_author']." | ".LAN_SEARCH_66.": ".$datestamp; + + + + return $res; + + } + + + + /** + * Optional - Advanced Where + * @param $parm - data returned from $_GET (ie. advanced fields included. in this case 'date' and 'author' ) + */ + function where($parm='') + { + $tp = e107::getParser(); + + $qry = "download_active > '0' AND d.download_visible IN (".USERCLASS_LIST.") AND c.download_category_class IN (".USERCLASS_LIST.") AND".$advanced_where; + + if (isset($parm['cat']) && is_numeric($parm['cat'])) + { + $qry .= " d.download_category='".$parm['cat']."' AND"; + } + + if (isset($parm['time']) && is_numeric($parm['time'])) + { + $qry .= " d.download_datestamp ".($parm['on'] == 'new' ? '>=' : '<=')." '".(time() - $parm['time'])."' AND"; + } + + if (isset($parm['author']) && $parm['author'] != '') + { + $qry .= " (d.download_author = '".$tp -> toDB($parm['author'])."') AND"; + } + + return $qry; + } + + +} + + +?> \ No newline at end of file