}
// }}}
-// {{{ menu HOOK
-
-
-function wiki_menu()
-{
- global $globals;
- if ($globals->wiki->wiki_enable) {
-// $globals->menu->addPrivateEntry(XOM_INFORMATIONS, 40, 'Documentations', 'wiki.php/Docs');
- }
-}
-
-// }}}
?>
require_once 'xorg.inc.php';
-// this page is to create a smarty template page from a wiki file
-// the wiki engine used is pmwiki.
-// the templates created are stored in wiki.d/cache_wikiword.tpl
-
-// some page can be seen by everybody (public), but to validate a password
-// if we arrive here before setting new access we need to try an auth
-new_skinned_page('wiki.tpl');
-
-if ($globals->wiki->wikidir) {
- $wikisite = 'xorg';
- require_once 'wiki.inc.php';
- $page->changeTpl($wiki_template);
+new_skinned_page('');
+if (!S::identified()) {
+ XorgSession::doAuth();
}
+require_once 'wiki.inc.php';
+$page->changeTpl($wiki_template);
+
if (!Env::get('action')) {
$page->addJsLink('javascript/wiki.js');
}
* Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
***************************************************************************/
-$wikisites = array('xorg','xnet');
function wiki_pagename() {
- $n = str_replace('/', '.', Env::get('n', false));
- if (!$n) {
+ if (!Env::get('n')) {
return null;
}
- $keywords = explode('.', $n);
- $count = count($keywords);
- if ($count == 1)
- $n = $keywords[0].".".$keywords[0];
- else
- $n = $keywords[$count - 2].".".$keywords[$count - 1];
+
+ $words = explode('/', Env::get('n'));
+ if (count($words) == 2) {
+ return join('.', $words);
+ }
+
+ array_unshift($words, $words[0]);
+ $b = array_pop($words);
+ $a = array_pop($words);
+
global $globals;
- if (($urln = str_replace('.', '/', $n)) != Env::get('n') && $n != Env::get('n'))
- redirect($globals->baseurl.'/'.$urln);
- $_REQUEST['n'] = $n;
- return $n;
+ redirect($globals->baseurl.'/'.$a.'/'.$b);
}
function wiki_work_dir() {
global $globals;
- return dirname(__FILE__).'/../htdocs/'.$globals->wiki->workdir;
-}
-
-function wiki_template($n) {
- global $wikisite;
- return $tpl = wiki_work_dir().'/cache_'.$wikisite.'_'.$n.'.tpl';
-}
-
-// several files are used for wiki :
-// - spool/wiki.d/PageName : the wiki page
-// - spool/wiki.d/cache_PageName.tpl : the template cache
-// - spool/templates_c/%%...%%cache_PageName.tpl.php : the PHP from Smarty
-function wiki_clear_cache($n) {
- global $page, $wikisite, $wikisites;
- $oldwikisite = $wikisite;
- foreach ($wikisites as $s) {
- $wikisite = $s;
- $tpl = wiki_template($n);
- @unlink($tpl);
- $page->clear_compiled_tpl($tpl);
- }
- $wikisite = $oldwikisite;
+ return $globals->spoolroot.'/spool/wiki.d';
}
function wiki_clear_all_cache()
function wiki_assign_auth() {
global $page, $wiki_auths;
- $page->assign('logged', S::logged());
+ $page->assign('true', true);
+ $page->assign('public', true);
+ $page->assign('logged', S::logged());
$page->assign('identified', S::identified());
- $page->assign('has_perms', S::has_perms());
- $page->assign('public', true);
- $page->assign('wiki_admin', S::has_perms() && S::identified());
+ $page->assign('has_perms', S::has_perms());
}
// cannot be in a function because pmwiki use all vars as if it was globals
-//function new_wiki_page() {
- // the wiki keword is given in the n var
- if ( $n = wiki_pagename() )
- {
+if ($n = wiki_pagename()) {
+ $wiki_template = wiki_work_dir().'/cache_'.$n.'.tpl';
+ $tmpfile_exists = file_exists($wiki_template);
- $wiki_template = wiki_template($n);
- $tmpfile_exists = file_exists($wiki_template);
+ if (Env::get('action') || !$tmpfile_exists) {
+ if ($tmpfile_exists) {
+ @unlink($wiki_template);
+ $page->clear_compiled_tpl($wiki_template);
+ }
- // don't recreate the tpl if it already exists
- if (Env::get('action') || !$tmpfile_exists)
- {
- if ($tmpfile_exists) {
- wiki_clear_cache($n);
- }
+ // we leave pmwiki do whatever it wants and store everything
+ ob_start();
+ require_once($globals->spoolroot.'/wiki/pmwiki.php');
- // we leave pmwiki do whatever it wants and store everything
- ob_start();
- require_once($globals->spoolroot.'/'.$globals->wiki->wikidir.'/pmwiki.php');
+ $wikiAll = ob_get_clean();
+ // the pmwiki skin we are using (almost empty) has these keywords:
+ $i = strpos($wikiAll, "<!--/HeaderText-->");
+ $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
+ }
- $wikiAll = ob_get_clean();
- // the pmwiki skin we are using (almost empty) has these keywords:
- $i = strpos($wikiAll, "<!--/HeaderText-->");
- $j = strpos($wikiAll, "<!--/PageLeftFmt-->", $i);
+ if (Env::get('action')) {
+ // clean old tmp files
+ wiki_clean_tmp();
+ $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
+ // create new tmp files with editing page from wiki engine
+ $wiki_template = wiki_create_tmp(substr($wikiAll, $j));
+ } else {
+ if (!$tmpfile_exists) {
+ $f = fopen($wiki_template, 'w');
+ fputs($f, substr($wikiAll, $j));
+ fclose($f);
}
- if (Env::get('action'))
- {
- // clean old tmp files
- wiki_clean_tmp();
- $page->assign('xorg_extra_header', substr($wikiAll, 0, $i));
- // create new tmp files with editing page from wiki engine
- $wiki_template = wiki_create_tmp(substr($wikiAll, $j));
- } else {
- if (!$tmpfile_exists)
- {
- $f = fopen($wiki_template, 'w');
- fputs($f, substr($wikiAll, $j));
- fclose($f);
- }
- }
}
- //return $wiki_template;
-//}
+}
?>
<?php if (!defined('PmWiki')) exit();
+require_once 'wiki.inc.php';
+
$ScriptUrl = $globals->baseurl;
$UploadUrlFmt = $ScriptUrl."/uploads";
-$WorkDir = $globals->wiki->workdir;
+$WorkDir = '../spool/wiki.d';
$WikiDir = new PageStore('$FarmD/'.$WorkDir.'/$FullName');
$PubDirUrl = $globals->baseurl.'/wiki';
$InterMapFiles[] = $globals->spoolroot.'plugins/pmwiki.intermap.txt';
Les différentes restrictions possibles sont :
<ul>
<li><strong>public:</strong> (pour tout le monde)</li>
- <li><strong>only_public:</strong> (pour les gens non connectés et non identifiés)</li>
<li><strong>logged:</strong> (pour ceux qui ont rentré leur mot de passe ou qui ont un cookie permanent)</li>
<li><strong>identified:</strong> (exige une identification par mot de passe)</li>
<li><strong>has_perms:</strong> (pour les administrateurs de la page)</li>
</ul>
Le <strong>:</strong> à la fin de chaque mot clef est important. Tu peux également combiner plusieurs mots clefs avec <strong>and:</strong>
ou des espaces (qui remplace le <em>ou</em> logique)<br/>"));
-
+
include_once($globals->spoolroot."/plugins/pmwiki.platalAuth.php");
include_once($globals->spoolroot."/plugins/pmwiki.platalSkin.php");
@include_once("$FarmD/cookbook/e-protect.php");
$DefaultPasswords['upload'] = 'has_perms: and: identified:';
$EnableGUIButtons = 1;
-$EnableUpload = 1;
-$LinkWikiWords = 0; # disable WikiWord links
-$EnableIMSCaching = 1; # allow browser caching
-
-## If you want to have to approve links to external sites before they
-## are turned into links, uncomment the line below. See PmWiki.UrlApprovals.
-## Also, setting $UnapprovedLinkCountMax limits the number of unapproved
-## links that are allowed in a page (useful to control wikispam).
-# include_once('scripts/urlapprove.php');
-# $UnapprovedLinkCountMax = 10;
+$EnableUpload = 1;
+$LinkWikiWords = 0; # disable WikiWord links
+$EnableIMSCaching = 1; # allow browser caching
## The following lines make additional editing buttons appear in the
## edit page for subheadings, lists, tables, etc.
'||border=1 width=80%\\n||!Hdr ||!Hdr ||!Hdr ||\\n|| || || ||\\n|| || || ||\\n', '', '',
'$GUIButtonDirUrlFmt/table.gif"$[Table]"');
-if (function_exists('more_wiki_config'))
- more_wiki_config();
?>
$Conditions['identified'] = S::identified();
$Conditions['has_perms'] = S::has_perms();
$Conditions['public'] = 'true';
-$Conditions['only_public'] = !S::identified();
-$HandleAuth['diff'] = 'edit';
-$HandleAuth['source'] = 'edit';
+$HandleAuth['diff'] = 'edit';
+$HandleAuth['source'] = 'edit';
-$InputTags['e_textarea'][':html'] =
- "<textarea \$InputFormArgs
- onkeydown='if (event.keyCode==27) event.returnValue=false;'
+$InputTags['e_textarea'][':html'] = "<textarea \$InputFormArgs
+ onkeydown='if (event.keyCode==27) event.returnValue=false;'
>{literal}\$EditText{/literal}</textarea>";
// impossible to see the diff without the source because of the smarty tags
$auth = $smarty?"":false;
$and = false;
foreach ($words as $word) {
- if (strpos($word, '@') === 0) $word = substr($word,1);
+ if (strpos($word, '@') === 0) $word = substr($word,1);
$iauth = false;
if ($word == 'and:') {
$and = true;
if ($cond == 'identified' && $could) {
$cond = 'logged';
}
- if ($smarty)
- $iauth = '$'.$cond.($param?(' eq "'.$param.'"'):'');
- else
- {
- if (strpos($cond, "smarty.") === 0)
- {
- $vars = explode('.', $cond);
- $iauth = false;
- switch ($vars[1])
- {
- case 'session':$iauth = S::v($vars[2]) == $param; break;
- case 'request':$iauth = Env::get($vars[2]) == $param; break;
- }
- }
- else $iauth = CondText($pagename, 'if '.$cond.' '.$param, true);
- }
+ if ($smarty) {
+ $iauth = '$'.$cond.($param?(' eq "'.$param.'"'):'');
+ } else {
+ if (strpos($cond, "smarty.") === 0) {
+ $vars = explode('.', $cond);
+ $iauth = false;
+ switch ($vars[1])
+ {
+ case 'session':$iauth = S::v($vars[2]) == $param; break;
+ case 'request':$iauth = Env::get($vars[2]) == $param; break;
+ }
+ }
+ else $iauth = CondText($pagename, 'if '.$cond.' '.$param, true);
+ }
if ($and) {
- if ($smarty)
- $auth = ($auth?"($auth) and ":"").$iauth;
- else
- $auth &= $iauth;
+ if ($smarty)
+ $auth = ($auth?"($auth) and ":"").$iauth;
+ else
+ $auth &= $iauth;
} else {
- if ($smarty)
- $auth = ($auth?"($auth) or ":"").$iauth;
- else
- $auth |= $iauth;
+ if ($smarty)
+ $auth = ($auth?"($auth) or ":"").$iauth;
+ else
+ $auth |= $iauth;
}
$and = false;
}
- if ($smarty)
- $auth = "($auth) or \$wiki_admin";
return $auth;
}
function auth_pmwiki_to_smarty($text, $pass)
{
$ifc = authPerms("", $pass, false, true);
- if (!$ifc) return "";
- return "{if $ifc}\n".$text."{/if}";
+ if (!$ifc)
+ return "";
+ return "{if $ifc}\n".$text."\n{else}(:div class='erreur':Droits insuffisants.:){/if}";
}
// for read pages: will come only once so we have to be careful
// and translate any auth from the wiki to smarty auth
-function AuthPlatal($pagename, $level, $authprompt, $since)
+function AuthPlatal($pagename, $level, $authprompt)
{
global $Conditions, $page;
$authUser = false;
$authPage = false;
- $page_read = ReadPage($pagename, $since);
+ $page_read = ReadPage($pagename);
$groupattr = FmtPageName('$Group/GroupAttributes', $pagename);
- $group_read = ReadPage($groupattr, $since);
+ $group_read = ReadPage($groupattr);
$levels = array('read', 'attr', 'edit', 'upload');
- foreach ($levels as $l)
- {
+ foreach ($levels as $l) {
list($from, $pass) = TryAllAuths($pagename, $l, $page_read, $group_read);
- $passwds[$l] = $pass;
+ $passwds[$l] = $pass;
$pwsources[$l] = $from;
}
$panel .= "{/if}\n";
$panel .= ">><<\n";
$panel .= "{/if}\n";
-
+
if ((S::identified() && S::has_perms()) || authPerms($pagename, $passwds[$level]))
{
- $page_read['=passwd'] = $passwds;
+ $page_read['=passwd'] = $passwds;
$page_read['=pwsource'] = $pwsources;
- // if try to read, add the permission limitation as a smarty if tag
- if ($level == 'read')
- {
- $page_read['text'] = auth_pmwiki_to_smarty($page_read['text'], $passwds['read']);
- $page_read['text'] = $panel.$page_read['text'];
- }
-// print_r($page_read); die();
+
+ // if try to read, add the permission limitation as a smarty if tag
+ if ($level == 'read') {
+ $page_read['text'] = auth_pmwiki_to_smarty($page_read['text'], $passwds['read']);
+ $page_read['text'] = $panel.$page_read['text'];
+ }
+
return $page_read;
}
// if we arrive here, the user doesn't have enough permission to access page
- // FIXME: seems to be broken, will be better soon
- new_skinned_page('index.tpl');
// maybe it is because he is not identified
- if ($authprompt && !S::identified())
- {
- XorgSession::doAuth();
+ if ($authprompt && !S::identified()) {
+ require_once dirname(__FILE__).'/../classes/Platal.php';
+ require_once dirname(__FILE__).'/../classes/PLModule.php';
+ $platal = new Platal();
+ $platal->force_login($page);
}
- XorgSession::doAuth();
if (S::has_perms()) {
$page->trig('Erreur : page Wiki inutilisable sur plat/al');
- } else {
- $page->trig("Tu n'as pas le droit d'accéder à ce service");
}
$page->run();
- // don't return false or pmwiki will send an exit breaking smarty page
- return 1;
}
?>
type='hidden' name='action' value='edit' /><input
type='hidden' name='n' value='{\$FullName}' /><input
type='hidden' name='basetime' value='\$EditBaseTime' /></div>");
-
+
// set profiles to point to plat/al fiche
Markup('[[~platal', '<[[~', '/\[\[~([^|\]]*)\|([^\]]*)\]\]/e',
'PreserveText("=", \'<a href="profile/$1" class="popup2">$2</a>\', "")');