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){
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'])."
";
//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 = mysql_query($query);
$pages = array();
$pages[0] = $this->msg["cms_module_menu_menu_entry_page_choice"];
if(mysql_num_rows($result)){
$form.="
".$this->format_text($this->msg['cms_module_search_classique_dest'])." ";
while($row = mysql_fetch_object($result)){
$form.="
id_page == $infos['page'] ? "selected='selected'" : "").">".$this->format_text($row->page_name)." ";
}
}
$form.="
";
return $form;
}
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 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;
}
// public function execute_ajax(){
// global $charset;
// global $do;
//
// switch($do){
// case "get_pages" :
// break;
// }
// }
}