Subversion Repositories Applications.papyrus

Rev

Rev 898 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 898 Rev 920
Line 19... Line 19...
19
// |                                                                                                      |
19
// |                                                                                                      |
20
// | You should have received a copy of the GNU General Public License                                    |
20
// | You should have received a copy of the GNU General Public License                                    |
21
// | along with Foobar; if not, write to the Free Software                                                |
21
// | along with Foobar; if not, write to the Free Software                                                |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
23
// +------------------------------------------------------------------------------------------------------+
23
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id: iw_integrateur.fonct.php,v 1.17 2006-07-04 09:40:49 alexandre_tb Exp $
24
// CVS : $Id: iw_integrateur.fonct.php,v 1.18 2006-08-29 20:01:33 ddelon Exp $
25
/**
25
/**
26
* Fonctions de l'integrateur de page Wikini
26
* Fonctions de l'integrateur de page Wikini
27
*
27
*
28
* Application permettant d'intégrer des pages wikini dans Papyrus.
28
* Application permettant d'intégrer des pages wikini dans Papyrus.
29
*
29
*
Line 31... Line 31...
31
//Auteur original :
31
//Auteur original :
32
*@author        David Delon <david.delon@clapas.net>
32
*@author        David Delon <david.delon@clapas.net>
33
//Autres auteurs :
33
//Autres auteurs :
34
*@author        Aucun
34
*@author        Aucun
35
*@copyright     Tela-Botanica 2000-2004
35
*@copyright     Tela-Botanica 2000-2004
36
*@version       $Revision: 1.17 $ $Date: 2006-07-04 09:40:49 $
36
*@version       $Revision: 1.18 $ $Date: 2006-08-29 20:01:33 $
37
*
37
*
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
40
// +------------------------------------------------------------------------------------------------------+
Line 196... Line 196...
196
			exit;
196
			exit;
197
			return;
197
			return;
198
		}
198
		}
Line 199... Line 199...
199
 
199
 
200
		if ($method=="edit") {
200
		if ($method=="edit") {
-
 
201
			
-
 
202
			if ($this->HasAccess("write") && $this->HasAccess("read")) {
201
 
203
		
202
			$result='';
204
				$result='';
203
 
205
		
204
			if ($_POST) {
206
				if ($_POST) {
205
				if ($_POST["submit"] == "Sauver")	{
207
					if ($_POST["submit"] == "Sauver")	{
206
				// check for overwriting
208
					// check for overwriting
207
					if ($this->page) {
209
						if ($this->page) {
208
						if ($this->page["id"] != $_POST["previous"]) {
210
							if ($this->page["id"] != $_POST["previous"]) {
209
							$error = "ALERTE : ".
211
								$error = "ALERTE : ".
210
							"Cette page a &eacute;t&eacute; modifi&eacute;e par quelqu'un d'autre pendant que vous l'&eacute;ditiez.<br />\n".
212
								"Cette page a &eacute;t&eacute; modifi&eacute;e par quelqu'un d'autre pendant que vous l'&eacute;ditiez.<br />\n".
-
 
213
								"Veuillez copier vos changements et r&eacute;&eacute;diter cette page.\n";
211
							"Veuillez copier vos changements et r&eacute;&eacute;diter cette page.\n";
214
							}
212
						}
-
 
213
					}
215
						}
214
					// store
216
						// store
215
					if (!$error) {
217
						if (!$error) {
216
						$body = str_replace("\r", "", $_POST["body"]);
218
							$body = str_replace("\r", "", $_POST["body"]);
217
						// test si la nouvelle page est differente de la précédente
219
							// test si la nouvelle page est differente de la précédente
218
						if(rtrim($body)==rtrim($this->page["body"])) {
220
							if(rtrim($body)==rtrim($this->page["body"])) {
-
 
221
								$this->SetMessage("Cette page n\'a pas &eacute;t&eacute; enregistr&eacute;e car elle n\'a subi aucune modification.");
-
 
222
								$this->Redirect($this->href());
-
 
223
							}
-
 
224
		
-
 
225
							// add page (revisions)
-
 
226
							$this->SavePage($this->tag, $body);
-
 
227
		
-
 
228
							// now we render it internally so we can write the updated link table.
-
 
229
							$this->ClearLinkTable();
-
 
230
							$this->StartLinkTracking();
-
 
231
							$dummy = $this->Header();
-
 
232
							$dummy .= $this->Format($body);
-
 
233
							$dummy .= $this->Footer();
-
 
234
							$this->StopLinkTracking();
-
 
235
							$this->WriteLinkTable();
-
 
236
							$this->ClearLinkTable();
-
 
237
		
219
							$this->SetMessage("Cette page n\'a pas &eacute;t&eacute; enregistr&eacute;e car elle n\'a subi aucune modification.");
238
							// forward
220
							$this->Redirect($this->href());
239
							$this->Redirect($this->href());
221
						}
-
 
222
 
-
 
223
						// add page (revisions)
-
 
224
						$this->SavePage($this->tag, $body);
-
 
225
 
-
 
226
						// now we render it internally so we can write the updated link table.
-
 
227
						$this->ClearLinkTable();
-
 
228
						$this->StartLinkTracking();
-
 
229
						$dummy = $this->Header();
-
 
230
						$dummy .= $this->Format($body);
-
 
231
						$dummy .= $this->Footer();
-
 
232
						$this->StopLinkTracking();
-
 
233
						$this->WriteLinkTable();
-
 
234
						$this->ClearLinkTable();
-
 
235
 
-
 
236
						// forward
-
 
237
						$this->Redirect($this->href());
240
						}
238
					}
241
					}
239
				}
-
 
240
			}
242
				}
241
 
243
		
242
			// fetch fields
244
				// fetch fields
243
			if (!$previous = $_POST["previous"]) $previous = $this->page["id"];
245
				if (!$previous = $_POST["previous"]) $previous = $this->page["id"];
244
			if (!$body = $_POST["body"]) $body = $this->page["body"];
246
				if (!$body = $_POST["body"]) $body = $this->page["body"];
245
 
247
		
246
			// preview?
248
				// preview?
247
			if ($_POST["submit"] == "Aperçu")
249
				if ($_POST["submit"] == "Aperçu")
248
			{
250
				{
249
				$result .=
251
					$result .=
250
					"<div class=\"prev_alert\"><strong>Aper&ccedil;u</strong></div>\n".
252
						"<div class=\"prev_alert\"><strong>Aper&ccedil;u</strong></div>\n".
-
 
253
						$this->Format($body)."\n\n".
-
 
254
						$this->FormOpen("edit").
-
 
255
						"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
-
 
256
						"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n".
-
 
257
						"<br />\n".
-
 
258
						"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
-
 
259
						"<input name=\"submit\" type=\"submit\" value=\"R&eacute;&eacute;diter \" accesskey=\"p\" />\n".
-
 
260
						"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
-
 
261
						$this->FormClose()."\n";
-
 
262
					return $result;
-
 
263
				}
-
 
264
				else
-
 
265
				{
-
 
266
					$ACbuttonsBar='';
-
 
267
				    require_once(IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.buttonsBar.php");
-
 
268
		
251
					$this->Format($body)."\n\n".
269
					$result .=
252
					$this->FormOpen("edit").
270
					$this->FormOpen("edit").
253
					"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".
271
					"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".$ACbuttonsBar.
254
					"<input type=\"hidden\" name=\"body\" value=\"".htmlentities($body)."\" />\n".
272
					"<textarea onkeydown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
-
 
273
					htmlspecialchars($body).
255
					"<br />\n".
274
					"\n</textarea><br />\n".'<div class="boutons_wiki">'.
256
					"<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n".
275
					($this->config["preview_before_save"] ? "" : "<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
257
					"<input name=\"submit\" type=\"submit\" value=\"R&eacute;&eacute;diter \" accesskey=\"p\" />\n".
276
					"<input name=\"submit\" type=\"submit\" value=\"Aper&ccedil;u\" accesskey=\"p\" />\n".
258
					"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" />\n".
277
					"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" /></div>\n".
-
 
278
					$this->FormClose();
259
					$this->FormClose()."\n";
279
		
-
 
280
					return $result;
-
 
281
				}
260
				return $result;
282
		
261
			}
283
			}
262
			else
-
 
263
			{
-
 
264
				$ACbuttonsBar='';
-
 
265
			    require_once(IW_CHEMIN_BIBLIO_ACEDITOR."ACeditor.buttonsBar.php");
-
 
266
 
-
 
267
				$result .=
-
 
268
				$this->FormOpen("edit").
-
 
269
				"<input type=\"hidden\" name=\"previous\" value=\"".$previous."\" />\n".$ACbuttonsBar.
-
 
270
				"<textarea onkeydown=\"fKeyDown()\" name=\"body\" cols=\"60\" rows=\"40\" wrap=\"soft\" class=\"edit\">\n".
-
 
271
				htmlspecialchars($body).
-
 
272
				"\n</textarea><br />\n".'<div class="boutons_wiki">'.
-
 
273
				($this->config["preview_before_save"] ? "" : "<input name=\"submit\" type=\"submit\" value=\"Sauver\" accesskey=\"s\" />\n").
284
			else {
274
				"<input name=\"submit\" type=\"submit\" value=\"Aper&ccedil;u\" accesskey=\"p\" />\n".
-
 
275
				"<input type=\"button\" value=\"Annulation\" onclick=\"document.location='".$this->href("")."';\" /></div>\n".
-
 
276
				$this->FormClose();
285
				echo "<i>Vous n'avez pas acc&egrave;s en &eacute;criture &agrave; cette page !</i>\n";
277
 
-
 
278
				return $result;
286
				
279
			}
-
 
280
 
287
			}
281
		}
288
		}
282
		else {
289
		else {
283
			return parent::Method($method);
290
			return parent::Method($method);
284
		}
291
		}
Line 294... Line 301...
294
 
301
 
Line 295... Line 302...
295
	// Identification
302
	// Identification
296
 
303
 
297
	function SetUser($user, $remember) {
304
	function SetUser($user, $remember) {
298
			// Appel à partir de Papyrus
305
			// Appel à partir de Papyrus
299
				if ($user=='') {
306
				if ($user=='initwiki') {
300
					$remember=1;
307
					$remember=1;
301
					$wiki_prenom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_prenom));
-
 
302
					$wiki_nom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_nom));
308
					$wiki_prenom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_prenom));
303
 
-
 
304
					$_SESSION["user"]["name"] = $wiki_prenom.$wiki_nom;
-
 
305
					$_SESSION["user"]["password"] = "wikini";
309
					$wiki_nom=$this->versChatMot($GLOBALS['_GEN_commun']['pear_auth']->getAuthData($GLOBALS['_GEN_commun']['info_auth_bdd']->chp_personne_nom));
306
					$_SESSION["user"]["changescount"] = 100;
310
					$_SESSION["user"]=array("name"=>$wiki_prenom.$wiki_nom,"password"=>"wikini","changescount"=> 100);
307
					$this->SetPersistentCookie("name", $user["name"], $remember);
311
					$this->SetPersistentCookie("name", $user["name"], $remember);
308
					$this->SetPersistentCookie("password", $user["password"], $remember);
312
					$this->SetPersistentCookie("password", $user["password"], $remember);
309
					$this->SetPersistentCookie("remember", $remember, $remember);
313
					$this->SetPersistentCookie("remember", $remember, $remember);
Line 407... Line 411...
407
*
411
*
408
* @return  string  du code XHTML correspondant au contenu renvoyé par l'application.
412
* @return  string  du code XHTML correspondant au contenu renvoyé par l'application.
409
*/
413
*/
410
function afficherPageWikini()
414
function afficherPageWikini()
411
{
415
{
-
 
416
	
Line 412... Line 417...
412
 
417
 
Line 413... Line 418...
413
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
418
	$GLOBALS['_PAPYRUS_']['erreur']->setActive(0);
414
 
419
 
Line 422... Line 427...
422
    if (!class_exists ('Wiki_Papyrus')) return ; 
427
    if (!class_exists ('Wiki_Papyrus')) return ; 
423
    $wiki  = new Wiki_Papyrus($wakkaConfig);
428
    $wiki  = new Wiki_Papyrus($wakkaConfig);
Line 424... Line 429...
424
 
429
 
425
	if  ($GLOBALS['_GEN_commun']['pear_auth']->checkAuth()) {
430
	if  ($GLOBALS['_GEN_commun']['pear_auth']->checkAuth()) {
426
		if (!isset($_SESSION["user"]) || ($_SESSION["user"]=="")) {
431
		if (!isset($_SESSION["user"]) || ($_SESSION["user"]=="")) {
427
			$wiki->SetUser('');
432
			$wiki->SetUser('initwiki');
428
		}
433
		}
429
	}
434
	}
430
	else {
435
	else {
431
		$wiki->LogoutUser();
436
		$wiki->LogoutUser();