From: x2003bruneau Date: Sat, 24 Mar 2007 10:39:51 +0000 (+0000) Subject: Add a small tool for ajax wiki preview and use it on email/send and %grp/mail X-Git-Tag: xorg/0.9.14~180 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=fdbeba4fe89c2fc5a37f75088472c571138c001b;p=platal.git Add a small tool for ajax wiki preview and use it on email/send and %grp/mail git-svn-id: svn+ssh://murphy/home/svn/platal/trunk@1606 839d8a87-29fc-0310-9880-83ba4fa771e5 --- diff --git a/classes/miniwiki.php b/classes/miniwiki.php index 5c0c176..6357d9b 100644 --- a/classes/miniwiki.php +++ b/classes/miniwiki.php @@ -155,17 +155,10 @@ class MiniWiki unset(MiniWiki::$info[12]); } - $i = 0; - $res = '' . "\n"; - $res .= "\n"; + $res = array(); foreach (MiniWiki::$info as $value) { - $i++; - $res .= ''; - $res .= ''; - $res .= ''; - $res .= "\n"; + $res[$value] = MiniWiki::wikiToHtml($value, true); } - $res .= '
SyntaxeApparence
' . nl2br(htmlentities($value)) . '' . MiniWiki::wikiToHtml($value, true) . '
'; if (!$with_title) { MiniWiki::$info[12] = $info12; diff --git a/htdocs/javascript/ajax.js b/htdocs/javascript/ajax.js index 71382a9..bc523d8 100644 --- a/htdocs/javascript/ajax.js +++ b/htdocs/javascript/ajax.js @@ -109,4 +109,20 @@ function showTempMessage(id, message, success) setTimeout("_showTempMessage('" + id + "', " + currentTempMessage + ", 20)", 700); } +function previewWiki(idFrom, idTo, withTitle, idShow) +{ + var text = encodeURIComponent(document.getElementById(idFrom).value); + if (text == "") { + return false; + } + var url = "wiki_preview"; + if (!withTitle) { + url += "/notitle"; + } + Ajax.update_html(idTo, url + "?text=" + text); + if (idShow != null) { + document.getElementById(idShow).style.display = ""; + } +} + // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: diff --git a/modules/core.php b/modules/core.php index 9043210..ed58bac 100644 --- a/modules/core.php +++ b/modules/core.php @@ -30,7 +30,9 @@ class CoreModule extends PLModule 'send_bug' => $this->make_hook('bug', AUTH_COOKIE), 'purge_cache' => $this->make_hook('purge_cache', AUTH_COOKIE, 'admin'), 'get_rights' => $this->make_hook('get_rights', AUTH_MDP, 'admin'), - 'wiki_help' => $this->make_hook('wiki_help', AUTH_PUBLIC), + + 'wiki_help' => $this->make_hook('wiki_help', AUTH_PUBLIC), + 'wiki_preview' => $this->make_hook('wiki_preview', AUTH_COOKIE, 'user', NO_AUTH), 'valid.html' => $this->make_hook('valid', AUTH_PUBLIC), 'favicon.ico' => $this->make_hook('favicon', AUTH_PUBLIC), @@ -135,6 +137,15 @@ class CoreModule extends PLModule $page->changeTpl('core/wiki.help.tpl', SIMPLE); $page->assign('wiki_help', MiniWiki::help($action == 'title')); } + + /// Shared handler for wiki syntax result preview + function handler_wiki_preview(&$page, $action = 'title') + { + header('Content-Type: text/html; charset=utf-8'); + $text = Get::v('text'); + echo MiniWiki::wikiToHtml($text, $action == 'title'); + exit; + } } // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: diff --git a/modules/xnetgrp.php b/modules/xnetgrp.php index ba86720..4115206 100644 --- a/modules/xnetgrp.php +++ b/modules/xnetgrp.php @@ -290,6 +290,7 @@ class XnetGrpModule extends PLModule $mmlist = new MMList(S::v('uid'), S::v('password'), $globals->asso('mail_domain')); $page->assign('listes', $mmlist->get_lists()); + $page->addJsLink('ajax.js'); if (Post::has('send')) { $from = Post::v('from'); diff --git a/templates/core/wiki.help.tpl b/templates/core/wiki.help.tpl index bfb591e..fa417cb 100644 --- a/templates/core/wiki.help.tpl +++ b/templates/core/wiki.help.tpl @@ -22,6 +22,14 @@

Syntaxe wiki

-{$wiki_help|smarty:nodefaults} + + + {foreach from=$wiki_help key=syntax item=html} + + + + + {/foreach} +
SyntaxeApparence
{$syntax|nl2br}{$html|smarty:nodefaults}
{* vim:set et sws=2 sts=2 sw=2 enc=utf-8: *} diff --git a/templates/emails/send.tpl b/templates/emails/send.tpl index bb8e90e..0c0d1c7 100644 --- a/templates/emails/send.tpl +++ b/templates/emails/send.tpl @@ -93,6 +93,15 @@ function removeCc() { _move('cc_contacts', 'contacts'); } + + function updateWikiView(box) { + if (box.checked) { + document.getElementById("preview_bt").style.display = "none"; + document.getElementById("preview").style.display = "none"; + } else { + document.getElementById("preview_bt").style.display = ""; + } + } {/literal} //]]> @@ -195,15 +204,22 @@ {/if} -
Sujet : 
Tu peux utiliser des {icon name=information title="Syntaxe wiki"} marqueurs wiki pour formatter ton texte.
- + coche cette case pour envoyer le mail en texte brut, sans formattage
-