Index: plugins/pages/page.php
===================================================================
--- plugins/pages/page.php	(revision 2390)
+++ plugins/pages/page.php	(revision 2511)
@@ -73,7 +73,7 @@
 	$params['post_type'] = 'page';
 	$params['post_id'] = $_REQUEST['id'];
-	
+
 	$post = $core->blog->getPosts($params);
-	
+
 	if ($post->isEmpty())
 	{
@@ -100,13 +100,13 @@
 		$post_open_tb = (boolean) $post->post_open_tb;
 		$post_selected = (boolean) $post->post_selected;
-		
+
 		$page_title = __('Edit page');
-		
+
 		$can_edit_page = $post->isEditable();
 		$can_delete= $post->isDeletable();
-		
+
 		$next_rs = $core->blog->getNextPost($post,1);
 		$prev_rs = $core->blog->getNextPost($post,-1);
-		
+
 		if ($next_rs !== null) {
 			$next_link = sprintf($post_link,$next_rs->post_id,
@@ -115,5 +115,5 @@
 				html::escapeHTML($next_rs->post_title),$next_rs->post_id);
 		}
-		
+
 		if ($prev_rs !== null) {
 			$prev_link = sprintf($post_link,$prev_rs->post_id,
@@ -122,5 +122,5 @@
 				html::escapeHTML($prev_rs->post_title),$prev_rs->post_id);
 		}
-		
+
 		try {
 			$core->media = new dcMedia($core);
@@ -138,11 +138,11 @@
 	$post_excerpt = $_POST['post_excerpt'];
 	$post_content = $_POST['post_content'];
-	
+
 	$post_title = $_POST['post_title'];
-	
+
 	if (isset($_POST['post_status'])) {
 		$post_status = (integer) $_POST['post_status'];
 	}
-	
+
 	if (empty($_POST['post_dt'])) {
 		$post_dt = '';
@@ -162,5 +162,5 @@
 		}
 	}
-	
+
 	$post_open_comment = !empty($_POST['post_open_comment']);
 	$post_open_tb = !empty($_POST['post_open_tb']);
@@ -169,5 +169,5 @@
 	$post_password = !empty($_POST['post_password']) ? $_POST['post_password'] : null;
 	$post_position = (integer) $_POST['post_position'];
-	
+
 	$post_notes = $_POST['post_notes'];
 
@@ -175,5 +175,5 @@
 		$post_url = $_POST['post_url'];
 	}
-	
+
 	$core->blog->setPostContent(
 		$post_id,$post_format,$post_lang,
@@ -199,8 +199,8 @@
 {
 	$cur = $core->con->openCursor($core->prefix.'post');
-	
+
 	# Magic tweak :)
 	$core->blog->settings->system->post_url_format = $page_url_format;
-	
+
 	$cur->post_type = 'page';
 	$cur->post_title = $post_title;
@@ -220,9 +220,9 @@
 	$cur->post_open_tb = (integer) $post_open_tb;
 	$cur->post_selected = (integer) $post_selected;
-	
+
 	if (isset($_POST['post_url'])) {
 		$cur->post_url = $post_url;
 	}
-	
+
 	# Update post
 	if ($post_id)
@@ -232,10 +232,10 @@
 			# --BEHAVIOR-- adminBeforePageUpdate
 			$core->callBehavior('adminBeforePageUpdate',$cur,$post_id);
-			
+
 			$core->blog->updPost($post_id,$cur);
-			
+
 			# --BEHAVIOR-- adminAfterPageUpdate
 			$core->callBehavior('adminAfterPageUpdate',$cur,$post_id);
-			
+
 			http::redirect($redir_url.'&id='.$post_id.'&upd=1');
 		}
@@ -248,15 +248,15 @@
 	{
 		$cur->user_id = $core->auth->userID();
-		
+
 		try
 		{
 			# --BEHAVIOR-- adminBeforePageCreate
 			$core->callBehavior('adminBeforePageCreate',$cur);
-			
+
 			$return_id = $core->blog->addPost($cur);
-			
+
 			# --BEHAVIOR-- adminAfterPageCreate
 			$core->callBehavior('adminAfterPageCreate',$cur,$return_id);
-			
+
 			http::redirect($redir_url.'&id='.$return_id.'&crea=1');
 		}
@@ -351,5 +351,5 @@
 	$post_content = $post_content_xhtml;
 	$post_format = 'xhtml';
-	
+
 	dcPage::message(__('Don\'t forget to validate your XHTML conversion by saving your post.'));
 }
@@ -367,8 +367,8 @@
 	if ($next_link && $prev_link) { echo ' | '; }
 	if ($next_link) { echo $next_link; }
-	
-	# --BEHAVIOR-- adminPageNavLinks 
+
+	# --BEHAVIOR-- adminPageNavLinks
 	$core->callBehavior('adminPageNavLinks',isset($post) ? $post : null);
-	
+
 	echo '</p>';
 }
@@ -389,9 +389,9 @@
 			'title' => __('Status'),
 			'items' => array(
-				'post_status' => 
+				'post_status' =>
 					'<p><label for="post_status">'.__('Page status').'</label> '.
 					form::combo('post_status',$status_combo,$post_status,'','',!$can_publish).
 					'</p>',
-				'post_dt' => 
+				'post_dt' =>
 					'<p><label for="post_dt">'.__('Publication date and hour').'</label>'.
 					form::field('post_dt',16,16,$post_dt,($bad_dt ? 'invalid' : '')).
@@ -407,10 +407,11 @@
 					'</p>'.
 					'<p class="format_control control_wiki">'.
-					'<a id="convert-xhtml" class="button'.($post_id && $post_format != 'wiki' ? ' hide' : '').'" href="post.php?id='.$post_id.'&amp;xconv=1">'.
+					'<a id="convert-xhtml" class="button'.($post_id && $post_format != 'wiki' ? ' hide' : '').
+					'" href="'.html::escapeURL($redir_url).'&amp;id='.$post_id.'&amp;xconv=1">'.
 					__('Convert to XHTML').'</a></p></div>')),
 		'metas-box' => array(
 			'title' => __('Filing'),
 			'items' => array(
-				'post_position' => 
+				'post_position' =>
 					'<p><label for="post_position" class="classic">'.__('Page position').'</label> '.
 					form::field('post_position',3,3,(string) $post_position).
@@ -425,9 +426,9 @@
 					form::checkbox('post_open_comment',1,$post_open_comment).' '.
 					__('Accept comments').'</label></p>'.
-					($core->blog->settings->system->allow_comments ? 
-						(isContributionAllowed($post_id,strtotime($post_dt),true) ? 
+					($core->blog->settings->system->allow_comments ?
+						(isContributionAllowed($post_id,strtotime($post_dt),true) ?
 							'' :
 							'<p class="form-note warn">'.
-							__('Warning: Comments are not more accepted for this entry.').'</p>') : 
+							__('Warning: Comments are not more accepted for this entry.').'</p>') :
 						'<p class="form-note warn">'.
 						__('Comments are not accepted on this blog so far.').'</p>').
@@ -435,12 +436,12 @@
 					form::checkbox('post_open_tb',1,$post_open_tb).' '.
 					__('Accept trackbacks').'</label></p>'.
-					($core->blog->settings->system->allow_trackbacks ? 
-						(isContributionAllowed($post_id,strtotime($post_dt),false) ? 
+					($core->blog->settings->system->allow_trackbacks ?
+						(isContributionAllowed($post_id,strtotime($post_dt),false) ?
 							'' :
 							'<p class="form-note warn">'.
-							__('Warning: Trackbacks are not more accepted for this entry.').'</p>') : 
+							__('Warning: Trackbacks are not more accepted for this entry.').'</p>') :
 						'<p class="form-note warn">'.__('Trackbacks are not accepted on this blog so far.').'</p>').
 					'</div>',
-				'post_hide' =>	
+				'post_hide' =>
 					'<p><label for="post_selected" class="classic">'.form::checkbox('post_selected',1,$post_selected).' '.
 					__('Hide in widget Pages').'</label>'.
@@ -465,5 +466,5 @@
 			form::field('post_title',20,255,html::escapeHTML($post_title),'maximal').
 			'</p>',
-		
+
 		"post_excerpt" =>
 			'<p class="area" id="excerpt-area"><label for="post_excerpt" class="bold">'.__('Excerpt:').' <span class="form-note">'.
@@ -471,5 +472,5 @@
 			form::textarea('post_excerpt',50,5,html::escapeHTML($post_excerpt)).
 			'</p>',
-		
+
 		"post_content" =>
 			'<p class="area" id="content-area"><label class="required bold" '.
@@ -477,5 +478,5 @@
 			form::textarea('post_content',50,$core->auth->getOption('edit_size'),html::escapeHTML($post_content)).
 			'</p>',
-		
+
 		"post_notes" =>
 			'<p class="area" id="notes-area"><label for="post_notes" class="bold">'.__('Personal notes:').' <span class="form-note">'.
@@ -495,6 +496,6 @@
 	echo '<div id="entry-content"><div class="constrained">';
 	echo '<h3 class="out-of-screen-if-js">'.__('Edit page').'</h3>';
-	
-	
+
+
 	foreach ($main_items as $id => $item) {
 		echo $item;
@@ -503,5 +504,5 @@
 	# --BEHAVIOR-- adminPageForm
 	$core->callBehavior('adminPageForm',isset($post) ? $post : null);
-	
+
 	echo
 	'<p class="border-top">'.
@@ -526,10 +527,10 @@
 	$core->formNonce().
 	'</p>';
-	
+
 	echo '</div></div>';		// End #entry-content
 	echo '</div>';		// End #entry-wrapper
 
 	echo '<div id="entry-sidebar">';
-	
+
 	foreach ($sidebar_items as $id => $c) {
 		echo '<div id="'.$id.'" class="sb-box">'.
@@ -540,13 +541,13 @@
 		echo '</div>';
 	}
-	
+
 	# --BEHAVIOR-- adminPageFormSidebar
 	$core->callBehavior('adminPageFormSidebar',isset($post) ? $post : null);
-	
+
 	echo '</div>';		// End #entry-sidebar
-	
+
 	echo '</form>';
-	echo '</div>';		// End 
-	
+	echo '</div>';		// End
+
 	if ($post_id && !empty($post_media))
 	{
@@ -566,8 +567,8 @@
 {
 	$params = array('post_id' => $post_id, 'order' => 'comment_dt ASC');
-	
+
 	$comments = $core->blog->getComments(array_merge($params,array('comment_trackback'=>0)));
 	$trackbacks = $core->blog->getComments(array_merge($params,array('comment_trackback'=>1)));
-	
+
 	# Actions combo box
 	$combo_action = array();
@@ -579,15 +580,15 @@
 		$combo_action[__('Mark as junk')] = 'junk';
 	}
-	
+
 	if ($can_edit_page && $core->auth->check('delete,contentadmin',$core->blog->id))
 	{
 		$combo_action[__('Delete')] = 'delete';
 	}
-	
+
 	$has_action = !empty($combo_action) && (!$trackbacks->isEmpty() || !$comments->isEmpty());
-	
+
 	echo
 	'<div id="comments" class="multi-part" title="'.__('Comments').'">';
-	
+
 	echo
 	'<p class="top-add"><a class="button add" href="#comment-form">'.__('Add a comment').'</a></p>';
@@ -596,7 +597,7 @@
 		echo '<form action="comments_actions.php" method="post">';
 	}
-	
+
 	echo '<h3>'.__('Trackbacks').'</h3>';
-	
+
 	if (!$trackbacks->isEmpty()) {
 		showComments($trackbacks,$has_action);
@@ -604,5 +605,5 @@
 		echo '<p>'.__('No trackback').'</p>';
 	}
-	
+
 	echo '<h3>'.__('Comments').'</h3>';
 	if (!$comments->isEmpty()) {
@@ -611,10 +612,10 @@
 		echo '<p>'.__('No comment').'</p>';
 	}
-	
+
 	if ($has_action) {
 		echo
 		'<div class="two-cols">'.
 		'<p class="col checkboxes-helpers"></p>'.
-		
+
 		'<p class="col right"><label for="action" class="classic">'.__('Selected comments action:').'</label> '.
 		form::combo('action',$combo_action).
@@ -631,5 +632,5 @@
 	'<div class="fieldset clear">'.
 	'<h3>'.__('Add a comment').'</h3>'.
-	
+
 	'<form action="comment.php" method="post" id="comment-form">'.
 	'<div class="constrained">'.
@@ -637,18 +638,18 @@
 	form::field('comment_author',30,255,html::escapeHTML($core->auth->getInfo('user_cn'))).
 	'</p>'.
-	
+
 	'<p><label for="comment_email">'.__('Email:').'</label>'.
 	form::field('comment_email',30,255,html::escapeHTML($core->auth->getInfo('user_email'))).
 	'</p>'.
-	
+
 	'<p><label for="comment_site">'.__('Web site:').'</label>'.
 	form::field('comment_site',30,255,html::escapeHTML($core->auth->getInfo('user_url'))).
 	'</p>'.
-	
+
 	'<p class="area"><label for="comment_content" class="required"><abbr title="'.__('Required field').'">*</abbr> '.
 	__('Comment:').'</label> '.
 	form::textarea('comment_content',50,8,html::escapeHTML('')).
 	'</p>'.
-	
+
 	'<p>'.form::hidden('post_id',$post_id).
 	$core->formNonce().
@@ -670,10 +671,10 @@
 	}
 	if ($com) {
-		if (($core->blog->settings->system->comments_ttl == 0) || 
+		if (($core->blog->settings->system->comments_ttl == 0) ||
 			(time() - $core->blog->settings->system->comments_ttl*86400 < $dt)) {
 			return true;
 		}
 	} else {
-		if (($core->blog->settings->system->trackbacks_ttl == 0) || 
+		if (($core->blog->settings->system->trackbacks_ttl == 0) ||
 			(time() - $core->blog->settings->system->trackbacks_ttl*86400 < $dt)) {
 			return true;
@@ -694,9 +695,9 @@
 	'<th>'.__('Edit').'</th>'.
 	'</tr>';
-	
+
 	while($rs->fetch())
 	{
 		$comment_url = 'comment.php?id='.$rs->comment_id;
-		
+
 		$img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
 		switch ($rs->comment_status) {
@@ -714,9 +715,9 @@
 				break;
 		}
-		
+
 		echo
 		'<tr class="line'.($rs->comment_status != 1 ? ' offline' : '').'"'.
 		' id="c'.$rs->comment_id.'">'.
-		
+
 		'<td class="nowrap">'.
 		($has_action ? form::checkbox(array('comments[]'),$rs->comment_id,'','','',0,'title="'.__('Select this comment').'"') : '').'</td>'.
@@ -727,8 +728,8 @@
 		'<td class="nowrap status"><a href="'.$comment_url.'">'.
 		'<img src="images/edit-mini.png" alt="" title="'.__('Edit this comment').'" /> '.__('Edit').'</a></td>'.
-		
+
 		'</tr>';
 	}
-	
+
 	echo '</table>';
 }
