Index: inc/admin/lib.dc.page.php
===================================================================
--- inc/admin/lib.dc.page.php	(revision 343)
+++ inc/admin/lib.dc.page.php	(revision 404)
@@ -4,5 +4,5 @@
 # This file is part of Dotclear 2.
 #
-# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear
+# Copyright (c) 2003-2010 Olivier Meunier & Association Dotclear
 # Licensed under the GPL version 2.0 license.
 # See LICENSE file or
@@ -16,6 +16,4 @@
 class dcPage
 {
-	private static $loaded_js=array();
-
 	# Auth check
 	public static function check($permissions)
@@ -104,10 +102,4 @@
 			echo '  <style type="text/css">'."\n".'  @import "style/default-rtl.css";'."\n"."  </style>\n";
 		}
-
-		$core->auth->user_prefs->addWorkspace('interface');
-		$user_ui_hide_std_favicon = $core->auth->user_prefs->interface->hide_std_favicon;
-		if (!$user_ui_hide_std_favicon) {
-			echo '<link rel="icon" type="image/png" href="images/favicon.png" />';
-		}
 		
 		echo
@@ -272,7 +264,7 @@
 			} else {
 				$prof_url = http::getSelfURI();
-				$prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&';
+				$prof_url .= (strpos($prof_url,'?') === false) ? '?' : '&amp;';
 				$prof_url .= 'XDEBUG_PROFILE';
-				$res .= '<p><a href="'.html::escapeURL($prof_url).'">Trigger profiler</a></p>';
+				$res .= '<p><a href="'.$prof_url.'">Trigger profiler</a></p>';
 			}
 			
@@ -351,9 +343,5 @@
 	public static function jsLoad($src)
 	{
-		$escaped_src = html::escapeHTML($src);
-		if (!isset(self::$loaded_js[$escaped_src])) {
-			self::$loaded_js[$escaped_src]=true;
-			return '<script type="text/javascript" src="'.$escaped_src.'"></script>'."\n";
-		}
+		return '<script type="text/javascript" src="'.html::escapeHTML($src).'"></script>'."\n";
 	}
 	
@@ -366,5 +354,4 @@
 	{
 		return
-		self::jsLoad('js/jquery/jquery.js').
 		self::jsLoad('js/jquery/jquery.js').
 		self::jsLoad('js/jquery/jquery.biscuit.js').
@@ -562,80 +549,273 @@
 	public static function jsToolBar()
 	{
+		$tb = new dcToolBar($GLOBALS['core']);
+		
+		// Add xhtml toolbar
+		$tb->addFormatter('xhtml');
+		$tb->addSettings('xhtml',array(
+			'mode' => 'textareas',
+			'relative_urls' => 'false',
+			'theme' => 'advanced',
+			'skin' => 'dotclear',
+			'theme_advanced_toolbar_location' => 'top',
+			'theme_advanced_toolbar_align' => 'left',
+			'theme_advanced_statusbar_location' => 'bottom',
+			'theme_advanced_resizing' => 'true',
+			'theme_advanced_resize_horizontal' => 'false',
+			'theme_advanced_blockformats' => 'p,pre,h3,h4,h5,h6',
+			'paste_auto_cleanup_on_paste' => 'true',
+			'forced_root_block' => '',
+			'formats' => '{underline: {inline: "ins"},strikethrough: {inline: "del"},inlinecode: {inline: "code"},quote: {inline: "q"}}'
+		));
+		$tb->addPlugins('xhtml',array(
+			'fullscreen' => true,
+			'paste' => true,
+			'searchreplace' => true,
+			'dcControls' => true
+		));
+		$tb->addButtons('xhtml',array(
+			1 => array(
+				'justifyleft',
+				'justifycenter',
+				'justifyright',
+				'separator',
+				'bold',
+				'italic',
+				'underline',
+				'strikethrough',
+				'inlinecode',
+				'quote',
+				'sub',
+				'sup',
+				'separator',
+				'blockquote',
+				'bullist',
+				'numlist',
+				'outdent',
+				'indent',
+				'separator',
+				'undo',
+				'redo',
+				'separator',
+				'fullscreen',
+				'separator',
+				'code'
+			),
+			2 => array(
+				'formatselect',
+				'removeformat',
+				'cleanup',
+				'separator',
+				'pastetext',
+				'pasteword',
+				'separator',
+				'search',
+				'replace'
+			),
+			3 => array(
+				'link',
+				'unlink',
+				'separator',
+				'media',
+				'webmedia',
+				'separator',
+				'hr',
+				'charmap',
+				'visualchars'
+			)
+		));
+		
+		// Add wiki toolbar
+		$tb->addFormatter('wiki');
+		$tb->addSettings('wiki',array(
+			'mode' => 'none',
+			'relative_urls' => 'false',
+			'theme' => 'advanced',
+			'skin' => 'dotclear',
+			'theme_advanced_toolbar_location' => 'top',
+			'theme_advanced_toolbar_align' => 'left',
+			'theme_advanced_statusbar_location' => 'bottom',
+			'theme_advanced_resizing' => 'true',
+			'theme_advanced_resize_horizontal' => 'false',
+			'theme_advanced_path'  => 'false',
+			'theme_advanced_blockformats' => 'p,pre,h3,h4,h5,h6',
+			'entity_encoding' => 'raw',
+			'remove_linebreaks' => 'false',
+			'inline_styles' => 'false',
+			'convert_fonts_to_spans' => 'false',
+			'paste_auto_cleanup_on_paste' => 'true',
+			'force_br_newlines' => 'true',
+			'force_p_newlines' => 'false',
+			'forced_root_block' => '',
+			'formats' => '{underline: {inline: "ins"},strikethrough: {inline: "del"},inlinecode: {inline: "code"},quote: {inline: "q"}}'
+		));
+		$tb->addPlugins('wiki',array(
+			'fullscreen' => true,
+			'paste' => true,
+			'searchreplace' => true,
+			'dcControls' => true
+		));
+		$tb->addButtons('wiki',array(
+			1 => array(
+				'formatselect',
+				'bold',
+				'italic',
+				'underline',
+				'strikethrough',
+				'quote',
+				'inlinecode',
+				'separator',
+				'blockquote',
+				'bullist',
+				'numlist',
+				'separator',
+				'link',
+				'unlink',
+				'separator',
+				'search',
+				'replace',
+				'separator',
+				'undo',
+				'redo',
+				'separator',
+				'fullscreen',
+				'separator',
+				'code'
+			)
+		));
+		
+		$tb->addI18n('common',array(
+			'edit_confirm' => __('Do you want to use the WYSIWYG mode for this textarea?'),
+			'apply' => __('Apply'),
+			'insert' => __('Insert'),
+			'update' => __('Update'),
+			'cancel' => __('Cancel'),
+			'close' => __('Close'),
+			'browse' => __('Browse'),
+			'class_name' => __('Class'),
+			'not_set' => __('-- Not set --'),
+			'clipboard_msg' => __('Copy/Cut/Paste is not available in Mozilla and Firefox. Do you want more information about this issue?'),
+			'clipboard_no_support' => __('Currently not supported by your browser, use keyboard shortcuts instead.'),
+			'popup_blocked' => __('Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.'),
+			'invalid_data' => __('{#field} is invalid'),
+			'invalid_data_number' => __('{#field} must be a number'),
+			'invalid_data_min' => __('{#field} must be a number greater than {#min}'),
+			'invalid_data_size' => __('{#field} must be a number or percentage'),
+			'more_colors' => __('More colors')
+		));
+		$tb->addI18n('advanced',array(
+			'style_select' => __('Styles'),
+			'font_size' => __('Font size'),
+			'fontdefault' => __('Font family'),
+			'block' => __('Format'),
+			'paragraph' => __('Paragraph'),
+			'div' => __('Div'),
+			'address' => __('Address'),
+			'pre' => __('Preformatted'),
+			'h1' => __('Heading blog'),
+			'h2' => __('Heading entry'),
+			'h3' => __('Heading 1'),
+			'h4' => __('Heading 2'),
+			'h5' => __('Heading 3'),
+			'h6' => __('Heading 4'),
+			'blockquote' => __('Blockquote'),
+			'code' => __('Code'),
+			'samp' => __('Code sample'),
+			'dt' => __('Definition term '),
+			'dd' => __('Definition description'),
+			'bold_desc' => __('Bold (Ctrl+B)'),
+			'italic_desc' => __('Italic (Ctrl+I)'),
+			'underline_desc' => __('Underline (Ctrl+U)'),
+			'striketrough_desc' => __('Strikethrough'),
+			'justifyleft_desc' => __('Align left'),
+			'justifycenter_desc' => __('Align center'),
+			'justifyright_desc' => __('Align right'),
+			'justifyfull_desc' => __('Align full'),
+			'bullist_desc' => __('Unordered list'),
+			'numlist_desc' => __('Ordered list'),
+			'outdent_desc' => __('Outdent'),
+			'indent_desc' => __('Indent'),
+			'undo_desc' => __('Undo (Ctrl+Z)'),
+			'redo_desc' => __('Redo (Ctrl+Y)'),
+			'link_desc' => __('Insert/edit link'),
+			'unlink_desc' => __('Unlink'),
+			'image_desc' => __('Insert/edit image'),
+			'cleanup_desc' => __('Cleanup messy code'),
+			'code_desc' => __('Edit HTML Source'),
+			'sub_desc' => __('Subscript'),
+			'sup_desc' => __('Superscript'),
+			'hr_desc' => __('Insert horizontal ruler'),
+			'removeformat_desc' => __('Remove formatting'),
+			'custom1_desc' => __('Your custom description here'),
+			'forecolor_desc' => __('Select text color'),
+			'backcolor_desc' => __('Select background color'),
+			'charmap_desc' => __('Insert custom character'),
+			'visualaid_desc' => __('Toggle guidelines/invisible elements'),
+			'anchor_desc' => __('Insert/edit anchor'),
+			'cut_desc' => __('Cut'),
+			'copy_desc' => __('Copy'),
+			'paste_desc' => __('Paste'),
+			'image_props_desc' => __('Image properties'),
+			'newdocument_desc' => __('New document'),
+			'help_desc' => __('Help'),
+			'blockquote_desc' => __('Blockquote'),
+			'clipboard_msg' => __('Copy/Cut/Paste is not available in Mozilla and Firefox.\r\nDo you want more information about this issue?'),
+			'path' => __('Path'),
+			'newdocument' => __('Are you sure you want clear all contents?'),
+			'toolbar_focus' => __('Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X'),
+			'more_colors' => __('More colors'),
+			'shortcuts_desc' => __('Accessibility Help'),
+			'help_shortcut' => __('. Press ALT F10 for toolbar. Press ALT 0 for help.'),
+			'rich_text_area' => __('Rich Text Area'),
+			'toolbar' => __('Toolbar')
+		));
+		$tb->addI18n('advanced_dlg',array(
+			'about_title' => __('About TinyMCE'),
+			'about_general' => __('About'),
+			'about_help' => __('Help'),
+			'about_license' => __('License'),
+			'about_plugins' => __('Plugins'),
+			'about_plugin' => __('Plugin'),
+			'about_author' => __('Author'),
+			'about_version' => __('Version'),
+			'about_loaded' => __('Loaded plugins'),
+			'anchor_title' => __('Insert/edit anchor'),
+			'anchor_name' => __('Anchor name'),
+			'anchor_invalid' => __('Please specify a valid anchor name.'),
+			'code_title' => __('HTML Source Editor'),
+			'code_wordwrap' => __('Word wrap'),
+			'charmap_title' => __('Select custom character'),
+			'accessibility_help' => __('Accessibility Help'),
+			'accessibility_usage_title' => __('General Usage')
+		));
+		$tb->addI18n('paste',array(
+			'paste_text_desc' => __('Paste as Plain Text'),
+			'paste_word_desc' => __('Paste from Word'),
+			'selectall_desc' => __('Select All'),
+			'plaintext_mode_sticky' => __('Paste is now in plain text mode. Click again to toggle back to regular paste mode. After you paste something you will be returned to regular paste mode.'),
+			'plaintext_mode' => __('Paste is now in plain text mode. Click again to toggle back to regular paste mode.')
+		));
+		$tb->addI18n('paste_dlg',array(
+			'text_title' => __('Use CTRL+V on your keyboard to paste the text into the window.'),
+			'text_linebreaks' => __('Keep linebreaks'),
+			'word_title' => __('Use CTRL+V on your keyboard to paste the text into the window.')
+		));
+		$tb->addI18n('fullscreen',array('desc' => __('Toggle fullscreen mode')));
+		$tb->addI18n('aria',array('rich_text_area' => __('Rich Text Area')));
+		
+		$tb->addI18n('dcControls',array(
+			'inlinecode_desc' => __('Code'),
+			'quote_desc' => __('Quote'),
+			'link_desc' => __('Link'),
+			'media_desc' => __('Add media from media manager'),
+			'webmedia_desc' => __('Add media from web')
+		));
+		
 		$res =
-		'<link rel="stylesheet" type="text/css" href="style/jsToolBar/jsToolBar.css" />'.
-		'<script type="text/javascript" src="js/jsToolBar/jsToolBar.js"></script>';
-		
-		if (isset($GLOBALS['core']->auth) && $GLOBALS['core']->auth->getOption('enable_wysiwyg')) {
-			$res .= '<script type="text/javascript" src="js/jsToolBar/jsToolBar.wysiwyg.js"></script>';
-		}
-		
-		$res .=
-		'<script type="text/javascript" src="js/jsToolBar/jsToolBar.dotclear.js"></script>'.
+		'<script type="text/javascript" src="js/tiny_mce/tiny_mce.js"></script>'.
+		'<script type="text/javascript" src="js/dcToolBar.js"></script>'.
 		'<script type="text/javascript">'."\n".
 		"//<![CDATA[\n".
-		"jsToolBar.prototype.dialog_url = 'popup.php'; ".
-		"jsToolBar.prototype.iframe_css = '".
-			'body{'.
-				'font: 12px "DejaVu Sans","Lucida Grande","Lucida Sans Unicode",Arial,sans-serif;'.
-				'color : #000;'.
-				'background: #f9f9f9;'.
-				'margin: 0;'.
-				'padding : 2px;'.
-				'border: none;'.
-				(l10n::getTextDirection($GLOBALS['_lang']) == 'rtl' ? 'direction:rtl;' : '').
-			'}'.
-			'pre, code, kbd, samp {'.
-				'font-family:"Courier New",Courier,monospace;'.
-				'font-size : 1.1em;'.
-			'}'.
-			'code {'.
-				'color : #666;'.
-				'font-weight : bold;'.
-			'}'.
-			'body > p:first-child {'.
-				'margin-top: 0;'.
-			'}'.
-		"'; ".
-		"jsToolBar.prototype.base_url = '".html::escapeJS($GLOBALS['core']->blog->host)."'; ".
-		"jsToolBar.prototype.switcher_visual_title = '".html::escapeJS(__('visual'))."'; ".
-		"jsToolBar.prototype.switcher_source_title = '".html::escapeJS(__('source'))."'; ".
-		"jsToolBar.prototype.legend_msg = '".
-		html::escapeJS(__('You can use the following shortcuts to format your text.'))."'; ".
-		"jsToolBar.prototype.elements.blocks.options.none = '".html::escapeJS(__('-- none --'))."'; ".
-		"jsToolBar.prototype.elements.blocks.options.nonebis = '".html::escapeJS(__('-- block format --'))."'; ".
-		"jsToolBar.prototype.elements.blocks.options.p = '".html::escapeJS(__('Paragraph'))."'; ".
-		"jsToolBar.prototype.elements.blocks.options.h1 = '".html::escapeJS(__('Level 1 header'))."'; ".
-		"jsToolBar.prototype.elements.blocks.options.h2 = '".html::escapeJS(__('Level 2 header'))."'; ".
-		"jsToolBar.prototype.elements.blocks.options.h3 = '".html::escapeJS(__('Level 3 header'))."'; ".
-		"jsToolBar.prototype.elements.blocks.options.h4 = '".html::escapeJS(__('Level 4 header'))."'; ".
-		"jsToolBar.prototype.elements.blocks.options.h5 = '".html::escapeJS(__('Level 5 header'))."'; ".
-		"jsToolBar.prototype.elements.blocks.options.h6 = '".html::escapeJS(__('Level 6 header'))."'; ".
-		"jsToolBar.prototype.elements.strong.title = '".html::escapeJS(__('Strong emphasis'))."'; ".
-		"jsToolBar.prototype.elements.em.title = '".html::escapeJS(__('Emphasis'))."'; ".
-		"jsToolBar.prototype.elements.ins.title = '".html::escapeJS(__('Inserted'))."'; ".
-		"jsToolBar.prototype.elements.del.title = '".html::escapeJS(__('Deleted'))."'; ".
-		"jsToolBar.prototype.elements.quote.title = '".html::escapeJS(__('Inline quote'))."'; ".
-		"jsToolBar.prototype.elements.code.title = '".html::escapeJS(__('Code'))."'; ".
-		"jsToolBar.prototype.elements.br.title = '".html::escapeJS(__('Line break'))."'; ".
-		"jsToolBar.prototype.elements.blockquote.title = '".html::escapeJS(__('Blockquote'))."'; ".
-		"jsToolBar.prototype.elements.pre.title = '".html::escapeJS(__('Preformated text'))."'; ".
-		"jsToolBar.prototype.elements.ul.title = '".html::escapeJS(__('Unordered list'))."'; ".
-		"jsToolBar.prototype.elements.ol.title = '".html::escapeJS(__('Ordered list'))."'; ".
-		
-		"jsToolBar.prototype.elements.link.title = '".html::escapeJS(__('Link'))."'; ".
-		"jsToolBar.prototype.elements.link.href_prompt = '".html::escapeJS(__('URL?'))."'; ".
-		"jsToolBar.prototype.elements.link.hreflang_prompt = '".html::escapeJS(__('Language?'))."'; ".
-		
-		"jsToolBar.prototype.elements.img.title = '".html::escapeJS(__('External image'))."'; ".
-		"jsToolBar.prototype.elements.img.src_prompt = '".html::escapeJS(__('URL?'))."'; ".
-		
-		"jsToolBar.prototype.elements.img_select.title = '".html::escapeJS(__('Media chooser'))."'; ".
-		"jsToolBar.prototype.elements.post_link.title = '".html::escapeJS(__('Link to an entry'))."'; ";
-		
-		if (!$GLOBALS['core']->auth->check('media,media_admin',$GLOBALS['core']->blog->id)) {
-			$res .= "jsToolBar.prototype.elements.img_select.disabled = true;\n";
-		}
-		
-		$res .=
+		$tb->getJS().
 		"\n//]]>\n".
 		"</script>\n";
@@ -691,17 +871,21 @@
 	{
 		return
-		'<script type="text/javascript" src="js/tool-man/core.js"></script>'.
-		'<script type="text/javascript" src="js/tool-man/events.js"></script>'.
-		'<script type="text/javascript" src="js/tool-man/css.js"></script>'.
-		'<script type="text/javascript" src="js/tool-man/coordinates.js"></script>'.
-		'<script type="text/javascript" src="js/tool-man/drag.js"></script>'.
-		'<script type="text/javascript" src="js/tool-man/dragsort.js"></script>'.
-		'<script type="text/javascript" src="js/dragsort-tablerows.js"></script>';
+		self::jsLoad('js/tool-man/core.js').
+		self::jsLoad('js/tool-man/events.js').
+		self::jsLoad('js/tool-man/css.js').
+		self::jsLoad('js/tool-man/coordinates.js').
+		self::jsLoad('js/tool-man/drag.js').
+		self::jsLoad('js/tool-man/dragsort.js').
+		self::jsLoad('js/dragsort-tablerows.js');
 	}
 	
 	public static function jsMetaEditor()
 	{
-		return
-		'<script type="text/javascript" src="js/meta-editor.js"></script>';
+		return self::jsLoad('js/meta-editor.js');
+	}
+	
+	public static function jsOEmbed()
+	{
+		return self::jsLoad('js/jquery/jquery.oembed.js');
 	}
 }
