3 $ROSPatterns['/\\(:faq:\\)/e'] = 'CreateFAQ()';
4 $HandleActions['faq'] = 'HandleFAQ';
5 $HandleActions['faqAnswer'] = 'HandleFAQAnswer';
7 Markup('faqNewQuestion','inline','/\\(:faqNewQuestion (\\w+) (\\w+):\\)/e',"newFAQ('$1', '$2')");
8 Markup('faqNewAnswer','inline','/\\(:faqNewAnswer (\\w+) (\\w+) (\\w+):\\)/e',"newFAQAnswer('$1', '$2', '$3')");
9 Markup('faqList','inline','/\\(:faqList (\\w+):\\)/','');
11 function CreateFAQ() {
12 $idfaq = substr(md5(rand()),0,4);
14 '!Foire aux questions'."\n".
15 '(:faqList '.$idfaq.':)'."\n".
16 '(:if auth edit:)(:faqNewQuestion '.$idfaq.' 1:)(:if:)';
19 function newFAQ($idfaq, $numquestion) {
20 return Keep('<h3>Poser une nouvelle question :</h3>
22 <input type="hidden" name="action" value="faq"/>
23 <input type="hidden" name="faqId" value="'.$idfaq.'"/>
24 <input type="hidden" name="numQuestion" value="'.$numquestion.'"/>
25 <input type="text" name="question" size="80"/>
29 function newFAQAnswer($idfaq, $numquestion, $numanswer) {
30 $idfaqanswer = 'faqAnswer-'.$idfaq.'-'.$numquestion.'-'.$numanswer;
31 return Keep('<blockquote>
32 <input type="button" value="Répondre" onclick="
33 this.style.display=\'none\';
34 var f = document.getElementById(\''.$idfaqanswer.'\');
37 <form method="post" id="'.$idfaqanswer.'" style="display:none">
38 <input type="hidden" name="action" value="faqAnswer"/>
39 <input type="hidden" name="faqId" value="'.$idfaq.'"/>
40 <input type="hidden" name="numQuestion" value="'.$numquestion.'"/>
41 <input type="hidden" name="numAnswer" value="'.$numanswer.'"/>
42 <textarea name="answer" rows="3" cols="80"></textarea>
44 <input type="submit" value="Envoyer la réponse"/>
49 function HandleFAQ() {
50 global $pagename, $CurrentTime, $Author;
52 if (isset($_REQUEST['question']) && $_REQUEST['question'] &&
53 ($page = RetrieveAuthPage($pagename, 'edit', true
))) {
54 $idfaq = stripmagic($_REQUEST['faqId']);
55 $question = stripmagic($_REQUEST['question']);
56 $numquestion = stripmagic($_REQUEST['numQuestion']);
58 if (strlen($titre) > 30) {
59 $titre = substr($question, 0, 50).'...';
60 $question = $titre."\n".$question;
62 $page['text'] = preg_replace(
63 ',(\(:faqList '.$idfaq.':\)),',
64 "\n".'*[[{$FullName}#faq'.$idfaq.'-'.$numquestion.' | '.$titre.']]$1',
66 $page['text'] = preg_replace(
67 ',(\(:if auth edit:\)\(:faqNewQuestion '.$idfaq.') '.$numquestion.':\),',
68 '!![[#faq'.$idfaq.'-'.$numquestion.']]Q : '.$question.'\\\\\\\\'."\n".
69 '[-\'\'question posée le '.$CurrentTime.($Author?
(' par [[~ '.$Author.' ]]\'\'-]'):'')."\n".
70 '(:if auth edit:)(:faqNewAnswer '.$idfaq.' '.$numquestion.' 1:)(:if:)'."\n".
71 '$1 '.($numquestion +
1).':)',
73 WritePage($pagename,$page);
80 function HandleFAQAnswer() {
81 global $pagename, $CurrentTime, $Author;
83 if (isset($_REQUEST['answer']) && $_REQUEST['answer'] &&
84 ($page = RetrieveAuthPage($pagename, 'edit', true
))) {
85 $idfaq = stripmagic($_REQUEST['faqId']);
86 $answer = str_replace("\n", "\n->", stripmagic($_REQUEST['answer']));
87 $numanswer = stripmagic($_REQUEST['numAnswer']);
88 $numquestion = stripmagic($_REQUEST['numQuestion']);
89 $page['text'] = preg_replace(
90 ',(\(:if auth edit:\)\(:faqNewAnswer '.$idfaq.' '.$numquestion.') '.$numanswer.':\),',
91 '->[[#faq'.$idfaq.'-'.$numquestion.'-'.$numanswer.']]R : '.$answer."\n".
92 '->[-\'\'réponse le '.$CurrentTime.($Author?
(' par [[~ '.$Author.' ]]\'\'-]'):'')."\n".
93 '$1 '.($numanswer +
1).':)',
95 WritePage($pagename,$page);