module_path = str_replace(basename(__FILE__),"",__FILE__); parent::__construct($id); $this->modcache = "no_cache"; } protected function get_max_server_id($datas){ $max = 0; if(count($datas)){ foreach ($datas as $key => $val){ $key = str_replace("server","",$key)*1; if($key>$max) $max = $key; } } return $max; } public function get_manage_form(){ global $base_path; //variables persos... global $server; $form="
"; if($this->managed_datas['module']['servers']){ foreach($this->managed_datas['module']['servers'] as $key => $server_infos){ $form.="

".$this->format_text($server_infos['name'])."   ".$this->format_text($this->msg[

"; } } $form.=" Ajouter un Serveur Piwik "; $form.="
"; if($server){ $form.=$this->get_managed_form_start(array('server'=>$server)); $form.=$this->get_managed_server_form($server); $form.=$this->get_managed_form_end(); } $form.="
"; return $form; } public function get_managed_server_form($server){ $infos = array(); if($server != "new"){ $infos = $this->managed_datas['module']['servers'][$server]; } $form="
"; //nom du server $form.="
"; //adresse du server $form.="
"; //identififiant du site $form.="
"; //suivi sur tous les sous-domaines $form.="

".$this->format_text($this->msg['cms_module_piwik_subdomains_description'])."
"; //prefix domaine $form.="

".$this->format_text($this->msg['cms_module_piwik_domain_prefix_description'])."
"; //click sortant vers sous-domaine $form.="

".$this->format_text($this->msg['cms_module_piwik_subdomains_links_description'])."
"; return $form; } public function save_manage_form(){ global $server; global $server_delete; global $cms_module_piwik_server_name; global $cms_module_piwik_server_url; global $cms_module_piwik_server_subdomain; global $cms_module_piwik_server_domain_prefix; global $cms_module_piwik_server_subdomains_links; global $cms_module_piwik_site_id; $params = $this->managed_datas['module']; if($server_delete){ unset($params['servers'][$server_delete]); }else{ //ajout d'un server if($server == "new"){ $server_infos = array( 'name' => $cms_module_piwik_server_name, 'url' => $cms_module_piwik_server_url, 'site_id' => $cms_module_piwik_site_id, 'subdomains' => $cms_module_piwik_server_subdomain, 'domain_prefix' => $cms_module_piwik_server_domain_prefix, 'subdomains_links' =>$cms_module_piwik_server_subdomains_links ); $params['servers']['server'.(self::get_max_server_id($this->managed_datas['module']['servers'])+1)] = $server_infos; }else{ //sinon on réécrit juste l'élément $params['servers'][$server]['name'] = $cms_module_piwik_server_name; $params['servers'][$server]['url'] = $cms_module_piwik_server_url; $params['servers'][$server]['site_id'] = $cms_module_piwik_site_id; $params['servers'][$server]['subdomains'] = $cms_module_piwik_server_subdomain; $params['servers'][$server]['domain_prefix'] = $cms_module_piwik_server_domain_prefix; $params['servers'][$server]['subdomains_links'] = $cms_module_piwik_server_subdomains_links; } } return $params; } }