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 <florent.bruneau@polytechnique.org>
* 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
/** 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.
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;
$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;
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];
} 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);
}
}
{
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
'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),
);
}
{
if (S::logged()) {
pl_redirect('events');
+ } else if (!@$GLOBALS['IS_XNET_SITE']) {
+ pl_redirect('review');
}
}
$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:
--- /dev/null
+<?php
+/***************************************************************************
+ * 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 *
+ ***************************************************************************/
+
+__autoload('PlWizard');
+
+class ReviewPage implements PlWizardPage
+{
+ public function __construct(PlWizard &$wiz) { }
+ public function template() { return 'platal/review.tpl'; }
+ public function process() { }
+
+ public function prepare(PlatalPage &$page, $id)
+ {
+ require_once 'wiki.inc.php';
+ $dom = (@$GLOBALS['IS_XNET_SITE'] ? 'ReviewXnet' : 'Review') . '.' . ucfirst($id);
+ wiki_require_page($dom);
+ $page->assign('article', $dom);
+ }
+}
+
+// vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8:
+?>
$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');
}
}
- 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");
}
}
- public function prepare(PlatalPage &$page)
+ public function prepare(PlatalPage &$page, $id)
{
- parent::prepare($page);
+ parent::prepare($page, $id);
require_once "applis.func.inc.php";
}
}
$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)
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
}
}
- 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"));
}
return 'profile/base.tpl';
}
- public function prepare(PlatalPage &$page)
+ public function prepare(PlatalPage &$page, $id)
{
if (count($this->values) == 0) {
$this->fetchData();
$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é',
{* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *}
{* *}
{**************************************************************************}
+{javascript name="jquery"}
+<script type="text/javascript">//<![CDATA[
+ {if ($stateless || $id gt $current) && $wiz_ajax}
+ {literal}
+ function changePage(obj, id)
+ {
+ var myUrl = obj.href;
+ $.ajax({ url: myUrl + "/ajax",
+ global: false,
+ dataTye: 'html',
+ error: function(request, error) {
+ document.location = myUrl;
+ },
+ success: function(data) {
+ $(".wiz_content").empty().prepend(data);
+ $(".wiz_tab").removeClass("active");
+ $("#wiz_tab_" + id).addClass("active");
+ }
+ });
+ return false;
+ }
+ {/literal}
+ {else}
+ {literal}
+ function changePage(obj)
+ {
+ return true;
+ }
+ {/literal}
+ {/if}
+//]]></script>
<div class="wizard" style="clear: both">
<div class="wiz_header">
{foreach from=$pages item=title key=id}
<div class="wiz_tab {if $id eq $current}active{/if} {if !$stateless && $current gt $id}grayed{/if}"
- style="float: left; width: {$tab_width}%">
- {if $stateless || $id gt $current}<a href="{$wiz_baseurl}/{$lookup[$id]}">{/if}
+ style="float: left; width: {$tab_width}%" id="wiz_tab_{$lookup[$id]}">
+ {if $stateless || $id gt $current}
+ <a href="{$wiz_baseurl}/{$lookup[$id]}" onclick="return changePage(this, '{$lookup[$id]}')">{/if}
{$title}
{if $stateless || $id gt $current}</a>{/if}
</div>
--- /dev/null
+{**************************************************************************}
+{* *}
+{* 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 *}
+{* *}
+{**************************************************************************}
+
+<div>
+ {include wiki=$article}
+</div>
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}