active_filename = $base_path.'/opac_css/temp/.maintenance'; $this->content_filename = $base_path.'/opac_css/temp/maintenance.html'; } public function fetch_data() { $this->active = false; if (file_exists($this->active_filename)) { $this->active = true; } $this->fetch_content(); } public function get_form() { global $maintenance_page_form, $base_path, $pmb_javascript_office_editor, $charset; $form = ''; if ($pmb_javascript_office_editor) { $form.= $pmb_javascript_office_editor; $form.= ""; } $form.= $maintenance_page_form; $checked = ''; if ($this->active) { $checked = 'checked="checked"'; } $form = str_replace('!!maintenance_page_activate_checked!!', $checked, $form); $form = str_replace('!!maintenance_page_content_title!!', $this->content['title'], $form); $form = str_replace('!!maintenance_page_content_body!!', $this->content['body'], $form); $form = str_replace('!!maintenance_page_content_style!!', $this->content['style'], $form); return $form; } public function get_values_from_form() { global $maintenance_page_activate; global $maintenance_page_content_body; global $maintenance_page_content_title; global $maintenance_page_content_style; $this->active = ($maintenance_page_activate*1 ? true : false); $this->content['body'] = stripslashes($maintenance_page_content_body); $this->content['title'] = stripslashes($maintenance_page_content_title); $this->content['style'] = stripslashes($maintenance_page_content_style); } public function save() { if ($this->active && !file_exists($this->active_filename)) { touch($this->active_filename); } if (!$this->active && file_exists($this->active_filename)) { unlink($this->active_filename); } file_put_contents($this->content_filename, $this->build_page()); } protected function fetch_content() { $this->content = array(); if (file_exists($this->content_filename)) { $html = file_get_contents($this->content_filename); $matches = array(); preg_match('/(.*)<\/title>/s', $html, $matches); $this->content['title'] = $matches[1]; preg_match('/<style>(.*)<\/style>/s', $html, $matches); $this->content['style'] = trim($matches[1]); preg_match('/<body>(.*)<\/body>/s', $html, $matches); $this->content['body'] = trim($matches[1]); } else { // Le fichier n'existe pas encore ou a été effacé, on va chercher le contenu par défaut global $maintenance_page_default_content, $msg; $this->content['body'] = $maintenance_page_default_content; $this->content['title'] = $msg['admin_opac_maintenance']; } } protected function build_page() { global $charset; $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset='.$charset.'" /> <title>'.$this->content['title'].' '.$this->content['body'].' '; return $html; } }