From: x2000habouzit Date: Thu, 19 Feb 2004 13:22:04 +0000 (+0000) Subject: passage à un modèle unifié pour la création de page, sans bug d'auth. X-Git-Tag: xorg/old~1861 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=dc30cc7e40f65b980abfc569f419eda4f96ce36d;p=platal.git passage à un modèle unifié pour la création de page, sans bug d'auth. new_popup_page n'a plus vraiment raison d'être (à part pour x.php, on traitera son cas plus tard...) remplacée par new_nonhtml_page pour les pages type rss.php et cie. j'ai aussi modifié la conf apache, plus besoin de hack pour faire marcher le site ! --- diff --git a/htdocs/mescontacts_ldif.php b/htdocs/mescontacts_ldif.php index f7e2ee0..91d4763 100644 --- a/htdocs/mescontacts_ldif.php +++ b/htdocs/mescontacts_ldif.php @@ -1,5 +1,6 @@ display('mescontacts_ldif.tpl'); +$page->display(); ?> diff --git a/htdocs/rss.php b/htdocs/rss.php index 101707a..5ecded1 100644 --- a/htdocs/rss.php +++ b/htdocs/rss.php @@ -1,5 +1,6 @@ = NOW()"; @@ -9,8 +10,8 @@ if (isset($_REQUEST["promo"])) { } $requete.=" ORDER BY (e.promo_min != 0 AND e.promo_max != 0) DESC, e.peremption"; -mysql_assign($page,$requete,'rss'); +$page->mysql_assign($requete,'rss'); header("Content-Type: text/xml"); -$page->display('rss.tpl'); +$page->display(); ?> diff --git a/htdocs/vcard.php b/htdocs/vcard.php index a5920fa..0058873 100644 --- a/htdocs/vcard.php +++ b/htdocs/vcard.php @@ -1,5 +1,6 @@ display('vcard.tpl'); +$page->display(); ?> diff --git a/include/auto.prepend.inc.php b/include/auto.prepend.inc.php index 2a0cab5..17599bc 100644 --- a/include/auto.prepend.inc.php +++ b/include/auto.prepend.inc.php @@ -1,6 +1,5 @@ root}/include/:{$globals->root}/configs/:$globals->libroot") ; setlocale(LC_TIME, "fr_FR"); require("xorg.common.inc.php"); @@ -30,8 +29,8 @@ function new_skinned_page($tpl_name, $min_auth, $popup=false, $tpl_head="") { _new_page(SKINNED, $tpl_name, $tpl_head, $min_auth, $popup); } -function new_popup_page($tpl_name, $min_auth, $popup=false, $tpl_head="") { - _new_page(SKINNED, $tpl_name, $tpl_head, $min_auth, $popup); +function new_nonhtml_page($tpl_name, $min_auth) { + _new_page(NO_SKIN, $tpl_name, "", $min_auth, false); } function new_admin_page($tpl_name, $popup=false, $tpl_head="") { diff --git a/include/nonhtml.inc.php b/include/nonhtml.inc.php deleted file mode 100644 index ef8410c..0000000 --- a/include/nonhtml.inc.php +++ /dev/null @@ -1,33 +0,0 @@ -assign_by_ref($var_name,$array); - if(!empty($var_nb_name)) - $page->assign($var_nb_name, count($array)); - return 0; -} - -$page = new Smarty(); - -$page->template_dir = $globals->spoolroot . "/templates/"; -$page->compile_dir = $globals->spoolroot . "/templates_c/"; -$page->plugins_dir[]= $globals->spoolroot . "/plugins/"; -$page->cache_dir = $globals->spoolroot . "/cache/"; - -$page->config_overwrite=false; -$page->compile_check=true; -$page->caching=false; -?> diff --git a/include/xorg.common.inc.php b/include/xorg.common.inc.php index 2adc3cf..01a32aa 100644 --- a/include/xorg.common.inc.php +++ b/include/xorg.common.inc.php @@ -10,11 +10,10 @@ define("PERMS_ADMIN", "admin"); define('SKIN_COMPATIBLE','default.tpl'); define('SKIN_COMPATIBLE_ID',1); -define('SKIN_POPUP_COMPATIBLE','default.popup.tpl'); define('SKIN_STOCHASKIN_ID','254'); define('SKINNED', 0); -define('POPUP', 1); +define('NO_SKIN', 1); // import class definitions require("diogenes.database.inc.php"); diff --git a/include/xorg.page.inc.php b/include/xorg.page.inc.php index c1d4744..b661aae 100644 --- a/include/xorg.page.inc.php +++ b/include/xorg.page.inc.php @@ -37,10 +37,10 @@ class XorgPage extends DiogenesCorePage { $this->cache_dir = $globals->spoolroot."/cache/"; $this->config_overwrite=false; - $this->compile_check=true; - $this->caching=true; + $this->compile_check = isset($site_dev); + $this->caching = ($type == SKINNED); - $this->_page_type = SKINNED; + $this->_page_type = $type; $this->_tpl = $tpl; $this->DiogenesCorePage(); @@ -66,8 +66,8 @@ class XorgPage extends DiogenesCorePage { $id = $this->make_id($append_to_id); if($site_dev) { $this->assign('validate', urlencode($baseurl.'/valid.html')); - if($this->_page_type == POPUP) - $result = $this->fetch('skin/'.$_SESSION['skin_popup'], $id); + if($this->_page_type == NO_SKIN) + $result = $this->fetch($this->_tpl, $id); else $result = $this->fetch('skin/'.$_SESSION['skin'], $id); $fd = fopen($this->cache_dir."valid.html","w"); @@ -75,8 +75,8 @@ class XorgPage extends DiogenesCorePage { fclose($fd); echo $result; } else { - if($this->_page_type == POPUP) - parent::display('skin/'.$_SESSION['skin_popup'], $id); + if($this->_page_type == NO_SKIN) + parent::display($this->_tpl, $id); else parent::display('skin/'.$_SESSION['skin'], $id); } @@ -85,14 +85,14 @@ class XorgPage extends DiogenesCorePage { function xorg_is_cached($append_to_id="") { $id = $this->make_id($append_to_id); - if($this->_page_type == POPUP) - return parent::is_cached('skin/'.$_SESSION['skin_popup'], $id); + if($this->_page_type == NO_SKIN) + return parent::is_cached($this->_tpl, $id); else return parent::is_cached('skin/'.$_SESSION['skin'], $id); } function make_id($append_to_id="") { - $ret = $this->_tpl; + $ret = ($this->_page_type == NO_SKIN ? "noskin|" : "") . $this->_tpl; if($append_to_id) $ret.="|$append_to_id"; diff --git a/include/xorg.session.inc.php b/include/xorg.session.inc.php index 72fbf05..0126f66 100644 --- a/include/xorg.session.inc.php +++ b/include/xorg.session.inc.php @@ -215,20 +215,19 @@ function start_connexion ($username, $uid, $identified) { function set_skin() { if(logged()) { - $result = mysql_query("SELECT skin,skin_tpl,skin_popup + $result = mysql_query("SELECT skin,skin_tpl FROM auth_user_md5 AS a INNER JOIN skins AS s ON a.skin=s.id WHERE user_id='{$_SESSION['uid']}' AND skin_tpl != ''"); - if(list($_SESSION['skin_id'], $_SESSION['skin'], $_SESSION['skin_popup']) = mysql_fetch_row($result)) { + if(list($_SESSION['skin_id'], $_SESSION['skin']) = mysql_fetch_row($result)) { if ($_SESSION['skin_id'] == SKIN_STOCHASKIN_ID) { - $res = mysql_query("SELECT id,skin,skin_popup FROM skins + $res = mysql_query("SELECT id,skin FROM skins WHERE !FIND_IN_SET('cachee',type) order by rand() limit 1"); - list($_SESSION['skin_id'], $_SESSION['skin'], $_SESSION['skin_popup']) = mysql_fetch_row($res); + list($_SESSION['skin_id'], $_SESSION['skin']) = mysql_fetch_row($res); mysql_free_result($res); } } else { $_SESSION['skin'] = SKIN_COMPATIBLE; $_SESSION['skin_id'] = SKIN_COMPATIBLE_ID; - $_SESSION['skin_popup'] = SKIN_POPUP_COMPATIBLE; } mysql_free_result($result); } @@ -238,7 +237,6 @@ function set_skin() { { $_SESSION['skin'] = SKIN_COMPATIBLE; $_SESSION['skin_id'] = SKIN_COMPATIBLE_ID; - $_SESSION['skin_popup'] = SKIN_POPUP_COMPATIBLE; } } diff --git a/templates/rss.tpl b/templates/rss.tpl index a1afeec..a6e0578 100644 --- a/templates/rss.tpl +++ b/templates/rss.tpl @@ -1,4 +1,4 @@ -{* $Id: rss.tpl,v 1.1 2004-02-04 19:47:47 x2000habouzit Exp $ *} +{* $Id: rss.tpl,v 1.2 2004-02-19 13:22:05 x2000habouzit Exp $ *} -{$line.titre|strip_tags} +{$line.titre|strip_tags|escape:"html"} http://{$smarty.server.SERVER_NAME}/login.php#newsid{$line.id} {/foreach}