From ddb649901f5a88d695a7050f2a59da140842ec89 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sat, 22 Sep 2007 00:03:34 +0200 Subject: [PATCH] New main page of the site with a multi-topic site preview based on PlWizard with configuration and sources taken from specific wiki pages. This still need CSS customization, but I won't do this, so, either somebody takes this task, or this will remain ugly. Signed-off-by: Florent Bruneau --- ChangeLog | 3 +++ classes/plwizard.php | 18 +++++++++++++----- modules/platal.php | 30 +++++++++++++++++++++++++++++- modules/platal/review.inc.php | 40 ++++++++++++++++++++++++++++++++++++++++ modules/profile.php | 2 +- modules/profile/decos.inc.php | 4 ++-- modules/profile/general.inc.php | 4 ++-- modules/profile/groups.inc.php | 4 ++-- modules/profile/jobs.inc.php | 4 ++-- modules/profile/mentor.inc.php | 4 ++-- modules/profile/page.inc.php | 2 +- modules/profile/skills.inc.php | 4 ++-- templates/core/plwizard.tpl | 36 ++++++++++++++++++++++++++++++++++-- templates/platal/review.tpl | 27 +++++++++++++++++++++++++++ 14 files changed, 160 insertions(+), 22 deletions(-) create mode 100644 modules/platal/review.inc.php create mode 100644 templates/platal/review.tpl diff --git a/ChangeLog b/ChangeLog index d41f469..fdc829b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,9 @@ New: * Lists: - Asynchronous mail moderation (should avoid server overload) -FRU + * Platal: + - New default page with a flexible multi-topic presentation -FRU + * Profile: - #28: Use group/subscription list from Xnet -FRU diff --git a/classes/plwizard.php b/classes/plwizard.php index b5affd1..78242f2 100644 --- a/classes/plwizard.php +++ b/classes/plwizard.php @@ -37,7 +37,7 @@ interface PlWizardPage /** Prepare the page by assigning to it any useful value. */ - public function prepare(PlatalPage &$page); + public function prepare(PlatalPage &$page, $id); /** Process information resulting of the application of the page. * This function must return a clue indicating the next page to show. @@ -67,13 +67,14 @@ class PlWizard protected $name; protected $layout; protected $stateless; + protected $ajax; protected $pages; protected $titles; protected $lookup; protected $inv_lookup; - public function __construct($name, $layout, $stateless = false) + public function __construct($name, $layout, $stateless = false, $ajax = true) { $this->name = 'wiz_' . $name; $this->layout = $layout; @@ -81,6 +82,7 @@ class PlWizard $this->pages = array(); $this->lookup = array(); $this->titles = array(); + $this->ajax = $ajax; if (!isset($_SESSION[$this->name])) { $_SESSION[$this->name] = array(); $_SESSION[$this->name . '_page'] = null; @@ -136,7 +138,7 @@ class PlWizard return new $page($this); } - public function apply(PlatalPage &$smarty, $baseurl, $pgid = null) + public function apply(PlatalPage &$smarty, $baseurl, $pgid = null, $mode = 'normal') { if ($this->stateless && (isset($this->lookup[$pgid]) || isset($this->pages[$pgid]))) { $curpage = is_numeric($pgid) ? $pgid : $this->lookup[$pgid]; @@ -194,16 +196,22 @@ class PlWizard } else if (!isset($page)) { $page = $this->getPage($curpage); } - $smarty->changeTpl($this->layout); + if ($mode == 'ajax') { + header('Content-Type: text/html; charset=utf-8'); + $smarty->changeTpl($page->template(), NO_SKIN); + } else { + $smarty->changeTpl($this->layout); + } $smarty->assign('pages', $this->titles); $smarty->assign('current', $curpage); $smarty->assign('lookup', $this->inv_lookup); $smarty->assign('stateless', $this->stateless); $smarty->assign('wiz_baseurl', $baseurl); + $smarty->assign('wiz_ajax', $this->ajax); $smarty->assign('tab_width', (int)(99 / count($this->pages))); $smarty->assign('wiz_page', $page->template()); $smarty->assign('xorg_no_errors', true); - $page->prepare($smarty); + $page->prepare($smarty, isset($this->inv_lookup[$curpage]) ? $this->inv_lookup[$curpage] : $curpage); } } diff --git a/modules/platal.php b/modules/platal.php index 4ba4740..9ef16e4 100644 --- a/modules/platal.php +++ b/modules/platal.php @@ -39,7 +39,7 @@ class PlatalModule extends PLModule { return array( 'index' => $this->make_hook('index', AUTH_PUBLIC), - 'cacert.pem' => $this->make_hook('cacert', AUTH_PUBLIC), + 'cacert.pem' => $this->make_hook('cacert', AUTH_PUBLIC), 'changelog' => $this->make_hook('changelog', AUTH_PUBLIC), // Preferences thingies @@ -55,6 +55,7 @@ class PlatalModule extends PLModule 'password/smtp' => $this->make_hook('smtppass', AUTH_MDP), 'recovery' => $this->make_hook('recovery', AUTH_PUBLIC), 'exit' => $this->make_hook('exit', AUTH_PUBLIC), + 'review' => $this->make_hook('review', AUTH_PUBLIC), 'deconnexion.php' => $this->make_hook('exit', AUTH_PUBLIC), ); } @@ -63,6 +64,8 @@ class PlatalModule extends PLModule { if (S::logged()) { pl_redirect('events'); + } else if (!@$GLOBALS['IS_XNET_SITE']) { + pl_redirect('review'); } } @@ -417,6 +420,31 @@ Adresse de secours : " . Post::v('email') : "")); $page->changeTpl('platal/exit.tpl'); } } + + function handler_review(&$page, $action = null, $mode = null) + { + require_once 'wiki.inc.php'; + require_once dirname(__FILE__) . '/platal/review.inc.php'; + $dir = wiki_work_dir(); + $dom = 'Review'; + if (@$GLOBALS['IS_XNET_SITE']) { + $dom .= 'Xnet'; + } + if (!is_dir($dir)) { + $page->kill("Impossible de trouver le wiki"); + } + if (!file_exists($dir . '/' . $dom . '.Admin')) { + $page->kill("Impossible de trouver la page d'administration"); + } + $conf = preg_grep('/^text=/', explode("\n", file_get_contents($dir . '/' . $dom . '.Admin'))); + $conf = preg_split('/(text\=|\%0a)/', array_shift($conf), -1, PREG_SPLIT_NO_EMPTY); + $wiz = new PlWizard('Tour d\'horizon', 'core/plwizard.tpl', true); + foreach ($conf as $line) { + $list = preg_split('/\s*[*|]\s*/', $line, -1, PREG_SPLIT_NO_EMPTY); + $wiz->addPage('ReviewPage', $list[0], $list[1]); + } + $wiz->apply($page, 'review', $action, $mode); + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: diff --git a/modules/platal/review.inc.php b/modules/platal/review.inc.php new file mode 100644 index 0000000..3cf4f27 --- /dev/null +++ b/modules/platal/review.inc.php @@ -0,0 +1,40 @@ +assign('article', $dom); + } +} + +// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: +?> diff --git a/modules/profile.php b/modules/profile.php index 2fede87..00969c2 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -329,7 +329,7 @@ class ProfileModule extends PLModule $page->addJsLink('ajax.js'); $page->addJsLink('jquery.js'); - $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true); + $wiz = new PlWizard('Profil', 'core/plwizard.tpl', true, false); require_once dirname(__FILE__) . '/profile/page.inc.php'; $wiz->addPage('ProfileGeneral', 'Général', 'general'); $wiz->addPage('ProfileAddresses', 'Adresses personnelles', 'adresses'); diff --git a/modules/profile/decos.inc.php b/modules/profile/decos.inc.php index ebd8f12..9aaea5e 100644 --- a/modules/profile/decos.inc.php +++ b/modules/profile/decos.inc.php @@ -115,9 +115,9 @@ class ProfileDecos extends ProfilePage } } - public function prepare(PlatalPage &$page) + public function prepare(PlatalPage &$page, $id) { - parent::prepare($page); + parent::prepare($page, $id); $res = XDB::iterator("SELECT * FROM profile_medals_grades ORDER BY mid, pos"); diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index 3e66990..3cd19e4 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -197,9 +197,9 @@ class ProfileGeneral extends ProfilePage } } - public function prepare(PlatalPage &$page) + public function prepare(PlatalPage &$page, $id) { - parent::prepare($page); + parent::prepare($page, $id); require_once "applis.func.inc.php"; } } diff --git a/modules/profile/groups.inc.php b/modules/profile/groups.inc.php index a967b94..f274eb6 100644 --- a/modules/profile/groups.inc.php +++ b/modules/profile/groups.inc.php @@ -105,9 +105,9 @@ class ProfileGroups extends ProfilePage $this->settings['binets'] = new ProfileGroup('binets', 'user_id', 'binet_id'); } - public function prepare(PlatalPage &$page) + public function prepare(PlatalPage &$page, $id) { - parent::prepare($page); + parent::prepare($page, $id); $page->assign('mygroups', XDB::iterator("SELECT a.nom, a.site, a.diminutif, a.unsub_url, a.pub, m.perms FROM groupex.asso AS a INNER JOIN groupex.membres AS m ON (m.asso_id = a.id) diff --git a/modules/profile/jobs.inc.php b/modules/profile/jobs.inc.php index 5b497c9..4f79328 100644 --- a/modules/profile/jobs.inc.php +++ b/modules/profile/jobs.inc.php @@ -202,9 +202,9 @@ class ProfileJobs extends ProfilePage parent::saveData(); } - public function prepare(PlatalPage &$page) + public function prepare(PlatalPage &$page, $id) { - parent::prepare($page); + parent::prepare($page, $id); $page->assign('secteurs', XDB::iterator("SELECT id, label FROM emploi_secteur")); $page->assign('fonctions', XDB::iterator("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) AS title diff --git a/modules/profile/mentor.inc.php b/modules/profile/mentor.inc.php index 5928acd..fbc06ec 100644 --- a/modules/profile/mentor.inc.php +++ b/modules/profile/mentor.inc.php @@ -148,9 +148,9 @@ class ProfileMentor extends ProfilePage } } - public function prepare(PlatalPage &$page) + public function prepare(PlatalPage &$page, $id) { - parent::prepare($page); + parent::prepare($page, $id); $page->assign('secteurs_sel', XDB::iterator("SELECT id, label FROM emploi_secteur")); } diff --git a/modules/profile/page.inc.php b/modules/profile/page.inc.php index e06e247..e30023d 100644 --- a/modules/profile/page.inc.php +++ b/modules/profile/page.inc.php @@ -242,7 +242,7 @@ abstract class ProfilePage implements PlWizardPage return 'profile/base.tpl'; } - public function prepare(PlatalPage &$page) + public function prepare(PlatalPage &$page, $id) { if (count($this->values) == 0) { $this->fetchData(); diff --git a/modules/profile/skills.inc.php b/modules/profile/skills.inc.php index a922fc0..17444eb 100644 --- a/modules/profile/skills.inc.php +++ b/modules/profile/skills.inc.php @@ -89,9 +89,9 @@ class ProfileSkills extends ProfilePage $this->settings['langues'] = new ProfileSkill('langues', 'lid', 'langue_fr'); } - public function prepare(PlatalPage &$page) + public function prepare(PlatalPage &$page, $id) { - parent::prepare($page); + parent::prepare($page, $id); $page->assign('comp_list', XDB::iterator("SELECT id, text_fr, FIND_IN_SET('titre',flags) AS title FROM competences_def")); $page->assign('comp_level', array('initié' => 'initié', diff --git a/templates/core/plwizard.tpl b/templates/core/plwizard.tpl index 3a0d2ad..0f55d7a 100644 --- a/templates/core/plwizard.tpl +++ b/templates/core/plwizard.tpl @@ -19,13 +19,45 @@ {* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} {* *} {**************************************************************************} +{javascript name="jquery"} +
{foreach from=$pages item=title key=id} diff --git a/templates/platal/review.tpl b/templates/platal/review.tpl new file mode 100644 index 0000000..c43d65e --- /dev/null +++ b/templates/platal/review.tpl @@ -0,0 +1,27 @@ +{**************************************************************************} +{* *} +{* Copyright (C) 2003-2007 Polytechnique.org *} +{* http://opensource.polytechnique.org/ *} +{* *} +{* This program is free software; you can redistribute it and/or modify *} +{* it under the terms of the GNU General Public License as published by *} +{* the Free Software Foundation; either version 2 of the License, or *} +{* (at your option) any later version. *} +{* *} +{* This program is distributed in the hope that it will be useful, *} +{* but WITHOUT ANY WARRANTY; without even the implied warranty of *} +{* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *} +{* GNU General Public License for more details. *} +{* *} +{* You should have received a copy of the GNU General Public License *} +{* along with this program; if not, write to the Free Software *} +{* Foundation, Inc., *} +{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *} +{* *} +{**************************************************************************} + +
+ {include wiki=$article} +
+ +{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *} -- 2.1.4