module_path = str_replace(basename(__FILE__),"",__FILE__);
parent::__construct($id);
}
public function get_manage_form(){
global $base_path;
global $search_dest;
$form="
".$this->format_text($this->msg['cms_module_search_admin_form_label'])."
";
if($this->managed_datas['module']['search_dests']){
foreach($this->managed_datas['module']['search_dests'] as $key => $cal){
$form.="
".$this->format_text($cal['name'])."
";
}
}
$form.="
".$this->format_text($this->msg['cms_module_search_add_search_dest'])."
";
$form.="
";
if($search_dest){
$form.=$this->get_managed_form_start(array('search_dest'=>$search_dest));
$form.=$this->get_managed_search_dest_form($search_dest);
$form.=$this->get_managed_form_end();
}
$form.="
";
return $form;
}
protected function get_managed_search_dest_form($search_dest){
global $opac_opac_view_activate;
if($search_dest != "new"){
$infos = $this->managed_datas['module']['search_dests'][$search_dest];
}else{
$infos = array(
'name' => "",
'page' => 0
);
}
$form = "";
//nom
$form.="
";
//page
$form.="
".$this->format_text($this->msg['cms_module_search_search_dest_page'])."
";
if($opac_opac_view_activate) {
$form.= $this->gen_options_opac_view($infos['page']);
} else {
$form.="
".$this->format_text($this->msg['cms_module_search_classique_dest'])." ";
}
//on va chercher les infos pour les pages du portail !
$query = "select id_page,page_name from cms_pages order by page_name asc";
$result = pmb_mysql_query($query);
$pages = array();
$pages[0] = $this->msg["cms_module_menu_menu_entry_page_choice"];
if(pmb_mysql_num_rows($result)){
$form.= "
";
while($row = pmb_mysql_fetch_object($result)){
$form.="
id_page == $infos['page'] ? "selected='selected'" : "").">".$this->format_text($row->page_name)." ";
}
$form.= "
";
}
$form.="
";
return $form;
}
protected function get_opac_views_list(){
$opac_views = array();
$query = "select opac_view_id, opac_view_name from opac_views";
$result = pmb_mysql_query($query);
if(pmb_mysql_num_rows($result)){
while($row = pmb_mysql_fetch_object($result)) {
$opac_views[$row->opac_view_id] = $row->opac_view_name;
}
}
return $opac_views;
}
protected function gen_options_opac_view($selected){
$opac_views = $this->get_opac_views_list();
$select = "
".$this->format_text($this->msg['cms_module_search_opac_view_current'])."
".$this->format_text($this->msg['cms_module_search_opac_view_any'])." ";
foreach($opac_views as $key => $name){
$select.="
".$this->format_text($name)." ";
}
$select.= "
";
return $select;
}
public function save_manage_form(){
global $search_dest;
global $search_dest_delete;
global $cms_module_search_search_dest_name;
global $cms_module_search_page_dest;
$params = $this->managed_datas['module'];
if($search_dest_delete){
unset($params['search_dests'][$search_dest_delete]);
}else{
if($search_dest == "new"){
$search_dest = "search_dest".(cms_module_search::get_max_search_dest_id($params['search_dests'])+1);
}
$params['search_dests'][$search_dest] = array(
'name' => stripslashes($cms_module_search_search_dest_name),
'page' => stripslashes($cms_module_search_page_dest)
);
}
return $params;
}
protected static function get_max_search_dest_id($datas){
$max = 0;
if(count($datas)){
foreach ($datas as $key => $val){
$key = str_replace("search_dest","",$key)*1;
if($key>$max) $max = $key;
}
}
return $max;
}
}