-Subproject commit 2b27ff99ce8ff74aa0e8a2a3e51c02d1c0655e13
+Subproject commit ec537891a3f18af89489062c0907523d3d57cced
$table_editor->apply($page, $action, $id);
}
- function handler_wiki(&$page, $action='list', $wikipage='', $wikipage2='')
+ function handler_wiki(&$page, $action = 'list', $wikipage = null, $wikipage2 = null)
{
- require_once 'wiki.inc.php';
-
if (S::v('core_rss_hash')) {
$page->setRssLink('Changement Récents',
'/Site/AllRecentChanges?action=rss&user=' . S::v('forlife') . '&hash=' . S::v('core_rss_hash'));
S::assert_xsrf_token();
$perms_read = Post::v('read');
- $perms_edot = Post::v('edit');
+ $perms_edit = Post::v('edit');
if ($perms_read || $perms_edit) {
- foreach ($_POST as $wiki_page => $val) if ($val == 'on') {
- $wiki_page = str_replace('_', '/', $wiki_page);
- if (!$perms_read || !$perms_edit)
- list($perms0, $perms1) = wiki_get_perms($wiki_page);
- if ($perms_read)
- $perms0 = $perms_read;
- if ($perms_edit)
- $perms1 = $perms_edit;
- wiki_set_perms($wiki_page, $perms0, $perms1);
+ foreach ($_POST as $wiki_page => $val) {
+ if ($val == 'on') {
+ $wp = new PlWikiPage(str_replace(array('_', '/'), '.', $wiki_page));
+ if ($wp->setPerms($perms_read ? $perms_read : $wp->readPerms(),
+ $perms_edit ? $perms_edit : $wp->writePerms())) {
+ $page->trigSuccess("Permission de la page $wiki_page mises à jour");
+ } else {
+ $page->trigError("Impossible de mettre les permissions de la page $wiki_page à jour");
+ }
+ }
}
}
- }
-
- if ($action == 'delete' && $wikipage != '') {
+ } else if ($action != 'list' && !empty($wikipage)) {
+ $wp = new PlWikiPage($wikipage);
S::assert_xsrf_token();
- if (wiki_delete_page($wikipage)) {
- $page->trigSuccess("La page ".$wikipage." a été supprimée.");
- } else {
- $page->trigError("Impossible de supprimer la page ".$wikipage.".");
- }
- }
-
- if ($action == 'rename' && $wikipage != '' && $wikipage2 != '' && $wikipage != $wikipage2) {
- S::assert_xsrf_token();
-
- if ($changedLinks = wiki_rename_page($wikipage, $wikipage2)) {
- $s = 'La page <em>'.$wikipage.'</em> a été déplacée en <em>'.$wikipage2.'</em>.';
- if (is_numeric($changedLinks)) {
- $s .= $changedLinks.' lien'.(($changedLinks>1)?'s ont été modifiés.':' a été modifié.');
+ if ($action == 'delete') {
+ if ($wp->delete()) {
+ $page->trigSuccess("La page ".$wikipage." a été supprimée.");
+ } else {
+ $page->trigError("Impossible de supprimer la page ".$wikipage.".");
+ }
+ } else if ($action == 'rename' && !empty($wikipage2) && $wikipage != $wikipage2) {
+ if ($changedLinks = $wp->rename($wikipage2)) {
+ $s = 'La page <em>'.$wikipage.'</em> a été déplacée en <em>'.$wikipage2.'</em>.';
+ if (is_numeric($changedLinks)) {
+ $s .= $changedLinks.' lien'.(($changedLinks>1)?'s ont été modifiés.':' a été modifié.');
+ }
+ $page->trigSuccess($s);
+ } else {
+ $page->trigError("Impossible de déplacer la page ".$wikipage);
}
- $page->trigSuccess($s);
- } else {
- $page->trigError("Impossible de déplacer la page ".$wikipage);
}
}
- $perms = wiki_perms_options();
+ $perms = PlWikiPage::permOptions();
// list wiki pages and their perms
- $wiki_pages = array();
- $dir = wiki_work_dir();
- if (is_dir($dir)) {
- if ($dh = opendir($dir)) {
- while (($file = readdir($dh)) !== false) if (substr($file,0,1) >= 'A' && substr($file,0,1) <= 'Z') {
- list($read,$edit) = wiki_get_perms($file);
- $wiki_pages[$file] = array('read' => $perms[$read], 'edit' => $perms[$edit]);
- if (is_file($dir . '/cache_' . wiki_filename($file) . '.tpl')) {
- $wiki_pages[$file]['cached'] = true;
- }
- }
- closedir($dh);
- }
- }
+ $wiki_pages = PlWikiPage::listPages();
ksort($wiki_pages);
$wiki_tree = array();
foreach ($wiki_pages as $file => $desc) {
function handler_antispam(&$page, $statut_filtre = null)
{
require_once 'emails.inc.php';
- require_once('wiki.inc.php');
- wiki_require_page('Xorg.Antispam');
+ $wp = new PlWikiPage('Xorg.Antispam');
+ $wp->buildCache();
$page->changeTpl('emails/antispam.tpl');
function handler_submit(&$page)
{
- require_once('wiki.inc.php');
- wiki_require_page('Xorg.Mails');
+ $wp = new PlWikiPage('Xorg.Mails');
+ $wp->buildCache();
$page->changeTpl('emails/submit_spam.tpl');
if (Post::has('send_email')) {
function handler_broken(&$page, $warn = null, $email = null)
{
require_once 'emails.inc.php';
- require_once('wiki.inc.php');
- wiki_require_page('Xorg.PatteCassée');
+ $wp = new PlWikiPage('Xorg.PatteCassée');
+ $wp->buildCache();
global $globals;
$page->changeTpl('events/submit.tpl');
$page->addJsLink('ajax.js');
- require_once('wiki.inc.php');
- wiki_require_page('Xorg.Annonce');
+ $wp = new PlWikiPage('Xorg.Annonce');
+ $wp->buildCache();
$titre = Post::v('titre');
$texte = Post::v('texte');
$page->changeTpl('newsletter/submit.tpl');
require_once 'newsletter.inc.php';
- require_once 'wiki.inc.php';
- wiki_require_page('Xorg.LettreMensuelle');
+ $wp = new PlWikiPage('Xorg.LettreMensuelle');
+ $wp->buildCache();
if (Post::has('see') || (Post::has('valid') && (!trim(Post::v('title')) || !trim(Post::v('body'))))) {
if (!Post::has('see')) {
$page->changeTpl('platal/acces_smtp.tpl');
$page->setTitle('Polytechnique.org - Acces SMTP/NNTP');
- require_once 'wiki.inc.php';
- wiki_require_page('Xorg.SMTPSécurisé');
- wiki_require_page('Xorg.NNTPSécurisé');
+ $wp = new PlWikiPage('Xorg.SMTPSécurisé');
+ $wp->buildCache();
+ $wp = new PlWikiPage('Xorg.NNTPSécurisé');
+ $wp->buildCache();
$uid = S::v('uid');
$pass = Env::v('smtppass1');
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);
+ $wp = new PlWikiPage($dom . '.Admin');
+ $conf = explode('%0a', $wp->getField('text'));
$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);
public function prepare(PlPage &$page, $id)
{
- require_once 'wiki.inc.php';
- $dom = (@$GLOBALS['IS_XNET_SITE'] ? 'ReviewXnet' : 'Review') . '.' . ucfirst($id);
- wiki_require_page($dom);
- $page->assign('cacheExists', wiki_work_dir() . '/cache_' . $dom . '.tpl');
- $page->assign('article', $dom);
+ $wp = new PlWikiPage((@$GLOBALS['IS_XNET_SITE'] ? 'ReviewXnet' : 'Review') . '.' . ucfirst($id));
+ $wp->buildCache();
+ $page->assign('cacheExists', $wp->cacheFilename());
+ $page->assign('article', $wp->name);
}
}
function handler_ref_search(&$page, $action = null, $subaction = null)
{
- require_once 'wiki.inc.php';
- wiki_require_page('Docs.Emploi');
+ $wp = new PlWikiPage('Docs.Emploi');
+ $wp->buildCache();
+
$page->setTitle('Polytechnique.org - Conseil Pro');
//recuperation des noms de secteurs
switch ($sub_state['step']) {
case 0:
- require_once('wiki.inc.php');
- wiki_require_page('Reference.Charte');
+ $wp = new PlWikiPage('Reference.Charte');
+ $wp->buildCache();
if (Post::has('step1')) {
$sub_state['step'] = 1;
if (isset($sub_state['hash'])) {