From 06a5e65b3b7109cee962cdf323660ab8086b5b89 Mon Sep 17 00:00:00 2001 From: x2000habouzit Date: Wed, 19 Jul 2006 21:50:32 +0000 Subject: [PATCH] tons of fixes and/or simplifications. but that's really clear: current method to deal with pmwiki is *way* too complicated, I can't understand a single line of that piece of code, and how it interacts with the rest. We don't need 10% of the complexity of what is currently developped. moreover, users can import any smarty tags in the text, which is awful :| git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@548 839d8a87-29fc-0310-9880-83ba4fa771e5 --- hooks/wiki.inc.php | 12 ----- htdocs/wiki.php | 18 +++---- include/wiki.inc.php | 120 ++++++++++++++++-------------------------- plugins/pmwiki.config.php | 22 +++----- plugins/pmwiki.platalAuth.php | 109 +++++++++++++++++--------------------- plugins/pmwiki.platalSkin.php | 2 +- 6 files changed, 108 insertions(+), 175 deletions(-) diff --git a/hooks/wiki.inc.php b/hooks/wiki.inc.php index 759a58b..b131f24 100644 --- a/hooks/wiki.inc.php +++ b/hooks/wiki.inc.php @@ -39,17 +39,5 @@ function wiki_config() } // }}} -// {{{ menu HOOK - - -function wiki_menu() -{ - global $globals; - if ($globals->wiki->wiki_enable) { -// $globals->menu->addPrivateEntry(XOM_INFORMATIONS, 40, 'Documentations', 'wiki.php/Docs'); - } -} - -// }}} ?> diff --git a/htdocs/wiki.php b/htdocs/wiki.php index 6db2203..188a574 100644 --- a/htdocs/wiki.php +++ b/htdocs/wiki.php @@ -21,20 +21,14 @@ 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'); } diff --git a/include/wiki.inc.php b/include/wiki.inc.php index 57a5f50..dbb7810 100644 --- a/include/wiki.inc.php +++ b/include/wiki.inc.php @@ -18,50 +18,28 @@ * 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() @@ -95,55 +73,47 @@ function wiki_clean_tmp() { 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, ""); + $j = strpos($wikiAll, "", $i); + } - $wikiAll = ob_get_clean(); - // the pmwiki skin we are using (almost empty) has these keywords: - $i = strpos($wikiAll, ""); - $j = strpos($wikiAll, "", $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; -//} +} ?> diff --git a/plugins/pmwiki.config.php b/plugins/pmwiki.config.php index e3d611b..14b0c0a 100644 --- a/plugins/pmwiki.config.php +++ b/plugins/pmwiki.config.php @@ -1,8 +1,10 @@ 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'; @@ -20,14 +22,13 @@ XLSDV('en', array('EnterAttributes' => Les différentes restrictions possibles sont : Le : à la fin de chaque mot clef est important. Tu peux également combiner plusieurs mots clefs avec and: ou des espaces (qui remplace le ou logique)
")); - + include_once($globals->spoolroot."/plugins/pmwiki.platalAuth.php"); include_once($globals->spoolroot."/plugins/pmwiki.platalSkin.php"); @include_once("$FarmD/cookbook/e-protect.php"); @@ -39,16 +40,9 @@ $DefaultPasswords['admin'] = 'has_perms: and: identified:'; $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. @@ -70,6 +64,4 @@ $GUIButtons['table'] = array(600, '||border=1 width=80%\\n||!Hdr ||!Hdr ||!Hdr ||\\n|| || || ||\\n|| || || ||\\n', '', '', '$GUIButtonDirUrlFmt/table.gif"$[Table]"'); -if (function_exists('more_wiki_config')) - more_wiki_config(); ?> diff --git a/plugins/pmwiki.platalAuth.php b/plugins/pmwiki.platalAuth.php index 646d3be..be37fbc 100644 --- a/plugins/pmwiki.platalAuth.php +++ b/plugins/pmwiki.platalAuth.php @@ -6,14 +6,12 @@ $Conditions['logged'] = S::logged(); $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'] = - "