summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-06-07 14:28:14 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-06-07 14:28:14 +0000
commit9d42ec4ee5db0437e9ad14b793f044fa0f5de8fe (patch)
treea0bb93e81f1856204377f936a97a8a285f77f2b7
parent16cdc878fce216364bd57f498baeeb1b94ca8662 (diff)
downloadwordpress-mu-9d42ec4ee5db0437e9ad14b793f044fa0f5de8fe.tar.gz
wordpress-mu-9d42ec4ee5db0437e9ad14b793f044fa0f5de8fe.tar.xz
wordpress-mu-9d42ec4ee5db0437e9ad14b793f044fa0f5de8fe.zip
WP Merge and new features
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@550 7be80a69-a1ef-0310-a953-fb0f7c49ff36
-rw-r--r--htaccess.dist2
-rw-r--r--wp-inst/wp-activate.php4
-rw-r--r--wp-inst/wp-admin/admin-db.php30
-rw-r--r--wp-inst/wp-admin/admin-footer.php6
-rw-r--r--wp-inst/wp-admin/admin-functions.php62
-rw-r--r--wp-inst/wp-admin/admin-header.php45
-rw-r--r--wp-inst/wp-admin/admin.php6
-rw-r--r--wp-inst/wp-admin/cat-js.php157
-rw-r--r--wp-inst/wp-admin/categories.php71
-rw-r--r--wp-inst/wp-admin/comment.php82
-rw-r--r--wp-inst/wp-admin/custom-fields.js19
-rw-r--r--wp-inst/wp-admin/dbx-admin-key-js.php4
-rw-r--r--wp-inst/wp-admin/edit-category-form.php4
-rw-r--r--wp-inst/wp-admin/edit-comments.js29
-rw-r--r--wp-inst/wp-admin/edit-comments.php104
-rw-r--r--wp-inst/wp-admin/edit-form-advanced.php95
-rw-r--r--wp-inst/wp-admin/edit-form-comment.php72
-rw-r--r--wp-inst/wp-admin/edit-link-form.php7
-rw-r--r--wp-inst/wp-admin/edit-page-form.php71
-rw-r--r--wp-inst/wp-admin/edit-pages.php33
-rw-r--r--wp-inst/wp-admin/edit.php94
-rw-r--r--wp-inst/wp-admin/execute-pings.php27
-rw-r--r--wp-inst/wp-admin/import.php8
-rw-r--r--wp-inst/wp-admin/import/blogger.php4
-rw-r--r--wp-inst/wp-admin/import/dotclear.php30
-rw-r--r--wp-inst/wp-admin/import/greymatter.php2
-rw-r--r--wp-inst/wp-admin/import/livejournal.php3
-rw-r--r--wp-inst/wp-admin/import/mt.php38
-rw-r--r--wp-inst/wp-admin/inline-uploading.php27
-rw-r--r--wp-inst/wp-admin/link-add.php5
-rw-r--r--wp-inst/wp-admin/link-import.php3
-rw-r--r--wp-inst/wp-admin/link-manager.php13
-rw-r--r--wp-inst/wp-admin/link.php22
-rw-r--r--wp-inst/wp-admin/list-manipulation-js.php19
-rw-r--r--wp-inst/wp-admin/list-manipulation.js96
-rw-r--r--wp-inst/wp-admin/list-manipulation.php95
-rw-r--r--wp-inst/wp-admin/menu.php30
-rw-r--r--wp-inst/wp-admin/moderation.php42
-rw-r--r--wp-inst/wp-admin/options-discussion.php1
-rw-r--r--wp-inst/wp-admin/options-general.php34
-rw-r--r--wp-inst/wp-admin/options-misc.php4
-rw-r--r--wp-inst/wp-admin/options-permalink.php6
-rw-r--r--wp-inst/wp-admin/options-privacy.php36
-rw-r--r--wp-inst/wp-admin/options-reading.php42
-rw-r--r--wp-inst/wp-admin/options-writing.php15
-rw-r--r--wp-inst/wp-admin/options.php54
-rw-r--r--wp-inst/wp-admin/page-new.php6
-rw-r--r--wp-inst/wp-admin/page.php27
-rw-r--r--wp-inst/wp-admin/plugin-editor.php3
-rw-r--r--wp-inst/wp-admin/plugins.php16
-rw-r--r--wp-inst/wp-admin/post-new.php4
-rw-r--r--wp-inst/wp-admin/post.php33
-rw-r--r--wp-inst/wp-admin/profile-update.php11
-rw-r--r--wp-inst/wp-admin/profile.php1
-rw-r--r--wp-inst/wp-admin/setup-config.php103
-rw-r--r--wp-inst/wp-admin/templates.php5
-rw-r--r--wp-inst/wp-admin/theme-editor.php3
-rw-r--r--wp-inst/wp-admin/themes.php4
-rw-r--r--wp-inst/wp-admin/upgrade-functions.php215
-rw-r--r--wp-inst/wp-admin/upgrade-schema.php59
-rw-r--r--wp-inst/wp-admin/upgrade.php10
-rw-r--r--wp-inst/wp-admin/user-edit.php24
-rw-r--r--wp-inst/wp-admin/users.php297
-rw-r--r--wp-inst/wp-admin/wp-admin.css2
-rw-r--r--wp-inst/wp-admin/wpmu-blogs.php74
-rw-r--r--wp-inst/wp-admin/wpmu-edit.php52
-rw-r--r--wp-inst/wp-admin/wpmu-users.php9
-rw-r--r--wp-inst/wp-comments-post.php23
-rw-r--r--wp-inst/wp-commentsrss2.php3
-rw-r--r--wp-inst/wp-content/blogs.php3
-rw-r--r--wp-inst/wp-content/mu-plugins/global-categories.php49
-rw-r--r--wp-inst/wp-content/mu-plugins/misc.php35
-rw-r--r--wp-inst/wp-content/mu-plugins/pluggable.php6
-rw-r--r--wp-inst/wp-content/themes/default/archives.php2
-rw-r--r--wp-inst/wp-cron.php2
-rw-r--r--wp-inst/wp-feed.php29
-rw-r--r--wp-inst/wp-includes/bookmark-template.php (renamed from wp-inst/wp-includes/template-functions-bookmarks.php)670
-rw-r--r--wp-inst/wp-includes/bookmark.php134
-rw-r--r--wp-inst/wp-includes/cache.php28
-rw-r--r--wp-inst/wp-includes/capabilities.php14
-rw-r--r--wp-inst/wp-includes/category-template.php (renamed from wp-inst/wp-includes/template-functions-category.php)248
-rw-r--r--wp-inst/wp-includes/category.php205
-rw-r--r--wp-inst/wp-includes/class-snoopy.php14
-rw-r--r--wp-inst/wp-includes/classes.php7
-rw-r--r--wp-inst/wp-includes/comment-functions.php892
-rw-r--r--wp-inst/wp-includes/comment.php4
-rw-r--r--wp-inst/wp-includes/default-filters.php34
-rw-r--r--wp-inst/wp-includes/deprecated.php18
-rw-r--r--wp-inst/wp-includes/feed-functions.php2
-rw-r--r--wp-inst/wp-includes/functions-compat.php15
-rw-r--r--wp-inst/wp-includes/functions-formatting.php11
-rw-r--r--wp-inst/wp-includes/functions-post.php66
-rw-r--r--wp-inst/wp-includes/functions.php117
-rw-r--r--wp-inst/wp-includes/js/fat.js4
-rw-r--r--wp-inst/wp-includes/js/tinymce/langs/en.js76
-rw-r--r--wp-inst/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js48
-rw-r--r--wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css69
-rw-r--r--wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js665
-rw-r--r--wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js455
-rw-r--r--wp-inst/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js685
-rw-r--r--wp-inst/wp-includes/js/tinymce/plugins/wordpress/images/help.gifbin92 -> 295 bytes
-rw-r--r--wp-inst/wp-includes/js/tinymce/plugins/wordpress/langs/en.js29
-rw-r--r--wp-inst/wp-includes/js/tinymce/plugins/wordpress/wordpress.css63
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/about.htm4
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/anchor.htm1
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/charmap.htm3
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/color_picker.htm3
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_content.css28
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css67
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css313
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/editor_template.js1420
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/image.htm100
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/images/buttons.gifbin3286 -> 8399 bytes
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/about.js13
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js21
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js10
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js3
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/image.js45
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/link.js52
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js23
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/langs/en.js2
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/link.htm95
-rw-r--r--wp-inst/wp-includes/js/tinymce/themes/advanced/source_editor.htm31
-rw-r--r--wp-inst/wp-includes/js/tinymce/tiny_mce.js9614
-rw-r--r--wp-inst/wp-includes/js/tinymce/tiny_mce_gzip.php427
-rw-r--r--wp-inst/wp-includes/js/tinymce/tiny_mce_popup.js97
-rw-r--r--wp-inst/wp-includes/js/tinymce/utils/form_utils.js33
-rw-r--r--wp-inst/wp-includes/js/tinymce/utils/mctabs.js6
-rw-r--r--wp-inst/wp-includes/js/tinymce/utils/validate.js6
-rw-r--r--wp-inst/wp-includes/js/tinymce/wp-mce-help.php20
-rw-r--r--wp-inst/wp-includes/js/tw-sack.js194
-rw-r--r--wp-inst/wp-includes/links.php580
-rw-r--r--wp-inst/wp-includes/pluggable-functions.php89
-rw-r--r--wp-inst/wp-includes/query.php34
-rw-r--r--wp-inst/wp-includes/registration-functions.php25
-rw-r--r--wp-inst/wp-includes/rewrite.php5
-rw-r--r--wp-inst/wp-includes/script-loader.php4
-rw-r--r--wp-inst/wp-includes/template-functions-author.php26
-rw-r--r--wp-inst/wp-includes/template-functions-general.php4
-rw-r--r--wp-inst/wp-includes/template-functions-post.php4
-rw-r--r--wp-inst/wp-includes/template-loader.php10
-rw-r--r--wp-inst/wp-includes/version.php2
-rw-r--r--wp-inst/wp-includes/wpmu-functions.php268
-rw-r--r--wp-inst/wp-login.php9
-rw-r--r--wp-inst/wp-rss2.php2
-rw-r--r--wp-inst/wp-settings.php45
-rw-r--r--wp-inst/wpmu-settings.php3
-rw-r--r--wp-inst/xmlrpc.php14
148 files changed, 11712 insertions, 9379 deletions
diff --git a/htaccess.dist b/htaccess.dist
index cf52033..5533f18 100644
--- a/htaccess.dist
+++ b/htaccess.dist
@@ -69,7 +69,7 @@ RewriteRule ^([_0-9a-zA-Z-]+)/wp-includes/images/(.*) BASE/wp-inst/wp-includes
RewriteRule ^([_0-9a-zA-Z-]+)/wp-includes/js/(.*) BASE/wp-inst/wp-includes/js/$2 [L]
RewriteRule ^wp-signup.php$ BASE/wp-inst/wp-signup.php [L]
-RewriteRule ^wp-activate.php$ /wp-inst/wp-activate.php [L]
+RewriteRule ^wp-activate.php$ BASE/wp-inst/wp-activate.php [L]
RewriteRule ^wp-login.php BASE/wp-inst/wp-login.php [L]
RewriteRule ^wp-admin/(.*) BASE/wp-inst/wp-admin/$1 [L]
RewriteRule ^wp-includes/images/(.*) BASE/wp-inst/wp-includes/images/$1 [L]
diff --git a/wp-inst/wp-activate.php b/wp-inst/wp-activate.php
index 345856c..a9dbbd2 100644
--- a/wp-inst/wp-activate.php
+++ b/wp-inst/wp-activate.php
@@ -45,7 +45,7 @@ form { margin-top: 2em; }
else
$key = $_POST['key'];
- $result = wpmu_activate_blog($key);
+ $result = wpmu_activate_signup($key);
if ( is_wp_error($result) ) {
if ( 'already_active' == $result->get_error_code() )
echo __('The blog is already active. Please check your email inbox for your username, password, and login instructions.');
@@ -68,7 +68,7 @@ form { margin-top: 2em; }
</td>
</tr>
</table>
-<h3 class="view"><?php printf(__('<a href="%1$s">View your site</a> or <a href="%2$s">Login</a>'), $url, 'http://wordpress.com/'); ?></h3>
+<h3 class="view"><?php printf(__('<a href="%1$s">View your site</a> or <a href="%2$s">Login</a>'), $url, 'http://' . $_SERVER[ 'SERVER_NAME' ] . '/' ); ?></h3>
<?php
}
}
diff --git a/wp-inst/wp-admin/admin-db.php b/wp-inst/wp-admin/admin-db.php
index 84d73fc..0b8c264 100644
--- a/wp-inst/wp-admin/admin-db.php
+++ b/wp-inst/wp-admin/admin-db.php
@@ -92,8 +92,8 @@ function wp_insert_category($catarr) {
else
$update = false;
- $cat_name = wp_specialchars($cat_name);
-
+ $cat_name = apply_filters('pre_category_name', $cat_name);
+
if ( !$update && category_exists($cat_name) )
return 0;
@@ -101,10 +101,13 @@ function wp_insert_category($catarr) {
$category_nicename = sanitize_title($cat_name);
else
$category_nicename = sanitize_title($category_nicename);
+ $category_nicename = apply_filters('pre_category_nicename', $category_nicename);
if (empty ($category_description))
$category_description = '';
+ $category_description = apply_filters('pre_category_description', $category_description);
+ $category_parent = (int) $category_parent;
if (empty ($category_parent))
$category_parent = 0;
@@ -189,12 +192,12 @@ function wp_delete_category($cat_ID) {
$default_cat = get_option('default_category');
$posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'");
if ( is_array($posts) ) foreach ($posts as $post_id) {
- $cats = wp_get_post_cats('', $post_id);
+ $cats = wp_get_post_categories($post_id);
if ( 1 == count($cats) )
$cats = array($default_cat);
else
$cats = array_diff($cats, array($cat_ID));
- wp_set_post_cats('', $post_id, $cats);
+ wp_set_post_categories($post_id, $cats);
}
$default_link_cat = get_option('default_link_category');
@@ -232,7 +235,7 @@ function wp_create_categories($categories, $post_id = '') {
}
if ($post_id)
- wp_set_post_cats('', $post_id, $cat_ids);
+ wp_set_post_categories($post_id, $cat_ids);
return $cat_ids;
}
@@ -285,23 +288,6 @@ function wp_revoke_user($id) {
$user->remove_all_caps();
}
-function get_link($link_id, $output = OBJECT) {
- global $wpdb;
-
- $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = '$link_id'");
- $link->link_category = wp_get_link_cats($link_id);
-
- if ( $output == OBJECT ) {
- return $link;
- } elseif ( $output == ARRAY_A ) {
- return get_object_vars($link);
- } elseif ( $output == ARRAY_N ) {
- return array_values(get_object_vars($link));
- } else {
- return $link;
- }
-}
-
function wp_insert_link($linkdata) {
global $wpdb, $current_user;
diff --git a/wp-inst/wp-admin/admin-footer.php b/wp-inst/wp-admin/admin-footer.php
index e660be2..783be91 100644
--- a/wp-inst/wp-admin/admin-footer.php
+++ b/wp-inst/wp-admin/admin-footer.php
@@ -9,11 +9,5 @@
<?php do_action('admin_footer', ''); ?>
<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
-<?php
-if ( (substr(php_sapi_name(), 0, 3) == 'cgi') && spawn_pinger() ) {
- echo '<iframe id="pingcheck" src="' . get_settings('siteurl') .'/wp-admin/execute-pings.php?time=' . time() . '" style="border:none;width:1px;height:1px;"></iframe>';
-}
-?>
-
</body>
</html>
diff --git a/wp-inst/wp-admin/admin-functions.php b/wp-inst/wp-admin/admin-functions.php
index 527df20..bf25871 100644
--- a/wp-inst/wp-admin/admin-functions.php
+++ b/wp-inst/wp-admin/admin-functions.php
@@ -647,7 +647,7 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) {
global $wpdb, $class;
if (!$categories)
- $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
+ $categories = get_categories('hide_empty=0');
if ($categories) {
foreach ($categories as $category) {
@@ -664,7 +664,7 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) {
$default_link_cat_id = get_option('default_link_category');
if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) )
- $edit .= "<td><a href='categories.php?action=delete&amp;cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category &quot;%s&quot;.\\nAll of its posts will go into the default category of &quot;%s&quot;\\nAll of its bookmarks will go into the default category of &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), addslashes($category->cat_name), addslashes(wp_specialchars(get_catname($default_cat_id),'double')), addslashes(wp_specialchars(get_catname($default_link_cat_id),'double')))."' );\" class='delete'>".__('Delete')."</a>";
+ $edit .= "<td><a href='" . wp_nonce_url("categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . sprintf(__("You are about to delete the category &quot;%s&quot;.\\nAll of its posts will go into the default category of &quot;%s&quot;\\nAll of its bookmarks will go into the default category of &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), addslashes($category->cat_name), js_escape(get_catname($default_cat_id)), js_escape(get_catname($default_link_cat_id))) . "' );\" class='delete'>".__('Delete')."</a>";
else
$edit .= "<td style='text-align:center'>".__("Default");
}
@@ -693,7 +693,7 @@ function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) {
global $wpdb, $class, $post;
if (!$pages)
- $pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'page' ORDER BY menu_order");
+ $pages = get_pages('sort_column=menu_order');
if (! $pages)
return false;
@@ -717,7 +717,7 @@ function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) {
<td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td>
<td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
<td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
- <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), addslashes(wp_specialchars(get_the_title(),'double')) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
+ <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='" . wp_nonce_url("page.php?action=delete&amp;post=$id", 'delete-page_' . $id) . "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), addslashes(wp_specialchars(get_the_title(),'double')) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
</tr>
<?php
@@ -726,9 +726,13 @@ function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) {
}
function user_row( $user_object, $style = '' ) {
+ global $current_user;
+
if ( !(is_object($user_object) && is_a($user_object, 'WP_User')) )
$user_object = new WP_User( (int) $user_object );
$email = $user_object->user_email;
+ if( $current_user->ID != $user_object->ID || is_site_admin() == false )
+ $email = "N/A";
$url = $user_object->user_url;
$short_url = str_replace('http://', '', $url);
$short_url = str_replace('www.', '', $short_url);
@@ -744,19 +748,19 @@ function user_row( $user_object, $style = '' ) {
<td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td>
<td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td>
<td><a href='$url' title='website: $url'>$short_url</a></td>";
- $r .= "\n\t\t<td align='right'>$numposts</td>";
+ $r .= "\n\t\t<td align='center'>$numposts</td>";
$r .= "\n\t\t<td>";
- if (current_user_can('edit_users'))
+ if ( ( is_site_admin() || $current_user->ID == $user_object->ID ) && current_user_can('edit_user', $user_object->ID) )
$r .= "<a href='user-edit.php?user_id=$user_object->ID' class='edit'>".__('Edit')."</a>";
$r .= "</td>\n\t</tr>";
return $r;
}
function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) {
- global $wpdb, $bgcolor;
- if (!$categories) {
- $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
- }
+ global $wpdb;
+ if (!$categories)
+ $categories = get_categories('hide_empty=0');
+
if ($categories) {
foreach ($categories as $category) {
if ($currentcat != $category->cat_ID && $parent == $category->category_parent) {
@@ -869,7 +873,6 @@ function wp_create_thumbnail($file, $max_side, $effect = '') {
if (!empty ($error)) {
return $error;
} else {
- apply_filters( 'wp_create_thumbnail', $thumbpath );
return $thumbpath;
}
}
@@ -1182,14 +1185,15 @@ function save_mod_rewrite_rules() {
function the_quicktags() {
// Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP
- if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Safari'))
+ if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Safari')) {
echo '
<div id="quicktags">
- <script src="../wp-includes/js/quicktags.js" type="text/javascript"></script>
- <script type="text/javascript">if ( typeof tinyMCE == "undefined" || tinyMCE.configs.length < 1 ) edToolbar();</script>
+ ';
+ wp_print_scripts( 'quicktags' );
+ echo ' <script type="text/javascript">if ( typeof tinyMCE == "undefined" || tinyMCE.configs.length < 1 ) edToolbar();</script>
</div>
';
- else echo '
+ } else echo '
<script type="text/javascript">
function edInsertContent(myField, myValue) {
//IE support
@@ -1568,8 +1572,8 @@ function get_file_description($file) {
if (isset ($wp_file_descriptions[basename($file)])) {
return $wp_file_descriptions[basename($file)];
}
- elseif (file_exists(ABSPATH.$file)) {
- $template_data = implode('', file(ABSPATH.$file));
+ elseif ( file_exists( ABSPATH . $file ) && is_file( ABSPATH . $file ) ) {
+ $template_data = implode('', file( ABSPATH . $file ));
if (preg_match("|Template Name:(.*)|i", $template_data, $name))
return $name[1];
}
@@ -1885,6 +1889,7 @@ function wp_handle_upload(&$file, $overrides = false) {
else
$filename = str_replace("$number$ext", ++$number . $ext, $filename);
}
+ $filename = preg_replace('#\.(?![^.]+$)#', '-', $filename);
}
// Move the file to the uploads dir
@@ -1920,21 +1925,14 @@ function wp_import_cleanup($id) {
function wp_import_upload_form($action) {
?>
-<script type="text/javascript">
-function cancelUpload() {
-o = document.getElementById('uploadForm');
-o.method = 'GET';
-o.action.value = 'view';
-o.submit();
-}
-</script>
-<form enctype="multipart/form-data" id="uploadForm" method="POST" action="<?php echo $action ?>">
-<label for="upload"><?php _e('File:'); ?></label><input type="file" id="upload" name="import" />
+<form enctype="multipart/form-data" id="import-upload-form" method="POST" action="<?php echo $action ?>">
+<p>
+<label for="upload"><?php _e('Choose a file from your computer:'); ?></label> <input type="file" id="upload" name="import" size="25" />
<input type="hidden" name="action" value="save" />
-<div id="buttons">
-<input type="submit" value="<?php _e('Import'); ?>" />
-<input type="button" value="<?php _e('Cancel'); ?>" onclick="cancelUpload()" />
-</div>
+</p>
+<p class="submit">
+<input type="submit" value="<?php _e('Upload file and import'); ?> &raquo;" />
+</p>
</form>
<?php
}
@@ -1947,7 +1945,7 @@ function wp_import_handle_upload() {
return $file;
$url = $file['url'];
- $file = $file['file'];
+ $file = addslashes( $file['file'] );
$filename = basename($file);
// Construct the object array
diff --git a/wp-inst/wp-admin/admin-header.php b/wp-inst/wp-admin/admin-header.php
index 063d539..ee0c286 100644
--- a/wp-inst/wp-admin/admin-header.php
+++ b/wp-inst/wp-admin/admin-header.php
@@ -2,14 +2,15 @@
@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
if (!isset($_GET["page"])) require_once('admin.php');
if ( $editing ) {
- $dbx_js = true;
+ wp_enqueue_script( array("dbx-admin-key?pagenow=$pagenow",'admin-custom-fields') );
if ( current_user_can('manage_categories') )
- $cat_js = true;
+ wp_enqueue_script( 'ajaxcat' );
+ if ( user_can_richedit() )
+ wp_enqueue_script( 'wp_tiny_mce' );
}
-if ( $list_js || $cat_js )
- $sack_js = true;
+
+get_admin_page_title();
?>
-<?php get_admin_page_title(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
@@ -21,41 +22,9 @@ if ( $list_js || $cat_js )
function addLoadEvent(func) {if ( typeof wpOnload!='function'){wpOnload=func;}else{ var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}}
//]]>
</script>
-<script type="text/javascript" src="../wp-includes/js/fat.js"></script>
-<?php if ( $xfn_js ) { ?>
-<script type="text/javascript" src="xfn.js"></script>
-<?php } ?>
-<?php if ( $sack_js ) { ?>
-<script type="text/javascript" src="../wp-includes/js/tw-sack.js"></script>
-<?php } ?>
-<?php if ( $list_js ) { ?>
-<script type="text/javascript" src="list-manipulation.js"></script>
-<?php } ?>
-<?php if ( $dbx_js ) { ?>
-<script type="text/javascript" src="../wp-includes/js/dbx.js"></script>
-<script type="text/javascript">
-//<![CDATA[
-addLoadEvent( function() {
-<?php switch ( $pagenow ) : case 'post.php' : case 'post-new.php' : ?>
-var manager = new dbxManager('postmeta');
-<?php break; case 'page.php' : case 'page-new.php' : ?>
-var manager = new dbxManager('pagemeta');
-<?php break; endswitch; ?>
-});
-//]]>
-</script>
-<script type="text/javascript" src="../wp-includes/js/dbx-key.js"></script>
-<?php } ?>
-<?php if ( $editing && user_can_richedit() ) { ?>
-<script type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce_gzip.php?ver=20051211"></script>
-<?php } ?>
-<?php if ( $cat_js ) { ?>
-<script type="text/javascript" src="cat-js.php"></script>
-<?php } ?>
<?php if ( ($parent_file != 'link-manager.php') && ($parent_file != 'options-general.php') ) : ?>
<style type="text/css">* html { overflow-x: hidden; }</style>
-<?php endif; ?>
-<?php do_action('admin_head'); ?>
+<?php endif; wp_print_scripts(); do_action('admin_head'); ?>
</head>
<body>
<div id="wphead">
diff --git a/wp-inst/wp-admin/admin.php b/wp-inst/wp-admin/admin.php
index 4cedbbe..dda460b 100644
--- a/wp-inst/wp-admin/admin.php
+++ b/wp-inst/wp-admin/admin.php
@@ -17,7 +17,7 @@ nocache_headers();
update_category_cache();
-get_currentuserinfo();
+wp_get_current_user();
$posts_per_page = get_settings('posts_per_page');
$what_to_show = get_settings('what_to_show');
@@ -40,7 +40,9 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
}
}
-$xfn_js = $sack_js = $list_js = $cat_js = $dbx_js = $editing = false;
+wp_enqueue_script( 'fat' );
+
+$editing = false;
require(ABSPATH . '/wp-admin/menu.php');
diff --git a/wp-inst/wp-admin/cat-js.php b/wp-inst/wp-admin/cat-js.php
index e4fee46..e740344 100644
--- a/wp-inst/wp-admin/cat-js.php
+++ b/wp-inst/wp-admin/cat-js.php
@@ -1,10 +1,9 @@
<?php
-require_once('admin.php');
+require_once('../wp-config.php');
header('Content-type: text/javascript; charset=' . get_settings('blog_charset'), true);
?>
-var ajaxCat = new sack();
-var newcat;
-
+addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.topAdder=1;catList.alt=0;catList.showLink=0;});
+addLoadEvent(newCatAddIn);
function newCatAddIn() {
if ( !document.getElementById('jaxcat') ) return false;
var ajaxcat = document.createElement('span');
@@ -16,14 +15,14 @@ function newCatAddIn() {
newcat.id = 'newcat';
newcat.size = '16';
newcat.setAttribute('autocomplete', 'off');
- newcat.onkeypress = ajaxNewCatKeyPress;
+ newcat.onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','categorydiv');", e); };
var newcatSub = document.createElement('input');
newcatSub.type = 'button';
newcatSub.name = 'Button';
newcatSub.id = 'catadd';
- newcatSub.value = '<?php echo addslashes(__('Add')); ?>';
- newcatSub.onclick = ajaxNewCat;
+ newcatSub.value = 'Add';
+ newcatSub.onclick = function() { catList.ajaxAdder('category', 'categorydiv'); };
ajaxcat.appendChild(newcat);
ajaxcat.appendChild(newcatSub);
@@ -41,149 +40,7 @@ function newCatAddIn() {
document.getElementById('jaxcat').appendChild(ajaxcat);
howto = document.createElement('span');
- howto.innerHTML = '<?php echo addslashes(__('Separate multiple categories with commas.')); ?>';
+ howto.innerHTML = "<?php _e('Separate multiple categories with commas.'); ?>";
howto.id = 'howto';
ajaxcat.appendChild(howto);
}
-
-addLoadEvent(newCatAddIn);
-
-function getResponseElement() {
- var p = document.getElementById('ajaxcatresponse');
- if (!p) {
- p = document.createElement('span');
- document.getElementById('jaxcat').appendChild(p);
- p.id = 'ajaxcatresponse';
- }
- return p;
-}
-
-function newCatLoading() {
- var p = getResponseElement();
- p.innerHTML = '<?php echo addslashes(__('Sending Data...')); ?>';
-}
-
-function newCatLoaded() {
- var p = getResponseElement();
- p.innerHTML = '<?php echo addslashes(__('Data Sent...')); ?>';
-}
-
-function newCatInteractive() {
- var p = getResponseElement();
- p.innerHTML = '<?php echo addslashes(__('Processing Request...')); ?>';
-}
-
-function newCatCompletion() {
- var p = getResponseElement();
- var id = 0;
- var ids = new Array();
- var names = new Array();
-
- ids = myPload( ajaxCat.response );
- names = myPload( newcat.value );
- for ( i = 0; i < ids.length; i++ ) {
- id = ids[i].replace(/[\n\r]+/g, "");
- if ( id == '-1' ) {
- p.innerHTML = "<?php echo addslashes(__("You don't have permission to do that.")); ?>";
- return;
- }
- if ( id == '0' ) {
- p.innerHTML = "<?php echo addslashes(__('That category name is invalid. Try something else.')); ?>";
- return;
- }
-
- var exists = document.getElementById('category-' + id);
-
- if (exists) {
- var moveIt = exists.parentNode;
- var container = moveIt.parentNode;
- container.removeChild(moveIt);
- container.insertBefore(moveIt, container.firstChild);
- moveIt.id = 'new-category-' + id;
- exists.checked = 'checked';
- var nowClass = moveIt.className;
- moveIt.className = nowClass + ' fade';
- Fat.fade_all();
- moveIt.className = nowClass;
- } else {
- var catDiv = document.getElementById('categorychecklist');
- var newLabel = document.createElement('label');
- newLabel.setAttribute('for', 'category-' + id);
- newLabel.id = 'new-category-' + id;
- newLabel.className = 'selectit fade';
-
- var newCheck = document.createElement('input');
- newCheck.type = 'checkbox';
- newCheck.value = id;
- newCheck.name = 'post_category[]';
- newCheck.id = 'category-' + id;
- newLabel.appendChild(newCheck);
-
- var newLabelText = document.createTextNode(' ' + names[i]);
- newLabel.appendChild(newLabelText);
-
- catDiv.insertBefore(newLabel, catDiv.firstChild);
- newCheck.checked = 'checked';
-
- Fat.fade_all();
- newLabel.className = 'selectit';
- }
- newcat.value = '';
- }
- p.parentNode.removeChild(p);
-// var id = parseInt(ajaxCat.response, 10);
-}
-
-function ajaxNewCatKeyPress(e) {
- if (!e) {
- if (window.event) {
- e = window.event;
- } else {
- return;
- }
- }
- if (e.keyCode == 13) {
- ajaxNewCat();
- e.returnValue = false;
- e.cancelBubble = true;
- return false;
- }
-}
-
-function ajaxNewCat() {
- var newcat = document.getElementById('newcat');
- var split_cats = new Array(1);
- var catString = '';
-
- catString = 'ajaxnewcat=' + encodeURIComponent(newcat.value);
- ajaxCat.requestFile = 'edit-form-ajax-cat.php';
- ajaxCat.method = 'GET';
- ajaxCat.onLoading = newCatLoading;
- ajaxCat.onLoaded = newCatLoaded;
- ajaxCat.onInteractive = newCatInteractive;
- ajaxCat.onCompletion = newCatCompletion;
- ajaxCat.runAJAX(catString);
-}
-
-function myPload( str ) {
- var fixedExplode = new Array();
- var comma = new String(',');
- var count = 0;
- var currentElement = '';
-
- for( x=0; x < str.length; x++) {
- andy = str.charAt(x);
- if ( comma.indexOf(andy) != -1 ) {
- currentElement = currentElement.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // trim
- fixedExplode[count] = currentElement;
- currentElement = "";
- count++;
- } else {
- currentElement += andy;
- }
- }
-
- if ( currentElement != "" )
- fixedExplode[count] = currentElement;
- return fixedExplode;
-}
diff --git a/wp-inst/wp-admin/categories.php b/wp-inst/wp-admin/categories.php
index 28d6925..3e33f0c 100644
--- a/wp-inst/wp-admin/categories.php
+++ b/wp-inst/wp-admin/categories.php
@@ -24,7 +24,7 @@ switch($action) {
case 'addcat':
- check_admin_referer();
+ check_admin_referer('add-category');
if ( !current_user_can('manage_categories') )
die (__('Cheatin&#8217; uh?'));
@@ -35,13 +35,12 @@ case 'addcat':
break;
case 'delete':
-
- check_admin_referer();
+ $cat_ID = (int) $_GET['cat_ID'];
+ check_admin_referer('delete-category_' . $cat_ID);
if ( !current_user_can('manage_categories') )
die (__('Cheatin&#8217; uh?'));
- $cat_ID = (int) $_GET['cat_ID'];
$cat_name = get_catname($cat_ID);
// Don't delete the default cats.
@@ -62,42 +61,13 @@ case 'edit':
require_once ('admin-header.php');
$cat_ID = (int) $_GET['cat_ID'];
$category = get_category_to_edit($cat_ID);
- ?>
-
-<div class="wrap">
- <h2><?php _e('Edit Category') ?></h2>
- <form name="editcat" action="categories.php" method="post">
- <table class="editform" width="100%" cellspacing="2" cellpadding="5">
- <tr>
- <th width="33%" scope="row" valign="top"><label for="cat_name"><?php _e('Category name:') ?></label></th>
- <td width="67%"><input name="cat_name" id="cat_name" type="text" value="<?php echo wp_specialchars($category->cat_name); ?>" size="40" /> <input type="hidden" name="action" value="editedcat" />
- <div style='display:none; height: 100px; width: 200px; overflow: auto; border: 1px solid #ccc; background: #eee; margin: 5px; padding: 5px;' id="searchresults"><?php _e( 'Search Results' ) ?></div>
- <?php AJAX_search_box( "wpmu-edit.php?action=searchcategories&search=", "cat_name", "searchresults" ); ?>
-<input type="hidden" name="cat_ID" value="<?php echo $category->cat_ID ?>" /></td>
- </tr>
- <tr>
- <th scope="row"><?php _e('Category parent:') ?></th>
- <td>
- <select name='category_parent' id='category_parent'>
- <option value='0' <?php if (!$category->category_parent) echo " selected='selected'"; ?>><?php _e('None') ?></option>
- <?php wp_dropdown_cats($category->cat_ID, $category->category_parent); ?>
- </select></td>
- </tr>
- <tr>
- <th scope="row" valign="top"><label for="category_description"><?php _e('Description:') ?></label></th>
- <td><textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->category_description, 1); ?></textarea></td>
- </tr>
- </table>
- <p class="submit"><input type="submit" name="submit" value="<?php _e('Edit category &raquo;') ?>" /></p>
- </form>
- <p><a href="categories.php"><?php _e('&laquo; Return to category list'); ?></a></p>
-</div>
- <?php
+ include('edit-category-form.php');
break;
case 'editedcat':
- check_admin_referer();
+ $cat_ID = (int) $_POST['cat_ID'];
+ check_admin_referer('update-category_' . $cat_ID);
if ( !current_user_can('manage_categories') )
die (__('Cheatin&#8217; uh?'));
@@ -109,7 +79,7 @@ break;
default:
-$list_js = true;
+wp_enqueue_script( 'admin-categories' );
require_once ('admin-header.php');
$messages[1] = __('Category added.');
@@ -127,12 +97,12 @@ $messages[3] = __('Category updated.');
<?php else : ?>
<h2><?php _e('Categories') ?> </h2>
<?php endif; ?>
-<table width="100%" cellpadding="3" cellspacing="3">
+<table class="widefat">
<thead>
<tr>
<th scope="col"><?php _e('ID') ?></th>
- <th scope="col"><?php _e('Name') ?></th>
- <th scope="col"><?php _e('Description') ?></th>
+ <th scope="col" style="text-align: left"><?php _e('Name') ?></th>
+ <th scope="col" style="text-align: left"><?php _e('Description') ?></th>
<th scope="col" width="90"><?php _e('Posts') ?></th>
<th scope="col" width="90"><?php _e('Bookmarks') ?></th>
<th colspan="2"><?php _e('Action') ?></th>
@@ -153,26 +123,7 @@ cat_rows();
<p><?php _e('<strong>Also Note:</strong><br />Categories will appear on your blog once you have posted something in them. Empty categories remain invisible.'); ?></p>
</div>
-<div class="wrap">
- <h2><?php _e('Add New Category') ?></h2>
- <form name="addcat" id="addcat" action="categories.php" method="post">
- <div class="alignleft"><?php _e('Name:') ?><br />
- <input type="text" name="cat_name" id="cat_name" value="" /></p>
- <div style='display:none; height: 100px; width: 200px; overflow: auto; border: 1px solid #ccc; background: #eee; margin: 5px; padding: 5px;' id="searchresults"><?php _e( 'Search Results' ) ?></div>
- <?php AJAX_search_box( "wpmu-edit.php?action=searchcategories&search=", "cat_name", "searchresults" ); ?>
- <p><?php _e('Category parent:') ?><br />
- <select name='category_parent' id='category_parent' class='postform'>
- <option value='0'><?php _e('None') ?></option>
- <?php wp_dropdown_cats(0); ?>
- </select>
- </div>
- <div id="ajax-response" class="alignleft"></div>
- <br class="clear" />
- <p><?php _e('Description: (optional)') ?> <br />
- <textarea name="category_description" id="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p>
- <p class="submit"><input type="hidden" name="action" value="addcat" /><input type="submit" name="submit" value="<?php _e('Add Category &raquo;') ?>" /></p>
- </form>
-</div>
+<?php include('edit-category-form.php'); ?>
<?php endif; ?>
<?php
diff --git a/wp-inst/wp-admin/comment.php b/wp-inst/wp-admin/comment.php
index 2a97d91..a8be39e 100644
--- a/wp-inst/wp-admin/comment.php
+++ b/wp-inst/wp-admin/comment.php
@@ -1,6 +1,8 @@
<?php
require_once('admin.php');
+$parent_file = 'edit.php';
+$submenu_file = 'edit-comments.php';
$wpvarstoreset = array('action');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
@@ -18,16 +20,16 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
}
}
+if ( isset( $_POST['deletecomment'] ) )
+ $action = 'deletecomment';
+
switch($action) {
case 'editcomment':
$title = __('Edit Comment');
- $parent_file = 'edit.php';
- $submenu_file = 'edit-comments.php';
- $editing = true;
+ if ( user_can_richedit() )
+ wp_enqueue_script( 'wp_tiny_mce' );
require_once ('admin-header.php');
- get_currentuserinfo();
-
$comment = (int) $_GET['comment'];
if ( ! $comment = get_comment($comment) )
@@ -43,23 +45,29 @@ case 'editcomment':
break;
case 'confirmdeletecomment':
+case 'mailapprovecomment':
require_once('./admin-header.php');
$comment = (int) $_GET['comment'];
$p = (int) $_GET['p'];
+ $formaction = 'confirmdeletecomment' == $action ? 'deletecomment' : 'approvecomment';
+ $nonce_action = 'confirmdeletecomment' == $action ? 'delete-comment_' : 'approve-comment_';
+ $nonce_action .= $comment;
if ( ! $comment = get_comment($comment) )
die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
- die( __('You are not allowed to delete comments on this post.') );
+ die( 'confirmdeletecomment' == $action ? __('You are not allowed to delete comments on this post.') : __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
echo "<div class='wrap'>\n";
if ( 'spam' == $_GET['delete_type'] )
echo "<p>" . __('<strong>Caution:</strong> You are about to mark the following comment as spam:') . "</p>\n";
- else
+ elseif ( 'confirmdeletecomment' == $action )
echo "<p>" . __('<strong>Caution:</strong> You are about to delete the following comment:') . "</p>\n";
+ else
+ echo "<p>" . __('<strong>Caution:</strong> You are about to approve the following comment:') . "</p>\n";
echo "<table border='0'>\n";
echo "<tr><td>" . __('Author:') . "</td><td>$comment->comment_author</td></tr>\n";
echo "<tr><td>" . __('E-mail:') . "</td><td>$comment->comment_author_email</td></tr>\n";
@@ -69,7 +77,8 @@ case 'confirmdeletecomment':
echo "<p>" . __('Are you sure you want to do that?') . "</p>\n";
echo "<form action='".get_settings('siteurl')."/wp-admin/comment.php' method='get'>\n";
- echo "<input type='hidden' name='action' value='deletecomment' />\n";
+ wp_nonce_field($nonce_action);
+ echo "<input type='hidden' name='action' value='$formaction' />\n";
if ( 'spam' == $_GET['delete_type'] )
echo "<input type='hidden' name='delete_type' value='spam' />\n";
echo "<input type='hidden' name='p' value='$p' />\n";
@@ -77,25 +86,25 @@ case 'confirmdeletecomment':
echo "<input type='hidden' name='noredir' value='1' />\n";
echo "<input type='submit' value='" . __('Yes') . "' />";
echo "&nbsp;&nbsp;";
- echo "<input type='button' value='" . __('No') . "' onclick=\"self.location='". get_settings('siteurl') ."/wp-admin/edit.php?p=$p&amp;c=1#comments';\" />\n";
+ echo "<input type='button' value='" . __('No') . "' onclick=\"self.location='". get_settings('siteurl') ."/wp-admin/edit-comments.php';\" />\n";
echo "</form>\n";
echo "</div>\n";
break;
case 'deletecomment':
+ $comment = (int) $_REQUEST['comment'];
+ check_admin_referer('delete-comment_' . $comment);
- check_admin_referer();
-
- $comment = (int) $_GET['comment'];
- $p = (int) $_GET['p'];
- if (isset($_GET['noredir'])) {
+ $p = (int) $_REQUEST['p'];
+ if ( isset($_REQUEST['noredir']) ) {
$noredir = true;
} else {
$noredir = false;
}
- $postdata = get_post($p) or die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
+ $postdata = get_post($p) or
+ die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
if ( ! $comment = get_comment($comment) )
die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit-comments.php'));
@@ -103,24 +112,23 @@ case 'deletecomment':
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
die( __('You are not allowed to edit comments on this post.') );
- if ( 'spam' == $_GET['delete_type'] )
+ if ( 'spam' == $_REQUEST['delete_type'] )
wp_set_comment_status($comment->comment_ID, 'spam');
else
wp_delete_comment($comment->comment_ID);
- if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) {
+ if (($_SERVER['HTTP_REFERER'] != '') && (false == $noredir)) {
header('Location: ' . $_SERVER['HTTP_REFERER']);
} else {
- header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
+ header('Location: '. get_settings('siteurl') .'/wp-admin/edit-comments.php');
}
exit();
break;
case 'unapprovecomment':
-
- check_admin_referer();
-
$comment = (int) $_GET['comment'];
+ check_admin_referer('unapprove-comment_' . $comment);
+
$p = (int) $_GET['p'];
if (isset($_GET['noredir'])) {
$noredir = true;
@@ -144,29 +152,10 @@ case 'unapprovecomment':
exit();
break;
-case 'mailapprovecomment':
-
- $comment = (int) $_GET['comment'];
-
- if ( ! $comment = get_comment($comment) )
- die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
-
- if ( !current_user_can('edit_post', $comment->comment_post_ID) )
- die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
-
- if ('1' != $comment->comment_approved) {
- wp_set_comment_status($comment->comment_ID, 'approve');
- if (true == get_option('comments_notify'))
- wp_notify_postauthor($comment->comment_ID);
- }
-
- header('Location: ' . get_option('siteurl') . '/wp-admin/moderation.php?approved=1');
- exit();
- break;
-
case 'approvecomment':
-
$comment = (int) $_GET['comment'];
+ check_admin_referer('approve-comment_' . $comment);
+
$p = (int) $_GET['p'];
if (isset($_GET['noredir'])) {
$noredir = true;
@@ -196,6 +185,11 @@ case 'approvecomment':
case 'editedcomment':
+ $comment_ID = (int) $_POST['comment_ID'];
+ $comment_post_ID = (int) $_POST['comment_post_id'];
+
+ check_admin_referer('update-comment_' . $comment_ID);
+
edit_comment();
$referredby = $_POST['referredby'];
@@ -209,5 +203,7 @@ case 'editedcomment':
default:
break;
} // end switch
+
include('admin-footer.php');
-?> \ No newline at end of file
+
+?>
diff --git a/wp-inst/wp-admin/custom-fields.js b/wp-inst/wp-admin/custom-fields.js
index 2e70d6c..e86c87e 100644
--- a/wp-inst/wp-admin/custom-fields.js
+++ b/wp-inst/wp-admin/custom-fields.js
@@ -1,6 +1,14 @@
+function customFieldsOnComplete() {
+ var pidEl = document.getElementById('post_ID');
+ pidEl.name = 'post_ID';
+ pidEl.value = getNodeValue(theList.ajaxAdd.responseXML, 'postid');
+ var aEl = document.getElementById('hiddenaction')
+ if ( aEl.value == 'post' ) aEl.value = 'postajaxpost';
+}
addLoadEvent(customFieldsAddIn);
function customFieldsAddIn() {
theList.showLink=0;
+ theList.addComplete = customFieldsOnComplete;
if (!theList.theList) return false;
inputs = theList.theList.getElementsByTagName('input');
for ( var i=0; i < inputs.length; i++ ) {
@@ -13,13 +21,6 @@ function customFieldsAddIn() {
}
}
- document.getElementById('metakeyinput').onkeypress = function(e) {return killSubmit('theList.inputData+="&id="+document.getElementById("post_ID").value;theList.ajaxAdder("meta", "newmeta", customFieldsOnComplete);', e); };
- document.getElementById('updatemetasub').onclick = function(e) {return killSubmit('theList.inputData+="&id="+document.getElementById("post_ID").value;theList.ajaxAdder("meta", "newmeta", customFieldsOnComplete);', e); };
-}
-function customFieldsOnComplete() {
- var pidEl = document.getElementById('post_ID');
- pidEl.name = 'post_ID';
- pidEl.value = getNodeValue(theList.ajaxAdd.responseXML, 'postid');
- var aEl = document.getElementById('hiddenaction')
- if ( aEl.value == 'post' ) aEl.value = 'postajaxpost';
+ document.getElementById('metakeyinput').onkeypress = function(e) {return killSubmit('theList.inputData+="&id="+document.getElementById("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); };
+ document.getElementById('updatemetasub').onclick = function(e) {return killSubmit('theList.inputData+="&id="+document.getElementById("post_ID").value;theList.ajaxAdder("meta", "newmeta");', e); };
}
diff --git a/wp-inst/wp-admin/dbx-admin-key-js.php b/wp-inst/wp-admin/dbx-admin-key-js.php
index de7cf9d..bca04ce 100644
--- a/wp-inst/wp-admin/dbx-admin-key-js.php
+++ b/wp-inst/wp-admin/dbx-admin-key-js.php
@@ -11,10 +11,12 @@ switch ( $_GET['pagenow'] ) :
case 'page-new.php' :
$man = 'pagemeta';
break;
- case 'link-add.php' :
case 'link.php' :
$man = 'linkmeta';
break;
+ default:
+ exit;
+ break;
endswitch;
?>
addLoadEvent( function() {var manager = new dbxManager('<?php echo $man; ?>');} );
diff --git a/wp-inst/wp-admin/edit-category-form.php b/wp-inst/wp-admin/edit-category-form.php
index 0063578..dde6b69 100644
--- a/wp-inst/wp-admin/edit-category-form.php
+++ b/wp-inst/wp-admin/edit-category-form.php
@@ -28,10 +28,6 @@ if ( ! empty($cat_ID) ) {
<?php AJAX_search_box( "wpmu-edit.php?action=searchcategories&search=", "cat_name", "searchresults" ); ?></td>
</tr>
<tr>
- <th scope="row" valign="top"><label for="category_nicename"><?php _e('Category slug:') ?></label></th>
- <td><input name="category_nicename" id="category_nicename" type="text" value="<?php echo wp_specialchars($category->category_nicename); ?>" size="40" /></td>
- </tr>
- <tr>
<th scope="row" valign="top"><label for="category_parent"><?php _e('Category parent:') ?></label></th>
<td>
<select name='category_parent' id='category_parent'>
diff --git a/wp-inst/wp-admin/edit-comments.js b/wp-inst/wp-admin/edit-comments.js
index 193dd48..2cd40af 100644
--- a/wp-inst/wp-admin/edit-comments.js
+++ b/wp-inst/wp-admin/edit-comments.js
@@ -1,5 +1,24 @@
-addLoadEvent(function() {theList.dimComplete = function(what,id,dimClass) {
- var m = document.getElementById('awaitmod');
- if ( document.getElementById(what + '-' + id).className.match(dimClass) ) m.innerHTML = parseInt(m.innerHTML,10) + 1;
- else m.innerHTML = parseInt(m.innerHTML,10) - 1;
-}});
+addLoadEvent(function() {
+ theCommentList = new listMan('the-comment-list');
+ if ( !theCommentList )
+ return false;
+ theCommentList.dimComplete = function(what,id,dimClass) {
+ var m = document.getElementById('awaitmod');
+ if ( document.getElementById(what + '-' + id).className.match(dimClass) ) m.innerHTML = parseInt(m.innerHTML,10) + 1;
+ else m.innerHTML = parseInt(m.innerHTML,10) - 1;
+ }
+ theCommentList.delComplete = function(what,id) {
+ var m = document.getElementById('awaitmod');
+ if ( document.getElementById(what + '-' + id).className.match('unapproved') ) m.innerHTML = parseInt(m.innerHTML,10) - 1;
+ }
+ if ( theList ) // the post list: edit.php
+ theList.delComplete = function() {
+ var comments = document.getElementById('comments');
+ var commdel = encloseFunc(function(a){a.parentNode.removeChild(a);},comments);
+ var listdel = encloseFunc(function(a){a.parentNode.removeChild(a);},theCommentList.theList);
+ setTimeout(commdel,705);
+ setTimeout(listdel,705);
+ }
+});
+
+
diff --git a/wp-inst/wp-admin/edit-comments.php b/wp-inst/wp-admin/edit-comments.php
index 0bd09ca..db8ad12 100644
--- a/wp-inst/wp-admin/edit-comments.php
+++ b/wp-inst/wp-admin/edit-comments.php
@@ -3,7 +3,7 @@ require_once('admin.php');
$title = __('Edit Comments');
$parent_file = 'edit.php';
-$list_js = true;
+wp_enqueue_script( 'admin-comments' );
require_once('admin-header.php');
if (empty($_GET['mode'])) $mode = 'view';
@@ -23,11 +23,23 @@ function checkAll(form)
}
}
}
+
+function getNumChecked(form)
+{
+ var num = 0;
+ for (i = 0, n = form.elements.length; i < n; i++) {
+ if(form.elements[i].type == "checkbox") {
+ if(form.elements[i].checked == true)
+ num++;
+ }
+ }
+ return num;
+}
//-->
</script>
<div class="wrap">
<h2><?php _e('Comments'); ?></h2>
-<form name="searchform" action="" method="get">
+<form name="searchform" action="" method="get" id="editcomments">
<fieldset>
<legend><?php _e('Show Comments That Contain...') ?></legend>
<input type="text" name="s" value="<?php if (isset($_GET['s'])) echo wp_specialchars($_GET['s'], 1); ?>" size="17" />
@@ -39,6 +51,8 @@ function checkAll(form)
<p><a href="?mode=view"><?php _e('View Mode') ?></a> | <a href="?mode=edit"><?php _e('Mass Edit Mode') ?></a></p>
<?php
if ( !empty( $_POST['delete_comments'] ) ) :
+ check_admin_referer('bulk-comments');
+
$i = 0;
foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
$comment = (int) $comment;
@@ -85,7 +99,7 @@ if ('view' == $mode) {
else
$start = '';
- echo "<ol id='the-list' class='commentlist' $start>";
+ echo "<ol id='the-comment-list' class='commentlist' $start>";
$i = 0;
foreach ($comments as $comment) {
++$i; $class = '';
@@ -97,37 +111,35 @@ if ('view' == $mode) {
$class .= ' alternate';
echo "<li id='comment-$comment->comment_ID' class='$class'>";
?>
- <p><strong><?php _e('Name:') ?></strong> <?php comment_author() ?> <?php if ($comment->comment_author_email) { ?>| <strong><?php _e('E-mail:') ?></strong> <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url ) { ?> | <strong><?php _e('URI:') ?></strong> <?php comment_author_url_link() ?> <?php } ?>| <strong><?php _e('IP:') ?></strong> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
-
- <?php comment_text() ?>
-
- <p><?php _e('Posted'); echo ' '; comment_date('M j, g:i A');
- if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
- echo " | <a href=\"comment.php?action=editcomment&amp;comment=".$comment->comment_ID."\">" . __('Edit Comment') . "</a>";
- echo " | <a href=\"comment.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars( $comment->comment_author, 1 )) . "' );\">" . __('Delete Comment') . "</a> ";
- echo " | <a href=\"comment.php?action=deletecomment&amp;delete_type=spam&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to mark as spam."), wp_specialchars( $comment->comment_author, 1 )) . "' );\">" . __('Mark Comment as Spam') . "</a> ";
- } // end if any comments to show
- // Get post title
- $post = get_post($comment->comment_post_ID);
- $post_title = $post->post_title;
- $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
- if ( 'page' == $post->post_type ) {
- if ( current_user_can('edit_page', $comment->comment_post_ID) ) ?>
- | <a href="page.php?action=edit&amp;post=<?php echo $comment->comment_post_ID; ?>"><?php printf(__('Edit Page &#8220;%s&#8221;'), $post_title); ?></a>
- <?php } else {
- if ( current_user_can('edit_post', $comment->comment_post_ID) ) ?>
- | <a href="post.php?action=edit&amp;post=<?php echo $comment->comment_post_ID; ?>"><?php printf(__('Edit Post &#8220;%s&#8221;'), $post_title); ?></a>
- <?php } ?>
- | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p>
+<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
+
+<?php comment_text() ?>
+
+<p><?php comment_date('M j, g:i A'); ?> &#8212; [
+<?php
+if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
+ echo " <a href='comment.php?action=editcomment&amp;comment=".$comment->comment_ID."\'>" . __('Edit') . '</a>';
+ echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
+ if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
+ echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
+ echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
+ }
+ echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;delete_type=spam&amp;p=" . $comment->comment_post_ID . "&amp;comment=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to mark as spam."), js_escape( $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> ";
+}
+$post = get_post($comment->comment_post_ID);
+$post_title = wp_specialchars( $post->post_title, 'double' );
+$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
+?>
+ | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ]</p>
</li>
-<?php } // end foreach ?>
+<?php } // end foreach($comment) ?>
</ol>
<div id="ajax-response"></div>
<?php
- } else {
+ } else { //no comments to show
?>
<p>
@@ -138,39 +150,51 @@ if ('view' == $mode) {
} elseif ('edit' == $mode) {
if ($comments) {
- echo '<form name="deletecomments" id="deletecomments" action="" method="post">
- <table width="100%" cellpadding="3" cellspacing="3">
+ echo '<form name="deletecomments" id="deletecomments" action="" method="post"> ';
+ wp_nonce_field('bulk-comments');
+ echo '<table class="widefat">
+<thead>
<tr>
- <th scope="col">*</th>
- <th scope="col">' . __('Name') . '</th>
- <th scope="col">' . __('E-mail') . '</th>
- <th scope="col">' . __('IP') . '</th>
- <th scope="col">' . __('Comment Excerpt') . '</th>
+ <th scope="col"><input type="checkbox" onclick="checkAll(document.getElementById(\'deletecomments\'));" /></th>
+ <th scope="col" style="text-align: left">' . __('Name') . '</th>
+ <th scope="col" style="text-align: left">' . __('E-mail') . '</th>
+ <th scope="col" style="text-align: left">' . __('IP') . '</th>
+ <th scope="col" style="text-align: left">' . __('Comment Excerpt') . '</th>
<th scope="col" colspan="3">' . __('Actions') . '</th>
- </tr>';
+ </tr>
+</thead>';
foreach ($comments as $comment) {
$authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
+ $comment_status = wp_get_comment_status($comment->comment_ID);
$class = ('alternate' == $class) ? '' : 'alternate';
+ $class .= ('unapproved' == $comment_status) ? ' unapproved' : '';
?>
- <tr class='<?php echo $class; ?>'>
+ <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'>
<td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
<td><?php comment_author_link() ?></td>
<td><?php comment_author_email_link() ?></td>
<td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td>
<td><?php comment_excerpt(); ?></td>
- <td><a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a></td>
+ <td>
+ <?php if ('unapproved' == $comment_status) { ?>
+ (Unapproved)
+ <?php } else { ?>
+ <a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a>
+ <?php } ?>
+ </td>
<td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
echo "<a href='comment.php?action=editcomment&amp;comment=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td>
<td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
- echo "<a href=\"comment.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), $comment->comment_author) . "')\" class='delete'>" . __('Delete') . "</a>"; } ?></td>
+ echo "<a href=\"comment.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape( $comment->comment_author )) . "', theCommentList );\" class='delete'>" . __('Delete') . "</a> ";
+ } ?></td>
</tr>
<?php
} // end foreach
?></table>
- <p><a href="javascript:;" onclick="checkAll(document.getElementById('deletecomments')); return false; "><?php _e('Invert Checkbox Selection') ?></a></p>
- <p class="submit"><input type="submit" name="delete_button" value="<?php _e('Delete Checked Comments &raquo;') ?>" onclick="return confirm('<?php _e("You are about to delete these comments permanently \\n \'Cancel\' to stop, \'OK\' to delete.") ?>')" />
+<p class="submit"><input type="submit" name="delete_button" value="<?php _e('Delete Checked Comments &raquo;') ?>" onclick="var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php _e("Please select some comments to delete"); ?>'); return false } return confirm('<?php printf(__("You are about to delete %s comments permanently \\n \'Cancel\' to stop, \'OK\' to delete."), "' + numchecked + '"); ?>')" />
<input type="submit" name="spam_button" value="<?php _e('Mark Checked Comments as Spam &raquo;') ?>" onclick="return confirm('<?php _e("You are about to mark these comments as spam \\n \'Cancel\' to stop, \'OK\' to mark as spam.") ?>')" /></p>
</form>
+<div id="ajax-response"></div>
<?php
} else {
?>
diff --git a/wp-inst/wp-admin/edit-form-advanced.php b/wp-inst/wp-admin/edit-form-advanced.php
index 0c8853e..8d593e1 100644
--- a/wp-inst/wp-admin/edit-form-advanced.php
+++ b/wp-inst/wp-admin/edit-form-advanced.php
@@ -21,10 +21,12 @@ $messages[3] = __('Custom field deleted.');
if (0 == $post_ID) {
$form_action = 'post';
$temp_ID = -1 * time();
- $form_extra = "<input type='hidden' name='temp_ID' value='$temp_ID' />";
+ $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
+ wp_nonce_field('add-post');
} else {
$form_action = 'editpost';
- $form_extra = "<input type='hidden' name='post_ID' value='$post_ID' />";
+ $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
+ wp_nonce_field('update-post_' . $post_ID);
}
$form_pingback = '<input type="hidden" name="post_pingback" value="' . get_option('default_pingback_flag') . '" id="post_pingback" />';
@@ -49,7 +51,7 @@ if (empty($post->post_status)) $post->post_status = 'draft';
?>
<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
-<input type="hidden" name="action" value="<?php echo $form_action ?>" />
+<input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" />
<input type="hidden" name="post_author" value="<?php echo $post->post_author ?>" />
<input type="hidden" name="post_type" value="post" />
@@ -68,6 +70,16 @@ addLoadEvent(focusit);
<div id="moremeta">
<div id="grabit" class="dbx-group">
+<fieldset id="categorydiv" class="dbx-box">
+<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
+<div class="dbx-content">
+<p id="jaxcat"></p>
+<ul id="categorychecklist"><?php dropdown_categories(get_settings('default_category')); ?></ul></div>
+<?php if ( current_user_can('manage_categories') ) : ?>
+<?php AJAX_search_box( "wpmu-edit.php?action=searchcategories&search=", "newcat", "searchresults" ); ?>
+<?php endif; ?>
+</fieldset>
+
<fieldset id="commentstatusdiv" class="dbx-box">
<h3 class="dbx-handle"><?php _e('Discussion') ?></h3>
<div class="dbx-content">
@@ -89,16 +101,6 @@ addLoadEvent(focusit);
<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo $post->post_name ?>" /></div>
</fieldset>
-<fieldset id="categorydiv" class="dbx-box">
-<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
-<div class="dbx-content">
-<p id="jaxcat"></p>
-<div id="categorychecklist"><?php dropdown_categories(get_settings('default_category')); ?></div></div>
-<?php if ( current_user_can('manage_categories') ) : ?>
-<?php AJAX_search_box( "wpmu-edit.php?action=searchcategories&search=", "newcat", "searchresults" ); ?>
-<?php endif; ?>
-</fieldset>
-
<fieldset class="dbx-box">
<h3 class="dbx-handle"><?php _e('Post Status') ?></h3>
<div class="dbx-content"><?php if ( current_user_can('publish_posts') ) : ?>
@@ -146,55 +148,7 @@ endforeach;
<fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>">
<legend><?php _e('Post') ?></legend>
-<?php
- $rows = get_settings('default_post_edit_rows');
- if (($rows < 3) || ($rows > 100)) {
- $rows = 12;
- }
-?>
-<?php the_quicktags(); ?>
-
-<div><textarea <?php if ( user_can_richedit() ) echo 'title="true" '; ?>rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="2" id="content"><?php echo user_can_richedit() ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div>
-</fieldset>
-
-<script type="text/javascript">
-<!--
-edCanvas = document.getElementById('content');
-<?php if ( user_can_richedit() ) : ?>
-// This code is meant to allow tabbing from Title to Post (TinyMCE).
-if ( tinyMCE.isMSIE )
- document.getElementById('title').onkeydown = function (e)
- {
- e = e ? e : window.event;
- if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
- var i = tinyMCE.selectedInstance;
- if(typeof i == 'undefined')
- return true;
- tinyMCE.execCommand("mceStartTyping");
- this.blur();
- i.contentWindow.focus();
- e.returnValue = false;
- return false;
- }
- }
-else
- document.getElementById('title').onkeypress = function (e)
- {
- e = e ? e : window.event;
- if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
- var i = tinyMCE.selectedInstance;
- if(typeof i == 'undefined')
- return true;
- tinyMCE.execCommand("mceStartTyping");
- this.blur();
- i.contentWindow.focus();
- e.returnValue = false;
- return false;
- }
- }
-<?php endif; ?>
-//-->
-</script>
+ <?php the_editor($post->post_content); ?>
<?php echo $form_pingback ?>
<?php echo $form_prevstatus ?>
@@ -224,7 +178,7 @@ else
<?php
if (current_user_can('upload_files')) {
$uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
- $uploading_iframe_src = "inline-uploading.php?action=view&amp;post=$uploading_iframe_ID";
+ $uploading_iframe_src = wp_nonce_url("inline-uploading.php?action=view&amp;post=$uploading_iframe_ID", 'inlineuploading');
$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
if ( false != $uploading_iframe_src )
echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
@@ -251,16 +205,17 @@ if ( ! empty($pings) )
<fieldset id="postcustom" class="dbx-box">
<h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3>
<div id="postcustomstuff" class="dbx-content">
-<?php
-if($metadata = has_meta($post_ID)) {
-?>
+<table cellpadding="3">
<?php
- list_meta($metadata);
+$metadata = has_meta($post_ID);
+list_meta($metadata);
?>
+
+</table>
<?php
-}
meta_form();
?>
+<div id="ajax-response"></div>
</div>
</fieldset>
@@ -268,8 +223,8 @@ if($metadata = has_meta($post_ID)) {
</div>
-<?php if ('edit' == $action) : ?>
-<input name="deletepost" class="button" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this post') ?>" <?php echo "onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), addslashes($post->post_title) ) . "')\""; ?> />
+<?php if ('edit' == $action) : $delete_nonce = wp_create_nonce( 'delete-post_' . $post_ID ); ?>
+<input name="deletepost" class="button" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this post') ?>" <?php echo "onclick=\"if ( confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), addslashes($post->post_title) ) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}\""; ?> />
<?php endif; ?>
</div>
diff --git a/wp-inst/wp-admin/edit-form-comment.php b/wp-inst/wp-admin/edit-form-comment.php
index ac92082..1f23cef 100644
--- a/wp-inst/wp-admin/edit-form-comment.php
+++ b/wp-inst/wp-admin/edit-form-comment.php
@@ -6,6 +6,7 @@ $form_extra = "' />\n<input type='hidden' name='comment_ID' value='" . $comment-
?>
<form name="post" action="comment.php" method="post" id="post">
+<?php wp_nonce_field('update-comment_' . $comment->comment_ID) ?>
<div class="wrap">
<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
<input type="hidden" name="action" value='<?php echo $form_action . $form_extra ?>' />
@@ -17,19 +18,19 @@ function focusit() { // focus on first input field
addLoadEvent(focusit);
</script>
<fieldset id="namediv">
- <legend><?php _e('Name:') ?></legend>
+ <legend><label for="name"><?php _e('Name:') ?></label></legend>
<div>
- <input type="text" name="newcomment_author" size="22" value="<?php echo $comment->comment_author ?>" tabindex="1" id="name" />
+ <input type="text" name="newcomment_author" size="25" value="<?php echo $comment->comment_author ?>" tabindex="1" id="name" />
</div>
</fieldset>
<fieldset id="emaildiv">
- <legend><?php _e('E-mail:') ?></legend>
+ <legend><label for="email"><?php _e('E-mail:') ?></label></legend>
<div>
- <input type="text" name="newcomment_author_email" size="30" value="<?php echo $comment->comment_author_email ?>" tabindex="2" id="email" />
+ <input type="text" name="newcomment_author_email" size="20" value="<?php echo $comment->comment_author_email ?>" tabindex="2" id="email" />
</div>
</fieldset>
<fieldset id="uridiv">
- <legend><?php _e('URI:') ?></legend>
+ <legend><label for="URL"><?php _e('URI:') ?></label></legend>
<div>
<input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url ?>" tabindex="3" id="URL" />
</div>
@@ -37,56 +38,9 @@ addLoadEvent(focusit);
<fieldset style="clear: both;">
<legend><?php _e('Comment') ?></legend>
-<?php the_quicktags(); ?>
-
-<?php
- $rows = get_settings('default_post_edit_rows');
- if (($rows < 3) || ($rows > 100)) {
- $rows = 10;
- }
-?>
-<div><textarea title="true" rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content" style="width: 99%"><?php echo user_can_richedit() ? wp_richedit_pre($comment->comment_content) : $comment->comment_content; ?></textarea></div>
+ <?php the_editor($comment->comment_content, 'content', 'newcomment_author_url'); ?>
</fieldset>
-<script type="text/javascript">
-<!--
-edCanvas = document.getElementById('content');
-<?php if ( user_can_richedit() ) : ?>
-// This code is meant to allow tabbing from Author URL to Post (TinyMCE).
-if ( tinyMCE.isMSIE )
- document.getElementById('newcomment_author_url').onkeydown = function (e)
- {
- e = e ? e : window.event;
- if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
- var i = tinyMCE.selectedInstance;
- if(typeof i == 'undefined')
- return true;
- tinyMCE.execCommand("mceStartTyping");
- this.blur();
- i.contentWindow.focus();
- e.returnValue = false;
- return false;
- }
- }
-else
- document.getElementById('newcomment_author_url').onkeypress = function (e)
- {
- e = e ? e : window.event;
- if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
- var i = tinyMCE.selectedInstance;
- if(typeof i == 'undefined')
- return true;
- tinyMCE.execCommand("mceStartTyping");
- this.blur();
- i.contentWindow.focus();
- e.returnValue = false;
- return false;
- }
- }
-<?php endif; ?>
-//-->
-</script>
-
<p class="submit"><input type="submit" name="editcomment" id="editcomment" value="<?php echo $submitbutton_text ?>" style="font-weight: bold;" tabindex="6" />
<input name="referredby" type="hidden" id="referredby" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" />
</p>
@@ -106,14 +60,18 @@ else
<?php if ( current_user_can('edit_posts') ) : ?>
<tr>
- <th scope="row"><?php _e('Edit time'); ?>:</th>
- <td><?php touch_time(('editcomment' == $action), 0); ?></td>
+ <th scope="row" valign="top"><?php _e('Edit time'); ?>:</th>
+ <td><?php touch_time(('editcomment' == $action), 0); ?> </td>
</tr>
<?php endif; ?>
<tr>
- <th scope="row"><?php _e('Delete'); ?>:</th>
- <td><p><a class="delete" href="comment.php?action=confirmdeletecomment&amp;noredir=true&amp;comment=<?php echo $comment->comment_ID; ?>&amp;p=<?php echo $comment->comment_post_ID; ?>"><?php _e('Delete comment') ?></a></p></td>
+ <th scope="row" valign="top"><?php _e('Delete'); ?>:</th>
+ <td><input name="deletecomment" class="button" type="submit" id="deletecomment" tabindex="10" value="<?php _e('Delete this comment') ?>" <?php echo "onclick=\"return confirm('" . __("You are about to delete this comment \\n \'Cancel\' to stop, \'OK\' to delete.") . "')\""; ?> />
+ <input type="hidden" name="comment" value="<?php echo $comment->comment_ID ?>" />
+ <input type="hidden" name="p" value="<?php echo $comment->comment_post_ID ?>" />
+ <input type="hidden" name="noredir" value="1" />
+ </td>
</tr>
</table>
diff --git a/wp-inst/wp-admin/edit-link-form.php b/wp-inst/wp-admin/edit-link-form.php
index b2d60c8..faa4956 100644
--- a/wp-inst/wp-admin/edit-link-form.php
+++ b/wp-inst/wp-admin/edit-link-form.php
@@ -2,11 +2,13 @@
if ( ! empty($link_id) ) {
$heading = __('Edit Bookmark');
$submit_text = __('Save Changes &raquo;');
- $form = '<form name="editlink" id="editlink" method="post" action="link.php">';
+ $form = '<form name="editlink" id="editlink" method="post" action="link.php">';
+ $nonce_action = 'update-bookmark_' . $link_id;
} else {
$heading = __('Create Bookmark');
$submit_text = __('Add Bookmark &raquo;');
$form = '<form name="addlink" id="addlink" method="post" action="link.php">';
+ $nonce_action = 'add-bookmark';
}
function xfn_check($class, $value = '', $type = 'check') {
@@ -31,7 +33,8 @@ function xfn_check($class, $value = '', $type = 'check') {
<div class="wrap">
<h2><?php echo $heading ?></h2>
<?php echo $form ?>
-
+<?php wp_nonce_field($nonce_action); ?>
+
<div id="poststuff">
<div id="moremeta">
<div id="grabit" class="dbx-group">
diff --git a/wp-inst/wp-admin/edit-page-form.php b/wp-inst/wp-admin/edit-page-form.php
index e10897a..530f979 100644
--- a/wp-inst/wp-admin/edit-page-form.php
+++ b/wp-inst/wp-admin/edit-page-form.php
@@ -5,11 +5,13 @@
<?php
if (0 == $post_ID) {
$form_action = 'post';
+ $nonce_action = 'add-page';
$temp_ID = -1 * time();
- $form_extra = "<input type='hidden' name='temp_ID' value='$temp_ID' />";
+ $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
} else {
$form_action = 'editpost';
- $form_extra = "<input type='hidden' name='post_ID' value='$post_ID' />";
+ $nonce_action = 'update-page_' . $post_ID;
+ $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
}
$sendto = $_SERVER['HTTP_REFERER'];
@@ -23,6 +25,8 @@ $sendto = wp_specialchars( $sendto );
<form name="post" action="page.php" method="post" id="post">
<?php
+wp_nonce_field($nonce_action);
+
if (isset($mode) && 'bookmarklet' == $mode) {
echo '<input type="hidden" name="mode" value="bookmarklet" />';
}
@@ -57,7 +61,7 @@ addLoadEvent(focusit);
<fieldset class="dbx-box">
<h3 class="dbx-handle"><?php _e('Page Status') ?></h3>
-<div class="dbx-content"><?php if ( current_user_can('publish_posts') ) : ?>
+<div class="dbx-content"><?php if ( current_user_can('publish_pages') ) : ?>
<label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label>
<?php endif; ?>
<label for="post_status_draft" class="selectit"><input id="post_status_draft" name="post_status" type="radio" value="draft" <?php checked($post->post_status, 'draft'); ?> /> <?php _e('Draft') ?></label>
@@ -130,56 +134,9 @@ endforeach;
<fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>">
<legend><?php _e('Page Content') ?></legend>
-<?php
- $rows = get_settings('default_post_edit_rows');
- if (($rows < 3) || ($rows > 100)) {
- $rows = 10;
- }
-?>
-<?php the_quicktags(); ?>
-
-<div><textarea title="true" rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content"><?php echo user_can_richedit() ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div>
+ <?php the_editor($post->post_content); ?>
</fieldset>
-<script type="text/javascript">
-<!--
-edCanvas = document.getElementById('content');
-<?php if ( user_can_richedit() ) : ?>
-// This code is meant to allow tabbing from Title to Post (TinyMCE).
-if ( tinyMCE.isMSIE )
- document.getElementById('title').onkeydown = function (e)
- {
- e = e ? e : window.event;
- if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
- var i = tinyMCE.selectedInstance;
- if(typeof i == 'undefined')
- return true;
- tinyMCE.execCommand("mceStartTyping");
- this.blur();
- i.contentWindow.focus();
- e.returnValue = false;
- return false;
- }
- }
-else
- document.getElementById('title').onkeypress = function (e)
- {
- e = e ? e : window.event;
- if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
- var i = tinyMCE.selectedInstance;
- if(typeof i == 'undefined')
- return true;
- tinyMCE.execCommand("mceStartTyping");
- this.blur();
- i.contentWindow.focus();
- e.returnValue = false;
- return false;
- }
- }
-<?php endif; ?>
-//-->
-</script>
-
<p class="submit">
<input name="save" type="submit" id="save" tabindex="3" value="<?php _e('Save and Continue Editing'); ?>" />
<input type="submit" name="submit" value="<?php _e('Save') ?>" style="font-weight: bold;" tabindex="4" />
@@ -197,7 +154,7 @@ if ('publish' != $post->post_status || 0 == $post_ID):
<?php
if (current_user_can('upload_files')) {
$uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
- $uploading_iframe_src = "inline-uploading.php?action=view&amp;post=$uploading_iframe_ID";
+ $uploading_iframe_src = wp_nonce_url("inline-uploading.php?action=view&amp;post=$uploading_iframe_ID", 'inlineuploading');
$uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
if ( false != $uploading_iframe_src )
echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
@@ -209,14 +166,14 @@ if (current_user_can('upload_files')) {
<fieldset id="postcustom" class="dbx-box">
<h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3>
<div id="postcustomstuff" class="dbx-content">
+<table cellpadding="3">
<?php
-if($metadata = has_meta($post_ID)) {
-?>
-<?php
- list_meta($metadata);
+$metadata = has_meta($post_ID);
+list_meta($metadata);
?>
+
+</table>
<?php
-}
meta_form();
?>
</div>
diff --git a/wp-inst/wp-admin/edit-pages.php b/wp-inst/wp-admin/edit-pages.php
index 2e25f53..ce169b8 100644
--- a/wp-inst/wp-admin/edit-pages.php
+++ b/wp-inst/wp-admin/edit-pages.php
@@ -2,7 +2,7 @@
require_once('admin.php');
$title = __('Pages');
$parent_file = 'edit.php';
-$list_js = true;
+wp_enqueue_script( 'listman' );
require_once('admin-header.php');
?>
@@ -19,7 +19,7 @@ require_once('admin-header.php');
</form>
<?php
-wp('post_type=page&orderby=menu_order&what_to_show=posts&posts_per_page=15&posts_per_archive_page=-1');
+wp('post_type=page&orderby=menu_order&what_to_show=posts&posts_per_page=-1&posts_per_archive_page=-1');
if ( $_GET['s'] )
$all = false;
@@ -28,28 +28,25 @@ else
if ($posts) {
?>
-<table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
- <tr>
- <th scope="col"><?php _e('ID') ?></th>
- <th scope="col"><?php _e('Title') ?></th>
- <th scope="col"><?php _e('Owner') ?></th>
- <th scope="col"><?php _e('Updated') ?></th>
- <th scope="col"></th>
- <th scope="col"></th>
- <th scope="col"></th>
- </tr>
+<table class="widefat">
+ <thead>
+ <tr>
+ <th scope="col"><?php _e('ID') ?></th>
+ <th scope="col" style="text-align: left"><?php _e('Title') ?></th>
+ <th scope="col" style="text-align: left"><?php _e('Owner') ?></th>
+ <th scope="col" style="text-align: left"><?php _e('Updated') ?></th>
+ <th scope="col" colspan="3"><?php _e('Action'); ?></th>
+ </tr>
+ </thead>
+ <tbody id="the-list">
<?php
page_rows(0, 0, $posts, $all);
?>
-</table>
+ </tbody>
+</table>
<div id="ajax-response"></div>
-<div class="navigation">
-<div class="alignleft"><?php next_posts_link(__('&laquo; Previous Entries')) ?></div>
-<div class="alignright"><?php previous_posts_link(__('Next Entries &raquo;')) ?></div>
-</div>
-
<?php
} else {
?>
diff --git a/wp-inst/wp-admin/edit.php b/wp-inst/wp-admin/edit.php
index d8e201f..a39338d 100644
--- a/wp-inst/wp-admin/edit.php
+++ b/wp-inst/wp-admin/edit.php
@@ -3,7 +3,7 @@ require_once('admin.php');
$title = __('Posts');
$parent_file = 'edit.php';
-$list_js = true;
+wp_enqueue_script( 1 == $_GET['c'] ? 'admin-comments' : 'listman' );
require_once('admin-header.php');
$_GET['m'] = (int) $_GET['m'];
@@ -91,16 +91,17 @@ if ( count($arc_result) ) { ?>
<select name='m'>
<?php
foreach ($arc_result as $arc_row) {
- $arc_year = $arc_row->yyear;
- $arc_month = $arc_row->mmonth;
+ if ( $arc_row->yyear == 0 )
+ continue;
+ $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
- if( isset($_GET['m']) && $arc_year . zeroise($arc_month, 2) == (int) $_GET['m'] )
+ if( isset($_GET['m']) && $arc_row->yyear . $arc_row->mmonth == (int) $_GET['m'] )
$default = 'selected="selected"';
else
$default = null;
- echo "<option $default value=\"" . $arc_year.zeroise($arc_month, 2) . '">';
- echo $month[zeroise($arc_month, 2)] . " $arc_year";
+ echo "<option $default value='$arc_row->yyear$arc_row->mmonth'>";
+ echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
echo "</option>\n";
}
?>
@@ -114,7 +115,6 @@ if ( count($arc_result) ) { ?>
<br style="clear:both;" />
<?php
-
// define the columns to display, the syntax is 'internal name' => 'display name'
$posts_columns = array(
'id' => __('ID'),
@@ -133,7 +133,8 @@ $posts_columns['control_delete'] = '';
?>
-<table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
+<table class="widefat">
+ <thead>
<tr>
<?php foreach($posts_columns as $column_display_name) { ?>
@@ -141,10 +142,13 @@ $posts_columns['control_delete'] = '';
<?php } ?>
</tr>
+ </thead>
+ <tbody id="the-list">
<?php
if ($posts) {
$bgcolor = '';
foreach ($posts as $post) { start_wp();
+add_filter('the_title','wp_specialchars');
$class = ('alternate' == $class) ? '' : 'alternate';
?>
<tr id='post-<?php echo $id; ?>' class='<?php echo $class; ?>'>
@@ -181,7 +185,7 @@ foreach($posts_columns as $column_name=>$column_display_name) {
case 'comments':
?>
- <td><a href="edit.php?p=<?php echo $id ?>&amp;c=1">
+ <td style="text-align: center"><a href="edit.php?p=<?php echo $id ?>&amp;c=1">
<?php comments_number(__('0'), __('1'), __('%')) ?>
</a></td>
<?php
@@ -207,7 +211,7 @@ foreach($posts_columns as $column_name=>$column_display_name) {
case 'control_delete':
?>
- <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . sprintf(__("You are about to delete this post &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars(get_the_title('', ''), 1) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
+ <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . sprintf(__("You are about to delete this post &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), js_escape(get_the_title()) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
<?php
break;
@@ -229,7 +233,8 @@ foreach($posts_columns as $column_name=>$column_display_name) {
</tr>
<?php
} // end if ($posts)
-?>
+?>
+ </tbody>
</table>
<div id="ajax-response"></div>
@@ -245,45 +250,40 @@ if ( 1 == count($posts) ) {
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved != 'spam' ORDER BY comment_date");
if ($comments) {
?>
-<h3><?php _e('Comments') ?></h3>
-<ol id="comments">
+<h3 id="comments"><?php _e('Comments') ?></h3>
+<ol id="the-comment-list" class="commentlist">
<?php
+$i = 0;
foreach ($comments as $comment) {
-$comment_status = wp_get_comment_status($comment->comment_ID);
-?>
-<li <?php if ("unapproved" == $comment_status) echo "class='unapproved'"; ?> >
- <?php comment_date('Y-n-j') ?>
- @
- <?php comment_time('g:m:s a') ?>
- <?php
- if ( current_user_can('edit_post', $post->ID) ) {
- echo "[ <a href=\"comment.php?action=editcomment&amp;comment=".$comment->comment_ID."\">" . __('Edit') . "</a>";
- echo " - <a href=\"comment.php?action=deletecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n \'OK\' to delete, \'Cancel\' to stop."), $comment->comment_author) . "')\">" . __('Delete') . "</a> ";
- if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
- if ('approved' == wp_get_comment_status($comment->comment_ID)) {
- echo " - <a href=\"comment.php?action=unapprovecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\">" . __('Unapprove') . "</a> ";
- } else {
- echo " - <a href=\"comment.php?action=approvecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\">" . __('Approve') . "</a> ";
- }
- }
- echo "]";
- } // end if any comments to show
- ?>
- <br />
- <strong>
- <?php comment_author() ?>
- (
- <?php comment_author_email_link() ?>
- /
- <?php comment_author_url_link() ?>
- )</strong> (IP:
- <?php comment_author_IP() ?>
- )
- <?php comment_text() ?>
-
-</li>
-<!-- /comment -->
+ ++$i; $class = '';
+ $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
+ $comment_status = wp_get_comment_status($comment->comment_ID);
+ if ('unapproved' == $comment_status)
+ $class .= ' unapproved';
+ if ($i % 2)
+ $class .= ' alternate';
+ echo "<li id='comment-$comment->comment_ID' class='$class'>";
+?>
+<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
+
+<?php comment_text() ?>
+
+<p><?php comment_date('M j, g:i A'); ?> &#8212; [
+<?php
+if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
+ echo " <a href='comment.php?action=editcomment&amp;comment=".$comment->comment_ID."\'>" . __('Edit') . '</a>';
+ echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
+ if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
+ echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
+ echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
+ }
+ echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;delete_type=spam&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to mark as spam."), js_escape( $comment->comment_author)) . "', theCommentList );\">" . __('Spam') . "</a> ]";
+} // end if any comments to show
+?>
+</p>
+ </li>
+
<?php //end of the loop, don't delete
} // end foreach
echo '</ol>';
diff --git a/wp-inst/wp-admin/execute-pings.php b/wp-inst/wp-admin/execute-pings.php
deleted file mode 100644
index a807223..0000000
--- a/wp-inst/wp-admin/execute-pings.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-require_once('../wp-config.php');
-
-// Do pingbacks
-while ($ping = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {
- $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$ping->ID} AND meta_key = '_pingme';");
- pingback($ping->post_content, $ping->ID);
-}
-
-// Do Enclosures
-while ($enclosure = $wpdb->get_row("SELECT * FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
- $wpdb->query("DELETE FROM {$wpdb->postmeta} WHERE post_id = {$enclosure->ID} AND meta_key = '_encloseme';");
- do_enclose($enclosure->post_content, $enclosure->ID);
-}
-
-// Do Trackbacks
-$trackbacks = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE CHAR_LENGTH(TRIM(to_ping)) > 7 AND post_status = 'publish'");
-if ( is_array($trackbacks) ) {
- foreach ( $trackbacks as $trackback ) {
- do_trackbacks($trackback->ID);
- }
-}
-
-generic_ping();
-
-?>
diff --git a/wp-inst/wp-admin/import.php b/wp-inst/wp-admin/import.php
index 743da65..cd1951a 100644
--- a/wp-inst/wp-admin/import.php
+++ b/wp-inst/wp-admin/import.php
@@ -1,7 +1,7 @@
<?php
require_once ('admin.php');
$title = __('Import');
-$parent_file = 'import.php';
+$parent_file = 'edit.php';
require_once ('admin-header.php');
?>
@@ -30,7 +30,7 @@ if (empty ($importers)) {
echo '<p>'.__('No importers are available.').'</p>'; // TODO: make more helpful
} else {
?>
-<table width="100%" cellpadding="3" cellspacing="3">
+<table class="widefat">
<?php
$style = '';
@@ -42,8 +42,8 @@ if (empty ($importers)) {
$style = 'class="'.$style.'"';
echo "
<tr $style>
- <td class=\"togl\">$action</td>
- <td class=\"desc\">{$data[1]}</td>
+ <td class='import-system'>$action</td>
+ <td class='desc'>{$data[1]}</td>
</tr>";
}
?>
diff --git a/wp-inst/wp-admin/import/blogger.php b/wp-inst/wp-admin/import/blogger.php
index 7b98a7c..8de766c 100644
--- a/wp-inst/wp-admin/import/blogger.php
+++ b/wp-inst/wp-admin/import/blogger.php
@@ -607,6 +607,8 @@ class Blogger_Import {
}
if ( isset($_GET['noheader']) ) {
+ header('Content-Type: text/html; charset=utf-8');
+
$this->import = get_settings('import-blogger');
if ( false === $this->import ) {
@@ -668,6 +670,6 @@ class Blogger_Import {
$blogger_import = new Blogger_Import();
-register_importer('blogger', 'Blogger', __('Import posts and comments from a Blogger account.'), array ($blogger_import, 'start'));
+register_importer('blogger', 'Blogger and Blogspot', __('Import <strong>posts and comments</strong> from your Blogger account'), array ($blogger_import, 'start'));
?>
diff --git a/wp-inst/wp-admin/import/dotclear.php b/wp-inst/wp-admin/import/dotclear.php
index 8b32ff1..9dc8a6e 100644
--- a/wp-inst/wp-admin/import/dotclear.php
+++ b/wp-inst/wp-admin/import/dotclear.php
@@ -157,10 +157,10 @@ class Dotclear_Import {
// General Housekeeping
$dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
set_magic_quotes_runtime(0);
- $prefix = get_option('tpre');
+ $dbprefix = get_option('dcdbprefix');
// Get Categories
- return $dcdb->get_results('SELECT * FROM dc_categorie', ARRAY_A);
+ return $dcdb->get_results('SELECT * FROM '.$dbprefix.'categorie', ARRAY_A);
}
function get_dc_users()
@@ -169,11 +169,11 @@ class Dotclear_Import {
// General Housekeeping
$dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
set_magic_quotes_runtime(0);
- $prefix = get_option('tpre');
+ $dbprefix = get_option('dcdbprefix');
// Get Users
- return $dcdb->get_results('SELECT * FROM dc_user', ARRAY_A);
+ return $dcdb->get_results('SELECT * FROM '.$dbprefix.'user', ARRAY_A);
}
function get_dc_posts()
@@ -181,12 +181,12 @@ class Dotclear_Import {
// General Housekeeping
$dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
set_magic_quotes_runtime(0);
- $prefix = get_option('tpre');
+ $dbprefix = get_option('dcdbprefix');
// Get Posts
- return $dcdb->get_results('SELECT dc_post.*, dc_categorie.cat_libelle_url AS post_cat_name
- FROM dc_post INNER JOIN dc_categorie
- ON dc_post.cat_id = dc_categorie.cat_id', ARRAY_A);
+ return $dcdb->get_results('SELECT '.$dbprefix.'post.*, '.$dbprefix.'categorie.cat_libelle_url AS post_cat_name
+ FROM '.$dbprefix.'post INNER JOIN '.$dbprefix.'categorie
+ ON '.$dbprefix.'post.cat_id = '.$dbprefix.'categorie.cat_id', ARRAY_A);
}
function get_dc_comments()
@@ -195,10 +195,10 @@ class Dotclear_Import {
// General Housekeeping
$dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
set_magic_quotes_runtime(0);
- $prefix = get_option('tpre');
+ $dbprefix = get_option('dcdbprefix');
// Get Comments
- return $dcdb->get_results('SELECT * FROM dc_comment', ARRAY_A);
+ return $dcdb->get_results('SELECT * FROM '.$dbprefix.'comment', ARRAY_A);
}
function get_dc_links()
@@ -206,7 +206,7 @@ class Dotclear_Import {
//General Housekeeping
$dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
set_magic_quotes_runtime(0);
- $dbprefix = get_option('dbprefix');
+ $dbprefix = get_option('dcdbprefix');
return $dcdb->get_results('SELECT * FROM '.$dbprefix.'link ORDER BY position', ARRAY_A);
}
@@ -609,7 +609,7 @@ class Dotclear_Import {
function cleanup_dcimport()
{
- delete_option('dbprefix');
+ delete_option('dcdbprefix');
delete_option('dc_cats');
delete_option('dcid2wpid');
delete_option('dccat2wpcat');
@@ -699,9 +699,9 @@ class Dotclear_Import {
}
if($_POST['dbprefix'])
{
- if(get_option('tpre'))
- delete_option('tpre');
- add_option('tpre',$_POST['dbprefix']);
+ if(get_option('dcdbprefix'))
+ delete_option('dcdbprefix');
+ add_option('dcdbprefix',$_POST['dbprefix']);
}
diff --git a/wp-inst/wp-admin/import/greymatter.php b/wp-inst/wp-admin/import/greymatter.php
index 809512d..f2b4e2d 100644
--- a/wp-inst/wp-admin/import/greymatter.php
+++ b/wp-inst/wp-admin/import/greymatter.php
@@ -6,7 +6,7 @@ class GM_Import {
function header() {
echo '<div class="wrap">';
- echo '<h2>'.__('Import Graymatter').'</h2>';
+ echo '<h2>'.__('Import Greymatter').'</h2>';
}
function footer() {
diff --git a/wp-inst/wp-admin/import/livejournal.php b/wp-inst/wp-admin/import/livejournal.php
index 40c14fc..44b92a5 100644
--- a/wp-inst/wp-admin/import/livejournal.php
+++ b/wp-inst/wp-admin/import/livejournal.php
@@ -37,7 +37,6 @@ class LJ_Import {
unset($importdata);
echo '<ol>';
foreach ($posts as $post) {
- flush();
preg_match('|<subject>(.*?)</subject>|is', $post, $post_title);
$post_title = $wpdb->escape(trim($post_title[1]));
if ( empty($post_title) ) {
@@ -118,8 +117,6 @@ class LJ_Import {
printf(__('(%s comments)'), $num_comments);
}
echo '</li>';
- flush();
- ob_flush();
}
echo '</ol>';
}
diff --git a/wp-inst/wp-admin/import/mt.php b/wp-inst/wp-admin/import/mt.php
index 08bd343..0bdfd6d 100644
--- a/wp-inst/wp-admin/import/mt.php
+++ b/wp-inst/wp-admin/import/mt.php
@@ -11,7 +11,7 @@ class MT_Import {
function header() {
echo '<div class="wrap">';
- echo '<h2>'.__('Import Movable Type').'</h2>';
+ echo '<h2>'.__('Import Movable Type and Typepad').'</h2>';
}
function footer() {
@@ -32,6 +32,7 @@ class MT_Import {
global $wpdb, $testing;
$users = get_users_of_blog($wpdb->blogid);
?><select name="userselect[<?php echo $n; ?>]">
+ <option value="#NONE#">- Select -</option>
<?php
@@ -132,11 +133,12 @@ class MT_Import {
}
function mt_authors_form() {
- $this->header();
?>
-<h2><?php _e('Select Authors'); ?></h2>
+<div class="wrap">
+<h2><?php _e('Assign Authors'); ?></h2>
<p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as <code>admin</code>s entries.'); ?></p>
-<p><?php _e('Below, you can see the names of the authors of the MovableType posts in <i>italics</i>. For each of these names, pick an author from your blog from the menu'); ?></p>
+<p><?php _e('Below, you can see the names of the authors of the MovableType posts in <i>italics</i>. For each of these names, you can either pick an author in your WordPress installation from the menu, or enter a name for the author in the textbox.'); ?></p>
+<p><?php _e('If a new user is created by WordPress, the password will be set, by default, to "changeme". Quite suggestive, eh? ;)'); ?></p>
<?php
@@ -146,23 +148,17 @@ class MT_Import {
$j = -1;
foreach ($authors as $author) {
++ $j;
- echo '<li><i>'.$author.'</i><br />';
+ echo '<li><i>'.$author.'</i><br />'.'<input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30">';
$this->users_form($j);
echo '</li>';
}
echo '<input type="submit" value="Submit">'.'<br/>';
echo '</form>';
- echo '</ol>';
+ echo '</ol></div>';
- flush();
- $this->footer();
-?>
-<?php
}
-
-
function select_authors() {
$file = wp_import_handle_upload();
if ( isset($file['error']) ) {
@@ -178,9 +174,8 @@ class MT_Import {
function process_posts() {
global $wpdb;
- $this->header();
$i = -1;
- echo "<ol>";
+ echo "<div class='wrap'><ol>";
foreach ($this->posts as $post) {
if ('' != trim($post)) {
++ $i;
@@ -336,7 +331,7 @@ class MT_Import {
}
}
if ( $num_comments )
- printf(__('(%s comments)'), $num_comments);
+ printf(__(' (%s comments)'), $num_comments);
// Finally the pings
// fix the double newline on the first one
@@ -384,23 +379,22 @@ class MT_Import {
}
}
if ( $num_pings )
- printf(__('(%s pings)'), $num_pings);
-
+ printf(__(' (%s pings)'), $num_pings);
+
echo "</li>";
}
- flush();
}
echo '</ol>';
wp_import_cleanup($this->id);
- echo '<h3>'.sprintf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')).'</h3>';
- $this->footer();
+ echo '<h3>'.sprintf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')).'</h3></div>';
}
function import() {
$this->id = (int) $_GET['id'];
+
$this->file = get_attached_file($this->id);
$this->get_authors_from_post();
$this->get_entries();
@@ -427,11 +421,11 @@ class MT_Import {
}
function MT_Import() {
- // Nothing.
+ // Nothing.
}
}
$mt_import = new MT_Import();
-register_importer('mt', 'Movable Type / Typepad', __('Import posts and comments from your Movable Type or Typepad blog from their export file.'), array ($mt_import, 'dispatch'));
+register_importer('mt', 'Movable Type and Typepad', __('Imports <strong>posts and comments</strong> from your Movable Type or Typepad blog'), array ($mt_import, 'dispatch'));
?>
diff --git a/wp-inst/wp-admin/inline-uploading.php b/wp-inst/wp-admin/inline-uploading.php
index 1e3b812..601f530 100644
--- a/wp-inst/wp-admin/inline-uploading.php
+++ b/wp-inst/wp-admin/inline-uploading.php
@@ -34,16 +34,20 @@ break;
case 'delete':
+check_admin_referer('inlineuploading');
+
if ( !current_user_can('edit_post', (int) $attachment) )
die(__('You are not allowed to delete this attachment.').' <a href="'.basename(__FILE__)."?post=$post&amp;all=$all&amp;action=upload\">".__('Go back').'</a>');
wp_delete_attachment($attachment);
-header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&start=$start");
+header("Location: " . basename(__FILE__) ."?post=$post&all=$all&action=view&start=$start");
die;
case 'save':
+check_admin_referer('inlineuploading');
+
$overrides = array('action'=>'save');
$file = wp_handle_upload($_FILES['image'], $overrides);
@@ -101,7 +105,7 @@ if ( preg_match('!^image/!', $attachment['post_mime_type']) ) {
add_post_meta($id, '_wp_attachment_metadata', array());
}
-header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&start=0");
+header("Location: " . basename(__FILE__) . "?post=$post&all=$all&action=view&start=0");
die();
case 'upload':
@@ -140,7 +144,7 @@ if ( '' == $sort )
$attachments = $wpdb->get_results("SELECT ID, post_date, post_title, post_mime_type, guid FROM $wpdb->posts WHERE post_type = 'attachment' $and_type $and_post $and_user ORDER BY $sort LIMIT $start, $double", ARRAY_A);
if ( count($attachments) == 0 ) {
- header("Location: ".basename(__FILE__)."?post=$post&action=upload");
+ header("Location: " . basename(__FILE__) ."?post=$post&action=upload" );
die;
} elseif ( count($attachments) > $num ) {
$next = $start + count($attachments) - $num;
@@ -214,7 +218,7 @@ var icon = new Array();
</noscript>
";
$send_delete_cancel = "<a onclick=\"sendToEditor({$ID});return false;\" href=\"javascript:void()\">$__send_to_editor</a>
-<a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&amp;attachment={$ID}&amp;all=$all&amp;start=$start&amp;post=$post\">$__delete</a>
+<a onclick=\"return confirm('$__confirmdelete')\" href=\"" . wp_nonce_url( basename(__FILE__) . "?action=delete&amp;attachment={$ID}&amp;all=$all&amp;start=$start&amp;post=$post", inlineuploading) . "\">$__delete</a>
<a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a>
";
$uwidth_sum += 128;
@@ -642,25 +646,25 @@ th {
</head>
<body>
<ul id="upload-menu">
-<li<?php echo $current_1; ?>><a href="<?php echo basename(__FILE__); ?>?action=upload&amp;post=<?php echo $post; ?>&amp;all=<?php echo $all; ?>&amp;start=<?php echo $start; ?>"><?php _e('Upload'); ?></a></li>
+<li<?php echo $current_1; ?>><a href="<?php echo basename(__FILE__) . "?action=upload&amp;post=$post&amp;all=$all&amp;start=$start"; ?>"><?php _e('Upload'); ?></a></li>
<?php if ( $attachments = $wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE post_parent = '$post'") ) { ?>
-<li<?php echo $current_2; ?>><a href="<?php echo basename(__FILE__); ?>?action=view&amp;post=<?php echo $post; ?>&amp;all=false"><?php _e('Browse'); ?></a></li>
+<li<?php echo $current_2; ?>><a href="<?php echo basename(__FILE__) . "?action=view&amp;post=$post&amp;all=false"; ?>"><?php _e('Browse'); ?></a></li>
<?php } ?>
<?php if ($wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_type = 'attachment'")) { ?>
-<li<?php echo $current_3; ?>><a href="<?php echo basename(__FILE__); ?>?action=view&amp;post=<?php echo $post; ?>&amp;all=true"><?php _e('Browse All'); ?></a></li>
+<li<?php echo $current_3; ?>><a href="<?php echo basename(__FILE__) . "?action=view&amp;post=$post&amp;all=true"; ?>"><?php _e('Browse All'); ?></a></li>
<?php } ?>
<li> </li>
<?php if ( $action == 'view' ) { ?>
<?php if ( false !== $back ) : ?>
-<li class="spacer"><a href="<?php echo basename(__FILE__); ?>?action=<?php echo $action; ?>&amp;post=<?php echo $post; ?>&amp;all=<?php echo $all; ?>&amp;start=0" title="<?php _e('First'); ?>">|&laquo;</a></li>
-<li><a href="<?php echo basename(__FILE__); ?>?action=<?php echo $action; ?>&amp;post=<?php echo $post; ?>&amp;all=<?php echo $all; ?>&amp;start=<?php echo $back; ?>"">&laquo; <?php _e('Back'); ?></a></li>
+<li class="spacer"><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=0"; ?>" title="<?php _e('First'); ?>">|&laquo;</a></li>
+<li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=$back"; ?>">&laquo; <?php _e('Back'); ?></a></li>
<?php else : ?>
<li class="inactive spacer">|&laquo;</li>
<li class="inactive">&laquo; <?php _e('Back'); ?></li>
<?php endif; ?>
<?php if ( false !== $next ) : ?>
-<li><a href="<?php echo basename(__FILE__); ?>?action=<?php echo $action; ?>&amp;post=<?php echo $post; ?>&amp;all=<?php echo $all; ?>&amp;start=<?php echo $next; ?>"><?php _e('Next &raquo;'); ?></a></li>
-<li><a href="<?php echo basename(__FILE__); ?>?action=<?php echo $action; ?>&amp;post=<?php echo $post; ?>&amp;all=<?php echo $all; ?>&amp;last=true" title="<?php _e('Last'); ?>">&raquo;|</a></li>
+<li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;start=$next"; ?>"><?php _e('Next &raquo;'); ?></a></li>
+<li><a href="<?php echo basename(__FILE__) . "?action=$action&amp;post=$post&amp;all=$all&amp;last=true"; ?>" title="<?php _e('Last'); ?>">&raquo;|</a></li>
<?php else : ?>
<li class="inactive"><?php _e('Next &raquo;'); ?></li>
<li class="inactive">&raquo;|</li>
@@ -702,6 +706,7 @@ th {
<input type="hidden" name="post" value="<?php echo $post; ?>" />
<input type="hidden" name="all" value="<?php echo $all; ?>" />
<input type="hidden" name="start" value="<?php echo $start; ?>" />
+<?php wp_nonce_field( 'inlineuploading' ); ?>
<div id="submit">
<input type="submit" value="<?php _e('Upload'); ?>" />
<?php if ( !empty($all) ) : ?>
diff --git a/wp-inst/wp-admin/link-add.php b/wp-inst/wp-admin/link-add.php
index 8f8f9f3..71ce294 100644
--- a/wp-inst/wp-admin/link-add.php
+++ b/wp-inst/wp-admin/link-add.php
@@ -25,8 +25,9 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
}
}
-$xfn_js = true;
-$editing = true;
+wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
+if ( current_user_can( 'manage_categories' ) )
+ wp_enqueue_script( 'ajaxcat' );
require('admin-header.php');
?>
diff --git a/wp-inst/wp-admin/link-import.php b/wp-inst/wp-admin/link-import.php
index 73a7ae1..352b6e7 100644
--- a/wp-inst/wp-admin/link-import.php
+++ b/wp-inst/wp-admin/link-import.php
@@ -24,6 +24,7 @@ switch ($step) {
<div class="wrap">
<h2><?php _e('Import your blogroll from another system') ?> </h2>
<form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll">
+<?php wp_nonce_field('import-bookmarks') ?>
<p><?php _e('If a program or website you use allows you to export your bookmarks or subscriptions as OPML you may import them here.'); ?>
<div style="width: 70%; margin: auto; height: 8em;">
@@ -63,7 +64,7 @@ foreach ($categories as $category) {
} // end case 0
case 1: {
- check_admin_referer();
+ check_admin_referer('import-bookmarks');
include_once('admin-header.php');
if ( !current_user_can('manage_links') )
diff --git a/wp-inst/wp-admin/link-manager.php b/wp-inst/wp-admin/link-manager.php
index 9ec047a..527c3e8 100644
--- a/wp-inst/wp-admin/link-manager.php
+++ b/wp-inst/wp-admin/link-manager.php
@@ -8,7 +8,7 @@ require_once ('admin.php');
$title = __('Manage Bookmarks');
$this_file = $parent_file = 'link-manager.php';
-$list_js = true;
+wp_enqueue_script( 'listman' );
$wpvarstoreset = array ('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]');
@@ -110,16 +110,17 @@ bookmarks ordered by
</form>
<form id="links" method="post" action="link.php">
+<?php wp_nonce_field('bulk-bookmarks') ?>
<input type="hidden" name="link_id" value="" />
<input type="hidden" name="action" value="" />
<input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
-<table width="100%" cellpadding="3" cellspacing="3">
+<table class="widefat">
<thead>
<tr>
- <th width="15%"><?php _e('Name') ?></th>
- <th><?php _e('URI') ?></th>
- <th><?php _e('Categories') ?></th>
+ <th width="15%" style="text-align: left"><?php _e('Name') ?></th>
+ <th style="text-align: left"><?php _e('URI') ?></th>
+ <th style="text-align: left"><?php _e('Categories') ?></th>
<th><?php _e('rel') ?></th>
<th><?php _e('Visible') ?></th>
<th colspan="2"><?php _e('Action') ?></th>
@@ -175,7 +176,7 @@ if ($links)
<?php
echo '<td><a href="link.php?link_id='.$link->link_id.'&amp;action=edit" class="edit">'.__('Edit').'</a></td>';
- echo '<td><a href="link.php?link_id='.$link->link_id.'&amp;action=delete"'." class='delete' onclick=\"return deleteSomething( 'link', $link->link_id , '".sprintf(__("You are about to delete the &quot;%s&quot; bookmark to %s.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($link->link_name, 1), wp_specialchars($link->link_url)).'\' );" class="delete">'.__('Delete').'</a></td>';
+ echo '<td><a href="' . wp_nonce_url('link.php?link_id='.$link->link_id.'&amp;action=delete', 'delete-bookmark_' . $link->link_id ) . '"'." class='delete' onclick=\"return deleteSomething( 'link', $link->link_id , '".sprintf(__("You are about to delete the &quot;%s&quot; bookmark to %s.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($link->link_name, 1), wp_specialchars($link->link_url)).'\' );" class="delete">'.__('Delete').'</a></td>';
echo '<td align="center"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></td>';
echo "\n </tr>\n";
}
diff --git a/wp-inst/wp-admin/link.php b/wp-inst/wp-admin/link.php
index df61692..6e3056d 100644
--- a/wp-inst/wp-admin/link.php
+++ b/wp-inst/wp-admin/link.php
@@ -29,7 +29,7 @@ $this_file = 'link-manager.php';
switch ($action) {
case 'deletebookmarks' :
- check_admin_referer();
+ check_admin_referer('bulk-bookmarks');
// check the current user's level first.
if (!current_user_can('manage_links'))
@@ -53,7 +53,7 @@ switch ($action) {
break;
case 'move' :
- check_admin_referer();
+ check_admin_referer('bulk-bookmarks');
// check the current user's level first.
if (!current_user_can('manage_links'))
@@ -72,7 +72,7 @@ switch ($action) {
break;
case 'add' :
- check_admin_referer();
+ check_admin_referer('add-bookmark');
add_link();
@@ -80,9 +80,9 @@ switch ($action) {
break;
case 'save' :
- check_admin_referer();
-
$link_id = (int) $_POST['link_id'];
+ check_admin_referer('update-bookmark_' . $link_id);
+
edit_link($link_id);
wp_redirect($this_file);
@@ -90,21 +90,21 @@ switch ($action) {
break;
case 'delete' :
- check_admin_referer();
+ $link_id = (int) $_GET['link_id'];
+ check_admin_referer('delete-bookmark_' . $link_id);
if (!current_user_can('manage_links'))
die(__("Cheatin' uh ?"));
- $link_id = (int) $_GET['link_id'];
-
wp_delete_link($link_id);
wp_redirect($this_file);
break;
case 'edit' :
- $xfn_js = true;
- $editing = true;
+ wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
+ if ( current_user_can( 'manage_categories' ) )
+ wp_enqueue_script( 'ajaxcat' );
$parent_file = 'link-manager.php';
$submenu_file = 'link-manager.php';
$title = __('Edit Bookmark');
@@ -125,4 +125,4 @@ switch ($action) {
}
include ('admin-footer.php');
-?> \ No newline at end of file
+?>
diff --git a/wp-inst/wp-admin/list-manipulation-js.php b/wp-inst/wp-admin/list-manipulation-js.php
index d87edab..ef09467 100644
--- a/wp-inst/wp-admin/list-manipulation-js.php
+++ b/wp-inst/wp-admin/list-manipulation-js.php
@@ -3,8 +3,8 @@ require_once('admin.php');
header('Content-type: text/javascript; charset=' . get_settings('blog_charset'), true);
?>
addLoadEvent(function(){theList=new listMan();});
-function deleteSomething(what,id,message){if(!message)message="<?php printf(__('Are you sure you want to delete this %s?'),"'+what+'"); ?>";if(confirm(message))return theList.ajaxDelete(what,id);else return false;}
-function dimSomething(what,id,dimClass){return theList.ajaxDimmer(what,id,dimClass);}
+function deleteSomething(what,id,message,obj){if(!obj)obj=theList;if(!message)message="<?php printf(__('Are you sure you want to delete this %s?'),"'+what+'"); ?>";if(confirm(message))return obj.ajaxDelete(what,id);else return false;}
+function dimSomething(what,id,dimClass,obj){if(!obj)obj=theList;return obj.ajaxDimmer(what,id,dimClass);}
function WPAjax(file, responseEl){//class WPAjax extends sack
this.getResponseElement=function(r){var p=document.getElementById(r+'-p');if(!p){p=document.createElement('span');p.id=r+'-p';document.getElementById(r).appendChild(p);}this.myResponseElement=p; }
@@ -38,10 +38,11 @@ function listMan(theListId){
this.ajaxRespEl=null;
this.inputData='';this.clearInputs=new Array();this.showLink=1;
this.topAdder=0;this.alt='alternate';this.recolorPos;this.reg_color='#FFFFFF';this.alt_color='#F1F1F1';
+ this.addComplete=null;this.delComplete=null;this.dimComplete=null;
var listType;var listItems;
self.aTrap=0;
- this.ajaxAdder=function(what,where,onComplete,update){//for TR, server must wrap TR in TABLE TBODY. this.makeEl cleans it
+ this.ajaxAdder=function(what,where,update){//for TR, server must wrap TR in TABLE TBODY. this.makeEl cleans it
if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300);
this.ajaxAdd=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response');
if(this.ajaxAdd.failed)return true;
@@ -61,28 +62,28 @@ function listMan(theListId){
if(tempObj.showLink){this.myResponseElement.innerHTML='<div id="jumplink" class="updated fade"><p><a href="#'+what+'-'+id+'"><?php _e('Jump to new item'); ?></a></p></div>';}
else this.myResponseElement.innerHTML='';
for(var i=0;i<tempObj.clearInputs.length;i++){try{var theI=document.getElementById(tempObj.clearInputs[i]);if(theI.tagName.match(/select/i))theI.selectedIndex=0;else theI.value='';}catch(e){}}
- if(onComplete&&typeof onComplete=='function')onComplete();
+ if(tempObj.addComplete&&typeof tempObj.addComplete=='function')tempObj.addComplete(what,where,update);
tempObj.recolorList(tempObj.recolorPos,1000);
}
this.ajaxAdd.runAJAX('action='+(update?'update-':'add-')+what+this.inputData);
return false;
}
- this.ajaxUpdater=function(what,where,onComplete){return this.ajaxAdder(what,where,onComplete,true);}
- this.ajaxDelete=function(what,id,onComplete){
+ this.ajaxUpdater=function(what,where){return this.ajaxAdder(what,where,true);}
+ this.ajaxDelete=function(what,id){
if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300);
this.ajaxDel=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response');
if(this.ajaxDel.failed)return true;
var tempObj=this;
- this.ajaxDel.onCompletion=function(){if(this.parseAjaxResponse()){tempObj.removeListItem(what.replace('-as-spam','')+'-'+id);this.myResponseElement.innerHTML='';if(onComplete&&typeof onComplete=='function')onComplete();tempObj.recolorList(tempObj.recolorPos,1000)}};
+ this.ajaxDel.onCompletion=function(){if(this.parseAjaxResponse()){tempObj.removeListItem(what.replace('-as-spam','')+'-'+id);this.myResponseElement.innerHTML='';if(tempObj.delComplete&&typeof tempObj.delComplete=='function')tempObj.delComplete(what,id);tempObj.recolorList(tempObj.recolorPos,1000)}};
this.ajaxDel.runAJAX('action=delete-'+what+'&id='+id);
return false;
}
- this.ajaxDimmer=function(what,id,dimClass,onComplete){
+ this.ajaxDimmer=function(what,id,dimClass){
if(self.aTrap)return;self.aTrap=1;setTimeout('aTrap=0',300);
this.ajaxDim=new WPAjax('admin-ajax.php',this.ajaxRespEl?this.ajaxRespEl:'ajax-response');
if(this.ajaxDim.failed)return true;
var tempObj=this;
- this.ajaxDim.onCompletion=function(){if(this.parseAjaxResponse()){tempObj.dimItem(what+'-'+id,dimClass);this.myResponseElement.innerHTML='';if(onComplete&&typeof onComplete=='function')onComplete();}};
+ this.ajaxDim.onCompletion=function(){if(this.parseAjaxResponse()){tempObj.dimItem(what+'-'+id,dimClass);this.myResponseElement.innerHTML='';if(tempObj.dimComplete&&typeof tempObj.dimComplete=='function')tempObj.dimComplete(what,id,dimClass);}};
this.ajaxDim.runAJAX('action=dim-'+what+'&id='+id);
return false;
}
diff --git a/wp-inst/wp-admin/list-manipulation.js b/wp-inst/wp-admin/list-manipulation.js
deleted file mode 100644
index f61b407..0000000
--- a/wp-inst/wp-admin/list-manipulation.js
+++ /dev/null
@@ -1,96 +0,0 @@
-var listItems;
-var reg_color = '#FFFFFF';
-var alt_color = '#F1F1F1';
-
-addLoadEvent(getListItems);
-
-function deleteSomething( what, id, message ) {
- what.replace('-', ' ');
- if (!message) message = 'Are you sure you want to delete this ' + what + '?';
- if ( confirm(message) ) {
- return ajaxDelete( what.replace(' ', '-'), id );
- } else {
- return false;
- }
-}
-
-function getResponseElement() {
- var p = document.getElementById('ajax-response-p');
- if (!p) {
- p = document.createElement('p');
- p.id = 'ajax-response-p';
- document.getElementById('ajax-response').appendChild(p);
- return p;
- }
-}
-
-function ajaxDelete(what, id) {
- ajaxDel = new sack('list-manipulation.php');
- if ( ajaxDel.failed ) return true;
- ajaxDel.myResponseElement = getResponseElement();
- ajaxDel.method = 'POST';
- ajaxDel.onLoading = function() { ajaxDel.myResponseElement.innerHTML = 'Sending Data...'; };
- ajaxDel.onLoaded = function() { ajaxDel.myResponseElement.innerHTML = 'Data Sent...'; };
- ajaxDel.onInteractive = function() { ajaxDel.myResponseElement.innerHTML = 'Processing Data...'; };
- ajaxDel.onCompletion = function() { removeThisItem( what + '-' + id ); };
- ajaxDel.runAJAX('action=delete-' + what + '&id=' + id);
- return false;
-}
-
-function removeThisItem(id) {
- var response = ajaxDel.response;
- if ( isNaN(response) ) { alert(response); }
- response = parseInt(response, 10);
- if ( -1 == response ) { ajaxDel.myResponseElement.innerHTML = "You don't have permission to do that."; }
- else if ( 0 == response ) { ajaxDel.myResponseElement.interHTML = "Something odd happened. Try refreshing the page? Either that or what you tried to delete never existed in the first place."; }
- else if ( 1 == response ) {
- theItem = document.getElementById(id);
- Fat.fade_element(id,null,700,'#FF3333');
- setTimeout('theItem.parentNode.removeChild(theItem)', 705);
- var pos = getListPos(id);
- listItems.splice(pos,1);
- recolorList(pos);
- ajaxDel.myResponseElement.parentNode.removeChild(ajaxDel.myResponseElement);
-
- }
-}
-
-function getListPos(id) {
- for (var i = 0; i < listItems.length; i++) {
- if (id == listItems[i]) {
- var pos = i;
- break;
- }
- }
- return pos;
-}
-
-function getListItems() {
- if (list) return;
- listItems = new Array();
- var extra = false;
- var list = document.getElementById('the-list');
- if (!list) { var list = document.getElementById('the-list-x'); extra = true; }
- if (list) {
- var items = list.getElementsByTagName('tr');
- if (!items[0]) { items = list.getElementsByTagName('li'); }
- for (var i=0; i<items.length; i++) { listItems.push(items[i].id); }
- if (extra) { listItems.splice(0,1); }
- }
-}
-
-function recolorList(pos,dur,from) {
- if (!pos) pos = 0;
-
- if (!from) {
- reg_from = alt_color;
- alt_from = reg_color;
- } else {
- reg_from = from;
- alt_from = from;
- }
- for (var i = pos; i < listItems.length; i++) {
- if (i % 2 == 1) Fat.fade_element(listItems[i],null,dur,reg_from,reg_color);
- else Fat.fade_element(listItems[i],null,dur,alt_from,alt_color);
- }
-}
diff --git a/wp-inst/wp-admin/list-manipulation.php b/wp-inst/wp-admin/list-manipulation.php
deleted file mode 100644
index dec8087..0000000
--- a/wp-inst/wp-admin/list-manipulation.php
+++ /dev/null
@@ -1,95 +0,0 @@
-<?php
-require_once('../wp-config.php');
-require_once('admin-functions.php');
-require_once('admin-db.php');
-
-get_currentuserinfo();
-if ( !is_user_logged_in() )
- die('-1');
-
-function grab_results() {
- global $ajax_results;
- $ajax_results = func_get_arg(0);
-}
-
-function get_out_now() { exit; }
-add_action('shutdown', 'get_out_now', -1);
-
-// check_admin_referer();
-
-switch ( $_POST['action'] ) :
-case 'delete-link' :
- $id = (int) $_POST['id'];
- if ( !current_user_can('manage_links') )
- die ('-1');
-
- if ( $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$id'") )
- die('1');
- else die('0');
- break;
-case 'delete-post' :
-case 'delete-page' :
- $id = (int) $_POST['id'];
- if ( !current_user_can('edit_post', $id) ) {
- die('-1');
- }
-
- if ( wp_delete_post($id) ) {
- die('1');
- } else die('0');
- break;
-case 'delete-cat' :
- if ( !current_user_can('manage_categories') )
- die ('-1');
-
- $id = (int) $_POST['id'];
- $cat_name = get_catname($cat_ID);
-
- if ( wp_delete_category($id) )
- die('1');
- else die('0');
- break;
-case 'delete-comment' :
- $id = (int) $_POST['id'];
-
- if ( !$comment = get_comment($id) )
- die('0');
- if ( !current_user_can('edit_post', $comment->comment_post_ID) )
- die('-1');
-
- if ( wp_delete_comment($comment->comment_ID) ) {
- die('1');
- } else {
- die('0');
- }
- break;
-case 'delete-comment-as-spam' :
- $id = (int) $_POST['id'];
-
- if ( !$comment = get_comment($id) )
- die('0');
- if ( !current_user_can('edit_posts', $comment->comment_post_ID) )
- die('-1');
-
- if ( wp_set_comment_status($comment->comment_ID, 'spam') ) {
- die('1');
- } else {
- die('0');
- }
- break;
-case 'delete-link-category' :
- $id = (int) $_POST['id'];
- if ( 1 == $id )
- die('0');
- if ( !current_user_can('manage_links') )
- die('-1');
-
- if ( $wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$id'") ) {
- $wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$id'");
- die('1');
- } else {
- die('0');
- }
- break;
-endswitch;
-?>
diff --git a/wp-inst/wp-admin/menu.php b/wp-inst/wp-admin/menu.php
index 12964ba..5482431 100644
--- a/wp-inst/wp-admin/menu.php
+++ b/wp-inst/wp-admin/menu.php
@@ -12,7 +12,7 @@ if( is_array( $menu_perms ) == false )
$menu[0] = array(__('Dashboard'), 'read', 'index.php');
$menu[5] = array(__('Write'), 'edit_posts', 'post-new.php');
$menu[10] = array(__('Manage'), 'edit_posts', 'edit.php');
-$menu[20] = array(__('Links'), 'manage_links', 'link-manager.php');
+$menu[20] = array(__('Bookmarks'), 'manage_links', 'link-manager.php');
$menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php');
if( $menu_perms[ 'plugins' ] == 1 )
$menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
@@ -21,7 +21,6 @@ if ( current_user_can('edit_users') )
else
$menu[35] = array(__('Profile'), 'read', 'profile.php');
$menu[40] = array(__('Options'), 'manage_options', 'options-general.php');
-$menu[45] = array(__('Import'), 'import', 'import.php');
$submenu['post-new.php'][5] = array(__('Write Post'), 'edit_posts', 'post-new.php');
$submenu['post-new.php'][10] = array(__('Write Page'), 'edit_pages', 'page-new.php');
@@ -31,17 +30,17 @@ $submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php');
$submenu['edit.php'][15] = array(__('Categories'), 'manage_categories', 'categories.php');
$submenu['edit.php'][20] = array(__('Comments'), 'edit_posts', 'edit-comments.php');
$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
-$submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), $awaiting_mod), 'edit_posts', 'moderation.php');
+$submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), "<span id='awaitmod'>$awaiting_mod</span>"), 'edit_posts', 'moderation.php');
#$submenu['edit.php'][30] = array(__('Files'), 'edit_files', 'templates.php');
+$submenu['edit.php'][35] = array(__('Import'), 'import', 'import.php');
/*
$invites_left = get_usermeta( $user_ID, 'invites_left' );
$submenu['edit.php'][35] = array(sprintf(__("Invites (%s)"), $invites_left ), 'edit_posts', 'invites.php'); // TODO: put somewhere else.
*/
-$submenu['link-manager.php'][5] = array(__('Manage Links'), 'manage_links', 'link-manager.php');
-$submenu['link-manager.php'][10] = array(__('Add Link'), 'manage_links', 'link-add.php');
-$submenu['link-manager.php'][15] = array(__('Link Categories'), 'manage_links', 'link-categories.php');
-$submenu['link-manager.php'][20] = array(__('Import Links'), 'manage_links', 'link-import.php');
+$submenu['link-manager.php'][5] = array(__('Manage Bookmarks'), 'manage_links', 'link-manager.php');
+$submenu['link-manager.php'][10] = array(__('Add Bookmark'), 'manage_links', 'link-add.php');
+$submenu['link-manager.php'][20] = array(__('Import Bookmarks'), 'manage_links', 'link-import.php');
$submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
$submenu['profile.php'][10] = array(__('Authors &amp; Users'), 'edit_users', 'users.php');
@@ -53,6 +52,13 @@ $submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options',
$submenu['themes.php'][5] = array(__('Themes'), 'switch_themes', 'themes.php');
+// Create list of page plugin hook names.
+foreach ($menu as $menu_page) {
+ $admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]);
+}
+
+do_action('admin_menu', '');
+
// Loop over submenus and remove pages for which the user does not have privs.
foreach ($submenu as $parent => $sub) {
foreach ($sub as $index => $data) {
@@ -108,21 +114,13 @@ if( is_site_admin() ) {
$submenu[ 'wpmu-admin.php' ][25] = array( 'Options', '10', 'wpmu-options.php' );
$submenu[ 'wpmu-admin.php' ][30] = array( 'Upgrade', '10', 'wpmu-upgrade-site.php' );
}
-
-// Create list of page plugin hook names.
-foreach ($menu as $menu_page) {
- $admin_page_hooks[$menu_page[2]] = sanitize_title($menu_page[0]);
-}
-
-do_action('admin_menu', '');
ksort($menu); // make it all pretty
if (! user_can_access_admin_page()) {
global $wpdb;
// find the blog of this user first
$primary_blog = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE user_id = '$user_ID' AND meta_key = 'primary_blog'" );
- $url = $wpdb->get_row("SELECT domain, path FROM $wpdb->blogs WHERE
-blog_id = $primary_blog");
+ $url = $wpdb->get_row("SELECT domain, path FROM $wpdb->blogs WHERE blog_id = $primary_blog");
header( 'Location: http://' . $url->domain . $url->path . 'wp-admin/' );
exit;
die( __('You do not have sufficient permissions to access this page.') );
diff --git a/wp-inst/wp-admin/moderation.php b/wp-inst/wp-admin/moderation.php
index c684f6e..5839e6f 100644
--- a/wp-inst/wp-admin/moderation.php
+++ b/wp-inst/wp-admin/moderation.php
@@ -3,7 +3,7 @@ require_once('admin.php');
$title = __('Moderate comments');
$parent_file = 'edit.php';
-$list_js = true;
+wp_enqueue_script( 'admin-comments' );
$wpvarstoreset = array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
@@ -32,6 +32,8 @@ switch($action) {
case 'update':
+ check_admin_referer('moderate-comments');
+
if ( ! current_user_can('moderate_comments') )
die('<p>'.__('Your level is not high enough to moderate comments.').'</p>');
@@ -130,28 +132,34 @@ if ($comments) {
?>
<h2><?php _e('Moderation Queue') ?></h2>
<form name="approval" action="moderation.php" method="post">
+ <?php wp_nonce_field('moderate-comments') ?>
<input type="hidden" name="action" value="update" />
- <ol id="the-list" class="commentlist">
+ <ol id="the-comment-list" class="commentlist">
<?php
$i = 0;
foreach($comments as $comment) {
++$i;
$comment_date = mysql2date(get_settings("date_format") . " @ " . get_settings("time_format"), $comment->comment_date);
$post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID='$comment->comment_post_ID'");
- if ($i % 2) $class = 'class="alternate"';
- else $class = '';
- echo "\n\t<li id='comment-$comment->comment_ID' $class>";
+ if ($i % 2) $class = 'js-unapproved alternate';
+ else $class = 'js-unapproved';
+ echo "\n\t<li id='comment-$comment->comment_ID' class='$class'>";
?>
- <p><strong><?php _e('Name:') ?></strong> <?php comment_author_link() ?> <?php if ($comment->comment_author_email) { ?>| <strong><?php _e('E-mail:') ?></strong> <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <strong><?php _e('URI:') ?></strong> <?php comment_author_url_link() ?> <?php } ?>| <strong><?php _e('IP:') ?></strong> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a> | <strong><?php _e('Date:') ?></strong> <?php comment_date(); ?></p>
+ <p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
<?php comment_text() ?>
-<p><?php
-echo '<a href="comment.php?action=editcomment&amp;comment='.$comment->comment_ID.'">' . __('Edit') . '</a> | ';?>
-<a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a> |
-<?php
-echo " <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($comment->comment_author, 1)) . "' );\">" . __('Delete just this comment') . "</a> | "; ?> <?php _e('Bulk action:') ?>
- <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-approve" value="approve" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-approve"><?php _e('Approve') ?></label>
- <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-spam" value="spam" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-spam"><?php _e('Spam') ?></label>
- <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-delete" value="delete" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-delete"><?php _e('Delete') ?></label>
+<p><?php comment_date('M j, g:i A'); ?> &#8212; [ <?php
+echo '<a href="comment.php?action=editcomment&amp;comment='.$comment->comment_ID.'">' . __('Edit') . '</a> | ';
+echo " <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($comment->comment_author)) . "', theCommentList );\">" . __('Delete ') . "</a> | "; ?>
+<?php
+$post = get_post($comment->comment_post_ID);
+$post_title = wp_specialchars( $post->post_title, 'double' );
+$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
+?>
+<a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ] &#8212;
+ <?php _e('Bulk action:') ?>
+ <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-approve" value="approve" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-approve"><?php _e('Approve') ?></label> &nbsp;
+ <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-spam" value="spam" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-spam"><?php _e('Spam') ?></label> &nbsp;
+ <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-delete" value="delete" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-delete"><?php _e('Delete') ?></label> &nbsp;
<input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-nothing" value="later" checked="checked" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-nothing"><?php _e('Defer until later') ?></label>
</p>
@@ -163,7 +171,7 @@ echo " <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID
<div id="ajax-response"></div>
- <p class="submit"><input type="submit" name="submit" value="<?php _e('Moderate Comments &raquo;') ?>" /></p>
+ <p class="submit"><input type="submit" name="submit" value="<?php _e('Bulk Moderate Comments &raquo;') ?>" /></p>
<script type="text/javascript">
// <![CDATA[
function markAllForDelete() {
@@ -219,4 +227,6 @@ break;
}
-include('admin-footer.php') ?>
+include('admin-footer.php');
+
+?>
diff --git a/wp-inst/wp-admin/options-discussion.php b/wp-inst/wp-admin/options-discussion.php
index af2db9a..247c01f 100644
--- a/wp-inst/wp-admin/options-discussion.php
+++ b/wp-inst/wp-admin/options-discussion.php
@@ -21,6 +21,7 @@ if ($action == 'retrospam') {
<div class="wrap">
<h2><?php _e('Discussion Options') ?></h2>
<form method="post" action="options.php">
+<?php wp_nonce_field('update-options') ?>
<fieldset class="options">
<legend><?php _e('Usual settings for an article:<br /><small><em>(These settings may be overridden for individual articles.)</em></small>') ?></legend>
<ul>
diff --git a/wp-inst/wp-admin/options-general.php b/wp-inst/wp-admin/options-general.php
index 99d7be9..e9375a0 100644
--- a/wp-inst/wp-admin/options-general.php
+++ b/wp-inst/wp-admin/options-general.php
@@ -10,6 +10,7 @@ include('./admin-header.php');
<div class="wrap">
<h2><?php _e('General Options') ?></h2>
<form method="post" action="options.php">
+<?php wp_nonce_field('update-options') ?>
<table class="optiontable">
<tr valign="top">
<th scope="row"><?php _e('Weblog title:') ?></th>
@@ -22,15 +23,19 @@ include('./admin-header.php');
<?php _e('In a few words, explain what this weblog is about.') ?></td>
</tr>
<tr valign="top">
-<th scope="row"><?php _e('Search Engines:') ?> </th>
-<td><label><input type="checkbox" name="blog_public" value="1" <?php checked('1', get_option('blog_public')); ?> /> <?php _e('I would like my blog to appear in search engines like Google and Technorati.'); ?></label>
+<th scope="row"><?php _e('Language:') ?> </th>
+<td><select name="language"><?php language_dropdown( get_option('language') ); ?></select>
+<br />
+<?php _e('Language this blog is primarily written in.') ?><br />
+<?php _e('In the future, you will be able to modify the interface language in your profile.') ?>
</td>
</tr>
-<th scope="row"><?php _e('E-mail address:') ?> </th>
-<td><?php form_option('admin_email'); ?>
-<br />
-<?php _e('This address is used only for admin purposes.') ?></td>
+<tr valign="top">
+<th scope="row"><?php _e('Search Engines:') ?> </th>
+<td><label><input type="checkbox" name="blog_public" value="1" <?php checked('1', $current_blog->public); ?> /> <?php _e('I would like my blog to appear in search engines like Google and Technorati, and in public listings around WordPress.com.'); ?></label> (<a href="http://wordpress.com/blog/2006/01/29/a-little-privacy/">more</a>)
+</td>
</tr>
+
<tr valign="top">
<th scope="row"><?php _e('Membership:') ?></th>
<td> <label for="comment_registration">
@@ -39,6 +44,14 @@ include('./admin-header.php');
</label>
</td>
</tr>
+<tr valign="top">
+<th scope="row"><?php _e('E-mail address:') ?> </th>
+<td><input name="new_admin_email" type="text" id="new_admin_email" value="<?php form_option('admin_email'); ?>" size="40" class="code" />
+<br />
+<p><?php _e('This address is used only for admin purposes.') ?> If you change this we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong></p>
+</td>
+</tr>
+
<?php
$lang_files = glob( ABSPATH . WPINC . "/languages/*" );
$lang = get_option( "WPLANG" );
@@ -47,7 +60,7 @@ if( $lang == false ) {
add_option( "WPLANG", $lang );
}
-if( is_array( $lang_files ) ) {
+if( is_array( $lang_files ) && count($lang_files) > 1 ) {
?>
<tr valign="top">
<th width="33%" scope="row"><?php _e('Language:') ?></th>
@@ -98,9 +111,8 @@ if( is_array( $lang_files ) ) {
<td><select name="start_of_week" id="start_of_week">
<?php
for ($day_index = 0; $day_index <= 6; $day_index++) :
-if ($day_index == get_settings('start_of_week')) $selected = " selected='selected'";
-else $selected = '';
-echo "\n\t<option value='$day_index' $selected>$weekday[$day_index]</option>";
+ $selected = (get_settings('start_of_week') == $day_index) ? 'selected="selected"' : '';
+ echo "\n\t<option value='$day_index' $selected>" . $wp_locale->get_weekday($day_index) . '</option>';
endfor;
?>
</select></td>
@@ -110,7 +122,7 @@ endfor;
<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="blogname,blogdescription,users_can_register,gmt_offset,date_format,time_format,start_of_week,comment_registration,WPLANG,blog_public" />
+<input type="hidden" name="page_options" value="blogname,blogdescription,new_admin_email,users_can_register,gmt_offset,date_format,time_format,start_of_week,comment_registration,WPLANG,language,blog_public" />
</p>
</form>
diff --git a/wp-inst/wp-admin/options-misc.php b/wp-inst/wp-admin/options-misc.php
index 4fdccdd..c4f544e 100644
--- a/wp-inst/wp-admin/options-misc.php
+++ b/wp-inst/wp-admin/options-misc.php
@@ -12,7 +12,7 @@ return;
<div class="wrap">
<h2><?php _e('Miscellaneous Options') ?></h2>
<form method="post" action="options.php">
-
+<?php wp_nonce_field('update-options') ?>
<fieldset class="options">
<legend><?php _e('Uploading'); ?></legend>
<table class="editform optiontable">
@@ -36,7 +36,7 @@ return;
</fieldset>
<p><input name="use_linksupdate" type="checkbox" id="use_linksupdate" value="1" <?php checked('1', get_settings('use_linksupdate')); ?> />
-<label for="use_linksupdate"><?php _e('Track Links&#8217; Update Times') ?></label></p>
+<label for="use_linksupdate"><?php _e('Track Bookmarks&#8217; Update Times') ?></label></p>
<p>
<label><input type="checkbox" name="hack_file" value="1" <?php checked('1', get_settings('hack_file')); ?> /> <?php _e('Use legacy <code>my-hacks.php</code> file support') ?></label>
</p>
diff --git a/wp-inst/wp-admin/options-permalink.php b/wp-inst/wp-admin/options-permalink.php
index ab63433..180a43a 100644
--- a/wp-inst/wp-admin/options-permalink.php
+++ b/wp-inst/wp-admin/options-permalink.php
@@ -58,7 +58,9 @@ include('admin-header.php');
$home_path = get_home_path();
-if ( isset($_POST) ) {
+if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
+ check_admin_referer('update-permalink');
+
if ( isset($_POST['permalink_structure']) ) {
$permalink_structure = $_POST['permalink_structure'];
if (! empty($permalink_structure) )
@@ -116,6 +118,7 @@ $structures = array(
);
?>
<form name="form" action="options-permalink.php" method="post">
+<?php wp_nonce_field('update-permalink') ?>
<h3><?php _e('Common options:'); ?></h3>
<p>
<label>
@@ -164,6 +167,7 @@ checked="checked"
<?php if ( $permalink_structure && !$usingpi && !$writable ) : ?>
<p><?php _e('If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Make_a_Directory_Writable">writable</a>, we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p>
<form action="options-permalink.php" method="post">
+<?php wp_nonce_field('update-permalink') ?>
<p>
<textarea rows="5" style="width: 98%;" name="rules"><?php echo $wp_rewrite->mod_rewrite_rules(); ?>
</textarea>
diff --git a/wp-inst/wp-admin/options-privacy.php b/wp-inst/wp-admin/options-privacy.php
deleted file mode 100644
index 17d0364..0000000
--- a/wp-inst/wp-admin/options-privacy.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-require_once('./admin.php');
-
-$title = __('Privacy Options');
-$parent_file = 'options-general.php';
-
-include('./admin-header.php');
-?>
-
-<div class="wrap">
-<h2><?php _e('Privacy Options') ?></h2>
-<form method="post" action="options.php">
-<?php wp_nonce_field('update-options') ?>
-<table class="optiontable">
-<tr valign="top">
-<th scope="row"><?php _e('Blog visibility:') ?> </th>
-<td>
-<input id="blog-public" type="radio" name="blog_public" value="1" <?php checked('1', get_option('blog_public')); ?> />
-<label for="blog-public">I would like my blog to be visible to anyone who visits, including search engines and archivers</label>
-<br />
-<input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked('0', get_option('blog_public')); ?> />
-<label for="blog-norobots">I would like to block search engines, but allow normal folks</label>
-<?php do_action('blog_privacy_selector'); ?>
-</td>
-</tr>
-</table>
-
-<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
-<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="blog_public" />
-</p>
-</form>
-
-</div>
-
-<?php include('./admin-footer.php') ?>
diff --git a/wp-inst/wp-admin/options-reading.php b/wp-inst/wp-admin/options-reading.php
index ba0765b..96abcdf 100644
--- a/wp-inst/wp-admin/options-reading.php
+++ b/wp-inst/wp-admin/options-reading.php
@@ -9,7 +9,43 @@ include('admin-header.php');
<div class="wrap">
<h2><?php _e('Reading Options') ?></h2>
-<form name="form1" method="post" action="options.php">
+<form name="form1" method="post" action="options.php">
+<?php wp_nonce_field('update-options') ?>
+
+<?php if ( get_pages() ): ?>
+<fieldset class="options">
+<legend><?php _e('Front Page') ?></legend>
+<table width="100%" cellspacing="2" cellpadding="5" class="editform">
+<tr valign="top">
+<th width="33%" scope="row"><?php _e('Front page displays:')?></th>
+<td>
+ <label>
+ <input name="show_on_front" type="radio" value="posts" class="tog" <?php checked('posts', get_option('show_on_front')); ?> />
+ <?php _e('The latest posts'); ?>
+ </label>
+ <br />
+ <label>
+ <input name="show_on_front" type="radio" value="page" class="tog" <?php checked('page', get_option('show_on_front')); ?> />
+ <?php printf(__('A static <a href="%s">page</a> (select below)'), 'edit-pages.php'); ?>
+ </label>
+<ul>
+ <li><?php printf(__('Show this page on the front page: %s'), wp_dropdown_pages("name=page_on_front&echo=0&selected=" . get_option('page_on_front'))); ?></li>
+ <li><?php printf(__('Show the latest posts on this page: %s'), wp_dropdown_pages("name=page_for_posts&echo=0&selected=" . get_option('page_for_posts'))); ?></li>
+</ul>
+<?php if ( 'page' == get_option('show_on_front') && get_option('page_for_posts') == get_option('page_on_front') ) : ?>
+<div id="front-page-warning" class="updated fade-ff0000">
+ <p>
+ <?php _e('<strong>Warning:</strong> these pages should not be the same!'); ?>
+ </p>
+</div>
+<?php endif; ?>
+</fieldset>
+</td>
+</tr>
+</table>
+</fieldset>
+<?php endif; ?>
+
<fieldset class="options">
<legend><?php _e('Blog Pages') ?></legend>
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
@@ -36,7 +72,7 @@ include('admin-header.php');
<tr valign="top">
<th scope="row"><?php _e('For each article, show:') ?> </th>
<td>
-<label><input name="rss_use_excerpt" type="radio" value="0" <?php checked(0, get_settings('rss_use_excerpt')); ?> /> <?php _e('Full text') ?></label><br />
+<label><input name="rss_use_excerpt" type="radio" value="0" <?php checked(0, get_settings('rss_use_excerpt')); ?> /> <?php _e('Full text') ?></label><br />
<label><input name="rss_use_excerpt" type="radio" value="1" <?php checked(1, get_settings('rss_use_excerpt')); ?> /> <?php _e('Summary') ?></label>
</td>
</tr>
@@ -51,7 +87,7 @@ include('admin-header.php');
</table>
<p class="submit">
<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="posts_per_page,what_to_show,posts_per_rss,rss_use_excerpt,blog_charset,gzipcompression " />
+<input type="hidden" name="page_options" value="posts_per_page,what_to_show,posts_per_rss,rss_use_excerpt,blog_charset,gzipcompression,show_on_front,page_on_front,page_for_posts" />
<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
</p>
</form>
diff --git a/wp-inst/wp-admin/options-writing.php b/wp-inst/wp-admin/options-writing.php
index 82c2ae6..4f362d3 100644
--- a/wp-inst/wp-admin/options-writing.php
+++ b/wp-inst/wp-admin/options-writing.php
@@ -10,6 +10,7 @@ include('admin-header.php');
<div class="wrap">
<h2><?php _e('Writing Options') ?></h2>
<form method="post" action="options.php">
+<?php wp_nonce_field('update-options') ?>
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr valign="top">
<th width="33%" scope="row"> <?php _e('Size of the post box:') ?></th>
@@ -38,13 +39,25 @@ endforeach;
?>
</select></td>
</tr>
+<tr valign="top">
+<th scope="row"><?php _e('Default bookmark category:') ?></th>
+<td><select name="default_link_category" id="default_link_category">
+<?php
+foreach ($categories as $category) :
+if ($category->cat_ID == get_settings('default_link_category')) $selected = " selected='selected'";
+else $selected = '';
+echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
+endforeach;
+?>
+</select></td>
+</tr>
</table>
<p class="submit">
<input type="hidden" name="action" value="update" />
-<input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,ping_sites,mailserver_url,mailserver_port,mailserver_login,mailserver_pass,default_category,default_email_category,use_balanceTags" />
+<input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,default_category,default_email_category,use_balanceTags,default_link_category" />
<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
</p>
</form>
diff --git a/wp-inst/wp-admin/options.php b/wp-inst/wp-admin/options.php
index 6214c2c..f2752b9 100644
--- a/wp-inst/wp-admin/options.php
+++ b/wp-inst/wp-admin/options.php
@@ -24,12 +24,22 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
if ( !current_user_can('manage_options') )
die ( __('Cheatin&#8217; uh?') );
+if( $_GET[ 'adminhash' ] ) {
+ $new_admin_details = get_option( 'new_admin_email' );
+ if( is_array( $new_admin_details ) && $new_admin_details[ 'hash' ] == $_GET[ 'adminhash' ] && $new_admin_details[ 'newemail' ] != '' ) {
+ update_option( "admin_email", $new_admin_details[ 'newemail' ] );
+ delete_option( "new_admin_email" );
+ }
+ wp_redirect( get_option( "siteurl" ) . "/wp-admin/options-general.php?updated=true" );
+ exit;
+}
+
switch($action) {
case 'update':
$any_changed = 0;
- check_admin_referer();
+ check_admin_referer('update-options');
if (!$_POST['page_options']) {
foreach ($_POST as $key => $value) {
@@ -54,10 +64,41 @@ case 'update':
$value = 'closed';
if( $option == 'blogdescription' || $option == 'blogname' )
- if (current_user_can('unfiltered_html') == false)
- $value = wp_filter_post_kses( $value );
+ $value = wp_filter_post_kses( $value );
+
+ if( $option == 'posts_per_page' && $value == '' )
+ $value = 10;
+
+ if( $option == 'new_admin_email' && $value != get_option( 'admin_email' ) ) {
+ $hash = md5( $value.time().mt_rand() );
+ $newadminemail = array(
+ "hash" => $hash,
+ "newemail" => $value
+ );
+ update_option( "new_admin_email", $newadminemail );
+ wp_mail( $value, "[ " . get_option( 'blogname' ) . " ] New Admin Email Address", "Dear User,
+
+You recently requested to have the administration email address on
+your blog changed.
+If this is correct, please click on the following link to change it:
+" . get_option( "siteurl" ) . "/adminemail/{$hash}/
+
+You can safely ignore and delete this email if you do not want to
+take this action.
+
+" );
+ } elseif (update_option($option, $value) ) {
+ $any_changed++;
+ }
- if (update_option($option, $value) ) {
+ if ( 'language' == $option ) {
+ $value = (int) $value;
+ update_blog_status( $wpdb->blogid, 'lang_id', $value );
+ $any_changed++;
+ }
+ if ( 'blog_public' == $option ) {
+ $value = (int) $value;
+ update_blog_status( $wpdb->blogid, 'public', $value );
$any_changed++;
}
}
@@ -68,8 +109,6 @@ case 'update':
if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) {
// If home changed, write rewrite rules to new location.
$wp_rewrite->flush_rules();
- // Get currently logged in user and password.
- get_currentuserinfo();
// Clear cookies for old paths.
wp_clearcookie();
// Set cookies for new paths.
@@ -94,13 +133,14 @@ if (!is_site_admin())
<div class="wrap">
<h2><?php _e('All options'); ?></h2>
<form name="form" action="options.php" method="post">
+ <?php wp_nonce_field('update-options') ?>
<input type="hidden" name="action" value="update" />
<table width="98%">
<?php
$options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
foreach ($options as $option) :
- $value = wp_specialchars($option->option_value);
+ $value = wp_specialchars($option->option_value, 'single');
echo "
<tr>
<th scope='row'><label for='$option->option_name'>$option->option_name</label></th>
diff --git a/wp-inst/wp-admin/page-new.php b/wp-inst/wp-admin/page-new.php
index ead2fd9..4f7fb8f 100644
--- a/wp-inst/wp-admin/page-new.php
+++ b/wp-inst/wp-admin/page-new.php
@@ -6,15 +6,13 @@ $editing = true;
require_once('admin-header.php');
?>
-<?php if ( isset($_GET['saved']) ) : ?>
-<div id="message" class="updated fade"><p><strong><?php _e('Page saved.') ?> <a href="edit-pages.php"><?php _e('Manage pages &raquo;'); ?></a></strong></p></div>
+<?php if ( isset($_GET['saved']) || isset($_GET['posted']) ) : ?>
+<div id="message" class="updated fade"><p><strong><?php _e('Page saved.') ?> <a href="edit-pages.php"><?php _e('Manage pages'); ?></a> | <a href="<?php echo get_bloginfo('home') . '/'; ?>"><?php _e('View site') ; ?> &raquo;</a></strong></p></div>
<?php endif; ?>
<?php
if ( current_user_can('edit_pages') ) {
$action = 'post';
- get_currentuserinfo();
-
$post = get_default_post_to_edit();
$post->post_type = 'page';
diff --git a/wp-inst/wp-admin/page.php b/wp-inst/wp-admin/page.php
index 0a2184b..cd4d5cc 100644
--- a/wp-inst/wp-admin/page.php
+++ b/wp-inst/wp-admin/page.php
@@ -1,6 +1,11 @@
<?php
require_once('admin.php');
+$parent_file = 'edit.php';
+$submenu_file = 'edit-pages.php';
+
+$wp_rewrite->flush_rules();
+
$wpvarstoreset = array('action');
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
@@ -24,7 +29,7 @@ $action = "delete";
switch($action) {
case 'post':
-
+ check_admin_referer('add-page');
$page_ID = write_post();
// Redirect.
@@ -53,12 +58,15 @@ case 'post':
case 'edit':
$title = __('Edit');
- $parent_file = 'edit.php';
- $submenu_file = 'edit-pages.php';
$editing = true;
- require_once('admin-header.php');
$page_ID = $post_ID = $p = (int) $_GET['post'];
+ $post = get_post($page_ID);
+ if( $post->post_type == 'post' ) {
+ header( "Location: " . str_replace( "page.php", "post.php", $_SERVER[ 'REQUEST_URI' ] ) );
+ die();
+ }
+ require_once('admin-header.php');
if ( !current_user_can('edit_page', $page_ID) )
die ( __('You are not allowed to edit this page.') );
@@ -76,6 +84,7 @@ case 'edit':
case 'editattachment':
$page_id = $post_ID = (int) $_POST['post_ID'];
+ check_admin_referer('update-attachment_' . $page_id);
// Don't let these be changed
unset($_POST['guid']);
@@ -91,6 +100,9 @@ case 'editattachment':
add_post_meta($page_id, '_wp_attachment_metadata', $newmeta);
case 'editpost':
+ $page_ID = (int) $_POST['post_ID'];
+ check_admin_referer('update-page_' . $page_ID);
+
$page_ID = edit_post();
if ($_POST['save']) {
@@ -114,9 +126,8 @@ case 'editpost':
break;
case 'delete':
- check_admin_referer();
-
$page_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
+ check_admin_referer('delete-page_' . $page_id);
$page = & get_post($page_id);
@@ -132,7 +143,7 @@ case 'delete':
}
$sendback = $_SERVER['HTTP_REFERER'];
- if (strstr($sendback, 'page.php')) $sendback = get_settings('siteurl') .'/wp-admin/page-new.php';
+ if (strstr($sendback, 'page.php')) $sendback = get_settings('siteurl') .'/wp-admin/page.php';
elseif (strstr($sendback, 'attachments.php')) $sendback = get_settings('siteurl') .'/wp-admin/attachments.php';
$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
header ('Location: ' . $sendback);
@@ -140,6 +151,8 @@ case 'delete':
break;
default:
+ header('Location: edit-pages.php');
+ exit();
break;
} // end switch
include('admin-footer.php');
diff --git a/wp-inst/wp-admin/plugin-editor.php b/wp-inst/wp-admin/plugin-editor.php
index 739ccb5..885fb94 100644
--- a/wp-inst/wp-admin/plugin-editor.php
+++ b/wp-inst/wp-admin/plugin-editor.php
@@ -35,6 +35,8 @@ switch($action) {
case 'update':
+ check_admin_referer('edit-plugin_' . $file);
+
if ( !current_user_can('edit_plugins') )
die('<p>'.__('You have do not have sufficient permissions to edit templates for this blog.').'</p>');
@@ -96,6 +98,7 @@ if ($plugin_files) :
</div>
<?php if (!$error) { ?>
<form name="template" id="template" action="plugin-editor.php" method="post">
+ <?php wp_nonce_field('edit-plugin_' . $file) ?>
<div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="file" value="<?php echo $file ?>" />
diff --git a/wp-inst/wp-admin/plugins.php b/wp-inst/wp-admin/plugins.php
index 9f45c10..e289e59 100644
--- a/wp-inst/wp-admin/plugins.php
+++ b/wp-inst/wp-admin/plugins.php
@@ -9,9 +9,8 @@ if( $menu_perms[ 'plugins' ] != 1 )
return;
if ( isset($_GET['action']) ) {
- check_admin_referer();
-
if ('activate' == $_GET['action']) {
+ check_admin_referer('activate-plugin_' . $_GET['plugin']);
$current = get_settings('active_plugins');
if (!in_array($_GET['plugin'], $current)) {
$current[] = trim( $_GET['plugin'] );
@@ -22,6 +21,7 @@ if ( isset($_GET['action']) ) {
}
header('Location: plugins.php?activate=true');
} else if ('deactivate' == $_GET['action']) {
+ check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
$current = get_settings('active_plugins');
array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
update_option('active_plugins', $current);
@@ -85,13 +85,15 @@ if (empty($plugins)) {
echo '</p>';
} else {
?>
-<table width="100%" cellpadding="3" cellspacing="3">
+<table class="widefat">
+ <thead>
<tr>
- <th><?php _e('Plugin'); ?></th>
+ <th style="text-align: left"><?php _e('Plugin'); ?></th>
<th><?php _e('Version'); ?></th>
- <th><?php _e('Description'); ?></th>
+ <th style="text-align: left"><?php _e('Description'); ?></th>
<th><?php _e('Action'); ?></th>
</tr>
+ </thead>
<?php
$style = '';
@@ -105,11 +107,11 @@ if (empty($plugins)) {
$style = ('class="alternate"' == $style|| 'class="alternate active"' == $style) ? '' : 'alternate';
if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) {
- $action = "<a href='plugins.php?action=deactivate&amp;plugin=$plugin_file' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>";
+ $action = "<a href='" . wp_nonce_url("plugins.php?action=deactivate&amp;plugin=$plugin_file", 'deactivate-plugin_' . $plugin_file) . "' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>";
$plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>";
$style .= $style == 'alternate' ? ' active' : 'active';
} else {
- $action = "<a href='plugins.php?action=activate&amp;plugin=$plugin_file' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";
+ $action = "<a href='" . wp_nonce_url("plugins.php?action=activate&amp;plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";
}
$plugin_data['Description'] = wp_kses($plugin_data['Description'], array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()) ); ;
if ($style != '') $style = 'class="' . $style . '"';
diff --git a/wp-inst/wp-admin/post-new.php b/wp-inst/wp-admin/post-new.php
index 76713cd..d0f9844 100644
--- a/wp-inst/wp-admin/post-new.php
+++ b/wp-inst/wp-admin/post-new.php
@@ -50,6 +50,8 @@ if ( $drafts = get_users_drafts( $user_ID ) ) { ?>
$post = get_default_post_to_edit();
include('edit-form-advanced.php');
?>
+
+<?php if ( $is_NS4 || $is_gecko || $is_winIE ) { ?>
<div class="wrap">
<h3><?php _e('WordPress bookmarklet'); ?></h3>
<p><?php _e('Right click on the following link and choose "Add to favorites" to create a posting shortcut.'); ?></p>
@@ -87,4 +89,6 @@ window.open ("profile.php?action=IErightclick", "oneclickbookmarklet", "width=50
?>
</p>
</div>
+<?php } ?>
+
<?php include('admin-footer.php'); ?>
diff --git a/wp-inst/wp-admin/post.php b/wp-inst/wp-admin/post.php
index 0ea17be..aad14e9 100644
--- a/wp-inst/wp-admin/post.php
+++ b/wp-inst/wp-admin/post.php
@@ -1,6 +1,8 @@
<?php
require_once('admin.php');
+$parent_file = 'edit.php';
+$submenu_file = 'edit.php';
$wpvarstoreset = array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder' );
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
@@ -18,14 +20,17 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
}
}
-if (isset($_POST['deletepost']))
-$action = "delete";
+if ( isset( $_POST['deletepost'] ) )
+ $action = 'delete';
switch($action) {
+case 'postajaxpost':
case 'post':
- check_admin_referer();
+ $parent_file = 'post-new.php';
+ $submenu_file = 'post-new.php';
+ check_admin_referer('add-post');
- $post_ID = write_post();
+ $post_ID = 'post' == $action ? write_post() : edit_post();
// Redirect.
if (!empty($_POST['mode'])) {
@@ -53,14 +58,16 @@ case 'post':
case 'edit':
$title = __('Edit');
- $parent_file = 'edit.php';
- $submenu_file = 'edit.php';
$editing = true;
- require_once('admin-header.php');
$post_ID = $p = (int) $_GET['post'];
$post = get_post($post_ID);
+ if( $post->post_type == 'page' ) {
+ header( "Location: " . str_replace( "post.php", "page.php", $_SERVER[ 'REQUEST_URI' ] ) );
+ die();
+ }
+ require_once('admin-header.php');
if ( !current_user_can('edit_post', $post_ID) )
die ( __('You are not allowed to edit this post.') );
@@ -77,10 +84,10 @@ case 'edit':
break;
case 'editattachment':
- check_admin_referer();
-
$post_id = (int) $_POST['post_ID'];
+ check_admin_referer('update-attachment_' . $post_id);
+
// Don't let these be changed
unset($_POST['guid']);
$_POST['post_type'] = 'attachment';
@@ -95,7 +102,8 @@ case 'editattachment':
add_post_meta($post_id, '_wp_attachment_metadata', $newmeta);
case 'editpost':
- check_admin_referer();
+ $post_ID = (int) $_POST['post_ID'];
+ check_admin_referer('update-post_' . $post_ID);
$post_ID = edit_post();
@@ -120,9 +128,8 @@ case 'editpost':
break;
case 'delete':
- check_admin_referer();
-
$post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']);
+ check_admin_referer('delete-post_' . $post_id);
$post = & get_post($post_id);
@@ -146,6 +153,8 @@ case 'delete':
break;
default:
+ header('Location: edit.php');
+ exit();
break;
} // end switch
include('admin-footer.php');
diff --git a/wp-inst/wp-admin/profile-update.php b/wp-inst/wp-admin/profile-update.php
index 77d5267..4d6595b 100644
--- a/wp-inst/wp-admin/profile-update.php
+++ b/wp-inst/wp-admin/profile-update.php
@@ -1,18 +1,19 @@
<?php
+$parent_file = 'profile.php';
+$submenu_file = 'profile.php';
require_once('admin.php');
-check_admin_referer();
+check_admin_referer('update-profile_' . $user_ID);
if ( !$_POST )
die( __('No post?') );
$errors = edit_user($user_ID);
-if (count($errors) != 0) {
- foreach ($errors as $id => $error) {
- echo $error . '<br/>';
- }
+if ( is_wp_error( $errors ) ) {
+ foreach( $errors->get_error_messages() as $message )
+ echo "$message<br />";
exit;
}
diff --git a/wp-inst/wp-admin/profile.php b/wp-inst/wp-admin/profile.php
index 1966cef..04f2fc4 100644
--- a/wp-inst/wp-admin/profile.php
+++ b/wp-inst/wp-admin/profile.php
@@ -19,6 +19,7 @@ $bookmarklet_height= 440;
<div class="wrap">
<h2><?php _e('Your Profile and Personal Options'); ?></h2>
<form name="profile" id="your-profile" action="profile-update.php" method="post">
+<?php wp_nonce_field('update-profile_' . $user_ID) ?>
<p>
<input type="hidden" name="from" value="profile" />
<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
diff --git a/wp-inst/wp-admin/setup-config.php b/wp-inst/wp-admin/setup-config.php
index d2c2829..51c69e0 100644
--- a/wp-inst/wp-admin/setup-config.php
+++ b/wp-inst/wp-admin/setup-config.php
@@ -1,17 +1,19 @@
<?php
+return;
define('WP_INSTALLING', true);
-if (file_exists('../wp-config.php'))
- die("The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.");
-
if (!file_exists('../wp-config-sample.php'))
die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
+
$configFile = file('../wp-config-sample.php');
if (!is_writable('../')) die("Sorry, I can't write to the directory. You'll have to either change the permissions on your WordPress directory or create your wp-config.php manually.");
-$step = 0;
-if(isset($_GET['step'])) $step = $_GET['step'];
+
+if (isset($_GET['step']))
+ $step = $_GET['step'];
+else
+ $step = 0;
header( 'Content-Type: text/html; charset=utf-8' );
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -20,45 +22,74 @@ header( 'Content-Type: text/html; charset=utf-8' );
<title>WordPress &rsaquo; Setup Configuration File</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style media="screen" type="text/css">
- <!--
+ <!--
+ html {
+ background: #eee;
+ }
body {
+ background: #fff;
+ color: #000;
font-family: Georgia, "Times New Roman", Times, serif;
- margin-left: 15%;
- margin-right: 15%;
+ margin-left: 20%;
+ margin-right: 20%;
+ padding: .2em 2em;
+ }
+
+ h1 {
+ color: #006;
+ font-size: 18px;
+ font-weight: lighter;
+ }
+
+ h2 {
+ font-size: 16px;
+ }
+
+ p, li, dt {
+ line-height: 140%;
+ padding-bottom: 2px;
+ }
+
+ ul, ol {
+ padding: 5px 5px 5px 20px;
}
#logo {
- margin: 0;
- padding: 0;
- background-image: url(http://wordpress.org/images/logo.png);
- background-repeat: no-repeat;
- height: 60px;
- border-bottom: 4px solid #333;
+ margin-bottom: 2em;
}
- #logo a {
- display: block;
- height: 60px;
+ .step a, .step input {
+ font-size: 2em;
}
- #logo a span {
- display: none;
+ td input {
+ font-size: 1.5em;
}
- p, li {
- line-height: 140%;
+ .step, th {
+ text-align: right;
+ }
+ #footer {
+ text-align: center;
+ border-top: 1px solid #ccc;
+ padding-top: 1em;
+ font-style: italic;
}
- -->
+ -->
</style>
</head>
-<body>
-<h1 id="logo"><a href="http://wordpress.org/"><span>WordPress</span></a></h1>
+<body>
+<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
<?php
+// Check if wp-config.php has been created
+if (file_exists('../wp-config.php'))
+ die("<p>The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p></body></html>");
switch($step) {
case 0:
?>
+
<p>Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.</p>
<ol>
<li>Database name</li>
<li>Database username</li>
- <li>Database password</li>
+ <li>Database password</li>
<li>Database host</li>
<li>Table prefix (if you want to run more than one WordPress in a single database) </li>
</ol>
@@ -70,36 +101,38 @@ switch($step) {
case 1:
?>
</p>
-<form method="post" action="setup-config.php?step=2">
+<form method="post" action="setup-config.php?step=2">
<p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
<table>
<tr>
<th scope="row">Database Name</th>
- <td><input name="dbname" type="text" size="45" value="wordpress" /></td>
+ <td><input name="dbname" type="text" size="25" value="wordpress" /></td>
<td>The name of the database you want to run WP in. </td>
</tr>
<tr>
<th scope="row">User Name</th>
- <td><input name="uname" type="text" size="45" value="username" /></td>
+ <td><input name="uname" type="text" size="25" value="username" /></td>
<td>Your MySQL username</td>
</tr>
<tr>
<th scope="row">Password</th>
- <td><input name="pwd" type="text" size="45" value="password" /></td>
+ <td><input name="pwd" type="text" size="25" value="password" /></td>
<td>...and MySQL password.</td>
</tr>
<tr>
<th scope="row">Database Host</th>
- <td><input name="dbhost" type="text" size="45" value="localhost" /></td>
+ <td><input name="dbhost" type="text" size="25" value="localhost" /></td>
<td>99% chance you won't need to change this value.</td>
</tr>
<tr>
<th scope="row">Table Prefix</th>
- <td><input name="prefix" type="text" id="prefix" value="wp_" size="45" /></td>
+ <td><input name="prefix" type="text" id="prefix" value="wp_" size="25" /></td>
<td>If you want to run multiple WordPress installations in a single database, change this.</td>
</tr>
- </table>
- <input name="submit" type="submit" value="Submit" />
+ </table>
+ <h2 class="step">
+ <input name="submit" type="submit" value="Submit" />
+ </h2>
</form>
<?php
break;
@@ -149,8 +182,8 @@ switch($step) {
<p>All right sparky! You've made it through this part of the installation. WordPress can now communicate with your database. If you are ready, time now to <a href="install.php">run the install!</a></p>
<?php
break;
-
}
-?>
+?>
+<p id="footer"><a href="http://wordpress.org/">WordPress</a>, personal publishing platform.</p>
</body>
</html>
diff --git a/wp-inst/wp-admin/templates.php b/wp-inst/wp-admin/templates.php
index c19dfa1..97c87ba 100644
--- a/wp-inst/wp-admin/templates.php
+++ b/wp-inst/wp-admin/templates.php
@@ -37,8 +37,10 @@ switch($action) {
case 'update':
+ check_admin_referer('edit-file_' . $file);
+
if ( ! current_user_can('edit_files') )
- die('<p>'.__('You have do not have sufficient permissions to edit templates for this blog.').'</p>');
+ die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
$newcontent = stripslashes($_POST['newcontent']);
if (is_writeable($real_file)) {
@@ -127,6 +129,7 @@ endif;
</div>
<?php if (!$error) { ?>
<form name="template" id="template" action="templates.php" method="post">
+ <?php wp_nonce_field('edit-file_' . $file) ?>
<div><textarea cols="70" rows="25" name="newcontent" id='newcontent' tabindex="1"><?php echo $content ?></textarea>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="file" value="<?php echo $file ?>" />
diff --git a/wp-inst/wp-admin/theme-editor.php b/wp-inst/wp-admin/theme-editor.php
index 153b04a..dfea183 100644
--- a/wp-inst/wp-admin/theme-editor.php
+++ b/wp-inst/wp-admin/theme-editor.php
@@ -48,6 +48,8 @@ switch($action) {
case 'update':
+ check_admin_referer('edit-theme_' . $file . $theme);
+
if ( !current_user_can('edit_themes') )
die('<p>'.__('You have do not have sufficient permissions to edit templates for this blog.').'</p>');
@@ -130,6 +132,7 @@ if ($allowed_files) :
if (!$error) {
?>
<form name="template" id="template" action="theme-editor.php" method="post">
+ <?php wp_nonce_field('edit-theme_' . $file . $theme) ?>
<div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
<input type="hidden" name="action" value="update" />
<input type="hidden" name="file" value="<?php echo $file ?>" />
diff --git a/wp-inst/wp-admin/themes.php b/wp-inst/wp-admin/themes.php
index 8f9e51b..f57bd1b 100644
--- a/wp-inst/wp-admin/themes.php
+++ b/wp-inst/wp-admin/themes.php
@@ -2,7 +2,7 @@
require_once('admin.php');
if ( isset($_GET['action']) ) {
- check_admin_referer();
+ check_admin_referer('switch-theme_' . $_GET['template']);
if ('activate' == $_GET['action']) {
if ( isset($_GET['template']) )
@@ -83,7 +83,7 @@ foreach ($theme_names as $theme_name) {
$author = $themes[$theme_name]['Author'];
$screenshot = $themes[$theme_name]['Screenshot'];
$stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
- $activate_link = "themes.php?action=activate&amp;template=$template&amp;stylesheet=$stylesheet";
+ $activate_link = wp_nonce_url("themes.php?action=activate&amp;template=$template&amp;stylesheet=$stylesheet", 'switch-theme_' . $template);
?>
<div class="available-theme">
<h3><a href="<?php echo $activate_link; ?>"><?php echo "$title $version"; ?></a></h3>
diff --git a/wp-inst/wp-admin/upgrade-functions.php b/wp-inst/wp-admin/upgrade-functions.php
index eb59d60..89e0a3b 100644
--- a/wp-inst/wp-admin/upgrade-functions.php
+++ b/wp-inst/wp-admin/upgrade-functions.php
@@ -1,8 +1,147 @@
<?php
-require_once(ABSPATH . 'wp-admin/admin-functions.php');
-require_once(ABSPATH . 'wp-admin/upgrade-schema.php');
-define( "RESET_CAPS", true );
+if ( file_exists(ABSPATH . 'wp-content/install.php') )
+ require (ABSPATH . 'wp-content/install.php');
+require_once(ABSPATH . '/wp-admin/admin-functions.php');
+require_once(ABSPATH . '/wp-admin/admin-db.php');
+require_once(ABSPATH . '/wp-admin/upgrade-schema.php');
+require_once(ABSPATH . '/wp-includes/registration-functions.php');
+
+if ( !function_exists('wp_install') ) :
+function wp_install($blog_title, $user_name, $user_email, $public, $meta='') {
+ global $wp_rewrite;
+
+ wp_cache_flush();
+ make_db_current_silent();
+ populate_options();
+ populate_roles();
+
+ update_option('blogname', $blog_title);
+ update_option('admin_email', $user_email);
+ update_option('blog_public', $public);
+ $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
+ $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
+ update_option('siteurl', $guessurl);
+
+ // If not a public blog, don't ping.
+ if ( ! $public )
+ update_option('default_pingback_flag', 0);
+
+ // Create default user. If the user already exists, the user tables are
+ // being shared among blogs. Just set the role in that case.
+ $user_id = username_exists($user_name);
+ if ( !$user_id ) {
+ $random_password = substr(md5(uniqid(microtime())), 0, 6);
+ $user_id = wp_create_user($user_name, $random_password, $user_email);
+ } else {
+ $random_password = __('User already exists. Password inherited.');
+ }
+
+ $user = new WP_User($user_id);
+ $user->set_role('administrator');
+
+ wp_install_defaults($user_id);
+
+ $wp_rewrite->flush_rules();
+
+ wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
+
+ wp_cache_flush();
+
+ return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
+}
+endif;
+
+if ( !function_exists('wp_install_defaults') ) :
+function wp_install_defaults($user_id) {
+ global $wpdb;
+
+ // Default category
+ $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')");
+
+ // Default link category
+ $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, link_count, category_description) VALUES ('0', '".$wpdb->escape(__('Blogroll'))."', '".sanitize_title(__('Blogroll'))."', '7', '')");
+
+ // Now drop in some default links
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 0, 'http://blogs.linux.ie/xeer/feed/', '');");
+ $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (1, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 0, 'http://zengun.org/weblog/feed/', '');");
+ $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (2, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 0, 'http://boren.nu/feed/', '');");
+ $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (3, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 0, 'http://xml.photomatt.net/feed/', '');");
+ $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (4, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 0, 'http://zed1.com/journalized/feed/', '');");
+ $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (5, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 0, 'http://www.alexking.org/blog/wp-rss2.php', '');");
+ $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (6, 2)" );
+
+ $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 0, 'http://dougal.gunters.org/feed/', '');");
+ $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (7, 2)" );
+
+ // First post
+ $now = date('Y-m-d H:i:s');
+ $now_gmt = gmdate('Y-m-d H:i:s');
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, comment_count, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(__('hello-world'))."', '$now', '$now_gmt', '1', '', '', '')");
+
+ $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
+
+ // Default comment
+ $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."')");
+
+ // First Page
+
+ $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'publish', 'page', '', '', '')");
+}
+endif;
+
+if ( !function_exists('wp_new_blog_notification') ) :
+function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
+ $user = new WP_User($user_id);
+ $email = $user->user_email;
+ $name = $user->user_login;
+ $message_headers = 'From: ' . $blog_title . ' <wordpress@' . $_SERVER['SERVER_NAME'] . '>';
+ $message = sprintf(__("Your new WordPress blog has been successfully set up at:
+
+%1\$s
+
+You can log in to the administrator account with the following information:
+
+Username: %2\$s
+Password: %3\$s
+
+We hope you enjoy your new weblog. Thanks!
+
+--The WordPress Team
+http://wordpress.org/
+"), $blog_url, $name, $password);
+
+ @wp_mail($email, __('New WordPress Blog'), $message, $message_headers);
+}
+endif;
+
+if ( !function_exists('wp_upgrade') ) :
+function wp_upgrade() {
+ global $wp_current_db_version, $wp_db_version;
+
+ $wp_current_db_version = __get_option('db_version');
+
+ // We are up-to-date. Nothing to do.
+ if ( $wp_db_version == $wp_current_db_version )
+ return;
+
+ wp_cache_flush();
+ make_db_current_silent();
+ upgrade_all();
+ wp_cache_flush();
+}
+endif;
+
// Functions to be called in install and upgrade scripts
function upgrade_all() {
global $wp_current_db_version, $wp_db_version, $wp_rewrite;
@@ -34,7 +173,7 @@ function upgrade_all() {
if ( $wp_current_db_version < 3308 )
upgrade_160();
- if ( $wp_current_db_version < 3548 )
+ if ( $wp_current_db_version < 3845 )
upgrade_210();
$wp_rewrite->flush_rules();
@@ -167,7 +306,7 @@ function upgrade_110() {
}
function upgrade_130() {
- global $wpdb, $table_prefix;
+ global $wpdb;
// Remove extraneous backslashes.
$posts = $wpdb->get_results("SELECT ID, post_title, post_content, post_excerpt, guid, post_date, post_name, post_status, post_author FROM $wpdb->posts");
@@ -220,10 +359,10 @@ function upgrade_130() {
}
// Obsolete tables
- $wpdb->query('DROP TABLE IF EXISTS ' . $table_prefix . 'optionvalues');
- $wpdb->query('DROP TABLE IF EXISTS ' . $table_prefix . 'optiontypes');
- $wpdb->query('DROP TABLE IF EXISTS ' . $table_prefix . 'optiongroups');
- $wpdb->query('DROP TABLE IF EXISTS ' . $table_prefix . 'optiongroup_options');
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues');
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes');
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups');
+ $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options');
// Update comments table to use comment_type
$wpdb->query("UPDATE $wpdb->comments SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
@@ -244,7 +383,7 @@ function upgrade_130() {
}
function upgrade_160_helper( $users ) {
- global $wpdb, $table_prefix;
+ global $wpdb, $wp_current_db_version;
populate_roles_160();
@@ -257,7 +396,7 @@ function upgrade_160_helper( $users ) {
if ( !empty( $user->user_nickname ) )
update_usermeta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) );
if ( !empty( $user->user_level ) )
- update_usermeta( $user->ID, $table_prefix . 'user_level', $user->user_level );
+ update_usermeta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
if ( !empty( $user->user_icq ) )
update_usermeta( $user->ID, 'icq', $wpdb->escape($user->user_icq) );
if ( !empty( $user->user_aim ) )
@@ -283,11 +422,11 @@ function upgrade_160_helper( $users ) {
endif;
// FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
- $caps = get_usermeta( $user->ID, $table_prefix . 'capabilities');
+ $caps = get_usermeta( $user->ID, $wpdb->prefix . 'capabilities');
if ( empty($caps) || defined('RESET_CAPS') ) {
- $level = get_usermeta($user->ID, $table_prefix . 'user_level');
+ $level = get_usermeta($user->ID, $wpdb->prefix . 'user_level');
$role = translate_level_to_role($level);
- update_usermeta( $user->ID, $table_prefix . 'capabilities', array($role => true) );
+ update_usermeta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) );
}
endforeach;
@@ -308,7 +447,7 @@ function upgrade_160() {
if ( 0 == $wpdb->get_var("SELECT SUM(category_count) FROM $wpdb->categories") ) { // Create counts
$categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
foreach ( $categories as $cat_id ) {
- $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status='publish' AND category_id = '$cat_id'");
+ $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_type='post' AND post_status='publish' AND category_id = '$cat_id'");
$wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
}
}
@@ -340,7 +479,7 @@ function upgrade_160() {
}
function upgrade_210() {
- global $wpdb, $table_prefix, $wp_current_db_version;
+ global $wpdb, $wp_current_db_version;
if ( $wp_current_db_version < 3506 ) {
// Update status and type.
@@ -362,11 +501,11 @@ function upgrade_210() {
}
}
- if ( $wp_current_db_version < 3513 ) {
+ if ( $wp_current_db_version < 3845 ) {
populate_roles_210();
}
- if ( $wp_current_db_version < 3533 ) {
+ if ( $wp_current_db_version < 3531 ) {
// Give future posts a post_status of future.
$now = gmdate('Y-m-d H:i:59');
$wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
@@ -374,7 +513,44 @@ function upgrade_210() {
$posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
if ( !empty($posts) )
foreach ( $posts as $post )
- wp_schedule_event(mysql2date('U', $post->post_date), 'once', 'publish_future_post', $post->ID);
+ wp_schedule_single_event(mysql2date('U', $post->post_date), 'publish_future_post', $post->ID);
+ }
+ if ( $wp_current_db_version < 3570 ) {
+ // Create categories for link categories if a category with the same
+ // name doesn't exist. Create a map of link cat IDs to cat IDs.
+ $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");
+ foreach ( $link_cats as $link_cat) {
+ if ( $cat_id = category_exists($link_cat->cat_name) ) {
+ $link_cat_id_map[$link_cat->cat_id] = $cat_id;
+ $default_link_cat = $cat_id;
+ } else {
+ $link_cat_id_map[$link_cat->cat_id] = wp_create_category($link_cat->cat_name);
+ $default_link_cat = $link_cat_id_map[$link_cat->cat_id];
+ }
+ }
+
+ // Associate links to cats.
+ $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
+ if ( !empty($links) ) foreach ( $links as $link ) {
+ $link_cat = $link_cat_id_map[$link->link_category];
+ $cat = $wpdb->get_row("SELECT * FROM $wpdb->link2cat WHERE link_id = '$link->link_id' AND category_id = '$link_cat'");
+ if (!$cat && 0 != $link->link_category) {
+ $wpdb->query("INSERT INTO $wpdb->link2cat (link_id, category_id)
+ VALUES ('$link->link_id', '$link_cat')");
+ }
+ }
+
+ // Set default to the last category we grabbed during the upgrade loop.
+ update_option('default_link_category', $default_link_cat);
+
+ // Count links per category.
+ if ( 0 == $wpdb->get_var("SELECT SUM(link_count) FROM $wpdb->categories") ) {
+ $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
+ foreach ( $categories as $cat_id ) {
+ $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
+ $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
+ }
+ }
}
}
@@ -700,6 +876,7 @@ function dbDelta($queries, $execute = true) {
function make_db_current() {
global $wp_queries;
+
$alterations = dbDelta($wp_queries);
echo "<ol>\n";
foreach($alterations as $alteration) echo "<li>$alteration</li>\n";
diff --git a/wp-inst/wp-admin/upgrade-schema.php b/wp-inst/wp-admin/upgrade-schema.php
index f36ec8f..955bbd3 100644
--- a/wp-inst/wp-admin/upgrade-schema.php
+++ b/wp-inst/wp-admin/upgrade-schema.php
@@ -3,7 +3,7 @@
global $wp_queries;
-$wp_queries = "CREATE TABLE $wpdb->categories (
+$wp_queries="CREATE TABLE $wpdb->categories (
cat_ID bigint(20) NOT NULL auto_increment,
cat_name varchar(55) NOT NULL default '',
category_nicename varchar(200) NOT NULL default '',
@@ -133,6 +133,8 @@ CREATE TABLE $wpdb->users (
user_activation_key varchar(60) NOT NULL default '',
user_status int(11) NOT NULL default '0',
display_name varchar(250) NOT NULL default '',
+ spam tinyint(2) NOT NULL default '0',
+ deleted tinyint(2) NOT NULL default '0',
PRIMARY KEY (ID),
KEY user_login_key (user_login)
);
@@ -159,8 +161,24 @@ CREATE TABLE $wpdb->blogs (
deleted tinyint(2) NOT NULL default '0',
lang_id int(11) NOT NULL default '0',
PRIMARY KEY (blog_id),
- KEY site_id (site_id),
- KEY domain (domain,path)
+ KEY domain (domain(50),path(5)),
+ KEY lang_id (lang_id)
+);
+CREATE TABLE wp_blog_versions (
+ blog_id bigint(20) NOT NULL default '0',
+ db_version varchar(20) NOT NULL default '',
+ last_updated datetime NOT NULL default '0000-00-00 00:00:00',
+ PRIMARY KEY (blog_id),
+ KEY db_version (db_version)
+);
+CREATE TABLE wp_registration_log (
+ ID bigint(20) NOT NULL auto_increment,
+ email varchar(255) NOT NULL default '',
+ IP varchar(30) NOT NULL default '',
+ blog_id bigint(20) NOT NULL default '0',
+ t timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
+ PRIMARY KEY (ID),
+ KEY IP (IP)
);
CREATE TABLE $wpdb->site (
id bigint(20) NOT NULL auto_increment,
@@ -182,9 +200,10 @@ CREATE TABLE $wpdb->sitecategories (
cat_ID bigint(20) NOT NULL auto_increment,
cat_name varchar(55) NOT NULL default '',
category_nicename varchar(200) NOT NULL default '',
- category_description longtext NOT NULL,
+ last_updated timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (cat_ID),
- KEY category_nicename (category_nicename)
+ KEY category_nicename (category_nicename),
+ KEY last_updated (last_updated)
);
CREATE TABLE $wpdb->signups (
domain varchar(200) NOT NULL default '',
@@ -193,12 +212,12 @@ CREATE TABLE $wpdb->signups (
user_login varchar(60) NOT NULL default '',
user_email varchar(100) NOT NULL default '',
registered datetime NOT NULL default '0000-00-00 00:00:00',
- activation_key longtext NOT NULL,
- meta longtext,
- active bigint(20),
activated datetime NOT NULL default '0000-00-00 00:00:00',
- PRIMARY KEY (domain,path),
- KEY user_login (user_login)
+ active tinyint(1) NOT NULL default '0',
+ activation_key varchar(50) NOT NULL default '',
+ meta longtext,
+ KEY activation_key (activation_key),
+ KEY domain (domain)
);
";
@@ -282,8 +301,14 @@ function populate_options() {
add_option('uploads_use_yearmonth_folders', 1);
add_option('upload_path', 'wp-content/uploads');
}
+
+ // 2.0.3
+ add_option('secret', md5(uniqid(microtime())));
+
// 2.1
add_option('blog_public', 1);
+ add_option('default_link_category', 2);
+ add_option('show_on_front', 'posts');
add_site_option( 'customizefeed1', '0' );
add_site_option( 'customizefeed2', '0' );
@@ -292,8 +317,6 @@ function populate_options() {
add_site_option( 'dashboardfeed1name', 'WordPress Development Blog' );
add_site_option( 'dashboardfeed2name', 'Other WordPress News' );
- populate_roles();
-
// Delete unused options
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');
foreach ($unusedoptions as $option) :
@@ -415,6 +438,18 @@ function populate_roles_210() {
$role->add_cap('delete_posts');
$role->add_cap('delete_others_posts');
$role->add_cap('delete_published_posts');
+ $role->add_cap('delete_private_posts');
+ $role->add_cap('edit_private_posts');
+ $role->add_cap('read_private_posts');
+ $role->add_cap('delete_private_pages');
+ $role->add_cap('edit_private_pages');
+ $role->add_cap('read_private_pages');
+ }
+
+ $role = get_role('administrator');
+ if ( ! empty($role) ) {
+ $role->add_cap('delete_users');
+ $role->add_cap('create_users');
}
$role = get_role('author');
diff --git a/wp-inst/wp-admin/upgrade.php b/wp-inst/wp-admin/upgrade.php
index 9c9ba81..cbc9699 100644
--- a/wp-inst/wp-admin/upgrade.php
+++ b/wp-inst/wp-admin/upgrade.php
@@ -75,10 +75,12 @@ switch($step) {
break;
case 1:
- wp_cache_flush();
- make_db_current_silent();
- upgrade_all();
- wp_cache_flush();
+ wp_upgrade();
+ if( $wpdb->get_row( "SELECT * FROM wp_blogs WHERE blog_id = '{$wpdb->blogid}'" ) ) {
+ $wpdb->query( "UPDATE wp_blogs SET db_version = '{$wp_db_version}' WHERE blog_id = '{$wpdb->blogid}'" );
+ } else {
+ $wpdb->query( "INSERT INTO `wp_blogs` ( `blog_id` , `db_version` , `last_updated` ) VALUES ( '{$wpdb->blogid}', '{$wp_db_version}', NOW());" );
+ }
if ( empty( $_GET['backto'] ) )
$backto = __get_option('home');
diff --git a/wp-inst/wp-admin/user-edit.php b/wp-inst/wp-admin/user-edit.php
index 5966f1a..3d394a4 100644
--- a/wp-inst/wp-admin/user-edit.php
+++ b/wp-inst/wp-admin/user-edit.php
@@ -25,7 +25,7 @@ $errors = array();
// Only allow site admins to edit every user.
if( is_site_admin() == false )
- if( $user_id != $current_user->ID ) $errors['head'] = __('You do not have permission to edit this user.');
+ if( $user_id != $current_user->ID ) $errors = new WP_Error('head', __('You do not have permission to edit this user.'));
switch ($action) {
case 'switchposts':
@@ -38,16 +38,14 @@ break;
case 'update':
-check_admin_referer();
-
-$errors = array();
+check_admin_referer('update-user_' . $user_id);
-if (!current_user_can('edit_users'))
- $errors['head'] = __('You do not have permission to edit this user.');
+if ( !current_user_can('edit_user', $user_id) )
+ $errors = new WP_Error('head', __('You do not have permission to edit this user.'));
else
- $errors = edit_user($user_id);
+ if( isset( $errors ) == false ) $errors = edit_user($user_id);
-if(count($errors) == 0) {
+if( !is_wp_error( $errors ) ) {
if( is_site_admin() )
update_usermeta( $user_id, 'invites_left', intval( $_POST[ 'invites_left' ] ) );
header("Location: user-edit.php?user_id=$user_id&updated=true");
@@ -59,7 +57,9 @@ include ('admin-header.php');
$profileuser = new WP_User($user_id);
-if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permission to edit this user.');
+if ( !current_user_can('edit_user', $user_id) )
+ if ( !is_wp_error( $errors ) )
+ $errors = new WP_Error('head', __('You do not have permission to edit this user.'));
?>
<?php if ( isset($_GET['updated']) ) : ?>
@@ -67,11 +67,12 @@ if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permi
<p><strong><?php _e('User updated.') ?></strong></p>
</div>
<?php endif; ?>
-<?php if ( count($errors) != 0 ) { ?>
+<?php if ( is_wp_error( $errors ) ) { ?>
<div class="error">
<ul>
<?php
- foreach($errors as $error) echo "<li>$error</li>";
+ foreach( $errors->get_error_messages() as $message )
+ echo "<li>$message</li>";
?>
</ul>
</div>
@@ -81,6 +82,7 @@ if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permi
<h2><?php _e('Edit User'); ?></h2>
<form name="profile" id="your-profile" action="user-edit.php" method="post">
+<?php wp_nonce_field('update-user_' . $user_id) ?>
<p>
<input type="hidden" name="from" value="profile" />
<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
diff --git a/wp-inst/wp-admin/users.php b/wp-inst/wp-admin/users.php
index 64b7662..6dfc57a 100644
--- a/wp-inst/wp-admin/users.php
+++ b/wp-inst/wp-admin/users.php
@@ -11,7 +11,7 @@ $update = '';
switch ($action) {
case 'promote':
- check_admin_referer();
+ check_admin_referer('bulk-users');
if (empty($_POST['users'])) {
header('Location: users.php');
@@ -23,6 +23,8 @@ case 'promote':
$userids = $_POST['users'];
$update = 'promote';
foreach($userids as $id) {
+ if ( ! current_user_can('edit_user', $id) )
+ die(__('You can&#8217;t edit that user.'));
// The new role of the current user must also have edit_users caps
if($id == $current_user->id && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) {
$update = 'err_admin_role';
@@ -38,20 +40,23 @@ case 'promote':
break;
case 'dodelete':
-
- check_admin_referer();
+ die( "This function is disabled." );
+ check_admin_referer('delete-users');
if ( empty($_POST['users']) ) {
header('Location: users.php');
}
- if ( !current_user_can('edit_users') )
+ if ( !current_user_can('delete_users') )
die(__('You can&#8217;t delete users.'));
$userids = $_POST['users'];
$update = 'del';
foreach ($userids as $id) {
+ if ( ! current_user_can('delete_user', $id) )
+ die(__('You can&#8217;t delete that user.'));
+
if($id == $current_user->id) {
$update = 'err_admin_del';
continue;
@@ -71,21 +76,22 @@ case 'dodelete':
break;
case 'delete':
-
- check_admin_referer();
+ die( "This function is disabled." );
+ check_admin_referer('bulk-users');
if (empty($_POST['users'])) {
header('Location: users.php');
}
- if ( !current_user_can('edit_users') )
- $error['edit_users'] = __('You can&#8217;t delete users.');
+ if ( !current_user_can('delete_users') )
+ $error = new WP_Error('edit_users', __('You can&#8217;t delete users.'));
$userids = $_POST['users'];
include ('admin-header.php');
?>
<form action="" method="post" name="updateusers" id="updateusers">
+<?php wp_nonce_field('delete-users') ?>
<div class="wrap">
<h2><?php _e('Delete Users'); ?></h2>
<p><?php _e('You have specified these users for deletion:'); ?></p>
@@ -130,13 +136,86 @@ case 'delete':
break;
+case 'doremove':
+ check_admin_referer();
+
+ if ( empty($_POST['users']) ) {
+ header('Location: users.php');
+ }
+
+ if ( !current_user_can('edit_users') )
+ die(__('You can&#8217;t remove users.'));
+
+ $userids = $_POST['users'];
+
+ $update = 'remove';
+ foreach ($userids as $id) {
+ if ($id == $current_user->id) {
+ $update = 'err_admin_remove';
+ continue;
+ }
+ remove_user_from_blog($id);
+ }
+
+ header('Location: users.php?update=' . $update);
+
+break;
+
+case 'removeuser':
+
+ check_admin_referer();
+
+ if (empty($_POST['users'])) {
+ header('Location: users.php');
+ }
+
+ if ( !current_user_can('edit_users') )
+ $error = new WP_Error('edit_users', __('You can&#8217;t remove users.'));
+
+ $userids = $_POST['users'];
+
+ include ('admin-header.php');
+?>
+<form action="" method="post" name="updateusers" id="updateusers">
+<div class="wrap">
+<h2><?php _e('Remove Users from Blog'); ?></h2>
+<p><?php _e('You have specified these users for removal:'); ?></p>
+<ul>
+<?php
+ $go_remove = false;
+ foreach ($userids as $id) {
+ $user = new WP_User($id);
+ if ($id == $current_user->id) {
+ echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be removed.</strong>'), $id, $user->user_login) . "</li>\n";
+ } else {
+ echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "</li>\n";
+ $go_remove = true;
+ }
+ }
+ ?>
+<?php if($go_remove) : ?>
+ <input type="hidden" name="action" value="doremove" />
+ <p class="submit"><input type="submit" name="submit" value="<?php _e('Confirm Removal'); ?>" /></p>
+<?php else : ?>
+ <p><?php _e('There are no valid users selected for removal.'); ?></p>
+<?php endif; ?>
+</div>
+</form>
+<?php
+
+break;
+
case 'adduser':
die( "This function is disabled. Add a user from your community." );
- check_admin_referer();
+ check_admin_referer('add-user');
- $errors = add_user();
+ if ( ! current_user_can('create_users') )
+ die(__('You can&#8217;t create users.'));
- if(count($errors) == 0) {
+ $user_id = add_user();
+ if ( is_wp_error( $user_id ) )
+ $errors = $user_id;
+ else {
header('Location: users.php?update=add');
die();
}
@@ -146,56 +225,36 @@ case 'addexistinguser':
if ( !current_user_can('edit_users') )
die(__('You can&#8217;t edit users.'));
- $new_user_login = wp_specialchars(trim($_POST['newuser']));
+ $new_user_email = wp_specialchars(trim($_POST['newuser']));
/* checking that username has been typed */
- if ($new_user_login != '' && $new_user_login != 'admin' ) {
- if ( username_exists( $new_user_login ) ) {
- $user_ID = $wpdb->get_var( "SELECT ID FROM $wpdb->users WHERE user_login = '$new_user_login'" );
- $primary_blog = get_usermeta( $user_ID, "primary_blog" );
- if( $primary_blog ) {
- $details = get_blog_details( $primary_blog );
- if( is_object( $details ) ) {
- if( $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) {
- header( "Location: users.php?update=notactive" );
- die();
- }
- }
- }
- if( $wpdb->get_var( "SELECT user_id FROM {$wpdb->usermeta} WHERE user_id = '{$user_ID}' AND meta_key = '{$wpdb->prefix}capabilities'" ) == false ) {
- $user = new WP_User($user_ID);
- $user->set_role( $_POST[ 'new_role' ] );
- do_action( "added_existing_user", $user_ID );
- header('Location: users.php?update=add');
- die();
+ if ( !empty($new_user_email) ) {
+ if ( $user_id = email_exists( $new_user_email ) ) {
+ if ( array_key_exists($blog_id, get_blogs_of_user($user_id)) ) {
+ $location = 'users.php?update=add_existing';
+ } else {
+ add_user_to_blog('', $user_id, $_POST[ 'new_role' ]);
+ do_action( "added_existing_user", $user_id );
+ $location = 'users.php?update=add';
}
+ header("Location: $location");
+ die();
}
}
header('Location: users.php');
die();
break;
default:
- if( is_array( $_POST[ 'new_roles' ] ) ) {
- check_admin_referer();
-
- if ( !current_user_can('edit_users') )
- die(__('You can&#8217;t edit users.'));
+ wp_enqueue_script( 'admin-users' );
- while( list( $key, $val ) = each( $_POST[ 'new_roles' ] ) ) {
- if( $val == 'inactive' ) {
- $wpdb->query( "DELETE FROM " . $wpdb->usermeta . " WHERE meta_key = '" . $wpmuBaseTablePrefix . $wpdb->blogid . "_capabilities' AND user_id = '" . $key . "'" );
- } else {
- $user = new WP_User($key);
- $user->set_role( $val );
- }
- }
- header('Location: users.php?update=promote');
- die();
- }
-
include ('admin-header.php');
-
- $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users, $wpdb->usermeta WHERE $wpdb->users.ID = $wpdb->usermeta.user_id AND meta_key = '".$wpdb->prefix."capabilities'");
-
+
+ if ( !current_user_can('edit_users') )
+ die(__('You can&#8217;t edit users.'));
+ $userids = array();
+ $users = get_users_of_blog();
+ foreach ( $users as $user )
+ $userids[] = $user->user_id;
+
foreach($userids as $userid) {
$tmp_user = new WP_User($userid);
$roles = $tmp_user->roles;
@@ -213,6 +272,11 @@ default:
<div id="message" class="updated fade"><p><?php _e('User deleted.'); ?></p></div>
<?php
break;
+ case 'remove':
+ ?>
+ <div id="message" class="updated fade"><p><?php _e('User removed from this blog.'); ?></p></div>
+ <?php
+ break;
case 'add':
?>
<div id="message" class="updated fade"><p><?php _e('New user created.'); ?></p></div>
@@ -235,18 +299,30 @@ default:
<div id="message" class="updated fade"><p><?php _e('Other users have been deleted.'); ?></p></div>
<?php
break;
+ case 'err_admin_remove':
+ ?>
+ <div id="message" class="error"><p><?php _e("You can't remove the current user."); ?></p></div>
+ <div id="message" class="updated fade"><p><?php _e('Other users have been removed.'); ?></p></div>
+ <?php
+ break;
case 'notactive':
?>
<div id="message" class="updated fade"><p><?php _e('User not added. User is deleted or not active.'); ?></p></div>
<?php
break;
+ case 'add_existing':
+ ?>
+ <div id="message" class="updated fade"><p><?php _e('User not added. User is already registered.'); ?></p></div>
+ <?php
+ break;
}
endif;
- if ( isset($errors) ) : ?>
+ if ( is_wp_error( $errors ) ) : ?>
<div class="error">
<ul>
<?php
- foreach($errors as $error) echo "<li>$error</li>";
+ foreach ( $errors->get_error_messages() as $message )
+ echo "<li>$message</li>";
?>
</ul>
</div>
@@ -255,87 +331,52 @@ default:
?>
<form action="" method="post" name="updateusers" id="updateusers">
+<?php wp_nonce_field('bulk-users') ?>
<div class="wrap">
<h2><?php _e('User List by Role'); ?></h2>
- <table cellpadding="3" cellspacing="3" width="100%">
- <?php
- foreach($roleclasses as $role => $roleclass) {
- ksort($roleclass);
- ?>
-
- <tr>
- <th colspan="8" align="left">
- <h3><?php echo $wp_roles->role_names[$role]; ?></h3>
- </th></tr>
+<table class="widefat">
+<?php
+foreach($roleclasses as $role => $roleclass) {
+ ksort($roleclass);
+?>
- <tr>
- <th><?php _e('ID') ?></th>
- <th><?php _e('Username') ?></th>
- <th><?php _e('Name') ?></th>
- <th><?php _e('E-mail') ?></th>
- <th><?php _e('Role') ?></th>
+<tr>
+ <th colspan="8" align="left"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>
+</tr>
+<thead>
+<tr>
+ <th style="text-align: left"><?php _e('ID') ?></th>
+ <th style="text-align: left"><?php _e('Username') ?></th>
+ <th style="text-align: left"><?php _e('Name') ?></th>
+ <th style="text-align: left"><?php _e('E-mail') ?></th>
+ <th style="text-align: left"><?php _e('Website') ?></th>
<th><?php _e('Posts') ?></th>
<th>&nbsp;</th>
- </tr>
- <?php
- $style = '';
- foreach ($roleclass as $user_object) {
- if( $user_object->ID != get_site_option( "admin_user_id" ) ) {
- $email = $user_object->user_email;
- $url = $user_object->user_url;
- $short_url = str_replace('http://', '', $url);
- $short_url = str_replace('www.', '', $short_url);
- if ('/' == substr($short_url, -1))
- $short_url = substr($short_url, 0, -1);
- if (strlen($short_url) > 35)
- $short_url = substr($short_url, 0, 32).'...';
- $style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
- $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$user_object->ID' and post_status = 'publish'");
- if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_object->ID' title='" . __('View posts') . "'>$numposts</a>";
- $do_not_edit = ( !is_site_admin() && $user_object->ID == $current_user->ID );
- $disabled = $do_not_edit ? "disabled='disabled' " : '';
- echo "
- <tr $style>
- <td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' {$disabled}/> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td>
- <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td>
- <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td>
- <td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td>";
- if ( $do_not_edit ) {
- echo "<td><b>{$wp_roles->role_names[$role]}</b></td>";
- } else {
- echo "<td><select name='new_roles[{$user_object->ID}]' id='new_role'>";
- foreach($wp_roles->role_names as $roleid => $name) {
- $selected = '';
- if( $role == $roleid)
- $selected = 'selected="selected"';
- echo "<option {$selected} value=\"{$roleid}\">{$name}</option>";
- }
- echo "</select></td>";
- }
- echo "<td align='right'>$numposts</td><td>";
- if (is_site_admin())
- echo "<a href='user-edit.php?user_id=$user_object->ID' class='edit'>".__('Edit')."</a>";
- echo '</td></tr>';
- } else {
- echo "<tr class='alternate'><td><label for='user_{$user_object->ID}'>{$user_object->ID}</label></td><td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td><td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td><td colspan='4'><strong>Cannot Edit Site Administrator</strong></td></tr>";
- }
- }
- }
-?>
- </table>
+</tr>
+</thead>
+<tbody id="role-<?php echo $role; ?>"><?php
+$style = '';
+foreach ($roleclass as $user_object) {
+ $style = (' class="alternate"' == $style) ? '' : ' class="alternate"';
+ echo "\n\t" . user_row( $user_object, $style );
+}
+?>
- <h2><?php _e('Update Users'); ?></h2>
+</tbody>
<?php
-$role_select = '<select name="new_role">';
-foreach($wp_roles->role_names as $role => $name) {
- $role_select .= "<option value=\"{$role}\">{$name}</option>";
}
-$role_select .= '</select>';
-?>
+?>
+</table>
+
+
+ <h2><?php _e('Update Users'); ?></h2>
<ul style="list-style:none;">
- <li><input type="radio" name="action" id="action0" value="delete" /> <label for="action0"><?php _e('Delete checked users.'); ?></label></li>
- <li><input type="radio" name="action" id="action1" value="promote" /> <?php echo '<label for="action1">'.__('Set the Role of checked users to:')."</label> $role_select"; ?></li>
+ <li><input type="radio" name="action" id="action0" value="removeuser" /> <label for="action0"><?php _e('Remove checked users from blog.'); ?></label></li>
+ <li>
+ <input type="radio" name="action" id="action1" value="promote" /> <label for="action1"><?php _e('Set the Role of checked users to:'); ?></label>
+ <select name="new_role"><?php wp_dropdown_roles(); ?></select>
+ </li>
</ul>
<p class="submit"><input type="submit" value="<?php _e('Update &raquo;'); ?>" /></p>
</div>
@@ -344,10 +385,11 @@ $role_select .= '</select>';
<div class="wrap">
<h2><?php _e('Add User From Community') ?></h2>
<form action="" method="post" name="adduser" id="adduser">
+ <?php wp_nonce_field('add-user') ?>
<input type='hidden' name='action' value='addexistinguser'>
-<p>Type the username of another user to add them to your blog.</p>
+<p>Type the e-mail address of another user to add them to your blog.</p>
<table>
-<tr><th scope="row">User&nbsp;Login: </th><td><input type="text" name="newuser" id="newuser"></td></tr>
+<tr><th scope="row">User&nbsp;E-Mail: </th><td><input type="text" name="newuser" id="newuser"></td></tr>
<tr>
<th scope="row"><?php _e('Role:') ?></th>
<td><select name="new_role" id="new_role"><?php
@@ -365,9 +407,10 @@ $role_select .= '</select>';
</td>
</table>
<p class="submit">
- <input name="adduser" type="submit" id="adduser" value="<?php _e('Add User &raquo;') ?>" />
+ <input name="adduser" type="submit" id="addusersub" value="<?php _e('Add User &raquo;') ?>" />
</p>
</form>
+<div id="ajax-response"></div>
</div>
<?php
diff --git a/wp-inst/wp-admin/wp-admin.css b/wp-inst/wp-admin/wp-admin.css
index 7b27c63..b73b73e 100644
--- a/wp-inst/wp-admin/wp-admin.css
+++ b/wp-inst/wp-admin/wp-admin.css
@@ -361,7 +361,7 @@ form#upload #post_content {
display: none;
}
-.updated {
+.updated, .confirm {
background: #CFEBF7 url(images/notice.gif) no-repeat 1em ;
border: 1px solid #2580B2;
margin: 1em 5% 10px;
diff --git a/wp-inst/wp-admin/wpmu-blogs.php b/wp-inst/wp-admin/wpmu-blogs.php
index 238e1a6..daf7a9e 100644
--- a/wp-inst/wp-admin/wpmu-blogs.php
+++ b/wp-inst/wp-admin/wpmu-blogs.php
@@ -25,10 +25,12 @@ switch( $_GET[ 'action' ] ) {
$details = $wpdb->get_row( $query, ARRAY_A );
print "<h2>Edit Blog</h2>";
+ print "<a href='http://{$details[ 'domain' ]}/'>{$details[ 'domain' ]}</a>";
?>
<form name="form1" method="post" action="wpmu-edit.php?action=updateblog">
<input type="hidden" name="id" value="<?php echo $_GET[ 'id' ] ?>" />
<table><td valign='top'>
+ <div class="wrap">
<table width="100%" border='0' cellspacing="2" cellpadding="5" class="editform">
<tr valign="top">
<th scope="row">URL</th>
@@ -70,6 +72,12 @@ switch( $_GET[ 'action' ] ) {
<input type='radio' name='blog[spam]' value='0' <?php if( $details[ 'spam' ] == '0' ) echo " checked"?>> No &nbsp;&nbsp;
</td>
</tr>
+ <tr valign="top">
+ <th scope="row">Deleted</th>
+ <td><input type='radio' name='blog[deleted]' value='1' <?php if( $details[ 'deleted' ] == '1' ) echo " checked"?>> Yes&nbsp;&nbsp;
+ <input type='radio' name='blog[deleted]' value='0' <?php if( $details[ 'deleted' ] == '0' ) echo " checked"?>> No &nbsp;&nbsp;
+ </td>
+ </tr>
<tr><td colspan='2'>
<br />
<br />
@@ -108,7 +116,7 @@ switch( $_GET[ 'action' ] ) {
?>
<tr valign="top">
<th scope="row"><?php echo ucwords( str_replace( "_", " ", $val[ 'option_name' ] ) ) ?></th>
- <td><input name="option[<?php echo $val[ 'option_name' ] ?>]" type="text" id="<?php echo $val[ 'option_name' ] ?>" value="<?php echo $val[ 'option_value' ] ?>" size="40" /></td>
+ <td><input name="option[<?php echo $val[ 'option_name' ] ?>]" type="text" id="<?php echo $val[ 'option_name' ] ?>" value="<?php echo stripslashes( $val[ 'option_value' ] ) ?>" size="40" /></td>
</tr>
<?php
}
@@ -118,6 +126,7 @@ switch( $_GET[ 'action' ] ) {
<p class="submit">
<input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
</p>
+ </div>
</td>
<td valign='top'>
<?php
@@ -149,14 +158,14 @@ switch( $_GET[ 'action' ] ) {
}
}
if( $out != '' ) {
- print "<h3>Blog Themes</h3>";
+ print "<div class='wrap'><h3>Blog Themes</h3>";
print '<table width="100%" border="0" cellspacing="2" cellpadding="5" class="editform">';
print '<tr><th>Theme</th><th>Enable</th></tr>';
print $out;
- print "</table>";
+ print "</table></div>";
}
$blogusers = get_users_of_blog( $_GET[ 'id' ] );
- print "<h3>Blog Users</h3>";
+ print "<div class='wrap'><h3>Blog Users</h3>";
if( is_array( $blogusers ) ) {
print "<table width='100%'><caption>Current Users</caption>";
print "<tr><th>User</th><th>Role</th><th>Remove</th><th></th></tr>";
@@ -205,7 +214,10 @@ switch( $_GET[ 'action' ] ) {
?></select></td>
</tr>
</table>
-<br />
+</div>
+<div class='wrap'><strong>Misc Blog Actions</strong>
+<p><?php do_action( "wpmueditblogaction", $_GET[ 'id' ] ); ?></p>
+</div>
<p class="submit">
<input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
</p>
@@ -232,15 +244,21 @@ switch( $_GET[ 'action' ] ) {
WHERE site_id = '".$wpdb->siteid."' ";
if( $_GET[ 's' ] != '' ) {
$query = "SELECT blog_id, {$wpdb->blogs}.domain, registered, last_updated
- FROM ".$wpdb->blogs.", ".$wpdb->site."
- WHERE site_id = '".$wpdb->siteid."'
- AND ".$wpdb->blogs.".site_id = ".$wpdb->site.".id
- AND {$wpdb->blogs}.domain like '%".$_GET[ 's' ]."%'";
+ FROM $wpdb->blogs, $wpdb->site
+ WHERE site_id = '$wpdb->siteid'
+ AND {$wpdb->blogs}.site_id = {$wpdb->site}.id
+ AND {$wpdb->blogs}.domain like '%". $_GET[ 's' ]."%'";
} elseif( $_GET[ 'blog_id' ] != '' ) {
$query = "SELECT *
- FROM ".$wpdb->blogs."
- WHERE site_id = '".$wpdb->siteid."'
- AND blog_id = '".$_GET[ 'blog_id' ]."'";
+ FROM $wpdb->blogs
+ WHERE site_id = '$wpdb->siteid'
+ AND blog_id = '".intval($_GET[ 'blog_id' ])."'";
+ } elseif( $_GET[ 'ip_address' ] != '' ) {
+ $query = "SELECT *
+ FROM $wpdb->blogs, wp_registration_log
+ WHERE site_id = '$wpdb->siteid'
+ AND {$wpdb->blogs}.blog_id = wp_registration_log.blog_id
+ AND wp_registration_log.IP LIKE ('%".$_GET[ 'ip_address' ]."%')";
}
if( isset( $_GET[ 'sortby' ] ) == false ) {
$_GET[ 'sortby' ] = 'ID';
@@ -260,7 +278,8 @@ switch( $_GET[ 'action' ] ) {
$query .= "ASC";
}
- $query .= " LIMIT " . intval( $start ) . ", " . intval( $num );
+ if ( $_GET[ 'ip_address' ] == '' )
+ $query .= " LIMIT " . intval( $start ) . ", " . intval( $num );
$blog_list = $wpdb->get_results( $query, ARRAY_A );
if( count( $blog_list ) < $num ) {
$next = false;
@@ -298,6 +317,7 @@ function check_all_rows() {
<input type='hidden' name='action' value='blogs'>
Name:&nbsp;<input type="text" name="s" value="<?php if (isset($_GET[ 's' ])) echo wp_specialchars($_GET[ 's' ], 1); ?>" size="17" /><br />
Blog&nbsp;ID:&nbsp;<input type="text" name="blog_id" value="<?php if (isset($_GET[ 'blog_id' ])) echo wp_specialchars($_GET[ 'blog_id' ], 1); ?>" size="10" /><br />
+ IP Address: <input type="text" name="ip_address" value="<?php if (isset($_GET[ 'ip_address' ])) echo wp_specialchars($_GET[ 'ip_address' ], 1); ?>" size="10" /><br />
<input type="submit" name="submit" value="<?php _e('Search') ?>" />
</fieldset>
<?php
@@ -310,7 +330,7 @@ function check_all_rows() {
<legend><?php _e('Blog Navigation') ?></legend>
<?php
- $url2 = "order=" . $_GET[ 'order' ] . "&sortby=" . $_GET[ 'sortby' ] . "&s=" . $_GET[ 's' ];
+ $url2 = "order=" . $_GET[ 'order' ] . "&sortby=" . $_GET[ 'sortby' ] . "&s=" . $_GET[ 's' ] . "&ip_address=" . $_GET[ 'ip_address' ];
if( $start == 0 ) {
echo 'Previous&nbsp;Blogs';
@@ -366,18 +386,18 @@ $posts_columns['control_delete'] = '';
</tr>
<?php
if ($blog_list) {
-$bgcolor = '';
-foreach ($blog_list as $blog) {
- $class = ('alternate' == $class) ? '' : 'alternate';
- if( is_archived( $blog[ 'blog_id' ] ) == '1' ) {
- ?>
- <tr style='background: #fee' class='<?php echo $class; ?>'>
- <?php
- } else {
- ?>
- <tr class='<?php echo $class; ?>'>
- <?php
- }
+ $bgcolor = '';
+ $status_list = array( "archived" => "#fee", "spam" => "#faa", "deleted" => "#f55" );
+ foreach ($blog_list as $blog) {
+ $class = ('alternate' == $class) ? '' : 'alternate';
+ reset( $status_list );
+ $bgcolour = "";
+ while( list( $status, $col ) = each( $status_list ) ) {
+ if( get_blog_status( $blog[ 'blog_id' ], $status ) == 1 ) {
+ $bgcolour = "style='background: $col'";
+ }
+ }
+ print "<tr $bgcolour class='$class'>";
foreach($posts_columns as $column_name=>$column_display_name) {
@@ -410,7 +430,7 @@ foreach($posts_columns as $column_name=>$column_display_name) {
case 'users':
?>
- <td valign='top'><?php $blogusers = get_users_of_blog( $blog[ 'blog_id' ] ); if( is_array( $blogusers ) ) while( list( $key, $val ) = each( $blogusers ) ) { print '<a href="user-edit.php?user_id=' . $val->user_id . '">' . $val->user_login . '</a><BR>'; } ?></td>
+ <td valign='top'><?php $blogusers = get_users_of_blog( $blog[ 'blog_id' ] ); if( is_array( $blogusers ) ) while( list( $key, $val ) = each( $blogusers ) ) { print '<a href="user-edit.php?user_id=' . $val->user_id . '">' . $val->user_login . '</a> ('.$val->user_email.')<BR>'; } ?></td>
<?php
break;
diff --git a/wp-inst/wp-admin/wpmu-edit.php b/wp-inst/wp-admin/wpmu-edit.php
index 99e1138..97c8f40 100644
--- a/wp-inst/wp-admin/wpmu-edit.php
+++ b/wp-inst/wp-admin/wpmu-edit.php
@@ -3,27 +3,6 @@ require_once('admin.php');
do_action( "wpmuadminedit", "" );
-function wpmu_delete_blog( $id ) {
- global $wpdb, $wpmuBaseTablePrefix;
- do_action( "delete_blog", $id );
- $drop_tables = array( $wpmuBaseTablePrefix . $id . "_categories",
- $wpmuBaseTablePrefix . $id . "_comments",
- $wpmuBaseTablePrefix . $id . "_linkcategories",
- $wpmuBaseTablePrefix . $id . "_links",
- $wpmuBaseTablePrefix . $id . "_options",
- $wpmuBaseTablePrefix . $id . "_post2cat",
- $wpmuBaseTablePrefix . $id . "_postmeta",
- $wpmuBaseTablePrefix . $id . "_posts",
- $wpmuBaseTablePrefix . $id . "_referer_visitLog",
- $wpmuBaseTablePrefix . $id . "_referer_blacklist" );
- reset( $drop_tables );
- while( list( $key, $val ) = each( $drop_tables ) )
- {
- $wpdb->query( "DROP TABLE IF EXISTS $val" );
- }
- $wpdb->query( "DELETE FROM ".$wpdb->blogs." WHERE blog_id = '".$id."'" );
-}
-
$_POST[ 'id' ] = intval( $_POST[ 'id' ] );
$_GET[ 'id' ] = intval( $_GET[ 'id' ] );
$id = $_POST[ 'id' ];
@@ -108,21 +87,12 @@ switch( $_GET[ 'action' ] ) {
if( is_array( $_POST[ 'theme' ] ) ) {
$allowed_themes = $_POST[ 'theme' ];
$_POST[ 'option' ][ 'allowed_themes' ] = $_POST[ 'theme' ];
+ } else {
+ $_POST[ 'option' ][ 'allowed_themes' ] = '';
}
if( is_array( $_POST[ 'option' ] ) ) {
while( list( $key, $val ) = each( $_POST[ 'option' ] ) ) {
- if ( is_array($val) || is_object($val) )
- $val = serialize($val);
-
- $query = "SELECT option_id, option_value FROM ".$options_table_name." WHERE option_name = '".$key."'";
- $opts = $wpdb->get_row( $query, ARRAY_A );
- $optvalue = $opts[ 'option_value' ];
- $option_id = $opts[ 'option_id' ];
- if( $opts == false ) {
- add_blog_option( $id, $key, $val );
- } elseif( $optvalue != $val ) {
- update_blog_option( $id, $key, $val );
- }
+ update_blog_option( $id, $key, $val );
}
}
// update blogs table
@@ -133,9 +103,11 @@ switch( $_GET[ 'action' ] ) {
public = '".$_POST[ 'blog' ][ 'public' ]."',
archived = '".$_POST[ 'blog' ][ 'archived' ]."',
mature = '".$_POST[ 'blog' ][ 'mature' ]."',
+ deleted = '".$_POST[ 'blog' ][ 'deleted' ]."',
spam = '".$_POST[ 'blog' ][ 'spam' ]."'
WHERE blog_id = '$id'";
$result = $wpdb->query( $query );
+ update_blog_status( $id, 'spam', $_POST[ 'blog' ][ 'spam' ] );
// user roles
if( is_array( $_POST[ 'role' ] ) == true ) {
$newroles = $_POST[ 'role' ];
@@ -179,7 +151,7 @@ switch( $_GET[ 'action' ] ) {
}
$id = $_GET[ 'id' ];
if( $id != '0' && $id != '1' )
- wpmu_delete_blog( $id );
+ wpmu_delete_blog( $id, true );
wpmu_admin_do_redirect( "wpmu-blogs.php" );
break;
case "allblogs":
@@ -190,7 +162,7 @@ switch( $_GET[ 'action' ] ) {
while( list( $key, $val ) = each( $_POST[ 'allblogs' ] ) ) {
if( $val != '0' && $val != '1' ) {
if( $_POST[ 'blogfunction' ] == 'delete' ) {
- wpmu_delete_blog( $val );
+ wpmu_delete_blog( $val, true );
} elseif( $_POST[ 'blogfunction' ] == 'spam' ) {
update_blog_status( $val, "spam", '1' );
}
@@ -234,6 +206,16 @@ switch( $_GET[ 'action' ] ) {
update_blog_status( $_GET[ 'id' ], "spam", '1' );
header( "Location: wpmu-blogs.php?updated=true" );
break;
+ case "mature":
+ update_blog_status( $_GET[ 'id' ], 'mature', '1' );
+ do_action( 'mature_blog', $_GET[ 'id' ] );
+ header( "Location: wpmu-blogs.php?updated=true" );
+ break;
+ case "unmature":
+ update_blog_status( $_GET[ 'id' ], 'mature', '0' );
+ do_action( 'unmature_blog', $_GET[ 'id' ] );
+ header( "Location: wpmu-blogs.php?updated=true" );
+ break;
case "updateuser":
if( is_site_admin() == false ) {
die( __('<p>You do not have permission to access this page.</p>') );
diff --git a/wp-inst/wp-admin/wpmu-users.php b/wp-inst/wp-admin/wpmu-users.php
index 7e3a1ff..fdcf55e 100644
--- a/wp-inst/wp-admin/wpmu-users.php
+++ b/wp-inst/wp-admin/wpmu-users.php
@@ -4,10 +4,8 @@ require_once('admin.php');
switch( $_GET[ 'action' ] ) {
case "delete":
$id = intval( $_GET[ 'id' ] );
- if( $id != '0' && $id != '1' ) {
- $wpdb->query( "DELETE FROM " . $wpdb->usermeta . " WHERE user_id = '" . $id . "'" );
- $wpdb->query( "DELETE FROM " . $wpdb->users . " WHERE ID = '" . $id . "'" );
- }
+ if( $id != '0' && $id != '1' )
+ wpmu_delete_user($id);
wpmu_admin_do_redirect( "wpmu-users.php" );
die();
break;
@@ -86,8 +84,7 @@ switch( $_GET[ 'action' ] ) {
if( $val != '' && $val != '0' && $val != '1' ) {
$user_details = get_userdata( $val );
if( $_POST[ 'userfunction' ] == 'delete' ) {
- $wpdb->query( "DELETE FROM {$wpdb->users} WHERE ID = '$val'" );
- $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE user_id = '$val'" );
+ wpmu_delete_user($val);
} elseif( $_POST[ 'userfunction' ] == 'spam' ) {
$blogs = get_blogs_of_user( $val );
if( is_array( $blogs ) ) {
diff --git a/wp-inst/wp-comments-post.php b/wp-inst/wp-comments-post.php
index e2ccba6..2e561b2 100644
--- a/wp-inst/wp-comments-post.php
+++ b/wp-inst/wp-comments-post.php
@@ -24,11 +24,11 @@ $comment_author_url = trim($_POST['url']);
$comment_content = trim($_POST['comment']);
// If the user is logged in
-get_currentuserinfo();
-if ( $user_ID ) :
- $comment_author = $wpdb->escape($user_identity);
- $comment_author_email = $wpdb->escape($user_email);
- $comment_author_url = $wpdb->escape($user_url);
+$user = wp_get_current_user();
+if ( $user->ID ) :
+ $comment_author = $wpdb->escape($user->display_name);
+ $comment_author_email = $wpdb->escape($user->user_email);
+ $comment_author_url = $wpdb->escape($user->user_url);
else :
if ( get_option('comment_registration') )
die( __('Sorry, you must be logged in to post a comment.') );
@@ -36,7 +36,7 @@ endif;
$comment_type = '';
-if ( get_settings('require_name_email') && !$user_ID ) {
+if ( get_settings('require_name_email') && !$user->ID ) {
if ( 6 > strlen($comment_author_email) || '' == $comment_author )
die( __('Error: please fill the required fields (name, email).') );
elseif ( !is_email($comment_author_email))
@@ -48,12 +48,13 @@ if ( '' == $comment_content )
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID');
-wp_new_comment( $commentdata );
+$comment_id = wp_new_comment( $commentdata );
-if ( !$user_ID ) :
- setcookie('comment_author_' . COOKIEHASH, stripslashes($comment_author), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
- setcookie('comment_author_email_' . COOKIEHASH, stripslashes($comment_author_email), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
- setcookie('comment_author_url_' . COOKIEHASH, stripslashes(clean_url($comment_author_url)), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
+$comment = get_comment($comment_id);
+if ( !$user->ID ) :
+ setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
+ setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
+ setcookie('comment_author_url_' . COOKIEHASH, clean_url($comment->comment_author_url), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
endif;
$location = ( empty( $_POST['redirect_to'] ) ) ? get_permalink( $comment_post_ID ) : $_POST['redirect_to'];
diff --git a/wp-inst/wp-commentsrss2.php b/wp-inst/wp-commentsrss2.php
index e81cc20..e62e7dc 100644
--- a/wp-inst/wp-commentsrss2.php
+++ b/wp-inst/wp-commentsrss2.php
@@ -31,7 +31,7 @@ if (have_posts()) :
$comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
$wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
- LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id'
+ LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '" . get_the_ID() . "'
AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish'
AND post_date_gmt < '" . gmdate("Y-m-d H:i:59") . "'
ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss') );
@@ -46,6 +46,7 @@ if (have_posts()) :
// this line is WordPress' motor, do not delete it.
if ($comments) {
foreach ($comments as $comment) {
+ $GLOBALS['comment'] =& $comment;
// Some plugins may need to know the metadata
// associated with this comment's post:
get_post_custom($comment->comment_post_ID);
diff --git a/wp-inst/wp-content/blogs.php b/wp-inst/wp-content/blogs.php
index e5d382f..b2fd603 100644
--- a/wp-inst/wp-content/blogs.php
+++ b/wp-inst/wp-content/blogs.php
@@ -24,6 +24,7 @@ if( is_file( $file ) ) {
$mimetype = "image/$ext";
}
+ // from http://blog.rd2inc.com/archives/2005/03/24/making-dynamic-php-pages-cacheable/
if( $_SERVER[ 'HTTP_IF_NONE_MATCH' ] == '"' . $etag . '"' || $lastModified == $_SERVER['HTTP_IF_MODIFIED_SINCE']) {
// They already have an up to date copy so tell them
header('HTTP/1.1 304 Not Modified');
@@ -46,4 +47,4 @@ if( is_file( $file ) ) {
print "<h1>File Not Found!</h1>";
print "</body></html>";
}
-?> \ No newline at end of file
+?>
diff --git a/wp-inst/wp-content/mu-plugins/global-categories.php b/wp-inst/wp-content/mu-plugins/global-categories.php
index 49e01e9..d8c7c8c 100644
--- a/wp-inst/wp-content/mu-plugins/global-categories.php
+++ b/wp-inst/wp-content/mu-plugins/global-categories.php
@@ -1,34 +1,31 @@
<?php
function global_categories( $cat_ID ) {
- global $wpdb;
+ global $wpdb;
- $cat_ID = intval( $cat_ID );
- $details = $wpdb->get_row( "SELECT * FROM $wpdb->categories WHERE cat_ID = '$cat_ID'" );
- if( $details == false ) { // this should *not* happen ever!
- return $cat_ID;
- }
- $global_cat = $wpdb->get_row( "SELECT * FROM $wpdb->sitecategories WHERE cat_name = '{$details->cat_name}'" );
- if( $global_cat == false ) {
- $res = $wpdb->query( "INSERT INTO $wpdb->sitecategories ( cat_ID, cat_name, category_nicename ) VALUES ( NULL, '" . $wpdb->escape( $details->cat_name ) . "', '" . $wpdb->escape( $details->category_nicename ) . "' )" );
- $newcat_ID = $wpdb->insert_id;
- if( $newcat_ID != 0 ) { // bad things happen when cat_id == 0
- $wpdb->query( "UPDATE $wpdb->categories SET cat_ID = '$newcat_ID' WHERE cat_ID = '$cat_ID'" );
- $wpdb->query( "UPDATE $wpdb->post2cat SET category_id = '$newcat_ID' WHERE category_id = '$cat_ID'" );
- $cat_ID = $newcat_ID;
- if( get_option( "default_category" ) == $cat_ID )
- update_option( "default_category", $newcat_ID );
+ $cat_ID = intval( $cat_ID );
+ $c = $wpdb->get_row( "SELECT * FROM $wpdb->categories WHERE cat_ID = '$cat_ID'" );
+
+ $global_category = $wpdb->get_row( "SELECT * FROM $wpdb->sitecategories WHERE category_nicename = '" . $wpdb->escape( $c->category_nicename ) . "'" );
+
+ if ( $global_category ) {
+ $global_id = $global_category->cat_ID;
+ } else {
+ $wpdb->query( "INSERT INTO $wpdb->sitecategories ( cat_name, category_nicename ) VALUES ( '" . $wpdb->escape( $c->cat_name ) . "', '" . $wpdb->escape( $c->category_nicename ) . "' )" );
+ $global_id = $wpdb->insert_id;
}
- } elseif( $global_cat->cat_ID != $cat_ID ) {
- $wpdb->query( "UPDATE $wpdb->categories SET cat_ID = '{$global_cat->cat_ID}' WHERE cat_ID = '$cat_ID'" );
- $wpdb->query( "UPDATE $wpdb->post2cat SET category_id = '{$global_cat->cat_ID}' WHERE category_id = '$cat_ID'" );
- if( get_option( "default_category" ) == $cat_ID )
- update_option( "default_category", $global_cat->cat_ID );
- $cat_ID = $global_cat->cat_ID;
- }
+ $wpdb->query( "UPDATE $wpdb->categories SET cat_ID = '$global_id' WHERE cat_id = '$cat_ID'" );
+ $wpdb->query( "UPDATE $wpdb->categories SET category_parent = '$global_id' WHERE category_parent = '$cat_ID'" );
+ $wpdb->query( "UPDATE $wpdb->post2cat SET category_id = '$global_id' WHERE category_id = '$cat_ID'" );
+ $wpdb->query( "UPDATE $wpdb->link2cat SET category_id = '$global_id' WHERE category_id = '$cat_ID'" );
+ wp_cache_delete($cat_ID, 'category');
+ wp_cache_delete($global_id, 'category');
+ wp_cache_delete('all_category_ids', 'category');
- return $cat_ID;
+ do_action('update_cat_id', $global_id, $cat_ID);
+
+ return $global_id;
}
-add_action( 'edit_category', 'global_categories' );
-add_action( 'add_category', 'global_categories' );
+
+add_filter( 'cat_id_filter', 'global_categories' );
?>
diff --git a/wp-inst/wp-content/mu-plugins/misc.php b/wp-inst/wp-content/mu-plugins/misc.php
index 33d1415..0663dd7 100644
--- a/wp-inst/wp-content/mu-plugins/misc.php
+++ b/wp-inst/wp-content/mu-plugins/misc.php
@@ -50,18 +50,23 @@ function upload_is_user_over_quota( $ret ) {
add_filter( "pre_upload_error", "upload_is_user_over_quota" );
function upload_is_file_too_big( $ret ) {
- $type = strtolower( substr( $_FILES[ 'image' ][ 'name' ], 1+strrpos( $_FILES[ 'image' ][ 'name' ], '.' ) ) );
- $allowed_types = split( " ", get_site_option( "upload_filetypes" ) );
- if( in_array( $type, $allowed_types ) == false ) {
- $ret = "You cannot upload files of this type.<br />";
- } elseif( $_FILES[ 'image' ][ 'size' ] > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
+ if( $_FILES[ 'image' ][ 'size' ] > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
$ret = "This file is too big. Files must be less than " . get_site_option( 'fileupload_maxk', 1500 ) . "Kb in size.<br />";
- }
return $ret;
}
add_filter( "check_uploaded_file", "upload_is_file_too_big" );
+function check_upload_mimes($mimes) {
+ $site_exts = explode( " ", get_site_option( "upload_filetypes" ) );
+ foreach ( $site_exts as $ext )
+ foreach ( $mimes as $ext_pattern => $mime )
+ if ( preg_match("/$ext_pattern/", $ext) )
+ $site_mimes[$ext_pattern] = $mime;
+ return $site_mimes;
+}
+add_filter('upload_mimes', 'check_upload_mimes');
+
add_filter('the_title', 'wp_filter_kses');
function update_posts_count( $post_id ) {
global $wpdb;
@@ -78,17 +83,13 @@ function update_pages_last_updated( $post_id ) {
update_option( "pages_last_updated", time() );
}
add_action( "save_post", "update_pages_last_updated" );
+add_action( "comment_post", "update_pages_last_updated" );
+add_action( "publish_post", "update_pages_last_updated" );
+add_action('delete_post', 'update_pages_last_updated');
+add_action('delete_comment', 'update_pages_last_updated');
+add_action('private_to_published', 'update_pages_last_updated');
+add_action('trackback_post', 'update_pages_last_updated');
+add_action('wp_set_comment_status', 'update_pages_last_updated');
-function remove_unfiltered_html() {
- $role = get_role('administrator');
- if( $role->capabilities[ 'unfiltered_html' ] ) {
- $role->remove_cap('unfiltered_html');
- }
- $role = get_role('editor');
- if( $role->capabilities[ 'unfiltered_html' ] ) {
- $role->remove_cap('unfiltered_html');
- }
-}
-add_action( "init", "remove_unfiltered_html" );
?>
diff --git a/wp-inst/wp-content/mu-plugins/pluggable.php b/wp-inst/wp-content/mu-plugins/pluggable.php
index 7943a6c..d6429dc 100644
--- a/wp-inst/wp-content/mu-plugins/pluggable.php
+++ b/wp-inst/wp-content/mu-plugins/pluggable.php
@@ -63,14 +63,16 @@ function wp_login($username, $password, $already_md5 = false) {
}
function get_userdata( $user_id ) {
- global $wpdb, $cache_userdata;
+ global $wpdb, $cache_userdata, $wpmuBaseTablePrefix;
$user_id = (int) $user_id;
if ( $user_id == 0 )
return false;
$user = wp_cache_get($user_id, 'users');
- if( $user->user_level != '' ) {
+ $user_level = $wpmuBaseTablePrefix . $wpdb->blogid . '_user_level';
+ if( $user->$user_level != '' || $user->user_level != '' ) {
if( $user && is_site_admin( $user->user_login ) == true ) {
+ $user->$user_level = 10;
$user->user_level = 10;
$cap_key = $wpdb->prefix . 'capabilities';
$user->{$cap_key} = array( 'administrator' => '1' );
diff --git a/wp-inst/wp-content/themes/default/archives.php b/wp-inst/wp-content/themes/default/archives.php
index 2c30466..de6c07c 100644
--- a/wp-inst/wp-content/themes/default/archives.php
+++ b/wp-inst/wp-content/themes/default/archives.php
@@ -17,7 +17,7 @@ Template Name: Archives
<h2>Archives by Subject:</h2>
<ul>
- <?php wp_list_cats(); ?>
+ <?php wp_list_categories(); ?>
</ul>
</div>
diff --git a/wp-inst/wp-cron.php b/wp-inst/wp-cron.php
index 69a1e94..c0e9de7 100644
--- a/wp-inst/wp-cron.php
+++ b/wp-inst/wp-cron.php
@@ -12,13 +12,13 @@ if (!is_array($crons) || array_shift(array_keys($crons)) > time())
foreach ($crons as $timestamp => $cronhooks) {
if ($timestamp > time()) break;
foreach($cronhooks as $hook => $args) {
+ wp_unschedule_event($timestamp, $hook);
do_action($hook, $args['args']);
$schedule = $args['schedule'];
if($schedule != false) {
$args = array_merge( array($timestamp, $schedule, $hook), $args['args']);
call_user_func_array('wp_reschedule_event', $args);
}
- wp_unschedule_event($timestamp, $hook);
}
}
?>
diff --git a/wp-inst/wp-feed.php b/wp-inst/wp-feed.php
index 9305077..a27fa33 100644
--- a/wp-inst/wp-feed.php
+++ b/wp-inst/wp-feed.php
@@ -5,33 +5,6 @@ if (empty($doing_rss)) {
require(dirname(__FILE__) . '/wp-blog-header.php');
}
-// Remove the pad, if present.
-$feed = preg_replace('/^_+/', '', $feed);
-
-if ($feed == '' || $feed == 'feed') {
- $feed = 'rss2';
-}
-
-if ( is_single() || ($withcomments == 1) ) {
- require(ABSPATH . 'wp-commentsrss2.php');
-} else {
- switch ($feed) {
- case 'atom':
- require(ABSPATH . 'wp-atom.php');
- break;
- case 'rdf':
- require(ABSPATH . 'wp-rdf.php');
- break;
- case 'rss':
- require(ABSPATH . 'wp-rss.php');
- break;
- case 'rss2':
- require(ABSPATH . 'wp-rss2.php');
- break;
- case 'comments-rss2':
- require(ABSPATH . 'wp-commentsrss2.php');
- break;
- }
-}
+do_feed();
?>
diff --git a/wp-inst/wp-includes/template-functions-bookmarks.php b/wp-inst/wp-includes/bookmark-template.php
index e74b494..cf2508d 100644
--- a/wp-inst/wp-includes/template-functions-bookmarks.php
+++ b/wp-inst/wp-includes/bookmark-template.php
@@ -1,389 +1,283 @@
-<?php
-
-/** function wp_get_links()
- ** Gets the links associated with category n.
- ** Parameters:
- ** category (no default) - The category to use.
- ** or:
- ** a query string
- **/
-function wp_get_links($args = '') {
- global $wpdb;
-
- if ( empty($args) )
- return;
-
- if ( false === strpos($args, '=') ) {
- $cat_id = $args;
- $args = add_query_arg('category', $cat_id, $args);
- }
-
- parse_str($args);
-
- if (! isset($category)) $category = -1;
- if (! isset($before)) $before = '';
- if (! isset($after)) $after = '<br />';
- if (! isset($between)) $between = ' ';
- if (! isset($show_images)) $show_images = true;
- if (! isset($orderby)) $orderby = 'name';
- if (! isset($show_description)) $show_description = true;
- if (! isset($show_rating)) $show_rating = false;
- if (! isset($limit)) $limit = -1;
- if (! isset($show_updated)) $show_updated = 1;
- if (! isset($echo)) $echo = true;
-
- return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo);
-} // end wp_get_links
-
-/** function get_links()
- ** Gets the links associated with category n.
- ** Parameters:
- ** category (default -1) - The category to use. If no category supplied
- ** uses all
- ** before (default '') - the html to output before the link
- ** after (default '<br />') - the html to output after the link
- ** between (default ' ') - the html to output between the link/image
- ** and its description. Not used if no image or show_images == true
- ** show_images (default true) - whether to show images (if defined).
- ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
- ** 'url', 'description', or 'rating'. Or maybe owner. If you start the
- ** name with an underscore the order will be reversed.
- ** You can also specify 'rand' as the order which will return links in a
- ** random order.
- ** show_description (default true) - whether to show the description if
- ** show_images=false/not defined .
- ** show_rating (default false) - show rating stars/chars
- ** limit (default -1) - Limit to X entries. If not specified, all entries
- ** are shown.
- ** show_updated (default 0) - whether to show last updated timestamp
- ** echo (default true) - whether to echo the results, or return them instead
- */
-function get_links($category = -1,
- $before = '',
- $after = '<br />',
- $between = ' ',
- $show_images = true,
- $orderby = 'name',
- $show_description = true,
- $show_rating = false,
- $limit = -1,
- $show_updated = 1,
- $echo = true) {
-
- global $wpdb;
-
- $order = 'ASC';
- if (substr($orderby, 0, 1) == '_') {
- $order = 'DESC';
- $orderby = substr($orderby, 1);
- }
-
- if ($category == -1) { //get_bookmarks uses '' to signify all categories
- $category = '';
- }
-
- $results = get_bookmarks("category=$category&orderby=$orderby&order=$order&show_updated=$show_updated&limit=$limit");
-
- if (!$results) {
- return;
- }
-
-
- $output = '';
-
- foreach ($results as $row) {
- if (!isset($row->recently_updated)) $row->recently_updated = false;
- $output .= $before;
- if ($show_updated && $row->recently_updated) {
- $output .= get_settings('links_recently_updated_prepend');
- }
-
- $the_link = '#';
- if (!empty($row->link_url))
- $the_link = wp_specialchars($row->link_url);
-
- $rel = $row->link_rel;
- if ($rel != '') {
- $rel = ' rel="' . $rel . '"';
- }
-
- $desc = wp_specialchars($row->link_description, ENT_QUOTES);
- $name = wp_specialchars($row->link_name, ENT_QUOTES);
- $title = $desc;
-
- if ($show_updated) {
- if (substr($row->link_updated_f, 0, 2) != '00') {
- $title .= ' (Last updated ' . date(get_settings('links_updated_date_format'), $row->link_updated_f + (get_settings('gmt_offset') * 3600)) . ')';
- }
- }
-
- if ('' != $title) {
- $title = ' title="' . $title . '"';
- }
-
- $alt = ' alt="' . $name . '"';
-
- $target = $row->link_target;
- if ('' != $target) {
- $target = ' target="' . $target . '"';
- }
-
- $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';
-
- if (($row->link_image != null) && $show_images) {
- if (strstr($row->link_image, 'http'))
- $output .= "<img src=\"$row->link_image\" $alt $title />";
- else // If it's a relative path
- $output .= "<img src=\"" . get_settings('siteurl') . "$row->link_image\" $alt $title />";
- } else {
- $output .= $name;
- }
-
- $output .= '</a>';
-
- if ($show_updated && $row->recently_updated) {
- $output .= get_settings('links_recently_updated_append');
- }
-
- if ($show_description && ($desc != '')) {
- $output .= $between . $desc;
- }
- $output .= "$after\n";
- } // end while
-
- if ($echo) {
- echo $output;
- } else {
- return $output;
- }
-}
-
-function get_linkrating($link) {
- return apply_filters('link_rating', $link->link_rating);
-}
-
-/** function get_linkcatname()
- ** Gets the name of category n.
- ** Parameters: id (default 0) - The category to get. If no category supplied
- ** uses 0
- */
-function get_linkcatname($id = 0) {
- if ( empty($id) )
- return '';
-
- $cats = wp_get_link_cats($id);
-
- if ( empty($cats) || ! is_array($cats) )
- return '';
-
- $cat_id = $cats[0]; // Take the first cat.
-
- $cat = get_category($cat_id);
- return $cat->cat_name;
-}
-
-/** function links_popup_script()
- ** This function contributed by Fullo -- http://sprite.csr.unibo.it/fullo/
- ** Show the link to the links popup and the number of links
- ** Parameters:
- ** text (default Links) - the text of the link
- ** width (default 400) - the width of the popup window
- ** height (default 400) - the height of the popup window
- ** file (default linkspopup.php) - the page to open in the popup window
- ** count (default true) - the number of links in the db
- */
-function links_popup_script($text = 'Links', $width=400, $height=400,
- $file='links.all.php', $count = true) {
- if ($count == true) {
- $counts = $wpdb->get_var("SELECT count(*) FROM $wpdb->links");
- }
-
- $javascript = "<a href=\"#\" " .
- " onclick=\"javascript:window.open('$file?popup=1', '_blank', " .
- "'width=$width,height=$height,scrollbars=yes,status=no'); " .
- " return false\">";
- $javascript .= $text;
-
- if ($count == true) {
- $javascript .= " ($counts)";
- }
-
- $javascript .="</a>\n\n";
- echo $javascript;
-}
-
-
-/*
- * function get_links_list()
- *
- * added by Dougal
- *
- * Output a list of all links, listed by category, using the
- * settings in $wpdb->linkcategories and output it as a nested
- * HTML unordered list.
- *
- * Parameters:
- * order (default 'name') - Sort link categories by 'name' or 'id'
- * hide_if_empty (default true) - Supress listing empty link categories
- */
-function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
- $order = strtolower($order);
-
- // Handle link category sorting
- $direction = 'ASC';
- if (substr($order,0,1) == '_') {
- $direction = 'DESC';
- $order = substr($order,1);
- }
-
- if (!isset($direction)) $direction = '';
-
- $cats = get_categories("type=link&orderby=$order&order=$direction&hierarchical=0");
-
- // Display each category
- if ($cats) {
- foreach ($cats as $cat) {
- // Handle each category.
-
- // Display the category name
- echo ' <li id="linkcat-' . $cat->cat_ID . '"><h2>' . $cat->cat_name . "</h2>\n\t<ul>\n";
- // Call get_links() with all the appropriate params
- get_links($cat->cat_ID,
- '<li>',"</li>","\n", true, 'name', false);
-
- // Close the last category
- echo "\n\t</ul>\n</li>\n";
- }
- }
-}
-
-function wp_list_bookmarks($args = '') {
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => 0, 'category' => 0,
- 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'echo' =>1,
- 'categorize' => 1, 'title_li' => __('Bookmarks'));
- $r = array_merge($defaults, $r);
- extract($r);
-
- // TODO: The rest of it.
- // If $categorize, group links by category with the category name being the
- // title of each li, otherwise just list them with title_li as the li title.
- // If $categorize and $category or $category_name, list links for the given category
- // with the category name as the title li. If not $categorize, use title_li.
- // When using each category's name as a title li, use before and after args for specifying
- // any markup. We don't want to hardcode h2.
-}
-
-function get_bookmarks($args = '') {
- global $wpdb;
-
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '',
- 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'include' => '', 'exclude' => '');
- $r = array_merge($defaults, $r);
- extract($r);
-
- $inclusions = '';
- if ( !empty($include) ) {
- $exclude = ''; //ignore exclude, category, and category_name params if using include
- $category = '';
- $category_name = '';
- $inclinks = preg_split('/[\s,]+/',$include);
- if ( count($inclinks) ) {
- foreach ( $inclinks as $inclink ) {
- if (empty($inclusions))
- $inclusions = ' AND ( link_id = ' . intval($inclink) . ' ';
- else
- $inclusions .= ' OR link_id = ' . intval($inclink) . ' ';
- }
- }
- }
- if (!empty($inclusions))
- $inclusions .= ')';
-
- $exclusions = '';
- if ( !empty($exclude) ) {
- $exlinks = preg_split('/[\s,]+/',$exclude);
- if ( count($exlinks) ) {
- foreach ( $exlinks as $exlink ) {
- if (empty($exclusions))
- $exclusions = ' AND ( link_id <> ' . intval($exlink) . ' ';
- else
- $exclusions .= ' AND link_id <> ' . intval($exlink) . ' ';
- }
- }
- }
- if (!empty($exclusions))
- $exclusions .= ')';
-
- if ( ! empty($category_name) ) {
- if ( $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category_name' LIMIT 1") )
- $category = $cat_id;
- }
-
- $category_query = '';
- $join = '';
- if ( !empty($category) ) {
- $incategories = preg_split('/[\s,]+/',$category);
- if ( count($incategories) ) {
- foreach ( $incategories as $incat ) {
- if (empty($category_query))
- $category_query = ' AND ( category_id = ' . intval($incat) . ' ';
- else
- $category_query .= ' OR category_id = ' . intval($incat) . ' ';
- }
- }
- }
- if (!empty($category_query)) {
- $category_query .= ')';
- $join = " LEFT JOIN $wpdb->link2cat ON ($wpdb->links.link_id = $wpdb->link2cat.link_id) ";
- }
-
- if (get_settings('links_recently_updated_time')) {
- $recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL " . get_settings('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated ";
- } else {
- $recently_updated_test = '';
- }
-
- if ($show_updated) {
- $get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f ";
- }
-
- $orderby = strtolower($orderby);
- $length = '';
- switch ($orderby) {
- case 'length':
- $length = ", CHAR_LENGTH(link_name) AS length";
- break;
- case 'rand':
- $orderby = 'rand()';
- break;
- default:
- $orderby = "link_" . $orderby;
- }
-
- if ( 'link_id' == $orderby )
- $orderby = "$wpdb->links.link_id";
-
- $visible = '';
- if ( $hide_invisible )
- $visible = "AND link_visible = 'Y'";
-
- $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query";
- $query .= " $exclusions $inclusions";
- $query .= " ORDER BY $orderby $order";
- if ($limit != -1)
- $query .= " LIMIT $limit";
-
- $results = $wpdb->get_results($query);
- return apply_filters('get_bookmarks', $results, $r);
-}
+<?php
+
+/** function wp_get_links()
+ ** Gets the links associated with category n.
+ ** Parameters:
+ ** category (no default) - The category to use.
+ ** or:
+ ** a query string
+ **/
+function wp_get_links($args = '') {
+ global $wpdb;
+
+ if ( empty($args) )
+ return;
+
+ if ( false === strpos($args, '=') ) {
+ $cat_id = $args;
+ $args = add_query_arg('category', $cat_id, $args);
+ }
+
+ parse_str($args);
+
+ if (! isset($category)) $category = -1;
+ if (! isset($before)) $before = '';
+ if (! isset($after)) $after = '<br />';
+ if (! isset($between)) $between = ' ';
+ if (! isset($show_images)) $show_images = true;
+ if (! isset($orderby)) $orderby = 'name';
+ if (! isset($show_description)) $show_description = true;
+ if (! isset($show_rating)) $show_rating = false;
+ if (! isset($limit)) $limit = -1;
+ if (! isset($show_updated)) $show_updated = 1;
+ if (! isset($echo)) $echo = true;
+
+ return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo);
+} // end wp_get_links
+
+/** function get_links()
+ ** Gets the links associated with category n.
+ ** Parameters:
+ ** category (default -1) - The category to use. If no category supplied
+ ** uses all
+ ** before (default '') - the html to output before the link
+ ** after (default '<br />') - the html to output after the link
+ ** between (default ' ') - the html to output between the link/image
+ ** and its description. Not used if no image or show_images == true
+ ** show_images (default true) - whether to show images (if defined).
+ ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
+ ** 'url', 'description', or 'rating'. Or maybe owner. If you start the
+ ** name with an underscore the order will be reversed.
+ ** You can also specify 'rand' as the order which will return links in a
+ ** random order.
+ ** show_description (default true) - whether to show the description if
+ ** show_images=false/not defined .
+ ** show_rating (default false) - show rating stars/chars
+ ** limit (default -1) - Limit to X entries. If not specified, all entries
+ ** are shown.
+ ** show_updated (default 0) - whether to show last updated timestamp
+ ** echo (default true) - whether to echo the results, or return them instead
+ */
+function get_links($category = -1,
+ $before = '',
+ $after = '<br />',
+ $between = ' ',
+ $show_images = true,
+ $orderby = 'name',
+ $show_description = true,
+ $show_rating = false,
+ $limit = -1,
+ $show_updated = 1,
+ $echo = true) {
+
+ global $wpdb;
+
+ $order = 'ASC';
+ if (substr($orderby, 0, 1) == '_') {
+ $order = 'DESC';
+ $orderby = substr($orderby, 1);
+ }
+
+ if ($category == -1) { //get_bookmarks uses '' to signify all categories
+ $category = '';
+ }
+
+ $results = get_bookmarks("category=$category&orderby=$orderby&order=$order&show_updated=$show_updated&limit=$limit");
+
+ if (!$results) {
+ return;
+ }
+
+
+ $output = '';
+
+ foreach ($results as $row) {
+ if (!isset($row->recently_updated)) $row->recently_updated = false;
+ $output .= $before;
+ if ($show_updated && $row->recently_updated) {
+ $output .= get_settings('links_recently_updated_prepend');
+ }
+
+ $the_link = '#';
+ if (!empty($row->link_url))
+ $the_link = wp_specialchars($row->link_url);
+
+ $rel = $row->link_rel;
+ if ($rel != '') {
+ $rel = ' rel="' . $rel . '"';
+ }
+
+ $desc = wp_specialchars($row->link_description, ENT_QUOTES);
+ $name = wp_specialchars($row->link_name, ENT_QUOTES);
+ $title = $desc;
+
+ if ($show_updated) {
+ if (substr($row->link_updated_f, 0, 2) != '00') {
+ $title .= ' (Last updated ' . date(get_settings('links_updated_date_format'), $row->link_updated_f + (get_settings('gmt_offset') * 3600)) . ')';
+ }
+ }
+
+ if ('' != $title) {
+ $title = ' title="' . $title . '"';
+ }
+
+ $alt = ' alt="' . $name . '"';
+
+ $target = $row->link_target;
+ if ('' != $target) {
+ $target = ' target="' . $target . '"';
+ }
+
+ $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';
+
+ if (($row->link_image != null) && $show_images) {
+ if (strstr($row->link_image, 'http'))
+ $output .= "<img src=\"$row->link_image\" $alt $title />";
+ else // If it's a relative path
+ $output .= "<img src=\"" . get_settings('siteurl') . "$row->link_image\" $alt $title />";
+ } else {
+ $output .= $name;
+ }
+
+ $output .= '</a>';
+
+ if ($show_updated && $row->recently_updated) {
+ $output .= get_settings('links_recently_updated_append');
+ }
+
+ if ($show_description && ($desc != '')) {
+ $output .= $between . $desc;
+ }
+ $output .= "$after\n";
+ } // end while
+
+ if ($echo) {
+ echo $output;
+ } else {
+ return $output;
+ }
+}
+
+function get_linkrating($link) {
+ return apply_filters('link_rating', $link->link_rating);
+}
+
+/** function get_linkcatname()
+ ** Gets the name of category n.
+ ** Parameters: id (default 0) - The category to get. If no category supplied
+ ** uses 0
+ */
+function get_linkcatname($id = 0) {
+ $id = (int) $id;
+
+ if ( empty($id) )
+ return '';
+
+ $cats = wp_get_link_cats($id);
+
+ if ( empty($cats) || ! is_array($cats) )
+ return '';
+
+ $cat_id = $cats[0]; // Take the first cat.
+
+ $cat = get_category($cat_id);
+ return $cat->cat_name;
+}
+
+/** function links_popup_script()
+ ** This function contributed by Fullo -- http://sprite.csr.unibo.it/fullo/
+ ** Show the link to the links popup and the number of links
+ ** Parameters:
+ ** text (default Links) - the text of the link
+ ** width (default 400) - the width of the popup window
+ ** height (default 400) - the height of the popup window
+ ** file (default linkspopup.php) - the page to open in the popup window
+ ** count (default true) - the number of links in the db
+ */
+function links_popup_script($text = 'Links', $width=400, $height=400,
+ $file='links.all.php', $count = true) {
+ if ($count == true) {
+ $counts = $wpdb->get_var("SELECT count(*) FROM $wpdb->links");
+ }
+
+ $javascript = "<a href=\"#\" " .
+ " onclick=\"javascript:window.open('$file?popup=1', '_blank', " .
+ "'width=$width,height=$height,scrollbars=yes,status=no'); " .
+ " return false\">";
+ $javascript .= $text;
+
+ if ($count == true) {
+ $javascript .= " ($counts)";
+ }
+
+ $javascript .="</a>\n\n";
+ echo $javascript;
+}
+
+
+/*
+ * function get_links_list()
+ *
+ * added by Dougal
+ *
+ * Output a list of all links, listed by category, using the
+ * settings in $wpdb->linkcategories and output it as a nested
+ * HTML unordered list.
+ *
+ * Parameters:
+ * order (default 'name') - Sort link categories by 'name' or 'id'
+ * hide_if_empty (default true) - Supress listing empty link categories
+ */
+function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
+ $order = strtolower($order);
+
+ // Handle link category sorting
+ $direction = 'ASC';
+ if (substr($order,0,1) == '_') {
+ $direction = 'DESC';
+ $order = substr($order,1);
+ }
+
+ if (!isset($direction)) $direction = '';
+
+ $cats = get_categories("type=link&orderby=$order&order=$direction&hierarchical=0");
+
+ // Display each category
+ if ($cats) {
+ foreach ($cats as $cat) {
+ // Handle each category.
+
+ // Display the category name
+ echo ' <li id="linkcat-' . $cat->cat_ID . '"><h2>' . $cat->cat_name . "</h2>\n\t<ul>\n";
+ // Call get_links() with all the appropriate params
+ get_links($cat->cat_ID,
+ '<li>',"</li>","\n", true, 'name', false);
+
+ // Close the last category
+ echo "\n\t</ul>\n</li>\n";
+ }
+ }
+}
+
+function wp_list_bookmarks($args = '') {
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => 0, 'category' => 0,
+ 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'echo' =>1,
+ 'categorize' => 1, 'title_li' => __('Bookmarks'));
+ $r = array_merge($defaults, $r);
+ extract($r);
+
+ // TODO: The rest of it.
+ // If $categorize, group links by category with the category name being the
+ // title of each li, otherwise just list them with title_li as the li title.
+ // If $categorize and $category or $category_name, list links for the given category
+ // with the category name as the title li. If not $categorize, use title_li.
+ // When using each category's name as a title li, use before and after args for specifying
+ // any markup. We don't want to hardcode h2.
+}
+
?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/bookmark.php b/wp-inst/wp-includes/bookmark.php
new file mode 100644
index 0000000..350d91e
--- /dev/null
+++ b/wp-inst/wp-includes/bookmark.php
@@ -0,0 +1,134 @@
+<?php
+
+function get_bookmark($bookmark_id, $output = OBJECT) {
+ global $wpdb;
+
+ $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = '$bookmark_id'");
+ $link->link_category = wp_get_link_cats($bookmark_id);
+
+ if ( $output == OBJECT ) {
+ return $link;
+ } elseif ( $output == ARRAY_A ) {
+ return get_object_vars($link);
+ } elseif ( $output == ARRAY_N ) {
+ return array_values(get_object_vars($link));
+ } else {
+ return $link;
+ }
+}
+
+// Deprecate
+function get_link($bookmark_id, $output = OBJECT) {
+ return get_bookmark($bookmark_id, $output);
+}
+
+function get_bookmarks($args = '') {
+ global $wpdb;
+
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '',
+ 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'include' => '', 'exclude' => '');
+ $r = array_merge($defaults, $r);
+ extract($r);
+
+ $inclusions = '';
+ if ( !empty($include) ) {
+ $exclude = ''; //ignore exclude, category, and category_name params if using include
+ $category = '';
+ $category_name = '';
+ $inclinks = preg_split('/[\s,]+/',$include);
+ if ( count($inclinks) ) {
+ foreach ( $inclinks as $inclink ) {
+ if (empty($inclusions))
+ $inclusions = ' AND ( link_id = ' . intval($inclink) . ' ';
+ else
+ $inclusions .= ' OR link_id = ' . intval($inclink) . ' ';
+ }
+ }
+ }
+ if (!empty($inclusions))
+ $inclusions .= ')';
+
+ $exclusions = '';
+ if ( !empty($exclude) ) {
+ $exlinks = preg_split('/[\s,]+/',$exclude);
+ if ( count($exlinks) ) {
+ foreach ( $exlinks as $exlink ) {
+ if (empty($exclusions))
+ $exclusions = ' AND ( link_id <> ' . intval($exlink) . ' ';
+ else
+ $exclusions .= ' AND link_id <> ' . intval($exlink) . ' ';
+ }
+ }
+ }
+ if (!empty($exclusions))
+ $exclusions .= ')';
+
+ if ( ! empty($category_name) ) {
+ if ( $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category_name' LIMIT 1") )
+ $category = $cat_id;
+ }
+
+ $category_query = '';
+ $join = '';
+ if ( !empty($category) ) {
+ $incategories = preg_split('/[\s,]+/',$category);
+ if ( count($incategories) ) {
+ foreach ( $incategories as $incat ) {
+ if (empty($category_query))
+ $category_query = ' AND ( category_id = ' . intval($incat) . ' ';
+ else
+ $category_query .= ' OR category_id = ' . intval($incat) . ' ';
+ }
+ }
+ }
+ if (!empty($category_query)) {
+ $category_query .= ')';
+ $join = " LEFT JOIN $wpdb->link2cat ON ($wpdb->links.link_id = $wpdb->link2cat.link_id) ";
+ }
+
+ if (get_settings('links_recently_updated_time')) {
+ $recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL " . get_settings('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated ";
+ } else {
+ $recently_updated_test = '';
+ }
+
+ if ($show_updated) {
+ $get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f ";
+ }
+
+ $orderby = strtolower($orderby);
+ $length = '';
+ switch ($orderby) {
+ case 'length':
+ $length = ", CHAR_LENGTH(link_name) AS length";
+ break;
+ case 'rand':
+ $orderby = 'rand()';
+ break;
+ default:
+ $orderby = "link_" . $orderby;
+ }
+
+ if ( 'link_id' == $orderby )
+ $orderby = "$wpdb->links.link_id";
+
+ $visible = '';
+ if ( $hide_invisible )
+ $visible = "AND link_visible = 'Y'";
+
+ $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query";
+ $query .= " $exclusions $inclusions";
+ $query .= " ORDER BY $orderby $order";
+ if ($limit != -1)
+ $query .= " LIMIT $limit";
+
+ $results = $wpdb->get_results($query);
+ return apply_filters('get_bookmarks', $results, $r);
+}
+
+?> \ No newline at end of file
diff --git a/wp-inst/wp-includes/cache.php b/wp-inst/wp-includes/cache.php
index 0ec19e1..976a0b3 100644
--- a/wp-inst/wp-includes/cache.php
+++ b/wp-inst/wp-includes/cache.php
@@ -47,8 +47,8 @@ function wp_cache_set($key, $data, $flag = '', $expire = 0) {
return $wp_object_cache->set($key, $data, $flag, $expire);
}
-define('CACHE_SERIAL_HEADER', "<?php\n//");
-define('CACHE_SERIAL_FOOTER', "\n?".">");
+define('CACHE_SERIAL_HEADER', "<?php\n/*");
+define('CACHE_SERIAL_FOOTER', "*/\n?".">");
class WP_Object_Cache {
var $cache_dir;
@@ -64,6 +64,7 @@ class WP_Object_Cache {
var $cold_cache_hits = 0;
var $warm_cache_hits = 0;
var $cache_misses = 0;
+ var $secret = '';
function acquire_lock() {
// Acquire a write lock.
@@ -142,7 +143,7 @@ class WP_Object_Cache {
return false;
}
- $cache_file = $this->cache_dir.$this->get_group_dir($group)."/".md5($id.DB_PASSWORD).'.php';
+ $cache_file = $this->cache_dir.$this->get_group_dir($group)."/".$this->hash($id).'.php';
if (!file_exists($cache_file)) {
$this->non_existant_objects[$group][$id] = true;
$this->cache_misses += 1;
@@ -158,7 +159,7 @@ class WP_Object_Cache {
return false;
}
- $this->cache[$group][$id] = unserialize(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER)));
+ $this->cache[$group][$id] = unserialize(base64_decode(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER))));
if (false === $this->cache[$group][$id])
$this->cache[$group][$id] = '';
@@ -173,6 +174,14 @@ class WP_Object_Cache {
return "{$this->blog_id}/$group";
}
+ function hash($data) {
+ if ( function_exists('hash_hmac') ) {
+ return hash_hmac('md5', $data, $this->secret);
+ } else {
+ return md5($data . $this->secret);
+ }
+ }
+
function load_group_from_db($group) {
global $wpdb;
@@ -322,7 +331,7 @@ class WP_Object_Cache {
$ids = array_unique($ids);
foreach ($ids as $id) {
- $cache_file = $group_dir.md5($id.DB_PASSWORD).'.php';
+ $cache_file = $group_dir.$this->hash($id).'.php';
// Remove the cache file if the key is not set.
if (!isset ($this->cache[$group][$id])) {
@@ -332,7 +341,7 @@ class WP_Object_Cache {
}
$temp_file = tempnam($group_dir, 'tmp');
- $serial = CACHE_SERIAL_HEADER.serialize($this->cache[$group][$id]).CACHE_SERIAL_FOOTER;
+ $serial = CACHE_SERIAL_HEADER.base64_encode(serialize($this->cache[$group][$id])).CACHE_SERIAL_FOOTER;
$fd = @fopen($temp_file, 'w');
if ( false === $fd ) {
$errors++;
@@ -414,7 +423,12 @@ class WP_Object_Cache {
if (defined('CACHE_EXPIRATION_TIME'))
$this->expiration_time = CACHE_EXPIRATION_TIME;
- $this->blog_id = md5($blog_id);
+ if ( defined('WP_SECRET') )
+ $this->secret = WP_SECRET;
+ else
+ $this->secret = DB_PASSWORD . DB_USER . DB_NAME . DB_HOST . ABSPATH;
+
+ $this->blog_id = $this->hash($blog_id);
}
}
?>
diff --git a/wp-inst/wp-includes/capabilities.php b/wp-inst/wp-includes/capabilities.php
index ea571cb..a1dfa56 100644
--- a/wp-inst/wp-includes/capabilities.php
+++ b/wp-inst/wp-includes/capabilities.php
@@ -272,6 +272,12 @@ function map_meta_cap($cap, $user_id) {
$caps = array();
switch ($cap) {
+ case 'delete_user':
+ $caps[] = 'delete_users';
+ break;
+ case 'edit_user':
+ $caps[] = 'edit_users';
+ break;
case 'delete_post':
$author_data = get_userdata($user_id);
//echo "post ID: {$args[0]}<br/>";
@@ -296,6 +302,8 @@ function map_meta_cap($cap, $user_id) {
// The post is published, extra cap required.
if ($post->post_status == 'publish')
$caps[] = 'delete_published_posts';
+ else if ($post->post_status == 'private')
+ $caps[] = 'delete_private_posts';
}
break;
case 'delete_page':
@@ -318,6 +326,8 @@ function map_meta_cap($cap, $user_id) {
// The page is published, extra cap required.
if ($page->post_status == 'publish')
$caps[] = 'delete_published_pages';
+ else if ($page->post_status == 'private')
+ $caps[] = 'delete_private_pages';
}
break;
// edit_post breaks down to edit_posts, edit_published_posts, or
@@ -346,6 +356,8 @@ function map_meta_cap($cap, $user_id) {
// The post is published, extra cap required.
if ($post->post_status == 'publish')
$caps[] = 'edit_published_posts';
+ else if ($post->post_status == 'private')
+ $caps[] = 'edit_private_posts';
}
break;
case 'edit_page':
@@ -368,6 +380,8 @@ function map_meta_cap($cap, $user_id) {
// The page is published, extra cap required.
if ($page->post_status == 'publish')
$caps[] = 'edit_published_pages';
+ else if ($page->post_status == 'private')
+ $caps[] = 'edit_private_pages';
}
break;
case 'read_post':
diff --git a/wp-inst/wp-includes/template-functions-category.php b/wp-inst/wp-includes/category-template.php
index a269e69..3df9b73 100644
--- a/wp-inst/wp-includes/template-functions-category.php
+++ b/wp-inst/wp-includes/category-template.php
@@ -1,15 +1,60 @@
<?php
-function walk_category_tree() {
- $walker = new Walker_Category;
- $args = func_get_args();
- return call_user_func_array(array(&$walker, 'walk'), $args);
+function get_category_children($id, $before = '/', $after = '') {
+ if ( 0 == $id )
+ return '';
+
+ $cat_ids = get_all_category_ids();
+ foreach ( $cat_ids as $cat_id ) {
+ if ( $cat_id == $id)
+ continue;
+
+ $category = get_category($cat_id);
+ if ( $category->category_parent == $id ) {
+ $chain .= $before.$category->cat_ID.$after;
+ $chain .= get_category_children($category->cat_ID, $before, $after);
+ }
+ }
+ return $chain;
}
-function walk_category_dropdown_tree() {
- $walker = new Walker_CategoryDropdown;
- $args = func_get_args();
- return call_user_func_array(array(&$walker, 'walk'), $args);
+function get_category_link($category_id) {
+ global $wp_rewrite;
+ $catlink = $wp_rewrite->get_category_permastruct();
+
+ if ( empty($catlink) ) {
+ $file = get_settings('home') . '/';
+ $catlink = $file . '?cat=' . $category_id;
+ } else {
+ $category = &get_category($category_id);
+ $category_nicename = $category->category_nicename;
+
+ if ( $parent = $category->category_parent )
+ $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename . '/';
+
+ $catlink = str_replace('%category%', $category_nicename, $catlink);
+ $catlink = get_settings('home') . trailingslashit($catlink);
+ }
+ return apply_filters('category_link', $catlink, $category_id);
+}
+
+function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
+ $chain = '';
+ $parent = &get_category($id);
+
+ if ( $nicename )
+ $name = $parent->category_nicename;
+ else
+ $name = $parent->cat_name;
+
+ if ( $parent->category_parent )
+ $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename);
+
+ if ( $link )
+ $chain .= '<a href="' . get_category_link($parent->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $parent->cat_name) . '">'.$name.'</a>' . $separator;
+ else
+ $chain .= $name.$separator;
+ return $chain;
}
function get_the_category($id = false) {
@@ -31,24 +76,10 @@ global $post, $category_cache;
return $categories;
}
-function get_category_link($category_id) {
- global $wp_rewrite;
- $catlink = $wp_rewrite->get_category_permastruct();
-
- if ( empty($catlink) ) {
- $file = get_settings('home') . '/';
- $catlink = $file . '?cat=' . $category_id;
- } else {
- $category = &get_category($category_id);
- $category_nicename = $category->category_nicename;
-
- if ( $parent = $category->category_parent )
- $category_nicename = get_category_parents($parent, false, '/', true) . $category_nicename . '/';
-
- $catlink = str_replace('%category%', $category_nicename, $catlink);
- $catlink = get_settings('home') . trailingslashit($catlink);
- }
- return apply_filters('category_link', $catlink, $category_id);
+function get_the_category_by_ID($cat_ID) {
+ $cat_ID = (int) $cat_ID;
+ $category = &get_category($cat_ID);
+ return $category->cat_name;
}
function get_the_category_list($separator = '', $parents='') {
@@ -106,51 +137,17 @@ function get_the_category_list($separator = '', $parents='') {
return apply_filters('the_category', $thelist, $separator, $parents);
}
-function the_category($separator = '', $parents='') {
- echo get_the_category_list($separator, $parents);
-}
-
-function get_the_category_by_ID($cat_ID) {
- $cat_ID = (int) $cat_ID;
- $category = &get_category($cat_ID);
- return $category->cat_name;
-}
-
-function get_category_parents($id, $link = FALSE, $separator = '/', $nicename = FALSE){
- $chain = '';
- $parent = &get_category($id);
-
- if ( $nicename )
- $name = $parent->category_nicename;
- else
- $name = $parent->cat_name;
-
- if ( $parent->category_parent )
- $chain .= get_category_parents($parent->category_parent, $link, $separator, $nicename);
+function in_category($category) { // Check if the current post is in the given category
+ global $category_cache, $post;
- if ( $link )
- $chain .= '<a href="' . get_category_link($parent->cat_ID) . '" title="' . sprintf(__("View all posts in %s"), $parent->cat_name) . '">'.$name.'</a>' . $separator;
+ if ( isset( $category_cache[$post->ID][$category] ) )
+ return true;
else
- $chain .= $name.$separator;
- return $chain;
+ return false;
}
-function get_category_children($id, $before = '/', $after = '') {
- if ( 0 == $id )
- return '';
-
- $cat_ids = get_all_category_ids();
- foreach ( $cat_ids as $cat_id ) {
- if ( $cat_id == $id)
- continue;
-
- $category = get_category($cat_id);
- if ( $category->category_parent == $id ) {
- $chain .= $before.$category->cat_ID.$after;
- $chain .= get_category_children($category->cat_ID, $before, $after);
- }
- }
- return $chain;
+function the_category($separator = '', $parents='') {
+ echo get_the_category_list($separator, $parents);
}
function category_description($category = 0) {
@@ -252,115 +249,20 @@ function wp_list_categories($args = '') {
echo apply_filters('list_cats', $output);
}
-function in_category($category) { // Check if the current post is in the given category
- global $category_cache, $post;
-
- if ( isset( $category_cache[$post->ID][$category] ) )
- return true;
- else
- return false;
-}
-
-function &_get_cat_children($category_id, $categories) {
- if ( empty($categories) )
- return array();
-
- $category_list = array();
- foreach ( $categories as $category ) {
- if ( $category->category_parent == $category_id ) {
- $category_list[] = $category;
- if ( $children = _get_cat_children($category->cat_ID, $categories) )
- $category_list = array_merge($category_list, $children);
- }
- }
+//
+// Helper functions
+//
- return $category_list;
+function walk_category_tree() {
+ $walker = new Walker_Category;
+ $args = func_get_args();
+ return call_user_func_array(array(&$walker, 'walk'), $args);
}
-function &get_categories($args = '') {
- global $wpdb, $category_links;
-
- if ( is_array($args) )
- $r = &$args;
- else
- parse_str($args, $r);
-
- $defaults = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC',
- 'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1, $exclude => '', $include => '');
- $r = array_merge($defaults, $r);
- $r['orderby'] = "cat_" . $r['orderby']; // restricts order by to cat_ID and cat_name fields
- extract($r);
-
- $where = 'cat_ID > 0';
- $inclusions = '';
- if ( !empty($include) ) {
- $child_of = 0; //ignore child_of and exclude params if using include
- $exclude = '';
- $incategories = preg_split('/[\s,]+/',$include);
- if ( count($incategories) ) {
- foreach ( $incategories as $incat ) {
- if (empty($inclusions))
- $inclusions = ' AND ( cat_ID = ' . intval($incat) . ' ';
- else
- $inclusions .= ' OR cat_ID = ' . intval($incat) . ' ';
- }
- }
- }
- if (!empty($inclusions))
- $inclusions .= ')';
- $where .= $inclusions;
-
- $exclusions = '';
- if ( !empty($exclude) ) {
- $excategories = preg_split('/[\s,]+/',$exclude);
- if ( count($excategories) ) {
- foreach ( $excategories as $excat ) {
- if (empty($exclusions))
- $exclusions = ' AND ( cat_ID <> ' . intval($excat) . ' ';
- else
- $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
- // TODO: Exclude children of excluded cats? Note: children are getting excluded
- }
- }
- }
- if (!empty($exclusions))
- $exclusions .= ')';
- $exclusions = apply_filters('list_cats_exclusions', $exclusions );
- $where .= $exclusions;
-
- $having = '';
- if ( $hide_empty ) {
- if ( 'link' == $type )
- $having = 'HAVING link_count > 0';
- else
- $having = 'HAVING category_count > 0';
- }
-
- $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE $where $having ORDER BY $orderby $order");
-
- if ( empty($categories) )
- return array();
-
- // TODO: Integrate this into the main query.
- if ( $include_last_update_time ) {
- $stamps = $wpdb->get_results("SELECT category_id, UNIX_TIMESTAMP( MAX(post_date) ) AS ts FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories
- WHERE post_status = 'publish' AND post_id = ID AND $where GROUP BY category_id");
- global $cat_stamps;
- foreach ($stamps as $stamp)
- $cat_stamps[$stamp->category_id] = $stamp->ts;
- function stamp_cat($cat) {
- global $cat_stamps;
- $cat->last_update_timestamp = $cat_stamps[$cat->cat_ID];
- return $cat;
- }
- $categories = array_map('stamp_cat', $categories);
- unset($cat_stamps);
- }
-
- if ( $child_of || $hierarchical )
- $categories = & _get_cat_children($child_of, $categories);
-
- return apply_filters('get_categories', $categories);
+function walk_category_dropdown_tree() {
+ $walker = new Walker_CategoryDropdown;
+ $args = func_get_args();
+ return call_user_func_array(array(&$walker, 'walk'), $args);
}
?>
diff --git a/wp-inst/wp-includes/category.php b/wp-inst/wp-includes/category.php
new file mode 100644
index 0000000..fb0ec87
--- /dev/null
+++ b/wp-inst/wp-includes/category.php
@@ -0,0 +1,205 @@
+<?php
+
+function get_all_category_ids() {
+ global $wpdb;
+
+ if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category') ) {
+ $cat_ids = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
+ wp_cache_add('all_category_ids', $cat_ids, 'category');
+ }
+
+ return $cat_ids;
+}
+
+function &get_categories($args = '') {
+ global $wpdb, $category_links;
+
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
+
+ $defaults = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC',
+ 'hide_empty' => true, 'include_last_update_time' => false, 'hierarchical' => 1, $exclude => '', $include => '');
+ $r = array_merge($defaults, $r);
+ $r['orderby'] = "cat_" . $r['orderby']; // restricts order by to cat_ID and cat_name fields
+ extract($r);
+
+ $where = 'cat_ID > 0';
+ $inclusions = '';
+ if ( !empty($include) ) {
+ $child_of = 0; //ignore child_of and exclude params if using include
+ $exclude = '';
+ $incategories = preg_split('/[\s,]+/',$include);
+ if ( count($incategories) ) {
+ foreach ( $incategories as $incat ) {
+ if (empty($inclusions))
+ $inclusions = ' AND ( cat_ID = ' . intval($incat) . ' ';
+ else
+ $inclusions .= ' OR cat_ID = ' . intval($incat) . ' ';
+ }
+ }
+ }
+ if (!empty($inclusions))
+ $inclusions .= ')';
+ $where .= $inclusions;
+
+ $exclusions = '';
+ if ( !empty($exclude) ) {
+ $excategories = preg_split('/[\s,]+/',$exclude);
+ if ( count($excategories) ) {
+ foreach ( $excategories as $excat ) {
+ if (empty($exclusions))
+ $exclusions = ' AND ( cat_ID <> ' . intval($excat) . ' ';
+ else
+ $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';
+ // TODO: Exclude children of excluded cats? Note: children are getting excluded
+ }
+ }
+ }
+ if (!empty($exclusions))
+ $exclusions .= ')';
+ $exclusions = apply_filters('list_cats_exclusions', $exclusions );
+ $where .= $exclusions;
+
+ $having = '';
+ if ( $hide_empty ) {
+ if ( 'link' == $type )
+ $having = 'HAVING link_count > 0';
+ else
+ $having = 'HAVING category_count > 0';
+ }
+
+ $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE $where $having ORDER BY $orderby $order");
+
+ if ( empty($categories) )
+ return array();
+
+ // TODO: Integrate this into the main query.
+ if ( $include_last_update_time ) {
+ $stamps = $wpdb->get_results("SELECT category_id, UNIX_TIMESTAMP( MAX(post_date) ) AS ts FROM $wpdb->posts, $wpdb->post2cat, $wpdb->categories
+ WHERE post_status = 'publish' AND post_id = ID AND $where GROUP BY category_id");
+ global $cat_stamps;
+ foreach ($stamps as $stamp)
+ $cat_stamps[$stamp->category_id] = $stamp->ts;
+ function stamp_cat($cat) {
+ global $cat_stamps;
+ $cat->last_update_timestamp = $cat_stamps[$cat->cat_ID];
+ return $cat;
+ }
+ $categories = array_map('stamp_cat', $categories);
+ unset($cat_stamps);
+ }
+
+ if ( $child_of || $hierarchical )
+ $categories = & _get_cat_children($child_of, $categories);
+
+ return apply_filters('get_categories', $categories);
+}
+
+// Retrieves category data given a category ID or category object.
+// Handles category caching.
+function &get_category(&$category, $output = OBJECT) {
+ global $wpdb;
+
+ if ( empty($category) )
+ return null;
+
+ if ( is_object($category) ) {
+ wp_cache_add($category->cat_ID, $category, 'category');
+ $_category = $category;
+ } else {
+ if ( ! $_category = wp_cache_get($category, 'category') ) {
+ $_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category' LIMIT 1");
+ wp_cache_add($category, $_category, 'category');
+ }
+ }
+
+ if ( $output == OBJECT ) {
+ return $_category;
+ } elseif ( $output == ARRAY_A ) {
+ return get_object_vars($_category);
+ } elseif ( $output == ARRAY_N ) {
+ return array_values(get_object_vars($_category));
+ } else {
+ return $_category;
+ }
+}
+
+function get_category_by_path($category_path, $full_match = true, $output = OBJECT) {
+ global $wpdb;
+ $category_path = rawurlencode(urldecode($category_path));
+ $category_path = str_replace('%2F', '/', $category_path);
+ $category_path = str_replace('%20', ' ', $category_path);
+ $category_paths = '/' . trim($category_path, '/');
+ $leaf_path = sanitize_title(basename($category_paths));
+ $category_paths = explode('/', $category_paths);
+ foreach($category_paths as $pathdir)
+ $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
+
+ $categories = $wpdb->get_results("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE category_nicename = '$leaf_path'");
+
+ if ( empty($categories) )
+ return NULL;
+
+ foreach ($categories as $category) {
+ $path = '/' . $leaf_path;
+ $curcategory = $category;
+ while ($curcategory->category_parent != 0) {
+ $curcategory = $wpdb->get_row("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE cat_ID = '$curcategory->category_parent'");
+ $path = '/' . $curcategory->category_nicename . $path;
+ }
+
+ if ( $path == $full_path )
+ return get_category($category->cat_ID, $output);
+ }
+
+ // If full matching is not required, return the first cat that matches the leaf.
+ if ( ! $full_match )
+ return get_category($categories[0]->cat_ID, $output);
+
+ return NULL;
+}
+
+// Get the ID of a category from its name
+function get_cat_ID($cat_name='General') {
+ global $wpdb;
+
+ $cid = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'");
+
+ return $cid?$cid:1; // default to cat 1
+}
+
+// Deprecate
+function get_catname($cat_ID) {
+ return get_cat_name($cat_ID);
+}
+
+// Get the name of a category from its ID
+function get_cat_name($cat_id) {
+ $cat_id = (int) $cat_id;
+ $category = &get_category($cat_id);
+ return $category->cat_name;
+}
+
+//
+// Private
+//
+
+function &_get_cat_children($category_id, $categories) {
+ if ( empty($categories) )
+ return array();
+
+ $category_list = array();
+ foreach ( $categories as $category ) {
+ if ( $category->category_parent == $category_id ) {
+ $category_list[] = $category;
+ if ( $children = _get_cat_children($category->cat_ID, $categories) )
+ $category_list = array_merge($category_list, $children);
+ }
+ }
+
+ return $category_list;
+}
+
+?>
diff --git a/wp-inst/wp-includes/class-snoopy.php b/wp-inst/wp-includes/class-snoopy.php
index f669ba5..0149582 100644
--- a/wp-inst/wp-includes/class-snoopy.php
+++ b/wp-inst/wp-includes/class-snoopy.php
@@ -720,13 +720,13 @@ class Snoopy
chr(176),
chr(39),
chr(128),
- "ä",
- "ö",
- "ü",
- "Ä",
- "Ö",
- "Ü",
- "ß",
+ "ä",
+ "ö",
+ "ü",
+ "Ä",
+ "Ö",
+ "Ü",
+ "ß",
);
$text = preg_replace($search,$replace,$document);
diff --git a/wp-inst/wp-includes/classes.php b/wp-inst/wp-includes/classes.php
index 3952cb5..79709db 100644
--- a/wp-inst/wp-includes/classes.php
+++ b/wp-inst/wp-includes/classes.php
@@ -73,7 +73,7 @@ class retrospam_mgr {
}
class WP {
- var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview');
+ var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type');
var $extra_query_vars = array();
@@ -224,6 +224,8 @@ class WP {
if ( isset($error) )
$this->query_vars['error'] = $error;
+
+ do_action('parse_request', array(&$this));
}
function send_headers() {
@@ -263,6 +265,8 @@ class WP {
exit;
}
}
+
+ do_action('send_headers', array(&$this));
}
function build_query_string() {
@@ -333,6 +337,7 @@ class WP {
$this->query_posts();
$this->handle_404();
$this->register_globals();
+ do_action('wp', array(&$this));
}
function WP() {
diff --git a/wp-inst/wp-includes/comment-functions.php b/wp-inst/wp-includes/comment-functions.php
deleted file mode 100644
index a61610a..0000000
--- a/wp-inst/wp-includes/comment-functions.php
+++ /dev/null
@@ -1,892 +0,0 @@
-<?php
-
-// Template functions
-
-function comments_template( $file = '/comments.php' ) {
- global $wp_query, $withcomments, $post, $wpdb, $id, $comment, $user_login, $user_ID, $user_identity;
-
- if ( is_single() || is_page() || $withcomments ) :
- $req = get_settings('require_name_email');
- $comment_author = isset($_COOKIE['comment_author_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_'.COOKIEHASH])) : '';
- $comment_author_email = isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_email_'.COOKIEHASH])) : '';
- $comment_author_url = isset($_COOKIE['comment_author_url_'.COOKIEHASH]) ? trim(stripslashes($_COOKIE['comment_author_url_'.COOKIEHASH])) : '';
- if ( empty($comment_author) ) {
- $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND comment_approved = '1' ORDER BY comment_date");
- } else {
- $author_db = $wpdb->escape($comment_author);
- $email_db = $wpdb->escape($comment_author_email);
- $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post->ID' AND ( comment_approved = '1' OR ( comment_author = '$author_db' AND comment_author_email = '$email_db' AND comment_approved = '0' ) ) ORDER BY comment_date");
- }
-
- get_currentuserinfo();
-
- define('COMMENTS_TEMPLATE', true);
- $include = apply_filters('comments_template', TEMPLATEPATH . $file );
- if ( file_exists( $include ) )
- require( $include );
- else
- require( ABSPATH . 'wp-content/themes/default/comments.php');
-
- endif;
-}
-
-function wp_new_comment( $commentdata ) {
- $commentdata = apply_filters('preprocess_comment', $commentdata);
-
- $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
- $commentdata['user_ID'] = (int) $commentdata['user_ID'];
-
- $commentdata['comment_author_IP'] = $_SERVER['REMOTE_ADDR'];
- $commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT'];
-
- $commentdata['comment_date'] = current_time('mysql');
- $commentdata['comment_date_gmt'] = current_time('mysql', 1);
-
-
- $commentdata = wp_filter_comment($commentdata);
-
- $commentdata['comment_approved'] = wp_allow_comment($commentdata);
-
- $comment_ID = wp_insert_comment($commentdata);
-
- do_action('comment_post', $comment_ID, $commentdata['comment_approved']);
-
- if ( 'spam' !== $commentdata['comment_approved'] ) { // If it's spam save it silently for later crunching
- if ( '0' == $commentdata['comment_approved'] )
- wp_notify_moderator($comment_ID);
-
- $post = &get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment
-
- if ( get_settings('comments_notify') && $commentdata['comment_approved'] && $post->post_author != $commentdata['user_ID'] )
- wp_notify_postauthor($comment_ID, $commentdata['comment_type']);
- }
-
- return $comment_ID;
-}
-
-function wp_insert_comment($commentdata) {
- global $wpdb;
- extract($commentdata);
-
- if ( ! isset($comment_author_IP) )
- $comment_author_IP = $_SERVER['REMOTE_ADDR'];
- if ( ! isset($comment_date) )
- $comment_date = current_time('mysql');
- if ( ! isset($comment_date_gmt) )
- $comment_date_gmt = gmdate('Y-m-d H:i:s', strtotime($comment_date) );
- if ( ! isset($comment_parent) )
- $comment_parent = 0;
- if ( ! isset($comment_approved) )
- $comment_approved = 1;
- if ( ! isset($user_id) )
- $user_id = 0;
-
- $result = $wpdb->query("INSERT INTO $wpdb->comments
- (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, comment_parent, user_id)
- VALUES
- ('$comment_post_ID', '$comment_author', '$comment_author_email', '$comment_author_url', '$comment_author_IP', '$comment_date', '$comment_date_gmt', '$comment_content', '$comment_approved', '$comment_agent', '$comment_type', '$comment_parent', '$user_id')
- ");
-
- $id = $wpdb->insert_id;
-
- if ( $comment_approved == 1) {
- $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'");
- $wpdb->query( "UPDATE $wpdb->posts SET comment_count = $count WHERE ID = '$comment_post_ID'" );
- }
- return $id;
-}
-
-function wp_filter_comment($commentdata) {
- $commentdata['user_id'] = apply_filters('pre_user_id', $commentdata['user_ID']);
- $commentdata['comment_agent'] = apply_filters('pre_comment_user_agent', $commentdata['comment_agent']);
- $commentdata['comment_author'] = apply_filters('pre_comment_author_name', $commentdata['comment_author']);
- $commentdata['comment_content'] = apply_filters('pre_comment_content', $commentdata['comment_content']);
- $commentdata['comment_author_IP'] = apply_filters('pre_comment_user_ip', $commentdata['comment_author_IP']);
- $commentdata['comment_author_url'] = apply_filters('pre_comment_author_url', $commentdata['comment_author_url']);
- $commentdata['comment_author_email'] = apply_filters('pre_comment_author_email', $commentdata['comment_author_email']);
- $commentdata['filtered'] = true;
- return $commentdata;
-}
-
-function wp_allow_comment($commentdata) {
- global $wpdb;
- extract($commentdata);
-
- $comment_user_domain = apply_filters('pre_comment_user_domain', gethostbyaddr($comment_author_IP) );
-
- // Simple duplicate check
- $dupe = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = '$comment_post_ID' AND ( comment_author = '$comment_author' ";
- if ( $comment_author_email )
- $dupe .= "OR comment_author_email = '$comment_author_email' ";
- $dupe .= ") AND comment_content = '$comment_content' LIMIT 1";
- if ( $wpdb->get_var($dupe) )
- die( __('Duplicate comment detected; it looks as though you\'ve already said that!') );
-
- // Simple flood-protection
- if ( $lasttime = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_author_IP = '$comment_author_IP' OR comment_author_email = '$comment_author_email' ORDER BY comment_date DESC LIMIT 1") ) {
- $time_lastcomment = mysql2date('U', $lasttime);
- $time_newcomment = mysql2date('U', $comment_date_gmt);
- if ( ($time_newcomment - $time_lastcomment) < 15 ) {
- do_action('comment_flood_trigger', $time_lastcomment, $time_newcomment);
- die( __('Sorry, you can only post a new comment once every 15 seconds. Slow down cowboy.') );
- }
- }
-
- if ( $user_id ) {
- $userdata = get_userdata($user_id);
- $user = new WP_User($user_id);
- $post_author = $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = '$comment_post_ID' LIMIT 1");
- }
-
- // The author and the admins get respect.
- if ( $userdata && ( $user_id == $post_author || $user->has_cap('level_9') ) ) {
- $approved = 1;
- }
-
- // Everyone else's comments will be checked.
- else {
- if ( check_comment($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent, $comment_type) )
- $approved = 1;
- else
- $approved = 0;
- if ( wp_blacklist_check($comment_author, $comment_author_email, $comment_author_url, $comment_content, $comment_author_IP, $comment_agent) )
- $approved = 'spam';
- }
-
- $approved = apply_filters('pre_comment_approved', $approved);
- return $approved;
-}
-
-
-function wp_update_comment($commentarr) {
- global $wpdb;
-
- // First, get all of the original fields
- $comment = get_comment($commentarr['comment_ID'], ARRAY_A);
-
- // Escape data pulled from DB.
- foreach ($comment as $key => $value)
- $comment[$key] = $wpdb->escape($value);
-
- // Merge old and new fields with new fields overwriting old ones.
- $commentarr = array_merge($comment, $commentarr);
-
- // Now extract the merged array.
- extract($commentarr);
-
- $comment_content = apply_filters('comment_save_pre', $comment_content);
-
- $result = $wpdb->query(
- "UPDATE $wpdb->comments SET
- comment_content = '$comment_content',
- comment_author = '$comment_author',
- comment_author_email = '$comment_author_email',
- comment_approved = '$comment_approved',
- comment_author_url = '$comment_author_url',
- comment_date = '$comment_date'
- WHERE comment_ID = $comment_ID" );
-
- $rval = $wpdb->rows_affected;
-
- $c = $wpdb->get_row( "SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'" );
- if( is_object( $c ) )
- $wpdb->query( "UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'" );
-
- do_action('edit_comment', $comment_ID);
-
- return $rval;
-}
-
-function wp_delete_comment($comment_id) {
- global $wpdb;
- do_action('delete_comment', $comment_id);
-
- $comment = get_comment($comment_id);
-
- if ( ! $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1") )
- return false;
-
- $post_id = $comment->comment_post_ID;
- if ( $post_id && $comment->comment_approved == 1 )
- $wpdb->query( "UPDATE $wpdb->posts SET comment_count = comment_count - 1 WHERE ID = '$post_id'" );
-
- do_action('wp_set_comment_status', $comment_id, 'delete');
- return true;
-}
-
-function clean_url( $url ) {
- if ('' == $url) return $url;
- $url = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $url);
- $url = str_replace(';//', '://', $url);
- $url = (!strstr($url, '://')) ? 'http://'.$url : $url;
- $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);
- return $url;
-}
-
-function get_comments_number( $post_id = 0 ) {
- global $wpdb, $comment_count_cache, $id;
- $post_id = (int) $post_id;
-
- if ( !$post_id )
- $post_id = $id;
-
- if ( !isset($comment_count_cache[$post_id]) )
- $comment_count_cache[$id] = $wpdb->get_var("SELECT comment_count FROM $wpdb->posts WHERE ID = '$post_id'");
-
- return apply_filters('get_comments_number', $comment_count_cache[$post_id]);
-}
-
-function comments_number( $zero = 'No Comments', $one = '1 Comment', $more = '% Comments', $number = '' ) {
- global $id, $comment;
- $number = get_comments_number( $id );
- if ($number == 0) {
- $blah = $zero;
- } elseif ($number == 1) {
- $blah = $one;
- } elseif ($number > 1) {
- $blah = str_replace('%', $number, $more);
- }
- echo apply_filters('comments_number', $blah);
-}
-
-function get_comments_link() {
- return get_permalink() . '#comments';
-}
-
-function get_comment_link() {
- global $comment;
- return get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment->comment_ID;
-}
-
-function comments_link( $file = '', $echo = true ) {
- echo get_comments_link();
-}
-
-function comments_popup_script($width=400, $height=400, $file='') {
- global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript;
-
- if (empty ($file)) {
- $wpcommentspopupfile = ''; // Use the index.
- } else {
- $wpcommentspopupfile = $file;
- }
-
- $wpcommentsjavascript = 1;
- $javascript = "<script type='text/javascript'>\nfunction wpopen (macagna) {\n window.open(macagna, '_blank', 'width=$width,height=$height,scrollbars=yes,status=yes');\n}\n</script>\n";
- echo $javascript;
-}
-
-function comments_popup_link($zero='No Comments', $one='1 Comment', $more='% Comments', $CSSclass='', $none='Comments Off') {
- global $id, $wpcommentspopupfile, $wpcommentsjavascript, $post, $wpdb;
- global $comment_count_cache;
-
- if (! is_single() && ! is_page()) {
- if ( !isset($comment_count_cache[$id]) )
- $comment_count_cache[$id] = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments WHERE comment_post_ID = $id AND comment_approved = '1';");
-
- $number = $comment_count_cache[$id];
-
- if (0 == $number && 'closed' == $post->comment_status && 'closed' == $post->ping_status) {
- echo $none;
- return;
- } else {
- if (!empty($post->post_password)) { // if there's a password
- if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie
- echo(__('Enter your password to view comments'));
- return;
- }
- }
- echo '<a href="';
- if ($wpcommentsjavascript) {
- if ( empty($wpcommentspopupfile) )
- $home = get_settings('home');
- else
- $home = get_settings('siteurl');
- echo $home . '/' . $wpcommentspopupfile.'?comments_popup='.$id;
- echo '" onclick="wpopen(this.href); return false"';
- } else { // if comments_popup_script() is not in the template, display simple comment link
- if ( 0 == $number )
- echo get_permalink() . '#respond';
- else
- comments_link();
- echo '"';
- }
- if (!empty($CSSclass)) {
- echo ' class="'.$CSSclass.'"';
- }
- echo ' title="' . sprintf( __('Comment on %s'), $post->post_title ) .'">';
- comments_number($zero, $one, $more, $number);
- echo '</a>';
- }
- }
-}
-
-function get_comment_ID() {
- global $comment;
- return apply_filters('get_comment_ID', $comment->comment_ID);
-}
-
-function comment_ID() {
- echo get_comment_ID();
-}
-
-function get_comment_author() {
- global $comment;
- if ( empty($comment->comment_author) )
- $author = __('Anonymous');
- else
- $author = $comment->comment_author;
- return apply_filters('get_comment_author', $author);
-}
-
-function comment_author() {
- $author = apply_filters('comment_author', get_comment_author() );
- echo $author;
-}
-
-function get_comment_author_email() {
- global $comment;
- return apply_filters('get_comment_author_email', $comment->comment_author_email);
-}
-
-function comment_author_email() {
- echo apply_filters('author_email', get_comment_author_email() );
-}
-
-function get_comment_author_link() {
- global $comment;
- $url = get_comment_author_url();
- $author = get_comment_author();
-
- if ( empty( $url ) || 'http://' == $url )
- $return = $author;
- else
- $return = "<a href='$url' rel='external nofollow'>$author</a>";
- return apply_filters('get_comment_author_link', $return);
-}
-
-function comment_author_link() {
- echo get_comment_author_link();
-}
-
-function get_comment_type() {
- global $comment;
-
- if ( '' == $comment->comment_type )
- $comment->comment_type = 'comment';
-
- return apply_filters('get_comment_type', $comment->comment_type);
-}
-
-function comment_type($commenttxt = 'Comment', $trackbacktxt = 'Trackback', $pingbacktxt = 'Pingback') {
- $type = get_comment_type();
- switch( $type ) {
- case 'trackback' :
- echo $trackbacktxt;
- break;
- case 'pingback' :
- echo $pingbacktxt;
- break;
- default :
- echo $commenttxt;
- }
-}
-
-function get_comment_author_url() {
- global $comment;
- return apply_filters('get_comment_author_url', $comment->comment_author_url);
-}
-
-function comment_author_url() {
- echo apply_filters('comment_url', get_comment_author_url());
-}
-
-function comment_author_email_link($linktext='', $before='', $after='') {
- global $comment;
- $email = apply_filters('comment_email', $comment->comment_author_email);
- if ((!empty($email)) && ($email != '@')) {
- $display = ($linktext != '') ? $linktext : $email;
- echo $before;
- echo "<a href='mailto:$email'>$display</a>";
- echo $after;
- }
-}
-
-function get_comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
- global $comment;
- $url = get_comment_author_url();
- $display = ($linktext != '') ? $linktext : $url;
- $return = "$before<a href='$url' rel='external'>$display</a>$after";
- return apply_filters('get_comment_author_url_link', $return);
-}
-
-function comment_author_url_link( $linktext = '', $before = '', $after = '' ) {
- echo get_comment_author_url_link( $linktext, $before, $after );
-}
-
-function get_comment_author_IP() {
- global $comment;
- return apply_filters('get_comment_author_IP', $comment->comment_author_IP);
-}
-
-function comment_author_IP() {
- echo get_comment_author_IP();
-}
-
-function get_comment_text() {
- global $comment;
- return apply_filters('get_comment_text', $comment->comment_content);
-}
-
-function comment_text() {
- echo apply_filters('comment_text', get_comment_text() );
-}
-
-function get_comment_excerpt() {
- global $comment;
- $comment_text = strip_tags($comment->comment_content);
- $blah = explode(' ', $comment_text);
- if (count($blah) > 20) {
- $k = 20;
- $use_dotdotdot = 1;
- } else {
- $k = count($blah);
- $use_dotdotdot = 0;
- }
- $excerpt = '';
- for ($i=0; $i<$k; $i++) {
- $excerpt .= $blah[$i] . ' ';
- }
- $excerpt .= ($use_dotdotdot) ? '...' : '';
- return apply_filters('get_comment_excerpt', $excerpt);
-}
-
-function comment_excerpt() {
- echo apply_filters('comment_excerpt', get_comment_excerpt() );
-}
-
-function get_comment_date( $d = '' ) {
- global $comment;
- if ( '' == $d )
- $date = mysql2date( get_settings('date_format'), $comment->comment_date);
- else
- $date = mysql2date($d, $comment->comment_date);
- return apply_filters('get_comment_date', $date);
-}
-
-function comment_date( $d = '' ) {
- echo get_comment_date( $d );
-}
-
-function get_comment_time( $d = '', $gmt = false ) {
- global $comment;
- $comment_date = $gmt? $comment->comment_date_gmt : $comment->comment_date;
- if ( '' == $d )
- $date = mysql2date(get_settings('time_format'), $comment_date);
- else
- $date = mysql2date($d, $comment_date);
- return apply_filters('get_comment_time', $date);
-}
-
-function comment_time( $d = '' ) {
- echo get_comment_time($d);
-}
-
-function get_trackback_url() {
- global $id;
- $tb_url = get_settings('siteurl') . '/wp-trackback.php?p=' . $id;
-
- if ( '' != get_settings('permalink_structure') )
- $tb_url = trailingslashit(get_permalink()) . 'trackback/';
-
- return $tb_url;
-}
-function trackback_url( $display = true ) {
- if ( $display)
- echo get_trackback_url();
- else
- return get_trackback_url();
-}
-
-function trackback_rdf($timezone = 0) {
- global $id;
- if (!stristr($_SERVER['HTTP_USER_AGENT'], 'W3C_Validator')) {
- echo '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:dc="http://purl.org/dc/elements/1.1/"
- xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
- <rdf:Description rdf:about="';
- the_permalink();
- echo '"'."\n";
- echo ' dc:identifier="';
- the_permalink();
- echo '"'."\n";
- echo ' dc:title="'.str_replace('--', '&#x2d;&#x2d;', wptexturize(strip_tags(get_the_title()))).'"'."\n";
- echo ' trackback:ping="'.trackback_url(0).'"'." />\n";
- echo '</rdf:RDF>';
- }
-}
-
-function comments_open() {
- global $post;
- if ( 'open' == $post->comment_status )
- return true;
- else
- return false;
-}
-
-function pings_open() {
- global $post;
- if ( 'open' == $post->ping_status )
- return true;
- else
- return false;
-}
-
-// Non-template functions
-
-function get_lastcommentmodified($timezone = 'server') {
- global $cache_lastcommentmodified, $pagenow, $wpdb;
- $add_seconds_blog = get_settings('gmt_offset') * 3600;
- $add_seconds_server = date('Z');
- $now = current_time('mysql', 1);
- if ( !isset($cache_lastcommentmodified[$timezone]) ) {
- switch(strtolower($timezone)) {
- case 'gmt':
- $lastcommentmodified = $wpdb->get_var("SELECT comment_date_gmt FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");
- break;
- case 'blog':
- $lastcommentmodified = $wpdb->get_var("SELECT comment_date FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");
- break;
- case 'server':
- $lastcommentmodified = $wpdb->get_var("SELECT DATE_ADD(comment_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->comments WHERE comment_date_gmt <= '$now' ORDER BY comment_date_gmt DESC LIMIT 1");
- break;
- }
- $cache_lastcommentmodified[$timezone] = $lastcommentmodified;
- } else {
- $lastcommentmodified = $cache_lastcommentmodified[$timezone];
- }
- return $lastcommentmodified;
-}
-
-function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = false ) { // less flexible, but saves DB queries
- global $postc, $id, $commentdata, $wpdb;
- if ($no_cache) {
- $query = "SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_ID'";
- if (false == $include_unapproved) {
- $query .= " AND comment_approved = '1'";
- }
- $myrow = $wpdb->get_row($query, ARRAY_A);
- } else {
- $myrow['comment_ID'] = $postc->comment_ID;
- $myrow['comment_post_ID'] = $postc->comment_post_ID;
- $myrow['comment_author'] = $postc->comment_author;
- $myrow['comment_author_email'] = $postc->comment_author_email;
- $myrow['comment_author_url'] = $postc->comment_author_url;
- $myrow['comment_author_IP'] = $postc->comment_author_IP;
- $myrow['comment_date'] = $postc->comment_date;
- $myrow['comment_content'] = $postc->comment_content;
- $myrow['comment_karma'] = $postc->comment_karma;
- $myrow['comment_approved'] = $postc->comment_approved;
- $myrow['comment_type'] = $postc->comment_type;
- }
- return $myrow;
-}
-
-function pingback($content, $post_ID) {
- global $wp_version, $wpdb;
- include_once (ABSPATH . WPINC . '/class-IXR.php');
-
- // original code by Mort (http://mort.mine.nu:8080)
- $log = debug_fopen(ABSPATH . '/pingback.log', 'a');
- $post_links = array();
- debug_fwrite($log, 'BEGIN '.date('YmdHis', time())."\n");
-
- $pung = get_pung($post_ID);
-
- // Variables
- $ltrs = '\w';
- $gunk = '/#~:.?+=&%@!\-';
- $punc = '.:?\-';
- $any = $ltrs . $gunk . $punc;
-
- // Step 1
- // Parsing the post, external links (if any) are stored in the $post_links array
- // This regexp comes straight from phpfreaks.com
- // http://www.phpfreaks.com/quickcode/Extract_All_URLs_on_a_Page/15.php
- preg_match_all("{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp);
-
- // Debug
- debug_fwrite($log, 'Post contents:');
- debug_fwrite($log, $content."\n");
-
- // Step 2.
- // Walking thru the links array
- // first we get rid of links pointing to sites, not to specific files
- // Example:
- // http://dummy-weblog.org
- // http://dummy-weblog.org/
- // http://dummy-weblog.org/post.php
- // We don't wanna ping first and second types, even if they have a valid <link/>
-
- foreach($post_links_temp[0] as $link_test) :
- if ( !in_array($link_test, $pung) && (url_to_postid($link_test) != $post_ID) // If we haven't pung it already and it isn't a link to itself
- && !is_local_attachment($link_test) ) : // Also, let's never ping local attachments.
- $test = parse_url($link_test);
- if (isset($test['query']))
- $post_links[] = $link_test;
- elseif(($test['path'] != '/') && ($test['path'] != ''))
- $post_links[] = $link_test;
- endif;
- endforeach;
-
- do_action('pre_ping', array(&$post_links, &$pung));
-
- foreach ($post_links as $pagelinkedto){
- debug_fwrite($log, "Processing -- $pagelinkedto\n");
- $pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);
-
- if ($pingback_server_url) {
- @ set_time_limit( 60 );
- // Now, the RPC call
- debug_fwrite($log, "Page Linked To: $pagelinkedto \n");
- debug_fwrite($log, 'Page Linked From: ');
- $pagelinkedfrom = get_permalink($post_ID);
- debug_fwrite($log, $pagelinkedfrom."\n");
-
- // using a timeout of 3 seconds should be enough to cover slow servers
- $client = new IXR_Client($pingback_server_url);
- $client->timeout = 3;
- $client->useragent .= ' -- WordPress/' . $wp_version;
-
- // when set to true, this outputs debug messages by itself
- $client->debug = false;
-
- if ( $client->query('pingback.ping', $pagelinkedfrom, $pagelinkedto ) )
- add_ping( $post_ID, $pagelinkedto );
- else
- debug_fwrite($log, "Error.\n Fault code: ".$client->getErrorCode()." : ".$client->getErrorMessage()."\n");
- }
- }
-
- debug_fwrite($log, "\nEND: ".time()."\n****************************\n");
- debug_fclose($log);
-}
-
-function discover_pingback_server_uri($url, $timeout_bytes = 2048) {
- global $wp_version;
-
- $byte_count = 0;
- $contents = '';
- $headers = '';
- $pingback_str_dquote = 'rel="pingback"';
- $pingback_str_squote = 'rel=\'pingback\'';
- $x_pingback_str = 'x-pingback: ';
- $pingback_href_original_pos = 27;
-
- extract(parse_url($url));
-
- if (!isset($host)) {
- // Not an URL. This should never happen.
- return false;
- }
-
- $path = (!isset($path)) ? '/' : $path;
- $path .= (isset($query)) ? '?'.$query : '';
- $port = (isset($port)) ? $port : 80;
-
- // Try to connect to the server at $host
- $fp = @fsockopen($host, $port, $errno, $errstr, 2);
- if (!$fp) {
- // Couldn't open a connection to $host;
- return false;
- }
-
- // Send the GET request
- $request = "GET $path HTTP/1.1\r\nHost: $host\r\nUser-Agent: WordPress/$wp_version \r\n\r\n";
-// ob_end_flush();
- fputs($fp, $request);
-
- // Let's check for an X-Pingback header first
- while (!feof($fp)) {
- $line = fgets($fp, 512);
- if (trim($line) == '') {
- break;
- }
- $headers .= trim($line)."\n";
- $x_pingback_header_offset = strpos(strtolower($headers), $x_pingback_str);
- if ($x_pingback_header_offset) {
- // We got it!
- preg_match('#x-pingback: (.+)#is', $headers, $matches);
- $pingback_server_url = trim($matches[1]);
- return $pingback_server_url;
- }
- if(strpos(strtolower($headers), 'content-type: ')) {
- preg_match('#content-type: (.+)#is', $headers, $matches);
- $content_type = trim($matches[1]);
- }
- }
-
- if (preg_match('#(image|audio|video|model)/#is', $content_type)) {
- // Not an (x)html, sgml, or xml page, no use going further
- return false;
- }
-
- while (!feof($fp)) {
- $line = fgets($fp, 1024);
- $contents .= trim($line);
- $pingback_link_offset_dquote = strpos($contents, $pingback_str_dquote);
- $pingback_link_offset_squote = strpos($contents, $pingback_str_squote);
- if ($pingback_link_offset_dquote || $pingback_link_offset_squote) {
- $quote = ($pingback_link_offset_dquote) ? '"' : '\'';
- $pingback_link_offset = ($quote=='"') ? $pingback_link_offset_dquote : $pingback_link_offset_squote;
- $pingback_href_pos = @strpos($contents, 'href=', $pingback_link_offset);
- $pingback_href_start = $pingback_href_pos+6;
- $pingback_href_end = @strpos($contents, $quote, $pingback_href_start);
- $pingback_server_url_len = $pingback_href_end - $pingback_href_start;
- $pingback_server_url = substr($contents, $pingback_href_start, $pingback_server_url_len);
- // We may find rel="pingback" but an incomplete pingback URI
- if ($pingback_server_url_len > 0) {
- // We got it!
- return $pingback_server_url;
- }
- }
- $byte_count += strlen($line);
- if ($byte_count > $timeout_bytes) {
- // It's no use going further, there probably isn't any pingback
- // server to find in this file. (Prevents loading large files.)
- return false;
- }
- }
-
- // We didn't find anything.
- return false;
-}
-
-function is_local_attachment($url) {
- if ( !strstr($url, get_bloginfo('home') ) )
- return false;
- if ( strstr($url, get_bloginfo('home') . '/?attachment_id=') )
- return true;
- if ( $id = url_to_postid($url) ) {
- $post = & get_post($id);
- if ( 'attachment' == $post->post_type )
- return true;
- }
- return false;
-}
-
-function wp_set_comment_status($comment_id, $comment_status) {
- global $wpdb;
-
- switch($comment_status) {
- case 'hold':
- $query = "UPDATE $wpdb->comments SET comment_approved='0' WHERE comment_ID='$comment_id' LIMIT 1";
- break;
- case 'approve':
- $query = "UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1";
- break;
- case 'spam':
- $query = "UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID='$comment_id' LIMIT 1";
- break;
- case 'delete':
- return wp_delete_comment($comment_id);
- break;
- default:
- return false;
- }
-
- if ($wpdb->query($query)) {
- do_action('wp_set_comment_status', $comment_id, $comment_status);
-
- $comment = get_comment($comment_id);
- $comment_post_ID = $comment->comment_post_ID;
- $c = $wpdb->get_row( "SELECT count(*) as c FROM {$wpdb->comments} WHERE comment_post_ID = '$comment_post_ID' AND comment_approved = '1'" );
- if( is_object( $c ) )
- $wpdb->query( "UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'" );
- return true;
- } else {
- return false;
- }
-}
-
-function wp_get_comment_status($comment_id) {
- global $wpdb;
-
- $result = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
- if ($result == NULL) {
- return 'deleted';
- } else if ($result == '1') {
- return 'approved';
- } else if ($result == '0') {
- return 'unapproved';
- } else if ($result == 'spam') {
- return 'spam';
- } else {
- return false;
- }
-}
-
-function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $comment_type) {
- global $wpdb;
-
- if (1 == get_settings('comment_moderation')) return false; // If moderation is set to manual
-
- if ( (count(explode('http:', $comment)) - 1) >= get_settings('comment_max_links') )
- return false; // Check # of external links
-
- $mod_keys = trim( get_settings('moderation_keys') );
- if ( !empty($mod_keys) ) {
- $words = explode("\n", $mod_keys );
-
- foreach ($words as $word) {
- $word = trim($word);
-
- // Skip empty lines
- if (empty($word)) { continue; }
-
- // Do some escaping magic so that '#' chars in the
- // spam words don't break things:
- $word = preg_quote($word, '#');
-
- $pattern = "#$word#i";
- if ( preg_match($pattern, $author) ) return false;
- if ( preg_match($pattern, $email) ) return false;
- if ( preg_match($pattern, $url) ) return false;
- if ( preg_match($pattern, $comment) ) return false;
- if ( preg_match($pattern, $user_ip) ) return false;
- if ( preg_match($pattern, $user_agent) ) return false;
- }
- }
-
- // Comment whitelisting:
- if ( 1 == get_settings('comment_whitelist')) {
- if ( 'trackback' == $comment_type || 'pingback' == $comment_type ) { // check if domain is in blogroll
- $uri = parse_url($url);
- $domain = $uri['host'];
- $uri = parse_url( get_option('home') );
- $home_domain = $uri['host'];
- if ( $wpdb->get_var("SELECT link_id FROM $wpdb->links WHERE link_url LIKE ('%$domain%') LIMIT 1") || $domain == $home_domain )
- return true;
- else
- return false;
- } elseif( $author != '' && $email != '' ) {
- $ok_to_comment = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_author = '$author' AND comment_author_email = '$email' and comment_approved = '1' LIMIT 1");
- if ( ( 1 == $ok_to_comment ) &&
- ( empty($mod_keys) || false === strpos( $email, $mod_keys) ) )
- return true;
- else
- return false;
- } else {
- return false;
- }
- }
-
- return true;
-}
-
-function get_approved_comments($post_id) {
- global $wpdb;
- return $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post_id AND comment_approved = '1' ORDER BY comment_date");
-}
-
-?>
diff --git a/wp-inst/wp-includes/comment.php b/wp-inst/wp-includes/comment.php
index a5acdd3..931a8a5 100644
--- a/wp-inst/wp-includes/comment.php
+++ b/wp-inst/wp-includes/comment.php
@@ -60,7 +60,9 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $
function get_approved_comments($post_id) {
global $wpdb;
- return $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post_id AND comment_approved = '1' ORDER BY comment_date");
+
+ $post_id = (int) $post_id;
+ return $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = '$post_id' AND comment_approved = '1' ORDER BY comment_date");
}
// Retrieves comment data given a comment ID or comment object.
diff --git a/wp-inst/wp-includes/default-filters.php b/wp-inst/wp-includes/default-filters.php
index a3a4e20..8500a0c 100644
--- a/wp-inst/wp-includes/default-filters.php
+++ b/wp-inst/wp-includes/default-filters.php
@@ -47,6 +47,38 @@ add_filter('comment_text', 'convert_smilies', 20);
add_filter('comment_excerpt', 'convert_chars');
+// Categories
+add_filter('pre_category_name', 'strip_tags');
+add_filter('pre_category_name', 'trim');
+add_filter('pre_category_name', 'wp_filter_kses');
+add_filter('pre_category_name', 'wp_specialchars', 30);
+add_filter('pre_category_description', 'wp_filter_kses');
+
+// Users
+add_filter('pre_user_display_name', 'strip_tags');
+add_filter('pre_user_display_name', 'trim');
+add_filter('pre_user_display_name', 'wp_filter_kses');
+add_filter('pre_user_display_name', 'wp_specialchars', 30);
+add_filter('pre_user_first_name', 'strip_tags');
+add_filter('pre_user_first_name', 'trim');
+add_filter('pre_user_first_name', 'wp_filter_kses');
+add_filter('pre_user_first_name', 'wp_specialchars', 30);
+add_filter('pre_user_last_name', 'strip_tags');
+add_filter('pre_user_last_name', 'trim');
+add_filter('pre_user_last_name', 'wp_filter_kses');
+add_filter('pre_user_last_name', 'wp_specialchars', 30);
+add_filter('pre_user_nickname', 'strip_tags');
+add_filter('pre_user_nickname', 'trim');
+add_filter('pre_user_nickname', 'wp_filter_kses');
+add_filter('pre_user_nickname', 'wp_specialchars', 30);
+add_filter('pre_user_description', 'trim');
+add_filter('pre_user_description', 'wp_filter_kses');
+add_filter('pre_user_url', 'strip_tags');
+add_filter('pre_user_url', 'trim');
+add_filter('pre_user_url', 'clean_url');
+add_filter('pre_user_email', 'trim');
+add_filter('pre_user_email', 'sanitize_email');
+
// Places to balance tags on input
add_filter('content_save_pre', 'balanceTags', 50);
add_filter('excerpt_save_pre', 'balanceTags', 50);
@@ -86,6 +118,7 @@ add_filter('option_ping_sites', 'privacy_ping_filter');
add_action('wp_head', 'rsd_link');
add_action('publish_future_post', 'wp_publish_post', 10, 1);
add_action('wp_head', 'noindex', 1);
+add_action('wp_head', 'wp_print_scripts');
if(!defined('DOING_CRON'))
add_action('init', 'wp_cron');
add_action('do_feed_rdf', 'do_feed_rdf', 10, 1);
@@ -93,4 +126,5 @@ add_action('do_feed_rss', 'do_feed_rss', 10, 1);
add_action('do_feed_rss2', 'do_feed_rss2', 10, 1);
add_action('do_feed_atom', 'do_feed_atom', 10, 1);
add_action('do_pings', 'do_all_pings', 10, 1);
+add_action('do_robots', 'do_robots');
?>
diff --git a/wp-inst/wp-includes/deprecated.php b/wp-inst/wp-includes/deprecated.php
index 8584932..be08e24 100644
--- a/wp-inst/wp-includes/deprecated.php
+++ b/wp-inst/wp-includes/deprecated.php
@@ -452,4 +452,22 @@ function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = '
return wp_dropdown_categories($query);
}
+// Deprecated. Use wp_print_scripts() or WP_Scripts instead.
+function tinymce_include() {
+ wp_print_script( 'wp_tiny_mce' );
+}
+
+function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
+ $args = compact('optioncount', 'exclude_admin', 'show_fullname', 'hide_empty', 'feed', 'feed_image');
+ return wp_list_authors($args);
+}
+
+function wp_get_post_cats($blogid = '1', $post_ID = 0) {
+ return wp_get_post_categories($post_ID);
+}
+
+function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
+ return wp_set_post_categories($post_ID, $post_categories);
+}
+
?>
diff --git a/wp-inst/wp-includes/feed-functions.php b/wp-inst/wp-includes/feed-functions.php
index 40e6778..728a6fa 100644
--- a/wp-inst/wp-includes/feed-functions.php
+++ b/wp-inst/wp-includes/feed-functions.php
@@ -2,7 +2,7 @@
function get_bloginfo_rss($show = '') {
$info = strip_tags(get_bloginfo($show));
- return convert_chars($info);
+ return apply_filters('bloginfo_rss', convert_chars($info));
}
function bloginfo_rss($show = '') {
diff --git a/wp-inst/wp-includes/functions-compat.php b/wp-inst/wp-includes/functions-compat.php
index 25bef35..0eb8c42 100644
--- a/wp-inst/wp-includes/functions-compat.php
+++ b/wp-inst/wp-includes/functions-compat.php
@@ -73,7 +73,7 @@ if (!defined('CASE_UPPER')) {
* @link http://php.net/function.array_change_key_case
* @author Stephan Schmidt <schst@php.net>
* @author Aidan Lister <aidan@php.net>
- * @version $Revision: 3689 $
+ * @version $Revision: 3758 $
* @since PHP 4.2.0
* @require PHP 4.0.0 (user_error)
*/
@@ -98,4 +98,17 @@ if (!function_exists('array_change_key_case')) {
}
}
+// From php.net
+if(!function_exists('http_build_query')) {
+ function http_build_query( $formdata, $numeric_prefix = null, $key = null ) {
+ $res = array();
+ foreach ((array)$formdata as $k=>$v) {
+ $tmp_key = urlencode(is_int($k) ? $numeric_prefix.$k : $k);
+ if ($key) $tmp_key = $key.'['.$tmp_key.']';
+ $res[] = ( ( is_array($v) || is_object($v) ) ? http_build_query($v, null, $tmp_key) : $tmp_key."=".urlencode($v) );
+ }
+ $separator = ini_get('arg_separator.output');
+ return implode($separator, $res);
+ }
+}
?>
diff --git a/wp-inst/wp-includes/functions-formatting.php b/wp-inst/wp-includes/functions-formatting.php
index 8b4f9da..5af4df5 100644
--- a/wp-inst/wp-includes/functions-formatting.php
+++ b/wp-inst/wp-includes/functions-formatting.php
@@ -278,7 +278,7 @@ function sanitize_user( $username, $strict = false ) {
// If strict, reduce to ASCII for max portability.
if ( $strict )
- $username = preg_replace('|[^a-z0-9 _.-@]|i', '', $username);
+ $username = preg_replace('|[^a-z0-9 _.\-@]|i', '', $username);
return apply_filters('sanitize_user', $username, $raw_username, $strict);
}
@@ -404,9 +404,9 @@ function funky_javascript_fix($text) {
Added Cleaning Hooks
1.0 First Version
*/
-function balanceTags($text, $is_comment = 0) {
+function balanceTags($text, $is_comment = 0, $force = false) {
- if ( get_option('use_balanceTags') == 0)
+ if ( !$force && get_option('use_balanceTags') == 0 )
return $text;
$tagstack = array(); $stacksize = 0; $tagqueue = ''; $newtext = '';
@@ -1040,4 +1040,9 @@ function htmlentities2($myHTML) {
return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&amp;" , strtr($myHTML, $translation_table));
}
+// Escape single quotes, specialchar double quotes, and fix line endings.
+function js_escape($text) {
+ $text = wp_specialchars($text, 'double');
+ return preg_replace("/\r?\n/", "\\n", addslashes($text));
+}
?>
diff --git a/wp-inst/wp-includes/functions-post.php b/wp-inst/wp-includes/functions-post.php
index 9513c62..7c2e497 100644
--- a/wp-inst/wp-includes/functions-post.php
+++ b/wp-inst/wp-includes/functions-post.php
@@ -161,7 +161,7 @@ function wp_insert_post($postarr = array()) {
$wpdb->query( "UPDATE $wpdb->posts SET post_name = '$post_name' WHERE ID = '$post_ID'" );
}
- wp_set_post_cats('', $post_ID, $post_category);
+ wp_set_post_categories($post_ID, $post_category);
if ( 'page' == $post_type ) {
clean_page_cache($post_ID);
@@ -208,6 +208,9 @@ function wp_insert_post($postarr = array()) {
if ( !empty($page_template) )
if ( ! update_post_meta($post_ID, '_wp_page_template', $page_template))
add_post_meta($post_ID, '_wp_page_template', $page_template, true);
+
+ if ( $post_status == 'publish' )
+ do_action('publish_page', $post_ID);
}
if ( 'future' == $post_status ) {
@@ -345,10 +348,10 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) {
$wpdb->query( "UPDATE $wpdb->posts SET post_name = '$post_name' WHERE ID = '$post_ID'" );
}
- wp_set_post_cats('', $post_ID, $post_category);
+ wp_set_post_categories($post_ID, $post_category);
if ( $file )
- add_post_meta($post_ID, '_wp_attached_file', $file);
+ add_post_meta($post_ID, '_wp_attached_file', $file );
clean_post_cache($post_ID);
@@ -365,7 +368,7 @@ function wp_delete_attachment($postid) {
global $wpdb;
$postid = (int) $postid;
- if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = $postid") )
+ if ( !$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE ID = '$postid'") )
return $post;
if ( 'attachment' != $post->post_type )
@@ -374,13 +377,13 @@ function wp_delete_attachment($postid) {
$meta = get_post_meta($postid, '_wp_attachment_metadata', true);
$file = get_post_meta($postid, '_wp_attached_file', true);
- $wpdb->query("DELETE FROM $wpdb->posts WHERE ID = $postid");
+ $wpdb->query("DELETE FROM $wpdb->posts WHERE ID = '$postid'");
- $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID = $postid");
+ $wpdb->query("DELETE FROM $wpdb->comments WHERE comment_post_ID = '$postid'");
- $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id = $postid");
+ $wpdb->query("DELETE FROM $wpdb->post2cat WHERE post_id = '$postid'");
- $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = $postid");
+ $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$postid'");
if ( ! empty($meta['thumb']) ) {
// Don't delete the thumb if another attachment uses it
@@ -408,10 +411,10 @@ function wp_get_single_post($postid = 0, $mode = OBJECT) {
// Set categories
if($mode == OBJECT) {
- $post->post_category = wp_get_post_cats('',$postid);
+ $post->post_category = wp_get_post_categories($postid);
}
else {
- $post['post_category'] = wp_get_post_cats('',$postid);
+ $post['post_category'] = wp_get_post_categories($postid);
}
return $post;
@@ -483,12 +486,14 @@ function wp_publish_post($post_id) {
return wp_update_post(array('post_status' => 'publish', 'ID' => $post_id));
}
-function wp_get_post_cats($blogid = '1', $post_ID = 0) {
+function wp_get_post_categories($post_ID = 0) {
global $wpdb;
+ $post_ID = (int) $post_ID;
+
$sql = "SELECT category_id
FROM $wpdb->post2cat
- WHERE post_id = $post_ID
+ WHERE post_id = '$post_ID'
ORDER BY category_id";
$result = $wpdb->get_col($sql);
@@ -499,7 +504,7 @@ function wp_get_post_cats($blogid = '1', $post_ID = 0) {
return array_unique($result);
}
-function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array()) {
+function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
global $wpdb;
// If $post_categories isn't already an array, make it one:
if (!is_array($post_categories) || 0 == count($post_categories))
@@ -550,7 +555,7 @@ function wp_set_post_cats($blogid = '1', $post_ID = 0, $post_categories = array(
$wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
wp_cache_delete($cat_id, 'category');
}
-} // wp_set_post_cats()
+} // wp_set_post_categories()
function wp_delete_post($postid = 0) {
global $wpdb, $wp_rewrite;
@@ -565,7 +570,7 @@ function wp_delete_post($postid = 0) {
do_action('delete_post', $postid);
if ( 'publish' == $post->post_status && 'post' == $post->post_type ) {
- $categories = wp_get_post_cats('', $post->ID);
+ $categories = wp_get_post_categories($post->ID);
if( is_array( $categories ) ) {
foreach ( $categories as $cat_id ) {
$wpdb->query("UPDATE $wpdb->categories SET category_count = category_count - 1 WHERE cat_ID = '$cat_id'");
@@ -602,25 +607,6 @@ function post_permalink($post_id = 0, $mode = '') { // $mode legacy
return get_permalink($post_id);
}
-// Get the name of a category from its ID
-function get_cat_name($cat_id) {
- global $wpdb;
-
- $cat_id -= 0; // force numeric
- $name = $wpdb->get_var("SELECT cat_name FROM $wpdb->categories WHERE cat_ID=$cat_id");
-
- return $name;
-}
-
-// Get the ID of a category from its name
-function get_cat_ID($cat_name='General') {
- global $wpdb;
-
- $cid = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'");
-
- return $cid?$cid:1; // default to cat 1
-}
-
// Get author's preferred display name
function get_author_name( $auth_id ) {
$authordata = get_userdata( $auth_id );
@@ -1035,18 +1021,6 @@ function do_all_pings() {
}
/**
- * Places two script links in <head>: one to get tinyMCE (big), one to configure and start it (small)
- */
-function tinymce_include() {
- $ver = '04162006';
- $src1 = get_settings('siteurl') . "/wp-includes/js/tinymce/tiny_mce_gzip.php?ver=$ver";
- $src2 = get_settings('siteurl') . "/wp-includes/js/tinymce/tiny_mce_config.php?ver=$ver";
-
- echo "<script type='text/javascript' src='$src1'></script>\n";
- echo "<script type='text/javascript' src='$src2'></script>\n";
-}
-
-/**
* Places a textarea according to the current user's preferences, filled with $content.
* Also places a script block that enables tabbing between Title and Content.
*
diff --git a/wp-inst/wp-includes/functions.php b/wp-inst/wp-includes/functions.php
index 94536ff..64f795e 100644
--- a/wp-inst/wp-includes/functions.php
+++ b/wp-inst/wp-includes/functions.php
@@ -195,12 +195,6 @@ function maybe_unserialize($original) {
function get_settings($setting) {
global $wpdb, $switched, $current_blog;
- if( ( $setting == 'siteurl' || $setting == 'home' ) && isset( $_SERVER[ 'HTTPS' ] ) == false && 1 == $current_blog->domain_mapping ) {
- if( is_redirected_domain() ) {
- return "http://" . $_SERVER[ 'HTTP_HOST' ];
- }
- }
-
if ( $switched == false && defined('WP_INSTALLING') == false && $_REQUEST['nomemcache'] != 'all' && $_REQUEST['nomemcache'] != $setting ) {
$value = wp_cache_get($setting, 'options');
} else {
@@ -649,86 +643,6 @@ function &get_page(&$page, $output = OBJECT) {
}
}
-function get_category_by_path($category_path, $full_match = true, $output = OBJECT) {
- global $wpdb;
- $category_path = rawurlencode(urldecode($category_path));
- $category_path = str_replace('%2F', '/', $category_path);
- $category_path = str_replace('%20', ' ', $category_path);
- $category_paths = '/' . trim($category_path, '/');
- $leaf_path = sanitize_title(basename($category_paths));
- $category_paths = explode('/', $category_paths);
- foreach($category_paths as $pathdir)
- $full_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
-
- $categories = $wpdb->get_results("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE category_nicename = '$leaf_path'");
-
- if ( empty($categories) )
- return NULL;
-
- foreach ($categories as $category) {
- $path = '/' . $leaf_path;
- $curcategory = $category;
- while ($curcategory->category_parent != 0) {
- $curcategory = $wpdb->get_row("SELECT cat_ID, category_nicename, category_parent FROM $wpdb->categories WHERE cat_ID = '$curcategory->category_parent'");
- $path = '/' . $curcategory->category_nicename . $path;
- }
-
- if ( $path == $full_path )
- return get_category($category->cat_ID, $output);
- }
-
- // If full matching is not required, return the first cat that matches the leaf.
- if ( ! $full_match )
- return get_category($categories[0]->cat_ID, $output);
-
- return NULL;
-}
-
-// Retrieves category data given a category ID or category object.
-// Handles category caching.
-function &get_category(&$category, $output = OBJECT) {
- global $wpdb;
-
- if ( empty($category) )
- return null;
-
- if ( is_object($category) ) {
- wp_cache_add($category->cat_ID, $category, 'category');
- $_category = $category;
- } else {
- if ( ! $_category = wp_cache_get($category, 'category') ) {
- $_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category' LIMIT 1");
- wp_cache_add($category, $_category, 'category');
- }
- }
-
- if ( $output == OBJECT ) {
- return $_category;
- } elseif ( $output == ARRAY_A ) {
- return get_object_vars($_category);
- } elseif ( $output == ARRAY_N ) {
- return array_values(get_object_vars($_category));
- } else {
- return $_category;
- }
-}
-
-function get_catname($cat_ID) {
- $category = &get_category($cat_ID);
- return $category->cat_name;
-}
-
-function get_all_category_ids() {
- global $wpdb;
-
- if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category') ) {
- $cat_ids = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
- wp_cache_add('all_category_ids', $cat_ids, 'category');
- }
-
- return $cat_ids;
-}
-
function get_all_page_ids() {
global $wpdb;
@@ -987,15 +901,13 @@ function wp_get_http_headers( $url, $red = 1 ) {
$headers["$key"] = $matches[2][$i];
}
- $code = preg_replace('/.*?(\d{3}).*/i', '$1', $response);
-
- $headers['status_code'] = $code;
-
- if ( '302' == $code || '301' == $code )
- return wp_get_http_headers( $url, ++$red );
-
preg_match('/.*([0-9]{3}).*/', $response, $return);
$headers['response'] = $return[1]; // HTTP response code eg 204, 200, 404
+
+ $code = $headers['response'];
+ if ( ('302' == $code || '301' == $code) && isset($headers['location']) )
+ return wp_get_http_headers( $headers['location'], ++$red );
+
return $headers;
}
@@ -1140,6 +1052,7 @@ function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args
// rebuild the list of filters
if ( isset($wp_filter[$tag]["$priority"]) ) {
+ $new_function_list = array();
foreach($wp_filter[$tag]["$priority"] as $filter) {
if ( $filter['function'] != $function_to_remove ) {
$new_function_list[] = $filter;
@@ -1690,6 +1603,16 @@ function do_feed_atom() {
load_template(ABSPATH . 'wp-atom.php');
}
+function do_robots() {
+ if ( '1' != get_option('blog_public') ) {
+ echo "User-agent: *\n";
+ echo "Disallow: /\n";
+ } else {
+ echo "User-agent: *\n";
+ echo "Disallow:\n";
+ }
+}
+
function is_blog_installed() {
global $wpdb;
$wpdb->hide_errors();
@@ -1698,4 +1621,12 @@ function is_blog_installed() {
return $installed;
}
+function wp_nonce_url($actionurl, $action = -1) {
+ return add_query_arg('_wpnonce', wp_create_nonce($action), $actionurl);
+}
+
+function wp_nonce_field($action = -1) {
+ echo '<input type="hidden" name="_wpnonce" value="' . wp_create_nonce($action) . '" />';
+}
+
?>
diff --git a/wp-inst/wp-includes/js/fat.js b/wp-inst/wp-includes/js/fat.js
index ded85ae..01f1b42 100644
--- a/wp-inst/wp-includes/js/fat.js
+++ b/wp-inst/wp-includes/js/fat.js
@@ -11,7 +11,7 @@ var Fat = {
b = b.toString(16); if (b.length == 1) b = '0' + b;
return "#" + r + g + b;
},
- fade_all : function ()
+ fade_all : function (dur)
{
var a = document.getElementsByTagName("*");
for (var i = 0; i < a.length; i++)
@@ -21,7 +21,7 @@ var Fat = {
if (r)
{
if (!r[1]) r[1] = "";
- if (o.id) Fat.fade_element(o.id,null,null,"#"+r[1]);
+ if (o.id) Fat.fade_element(o.id,null,dur,"#"+r[1]);
}
}
},
diff --git a/wp-inst/wp-includes/js/tinymce/langs/en.js b/wp-inst/wp-includes/js/tinymce/langs/en.js
index 6d74cd8..c093eaf 100644
--- a/wp-inst/wp-includes/js/tinymce/langs/en.js
+++ b/wp-inst/wp-includes/js/tinymce/langs/en.js
@@ -1,39 +1,41 @@
// UK lang variables
-tinyMCELang['lang_bold_desc'] = 'Bold (Alt+b)';
-tinyMCELang['lang_italic_desc'] = 'Italic (Alt+i)';
-tinyMCELang['lang_underline_desc'] = 'Underline';
-tinyMCELang['lang_striketrough_desc'] = 'Striketrough (Alt-d)';
-tinyMCELang['lang_justifyleft_desc'] = 'Align left (Alt-f)';
-tinyMCELang['lang_justifycenter_desc'] = 'Align center (Alt-c)';
-tinyMCELang['lang_justifyright_desc'] = 'Align right (Alt-r)';
-tinyMCELang['lang_justifyfull_desc'] = 'Align full';
-tinyMCELang['lang_bullist_desc'] = 'Unordered list (Alt-l)';
-tinyMCELang['lang_numlist_desc'] = 'Ordered list (Alt-o)';
-tinyMCELang['lang_outdent_desc'] = 'Outdent (Alt-w)';
-tinyMCELang['lang_indent_desc'] = 'Indent/Blockquote (Alt-q)';
-tinyMCELang['lang_undo_desc'] = 'Undo (Alt-u)';
-tinyMCELang['lang_redo_desc'] = 'Redo (Alt-y)';
-tinyMCELang['lang_link_desc'] = 'Insert/edit link (Alt-a)';
-tinyMCELang['lang_unlink_desc'] = 'Unlink (Alt-s)';
-tinyMCELang['lang_image_desc'] = 'Insert/edit image (Alt-m)';
-tinyMCELang['lang_cleanup_desc'] = 'Cleanup messy code';
-tinyMCELang['lang_focus_alert'] = 'A editor instance must be focused before using this command.';
-tinyMCELang['lang_edit_confirm'] = 'Do you want to use the WYSIWYG mode for this textarea?';
-tinyMCELang['lang_insert_link_title'] = 'Insert/edit link';
-tinyMCELang['lang_insert'] = 'Insert';
-tinyMCELang['lang_update'] = 'Update';
-tinyMCELang['lang_cancel'] = 'Cancel';
-tinyMCELang['lang_insert_link_url'] = 'Link URL';
-tinyMCELang['lang_insert_link_target'] = 'Target';
-tinyMCELang['lang_insert_link_target_same'] = 'Open link in the same window';
-tinyMCELang['lang_insert_link_target_blank'] = 'Open link in a new window';
-tinyMCELang['lang_insert_image_title'] = 'Insert/edit image';
-tinyMCELang['lang_insert_image_src'] = 'Image URL';
-tinyMCELang['lang_insert_image_alt'] = 'Image description';
-tinyMCELang['lang_help_desc'] = 'Help';
-tinyMCELang['lang_bold_img'] = "bold.gif";
-tinyMCELang['lang_italic_img'] = "italic.gif";
-tinyMCELang['lang_underline_img'] = "underline.gif";
-tinyMCELang['lang_clipboard_msg'] = 'Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?';
-tinyMCELang['lang_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.';
+tinyMCE.addToLang('',{
+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',
+focus_alert : 'A editor instance must be focused before using this command.',
+edit_confirm : 'Do you want to use the WYSIWYG mode for this textarea?',
+insert_link_title : 'Insert/edit link',
+insert : 'Insert',
+update : 'Update',
+cancel : 'Cancel',
+insert_link_url : 'Link URL',
+insert_link_target : 'Target',
+insert_link_target_same : 'Open link in the same window',
+insert_link_target_blank : 'Open link in a new window',
+insert_image_title : 'Insert/edit image',
+insert_image_src : 'Image URL',
+insert_image_alt : 'Image description',
+help_desc : 'Help',
+bold_img : "bold.gif",
+italic_img : "italic.gif",
+underline_img : "underline.gif",
+clipboard_msg : 'Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?',
+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.'
+});
diff --git a/wp-inst/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js b/wp-inst/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js
index 28d7ae7..4b88d2e 100644
--- a/wp-inst/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js
+++ b/wp-inst/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js
@@ -1,2 +1,48 @@
+/**
+ * $RCSfile: editor_plugin_src.js,v $
+ * $Revision: 1.11 $
+ * $Date: 2006/03/22 12:21:21 $
+ *
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
+ */
+
/* Import plugin specific language pack */
- tinyMCE.importPluginLanguagePack('autosave','en,sv,cs,he,no,hu,de,da,ru,ru_KOI8-R,ru_UTF-8,fi,cy,es,is,pl');function TinyMCE_autosave_getInfo(){return{longname:'Auto save',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};};function TinyMCE_autosave_beforeUnloadHandler(){var msg=tinyMCE.getLang("lang_autosave_unload_msg");var anyDirty=false;for(var n in tinyMCE.instances){var inst=tinyMCE.instances[n];if(!tinyMCE.isInstance(inst))continue;if(inst.isDirty())return msg;}return;}window.onbeforeunload=TinyMCE_autosave_beforeUnloadHandler; \ No newline at end of file
+tinyMCE.importPluginLanguagePack('autosave', 'en,tr,sv,cs,he,nb,hu,de,da,ru,ru_KOI8-R,ru_UTF-8,nn,fi,cy,es,is,pl,pt_br');
+
+var TinyMCE_AutoSavePlugin = {
+ getInfo : function() {
+ return {
+ longname : 'Auto save',
+ author : 'Moxiecode Systems',
+ authorurl : 'http://tinymce.moxiecode.com',
+ infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html',
+ version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
+ };
+ },
+
+ // Private plugin internal methods
+
+ _beforeUnloadHandler : function() {
+ var n, inst, anyDirty = false, msg = tinyMCE.getLang("lang_autosave_unload_msg");
+
+ if (tinyMCE.getParam("fullscreen_is_enabled"))
+ return;
+
+ for (n in tinyMCE.instances) {
+ inst = tinyMCE.instances[n];
+
+ if (!tinyMCE.isInstance(inst))
+ continue;
+
+ if (inst.isDirty())
+ return msg;
+ }
+
+ return;
+ }
+};
+
+window.onbeforeunload = TinyMCE_AutoSavePlugin._beforeUnloadHandler;
+
+tinyMCE.addPlugin("autosave", TinyMCE_AutoSavePlugin);
diff --git a/wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css b/wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css
index e69de29..43be823 100644
--- a/wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css
+++ b/wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css
@@ -0,0 +1,69 @@
+/* Window classes */
+
+.mceWindow {
+ position: absolute;
+ left: 0;
+ top: 0;
+ border: 1px solid black;
+ background-color: #D4D0C8;
+}
+
+.mceWindowHead {
+ background-color: #334F8D;
+ width: 100%;
+ height: 18px;
+ cursor: move;
+ overflow: hidden;
+}
+
+.mceWindowBody {
+ clear: both;
+ background-color: white;
+}
+
+.mceWindowStatusbar {
+ background-color: #D4D0C8;
+ height: 12px;
+ border-top: 1px solid black;
+}
+
+.mceWindowTitle {
+ float: left;
+ font-family: "MS Sans Serif";
+ font-size: 9pt;
+ font-weight: bold;
+ line-height: 18px;
+ color: white;
+ margin-left: 2px;
+ overflow: hidden;
+}
+
+.mceWindowHeadTools {
+ margin-right: 2px;
+}
+
+.mceWindowClose, .mceWindowMinimize, .mceWindowMaximize {
+ display: block;
+ float: right;
+ overflow: hidden;
+ margin-top: 2px;
+}
+
+.mceWindowClose {
+ margin-left: 2px;
+}
+
+.mceWindowMinimize {
+}
+
+.mceWindowMaximize {
+}
+
+.mceWindowResize {
+ display: block;
+ float: right;
+ overflow: hidden;
+ cursor: se-resize;
+ width: 12px;
+ height: 12px;
+}
diff --git a/wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js b/wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
index e69de29..74d1805 100644
--- a/wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
+++ b/wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
@@ -0,0 +1,665 @@
+/**
+ * $RCSfile: editor_plugin_src.js,v $
+ * $Revision: 1.8 $
+ * $Date: 2006/02/06 20:02:38 $
+ *
+ * Moxiecode DHTML Windows script.
+ *
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
+ */
+
+// Patch openWindow, closeWindow TinyMCE functions
+
+var TinyMCE_InlinePopupsPlugin = {
+ getInfo : function() {
+ return {
+ longname : 'Inline Popups',
+ author : 'Moxiecode Systems',
+ authorurl : 'http://tinymce.moxiecode.com',
+ infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_inlinepopups.html',
+ version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
+ };
+ }
+};
+
+tinyMCE.addPlugin("inlinepopups", TinyMCE_InlinePopupsPlugin);
+
+// Patch openWindow, closeWindow TinyMCE functions
+
+TinyMCE_Engine.prototype.orgOpenWindow = TinyMCE_Engine.prototype.openWindow;
+
+TinyMCE_Engine.prototype.openWindow = function(template, args) {
+ // Does the caller support inline
+ if (args['inline'] != "yes" || tinyMCE.isOpera || tinyMCE.getParam("plugins").indexOf('inlinepopups') == -1) {
+ mcWindows.selectedWindow = null;
+ args['mce_inside_iframe'] = false;
+ this.orgOpenWindow(template, args);
+ return;
+ }
+
+ var url, resizable, scrollbars;
+
+ args['mce_inside_iframe'] = true;
+ tinyMCE.windowArgs = args;
+
+ if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1)
+ url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file'];
+ else
+ url = template['file'];
+
+ if (!(width = parseInt(template['width'])))
+ width = 320;
+
+ if (!(height = parseInt(template['height'])))
+ height = 200;
+
+ resizable = (args && args['resizable']) ? args['resizable'] : "no";
+ scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no";
+
+ height += 18;
+
+ // Replace all args as variables in URL
+ for (var name in args) {
+ if (typeof(args[name]) == 'function')
+ continue;
+
+ url = tinyMCE.replaceVar(url, name, escape(args[name]));
+ }
+
+ var elm = document.getElementById(this.selectedInstance.editorId + '_parent');
+ var pos = tinyMCE.getAbsPosition(elm);
+
+ // Center div in editor area
+ pos.absLeft += Math.round((elm.firstChild.clientWidth / 2) - (width / 2));
+ pos.absTop += Math.round((elm.firstChild.clientHeight / 2) - (height / 2));
+
+ url += tinyMCE.settings['imp_version'] ? (url.indexOf('?')==-1?'?':'&') + 'ver=' + tinyMCE.settings['imp_version'] : '';
+
+ mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop);
+};
+
+TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow;
+
+TinyMCE_Engine.prototype.closeWindow = function(win) {
+ if (mcWindows.selectedWindow != null)
+ mcWindows.selectedWindow.close();
+ else
+ this.orgCloseWindow(win);
+};
+
+TinyMCE_Engine.prototype.setWindowTitle = function(win_ref, title) {
+ for (var n in mcWindows.windows) {
+ var win = mcWindows.windows[n];
+ if (typeof(win) == 'function')
+ continue;
+
+ if (win_ref.name == win.id + "_iframe")
+ window.frames[win.id + "_iframe"].document.getElementById(win.id + '_title').innerHTML = title;
+ }
+};
+
+// * * * * * TinyMCE_Windows classes below
+
+// Windows handler
+function TinyMCE_Windows() {
+ this.settings = new Array();
+ this.windows = new Array();
+ this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
+ this.isGecko = navigator.userAgent.indexOf('Gecko') != -1;
+ this.isSafari = navigator.userAgent.indexOf('Safari') != -1;
+ this.isMac = navigator.userAgent.indexOf('Mac') != -1;
+ this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1);
+ this.action = "none";
+ this.selectedWindow = null;
+ this.lastSelectedWindow = null;
+ this.zindex = 100;
+ this.mouseDownScreenX = 0;
+ this.mouseDownScreenY = 0;
+ this.mouseDownLayerX = 0;
+ this.mouseDownLayerY = 0;
+ this.mouseDownWidth = 0;
+ this.mouseDownHeight = 0;
+ this.idCounter = 0;
+};
+
+TinyMCE_Windows.prototype.init = function(settings) {
+ this.settings = settings;
+
+ if (this.isMSIE)
+ this.addEvent(document, "mousemove", mcWindows.eventDispatcher);
+ else
+ this.addEvent(window, "mousemove", mcWindows.eventDispatcher);
+
+ this.addEvent(document, "mouseup", mcWindows.eventDispatcher);
+
+ this.doc = document;
+};
+
+TinyMCE_Windows.prototype.getParam = function(name, default_value) {
+ var value = null;
+
+ value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
+
+ // Fix bool values
+ if (value == "true" || value == "false")
+ return (value == "true");
+
+ return value;
+};
+
+TinyMCE_Windows.prototype.eventDispatcher = function(e) {
+ e = typeof(e) == "undefined" ? window.event : e;
+
+ if (mcWindows.selectedWindow == null)
+ return;
+
+ // Switch focus
+ if (mcWindows.isGecko && e.type == "mousedown") {
+ var elm = e.currentTarget;
+
+ for (var n in mcWindows.windows) {
+ var win = mcWindows.windows[n];
+
+ if (win.headElement == elm || win.resizeElement == elm) {
+ win.focus();
+ break;
+ }
+ }
+ }
+
+ switch (e.type) {
+ case "mousemove":
+ mcWindows.selectedWindow.onMouseMove(e);
+ break;
+
+ case "mouseup":
+ mcWindows.selectedWindow.onMouseUp(e);
+ break;
+
+ case "mousedown":
+ mcWindows.selectedWindow.onMouseDown(e);
+ break;
+
+ case "focus":
+ mcWindows.selectedWindow.onFocus(e);
+ break;
+ }
+};
+
+TinyMCE_Windows.prototype.addEvent = function(obj, name, handler) {
+ if (this.isMSIE)
+ obj.attachEvent("on" + name, handler);
+ else
+ obj.addEventListener(name, handler, true);
+};
+
+TinyMCE_Windows.prototype.cancelEvent = function(e) {
+ if (this.isMSIE) {
+ e.returnValue = false;
+ e.cancelBubble = true;
+ } else
+ e.preventDefault();
+};
+
+TinyMCE_Windows.prototype.parseFeatures = function(opts) {
+ // Cleanup the options
+ opts = opts.toLowerCase();
+ opts = opts.replace(/;/g, ",");
+ opts = opts.replace(/[^0-9a-z=,]/g, "");
+
+ var optionChunks = opts.split(',');
+ var options = new Array();
+
+ options['left'] = "10";
+ options['top'] = "10";
+ options['width'] = "300";
+ options['height'] = "300";
+ options['resizable'] = "yes";
+ options['minimizable'] = "yes";
+ options['maximizable'] = "yes";
+ options['close'] = "yes";
+ options['movable'] = "yes";
+ options['statusbar'] = "yes";
+ options['scrollbars'] = "auto";
+ options['modal'] = "no";
+
+ if (opts == "")
+ return options;
+
+ for (var i=0; i<optionChunks.length; i++) {
+ var parts = optionChunks[i].split('=');
+
+ if (parts.length == 2)
+ options[parts[0]] = parts[1];
+ }
+
+ options['left'] = parseInt(options['left']);
+ options['top'] = parseInt(options['top']);
+ options['width'] = parseInt(options['width']);
+ options['height'] = parseInt(options['height']);
+
+ return options;
+};
+
+TinyMCE_Windows.prototype.open = function(url, name, features) {
+ this.lastSelectedWindow = this.selectedWindow;
+
+ var win = new TinyMCE_Window();
+ var winDiv, html = "", id;
+ var imgPath = this.getParam("images_path");
+
+ features = this.parseFeatures(features);
+
+ // Create div
+ id = "mcWindow_" + name;
+ win.deltaHeight = 18;
+
+ if (features['statusbar'] == "yes") {
+ win.deltaHeight += 13;
+
+ if (this.isMSIE)
+ win.deltaHeight += 1;
+ }
+
+ width = parseInt(features['width']);
+ height = parseInt(features['height'])-win.deltaHeight;
+
+ if (this.isMSIE)
+ width -= 2;
+
+ // Setup first part of window
+ win.id = id;
+ win.url = url;
+ win.name = name;
+ win.features = features;
+ this.windows[name] = win;
+
+ iframeWidth = width;
+ iframeHeight = height;
+
+ // Create inner content
+ html += '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
+ html += '<html>';
+ html += '<head>';
+ html += '<title>Wrapper iframe</title>';
+ html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
+ html += '<link href="' + this.getParam("css_file") + '" rel="stylesheet" type="text/css" />';
+ if ( this.isMac ) html += '<style type="text/css">.mceWindowTitle{float:none;margin:0;text-align:center;}.mceWindowClose{float:none;position:absolute;left:0px;top:0px;}</style>';
+ html += '</head>';
+ html += '<body onload="parent.mcWindows.onLoad(\'' + name + '\');">';
+
+ html += '<div id="' + id + '_container" class="mceWindow">';
+ html += '<div id="' + id + '_head" class="mceWindowHead" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';
+ html += ' <div id="' + id + '_title" class="mceWindowTitle"';
+ html += ' onselectstart="return false;" unselectable="on" style="-moz-user-select: none !important;"></div>';
+ html += ' <div class="mceWindowHeadTools">';
+ html += ' <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].close();" target="_self" onmousedown="return false;" class="mceWindowClose"><img border="0" src="' + imgPath + '/window_close.gif" /></a>';
+// html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].maximize();" target="_self" onmousedown="return false;" class="mceWindowMaximize"></a>';
+// html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" target="_self" onmousedown="return false;" class="mceWindowMinimize"></a>';
+ html += ' </div>';
+ html += '</div><div id="' + id + '_body" class="mceWindowBody" style="width: ' + width + 'px; height: ' + height + 'px;">';
+ html += '<iframe id="' + id + '_iframe" name="' + id + '_iframe" frameborder="0" width="' + iframeWidth + '" height="' + iframeHeight + '" src="' + url + '" class="mceWindowBodyIframe" scrolling="' + features['scrollbars'] + '"></iframe></div>';
+
+ if (features['statusbar'] == "yes") {
+ html += '<div id="' + id + '_statusbar" class="mceWindowStatusbar" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';
+
+ if (features['resizable'] == "yes") {
+ if (this.isGecko)
+ html += '<div id="' + id + '_resize" class="mceWindowResize"><div style="background-image: url(\'' + imgPath + '/window_resize.gif\'); width: 12px; height: 12px;"></div></div>';
+ else
+ html += '<div id="' + id + '_resize" class="mceWindowResize"><img onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();" border="0" src="' + imgPath + '/window_resize.gif" /></div>';
+ }
+
+ html += '</div>';
+ }
+
+ html += '</div>';
+
+ html += '</body>';
+ html += '</html>';
+
+ // Create iframe
+ this.createFloatingIFrame(id, features['left'], features['top'], features['width'], features['height'], html);
+};
+
+// Blocks the document events by placing a image over the whole document
+TinyMCE_Windows.prototype.setDocumentLock = function(state) {
+ if (state) {
+ var elm = document.getElementById('mcWindowEventBlocker');
+ if (elm == null) {
+ elm = document.createElement("div");
+
+ elm.id = "mcWindowEventBlocker";
+ elm.style.position = "absolute";
+ elm.style.left = "0";
+ elm.style.top = "0";
+
+ document.body.appendChild(elm);
+ }
+
+ elm.style.display = "none";
+
+ var imgPath = this.getParam("images_path");
+ var width = document.body.clientWidth;
+ var height = document.body.clientHeight;
+
+ elm.style.width = width;
+ elm.style.height = height;
+ elm.innerHTML = '<img src="' + imgPath + '/spacer.gif" width="' + width + '" height="' + height + '" />';
+
+ elm.style.zIndex = mcWindows.zindex-1;
+ elm.style.display = "block";
+ } else {
+ var elm = document.getElementById('mcWindowEventBlocker');
+
+ if (mcWindows.windows.length == 0)
+ elm.parentNode.removeChild(elm);
+ else
+ elm.style.zIndex = mcWindows.zindex-1;
+ }
+};
+
+// Gets called when wrapper iframe is initialized
+TinyMCE_Windows.prototype.onLoad = function(name) {
+ var win = mcWindows.windows[name];
+ var id = "mcWindow_" + name;
+ var wrapperIframe = window.frames[id + "_iframe"].frames[0];
+ var wrapperDoc = window.frames[id + "_iframe"].document;
+ var doc = window.frames[id + "_iframe"].document;
+ var winDiv = document.getElementById("mcWindow_" + name + "_div");
+ var realIframe = window.frames[id + "_iframe"].frames[0];
+
+ // Set window data
+ win.id = "mcWindow_" + name;
+ win.winElement = winDiv;
+ win.bodyElement = doc.getElementById(id + '_body');
+ win.iframeElement = doc.getElementById(id + '_iframe');
+ win.headElement = doc.getElementById(id + '_head');
+ win.titleElement = doc.getElementById(id + '_title');
+ win.resizeElement = doc.getElementById(id + '_resize');
+ win.containerElement = doc.getElementById(id + '_container');
+ win.left = win.features['left'];
+ win.top = win.features['top'];
+ win.frame = window.frames[id + '_iframe'].frames[0];
+ win.wrapperFrame = window.frames[id + '_iframe'];
+ win.wrapperIFrameElement = document.getElementById(id + "_iframe");
+
+ // Add event handlers
+ mcWindows.addEvent(win.headElement, "mousedown", mcWindows.eventDispatcher);
+
+ if (win.resizeElement != null)
+ mcWindows.addEvent(win.resizeElement, "mousedown", mcWindows.eventDispatcher);
+
+ if (mcWindows.isMSIE) {
+ mcWindows.addEvent(realIframe.document, "mousemove", mcWindows.eventDispatcher);
+ mcWindows.addEvent(realIframe.document, "mouseup", mcWindows.eventDispatcher);
+ } else {
+ mcWindows.addEvent(realIframe, "mousemove", mcWindows.eventDispatcher);
+ mcWindows.addEvent(realIframe, "mouseup", mcWindows.eventDispatcher);
+ mcWindows.addEvent(realIframe, "focus", mcWindows.eventDispatcher);
+ }
+
+ for (var i=0; i<window.frames.length; i++) {
+ if (!window.frames[i]._hasMouseHandlers) {
+ if (mcWindows.isMSIE) {
+ mcWindows.addEvent(window.frames[i].document, "mousemove", mcWindows.eventDispatcher);
+ mcWindows.addEvent(window.frames[i].document, "mouseup", mcWindows.eventDispatcher);
+ } else {
+ mcWindows.addEvent(window.frames[i], "mousemove", mcWindows.eventDispatcher);
+ mcWindows.addEvent(window.frames[i], "mouseup", mcWindows.eventDispatcher);
+ }
+
+ window.frames[i]._hasMouseHandlers = true;
+ }
+ }
+
+ if (mcWindows.isMSIE) {
+ mcWindows.addEvent(win.frame.document, "mousemove", mcWindows.eventDispatcher);
+ mcWindows.addEvent(win.frame.document, "mouseup", mcWindows.eventDispatcher);
+ } else {
+ mcWindows.addEvent(win.frame, "mousemove", mcWindows.eventDispatcher);
+ mcWindows.addEvent(win.frame, "mouseup", mcWindows.eventDispatcher);
+ mcWindows.addEvent(win.frame, "focus", mcWindows.eventDispatcher);
+ }
+
+ // Dispatch open window event
+ var func = this.getParam("on_open_window", "");
+ if (func != "")
+ eval(func + "(win);");
+
+ win.focus();
+
+ if (win.features['modal'] == "yes")
+ mcWindows.setDocumentLock(true);
+};
+
+TinyMCE_Windows.prototype.createFloatingIFrame = function(id_prefix, left, top, width, height, html) {
+ var iframe = document.createElement("iframe");
+ var div = document.createElement("div");
+
+ width = parseInt(width);
+ height = parseInt(height)+1;
+
+ // Create wrapper div
+ div.setAttribute("id", id_prefix + "_div");
+ div.setAttribute("width", width);
+ div.setAttribute("height", (height));
+ div.style.position = "absolute";
+ div.style.left = left + "px";
+ div.style.top = top + "px";
+ div.style.width = width + "px";
+ div.style.height = (height) + "px";
+ div.style.backgroundColor = "white";
+ div.style.display = "none";
+
+ if (this.isGecko) {
+ iframeWidth = width + 2;
+ iframeHeight = height + 2;
+ } else {
+ iframeWidth = width;
+ iframeHeight = height + 1;
+ }
+
+ // Create iframe
+ iframe.setAttribute("id", id_prefix + "_iframe");
+ iframe.setAttribute("name", id_prefix + "_iframe");
+ iframe.setAttribute("border", "0");
+ iframe.setAttribute("frameBorder", "0");
+ iframe.setAttribute("marginWidth", "0");
+ iframe.setAttribute("marginHeight", "0");
+ iframe.setAttribute("leftMargin", "0");
+ iframe.setAttribute("topMargin", "0");
+ iframe.setAttribute("width", iframeWidth);
+ iframe.setAttribute("height", iframeHeight);
+// iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");
+ // iframe.setAttribute("allowtransparency", "false");
+ iframe.setAttribute("scrolling", "no");
+ iframe.style.width = iframeWidth + "px";
+ iframe.style.height = iframeHeight + "px";
+ iframe.style.backgroundColor = "white";
+ div.appendChild(iframe);
+
+ document.body.appendChild(div);
+
+ // Fixed MSIE 5.0 issue
+ div.innerHTML = div.innerHTML;
+
+ if (this.isSafari) {
+ // Give Safari some time to setup
+ window.setTimeout(function() {
+ doc = window.frames[id_prefix + '_iframe'].document;
+ doc.open();
+ doc.write(html);
+ doc.close();
+ }, 10);
+ } else {
+ doc = window.frames[id_prefix + '_iframe'].window.document;
+ doc.open();
+ doc.write(html);
+ doc.close();
+ }
+
+ div.style.display = "block";
+
+ return div;
+};
+
+// Window instance
+function TinyMCE_Window() {
+};
+
+TinyMCE_Window.prototype.focus = function() {
+ if (this != mcWindows.selectedWindow) {
+ this.winElement.style.zIndex = ++mcWindows.zindex;
+ mcWindows.lastSelectedWindow = mcWindows.selectedWindow;
+ mcWindows.selectedWindow = this;
+ }
+};
+
+TinyMCE_Window.prototype.minimize = function() {
+};
+
+TinyMCE_Window.prototype.maximize = function() {
+
+};
+
+TinyMCE_Window.prototype.startResize = function() {
+ mcWindows.action = "resize";
+};
+
+TinyMCE_Window.prototype.startMove = function(e) {
+ mcWindows.action = "move";
+};
+
+TinyMCE_Window.prototype.close = function() {
+ if (this.frame && this.frame['tinyMCEPopup'])
+ this.frame['tinyMCEPopup'].restoreSelection();
+
+ if (mcWindows.lastSelectedWindow != null)
+ mcWindows.lastSelectedWindow.focus();
+
+ var mcWindowsNew = new Array();
+ for (var n in mcWindows.windows) {
+ var win = mcWindows.windows[n];
+ if (typeof(win) == 'function')
+ continue;
+
+ if (win.name != this.name)
+ mcWindowsNew[n] = win;
+ }
+
+ mcWindows.windows = mcWindowsNew;
+
+// alert(mcWindows.doc.getElementById(this.id + "_iframe"));
+
+ var e = mcWindows.doc.getElementById(this.id + "_iframe");
+ e.parentNode.removeChild(e);
+
+ var e = mcWindows.doc.getElementById(this.id + "_div");
+ e.parentNode.removeChild(e);
+
+ mcWindows.setDocumentLock(false);
+};
+
+TinyMCE_Window.prototype.onMouseMove = function(e) {
+ var scrollX = 0;//this.doc.body.scrollLeft;
+ var scrollY = 0;//this.doc.body.scrollTop;
+
+ // Calculate real X, Y
+ var dx = e.screenX - mcWindows.mouseDownScreenX;
+ var dy = e.screenY - mcWindows.mouseDownScreenY;
+
+ switch (mcWindows.action) {
+ case "resize":
+ width = mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX);
+ height = mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY);
+
+ width = width < 100 ? 100 : width;
+ height = height < 100 ? 100 : height;
+
+ this.wrapperIFrameElement.style.width = width+2;
+ this.wrapperIFrameElement.style.height = height+2;
+ this.wrapperIFrameElement.width = width+2;
+ this.wrapperIFrameElement.height = height+2;
+ this.winElement.style.width = width;
+ this.winElement.style.height = height;
+
+ height = height - this.deltaHeight;
+
+ this.containerElement.style.width = width;
+
+ this.iframeElement.style.width = width;
+ this.iframeElement.style.height = height;
+ this.bodyElement.style.width = width;
+ this.bodyElement.style.height = height;
+ this.headElement.style.width = width;
+ //this.statusElement.style.width = width;
+
+ mcWindows.cancelEvent(e);
+ break;
+
+ case "move":
+ this.left = mcWindows.mouseDownLayerX + (e.screenX - mcWindows.mouseDownScreenX);
+ this.top = mcWindows.mouseDownLayerY + (e.screenY - mcWindows.mouseDownScreenY);
+ this.winElement.style.left = this.left + "px";
+ this.winElement.style.top = this.top + "px";
+
+ mcWindows.cancelEvent(e);
+ break;
+ }
+};
+
+function debug(msg) {
+ document.getElementById('debug').value += msg + "\n";
+}
+
+TinyMCE_Window.prototype.onMouseUp = function(e) {
+ mcWindows.action = "none";
+};
+
+TinyMCE_Window.prototype.onFocus = function(e) {
+ // Gecko only handler
+ var winRef = e.currentTarget;
+
+ for (var n in mcWindows.windows) {
+ var win = mcWindows.windows[n];
+ if (typeof(win) == 'function')
+ continue;
+
+ if (winRef.name == win.id + "_iframe") {
+ win.focus();
+ return;
+ }
+ }
+};
+
+TinyMCE_Window.prototype.onMouseDown = function(e) {
+ var elm = mcWindows.isMSIE ? this.wrapperFrame.event.srcElement : e.target;
+
+ var scrollX = 0;//this.doc.body.scrollLeft;
+ var scrollY = 0;//this.doc.body.scrollTop;
+
+ mcWindows.mouseDownScreenX = e.screenX;
+ mcWindows.mouseDownScreenY = e.screenY;
+ mcWindows.mouseDownLayerX = this.left;
+ mcWindows.mouseDownLayerY = this.top;
+ mcWindows.mouseDownWidth = parseInt(this.winElement.style.width);
+ mcWindows.mouseDownHeight = parseInt(this.winElement.style.height);
+
+ if (this.resizeElement != null && elm == this.resizeElement.firstChild)
+ this.startResize(e);
+ else
+ this.startMove(e);
+
+ mcWindows.cancelEvent(e);
+};
+
+// Global instance
+var mcWindows = new TinyMCE_Windows();
+
+// Initialize windows
+mcWindows.init({
+ images_path : tinyMCE.baseURL + "/plugins/inlinepopups/images",
+ css_file : tinyMCE.baseURL + "/plugins/inlinepopups/css/inlinepopup.css"
+});
diff --git a/wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js b/wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js
index e69de29..a88ffd7 100644
--- a/wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js
+++ b/wp-inst/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js
@@ -0,0 +1,455 @@
+/**
+ * $RCSfile: mcwindows.js,v $
+ * $Revision: 1.2 $
+ * $Date: 2005/10/18 13:59:43 $
+ *
+ * Moxiecode DHTML Windows script.
+ *
+ * @author Moxiecode
+ * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.
+ */
+
+// Windows handler
+function MCWindows() {
+ this.settings = new Array();
+ this.windows = new Array();
+ this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
+ this.isGecko = navigator.userAgent.indexOf('Gecko') != -1;
+ this.isSafari = navigator.userAgent.indexOf('Safari') != -1;
+ this.isMac = navigator.userAgent.indexOf('Mac') != -1;
+ this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1);
+ this.action = "none";
+ this.selectedWindow = null;
+ this.zindex = 100;
+ this.mouseDownScreenX = 0;
+ this.mouseDownScreenY = 0;
+ this.mouseDownLayerX = 0;
+ this.mouseDownLayerY = 0;
+ this.mouseDownWidth = 0;
+ this.mouseDownHeight = 0;
+};
+
+MCWindows.prototype.init = function(settings) {
+ this.settings = settings;
+
+ if (this.isMSIE)
+ this.addEvent(document, "mousemove", mcWindows.eventDispatcher);
+ else
+ this.addEvent(window, "mousemove", mcWindows.eventDispatcher);
+
+ this.addEvent(document, "mouseup", mcWindows.eventDispatcher);
+};
+
+MCWindows.prototype.getParam = function(name, default_value) {
+ var value = null;
+
+ value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
+
+ // Fix bool values
+ if (value == "true" || value == "false")
+ return (value == "true");
+
+ return value;
+};
+
+MCWindows.prototype.eventDispatcher = function(e) {
+ e = typeof(e) == "undefined" ? window.event : e;
+
+ if (mcWindows.selectedWindow == null)
+ return;
+
+ // Switch focus
+ if (mcWindows.isGecko && e.type == "mousedown") {
+ var elm = e.currentTarget;
+
+ for (var n in mcWindows.windows) {
+ var win = mcWindows.windows[n];
+ if (typeof(win) == 'function')
+ continue;
+
+ if (win.headElement == elm || win.resizeElement == elm) {
+ win.focus();
+ break;
+ }
+ }
+ }
+
+ switch (e.type) {
+ case "mousemove":
+ mcWindows.selectedWindow.onMouseMove(e);
+ break;
+
+ case "mouseup":
+ mcWindows.selectedWindow.onMouseUp(e);
+ break;
+
+ case "mousedown":
+ mcWindows.selectedWindow.onMouseDown(e);
+ break;
+
+ case "focus":
+ mcWindows.selectedWindow.onFocus(e);
+ break;
+ }
+}
+
+MCWindows.prototype.addEvent = function(obj, name, handler) {
+ if (this.isMSIE)
+ obj.attachEvent("on" + name, handler);
+ else
+ obj.addEventListener(name, handler, true);
+};
+
+MCWindows.prototype.cancelEvent = function(e) {
+ if (this.isMSIE) {
+ e.returnValue = false;
+ e.cancelBubble = true;
+ } else
+ e.preventDefault();
+};
+
+MCWindows.prototype.parseFeatures = function(opts) {
+ // Cleanup the options
+ opts = opts.toLowerCase();
+ opts = opts.replace(/;/g, ",");
+ opts = opts.replace(/[^0-9a-z=,]/g, "");
+
+ var optionChunks = opts.split(',');
+ var options = new Array();
+
+ options['left'] = 10;
+ options['top'] = 10;
+ options['width'] = 300;
+ options['height'] = 300;
+ options['resizable'] = true;
+ options['minimizable'] = true;
+ options['maximizable'] = true;
+ options['close'] = true;
+ options['movable'] = true;
+
+ if (opts == "")
+ return options;
+
+ for (var i=0; i<optionChunks.length; i++) {
+ var parts = optionChunks[i].split('=');
+
+ if (parts.length == 2)
+ options[parts[0]] = parts[1];
+ }
+
+ return options;
+};
+
+MCWindows.prototype.open = function(url, name, features) {
+ var win = new MCWindow();
+ var winDiv, html = "", id;
+
+ features = this.parseFeatures(features);
+
+ // Create div
+ id = "mcWindow_" + name;
+
+ width = parseInt(features['width']);
+ height = parseInt(features['height'])-12-19;
+
+ if (this.isMSIE)
+ width -= 2;
+
+ // Setup first part of window
+ win.id = id;
+ win.url = url;
+ win.name = name;
+ win.features = features;
+ this.windows[name] = win;
+
+ iframeWidth = width;
+ iframeHeight = height;
+
+ // Create inner content
+ html += '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
+ html += '<html>';
+ html += '<head>';
+ html += '<title>Wrapper iframe</title>';
+ html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
+ html += '<link href="../jscripts/tiny_mce/themes/advanced/css/editor_ui.css" rel="stylesheet" type="text/css" />';
+ html += '</head>';
+ html += '<body onload="parent.mcWindows.onLoad(\'' + name + '\');">';
+
+ html += '<div id="' + id + '_container" class="mceWindow">';
+ html += '<div id="' + id + '_head" class="mceWindowHead" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';
+ html += ' <div id="' + id + '_title" class="mceWindowTitle"';
+ html += ' onselectstart="return false;" unselectable="on" style="-moz-user-select: none !important;">No name window</div>';
+ html += ' <div class="mceWindowHeadTools">';
+ html += ' <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].close();" onmousedown="return false;" class="mceWindowClose"><img border="0" src="../jscripts/tiny_mce/themes/advanced/images/window_close.gif" /></a>';
+// html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].maximize();" onmousedown="return false;" class="mceWindowMaximize"></a>';
+// html += ' <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" onmousedown="return false;" class="mceWindowMinimize"></a>';
+ html += ' </div>';
+ html += '</div><div id="' + id + '_body" class="mceWindowBody" style="width: ' + width + 'px; height: ' + height + 'px;">';
+ html += '<iframe id="' + id + '_iframe" name="' + id + '_iframe" onfocus="parent.mcWindows.windows[\'' + name + '\'].focus();" frameborder="0" width="' + iframeWidth + '" height="' + iframeHeight + '" src="' + url + '" class="mceWindowBodyIframe"></iframe></div>';
+ html += '<div id="' + id + '_statusbar" class="mceWindowStatusbar" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';
+ html += '<div id="' + id + '_resize" class="mceWindowResize"><img onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();" border="0" src="../jscripts/tiny_mce/themes/advanced/images/window_resize.gif" /></div>';
+ html += '</div>';
+ html += '</div>';
+
+ html += '</body>';
+ html += '</html>';
+
+ // Create iframe
+ this.createFloatingIFrame(id, features['left'], features['top'], features['width'], features['height'], html);
+};
+
+// Gets called when wrapper iframe is initialized
+MCWindows.prototype.onLoad = function(name) {
+ var win = mcWindows.windows[name];
+ var id = "mcWindow_" + name;
+ var wrapperIframe = window.frames[id + "_iframe"].frames[0];
+ var wrapperDoc = window.frames[id + "_iframe"].document;
+ var doc = window.frames[id + "_iframe"].document;
+ var winDiv = document.getElementById("mcWindow_" + name + "_div");
+ var realIframe = window.frames[id + "_iframe"].frames[0];
+
+ // Set window data
+ win.id = "mcWindow_" + name + "_iframe";
+ win.winElement = winDiv;
+ win.bodyElement = doc.getElementById(id + '_body');
+ win.iframeElement = doc.getElementById(id + '_iframe');
+ win.headElement = doc.getElementById(id + '_head');
+ win.titleElement = doc.getElementById(id + '_title');
+ win.resizeElement = doc.getElementById(id + '_resize');
+ win.containerElement = doc.getElementById(id + '_container');
+ win.left = win.features['left'];
+ win.top = win.features['top'];
+ win.frame = window.frames[id + '_iframe'].frames[0];
+ win.wrapperFrame = window.frames[id + '_iframe'];
+ win.wrapperIFrameElement = document.getElementById(id + "_iframe");
+
+ // Add event handlers
+ mcWindows.addEvent(win.headElement, "mousedown", mcWindows.eventDispatcher);
+ mcWindows.addEvent(win.resizeElement, "mousedown", mcWindows.eventDispatcher);
+
+ if (mcWindows.isMSIE) {
+ mcWindows.addEvent(realIframe.document, "mousemove", mcWindows.eventDispatcher);
+ mcWindows.addEvent(realIframe.document, "mouseup", mcWindows.eventDispatcher);
+ } else {
+ mcWindows.addEvent(realIframe, "mousemove", mcWindows.eventDispatcher);
+ mcWindows.addEvent(realIframe, "mouseup", mcWindows.eventDispatcher);
+ mcWindows.addEvent(realIframe, "focus", mcWindows.eventDispatcher);
+ }
+
+ for (var i=0; i<window.frames.length; i++) {
+ if (!window.frames[i]._hasMouseHandlers) {
+ if (mcWindows.isMSIE) {
+ mcWindows.addEvent(window.frames[i].document, "mousemove", mcWindows.eventDispatcher);
+ mcWindows.addEvent(window.frames[i].document, "mouseup", mcWindows.eventDispatcher);
+ } else {
+ mcWindows.addEvent(window.frames[i], "mousemove", mcWindows.eventDispatcher);
+ mcWindows.addEvent(window.frames[i], "mouseup", mcWindows.eventDispatcher);
+ }
+
+ window.frames[i]._hasMouseHandlers = true;
+ }
+ }
+
+ if (mcWindows.isMSIE) {
+ mcWindows.addEvent(win.frame.document, "mousemove", mcWindows.eventDispatcher);
+ mcWindows.addEvent(win.frame.document, "mouseup", mcWindows.eventDispatcher);
+ } else {
+ mcWindows.addEvent(win.frame, "mousemove", mcWindows.eventDispatcher);
+ mcWindows.addEvent(win.frame, "mouseup", mcWindows.eventDispatcher);
+ mcWindows.addEvent(win.frame, "focus", mcWindows.eventDispatcher);
+ }
+
+ this.selectedWindow = win;
+};
+
+MCWindows.prototype.createFloatingIFrame = function(id_prefix, left, top, width, height, html) {
+ var iframe = document.createElement("iframe");
+ var div = document.createElement("div");
+
+ width = parseInt(width);
+ height = parseInt(height)+1;
+
+ // Create wrapper div
+ div.setAttribute("id", id_prefix + "_div");
+ div.setAttribute("width", width);
+ div.setAttribute("height", (height));
+ div.style.position = "absolute";
+ div.style.left = left + "px";
+ div.style.top = top + "px";
+ div.style.width = width + "px";
+ div.style.height = (height) + "px";
+ div.style.backgroundColor = "white";
+ div.style.display = "none";
+
+ if (this.isGecko) {
+ iframeWidth = width + 2;
+ iframeHeight = height + 2;
+ } else {
+ iframeWidth = width;
+ iframeHeight = height + 1;
+ }
+
+ // Create iframe
+ iframe.setAttribute("id", id_prefix + "_iframe");
+ iframe.setAttribute("name", id_prefix + "_iframe");
+ iframe.setAttribute("border", "0");
+ iframe.setAttribute("frameBorder", "0");
+ iframe.setAttribute("marginWidth", "0");
+ iframe.setAttribute("marginHeight", "0");
+ iframe.setAttribute("leftMargin", "0");
+ iframe.setAttribute("topMargin", "0");
+ iframe.setAttribute("width", iframeWidth);
+ iframe.setAttribute("height", iframeHeight);
+// iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");
+ // iframe.setAttribute("allowtransparency", "false");
+ iframe.setAttribute("scrolling", "no");
+ iframe.style.width = iframeWidth + "px";
+ iframe.style.height = iframeHeight + "px";
+ iframe.style.backgroundColor = "white";
+ div.appendChild(iframe);
+
+ document.body.appendChild(div);
+
+ // Fixed MSIE 5.0 issue
+ div.innerHTML = div.innerHTML;
+
+ if (this.isSafari) {
+ // Give Safari some time to setup
+ window.setTimeout(function() {
+ doc = window.frames[id_prefix + '_iframe'].document;
+ doc.open();
+ doc.write(html);
+ doc.close();
+ }, 10);
+ } else {
+ doc = window.frames[id_prefix + '_iframe'].window.document
+ doc.open();
+ doc.write(html);
+ doc.close();
+ }
+
+ div.style.display = "block";
+
+ return div;
+};
+
+// Window instance
+function MCWindow() {
+};
+
+MCWindow.prototype.focus = function() {
+ this.winElement.style.zIndex = mcWindows.zindex++;
+ mcWindows.selectedWindow = this;
+};
+
+MCWindow.prototype.minimize = function() {
+};
+
+MCWindow.prototype.maximize = function() {
+
+};
+
+MCWindow.prototype.startResize = function() {
+ mcWindows.action = "resize";
+};
+
+MCWindow.prototype.startMove = function(e) {
+ mcWindows.action = "move";
+};
+
+MCWindow.prototype.close = function() {
+ document.body.removeChild(this.winElement);
+ mcWindows.windows[this.name] = null;
+};
+
+MCWindow.prototype.onMouseMove = function(e) {
+ var scrollX = 0;//this.doc.body.scrollLeft;
+ var scrollY = 0;//this.doc.body.scrollTop;
+
+ // Calculate real X, Y
+ var dx = e.screenX - mcWindows.mouseDownScreenX;
+ var dy = e.screenY - mcWindows.mouseDownScreenY;
+
+ switch (mcWindows.action) {
+ case "resize":
+ width = mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX);
+ height = mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY);
+
+ width = width < 100 ? 100 : width;
+ height = height < 100 ? 100 : height;
+
+ this.wrapperIFrameElement.style.width = width+2;
+ this.wrapperIFrameElement.style.height = height+2;
+ this.wrapperIFrameElement.width = width+2;
+ this.wrapperIFrameElement.height = height+2;
+ this.winElement.style.width = width;
+ this.winElement.style.height = height;
+
+ height = height-12-19;
+
+ this.containerElement.style.width = width;
+
+ this.iframeElement.style.width = width;
+ this.iframeElement.style.height = height;
+ this.bodyElement.style.width = width;
+ this.bodyElement.style.height = height;
+ this.headElement.style.width = width;
+ //this.statusElement.style.width = width;
+
+ mcWindows.cancelEvent(e);
+ break;
+
+ case "move":
+ this.left = mcWindows.mouseDownLayerX + (e.screenX - mcWindows.mouseDownScreenX);
+ this.top = mcWindows.mouseDownLayerY + (e.screenY - mcWindows.mouseDownScreenY);
+ this.winElement.style.left = this.left + "px";
+ this.winElement.style.top = this.top + "px";
+
+ mcWindows.cancelEvent(e);
+ break;
+ }
+};
+
+MCWindow.prototype.onMouseUp = function(e) {
+ mcWindows.action = "none";
+};
+
+MCWindow.prototype.onFocus = function(e) {
+ // Gecko only handler
+ var winRef = e.currentTarget;
+
+ for (var n in mcWindows.windows) {
+ var win = mcWindows.windows[n];
+ if (typeof(win) == 'function')
+ continue;
+
+ if (winRef.name == win.id) {
+ win.focus();
+ return;
+ }
+ }
+};
+
+MCWindow.prototype.onMouseDown = function(e) {
+ var elm = mcWindows.isMSIE ? this.wrapperFrame.event.srcElement : e.target;
+
+ var scrollX = 0;//this.doc.body.scrollLeft;
+ var scrollY = 0;//this.doc.body.scrollTop;
+
+ mcWindows.mouseDownScreenX = e.screenX;
+ mcWindows.mouseDownScreenY = e.screenY;
+ mcWindows.mouseDownLayerX = this.left;
+ mcWindows.mouseDownLayerY = this.top;
+ mcWindows.mouseDownWidth = parseInt(this.winElement.style.width);
+ mcWindows.mouseDownHeight = parseInt(this.winElement.style.height);
+
+ if (elm == this.resizeElement.firstChild)
+ this.startResize(e);
+ else
+ this.startMove(e);
+
+ mcWindows.cancelEvent(e);
+};
+
+// Global instance
+var mcWindows = new MCWindows();
diff --git a/wp-inst/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js b/wp-inst/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
index 697ba72..e5067c0 100644
--- a/wp-inst/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
+++ b/wp-inst/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
@@ -1,285 +1,400 @@
-/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('wordpress', '');
-
-function TinyMCE_wordpress_initInstance(inst) {
- if (!tinyMCE.settings['wordpress_skip_plugin_css'])
- tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/wordpress/wordpress.css");
-}
-
-function TinyMCE_wordpress_getControlHTML(control_name) {
- switch (control_name) {
- case "wordpress":
- var titleMore = tinyMCE.getLang('lang_wordpress_more_button');
- var titlePage = tinyMCE.getLang('lang_wordpress_page_button');
- var titleHelp = tinyMCE.getLang('lang_wordpress_help_button');
- var buttons = '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\')" target="_self" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\');return false;"><img id="{$editor_id}_wordpress_more" src="{$pluginurl}/images/more.gif" title="'+titleMore+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
- // Add this to the buttons var to put the Page button into the toolbar.
- // '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\')" target="_self" onclick="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\');return false;"><img id="{$editor_id}_wordpress_page" src="{$pluginurl}/images/page.gif" title="'+titlePage+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
- return buttons;
- }
-
- return '';
-}
-
-function TinyMCE_wordpress_parseAttributes(attribute_string) {
- var attributeName = "";
- var attributeValue = "";
- var withInName;
- var withInValue;
- var attributes = new Array();
- var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
- var titleText = tinyMCE.getLang('lang_wordpress_more');
- var titleTextPage = tinyMCE.getLang('lang_wordpress_page');
-
- if (attribute_string == null || attribute_string.length < 2)
- return null;
-
- withInName = withInValue = false;
-
- for (var i=0; i<attribute_string.length; i++) {
- var chr = attribute_string.charAt(i);
-
- if ((chr == '"' || chr == "'") && !withInValue)
- withInValue = true;
- else if ((chr == '"' || chr == "'") && withInValue) {
- withInValue = false;
-
- var pos = attributeName.lastIndexOf(' ');
- if (pos != -1)
- attributeName = attributeName.substring(pos+1);
-
- attributes[attributeName.toLowerCase()] = attributeValue.substring(1).toLowerCase();
-
- attributeName = "";
- attributeValue = "";
- } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)
- withInName = true;
-
- if (chr == '=' && withInName)
- withInName = false;
-
- if (withInName)
- attributeName += chr;
-
- if (withInValue)
- attributeValue += chr;
- }
-
- return attributes;
-}
-
-function TinyMCE_wordpress_execCommand(editor_id, element, command, user_interface, value) {
- var inst = tinyMCE.getInstanceById(editor_id);
- var focusElm = inst.getFocusElement();
- var doc = inst.getDoc();
-
- function getAttrib(elm, name) {
- return elm.getAttribute(name) ? elm.getAttribute(name) : "";
- }
-
- // Handle commands
- switch (command) {
- case "mcewordpressmore":
- var flag = "";
- var template = new Array();
- var altMore = tinyMCE.getLang('lang_wordpress_more_alt');
-
- // Is selection a image
- if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
- flag = getAttrib(focusElm, 'class');
-
- if (flag != 'mce_plugin_wordpress_more') // Not a wordpress
- return true;
-
- action = "update";
- }
-
- html = ''
- + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
- + ' width="100%" height="10px" '
- + 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
- tinyMCE.execCommand("mceInsertContent",true,html);
- tinyMCE.selectedInstance.repaint();
- return true;
- case "mcewordpresspage":
- var flag = "";
- var template = new Array();
- var altPage = tinyMCE.getLang('lang_wordpress_more_alt');
-
- // Is selection a image
- if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
- flag = getAttrib(focusElm, 'name');
-
- if (flag != 'mce_plugin_wordpress_page') // Not a wordpress
- return true;
-
- action = "update";
- }
-
- html = ''
- + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
- + ' width="100%" height="10px" '
- + 'alt="'+altPage+'" title="'+altPage+'" class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
- tinyMCE.execCommand("mceInsertContent",true,html);
- tinyMCE.selectedInstance.repaint();
- return true;
- }
-
- // Pass to next handler in chain
- return false;
-}
-
-function TinyMCE_wordpress_cleanup(type, content) {
- switch (type) {
-
- case "insert_to_editor":
- var startPos = 0;
- var altMore = tinyMCE.getLang('lang_wordpress_more_alt');
- var altPage = tinyMCE.getLang('lang_wordpress_page_alt');
-
- // Parse all <!--more--> tags and replace them with images
- while ((startPos = content.indexOf('<!--more-->', startPos)) != -1) {
- // Insert image
- var contentAfter = content.substring(startPos + 11);
- content = content.substring(0, startPos);
- content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
- content += ' width="100%" height="10px" ';
- content += 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" />';
- content += contentAfter;
-
- startPos++;
- }
- var startPos = 0;
-
- // Parse all <!--page--> tags and replace them with images
- while ((startPos = content.indexOf('<!--nextpage-->', startPos)) != -1) {
- // Insert image
- var contentAfter = content.substring(startPos + 15);
- content = content.substring(0, startPos);
- content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
- content += ' width="100%" height="10px" ';
- content += 'alt="'+altPage+'" title="'+altPage+'" class="mce_plugin_wordpress_page" />';
- content += contentAfter;
-
- startPos++;
- }
-
- // It's supposed to be WYSIWYG, right?
- content = content.replace(new RegExp('&', 'g'), '&amp;');
-
- break;
-
- case "get_from_editor":
- // Parse all img tags and replace them with <!--more-->
- var startPos = -1;
- while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
- var endPos = content.indexOf('/>', startPos);
- var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos));
-
- if (attribs['class'] == "mce_plugin_wordpress_more") {
- endPos += 2;
-
- var embedHTML = '<!--more-->';
-
- // Insert embed/object chunk
- chunkBefore = content.substring(0, startPos);
- chunkAfter = content.substring(endPos);
- content = chunkBefore + embedHTML + chunkAfter;
- }
- if (attribs['class'] == "mce_plugin_wordpress_page") {
- endPos += 2;
-
- var embedHTML = '<!--nextpage-->';
-
- // Insert embed/object chunk
- chunkBefore = content.substring(0, startPos);
- chunkAfter = content.substring(endPos);
- content = chunkBefore + embedHTML + chunkAfter;
- }
- }
-
- // If it says & in the WYSIWYG editor, it should say &amp; in the html.
- content = content.replace(new RegExp('&', 'g'), '&amp;');
- content = content.replace(new RegExp('&amp;nbsp;', 'g'), '&nbsp;');
-
- // Remove anonymous, empty paragraphs.
- content = content.replace(new RegExp('<p>(\\s|&nbsp;)*</p>', 'mg'), '');
-
- // Handle table badness.
- content = content.replace(new RegExp('<(table( [^>]*)?)>.*?<((tr|thead)( [^>]*)?)>', 'mg'), '<$1><$3>');
- content = content.replace(new RegExp('<(tr|thead|tfoot)>.*?<((td|th)( [^>]*)?)>', 'mg'), '<$1><$2>');
- content = content.replace(new RegExp('</(td|th)>.*?<(td( [^>]*)?|th( [^>]*)?|/tr|/thead|/tfoot)>', 'mg'), '</$1><$2>');
- content = content.replace(new RegExp('</tr>.*?<(tr|/table)>', 'mg'), '</tr><$1>');
- content = content.replace(new RegExp('<(/?(table|tbody|tr|th|td)[^>]*)>(\\s*|(<br ?/?>)*)*', 'g'), '<$1>');
-
- // Pretty it up for the source editor.
- var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre|p';
- content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
- content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>\\s*', 'mg'), '\n<$1>');
- content = content.replace(new RegExp('<((li|/?tr|/?thead|/?tfoot)( [^>]*)?)>', 'g'), '\t<$1>');
- content = content.replace(new RegExp('<((td|th)( [^>]*)?)>', 'g'), '\t\t<$1>');
- content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'mg'), '<br />\n');
- content = content.replace(new RegExp('^\\s*', ''), '');
- content = content.replace(new RegExp('\\s*$', ''), '');
-
- break;
- }
-
- // Pass through to next handler in chain
- return content;
-}
-
-function TinyMCE_wordpress_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
- function getAttrib(elm, name) {
- return elm.getAttribute(name) ? elm.getAttribute(name) : "";
- }
-
- tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonNormal');
- tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonNormal');
-
- if (node == null)
- return;
-
- do {
- if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0)
- tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected');
- if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0)
- tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected');
- } while ((node = node.parentNode));
-
- return true;
-}
-
-function wp_save_callback(el, content, body) {
- // We have a TON of cleanup to do.
-
- // Mark </p> if it has any attributes.
- content = content.replace(new RegExp('(<p[^>]+>.*?)</p>', 'mg'), '$1</p#>');
-
- // Decode the ampersands of time.
- content = content.replace(new RegExp('&amp;', 'g'), '&');
-
- // Get it ready for wpautop.
- content = content.replace(new RegExp('[\\s]*<p>[\\s]*', 'mgi'), '');
- content = content.replace(new RegExp('[\\s]*</p>[\\s]*', 'mgi'), '\n\n');
- content = content.replace(new RegExp('\\n\\s*\\n\\s*\\n*', 'mgi'), '\n\n');
- content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
-
- // Fix some block element newline issues
- var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre';
- content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
- content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
- content = content.replace(new RegExp('<li>', 'g'), '\t<li>');
-
- // Unmark special paragraph closing tags
- content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
- content = content.replace(new RegExp('\\s*(<p[^>]+>.*</p>)', 'mg'), '\n$1');
-
- // Trim any whitespace
- content = content.replace(new RegExp('^\\s*', ''), '');
- content = content.replace(new RegExp('\\s*$', ''), '');
-
- // Hope.
- return content;
-
-}
+/* Import plugin specific language pack */
+tinyMCE.importPluginLanguagePack('wordpress', 'en');
+
+var TinyMCE_wordpressPlugin = {
+ getInfo : function() {
+ return {
+ longname : 'WordPress Plugin',
+ author : 'WordPress',
+ authorurl : 'http://wordpress.org',
+ infourl : 'http://wordpress.org',
+ version : '1'
+ };
+ },
+
+ getControlHTML : function(control_name) {
+ switch (control_name) {
+ case "wp_more":
+ return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_more_button', '{$pluginurl}/images/more.gif', 'wpMore');
+ case "wp_page":
+ return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_page_button', '{$pluginurl}/images/page.gif', 'wpPage');
+ case "wp_help":
+ var buttons = tinyMCE.getButtonHTML(control_name, 'lang_help_button_title', '{$pluginurl}/images/help.gif', 'wpHelp');
+ var hiddenControls = '<div class="zerosize">'
+ + '<input type="button" accesskey="n" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSpellCheck\',false);" />'
+ + '<input type="button" accesskey="k" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Strikethrough\',false);" />'
+ + '<input type="button" accesskey="l" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'InsertUnorderedList\',false);" />'
+ + '<input type="button" accesskey="o" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'InsertOrderedList\',false);" />'
+ + '<input type="button" accesskey="w" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Outdent\',false);" />'
+ + '<input type="button" accesskey="q" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Indent\',false);" />'
+ + '<input type="button" accesskey="f" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyLeft\',false);" />'
+ + '<input type="button" accesskey="c" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyCenter\',false);" />'
+ + '<input type="button" accesskey="r" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyRight\',false);" />'
+ + '<input type="button" accesskey="j" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyFull\',false);" />'
+ + '<input type="button" accesskey="a" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceLink\',true);" />'
+ + '<input type="button" accesskey="s" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'unlink\',false);" />'
+ + '<input type="button" accesskey="m" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceImage\',true);" />'
+ + '<input type="button" accesskey="t" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpMore\');" />'
+ + '<input type="button" accesskey="g" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpPage\');" />'
+ + '<input type="button" accesskey="u" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Undo\',false);" />'
+ + '<input type="button" accesskey="y" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Redo\',false);" />'
+ + '<input type="button" accesskey="e" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceCodeEditor\',false);" />'
+ + '<input type="button" accesskey="h" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpHelp\',false);" />'
+ + '<input type="button" accesskey="b" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpAdv\',false);" />'
+ + '</div>';
+ return buttons+hiddenControls;
+ case "wp_adv":
+ return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_adv_button', '{$pluginurl}/images/toolbars.gif', 'wpAdv');
+ case "wp_adv_start":
+ return '<div id="wpadvbar" style="display:none;"><br />';
+ case "wp_adv_end":
+ return '</div>';
+ }
+ return '';
+ },
+
+ execCommand : function(editor_id, element, command, user_interface, value) {
+ var inst = tinyMCE.getInstanceById(editor_id);
+ var focusElm = inst.getFocusElement();
+ var doc = inst.getDoc();
+
+ function getAttrib(elm, name) {
+ return elm.getAttribute(name) ? elm.getAttribute(name) : "";
+ }
+
+ // Handle commands
+ switch (command) {
+ case "wpMore":
+ var flag = "";
+ var template = new Array();
+ var altMore = tinyMCE.getLang('lang_wordpress_more_alt');
+
+ // Is selection a image
+ if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
+ flag = getAttrib(focusElm, 'class');
+
+ if (flag != 'mce_plugin_wordpress_more') // Not a wordpress
+ return true;
+
+ action = "update";
+ }
+
+ html = ''
+ + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
+ + ' width="100%" height="10px" '
+ + 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
+ tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, html);
+ tinyMCE.selectedInstance.repaint();
+ return true;
+
+ case "wpPage":
+ var flag = "";
+ var template = new Array();
+ var altPage = tinyMCE.getLang('lang_wordpress_more_alt');
+
+ // Is selection a image
+ if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
+ flag = getAttrib(focusElm, 'name');
+
+ if (flag != 'mce_plugin_wordpress_page') // Not a wordpress
+ return true;
+
+ action = "update";
+ }
+
+ html = ''
+ + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
+ + ' width="100%" height="10px" '
+ + 'alt="'+altPage+'" title="'+altPage+'" class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
+ tinyMCE.execCommand("mceInsertContent",true,html);
+ tinyMCE.selectedInstance.repaint();
+ return true;
+
+ case "wpHelp":
+ var template = new Array();
+
+ template['file'] = tinyMCE.baseURL + '/wp-mce-help.php';
+ template['width'] = 480;
+ template['height'] = 380;
+
+ args = {
+ resizable : 'yes',
+ scrollbars : 'yes'
+ };
+
+ tinyMCE.openWindow(template, args);
+ return true;
+ case "wpAdv":
+ var adv = document.getElementById('wpadvbar');
+ if ( adv.style.display == 'none' ) {
+ adv.style.display = 'block';
+ tinyMCE.switchClass(editor_id + '_wp_adv', 'mceButtonSelected');
+ } else {
+ adv.style.display = 'none';
+ tinyMCE.switchClass(editor_id + '_wp_adv', 'mceButtonNormal');
+ }
+ return true;
+ }
+
+ // Pass to next handler in chain
+ return false;
+ },
+
+ cleanup : function(type, content) {
+ switch (type) {
+
+ case "insert_to_editor":
+ var startPos = 0;
+ var altMore = tinyMCE.getLang('lang_wordpress_more_alt');
+ var altPage = tinyMCE.getLang('lang_wordpress_page_alt');
+
+ // Parse all <!--more--> tags and replace them with images
+ while ((startPos = content.indexOf('<!--more-->', startPos)) != -1) {
+ // Insert image
+ var contentAfter = content.substring(startPos + 11);
+ content = content.substring(0, startPos);
+ content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
+ content += ' width="100%" height="10px" ';
+ content += 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
+ content += contentAfter;
+
+ startPos++;
+ }
+ var startPos = 0;
+
+ // Parse all <!--page--> tags and replace them with images
+ while ((startPos = content.indexOf('<!--nextpage-->', startPos)) != -1) {
+ // Insert image
+ var contentAfter = content.substring(startPos + 15);
+ content = content.substring(0, startPos);
+ content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
+ content += ' width="100%" height="10px" ';
+ content += 'alt="'+altPage+'" title="'+altPage+'" class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
+ content += contentAfter;
+
+ startPos++;
+ }
+
+ // Look for \n in <pre>, replace with <br>
+ var startPos = -1;
+ while ((startPos = content.indexOf('<pre', startPos+1)) != -1) {
+ var endPos = content.indexOf('</pre>', startPos+1);
+ var innerPos = content.indexOf('>', startPos+1);
+ var chunkBefore = content.substring(0, innerPos);
+ var chunkAfter = content.substring(endPos);
+
+ var innards = content.substring(innerPos, endPos);
+ innards = innards.replace(/\n/g, '<br />');
+ content = chunkBefore + innards + chunkAfter;
+ }
+
+ break;
+
+ case "get_from_editor":
+ // Parse all img tags and replace them with <!--more-->
+ var startPos = -1;
+ while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
+ var endPos = content.indexOf('/>', startPos);
+ var attribs = this._parseAttributes(content.substring(startPos + 4, endPos));
+
+ if (attribs['class'] == "mce_plugin_wordpress_more" || attribs['name'] == "mce_plugin_wordpress_more") {
+ endPos += 2;
+
+ var embedHTML = '<!--more-->';
+
+ // Insert embed/object chunk
+ chunkBefore = content.substring(0, startPos);
+ chunkAfter = content.substring(endPos);
+ content = chunkBefore + embedHTML + chunkAfter;
+ }
+ if (attribs['class'] == "mce_plugin_wordpress_page" || attribs['name'] == "mce_plugin_wordpress_page") {
+ endPos += 2;
+
+ var embedHTML = '<!--nextpage-->';
+
+ // Insert embed/object chunk
+ chunkBefore = content.substring(0, startPos);
+ chunkAfter = content.substring(endPos);
+ content = chunkBefore + embedHTML + chunkAfter;
+ }
+ }
+
+ // Remove normal line breaks
+ content = content.replace(/\n|\r/g, ' ');
+
+ // Look for <br> in <pre>, replace with \n
+ var startPos = -1;
+ while ((startPos = content.indexOf('<pre', startPos+1)) != -1) {
+ var endPos = content.indexOf('</pre>', startPos+1);
+ var innerPos = content.indexOf('>', startPos+1);
+ var chunkBefore = content.substring(0, innerPos);
+ var chunkAfter = content.substring(endPos);
+
+ var innards = content.substring(innerPos, endPos);
+ innards = innards.replace(new RegExp('<br\\s?/?>', 'g'), '\n');
+ innards = innards.replace(new RegExp('\\s$', ''), '');
+ content = chunkBefore + innards + chunkAfter;
+ }
+
+ // Remove anonymous, empty paragraphs.
+ content = content.replace(new RegExp('<p>(\\s|&nbsp;)*</p>', 'mg'), '');
+
+ // Handle table badness.
+ content = content.replace(new RegExp('<(table( [^>]*)?)>.*?<((tr|thead)( [^>]*)?)>', 'mg'), '<$1><$3>');
+ content = content.replace(new RegExp('<(tr|thead|tfoot)>.*?<((td|th)( [^>]*)?)>', 'mg'), '<$1><$2>');
+ content = content.replace(new RegExp('</(td|th)>.*?<(td( [^>]*)?|th( [^>]*)?|/tr|/thead|/tfoot)>', 'mg'), '</$1><$2>');
+ content = content.replace(new RegExp('</tr>.*?<(tr|/table)>', 'mg'), '</tr><$1>');
+ content = content.replace(new RegExp('<(/?(table|tbody|tr|th|td)[^>]*)>(\\s*|(<br ?/?>)*)*', 'g'), '<$1>');
+
+ // Pretty it up for the source editor.
+ var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre|p';
+ content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
+ content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>\\s*', 'mg'), '\n<$1>');
+ content = content.replace(new RegExp('<((li|/?tr|/?thead|/?tfoot)( [^>]*)?)>', 'g'), '\t<$1>');
+ content = content.replace(new RegExp('<((td|th)( [^>]*)?)>', 'g'), '\t\t<$1>');
+ content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'mg'), '<br />\n');
+ content = content.replace(new RegExp('^\\s*', ''), '');
+ content = content.replace(new RegExp('\\s*$', ''), '');
+
+ break;
+ }
+
+ // Pass through to next handler in chain
+ return content;
+ },
+
+ handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
+
+ tinyMCE.switchClass(editor_id + '_wp_more', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_wp_page', 'mceButtonNormal');
+
+ if (node == null)
+ return;
+
+ do {
+ if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0)
+ tinyMCE.switchClass(editor_id + '_wp_more', 'mceButtonSelected');
+ if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0)
+ tinyMCE.switchClass(editor_id + '_wp_page', 'mceButtonSelected');
+ } while ((node = node.parentNode));
+
+ return true;
+ },
+
+ saveCallback : function(el, content, body) {
+ // We have a TON of cleanup to do.
+
+ // Mark </p> if it has any attributes.
+ content = content.replace(new RegExp('(<p[^>]+>.*?)</p>', 'mg'), '$1</p#>');
+
+ // Decode the ampersands of time.
+ // content = content.replace(new RegExp('&amp;', 'g'), '&');
+
+ // Get it ready for wpautop.
+ content = content.replace(new RegExp('[\\s]*<p>[\\s]*', 'mgi'), '');
+ content = content.replace(new RegExp('[\\s]*</p>[\\s]*', 'mgi'), '\n\n');
+ content = content.replace(new RegExp('\\n\\s*\\n\\s*\\n*', 'mgi'), '\n\n');
+ content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
+
+ // Fix some block element newline issues
+ var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre';
+ content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
+ content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
+ content = content.replace(new RegExp('<li>', 'g'), '\t<li>');
+
+ // Unmark special paragraph closing tags
+ content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
+ content = content.replace(new RegExp('\\s*(<p[^>]+>.*</p>)', 'mg'), '\n$1');
+
+ // Trim any whitespace
+ content = content.replace(new RegExp('^\\s*', ''), '');
+ content = content.replace(new RegExp('\\s*$', ''), '');
+
+ // Hope.
+ return content;
+
+ },
+
+ _parseAttributes : function(attribute_string) {
+ var attributeName = "";
+ var attributeValue = "";
+ var withInName;
+ var withInValue;
+ var attributes = new Array();
+ var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
+ var titleText = tinyMCE.getLang('lang_wordpress_more');
+ var titleTextPage = tinyMCE.getLang('lang_wordpress_page');
+
+ if (attribute_string == null || attribute_string.length < 2)
+ return null;
+
+ withInName = withInValue = false;
+
+ for (var i=0; i<attribute_string.length; i++) {
+ var chr = attribute_string.charAt(i);
+
+ if ((chr == '"' || chr == "'") && !withInValue)
+ withInValue = true;
+ else if ((chr == '"' || chr == "'") && withInValue) {
+ withInValue = false;
+
+ var pos = attributeName.lastIndexOf(' ');
+ if (pos != -1)
+ attributeName = attributeName.substring(pos+1);
+
+ attributes[attributeName.toLowerCase()] = attributeValue.substring(1).toLowerCase();
+
+ attributeName = "";
+ attributeValue = "";
+ } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)
+ withInName = true;
+
+ if (chr == '=' && withInName)
+ withInName = false;
+
+ if (withInName)
+ attributeName += chr;
+
+ if (withInValue)
+ attributeValue += chr;
+ }
+
+ return attributes;
+ }
+};
+
+tinyMCE.addPlugin("wordpress", TinyMCE_wordpressPlugin);
+
+/* This little hack protects our More and Page placeholders from the removeformat command */
+tinyMCE.orgExecCommand = tinyMCE.execCommand;
+tinyMCE.execCommand = function (command, user_interface, value) {
+ re = this.orgExecCommand(command, user_interface, value);
+
+ if ( command == 'removeformat' ) {
+ var inst = tinyMCE.getInstanceById('mce_editor_0');
+ doc = inst.getDoc();
+ var imgs = doc.getElementsByTagName('img');
+ for (i=0;img=imgs[i];i++)
+ img.className = img.name;
+ }
+ return re;
+};
+
+tinyMCE.orgFixGeckoBaseHREFBug = tinyMCE.fixGeckoBaseHREFBug;
+tinyMCE.fixGeckoBaseHREFBug = function(m, e, h) {
+ if ( tinyMCE.isGecko && m == 1 )
+ h = h.replace(new RegExp('<((a|img|select|area|iframe|base|input|script|embed|object|link)\\s([^>]*\\s)?)(src|href)\\s*=', 'gi'), '<$1 x$4=');
+ else
+ h = tinyMCE.orgFixGeckoBaseHREFBug(m, e, h);
+
+ return h;
+};
+
+tinyMCE.orgStoreAwayURLs = tinyMCE.storeAwayURLs;
+tinyMCE.storeAwayURLs = function(s) {
+ // Remove all mce_src, mce_href and replace them with new ones
+ s = s.replace(new RegExp('mce_(href|src)\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
+ s = s.replace(new RegExp('<((a|img|select|area|iframe|base|input|script|embed|object|link)\\s([^>]*\\s)?)(src|href)\\s*=\\s*"([^"]*)"', 'gi'), '<$1 $4="$5" mce_$4="$5"');
+
+ return s;
+};
diff --git a/wp-inst/wp-includes/js/tinymce/plugins/wordpress/images/help.gif b/wp-inst/wp-includes/js/tinymce/plugins/wordpress/images/help.gif
index 933d853..51a1ee4 100644
--- a/wp-inst/wp-includes/js/tinymce/plugins/wordpress/images/help.gif
+++ b/wp-inst/wp-includes/js/tinymce/plugins/wordpress/images/help.gif
Binary files differ
diff --git a/wp-inst/wp-includes/js/tinymce/plugins/wordpress/langs/en.js b/wp-inst/wp-includes/js/tinymce/plugins/wordpress/langs/en.js
index 30dda2f..f38e89d 100644
--- a/wp-inst/wp-includes/js/tinymce/plugins/wordpress/langs/en.js
+++ b/wp-inst/wp-includes/js/tinymce/plugins/wordpress/langs/en.js
@@ -1,8 +1,33 @@
// EN lang variables
+if (navigator.userAgent.indexOf('Mac OS') != -1) {
+// Mac OS browsers use Ctrl to hit accesskeys
+ var metaKey = 'Ctrl';
+}
+else {
+ var metaKey = 'Alt';
+}
+
tinyMCE.addToLang('',{
-wordpress_more_button : 'Split post with More tag (Alt-t)',
+wordpress_more_button : 'Split post with More tag (' + metaKey + '+t)',
wordpress_page_button : 'Split post with Page tag',
+wordpress_adv_button : 'Show/Hide Advanced Toolbar (' + metaKey + '+b)',
wordpress_more_alt : 'More...',
-wordpress_page_alt : '...page...'
+wordpress_page_alt : '...page...',
+help_button_title : 'Help (' + metaKey + '+h)',
+bold_desc : 'Bold (Ctrl+B)',
+italic_desc : 'Italic (Ctrl+I)',
+underline_desc : 'Underline (Ctrl+U)',
+link_desc : 'Insert/edit link (' + metaKey + '+a)',
+unlink_desc : 'Unlink (' + metaKey + '+s)',
+image_desc : 'Insert/edit image (' + metaKey + '+m)',
+striketrough_desc : 'Strikethrough (' + metaKey + '+k)',
+justifyleft_desc : 'Align left (' + metaKey + '+f)',
+justifycenter_desc : 'Align center (' + metaKey + '+c)',
+justifyright_desc : 'Align right (' + metaKey + '+r)',
+justifyfull_desc : 'Align full (' + metaKey + '+j)',
+bullist_desc : 'Unordered list (' + metaKey + '+l)',
+numlist_desc : 'Ordered list (' + metaKey + '+o)',
+outdent_desc : 'Outdent (' + metaKey + '+w)',
+indent_desc : 'Indent List/Blockquote (' + metaKey + '+q)'
});
diff --git a/wp-inst/wp-includes/js/tinymce/plugins/wordpress/wordpress.css b/wp-inst/wp-includes/js/tinymce/plugins/wordpress/wordpress.css
index b51a098..3698741 100644
--- a/wp-inst/wp-includes/js/tinymce/plugins/wordpress/wordpress.css
+++ b/wp-inst/wp-includes/js/tinymce/plugins/wordpress/wordpress.css
@@ -19,3 +19,66 @@
background-repeat: no-repeat;
background-position: right top;
}
+
+/* This file contains the CSS data for the editable area(iframe) of TinyMCE */
+/* You can extend this CSS by adding your own CSS file with the the content_css option */
+
+body {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 0.9em;
+ line-height: 1.2em;
+ padding: .3em;
+ background-color: #FFFFFF;
+}
+
+td {
+ font-size: 10px;
+}
+
+pre {
+ font-family: "Courier New", fixed;
+ font-size: 11px;
+ line-height: 13px;
+}
+
+.mceVisualAid {
+ border: 1px dashed #BBBBBB !important;
+}
+
+.mceItemAnchor {
+ width: 12px;
+ line-height: 6px;
+ overflow: hidden;
+ padding-left: 12px;
+ background-image: url('../images/anchor_symbol.gif');
+ background-position: bottom;
+ background-repeat: no-repeat;
+}
+
+/* Important is needed in Gecko browsers inorder to style links */
+/*
+a {
+ color: green !important;
+}
+*/
+
+/* Style selection range colors in Gecko browsers */
+/*
+::-moz-selection {
+ background-color: red;
+ color: green;
+}
+*/
+
+/* MSIE specific */
+
+* html body {
+ scrollbar-3dlight-color: #F0F0EE;
+ scrollbar-arrow-color: #676662;
+ scrollbar-base-color: #F0F0EE;
+ scrollbar-darkshadow-color: #DDDDDD;
+ scrollbar-face-color: #E0E0DD;
+ scrollbar-highlight-color: #F0F0EE;
+ scrollbar-shadow-color: #F0F0EE;
+ scrollbar-track-color: #F5F5F5;
+} \ No newline at end of file
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/about.htm b/wp-inst/wp-includes/js/tinymce/themes/advanced/about.htm
index bbd8d13..2a86227 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/about.htm
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/about.htm
@@ -4,7 +4,7 @@
<script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script language="javascript" type="text/javascript" src="../../utils/mctabs.js"></script>
<script language="javascript" type="text/javascript" src="jscripts/about.js"></script>
- <link href="css/dialog_about.css" rel="stylesheet" type="text/css" />
+ <base target="_self" />
</head>
<body id="about" onload="tinyMCEPopup.executeOnLoad('init();');" style="display: none">
<div class="tabs">
@@ -21,7 +21,7 @@
<p>Version: {$tinymce_version} ({$tinymce_releasedate})</p>
<p>TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under <a href="../../license.txt" target="_blank">LGPL</a>
by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances.</p>
- <p>Copyright &copy; 2005, <a href="http://www.moxiecode.com" target="_blank">Moxiecode Systems AB</a>, All rights reserved.</p>
+ <p>Copyright &copy; 2003-2006, <a href="http://www.moxiecode.com" target="_blank">Moxiecode Systems AB</a>, All rights reserved.</p>
<p>For more information about this software visit the <a href="http://tinymce.moxiecode.com" target="_blank">TinyMCE website</a>.</p>
<div id="buttoncontainer"></div>
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/anchor.htm b/wp-inst/wp-includes/js/tinymce/themes/advanced/anchor.htm
index 48ba245..988bcb6 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/anchor.htm
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/anchor.htm
@@ -3,6 +3,7 @@
<title>{$lang_insert_anchor_title}</title>
<script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script language="javascript" type="text/javascript" src="jscripts/anchor.js"></script>
+ <base target="_self" />
</head>
<body onload="tinyMCEPopup.executeOnLoad('init();');" style="display: none">
<form onsubmit="insertAnchor();return false;" action="#">
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/charmap.htm b/wp-inst/wp-includes/js/tinymce/themes/advanced/charmap.htm
index bcebff2..9dac168 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/charmap.htm
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/charmap.htm
@@ -4,8 +4,9 @@
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script language="javascript" type="text/javascript" src="jscripts/charmap.js"></script>
+ <base target="_self" />
</head>
-<body onload="tinyMCEPopup.executeOnLoad('init();');" style="display: none">
+<body onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('insert').focus();" style="display: none">
<table align="center" border="0" cellspacing="0" cellpadding="2">
<tr>
<td colspan="2" class="title">{$lang_theme_charmap_title}</td>
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/color_picker.htm b/wp-inst/wp-includes/js/tinymce/themes/advanced/color_picker.htm
index e35d711..725466e 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/color_picker.htm
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/color_picker.htm
@@ -3,8 +3,9 @@
<title>{$lang_theme_colorpicker_title}</title>
<script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script language="javascript" type="text/javascript" src="jscripts/color_picker.js"></script>
+ <base target="_self" />
</head>
-<body onload="tinyMCEPopup.executeOnLoad('init();');" marginheight="3" topmargin="3" leftmargin="3" marginwidth="3" style="display: none">
+<body onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('insert').focus();" style="margin: 3px; display: none">
<div align="center">
<script language="javascript" type="text/javascript">renderColorMap();</script>
</div>
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_content.css b/wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_content.css
index 7dbe1fe..11f75df 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_content.css
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_content.css
@@ -1,22 +1,13 @@
/* This file contains the CSS data for the editable area(iframe) of TinyMCE */
/* You can extend this CSS by adding your own CSS file with the the content_css option */
-body {
- background-color: #FFFFFF;
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 0.9em;
- line-height: 1.2em;
- padding: .3em;
-}
-
-td {
+body, td, pre {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
}
-pre {
- font-family: Verdana, Arial, Helvetica, sans-serif;
- font-size: 10px;
+body {
+ background-color: #FFFFFF;
}
.mceVisualAid {
@@ -47,3 +38,16 @@ a {
color: green;
}
*/
+
+/* MSIE specific */
+
+* html body {
+ scrollbar-3dlight-color: #F0F0EE;
+ scrollbar-arrow-color: #676662;
+ scrollbar-base-color: #F0F0EE;
+ scrollbar-darkshadow-color: #DDDDDD;
+ scrollbar-face-color: #E0E0DD;
+ scrollbar-highlight-color: #F0F0EE;
+ scrollbar-shadow-color: #F0F0EE;
+ scrollbar-track-color: #F5F5F5;
+}
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css b/wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css
index 14f8322..3b42925 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css
@@ -35,14 +35,14 @@ input, select, textarea {
}
.input_noborder {
- border: 0px solid #808080;
+ border: 0;
}
-#insert {
+#insert, .updateButton {
font-weight: bold;
width: 90px;
height: 21px;
- border: 0px;
+ border: 0;
background-image: url('../images/insert_button_bg.gif');
cursor: pointer;
}
@@ -51,7 +51,7 @@ input, select, textarea {
font-weight: bold;
width: 90px;
height: 21px;
- border: 0px;
+ border: 0;
background-image: url('../images/cancel_button_bg.gif');
cursor: pointer;
}
@@ -84,7 +84,7 @@ td.charmap, td.charmapOver {
td.charmapOver {
background-color: #CCCCCC;
- cursor: arrow;
+ cursor: default;
}
a.charmap {
@@ -120,17 +120,17 @@ input.checkbox {
border-bottom: 1px solid;
border-right: 1px solid;
border-color: #F0F0EE;
- cursor: arrow;
+ cursor: default;
}
.mceButtonOver {
border: 1px solid #0A246A;
- cursor: arrow;
+ cursor: default;
background-color: #B6BDD2;
}
.mceButtonDown {
- cursor: arrow;
+ cursor: default;
border: 1px solid #0A246A;
background-color: #8592B5;
}
@@ -144,7 +144,7 @@ input.checkbox {
border-bottom: 1px solid;
border-right: 1px solid;
border-color: #F0F0EE;
- cursor: arrow;
+ cursor: default;
}
.mceActionPanel {
@@ -162,7 +162,7 @@ input.checkbox {
.tabs ul {
margin: 0;
- padding: 0px 0px 0;
+ padding: 0 0 0;
list-style: none;
}
@@ -170,7 +170,7 @@ input.checkbox {
float: left;
background: url("../images/xp/tab_bg.gif") no-repeat left top;
margin: 0;
- margin-left: 0px;
+ margin-left: 0;
margin-right: 2px;
padding: 0 0 0 10px;
line-height: 18px;
@@ -185,7 +185,7 @@ input.checkbox {
float: left;
display: block;
background: url("../images/xp/tab_end.gif") no-repeat right top;
- padding: 0px 10px 0px 0px;
+ padding: 0px 10px 0 0;
}
.tabs .current span {
@@ -235,8 +235,8 @@ fieldset {
border: 1px solid #919B9C;
font-family: Verdana, Arial;
font-size: 10px;
- padding: 0px;
- margin: 0px;
+ padding: 0;
+ margin: 0;
padding: 4px;
}
@@ -295,8 +295,8 @@ a:hover {
h1, h2, h3, h4 {
color: #2B6FB6;
- margin: 0px;
- padding: 0px;
+ margin: 0;
+ padding: 0;
padding-top: 5px;
}
@@ -304,6 +304,14 @@ h3 {
font-size: 14px;
}
+#link .panel_wrapper, #link div.current {
+ height: 125px;
+}
+
+#image .panel_wrapper, #image div.current {
+ height: 190px;
+}
+
/* Disables the advanced tab in the table plugin. */
/*
#table #advanced_tab {
@@ -317,3 +325,30 @@ h3 {
display: none;
}
*/
+
+/* Below this line is WordPress customizations */
+#insert, #cancel, .submitbutton {
+ font: 11px Verdana, Arial, Helvetica, sans-serif;
+ height: auto;
+ width: auto;
+ background-color: transparent;
+ background-image: url(../../../../../../wp-admin/images/fade-butt.png);
+ background-repeat: repeat;
+ border: 3px double;
+ border-right-color: rgb(153, 153, 153);
+ border-bottom-color: rgb(153, 153, 153);
+ border-left-color: rgb(204, 204, 204);
+ border-top-color: rgb(204, 204, 204);
+ color: rgb(51, 51, 51);
+ padding: 0.1em 0.5em;
+}
+
+#insert:active, #cancel:active, .submitbutton:active {
+ background: #f4f4f4;
+ border-left-color: #999;
+ border-top-color: #999;
+}
+
+#styleSelectRow {
+ display: none;
+}
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css b/wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css
index f2f5eff..04fccc7 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css
@@ -1,84 +1,25 @@
/* This file contains the CSS data for the editor UI of TinyMCE instances */
.mceToolbarTop a, .mceToolbarTop a:visited, .mceToolbarTop a:hover, .mceToolbarBottom a, .mceToolbarBottom a:visited, .mceToolbarBottom a:hover {
- border: 0px; margin: 0px; padding: 0px; background: transparent;
-}
-
-.mceButtonNormal, .mceButtonOver, .mceButtonDown, .mceSeparator, .mceSeparatorLine, .mceButtonDisabled, .mceButtonSelected {
- border: 0px; margin: 0px; padding: 0px; background: transparent;
- margin-top: 1px;
- margin-left: 1px;
-}
-
-.mceButtonNormal {
- border-top: 1px solid;
- border-left: 1px solid;
- border-bottom: 1px solid;
- border-right: 1px solid;
- border-color: #F0F0EE;
- cursor: arrow;
-}
-
-.mceButtonOver {
- border: 1px solid #0A246A;
- cursor: arrow;
- background-color: #B6BDD2;
-}
-
-.mceButtonDown {
- cursor: arrow;
- border: 1px solid #0A246A;
- background-color: #8592B5;
-}
-
-.mceButtonSelected {
- border: 1px solid;
- border-color: #C0C0BB;
- cursor: arrow;
-}
-
-.mceButtonDisabled {
- filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);
- -moz-opacity:0.3;
- opacity: 0.3;
- border-top: 1px solid;
- border-left: 1px solid;
- border-bottom: 1px solid;
- border-right: 1px solid;
- border-color: #F0F0EE;
- cursor: arrow;
-}
-
-.mceSeparator {
- border-top: 1px solid buttonhighlight;
- border-left: 1px solid buttonhighlight;
- border-bottom: 1px solid buttonshadow;
- border-right: 1px solid buttonshadow;
- margin-right: 2px;
- margin-left: 2px;
+ border: 0; margin: 0; padding: 0; background: transparent;
}
.mceSeparatorLine {
- margin:2px;
+ border: 0;
+ padding: 0;
margin-left: 4px;
- background-color: #F0F0EE;
- border-top: 1px solid buttonshadow;
- border-left: 1px solid buttonshadow;
- border-bottom: 1px solid buttonhighlight;
- border-right: 1px solid buttonhighlight;
- width: 0px;
- height: 15px;
+ margin-right: 2px;
}
.mceSelectList {
- font-family: "MS Sans Serif";
- font-size: 7pt;
+ font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
+ font-size: 7pt !important;
font-weight: normal;
margin-top: 3px;
- padding: 0px;
+ padding: 0;
display: inline;
vertical-align: top;
- background-color: #F0F0EE
+ background-color: #F0F0EE;
}
.mceLabel, .mceLabelDisabled {
@@ -98,15 +39,15 @@
.mceEditor {
background: #F0F0EE;
border: 1px solid #cccccc;
- padding: 0px;
- margin: 0px;
+ padding: 0;
+ margin: 0;
}
.mceEditorArea {
font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
background: #FFFFFF;
- padding: 0px;
- margin: 0px;
+ padding: 0;
+ margin: 0;
}
.mceToolbarTop, .mceToolbarBottom {
@@ -117,6 +58,7 @@
.mceToolbarTop {
border-bottom: 1px solid #cccccc;
+ padding-bottom: 1px;
}
.mceToolbarBottom {
@@ -176,6 +118,231 @@
height: 10px;
display: none;
border: 1px dotted gray;
- margin: 0px;
- padding: 0px;
+ margin: 0;
+ padding: 0;
+}
+
+/* Button CSS rules */
+
+a.mceButtonDisabled img, a.mceButtonNormal img, a.mceButtonSelected img {
+ width: 20px;
+ height: 20px;
+ cursor: default;
+ margin-top: 1px;
+ margin-left: 1px;
+}
+
+a.mceButtonDisabled img {
+ border: 0 !important;
+}
+
+a.mceButtonNormal img, a.mceButtonSelected img {
+ border: 1px solid #F0F0EE !important;
+}
+
+a.mceButtonSelected img {
+ border: 1px solid #6779AA !important;
+ background-color: #D4D5D8;
+}
+
+a.mceButtonNormal img:hover, a.mceButtonSelected img:hover {
+ border: 1px solid #0A246A !important;
+ cursor: default;
+ background-color: #B6BDD2;
+}
+
+a.mceButtonDisabled img {
+ -moz-opacity:0.3;
+ opacity: 0.3;
+ border: 1px solid #F0F0EE !important;
+ cursor: default;
+}
+
+a.mceTiledButton img {
+ background-image: url('../images/buttons.gif');
+ background-repeat: no-repeat;
+}
+
+/* MSIE specific rules */
+
+* html a.mceButtonNormal img, * html a.mceButtonSelected img, * html a.mceButtonDisabled img {
+ border: 0 !important;
+ margin-top: 2px;
+ margin-bottom: 1px;
+}
+
+* html a.mceButtonDisabled img {
+ filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);
+ border: 0 !important;
+}
+
+* html a.mceButtonDisabled {
+ border: 1px solid #F0F0EE !important;
+}
+
+* html a.mceButtonNormal, * html a.mceButtonSelected {
+ border: 1px solid #F0F0EE !important;
+ cursor: default;
+}
+
+* html a.mceButtonSelected {
+ border: 1px solid #6779AA !important;
+ background-color: #D4D5D8;
+}
+
+* html a.mceButtonNormal:hover, * html a.mceButtonSelected:hover {
+ border: 1px solid #0A246A !important;
+ cursor: default;
+ background-color: #B6BDD2;
+}
+
+* html .mceSelectList {
+ margin-top: 2px;
+}
+
+/* Menu button CSS rules */
+
+span.mceMenuButton img, span.mceMenuButtonSelected img {
+ border: 1px solid #F0F0EE;
+ margin-left: 1px;
+}
+
+span.mceMenuButtonSelected img {
+ border: 1px solid #6779AA;
+ background-color: #B6BDD2;
+}
+
+span.mceMenuButtonSelected img.mceMenuButton {
+ border: 1px solid #F0F0EE;
+ background-color: transparent;
+}
+
+span.mceMenuButton img.mceMenuButton, span.mceMenuButtonSelected img.mceMenuButton {
+ border-left: 0;
+ margin-left: 0;
+}
+
+span.mceMenuButton:hover img, span.mceMenuButtonSelected:hover img {
+ border: 1px solid #0A246A;
+ background-color: #B6BDD2;
+}
+
+span.mceMenuButton:hover img.mceMenuButton, span.mceMenuButtonSelected:hover img.mceMenuButton {
+ border-left: 0;
+}
+
+span.mceMenuButtonFocus img {
+ border: 1px solid gray;
+ border-right: 0;
+ margin-left: 1px;
+ background-color: #F5F4F2;
+}
+
+span.mceMenuButtonFocus img.mceMenuButton {
+ border: 1px solid gray;
+ border-left: 1px solid #F5F4F2;
+ margin-left: 0;
+}
+
+/* Menu button MSIE specific rules */
+
+* html span.mceMenuButton, * html span.mceMenuButtonFocus {
+ position: relative;
+ left: 0;
+ top: 0;
+}
+
+* html span.mceMenuButton img, * html span.mceMenuButtonSelected img, * html span.mceMenuButtonFocus img {
+ position: relative;
+ top: 1px;
+}
+
+* html span.mceMenuHover img {
+ border: 1px solid #0A246A;
+ background-color: #B6BDD2;
+}
+
+* html span.mceMenuButtonSelected.mceMenuHover img.mceMenuButton {
+ border: 1px solid #0A246A;
+ background-color: #B6BDD2;
+ border-left: 0;
+}
+
+/* Menu */
+
+.mceMenu {
+ position: absolute;
+ left: 0;
+ top: 0;
+ display: none;
+ z-index: 100;
+ background-color: white;
+ border: 1px solid gray;
+ font-weight: normal;
+}
+
+.mceMenu a, .mceMenuTitle, .mceMenuDisabled {
+ display: block;
+ width: 100%;
+ text-decoration: none;
+ background-color: white;
+ font-family: Tahoma, Verdana, Arial, Helvetica;
+ font-size: 11px;
+ line-height: 20px;
+ color: black;
+}
+
+.mceMenu a:hover {
+ background-color: #B6BDD2;
+ color: black;
+}
+
+.mceMenu span {
+ padding-left: 10px;
+ padding-right: 10px;
+ display: block;
+ line-height: 20px;
+}
+
+.mceMenuSeparator {
+ border-bottom: 1px solid gray;
+ background-color: gray;
+ height: 1px;
+}
+
+.mceMenuTitle span {
+ padding-left: 5px;
+}
+
+.mceMenuTitle {
+ background-color: #DDDDDD;
+ font-weight: bold;
+}
+
+.mceMenuDisabled {
+ color: gray;
+}
+
+span.mceMenuSelectedItem {
+ background-image: url('../images/menu_check.gif');
+ background-repeat: no-repeat;
+ background-position: 5px 8px;
+ padding-left: 20px;
+}
+
+span.mceMenuCheckItem {
+ padding-left: 20px;
+}
+
+span.mceMenuLine {
+ display: block;
+ position: absolute;
+ left: 0;
+ top: -1px;
+ background-color: #F5F4F2;
+ width: 30px;
+ height: 1px;
+ overflow: hidden;
+ padding-left: 0;
+ padding-right: 0;
}
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/editor_template.js b/wp-inst/wp-includes/js/tinymce/themes/advanced/editor_template.js
index 0dd4074..5a3e09c 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/editor_template.js
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/editor_template.js
@@ -1,13 +1,1409 @@
+/**
+ * $RCSfile: editor_template_src.js,v $
+ * $Revision: 1.93 $
+ * $Date: 2006/03/14 17:33:50 $
+ *
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
+ */
+
/* Import theme specific language pack */
- tinyMCE.importThemeLanguagePack('advanced');var TinyMCE_advanced_autoImportCSSClasses=true;var TinyMCE_advanced_resizer=new Object();var TinyMCE_advanced_buttons=[['bold','{$lang_bold_img}','{$lang_bold_desc}','Bold'],['italic','{$lang_italic_img}','{$lang_italic_desc}','Italic'],['underline','{$lang_underline_img}','{$lang_underline_desc}','Underline'],['strikethrough','strikethrough.gif','{$lang_striketrough_desc}','Strikethrough'],['justifyleft','left.gif','{$lang_justifyleft_desc}','JustifyLeft'],['justifycenter','center.gif','{$lang_justifycenter_desc}','JustifyCenter'],['justifyright','right.gif','{$lang_justifyright_desc}','JustifyRight'],['justifyfull','full.gif','{$lang_justifyfull_desc}','JustifyFull'],['bullist','bullist.gif','{$lang_bullist_desc}','InsertUnorderedList'],['numlist','numlist.gif','{$lang_numlist_desc}','InsertOrderedList'],['outdent','outdent.gif','{$lang_outdent_desc}','Outdent'],['indent','indent.gif','{$lang_indent_desc}','Indent'],['cut','cut.gif','{$lang_cut_desc}','Cut'],['copy','copy.gif','{$lang_copy_desc}','Copy'],['paste','paste.gif','{$lang_paste_desc}','Paste'],['undo','undo.gif','{$lang_undo_desc}','Undo'],['redo','redo.gif','{$lang_redo_desc}','Redo'],['link','link.gif','{$lang_link_desc}','mceLink',true],['unlink','unlink.gif','{$lang_unlink_desc}','unlink'],['image','image.gif','{$lang_image_desc}','mceImage',true],['cleanup','cleanup.gif','{$lang_cleanup_desc}','mceCleanup'],['help','help.gif','{$lang_help_desc}','mceHelp'],['code','code.gif','{$lang_theme_code_desc}','mceCodeEditor'],['hr','hr.gif','{$lang_theme_hr_desc}','inserthorizontalrule'],['removeformat','removeformat.gif','{$lang_theme_removeformat_desc}','removeformat'],['sub','sub.gif','{$lang_theme_sub_desc}','subscript'],['sup','sup.gif','{$lang_theme_sup_desc}','superscript'],['forecolor','forecolor.gif','{$lang_theme_forecolor_desc}','mceForeColor',true],['backcolor','backcolor.gif','{$lang_theme_backcolor_desc}','mceBackColor',true],['charmap','charmap.gif','{$lang_theme_charmap_desc}','mceCharMap'],['visualaid','visualaid.gif','{$lang_theme_visualaid_desc}','mceToggleVisualAid'],['anchor','anchor.gif','{$lang_theme_anchor_desc}','mceInsertAnchor'],['newdocument','newdocument.gif','{$lang_newdocument_desc}','mceNewDocument']];function TinyMCE_advanced_getControlHTML(button_name){var buttonTileMap=new Array('anchor.gif','backcolor.gif','bullist.gif','center.gif','charmap.gif','cleanup.gif','code.gif','copy.gif','custom_1.gif','cut.gif','forecolor.gif','full.gif','help.gif','hr.gif','image.gif','indent.gif','left.gif','link.gif','numlist.gif','outdent.gif','paste.gif','redo.gif','removeformat.gif','right.gif','strikethrough.gif','sub.gif','sup.gif','undo.gif','unlink.gif','visualaid.gif');for(var i=0;i<TinyMCE_advanced_buttons.length;i++){var but=TinyMCE_advanced_buttons[i];if(but[0]==button_name){if(tinyMCE.settings['button_tile_map']){for(var x=0;!tinyMCE.isMSIE&&x<buttonTileMap.length;x++){if(buttonTileMap[x]==but[1]){var cmd='tinyMCE.execInstanceCommand(\'{$editor_id}\',\''+but[3]+'\','+(but.length>4?but[4]:false)+(but.length>5?',\''+but[5]+'\'':'')+')';return '<a href="javascript:'+cmd+'" onclick="'+cmd+';return false;" onmousedown="return false;" target="_self"><img id="{$editor_id}_'+but[0]+'" src="{$themeurl}/images/spacer.gif" style="background-image:url({$themeurl}/images/buttons.gif); background-position: '+(0-(x*20))+'px 0px" title="'+but[2]+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';}}}var cmd='tinyMCE.execInstanceCommand(\'{$editor_id}\',\''+but[3]+'\','+(but.length>4?but[4]:false)+(but.length>5?',\''+but[5]+'\'':'')+')';return '<a href="javascript:'+cmd+'" onclick="'+cmd+';return false;" onmousedown="return false;" target="_self"><img id="{$editor_id}_'+but[0]+'" src="{$themeurl}/images/'+but[1]+'" title="'+but[2]+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';}}switch(button_name){case "formatselect":var html='<select id="{$editor_id}_formatSelect" name="{$editor_id}_formatSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FormatBlock\',false,this.options[this.selectedIndex].value);" class="mceSelectList">';var formats=tinyMCE.getParam("theme_advanced_blockformats","p,address,pre,h1,h2,h3,h4,h5,h6",true).split(',');var lookup=[['p','{$lang_theme_paragraph}'],['address','{$lang_theme_address}'],['pre','{$lang_theme_pre}'],['h1','{$lang_theme_h1}'],['h2','{$lang_theme_h2}'],['h3','{$lang_theme_h3}'],['h4','{$lang_theme_h4}'],['h5','{$lang_theme_h5}'],['h6','{$lang_theme_h6}']];html+='<option value="">{$lang_theme_block}</option>';for(var i=0;i<formats.length;i++){for(var x=0;x<lookup.length;x++){if(formats[i]==lookup[x][0]){html+='<option value="<'+lookup[x][0]+'>">'+lookup[x][1]+'</option>';}}}html+='</select>';return html;case "styleselect":return '<select id="{$editor_id}_styleSelect" onmousedown="TinyMCE_advanced_setupCSSClasses(\'{$editor_id}\');" name="{$editor_id}_styleSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSetCSSClass\',false,this.options[this.selectedIndex].value);" class="mceSelectList">{$style_select_options}</select>';case "fontselect":var fontHTML='<select id="{$editor_id}_fontNameSelect" name="{$editor_id}_fontNameSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontName\',false,this.options[this.selectedIndex].value);" class="mceSelectList"><option value="">{$lang_theme_fontdefault}</option>';var iFonts='Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;WingDings=wingdings';var nFonts='Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sand;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats';var fonts=tinyMCE.getParam("theme_advanced_fonts",nFonts).split(';');for(var i=0;i<fonts.length;i++){if(fonts[i]!=''){var parts=fonts[i].split('=');fontHTML+='<option value="'+parts[1]+'">'+parts[0]+'</option>';}}fontHTML+='</select>';return fontHTML;case "fontsizeselect":return '<select id="{$editor_id}_fontSizeSelect" name="{$editor_id}_fontSizeSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontSize\',false,this.options[this.selectedIndex].value);" class="mceSelectList">\
- <option value="0">{$lang_theme_font_size}</option>\
- <option value="1">1 (8 pt)</option>\
- <option value="2">2 (10 pt)</option>\
- <option value="3">3 (12 pt)</option>\
- <option value="4">4 (14 pt)</option>\
- <option value="5">5 (18 pt)</option>\
- <option value="6">6 (24 pt)</option>\
- <option value="7">7 (36 pt)</option>\
- </select>';case "|":case "separator":return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" class="mceSeparatorLine">';case "spacer":return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" border="0" class="mceSeparatorLine" style="vertical-align: middle" />';case "rowseparator":return '<br />';}return "";}function TinyMCE_advanced_execCommand(editor_id,element,command,user_interface,value){switch(command){case "mceForeColor":var template=new Array();var elm=tinyMCE.selectedInstance.getFocusElement();var inputColor=tinyMCE.getAttrib(elm,"color");if(inputColor=='')inputColor=elm.style.color;if(!inputColor)inputColor="#000000";template['file']='color_picker.htm';template['width']=220;template['height']=190;tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes",command:"forecolor",input_color:inputColor});return true;case "mceBackColor":var template=new Array();var elm=tinyMCE.selectedInstance.getFocusElement();var inputColor=elm.style.backgroundColor;if(!inputColor)inputColor="#000000";template['file']='color_picker.htm';template['width']=220;template['height']=190;template['width']+=tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes",command:"HiliteColor",input_color:inputColor});return true;case "mceColorPicker":if(user_interface){var template=new Array();var inputColor=value['document'].getElementById(value['element_id']).value;template['file']='color_picker.htm';template['width']=220;template['height']=190;template['close_previous']="no";template['width']+=tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height',0);if(typeof(value['store_selection'])=="undefined")value['store_selection']=true;tinyMCE.lastColorPickerValue=value;tinyMCE.openWindow(template,{editor_id:editor_id,mce_store_selection:value['store_selection'],inline:"yes",command:"mceColorPicker",input_color:inputColor});}else{var savedVal=tinyMCE.lastColorPickerValue;var elm=savedVal['document'].getElementById(savedVal['element_id']);elm.value=value;eval('elm.onchange();');}return true;case "mceCodeEditor":var template=new Array();template['file']='source_editor.htm';template['width']=parseInt(tinyMCE.getParam("theme_advanced_source_editor_width",500));template['height']=parseInt(tinyMCE.getParam("theme_advanced_source_editor_height",400));tinyMCE.openWindow(template,{editor_id:editor_id,resizable:"yes",scrollbars:"no",inline:"yes"});return true;case "mceCharMap":var template=new Array();template['file']='charmap.htm';template['width']=550+(tinyMCE.isOpera?40:0);template['height']=250;template['width']+=tinyMCE.getLang('lang_theme_advanced_charmap_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_charmap_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes"});return true;case "mceInsertAnchor":var template=new Array();template['file']='anchor.htm';template['width']=320;template['height']=90+(tinyMCE.isNS7?30:0);template['width']+=tinyMCE.getLang('lang_theme_advanced_anchor_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_anchor_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes"});return true;case "mceNewDocument":if(confirm(tinyMCE.getLang('lang_newdocument')))tinyMCE.execInstanceCommand(editor_id,'mceSetContent',false,'');return true;}return false;}function TinyMCE_advanced_getEditorTemplate(settings,editorId){function removeFromArray(in_array,remove_array){var outArray=new Array();for(var i=0;i<in_array.length;i++){skip=false;for(var j=0;j<remove_array.length;j++){if(in_array[i]==remove_array[j]){skip=true;}}if(!skip){outArray[outArray.length]=in_array[i];}}return outArray;}function addToArray(in_array,add_array){for(var i=0;i<add_array.length;i++){in_array[in_array.length]=add_array[i];}return in_array;}var template=new Array();var deltaHeight=0;var resizing=tinyMCE.getParam("theme_advanced_resizing",false);var path=tinyMCE.getParam("theme_advanced_path",true);var statusbarHTML='<div id="{$editor_id}_path" class="mceStatusbarPathText" style="display: '+(path?"block":"none")+'">&nbsp;</div><div id="{$editor_id}_resize" class="mceStatusbarResize" style="display: '+(resizing?"block":"none")+'" onmousedown="TinyMCE_advanced_setResizing(event,\'{$editor_id}\',true);"></div><br style="clear: both" />';var layoutManager=tinyMCE.getParam("theme_advanced_layout_manager","SimpleLayout");var styleSelectHTML='<option value="">{$lang_theme_style_select}</option>';if(settings['theme_advanced_styles']){var stylesAr=settings['theme_advanced_styles'].split(';');for(var i=0;i<stylesAr.length;i++){var key,value;key=stylesAr[i].split('=')[0];value=stylesAr[i].split('=')[1];styleSelectHTML+='<option value="'+value+'">'+key+'</option>';}TinyMCE_advanced_autoImportCSSClasses=false;}switch(layoutManager){case "SimpleLayout":var toolbarHTML="";var toolbarLocation=tinyMCE.getParam("theme_advanced_toolbar_location","bottom");var toolbarAlign=tinyMCE.getParam("theme_advanced_toolbar_align","center");var pathLocation=tinyMCE.getParam("theme_advanced_path_location","none");var statusbarLocation=tinyMCE.getParam("theme_advanced_statusbar_location",pathLocation);var defVals={theme_advanced_buttons1:"bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect",theme_advanced_buttons2:"bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code",theme_advanced_buttons3:"hr,removeformat,visualaid,separator,sub,sup,separator,charmap"};/*toolbarHTML+='<a href="#" accesskey="q" title="'+tinyMCE.getLang("lang_toolbar_focus")+'"></a>';*/for(var i=1;i<100;i++){var def=defVals["theme_advanced_buttons"+i];var buttons=tinyMCE.getParam("theme_advanced_buttons"+i,def==null?'':def,true,',');if(buttons.length==0)break;buttons=removeFromArray(buttons,tinyMCE.getParam("theme_advanced_disable","",true,','));buttons=addToArray(buttons,tinyMCE.getParam("theme_advanced_buttons"+i+"_add","",true,','));buttons=addToArray(tinyMCE.getParam("theme_advanced_buttons"+i+"_add_before","",true,','),buttons);for(var b=0;b<buttons.length;b++)toolbarHTML+=tinyMCE.getControlHTML(buttons[b]);if(buttons.length>0){toolbarHTML+="<br />";deltaHeight-=23;}}toolbarHTML+='<a href="#" accesskey="z" onfocus="tinyMCE.getInstanceById(\''+editorId+'\').getWin().focus();"></a>';template['html']='<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';if(toolbarLocation=="top"){template['html']+='<tr><td class="mceToolbarTop" align="'+toolbarAlign+'" height="1" nowrap="nowrap">'+toolbarHTML+'</td></tr>';}if(statusbarLocation=="top"){template['html']+='<tr><td class="mceStatusbarTop" height="1">'+statusbarHTML+'</td></tr>';deltaHeight-=23;}template['html']+='<tr><td align="center"><span id="{$editor_id}"></span></td></tr>';if(toolbarLocation=="bottom"){template['html']+='<tr><td class="mceToolbarBottom" align="'+toolbarAlign+'" height="1">'+toolbarHTML+'</td></tr>';}if(toolbarLocation=="external"){var bod=document.body;var elm=document.createElement("div");toolbarHTML=tinyMCE.replaceVars(toolbarHTML,tinyMCE.settings);toolbarHTML=tinyMCE.replaceVars(toolbarHTML,tinyMCELang);toolbarHTML=tinyMCE.replaceVar(toolbarHTML,'style_select_options',styleSelectHTML);toolbarHTML=tinyMCE.replaceVar(toolbarHTML,"editor_id",editorId);toolbarHTML=tinyMCE.applyTemplate(toolbarHTML);elm.className="mceToolbarExternal";elm.id=editorId+"_toolbar";elm.innerHTML='<table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table>';bod.appendChild(elm);deltaHeight=0;tinyMCE.getInstanceById(editorId).toolbarElement=elm;}else{tinyMCE.getInstanceById(editorId).toolbarElement=null;}if(statusbarLocation=="bottom"){template['html']+='<tr><td class="mceStatusbarBottom" height="1">'+statusbarHTML+'</td></tr>';deltaHeight-=23;}template['html']+='</tbody></table>';break;case "RowLayout":template['html']='<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';var containers=tinyMCE.getParam("theme_advanced_containers","",true,",");var defaultContainerCSS=tinyMCE.getParam("theme_advanced_containers_default_class","container");var defaultContainerAlign=tinyMCE.getParam("theme_advanced_containers_default_align","center");for(var i=0;i<containers.length;i++){if(containers[i]=="mceEditor"){template['html']+='<tr><td align="center" class="mceEditor_border">\
- <span id="{$editor_id}"></span>\
- </td></tr>';}else if(containers[i]=="mceElementpath"||containers[i]=="mceStatusbar"){var pathClass="mceStatusbar";if(i==containers.length-1){pathClass="mceStatusbarBottom";}else if(i==0){pathClass="mceStatusbar";}else{deltaHeight-=2;}template['html']+='<tr><td class="'+pathClass+'" height="1">'+statusbarHTML+'</td></tr>';deltaHeight-=22;}else{var curContainer=tinyMCE.getParam("theme_advanced_container_"+containers[i],"",true,',');var curContainerHTML="";var curAlign=tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align",defaultContainerAlign);var curCSS=tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class",defaultContainerCSS);for(var j=0;j<curContainer.length;j++){curContainerHTML+=tinyMCE.getControlHTML(curContainer[j]);}if(curContainer.length>0){curContainerHTML+="<br />";deltaHeight-=23;}template['html']+='<tr><td class="'+curCSS+'" align="'+curAlign+'" height="1">'+curContainerHTML+'</td></tr>';}}template['html']+='</tbody></table>';break;case "BorderLayout":break;case "CustomLayout":var customLayout=tinyMCE.getParam("theme_advanced_custom_layout","");if(customLayout!=""&&eval("typeof("+customLayout+")")!="undefined"){template=eval(customLayout+"(template);");}break;default:alert('UNDEFINED LAYOUT MANAGER! PLEASE CHECK YOUR TINYMCE CONFIG!');break;}template['html']+='<div id="{$editor_id}_resize_box" class="mceResizeBox"></div>';template['html']=tinyMCE.replaceVar(template['html'],'style_select_options',styleSelectHTML);template['delta_width']=0;template['delta_height']=deltaHeight;return template;}function TinyMCE_advanced_setResizing(e,editor_id,state){e=typeof(e)=="undefined"?window.event:e;var resizer=TinyMCE_advanced_resizer;var editorContainer=document.getElementById(editor_id+'_parent');var editorArea=document.getElementById(editor_id+'_parent').firstChild;var resizeBox=document.getElementById(editor_id+'_resize_box');var inst=tinyMCE.getInstanceById(editor_id);if(state){var width=editorArea.clientWidth;var height=editorArea.clientHeight;resizeBox.style.width=width+"px";resizeBox.style.height=height+"px";resizer.iframeWidth=inst.iframeElement.clientWidth;resizer.iframeHeight=inst.iframeElement.clientHeight;editorArea.style.display="none";resizeBox.style.display="block";if(!resizer.eventHandlers){if(tinyMCE.isMSIE)tinyMCE.addEvent(document,"mousemove",TinyMCE_advanced_resizeEventHandler);else tinyMCE.addEvent(window,"mousemove",TinyMCE_advanced_resizeEventHandler);tinyMCE.addEvent(document,"mouseup",TinyMCE_advanced_resizeEventHandler);resizer.eventHandlers=true;}resizer.resizing=true;resizer.downX=e.screenX;resizer.downY=e.screenY;resizer.width=parseInt(resizeBox.style.width);resizer.height=parseInt(resizeBox.style.height);resizer.editorId=editor_id;resizer.resizeBox=resizeBox;resizer.horizontal=tinyMCE.getParam("theme_advanced_resize_horizontal",true);}else{resizer.resizing=false;resizeBox.style.display="none";editorArea.style.display=tinyMCE.isMSIE?"block":"table";tinyMCE.execCommand('mceResetDesignMode');}}function TinyMCE_advanced_initInstance(inst){if(tinyMCE.getParam("theme_advanced_resizing",false)){if(tinyMCE.getParam("theme_advanced_resizing_use_cookie",true)){var w=TinyMCE_advanced_getCookie("TinyMCE_"+inst.editorId+"_width");var h=TinyMCE_advanced_getCookie("TinyMCE_"+inst.editorId+"_height");TinyMCE_advanced_resizeTo(inst,w,h,tinyMCE.getParam("theme_advanced_resize_horizontal",true));}}}function TinyMCE_advanced_setCookie(name,value,expires,path,domain,secure){var curCookie=name+"="+escape(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+escape(path):"")+((domain)?"; domain="+domain:"")+((secure)?"; secure":"");document.cookie=curCookie;}function TinyMCE_advanced_getCookie(name){var dc=document.cookie;var prefix=name+"=";var begin=dc.indexOf("; "+prefix);if(begin==-1){begin=dc.indexOf(prefix);if(begin!=0)return null;}else begin+=2;var end=document.cookie.indexOf(";",begin);if(end==-1)end=dc.length;return unescape(dc.substring(begin+prefix.length,end));}function TinyMCE_advanced_resizeTo(inst,w,h,set_w){var editorContainer=document.getElementById(inst.editorId+'_parent');var tableElm=editorContainer.firstChild;var iframe=inst.iframeElement;if(w==null||w=="null"){set_w=false;w=0;}if(h==null||h=="null")return;w=parseInt(w);h=parseInt(h);if(tinyMCE.isGecko){w+=2;h+=2;}var dx=w-tableElm.clientWidth;var dy=h-tableElm.clientHeight;if(set_w)tableElm.style.width=w+"px";tableElm.style.height=h+"px";iw=iframe.clientWidth+dx;ih=iframe.clientHeight+dy;if(tinyMCE.isGecko){iw-=2;ih-=2;}if(set_w)iframe.style.width=iw+"px";iframe.style.height=ih+"px";if(set_w){var tableBodyElm=tableElm.firstChild;var minIframeWidth=tableBodyElm.scrollWidth;if(inst.iframeElement.clientWidth<minIframeWidth){dx=minIframeWidth-inst.iframeElement.clientWidth;inst.iframeElement.style.width=(iw+dx)+"px";}}}function TinyMCE_advanced_resizeEventHandler(e){var resizer=TinyMCE_advanced_resizer;if(!resizer.resizing)return;e=typeof(e)=="undefined"?window.event:e;var dx=e.screenX-resizer.downX;var dy=e.screenY-resizer.downY;var resizeBox=resizer.resizeBox;var editorId=resizer.editorId;switch(e.type){case "mousemove":if(resizer.horizontal)resizeBox.style.width=(resizer.width+dx)+"px";resizeBox.style.height=(resizer.height+dy)+"px";break;case "mouseup":TinyMCE_advanced_setResizing(e,editorId,false);TinyMCE_advanced_resizeTo(tinyMCE.getInstanceById(editorId),resizer.width+dx,resizer.height+dy,resizer.horizontal);if(tinyMCE.getParam("theme_advanced_resizing_use_cookie",true)){var expires=new Date();expires.setTime(expires.getTime()+3600000*24*30);TinyMCE_advanced_setCookie("TinyMCE_"+editorId+"_width",""+(resizer.horizontal?resizer.width+dx:""),expires);TinyMCE_advanced_setCookie("TinyMCE_"+editorId+"_height",""+(resizer.height+dy),expires);}break;}}function TinyMCE_advanced_getInsertLinkTemplate(){var template=new Array();template['file']='link.htm';template['width']=330;template['height']=160;template['width']+=tinyMCE.getLang('lang_insert_link_delta_width',0);template['height']+=tinyMCE.getLang('lang_insert_link_delta_height',0);return template;};function TinyMCE_advanced_getInsertImageTemplate(){var template=new Array();template['file']='image.htm?src={$src}';template['width']=340;template['height']=165;template['width']+=tinyMCE.getLang('lang_insert_image_delta_width',0);template['height']+=tinyMCE.getLang('lang_insert_image_delta_height',0);return template;};function TinyMCE_advanced_handleNodeChange(editor_id,node,undo_index,undo_levels,visual_aid,any_selection,setup_content){function selectByValue(select_elm,value,first_index){first_index=typeof(first_index)=="undefined"?false:true;if(select_elm){for(var i=0;i<select_elm.options.length;i++){var ov=""+select_elm.options[i].value;if(first_index&&ov.toLowerCase().indexOf(value.toLowerCase())==0){select_elm.selectedIndex=i;return true;}if(ov==value){select_elm.selectedIndex=i;return true;}}}return false;};function getAttrib(elm,name){return elm.getAttribute(name)?elm.getAttribute(name):"";};if(node==null){return;}var pathElm=document.getElementById(editor_id+"_path");var inst=tinyMCE.getInstanceById(editor_id);var doc=inst.getDoc();if(pathElm){var parentNode=node;var path=new Array();while(parentNode!=null){if(parentNode.nodeName.toUpperCase()=="BODY"){break;}if(parentNode.nodeType==1){path[path.length]=parentNode;}parentNode=parentNode.parentNode;}var html="";for(var i=path.length-1;i>=0;i--){var nodeName=path[i].nodeName.toLowerCase();var nodeData="";if(nodeName=="b"){nodeName="strong";}if(nodeName=="i"){nodeName="em";}if(nodeName=="span"){var cn=tinyMCE.getAttrib(path[i],"class");if(cn!=""&&cn.indexOf('mceItem')==-1)nodeData+="class: "+cn+" ";var st=tinyMCE.getAttrib(path[i],"style");if(st!=""){st=tinyMCE.serializeStyle(tinyMCE.parseStyle(st));nodeData+="style: "+st+" ";}}if(nodeName=="font"){if(tinyMCE.getParam("convert_fonts_to_spans"))nodeName="span";var face=tinyMCE.getAttrib(path[i],"face");if(face!="")nodeData+="font: "+face+" ";var size=tinyMCE.getAttrib(path[i],"size");if(size!="")nodeData+="size: "+size+" ";var color=tinyMCE.getAttrib(path[i],"color");if(color!="")nodeData+="color: "+color+" ";}if(getAttrib(path[i],'id')!=""){nodeData+="id: "+path[i].getAttribute('id')+" ";}var className=tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i],"class"),false);if(className!=""&&className.indexOf('mceItem')==-1)nodeData+="class: "+className+" ";if(getAttrib(path[i],'src')!=""){nodeData+="src: "+path[i].getAttribute('src')+" ";}if(getAttrib(path[i],'href')!=""){nodeData+="href: "+path[i].getAttribute('href')+" ";}if(nodeName=="img"&&tinyMCE.getAttrib(path[i],"class").indexOf('mceItemFlash')!=-1){nodeName="flash";nodeData="src: "+path[i].getAttribute('title');}if(nodeName=="a"&&(anchor=tinyMCE.getAttrib(path[i],"name"))!=""){nodeName="a";nodeName+="#"+anchor;nodeData="";}if(getAttrib(path[i],'name').indexOf("mce_")!=0){var className=tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i],"class"),false);if(className!=""&&className.indexOf('mceItem')==-1){nodeName+="."+className;}}var cmd='tinyMCE.execInstanceCommand(\''+editor_id+'\',\'mceSelectNodeDepth\',false,\''+i+'\');';html+='<a title="'+nodeData+'" href="javascript:'+cmd+'" onclick="'+cmd+'return false;" onmousedown="return false;" target="_self" class="mcePathItem">'+nodeName+'</a>';if(i>0){html+=" &raquo; ";}}pathElm.innerHTML='<a href="#" accesskey="x"></a>'+tinyMCE.getLang('lang_theme_path')+": "+html+'&nbsp;';}tinyMCE.switchClassSticky(editor_id+'_justifyleft','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifyright','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifycenter','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifyfull','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_bold','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_italic','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_underline','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_strikethrough','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_bullist','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_numlist','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_sub','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_sup','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_anchor','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_link','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_unlink','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_outdent','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_image','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_hr','mceButtonNormal');if(node.nodeName=="A"&&tinyMCE.getAttrib(node,"class").indexOf('mceItemAnchor')!=-1)tinyMCE.switchClassSticky(editor_id+'_anchor','mceButtonSelected');var anchorLink=tinyMCE.getParentElement(node,"a","href");if(anchorLink||any_selection){tinyMCE.switchClassSticky(editor_id+'_link',anchorLink?'mceButtonSelected':'mceButtonNormal',false);tinyMCE.switchClassSticky(editor_id+'_unlink',anchorLink?'mceButtonSelected':'mceButtonNormal',false);}tinyMCE.switchClassSticky(editor_id+'_visualaid',visual_aid?'mceButtonSelected':'mceButtonNormal',false);if(undo_levels!=-1){tinyMCE.switchClassSticky(editor_id+'_undo','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_redo','mceButtonDisabled',true);}if(tinyMCE.getParentElement(node,"li,blockquote")){tinyMCE.switchClassSticky(editor_id+'_outdent','mceButtonNormal',false);}if(undo_index!=-1&&(undo_index<undo_levels-1&&undo_levels>0)){tinyMCE.switchClassSticky(editor_id+'_redo','mceButtonNormal',false);}if(undo_index!=-1&&(undo_index>0&&undo_levels>0)){tinyMCE.switchClassSticky(editor_id+'_undo','mceButtonNormal',false);}var selectElm=document.getElementById(editor_id+"_styleSelect");if(selectElm){TinyMCE_advanced_setupCSSClasses(editor_id);classNode=node;breakOut=false;var index=0;do{if(classNode&&classNode.className){for(var i=0;i<selectElm.options.length;i++){if(selectElm.options[i].value==classNode.className){index=i;breakOut=true;break;}}}}while(!breakOut&&classNode!=null&&(classNode=classNode.parentNode)!=null);selectElm.selectedIndex=index;}var selectElm=document.getElementById(editor_id+"_formatSelect");if(selectElm){var elm=tinyMCE.getParentElement(node,"p,div,h1,h2,h3,h4,h5,h6,pre,address");if(elm){selectByValue(selectElm,"<"+elm.nodeName.toLowerCase()+">");}else{selectByValue(selectElm,"");}}var selectElm=document.getElementById(editor_id+"_fontNameSelect");if(selectElm){if(!tinyMCE.isSafari&&!(tinyMCE.isMSIE&&!tinyMCE.isOpera)){var face=doc.queryCommandValue('FontName');face=face==null||face==""?"":face;selectByValue(selectElm,face,face!="");}else{var elm=tinyMCE.getParentElement(node,"font","face");if(elm){var family=tinyMCE.getAttrib(elm,"face");if(family=='')family=''+elm.style.fontFamily;if(!selectByValue(selectElm,family,family!=""))selectByValue(selectElm,"");}else selectByValue(selectElm,"");}}var selectElm=document.getElementById(editor_id+"_fontSizeSelect");if(selectElm){if(!tinyMCE.isSafari&&!tinyMCE.isOpera){var size=doc.queryCommandValue('FontSize');selectByValue(selectElm,size==null||size==""?"0":size);}else{var elm=tinyMCE.getParentElement(node,"font","size");if(elm){var size=tinyMCE.getAttrib(elm,"size");if(size==''){var sizes=new Array('','8px','10px','12px','14px','18px','24px','36px');size=''+elm.style.fontSize;for(var i=0;i<sizes.length;i++){if((''+sizes[i])==size){size=i;break;}}}if(!selectByValue(selectElm,size))selectByValue(selectElm,"");}else selectByValue(selectElm,"0");}}alignNode=node;breakOut=false;do{if(!alignNode.getAttribute||!alignNode.getAttribute('align')){continue;}switch(alignNode.getAttribute('align').toLowerCase()){case "left":tinyMCE.switchClassSticky(editor_id+'_justifyleft','mceButtonSelected');breakOut=true;break;case "right":tinyMCE.switchClassSticky(editor_id+'_justifyright','mceButtonSelected');breakOut=true;break;case "middle":case "center":tinyMCE.switchClassSticky(editor_id+'_justifycenter','mceButtonSelected');breakOut=true;break;case "justify":tinyMCE.switchClassSticky(editor_id+'_justifyfull','mceButtonSelected');breakOut=true;break;}}while(!breakOut&&(alignNode=alignNode.parentNode)!=null);var div=tinyMCE.getParentElement(node,"div");if(div&&div.style.textAlign=="center")tinyMCE.switchClassSticky(editor_id+'_justifycenter','mceButtonSelected');if(!setup_content){var ar=new Array("Bold","_bold","Italic","_italic","Strikethrough","_strikethrough","superscript","_sup","subscript","_sub");for(var i=0;i<ar.length;i+=2){if(doc.queryCommandState(ar[i]))tinyMCE.switchClassSticky(editor_id+ar[i+1],'mceButtonSelected');}if(doc.queryCommandState("Underline")&&(node.parentNode==null||node.parentNode.nodeName!="A")){tinyMCE.switchClassSticky(editor_id+'_underline','mceButtonSelected');}}do{switch(node.nodeName){case "UL":tinyMCE.switchClassSticky(editor_id+'_bullist','mceButtonSelected');break;case "OL":tinyMCE.switchClassSticky(editor_id+'_numlist','mceButtonSelected');break;case "HR":tinyMCE.switchClassSticky(editor_id+'_hr','mceButtonSelected');break;case "IMG":if(getAttrib(node,'name').indexOf('mce_')!=0){tinyMCE.switchClassSticky(editor_id+'_image','mceButtonSelected');}break;}}while((node=node.parentNode)!=null);};function TinyMCE_advanced_setupCSSClasses(editor_id){if(!TinyMCE_advanced_autoImportCSSClasses){return;}var selectElm=document.getElementById(editor_id+'_styleSelect');if(selectElm&&selectElm.getAttribute('cssImported')!='true'){var csses=tinyMCE.getCSSClasses(editor_id);if(csses&&selectElm){for(var i=0;i<csses.length;i++){selectElm.options[selectElm.length]=new Option(csses[i],csses[i]);}}if(csses!=null&&csses.length>0){selectElm.setAttribute('cssImported','true');}}};
+tinyMCE.importThemeLanguagePack('advanced');
+
+var TinyMCE_AdvancedTheme = {
+ // Private theme fields
+ _autoImportCSSClasses : true,
+ _resizer : {},
+ _buttons : [
+ // Control id, button img, button title, command, user_interface, value
+ ['bold', '{$lang_bold_img}', 'lang_bold_desc', 'Bold'],
+ ['italic', '{$lang_italic_img}', 'lang_italic_desc', 'Italic'],
+ ['underline', '{$lang_underline_img}', 'lang_underline_desc', 'Underline'],
+ ['strikethrough', 'strikethrough.gif', 'lang_striketrough_desc', 'Strikethrough'],
+ ['justifyleft', 'justifyleft.gif', 'lang_justifyleft_desc', 'JustifyLeft'],
+ ['justifycenter', 'justifycenter.gif', 'lang_justifycenter_desc', 'JustifyCenter'],
+ ['justifyright', 'justifyright.gif', 'lang_justifyright_desc', 'JustifyRight'],
+ ['justifyfull', 'justifyfull.gif', 'lang_justifyfull_desc', 'JustifyFull'],
+ ['bullist', 'bullist.gif', 'lang_bullist_desc', 'InsertUnorderedList'],
+ ['numlist', 'numlist.gif', 'lang_numlist_desc', 'InsertOrderedList'],
+ ['outdent', 'outdent.gif', 'lang_outdent_desc', 'Outdent'],
+ ['indent', 'indent.gif', 'lang_indent_desc', 'Indent'],
+ ['cut', 'cut.gif', 'lang_cut_desc', 'Cut'],
+ ['copy', 'copy.gif', 'lang_copy_desc', 'Copy'],
+ ['paste', 'paste.gif', 'lang_paste_desc', 'Paste'],
+ ['undo', 'undo.gif', 'lang_undo_desc', 'Undo'],
+ ['redo', 'redo.gif', 'lang_redo_desc', 'Redo'],
+ ['link', 'link.gif', 'lang_link_desc', 'mceLink', true],
+ ['unlink', 'unlink.gif', 'lang_unlink_desc', 'unlink'],
+ ['image', 'image.gif', 'lang_image_desc', 'mceImage', true],
+ ['cleanup', 'cleanup.gif', 'lang_cleanup_desc', 'mceCleanup'],
+ ['help', 'help.gif', 'lang_help_desc', 'mceHelp'],
+ ['code', 'code.gif', 'lang_theme_code_desc', 'mceCodeEditor'],
+ ['hr', 'hr.gif', 'lang_theme_hr_desc', 'inserthorizontalrule'],
+ ['removeformat', 'removeformat.gif', 'lang_theme_removeformat_desc', 'removeformat'],
+ ['sub', 'sub.gif', 'lang_theme_sub_desc', 'subscript'],
+ ['sup', 'sup.gif', 'lang_theme_sup_desc', 'superscript'],
+ ['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'mceForeColor', true],
+ ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'mceBackColor', true],
+ ['charmap', 'charmap.gif', 'lang_theme_charmap_desc', 'mceCharMap'],
+ ['visualaid', 'visualaid.gif', 'lang_theme_visualaid_desc', 'mceToggleVisualAid'],
+ ['anchor', 'anchor.gif', 'lang_theme_anchor_desc', 'mceInsertAnchor'],
+ ['newdocument', 'newdocument.gif', 'lang_newdocument_desc', 'mceNewDocument']
+ ],
+
+ _buttonMap : 'anchor,backcolor,bold,bullist,charmap,cleanup,code,copy,cut,forecolor,help,hr,image,indent,italic,justifycenter,justifyfull,justifyleft,justifyright,link,newdocument,numlist,outdent,paste,redo,removeformat,strikethrough,sub,sup,underline,undo,unlink,visualaid,advhr,ltr,rtl,emotions,flash,fullpage,fullscreen,iespell,insertdate,inserttime,pastetext,pasteword,selectall,preview,print,save,replace,search,table,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,merge_cells,row_props,split_cells',
+
+ /**
+ * Returns HTML code for the specificed control.
+ */
+ getControlHTML : function(button_name) {
+ var i, x;
+
+ // Lookup button in button list
+ for (i=0; i<TinyMCE_AdvancedTheme._buttons.length; i++) {
+ var but = TinyMCE_AdvancedTheme._buttons[i];
+
+ if (but[0] == button_name)
+ return tinyMCE.getButtonHTML(but[0], but[2], '{$themeurl}/images/' + but[1], but[3], (but.length > 4 ? but[4] : false), (but.length > 5 ? but[5] : null));
+ }
+
+ // Custom controlls other than buttons
+ switch (button_name) {
+ case "formatselect":
+ var html = '<select id="{$editor_id}_formatSelect" name="{$editor_id}_formatSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FormatBlock\',false,this.options[this.selectedIndex].value);" class="mceSelectList">';
+ var formats = tinyMCE.getParam("theme_advanced_blockformats", "p,address,pre,h1,h2,h3,h4,h5,h6", true).split(',');
+ var lookup = [
+ ['p', '{$lang_theme_paragraph}'],
+ ['address', '{$lang_theme_address}'],
+ ['pre', '{$lang_theme_pre}'],
+ ['h1', '{$lang_theme_h1}'],
+ ['h2', '{$lang_theme_h2}'],
+ ['h3', '{$lang_theme_h3}'],
+ ['h4', '{$lang_theme_h4}'],
+ ['h5', '{$lang_theme_h5}'],
+ ['h6', '{$lang_theme_h6}']
+ ];
+
+ html += '<option value="">{$lang_theme_block}</option>';
+
+ // Build format select
+ for (var i=0; i<formats.length; i++) {
+ for (var x=0; x<lookup.length; x++) {
+ if (formats[i] == lookup[x][0])
+ html += '<option value="<' + lookup[x][0] + '>">' + lookup[x][1] + '</option>';
+ }
+ }
+
+ html += '</select>';
+
+ return html;
+
+ case "styleselect":
+ return '<select id="{$editor_id}_styleSelect" onmousedown="tinyMCE.themes.advanced._setupCSSClasses(\'{$editor_id}\');" name="{$editor_id}_styleSelect" onfocus="tinyMCE.addSelectAccessibility(event,this,window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSetCSSClass\',false,this.options[this.selectedIndex].value);" class="mceSelectList">{$style_select_options}</select>';
+
+ case "fontselect":
+ var fontHTML = '<select id="{$editor_id}_fontNameSelect" name="{$editor_id}_fontNameSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontName\',false,this.options[this.selectedIndex].value);" class="mceSelectList"><option value="">{$lang_theme_fontdefault}</option>';
+ var iFonts = 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;WingDings=wingdings';
+ var nFonts = 'Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sand;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats';
+ var fonts = tinyMCE.getParam("theme_advanced_fonts", nFonts).split(';');
+ for (i=0; i<fonts.length; i++) {
+ if (fonts[i] != '') {
+ var parts = fonts[i].split('=');
+ fontHTML += '<option value="' + parts[1] + '">' + parts[0] + '</option>';
+ }
+ }
+
+ fontHTML += '</select>';
+ return fontHTML;
+
+ case "fontsizeselect":
+ return '<select id="{$editor_id}_fontSizeSelect" name="{$editor_id}_fontSizeSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontSize\',false,this.options[this.selectedIndex].value);" class="mceSelectList">\
+ <option value="0">{$lang_theme_font_size}</option>\
+ <option value="1">1 (8 pt)</option>\
+ <option value="2">2 (10 pt)</option>\
+ <option value="3">3 (12 pt)</option>\
+ <option value="4">4 (14 pt)</option>\
+ <option value="5">5 (18 pt)</option>\
+ <option value="6">6 (24 pt)</option>\
+ <option value="7">7 (36 pt)</option>\
+ </select>';
+
+ case "|":
+ case "separator":
+ return '<img src="{$themeurl}/images/separator.gif" width="2" height="20" class="mceSeparatorLine" />';
+
+ case "spacer":
+ return '<img src="{$themeurl}/images/separator.gif" width="2" height="15" border="0" class="mceSeparatorLine" style="vertical-align: middle" />';
+
+ case "rowseparator":
+ return '<br />';
+ }
+
+ return "";
+ },
+
+ /**
+ * Theme specific execcommand handling.
+ */
+ execCommand : function(editor_id, element, command, user_interface, value) {
+ switch (command) {
+ case "mceLink":
+ var inst = tinyMCE.getInstanceById(editor_id);
+ var doc = inst.getDoc();
+ var selectedText = "";
+
+ if (tinyMCE.isMSIE) {
+ var rng = doc.selection.createRange();
+ selectedText = rng.text;
+ } else
+ selectedText = inst.getSel().toString();
+
+ if (!tinyMCE.linkElement) {
+ if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0))
+ return true;
+ }
+
+ var href = "", target = "", title = "", onclick = "", action = "insert", style_class = "";
+
+ if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a")
+ tinyMCE.linkElement = tinyMCE.selectedElement;
+
+ // Is anchor not a link
+ if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "")
+ tinyMCE.linkElement = null;
+
+ if (tinyMCE.linkElement) {
+ href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href');
+ target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target');
+ title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title');
+ onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');
+ style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class');
+
+ // Try old onclick to if copy/pasted content
+ if (onclick == "")
+ onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');
+
+ onclick = tinyMCE.cleanupEventStr(onclick);
+
+ href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");
+
+ // Use mce_href if defined
+ mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href');
+ if (mceRealHref != "") {
+ href = mceRealHref;
+
+ if (tinyMCE.getParam('convert_urls'))
+ href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");
+ }
+
+ action = "update";
+ }
+
+ var template = new Array();
+
+ template['file'] = 'link.htm';
+ template['width'] = 310;
+ template['height'] = 200;
+
+ // Language specific width and height addons
+ template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0);
+ template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0);
+
+ if (inst.settings['insertlink_callback']) {
+ var returnVal = eval(inst.settings['insertlink_callback'] + "(href, target, title, onclick, action, style_class);");
+ if (returnVal && returnVal['href'])
+ TinyMCE_AdvancedTheme._insertLink(returnVal['href'], returnVal['target'], returnVal['title'], returnVal['onclick'], returnVal['style_class']);
+ } else {
+ tinyMCE.openWindow(template, {href : href, target : target, title : title, onclick : onclick, action : action, className : style_class, inline : "yes"});
+ }
+
+ return true;
+
+ case "mceImage":
+ var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = "";
+ var title = "", onmouseover = "", onmouseout = "", action = "insert";
+ var img = tinyMCE.imgElement;
+ var inst = tinyMCE.getInstanceById(editor_id);
+
+ if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") {
+ img = tinyMCE.selectedElement;
+ tinyMCE.imgElement = img;
+ }
+
+ if (img) {
+ // Is it a internal MCE visual aid image, then skip this one.
+ if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0)
+ return true;
+
+ src = tinyMCE.getAttrib(img, 'src');
+ alt = tinyMCE.getAttrib(img, 'alt');
+
+ // Try polling out the title
+ if (alt == "")
+ alt = tinyMCE.getAttrib(img, 'title');
+
+ // Fix width/height attributes if the styles is specified
+ if (tinyMCE.isGecko) {
+ var w = img.style.width;
+ if (w != null && w != "")
+ img.setAttribute("width", w);
+
+ var h = img.style.height;
+ if (h != null && h != "")
+ img.setAttribute("height", h);
+ }
+
+ border = tinyMCE.getAttrib(img, 'border');
+ hspace = tinyMCE.getAttrib(img, 'hspace');
+ vspace = tinyMCE.getAttrib(img, 'vspace');
+ width = tinyMCE.getAttrib(img, 'width');
+ height = tinyMCE.getAttrib(img, 'height');
+ align = tinyMCE.getAttrib(img, 'align');
+ onmouseover = tinyMCE.getAttrib(img, 'onmouseover');
+ onmouseout = tinyMCE.getAttrib(img, 'onmouseout');
+ title = tinyMCE.getAttrib(img, 'title');
+
+ // Is realy specified?
+ if (tinyMCE.isMSIE) {
+ width = img.attributes['width'].specified ? width : "";
+ height = img.attributes['height'].specified ? height : "";
+ }
+
+ //onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover));
+ //onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout));
+
+ src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
+
+ // Use mce_src if defined
+ mceRealSrc = tinyMCE.getAttrib(img, 'mce_src');
+ if (mceRealSrc != "") {
+ src = mceRealSrc;
+
+ if (tinyMCE.getParam('convert_urls'))
+ src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
+ }
+
+ //if (onmouseover != "")
+ // onmouseover = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, img, true);");
+
+ //if (onmouseout != "")
+ // onmouseout = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, img, true);");
+
+ action = "update";
+ }
+
+ var template = new Array();
+
+ template['file'] = 'image.htm?src={$src}';
+ template['width'] = 355;
+ template['height'] = 265 + (tinyMCE.isMSIE ? 25 : 0);
+
+ // Language specific width and height addons
+ template['width'] += tinyMCE.getLang('lang_insert_image_delta_width', 0);
+ template['height'] += tinyMCE.getLang('lang_insert_image_delta_height', 0);
+
+ if (inst.settings['insertimage_callback']) {
+ var returnVal = eval(inst.settings['insertimage_callback'] + "(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);");
+ if (returnVal && returnVal['src'])
+ TinyMCE_AdvancedTheme._insertImage(returnVal['src'], returnVal['alt'], returnVal['border'], returnVal['hspace'], returnVal['vspace'], returnVal['width'], returnVal['height'], returnVal['align'], returnVal['title'], returnVal['onmouseover'], returnVal['onmouseout']);
+ } else
+ tinyMCE.openWindow(template, {src : src, alt : alt, border : border, hspace : hspace, vspace : vspace, width : width, height : height, align : align, title : title, onmouseover : onmouseover, onmouseout : onmouseout, action : action, inline : "yes"});
+
+ return true;
+
+ case "mceForeColor":
+ var template = new Array();
+ var elm = tinyMCE.selectedInstance.getFocusElement();
+ var inputColor = tinyMCE.getAttrib(elm, "color");
+
+ if (inputColor == '')
+ inputColor = elm.style.color;
+
+ if (!inputColor)
+ inputColor = "#000000";
+
+ template['file'] = 'color_picker.htm';
+ template['width'] = 220;
+ template['height'] = 190;
+
+ tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "forecolor", input_color : inputColor});
+ return true;
+
+ case "mceBackColor":
+ var template = new Array();
+ var elm = tinyMCE.selectedInstance.getFocusElement();
+ var inputColor = elm.style.backgroundColor;
+
+ if (!inputColor)
+ inputColor = "#000000";
+
+ template['file'] = 'color_picker.htm';
+ template['width'] = 220;
+ template['height'] = 190;
+
+ template['width'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width', 0);
+ template['height'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height', 0);
+
+ tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "HiliteColor", input_color : inputColor});
+ //mceBackColor
+ return true;
+
+ case "mceColorPicker":
+ if (user_interface) {
+ var template = new Array();
+ var inputColor = value['document'].getElementById(value['element_id']).value;
+
+ template['file'] = 'color_picker.htm';
+ template['width'] = 220;
+ template['height'] = 190;
+ template['close_previous'] = "no";
+
+ template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0);
+ template['height'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height', 0);
+
+ if (typeof(value['store_selection']) == "undefined")
+ value['store_selection'] = true;
+
+ tinyMCE.lastColorPickerValue = value;
+ tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : inputColor});
+ } else {
+ var savedVal = tinyMCE.lastColorPickerValue;
+ var elm = savedVal['document'].getElementById(savedVal['element_id']);
+ elm.value = value;
+
+ if (elm.onchange != null && elm.onchange != '')
+ eval('elm.onchange();');
+ }
+ return true;
+
+ case "mceCodeEditor":
+ var template = new Array();
+
+ template['file'] = 'source_editor.htm';
+ template['width'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_width", 720));
+ template['height'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_height", 580));
+
+ tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no", inline : "yes"});
+ return true;
+
+ case "mceCharMap":
+ var template = new Array();
+
+ template['file'] = 'charmap.htm';
+ template['width'] = 550 + (tinyMCE.isOpera ? 40 : 0);
+ template['height'] = 250;
+
+ template['width'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_width', 0);
+ template['height'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_height', 0);
+
+ tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
+ return true;
+
+ case "mceInsertAnchor":
+ var template = new Array();
+
+ template['file'] = 'anchor.htm';
+ template['width'] = 320;
+ template['height'] = 90 + (tinyMCE.isNS7 ? 30 : 0);
+
+ template['width'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_width', 0);
+ template['height'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_height', 0);
+
+ tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
+ return true;
+
+ case "mceNewDocument":
+ if (confirm(tinyMCE.getLang('lang_newdocument')))
+ tinyMCE.execInstanceCommand(editor_id, 'mceSetContent', false, ' ');
+
+ return true;
+ }
+
+ return false;
+ },
+
+ /**
+ * Editor instance template function.
+ */
+ getEditorTemplate : function(settings, editorId) {
+ function removeFromArray(in_array, remove_array) {
+ var outArray = new Array();
+
+ for (var i=0; i<in_array.length; i++) {
+ skip = false;
+
+ for (var j=0; j<remove_array.length; j++) {
+ if (in_array[i] == remove_array[j]) {
+ skip = true;
+ }
+ }
+
+ if (!skip) {
+ outArray[outArray.length] = in_array[i];
+ }
+ }
+
+ return outArray;
+ }
+
+ function addToArray(in_array, add_array) {
+ for (var i=0; i<add_array.length; i++) {
+ in_array[in_array.length] = add_array[i];
+ }
+
+ return in_array;
+ }
+
+ var template = new Array();
+ var deltaHeight = 0;
+ var resizing = tinyMCE.getParam("theme_advanced_resizing", false);
+ var path = tinyMCE.getParam("theme_advanced_path", true);
+ var statusbarHTML = '<div id="{$editor_id}_path" class="mceStatusbarPathText" style="display: ' + (path ? "block" : "none") + '">&nbsp;</div><div id="{$editor_id}_resize" class="mceStatusbarResize" style="display: ' + (resizing ? "block" : "none") + '" onmousedown="tinyMCE.themes.advanced._setResizing(event,\'{$editor_id}\',true);"></div><br style="clear: both" />';
+ var layoutManager = tinyMCE.getParam("theme_advanced_layout_manager", "SimpleLayout");
+
+ // Setup style select options -- MOVED UP FOR EXTERNAL TOOLBAR COMPATABILITY!
+ var styleSelectHTML = '<option value="">{$lang_theme_style_select}</option>';
+ if (settings['theme_advanced_styles']) {
+ var stylesAr = settings['theme_advanced_styles'].split(';');
+
+ for (var i=0; i<stylesAr.length; i++) {
+ var key, value;
+
+ key = stylesAr[i].split('=')[0];
+ value = stylesAr[i].split('=')[1];
+
+ styleSelectHTML += '<option value="' + value + '">' + key + '</option>';
+ }
+
+ TinyMCE_AdvancedTheme._autoImportCSSClasses = false;
+ }
+
+ switch(layoutManager) {
+ case "SimpleLayout" : //the default TinyMCE Layout (for backwards compatibility)...
+ var toolbarHTML = "";
+ var toolbarLocation = tinyMCE.getParam("theme_advanced_toolbar_location", "bottom");
+ var toolbarAlign = tinyMCE.getParam("theme_advanced_toolbar_align", "center");
+ var pathLocation = tinyMCE.getParam("theme_advanced_path_location", "none"); // Compatiblity
+ var statusbarLocation = tinyMCE.getParam("theme_advanced_statusbar_location", pathLocation);
+ var defVals = {
+ theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect",
+ theme_advanced_buttons2 : "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code",
+ theme_advanced_buttons3 : "hr,removeformat,visualaid,separator,sub,sup,separator,charmap"
+ };
+
+ // Add accessibility control
+ toolbarHTML += '<a href="#" accesskey="q" title="' + tinyMCE.getLang("lang_toolbar_focus") + '"';
+
+ if (!tinyMCE.getParam("accessibility_focus"))
+ toolbarHTML += ' onfocus="tinyMCE.getInstanceById(\'' + editorId + '\').getWin().focus();"';
+
+ toolbarHTML += '></a>';
+
+ // Render rows
+ for (var i=1; i<100; i++) {
+ var def = defVals["theme_advanced_buttons" + i];
+
+ var buttons = tinyMCE.getParam("theme_advanced_buttons" + i, def == null ? '' : def, true, ',');
+ if (buttons.length == 0)
+ break;
+
+ buttons = removeFromArray(buttons, tinyMCE.getParam("theme_advanced_disable", "", true, ','));
+ buttons = addToArray(buttons, tinyMCE.getParam("theme_advanced_buttons" + i + "_add", "", true, ','));
+ buttons = addToArray(tinyMCE.getParam("theme_advanced_buttons" + i + "_add_before", "", true, ','), buttons);
+
+ for (var b=0; b<buttons.length; b++)
+ toolbarHTML += tinyMCE.getControlHTML(buttons[b]);
+
+ if (buttons.length > 0) {
+ toolbarHTML += "<br />";
+ deltaHeight -= 23;
+ }
+ }
+
+ // Add accessibility control
+ toolbarHTML += '<a href="#" accesskey="z" onfocus="tinyMCE.getInstanceById(\'' + editorId + '\').getWin().focus();"></a>';
+
+ // Setup template html
+ template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';
+
+ if (toolbarLocation == "top") {
+ template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap">' + toolbarHTML + '</td></tr>';
+ }
+
+ if (statusbarLocation == "top") {
+ template['html'] += '<tr><td class="mceStatusbarTop" height="1">' + statusbarHTML + '</td></tr>';
+ deltaHeight -= 23;
+ }
+
+ template['html'] += '<tr><td align="center"><span id="{$editor_id}"></span></td></tr>';
+
+ if (toolbarLocation == "bottom") {
+ template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1">' + toolbarHTML + '</td></tr>';
+ }
+
+ // External toolbar changes
+ if (toolbarLocation == "external") {
+ var bod = document.body;
+ var elm = document.createElement ("div");
+
+ toolbarHTML = tinyMCE.replaceVar(toolbarHTML, 'style_select_options', styleSelectHTML);
+ toolbarHTML = tinyMCE.applyTemplate(toolbarHTML, {editor_id : editorId});
+
+ elm.className = "mceToolbarExternal";
+ elm.id = editorId+"_toolbar";
+ elm.innerHTML = '<table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table>';
+ bod.appendChild (elm);
+ // bod.style.marginTop = elm.offsetHeight + "px";
+
+ deltaHeight = 0;
+ tinyMCE.getInstanceById(editorId).toolbarElement = elm;
+
+ //template['html'] = '<div id="mceExternalToolbar" align="center" class="mceToolbarExternal"><table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table></div>' + template["html"];
+ } else {
+ tinyMCE.getInstanceById(editorId).toolbarElement = null;
+ }
+
+ if (statusbarLocation == "bottom") {
+ template['html'] += '<tr><td class="mceStatusbarBottom" height="1">' + statusbarHTML + '</td></tr>';
+ deltaHeight -= 23;
+ }
+
+ template['html'] += '</tbody></table>';
+ //"SimpleLayout"
+ break;
+
+ case "RowLayout" : //Container Layout - containers defined in "theme_advanced_containers" are rendered from top to bottom.
+ template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';
+
+ var containers = tinyMCE.getParam("theme_advanced_containers", "", true, ",");
+ var defaultContainerCSS = tinyMCE.getParam("theme_advanced_containers_default_class", "container");
+ var defaultContainerAlign = tinyMCE.getParam("theme_advanced_containers_default_align", "center");
+
+ //Render Containers:
+ for (var i = 0; i < containers.length; i++)
+ {
+ if (containers[i] == "mceEditor") //Exceptions for mceEditor and ...
+ {
+ template['html'] += '<tr><td align="center" class="mceEditor_border">\
+ <span id="{$editor_id}"></span>\
+ </td></tr>';
+ }
+ else if (containers[i] == "mceElementpath" || containers[i] == "mceStatusbar") // ... mceElementpath:
+ {
+ var pathClass = "mceStatusbar";
+
+ if (i == containers.length-1)
+ {
+ pathClass = "mceStatusbarBottom";
+ }
+ else if (i == 0)
+ {
+ pathClass = "mceStatusbar";
+ }
+ else
+ {
+ deltaHeight-=2;
+ }
+
+ template['html'] += '<tr><td class="' + pathClass + '" height="1">' + statusbarHTML + '</td></tr>';
+ deltaHeight -= 22;
+ } else { // Render normal Container
+ var curContainer = tinyMCE.getParam("theme_advanced_container_"+containers[i], "", true, ',');
+ var curContainerHTML = "";
+ var curAlign = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align", defaultContainerAlign);
+ var curCSS = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class", defaultContainerCSS);
+
+ for (var j=0; j<curContainer.length; j++) {
+ curContainerHTML += tinyMCE.getControlHTML(curContainer[j]);
+ }
+
+ if (curContainer.length > 0) {
+ curContainerHTML += "<br />";
+ deltaHeight -= 23;
+ }
+
+ template['html'] += '<tr><td class="' + curCSS + '" align="' + curAlign + '" height="1">' + curContainerHTML + '</td></tr>';
+ }
+ }
+
+ template['html'] += '</tbody></table>';
+ //RowLayout
+ break;
+
+ case "CustomLayout" : //User defined layout callback...
+ var customLayout = tinyMCE.getParam("theme_advanced_custom_layout","");
+
+ if (customLayout != "" && eval("typeof(" + customLayout + ")") != "undefined") {
+ template = eval(customLayout + "(template);");
+ }
+ break;
+ }
+
+ if (resizing)
+ template['html'] += '<span id="{$editor_id}_resize_box" class="mceResizeBox"></span>';
+
+ template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML);
+ template['delta_width'] = 0;
+ template['delta_height'] = deltaHeight;
+
+ return template;
+ },
+
+ initInstance : function(inst) {
+ if (tinyMCE.getParam("theme_advanced_resizing", false)) {
+ if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) {
+ var w = TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_width");
+ var h = TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_height");
+
+ TinyMCE_AdvancedTheme._resizeTo(inst, w, h, tinyMCE.getParam("theme_advanced_resize_horizontal", true));
+ }
+ }
+
+ inst.addShortcut('ctrl', 'k', 'lang_link_desc', 'mceLink');
+ },
+
+ /**
+ * Node change handler.
+ */
+ handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection, setup_content) {
+ function selectByValue(select_elm, value, first_index) {
+ first_index = typeof(first_index) == "undefined" ? false : true;
+
+ if (select_elm) {
+ for (var i=0; i<select_elm.options.length; i++) {
+ var ov = "" + select_elm.options[i].value;
+
+ if (first_index && ov.toLowerCase().indexOf(value.toLowerCase()) == 0) {
+ select_elm.selectedIndex = i;
+ return true;
+ }
+
+ if (ov == value) {
+ select_elm.selectedIndex = i;
+ return true;
+ }
+ }
+ }
+
+ return false;
+ };
+
+ function getAttrib(elm, name) {
+ return elm.getAttribute(name) ? elm.getAttribute(name) : "";
+ };
+
+ // No node provided
+ if (node == null)
+ return;
+
+ // Update path
+ var pathElm = document.getElementById(editor_id + "_path");
+ var inst = tinyMCE.getInstanceById(editor_id);
+ var doc = inst.getDoc();
+
+ if (pathElm) {
+ // Get node path
+ var parentNode = node;
+ var path = new Array();
+
+ while (parentNode != null) {
+ if (parentNode.nodeName.toUpperCase() == "BODY") {
+ break;
+ }
+
+ // Only append element nodes to path
+ if (parentNode.nodeType == 1 && tinyMCE.getAttrib(parentNode, "class").indexOf('mceItemHidden') == -1) {
+ path[path.length] = parentNode;
+ }
+
+ parentNode = parentNode.parentNode;
+ }
+
+ // Setup HTML
+ var html = "";
+ for (var i=path.length-1; i>=0; i--) {
+ var nodeName = path[i].nodeName.toLowerCase();
+ var nodeData = "";
+
+ if (nodeName == "b") {
+ nodeName = "strong";
+ }
+
+ if (nodeName == "i") {
+ nodeName = "em";
+ }
+
+ if (nodeName == "span") {
+ var cn = tinyMCE.getAttrib(path[i], "class");
+ if (cn != "" && cn.indexOf('mceItem') == -1)
+ nodeData += "class: " + cn + " ";
+
+ var st = tinyMCE.getAttrib(path[i], "style");
+ if (st != "") {
+ st = tinyMCE.serializeStyle(tinyMCE.parseStyle(st));
+ nodeData += "style: " + st + " ";
+ }
+ }
+
+ if (nodeName == "font") {
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ nodeName = "span";
+
+ var face = tinyMCE.getAttrib(path[i], "face");
+ if (face != "")
+ nodeData += "font: " + face + " ";
+
+ var size = tinyMCE.getAttrib(path[i], "size");
+ if (size != "")
+ nodeData += "size: " + size + " ";
+
+ var color = tinyMCE.getAttrib(path[i], "color");
+ if (color != "")
+ nodeData += "color: " + color + " ";
+ }
+
+ if (getAttrib(path[i], 'id') != "") {
+ nodeData += "id: " + path[i].getAttribute('id') + " ";
+ }
+
+ var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false);
+ if (className != "" && className.indexOf('mceItem') == -1)
+ nodeData += "class: " + className + " ";
+
+ if (getAttrib(path[i], 'src') != "") {
+ var src = tinyMCE.getAttrib(path[i], "mce_src");
+
+ if (src == "")
+ src = tinyMCE.getAttrib(path[i], "src");
+
+ nodeData += "src: " + src + " ";
+ }
+
+ if (getAttrib(path[i], 'href') != "") {
+ var href = tinyMCE.getAttrib(path[i], "mce_href");
+
+ if (href == "")
+ href = tinyMCE.getAttrib(path[i], "href");
+
+ nodeData += "href: " + href + " ";
+ }
+
+ if (nodeName == "img" && tinyMCE.getAttrib(path[i], "class").indexOf('mceItemFlash') != -1) {
+ nodeName = "flash";
+ nodeData = "src: " + path[i].getAttribute('title');
+ }
+
+ if (nodeName == "a" && (anchor = tinyMCE.getAttrib(path[i], "name")) != "") {
+ nodeName = "a";
+ nodeName += "#" + anchor;
+ nodeData = "";
+ }
+
+ if (getAttrib(path[i], 'name').indexOf("mce_") != 0) {
+ var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false);
+ if (className != "" && className.indexOf('mceItem') == -1) {
+ nodeName += "." + className;
+ }
+ }
+
+ var cmd = 'tinyMCE.execInstanceCommand(\'' + editor_id + '\',\'mceSelectNodeDepth\',false,\'' + i + '\');';
+ html += '<a title="' + nodeData + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" target="_self" class="mcePathItem">' + nodeName + '</a>';
+
+ if (i > 0) {
+ html += " &raquo; ";
+ }
+ }
+
+ pathElm.innerHTML = '<a href="#" accesskey="x"></a>' + tinyMCE.getLang('lang_theme_path') + ": " + html + '&nbsp;';
+ }
+
+ // Reset old states
+ tinyMCE.switchClass(editor_id + '_justifyleft', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_justifyright', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_justifyfull', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_bold', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_italic', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_underline', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_strikethrough', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_bullist', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_numlist', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_sub', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_sup', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_link', 'mceButtonDisabled');
+ tinyMCE.switchClass(editor_id + '_unlink', 'mceButtonDisabled');
+ tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonDisabled');
+ tinyMCE.switchClass(editor_id + '_image', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_hr', 'mceButtonNormal');
+
+ if (node.nodeName == "A" && tinyMCE.getAttrib(node, "class").indexOf('mceItemAnchor') != -1)
+ tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonSelected');
+
+ // Get link
+ var anchorLink = tinyMCE.getParentElement(node, "a", "href");
+
+ if (anchorLink || any_selection) {
+ tinyMCE.switchClass(editor_id + '_link', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_unlink', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal');
+ }
+
+ // Handle visual aid
+ tinyMCE.switchClass(editor_id + '_visualaid', visual_aid ? 'mceButtonSelected' : 'mceButtonNormal');
+
+ if (undo_levels != -1) {
+ tinyMCE.switchClass(editor_id + '_undo', 'mceButtonDisabled');
+ tinyMCE.switchClass(editor_id + '_redo', 'mceButtonDisabled');
+ }
+
+ // Within li, blockquote
+ if (tinyMCE.getParentElement(node, "li,blockquote"))
+ tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonNormal');
+
+ // Has redo levels
+ if (undo_index != -1 && (undo_index < undo_levels-1 && undo_levels > 0))
+ tinyMCE.switchClass(editor_id + '_redo', 'mceButtonNormal');
+
+ // Has undo levels
+ if (undo_index != -1 && (undo_index > 0 && undo_levels > 0))
+ tinyMCE.switchClass(editor_id + '_undo', 'mceButtonNormal');
+
+ // Select class in select box
+ var selectElm = document.getElementById(editor_id + "_styleSelect");
+
+ if (selectElm) {
+ TinyMCE_AdvancedTheme._setupCSSClasses(editor_id);
+
+ classNode = node;
+ breakOut = false;
+ var index = 0;
+
+ do {
+ if (classNode && classNode.className) {
+ for (var i=0; i<selectElm.options.length; i++) {
+ if (selectElm.options[i].value == classNode.className) {
+ index = i;
+ breakOut = true;
+ break;
+ }
+ }
+ }
+ } while (!breakOut && classNode != null && (classNode = classNode.parentNode) != null);
+
+ selectElm.selectedIndex = index;
+ }
+
+ // Select formatblock
+ var selectElm = document.getElementById(editor_id + "_formatSelect");
+ if (selectElm) {
+ var elm = tinyMCE.getParentElement(node, "p,div,h1,h2,h3,h4,h5,h6,pre,address");
+
+ if (elm)
+ selectByValue(selectElm, "<" + elm.nodeName.toLowerCase() + ">");
+ else
+ selectByValue(selectElm, "");
+ }
+
+ // Select fontselect
+ var selectElm = document.getElementById(editor_id + "_fontNameSelect");
+ if (selectElm) {
+ if (!tinyMCE.isSafari && !(tinyMCE.isMSIE && !tinyMCE.isOpera)) {
+ var face = inst.queryCommandValue('FontName');
+
+ face = face == null || face == "" ? "" : face;
+
+ selectByValue(selectElm, face, face != "");
+ } else {
+ var elm = tinyMCE.getParentElement(node, "font", "face");
+
+ if (elm) {
+ var family = tinyMCE.getAttrib(elm, "face");
+
+ if (family == '')
+ family = '' + elm.style.fontFamily;
+
+ if (!selectByValue(selectElm, family, family != ""))
+ selectByValue(selectElm, "");
+ } else
+ selectByValue(selectElm, "");
+ }
+ }
+
+ // Select fontsize
+ var selectElm = document.getElementById(editor_id + "_fontSizeSelect");
+ if (selectElm) {
+ if (!tinyMCE.isSafari && !tinyMCE.isOpera) {
+ var size = inst.queryCommandValue('FontSize');
+ selectByValue(selectElm, size == null || size == "" ? "0" : size);
+ } else {
+ var elm = tinyMCE.getParentElement(node, "font", "size");
+ if (elm) {
+ var size = tinyMCE.getAttrib(elm, "size");
+
+ if (size == '') {
+ var sizes = new Array('', '8px', '10px', '12px', '14px', '18px', '24px', '36px');
+
+ size = '' + elm.style.fontSize;
+
+ for (var i=0; i<sizes.length; i++) {
+ if (('' + sizes[i]) == size) {
+ size = i;
+ break;
+ }
+ }
+ }
+
+ if (!selectByValue(selectElm, size))
+ selectByValue(selectElm, "");
+ } else
+ selectByValue(selectElm, "0");
+ }
+ }
+
+ // Handle align attributes
+ alignNode = node;
+ breakOut = false;
+ do {
+ if (!alignNode.getAttribute || !alignNode.getAttribute('align'))
+ continue;
+
+ switch (alignNode.getAttribute('align').toLowerCase()) {
+ case "left":
+ tinyMCE.switchClass(editor_id + '_justifyleft', 'mceButtonSelected');
+ breakOut = true;
+ break;
+
+ case "right":
+ tinyMCE.switchClass(editor_id + '_justifyright', 'mceButtonSelected');
+ breakOut = true;
+ break;
+
+ case "middle":
+ case "center":
+ tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonSelected');
+ breakOut = true;
+ break;
+
+ case "justify":
+ tinyMCE.switchClass(editor_id + '_justifyfull', 'mceButtonSelected');
+ breakOut = true;
+ break;
+ }
+ } while (!breakOut && (alignNode = alignNode.parentNode) != null);
+
+ // Div justification
+ var div = tinyMCE.getParentElement(node, "div");
+ if (div && div.style.textAlign == "center")
+ tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonSelected');
+
+ // Do special text
+ if (!setup_content) {
+ // , "JustifyLeft", "_justifyleft", "JustifyCenter", "justifycenter", "JustifyRight", "justifyright", "JustifyFull", "justifyfull", "InsertUnorderedList", "bullist", "InsertOrderedList", "numlist", "InsertUnorderedList", "bullist", "Outdent", "outdent", "Indent", "indent", "subscript", "sub"
+ var ar = new Array("Bold", "_bold", "Italic", "_italic", "Strikethrough", "_strikethrough", "superscript", "_sup", "subscript", "_sub");
+ for (var i=0; i<ar.length; i+=2) {
+ if (inst.queryCommandState(ar[i]))
+ tinyMCE.switchClass(editor_id + ar[i+1], 'mceButtonSelected');
+ }
+
+ if (inst.queryCommandState("Underline") && (node.parentNode == null || node.parentNode.nodeName != "A"))
+ tinyMCE.switchClass(editor_id + '_underline', 'mceButtonSelected');
+ }
+
+ // Handle elements
+ do {
+ switch (node.nodeName) {
+ case "UL":
+ tinyMCE.switchClass(editor_id + '_bullist', 'mceButtonSelected');
+ break;
+
+ case "OL":
+ tinyMCE.switchClass(editor_id + '_numlist', 'mceButtonSelected');
+ break;
+
+ case "HR":
+ tinyMCE.switchClass(editor_id + '_hr', 'mceButtonSelected');
+ break;
+
+ case "IMG":
+ if (getAttrib(node, 'name').indexOf('mce_') != 0) {
+ tinyMCE.switchClass(editor_id + '_image', 'mceButtonSelected');
+ }
+ break;
+ }
+ } while ((node = node.parentNode) != null);
+ },
+
+ // Private theme internal functions
+
+ // This function auto imports CSS classes into the class selection droplist
+ _setupCSSClasses : function(editor_id) {
+ var i, selectElm;
+
+ if (!TinyMCE_AdvancedTheme._autoImportCSSClasses)
+ return;
+
+ selectElm = document.getElementById(editor_id + '_styleSelect');
+
+ if (selectElm && selectElm.getAttribute('cssImported') != 'true') {
+ var csses = tinyMCE.getCSSClasses(editor_id);
+ if (csses && selectElm) {
+ for (i=0; i<csses.length; i++)
+ selectElm.options[selectElm.options.length] = new Option(csses[i], csses[i]);
+ }
+
+ // Only do this once
+ if (csses != null && csses.length > 0)
+ selectElm.setAttribute('cssImported', 'true');
+ }
+ },
+
+ _setCookie : function(name, value, expires, path, domain, secure) {
+ var curCookie = name + "=" + escape(value) +
+ ((expires) ? "; expires=" + expires.toGMTString() : "") +
+ ((path) ? "; path=" + escape(path) : "") +
+ ((domain) ? "; domain=" + domain : "") +
+ ((secure) ? "; secure" : "");
+
+ document.cookie = curCookie;
+ },
+
+ _getCookie : function(name) {
+ var dc = document.cookie;
+ var prefix = name + "=";
+ var begin = dc.indexOf("; " + prefix);
+
+ if (begin == -1) {
+ begin = dc.indexOf(prefix);
+
+ if (begin != 0)
+ return null;
+ } else
+ begin += 2;
+
+ var end = document.cookie.indexOf(";", begin);
+
+ if (end == -1)
+ end = dc.length;
+
+ return unescape(dc.substring(begin + prefix.length, end));
+ },
+
+ _resizeTo : function(inst, w, h, set_w) {
+ var editorContainer = document.getElementById(inst.editorId + '_parent');
+ var tableElm = editorContainer.firstChild;
+ var iframe = inst.iframeElement;
+
+ if (w == null || w == "null") {
+ set_w = false;
+ w = 0;
+ }
+
+ if (h == null || h == "null")
+ return;
+
+ w = parseInt(w);
+ h = parseInt(h);
+
+ if (tinyMCE.isGecko) {
+ w += 2;
+ h += 2;
+ }
+
+ var dx = w - tableElm.clientWidth;
+ var dy = h - tableElm.clientHeight;
+
+ w = w < 1 ? 30 : w;
+ h = h < 1 ? 30 : h;
+
+ if (set_w)
+ tableElm.style.width = w + "px";
+
+ tableElm.style.height = h + "px";
+
+ iw = iframe.clientWidth + dx;
+ ih = iframe.clientHeight + dy;
+
+ iw = iw < 1 ? 30 : iw;
+ ih = ih < 1 ? 30 : ih;
+
+ if (tinyMCE.isGecko) {
+ iw -= 2;
+ ih -= 2;
+ }
+
+ if (set_w)
+ iframe.style.width = iw + "px";
+
+ iframe.style.height = ih + "px";
+
+ // Is it to small, make it bigger again
+ if (set_w) {
+ var tableBodyElm = tableElm.firstChild;
+ var minIframeWidth = tableBodyElm.scrollWidth;
+ if (inst.iframeElement.clientWidth < minIframeWidth) {
+ dx = minIframeWidth - inst.iframeElement.clientWidth;
+
+ inst.iframeElement.style.width = (iw + dx) + "px";
+ }
+ }
+ },
+
+ /**
+ * Handles resizing events.
+ */
+ _resizeEventHandler : function(e) {
+ var resizer = TinyMCE_AdvancedTheme._resizer;
+
+ // Do nothing
+ if (!resizer.resizing)
+ return;
+
+ e = typeof(e) == "undefined" ? window.event : e;
+
+ var dx = e.screenX - resizer.downX;
+ var dy = e.screenY - resizer.downY;
+ var resizeBox = resizer.resizeBox;
+ var editorId = resizer.editorId;
+
+ switch (e.type) {
+ case "mousemove":
+ var w, h;
+
+ w = resizer.width + dx;
+ h = resizer.height + dy;
+
+ w = w < 1 ? 1 : w;
+ h = h < 1 ? 1 : h;
+
+ if (resizer.horizontal)
+ resizeBox.style.width = w + "px";
+
+ resizeBox.style.height = h + "px";
+ break;
+
+ case "mouseup":
+ TinyMCE_AdvancedTheme._setResizing(e, editorId, false);
+ TinyMCE_AdvancedTheme._resizeTo(tinyMCE.getInstanceById(editorId), resizer.width + dx, resizer.height + dy, resizer.horizontal);
+
+ // Expire in a month
+ if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) {
+ var expires = new Date();
+ expires.setTime(expires.getTime() + 3600000 * 24 * 30);
+
+ // Set the cookies
+ TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + editorId + "_width", "" + (resizer.horizontal ? resizer.width + dx : ""), expires);
+ TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + editorId + "_height", "" + (resizer.height + dy), expires);
+ }
+ break;
+ }
+ },
+
+ /**
+ * Starts/stops the editor resizing.
+ */
+ _setResizing : function(e, editor_id, state) {
+ e = typeof(e) == "undefined" ? window.event : e;
+
+ var resizer = TinyMCE_AdvancedTheme._resizer;
+ var editorContainer = document.getElementById(editor_id + '_parent');
+ var editorArea = document.getElementById(editor_id + '_parent').firstChild;
+ var resizeBox = document.getElementById(editor_id + '_resize_box');
+ var inst = tinyMCE.getInstanceById(editor_id);
+
+ if (state) {
+ // Place box over editor area
+ var width = editorArea.clientWidth;
+ var height = editorArea.clientHeight;
+
+ resizeBox.style.width = width + "px";
+ resizeBox.style.height = height + "px";
+
+ resizer.iframeWidth = inst.iframeElement.clientWidth;
+ resizer.iframeHeight = inst.iframeElement.clientHeight;
+
+ // Hide editor and show resize box
+ editorArea.style.display = "none";
+ resizeBox.style.display = "block";
+
+ // Add event handlers, only once
+ if (!resizer.eventHandlers) {
+ if (tinyMCE.isMSIE)
+ tinyMCE.addEvent(document, "mousemove", TinyMCE_AdvancedTheme._resizeEventHandler);
+ else
+ tinyMCE.addEvent(window, "mousemove", TinyMCE_AdvancedTheme._resizeEventHandler);
+
+ tinyMCE.addEvent(document, "mouseup", TinyMCE_AdvancedTheme._resizeEventHandler);
+
+ resizer.eventHandlers = true;
+ }
+
+ resizer.resizing = true;
+ resizer.downX = e.screenX;
+ resizer.downY = e.screenY;
+ resizer.width = parseInt(resizeBox.style.width);
+ resizer.height = parseInt(resizeBox.style.height);
+ resizer.editorId = editor_id;
+ resizer.resizeBox = resizeBox;
+ resizer.horizontal = tinyMCE.getParam("theme_advanced_resize_horizontal", true);
+ } else {
+ resizer.resizing = false;
+ resizeBox.style.display = "none";
+ editorArea.style.display = tinyMCE.isMSIE && !tinyMCE.isOpera ? "block" : "table";
+ tinyMCE.execCommand('mceResetDesignMode');
+ }
+ },
+
+ _insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) {
+ tinyMCE.execCommand('mceBeginUndoLevel');
+
+ if (src == "")
+ return;
+
+ if (!tinyMCE.imgElement && tinyMCE.isSafari) {
+ var html = "";
+
+ html += '<img src="' + src + '" alt="' + alt + '"';
+ html += ' border="' + border + '" hspace="' + hspace + '"';
+ html += ' vspace="' + vspace + '" width="' + width + '"';
+ html += ' height="' + height + '" align="' + align + '" title="' + title + '" onmouseover="' + onmouseover + '" onmouseout="' + onmouseout + '" />';
+
+ tinyMCE.execCommand("mceInsertContent", false, html);
+ } else {
+ if (!tinyMCE.imgElement && tinyMCE.selectedInstance) {
+ if (tinyMCE.isSafari)
+ tinyMCE.execCommand("mceInsertContent", false, '<img src="' + tinyMCE.uniqueURL + '" />');
+ else
+ tinyMCE.selectedInstance.contentDocument.execCommand("insertimage", false, tinyMCE.uniqueURL);
+
+ tinyMCE.imgElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "img", "src", tinyMCE.uniqueURL);
+ }
+ }
+
+ if (tinyMCE.imgElement) {
+ var needsRepaint = false;
+ var msrc = src;
+
+ src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, tinyMCE.imgElement);");
+
+ if (tinyMCE.getParam('convert_urls'))
+ msrc = src;
+
+ if (onmouseover && onmouseover != "")
+ onmouseover = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, tinyMCE.imgElement);") + "';";
+
+ if (onmouseout && onmouseout != "")
+ onmouseout = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, tinyMCE.imgElement);") + "';";
+
+ // Use alt as title if it's undefined
+ if (typeof(title) == "undefined")
+ title = alt;
+
+ if (width != tinyMCE.imgElement.getAttribute("width") || height != tinyMCE.imgElement.getAttribute("height") || align != tinyMCE.imgElement.getAttribute("align"))
+ needsRepaint = true;
+
+ tinyMCE.setAttrib(tinyMCE.imgElement, 'src', src);
+ tinyMCE.setAttrib(tinyMCE.imgElement, 'mce_src', msrc);
+ tinyMCE.setAttrib(tinyMCE.imgElement, 'alt', alt);
+ tinyMCE.setAttrib(tinyMCE.imgElement, 'title', title);
+ tinyMCE.setAttrib(tinyMCE.imgElement, 'align', align);
+ tinyMCE.setAttrib(tinyMCE.imgElement, 'border', border, true);
+ tinyMCE.setAttrib(tinyMCE.imgElement, 'hspace', hspace, true);
+ tinyMCE.setAttrib(tinyMCE.imgElement, 'vspace', vspace, true);
+ tinyMCE.setAttrib(tinyMCE.imgElement, 'width', width, true);
+ tinyMCE.setAttrib(tinyMCE.imgElement, 'height', height, true);
+ tinyMCE.setAttrib(tinyMCE.imgElement, 'onmouseover', onmouseover);
+ tinyMCE.setAttrib(tinyMCE.imgElement, 'onmouseout', onmouseout);
+
+ // Fix for bug #989846 - Image resize bug
+ if (width && width != "")
+ tinyMCE.imgElement.style.pixelWidth = width;
+
+ if (height && height != "")
+ tinyMCE.imgElement.style.pixelHeight = height;
+
+ if (needsRepaint)
+ tinyMCE.selectedInstance.repaint();
+ }
+
+ tinyMCE.execCommand('mceEndUndoLevel');
+ },
+
+ _insertLink : function(href, target, title, onclick, style_class) {
+ tinyMCE.execCommand('mceBeginUndoLevel');
+
+ if (tinyMCE.selectedInstance && tinyMCE.selectedElement && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") {
+ var doc = tinyMCE.selectedInstance.getDoc();
+ var linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
+ var newLink = false;
+
+ if (!linkElement) {
+ linkElement = doc.createElement("a");
+ newLink = true;
+ }
+
+ var mhref = href;
+ var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, linkElement);");
+ mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
+
+ tinyMCE.setAttrib(linkElement, 'href', thref);
+ tinyMCE.setAttrib(linkElement, 'mce_href', mhref);
+ tinyMCE.setAttrib(linkElement, 'target', target);
+ tinyMCE.setAttrib(linkElement, 'title', title);
+ tinyMCE.setAttrib(linkElement, 'onclick', onclick);
+ tinyMCE.setAttrib(linkElement, 'class', style_class);
+
+ if (newLink) {
+ linkElement.appendChild(tinyMCE.selectedElement.cloneNode(true));
+ tinyMCE.selectedElement.parentNode.replaceChild(linkElement, tinyMCE.selectedElement);
+ }
+
+ return;
+ }
+
+ if (!tinyMCE.linkElement && tinyMCE.selectedInstance) {
+ if (tinyMCE.isSafari) {
+ tinyMCE.execCommand("mceInsertContent", false, '<a href="' + tinyMCE.uniqueURL + '">' + tinyMCE.selectedInstance.selection.getSelectedHTML() + '</a>');
+ } else
+ tinyMCE.selectedInstance.contentDocument.execCommand("createlink", false, tinyMCE.uniqueURL);
+
+ tinyMCE.linkElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);
+
+ var elementArray = tinyMCE.getElementsByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);
+
+ for (var i=0; i<elementArray.length; i++) {
+ var mhref = href;
+ var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, elementArray[i]);");
+ mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
+
+ tinyMCE.setAttrib(elementArray[i], 'href', thref);
+ tinyMCE.setAttrib(elementArray[i], 'mce_href', mhref);
+ tinyMCE.setAttrib(elementArray[i], 'target', target);
+ tinyMCE.setAttrib(elementArray[i], 'title', title);
+ tinyMCE.setAttrib(elementArray[i], 'onclick', onclick);
+ tinyMCE.setAttrib(elementArray[i], 'class', style_class);
+ }
+
+ tinyMCE.linkElement = elementArray[0];
+ }
+
+ if (tinyMCE.linkElement) {
+ var mhref = href;
+ href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement);");
+ mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
+
+ tinyMCE.setAttrib(tinyMCE.linkElement, 'href', href);
+ tinyMCE.setAttrib(tinyMCE.linkElement, 'mce_href', mhref);
+ tinyMCE.setAttrib(tinyMCE.linkElement, 'target', target);
+ tinyMCE.setAttrib(tinyMCE.linkElement, 'title', title);
+ tinyMCE.setAttrib(tinyMCE.linkElement, 'onclick', onclick);
+ tinyMCE.setAttrib(tinyMCE.linkElement, 'class', style_class);
+ }
+
+ tinyMCE.execCommand('mceEndUndoLevel');
+ }
+};
+
+tinyMCE.addTheme("advanced", TinyMCE_AdvancedTheme);
+
+// Add default buttons maps for advanced theme and all internal plugins
+tinyMCE.addButtonMap(TinyMCE_AdvancedTheme._buttonMap);
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/image.htm b/wp-inst/wp-includes/js/tinymce/themes/advanced/image.htm
index 0b5c7db..4826a8d 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/image.htm
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/image.htm
@@ -2,44 +2,27 @@
<head>
<title>{$lang_insert_image_title}</title>
<script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
+ <script language="javascript" type="text/javascript" src="../../utils/mctabs.js"></script>
<script language="javascript" type="text/javascript" src="../../utils/form_utils.js"></script>
<script language="javascript" type="text/javascript" src="jscripts/image.js"></script>
- <style type="text/css">
- #insert, #cancel {
- font: 13px Verdana, Arial, Helvetica, sans-serif;
- height:auto;
- width: auto;
- background-color: transparent;
- background-image: url(../../../../../wp-admin/images/fade-butt.png);
- background-repeat: repeat;
- border: 3px double;
- border-right-color: rgb(153, 153, 153);
- border-bottom-color: rgb(153, 153, 153);
- border-left-color: rgb(204, 204, 204);
- border-top-color: rgb(204, 204, 204);
- color: rgb(51, 51, 51);
- padding: 0.25em 1em;
- }
- #insert:active, #cancel:active {
- background: #f4f4f4;
- border-left-color: #999;
- border-top-color: #999;
- }
- </style>
+ <base target="_self" />
</head>
-<body onload="tinyMCEPopup.executeOnLoad('init();');document.getElementById('src').focus();" style="display: none">
-<form onsubmit="insertImage();return false;">
- <table border="0" cellpadding="0" cellspacing="0" width="200">
- <tr>
- <td align="center" valign="middle"><table border="0" cellpadding="4" cellspacing="0">
- <tr>
- <td colspan="2" class="title" nowrap="nowrap">{$lang_insert_image_title}</td>
- </tr>
+<body id="image" onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('src').focus();" style="display: none">
+<form onsubmit="insertImage();return false;" action="#">
+ <div class="tabs">
+ <ul>
+ <li id="general_tab" class="current"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{$lang_insert_image_title}</a></span></li>
+ </ul>
+ </div>
+
+ <div class="panel_wrapper">
+ <div id="general_panel" class="panel current">
+ <table border="0" cellpadding="4" cellspacing="0">
<tr>
- <td nowrap="nowrap">{$lang_insert_image_src}:</td>
+ <td nowrap="nowrap"><label for="src">{$lang_insert_image_src}</label></td>
<td><table border="0" cellspacing="0" cellpadding="0">
<tr>
- <td><input name="src" type="text" id="src" value="" style="width: 200px" onchange="getImageData();"></td>
+ <td><input id="src" name="src" type="text" value="" style="width: 200px" onchange="getImageData();"></td>
<td id="srcbrowsercontainer">&nbsp;</td>
</tr>
</table></td>
@@ -49,8 +32,8 @@
if (typeof(tinyMCEImageList) != "undefined" && tinyMCEImageList.length > 0) {
var html = "";
- html += '<tr><td>{$lang_image_list}:</td>';
- html += '<td><select name="image_list" style="width: 200px" onchange="this.form.src.value=this.options[this.selectedIndex].value;resetImageData();getImageData();">';
+ html += '<tr><td><label for="image_list">{$lang_image_list}</label></td>';
+ html += '<td><select id="image_list" name="image_list" style="width: 200px" onchange="this.form.src.value=this.options[this.selectedIndex].value;resetImageData();getImageData();">';
html += '<option value="">---</option>';
for (var i=0; i<tinyMCEImageList.length; i++)
@@ -63,12 +46,12 @@
</script>
<!-- /Image list -->
<tr>
- <td nowrap="nowrap">{$lang_insert_image_alt}:</td>
- <td><input name="alt" type="text" id="alt" value="" style="width: 200px"></td>
+ <td nowrap="nowrap"><label for="alt">{$lang_insert_image_alt}</label></td>
+ <td><input id="alt" name="alt" type="text" value="" style="width: 200px"></td>
</tr>
<tr>
- <td nowrap="nowrap">{$lang_insert_image_align}:</td>
- <td><select name="align">
+ <td nowrap="nowrap"><label for="align">{$lang_insert_image_align}</label></td>
+ <td><select id="align" name="align">
<option value="">{$lang_insert_image_align_default}</option>
<option value="baseline">{$lang_insert_image_align_baseline}</option>
<option value="top">{$lang_insert_image_align_top}</option>
@@ -82,31 +65,36 @@
</select></td>
</tr>
<tr>
- <td nowrap="nowrap"><!--{$lang_insert_image_dimensions}:</td>
- <td><input name="width" type="text" id="width" value="" size="3" maxlength="3">
+ <td nowrap="nowrap"><label for="width">{$lang_insert_image_dimensions}</label></td>
+ <td><input id="width" name="width" type="text" value="" size="4" maxlength="4">
x
- <input name="height" type="text" id="height" value="" size="3" maxlength="3">--></td>
- </tr>
-<!-- <tr>
- <td nowrap="nowrap">{$lang_insert_image_border}:</td>
- <td><input name="border" type="text" id="border" value="" size="3" maxlength="3"></td>
+ <input id="height" name="height" type="text" value="" size="4" maxlength="4"></td>
</tr>
<tr>
- <td nowrap="nowrap">{$lang_insert_image_vspace}:</td>
- <td><input name="vspace" type="text" id="vspace" value="" size="3" maxlength="3"></td>
+ <td nowrap="nowrap"><label for="border">{$lang_insert_image_border}</label></td>
+ <td><input id="border" name="border" type="text" value="" size="4" maxlength="4"></td>
</tr>
<tr>
- <td nowrap="nowrap">{$lang_insert_image_hspace}:</td>
- <td><input name="hspace" type="text" id="hspace" value="" size="3" maxlength="3"></td>
+ <td nowrap="nowrap"><label for="vspace">{$lang_insert_image_vspace}</label></td>
+ <td><input id="vspace" name="vspace" type="text" value="" size="4" maxlength="4"></td>
</tr>
---> <tr>
- <td nowrap="nowrap"><input type="submit" id="insert" name="insert" value="{$lang_insert}" onclick="insertImage();">
- </td>
- <td align="right"><input type="button" id="cancel" name="cancel" value="{$lang_cancel}" onclick="tinyMCEPopup.close();"></td>
+ <tr>
+ <td nowrap="nowrap"><label for="hspace">{$lang_insert_image_hspace}</label></td>
+ <td><input id="hspace" name="hspace" type="text" value="" size="4" maxlength="4"></td>
</tr>
- </table></td>
- </tr>
- </table>
+ </table>
+ </div>
+ </div>
+
+ <div class="mceActionPanel">
+ <div style="float: left">
+ <input type="button" id="cancel" name="cancel" value="{$lang_cancel}" onclick="tinyMCEPopup.close();" />
+ </div>
+
+ <div style="float: right">
+ <input type="submit" id="insert" name="insert" value="{$lang_insert}" onclick="insertImage();" />
+ </div>
+ </div>
</form>
</body>
</html>
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/images/buttons.gif b/wp-inst/wp-includes/js/tinymce/themes/advanced/images/buttons.gif
index 5d5e08b..6196350 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/images/buttons.gif
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/images/buttons.gif
Binary files differ
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/about.js b/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/about.js
index 9cb015d..f60e6f6 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/about.js
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/about.js
@@ -1,5 +1,8 @@
function init() {
+ var inst;
+
tinyMCEPopup.resizeToInnerSize();
+ inst = tinyMCE.selectedInstance;
// Give FF some time
window.setTimeout('insertHelpIFrame();', 10);
@@ -20,8 +23,8 @@ function init() {
html += '</thead>';
html += '<tbody>';
- for (var i=0; i<plugins.length; i++) {
- var info = getPluginInfo(plugins[i]);
+ for (var i=0; i<inst.plugins.length; i++) {
+ var info = getPluginInfo(inst.plugins[i]);
html += '<tr>';
@@ -46,10 +49,8 @@ function init() {
}
function getPluginInfo(name) {
- var fn = eval('tinyMCEPopup.windowOpener.TinyMCE_' + name + '_getInfo');
-
- if (typeof(fn) != 'undefined')
- return fn();
+ if (tinyMCE.plugins[name].getInfo)
+ return tinyMCE.plugins[name].getInfo();
return {
longname : name,
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js b/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js
index a89f972..f2e5d48 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js
@@ -26,7 +26,7 @@ function init() {
function insertAnchor() {
var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id'));
- var name = document.forms[0].anchorName.value;
+ var name = document.forms[0].anchorName.value, e;
tinyMCEPopup.execCommand("mceBeginUndoLevel");
@@ -44,11 +44,26 @@ function insertAnchor() {
name = name.replace(/&/g, '&amp;');
name = name.replace(/\"/g, '&quot;');
name = name.replace(/</g, '&lt;');
- name = name.replace(/>/g, '&gr;');
+ name = name.replace(/>/g, '&gt;');
- html = '<a name="' + name + '"></a>';
+ // Fix for bug #1447335
+ if (tinyMCE.isGecko)
+ html = '<a id="mceNewAnchor" name="' + name + '"></a>';
+ else
+ html = '<a name="' + name + '"></a>';
tinyMCEPopup.execCommand("mceInsertContent", false, html);
+
+ // Fix for bug #1447335 force cursor after the anchor element
+ if (tinyMCE.isGecko) {
+ e = inst.getDoc().getElementById('mceNewAnchor');
+
+ if (e) {
+ inst.selection.selectNode(e, true, false, false);
+ e.removeAttribute('id');
+ }
+ }
+
tinyMCE.handleVisualAid(inst.getBody(), true, inst.visualAid, inst);
}
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js b/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js
index 2f758cf..c4ec326 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js
@@ -170,7 +170,7 @@ charmap = [
['&yacute;', '&#253;', true, 'y - acute'],
['&thorn;', '&#254;', true, 'thorn'],
['&yuml;', '&#255;', true, 'y - diaeresis'],
-// ['&Alpha;', '&#913;', true, 'Alpha'],
+ ['&Alpha;', '&#913;', true, 'Alpha'],
['&Beta;', '&#914;', true, 'Beta'],
['&Gamma;', '&#915;', true, 'Gamma'],
['&Delta;', '&#916;', true, 'Delta'],
@@ -279,9 +279,9 @@ function renderCharMapHTML() {
cols++;
html += ''
+ '<td width="' + tdWidth + '" height="' + tdHeight + '" class="charmap"'
- + ' onmouseover="tinyMCE.switchClass(this,\'charmapOver\');'
+ + ' onmouseover="this.className=\'charmapOver\';'
+ 'previewChar(\'' + charmap[i][1].substring(1,charmap[i][1].length) + '\',\'' + charmap[i][0].substring(1,charmap[i][0].length) + '\',\'' + charmap[i][3] + '\');"'
- + ' onmouseout="tinyMCE.restoreClass(this,\'charmapOver\');"'
+ + ' onmouseout="this.className=\'charmap\';"'
+ ' nowrap="nowrap" onclick="insertChar(\'' + charmap[i][1].substring(2,charmap[i][1].length-1) + '\');"><a style="text-decoration: none;" onfocus="previewChar(\'' + charmap[i][1].substring(1,charmap[i][1].length) + '\',\'' + charmap[i][0].substring(1,charmap[i][0].length) + '\',\'' + charmap[i][3] + '\');" href="javascript:insertChar(\'' + charmap[i][1].substring(2,charmap[i][1].length-1) + '\');" onclick="return false;" onmousedown="return false;" title="' + charmap[i][3] + '">'
+ charmap[i][1]
+ '</a></td>';
@@ -299,11 +299,13 @@ function renderCharMapHTML() {
}
function insertChar(chr) {
- tinyMCEPopup.execCommand('mceInsertContent', false, '\&#' + chr + ';');
+ tinyMCEPopup.execCommand('mceInsertContent', false, '&#' + chr + ';');
// Refocus in window
if (tinyMCEPopup.isWindow)
window.focus();
+
+ tinyMCEPopup.close();
}
function previewChar(codeA, codeB, codeN) {
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js b/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js
index 1d585aa..aa80714 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js
@@ -99,7 +99,8 @@ function renderColorMap() {
+ '<input id="selectedColorBox" name="selectedColorBox" type="text" size="7" maxlength="7" style="width:65px" value="' + inputColor + '" />'
+ '</td></tr>'
+ '</table>'
- + '<input type="button" id="insert" name="insert" value="{$lang_theme_colorpicker_apply}" style="margin-top:3px" onclick="selectColor();">'
+ + '<div style="float: left"><input type="button" id="insert" name="insert" value="{$lang_theme_colorpicker_apply}" style="margin-top:3px" onclick="selectColor();"></div>'
+ + '<div style="float: right"><input type="button" name="cancel" value="{$lang_cancel}" style="margin-top:3px" onclick="tinyMCEPopup.close();" id="cancel" /></div>'
+ '</td></tr>'
+ '</table>';
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/image.js b/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/image.js
index d97e79b..950c043 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/image.js
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/image.js
@@ -8,19 +8,18 @@ if (url != null) {
}
function insertImage() {
- if (window.opener) {
- var src = document.forms[0].src.value;
- var alt = document.forms[0].alt.value;
- var border = '';//document.forms[0].border.value;
- var vspace = '';//document.forms[0].vspace.value;
- var hspace = '';//document.forms[0].hspace.value;
- var width = '';//document.forms[0].width.value;
- var height = '';//document.forms[0].height.value;
- var align = document.forms[0].align.options[document.forms[0].align.selectedIndex].value;
-
- window.opener.tinyMCE.insertImage(src, alt, border, hspace, vspace, width, height, align);
- top.close();
- }
+ var src = document.forms[0].src.value;
+ var alt = document.forms[0].alt.value;
+ var border = document.forms[0].border.value;
+ var vspace = document.forms[0].vspace.value;
+ var hspace = document.forms[0].hspace.value;
+ var width = document.forms[0].width.value;
+ var height = document.forms[0].height.value;
+ var align = document.forms[0].align.options[document.forms[0].align.selectedIndex].value;
+
+ tinyMCEPopup.restoreSelection();
+ tinyMCE.themes['advanced']._insertImage(src, alt, border, hspace, vspace, width, height, align);
+ tinyMCEPopup.close();
}
function init() {
@@ -37,11 +36,11 @@ function init() {
formObj.src.value = tinyMCE.getWindowArg('src');
formObj.alt.value = tinyMCE.getWindowArg('alt');
-// formObj.border.value = tinyMCE.getWindowArg('border');
-// formObj.vspace.value = tinyMCE.getWindowArg('vspace');
-// formObj.hspace.value = tinyMCE.getWindowArg('hspace');
-// formObj.width.value = tinyMCE.getWindowArg('width');
-// formObj.height.value = tinyMCE.getWindowArg('height');
+ formObj.border.value = tinyMCE.getWindowArg('border');
+ formObj.vspace.value = tinyMCE.getWindowArg('vspace');
+ formObj.hspace.value = tinyMCE.getWindowArg('hspace');
+ formObj.width.value = tinyMCE.getWindowArg('width');
+ formObj.height.value = tinyMCE.getWindowArg('height');
formObj.insert.value = tinyMCE.getLang('lang_' + tinyMCE.getWindowArg('action'), 'Insert', true);
// Handle file browser
@@ -61,17 +60,17 @@ var preloadImg = new Image();
function resetImageData() {
var formObj = document.forms[0];
- formObj.width.value = formObj.height.value = "";
+ formObj.width.value = formObj.height.value = "";
}
function updateImageData() {
var formObj = document.forms[0];
-// if (formObj.width.value == "")
-// formObj.width.value = preloadImg.width;
+ if (formObj.width.value == "")
+ formObj.width.value = preloadImg.width;
-// if (formObj.height.value == "")
-// formObj.height.value = preloadImg.height;
+ if (formObj.height.value == "")
+ formObj.height.value = preloadImg.height;
}
function getImageData() {
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/link.js b/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/link.js
index adc1053..31b3878 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/link.js
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/link.js
@@ -10,7 +10,11 @@ if (url != null) {
function init() {
tinyMCEPopup.resizeToInnerSize();
-// document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','theme_advanced_link');
+ document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','theme_advanced_link');
+
+ // Handle file browser
+ if (isVisible('hrefbrowser'))
+ document.getElementById('href').style.width = '180px';
var formObj = document.forms[0];
@@ -25,12 +29,15 @@ function init() {
document.forms[0].linktitle.value = tinyMCE.getWindowArg('title');
document.forms[0].insert.value = tinyMCE.getLang('lang_' + tinyMCE.getWindowArg('action'), 'Insert', true);
-// addClassesToList('styleSelect', 'theme_advanced_link_styles');
-// selectByValue(formObj, 'styleSelect', tinyMCE.getWindowArg('className'), true);
+ addClassesToList('styleSelect', 'theme_advanced_link_styles');
+ selectByValue(formObj, 'styleSelect', tinyMCE.getWindowArg('className'), true);
- // Handle file browser
- if (isVisible('hrefbrowser'))
- document.getElementById('href').style.width = '180px';
+ // Hide css select row if no CSS classes
+ if (formObj.styleSelect && formObj.styleSelect.options.length <= 1) {
+ var sr = document.getElementById('styleSelectRow');
+ sr.style.display = 'none';
+ sr.parentNode.removeChild(sr);
+ }
// Auto select link in list
if (typeof(tinyMCELinkList) != "undefined" && tinyMCELinkList.length > 0) {
@@ -44,21 +51,20 @@ function init() {
}
function insertLink() {
- if (window.opener) {
- var href = document.forms[0].href.value;
- var target = document.forms[0].target.options[document.forms[0].target.selectedIndex].value;
- var title = document.forms[0].linktitle.value;
- var style_class = '';//document.forms[0].styleSelect.value;
- var dummy;
-
- // Make anchors absolute
- if (href.charAt(0) == '#')
- href = tinyMCE.settings['document_base_url'] + href;
-
- if (target == '_self')
- target = '';
-
- window.opener.tinyMCE.insertLink(href, target, title, dummy, style_class);
- tinyMCEPopup.close();
- }
+ var href = document.forms[0].href.value;
+ var target = document.forms[0].target.options[document.forms[0].target.selectedIndex].value;
+ var title = document.forms[0].linktitle.value;
+ var style_class = document.forms[0].styleSelect ? document.forms[0].styleSelect.value : "";
+ var dummy;
+
+ // Make anchors absolute
+ if (href.charAt(0) == '#')
+ href = tinyMCE.settings['document_base_url'] + href;
+
+ if (target == '_self')
+ target = '';
+
+ tinyMCEPopup.restoreSelection();
+ tinyMCE.themes['advanced']._insertLink(href, target, title, dummy, style_class);
+ tinyMCEPopup.close();
}
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js b/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
index cb5704f..c266c82 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
@@ -5,13 +5,10 @@ function saveContent() {
// Fixes some charcode issues
function fixContent(html) {
- // WP
- return html;
-
- html = html.replace(new RegExp('<(p|hr|table|tr|td|ol|ul|object|embed|li|blockquote)', 'gi'),'\n<$1');
+/* html = html.replace(new RegExp('<(p|hr|table|tr|td|ol|ul|object|embed|li|blockquote)', 'gi'),'\n<$1');
html = html.replace(new RegExp('<\/(p|ol|ul|li|table|tr|td|blockquote|object)>', 'gi'),'</$1>\n');
html = tinyMCE.regexpReplace(html, '<br />','<br />\n','gi');
- html = tinyMCE.regexpReplace(html, '\n\n','\n','gi');
+ html = tinyMCE.regexpReplace(html, '\n\n','\n','gi');*/
return html;
}
@@ -20,12 +17,20 @@ function onLoadInit() {
document.forms[0].htmlSource.value = fixContent(tinyMCE.getContent(tinyMCE.getWindowArg('editor_id')));
resizeInputs();
- setWrap('off');
}
function setWrap(val) {
- // hard soft off
- document.forms[0].htmlSource.wrap = val;
+ var s = document.forms[0].htmlSource;
+
+ s.wrap = val;
+
+ if (tinyMCE.isGecko) {
+ var v = s.value;
+ var n = s.cloneNode(false);
+ n.setAttribute("wrap", val);
+ s.parentNode.replaceChild(n, s);
+ n.value = v;
+ }
}
function toggleWordWrap(elm) {
@@ -51,6 +56,6 @@ function resizeInputs() {
}
function renderWordWrap() {
- if (tinyMCE.isMSIE)
+ if (tinyMCE.isMSIE || tinyMCE.isGecko)
document.write('<input type="checkbox" name="wraped" id="wraped" onclick="toggleWordWrap(this);" class="wordWrapCode" /><label for="wraped">{$lang_theme_code_wordwrap}</label>');
}
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/langs/en.js b/wp-inst/wp-includes/js/tinymce/themes/advanced/langs/en.js
index 14657ba..ca72676 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/langs/en.js
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/langs/en.js
@@ -2,7 +2,7 @@
tinyMCE.addToLang('',{
theme_style_select : '-- Styles --',
-theme_code_desc : 'Edit HTML Source (Alt+e)',
+theme_code_desc : 'Edit HTML Source',
theme_code_title : 'HTML Source Editor',
theme_code_wordwrap : 'Word wrap',
theme_sub_desc : 'Subscript',
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/link.htm b/wp-inst/wp-includes/js/tinymce/themes/advanced/link.htm
index 4b866fa..98d2f17 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/link.htm
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/link.htm
@@ -2,55 +2,39 @@
<head>
<title>{$lang_insert_link_title}</title>
<script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
+ <script language="javascript" type="text/javascript" src="../../utils/mctabs.js"></script>
<script language="javascript" type="text/javascript" src="../../utils/form_utils.js"></script>
<script language="javascript" type="text/javascript" src="jscripts/link.js"></script>
- <style type="text/css">
- #insert, #cancel {
- font: 13px Verdana, Arial, Helvetica, sans-serif;
- height: auto;
- width: auto;
- background-color: transparent;
- background-image: url(../../../../../wp-admin/images/fade-butt.png);
- background-repeat: repeat;
- border: 3px double;
- border-right-color: rgb(153, 153, 153);
- border-bottom-color: rgb(153, 153, 153);
- border-left-color: rgb(204, 204, 204);
- border-top-color: rgb(204, 204, 204);
- color: rgb(51, 51, 51);
- padding: 0.25em 0.75em;
- }
- #insert:active, #cancel:active {
- background: #f4f4f4;
- border-left-color: #999;
- border-top-color: #999;
- }
- </style>
+ <base target="_self" />
</head>
-<body onload="tinyMCEPopup.executeOnLoad('init();');document.getElementById('href').focus();" style="display: none">
-<form onsubmit="insertLink();return false;">
- <table border="0" cellpadding="0" cellspacing="0" width="100">
- <tr>
- <td align="center" valign="middle"><table border="0" cellpadding="4" cellspacing="0">
- <tr>
- <td colspan="2" class="title" nowrap="nowrap">{$lang_insert_link_title}</td>
- </tr>
+<body id="link" onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('href').focus();" style="display: none">
+<form onsubmit="insertLink();return false;" action="#">
+ <div class="tabs">
+ <ul>
+ <li id="general_tab" class="current"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{$lang_insert_link_title}</a></span></li>
+ </ul>
+ </div>
+
+ <div class="panel_wrapper">
+ <div id="general_panel" class="panel current">
+
+ <table border="0" cellpadding="4" cellspacing="0">
<tr>
- <td nowrap="nowrap">{$lang_insert_link_url}:</td>
- <td> <table border="0" cellspacing="0" cellpadding="0">
- <tr>
- <td><input name="href" type="text" id="href" value="" style="width: 200px"></td>
- <td id="hrefbrowsercontainer">&nbsp;</td>
- </tr>
- </table></td>
+ <td nowrap="nowrap"><label for="href">{$lang_insert_link_url}</label></td>
+ <td><table border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td><input id="href" name="href" type="text" value="" style="width: 200px" /></td>
+ <td id="hrefbrowsercontainer">&nbsp;</td>
+ </tr>
+ </table></td>
</tr>
<!-- Link list -->
<script language="javascript">
if (typeof(tinyMCELinkList) != "undefined" && tinyMCELinkList.length > 0) {
var html = "";
- html += '<tr><td>{$lang_link_list}:</td>';
- html += '<td><select name="link_list" style="width: 200px" onchange="this.form.href.value=this.options[this.selectedIndex].value;">';
+ html += '<tr><td><label for="link_list">{$lang_link_list}</label></td>';
+ html += '<td><select id="link_list" name="link_list" style="width: 200px" onchange="this.form.href.value=this.options[this.selectedIndex].value;">';
html += '<option value="">---</option>';
for (var i=0; i<tinyMCELinkList.length; i++)
@@ -63,8 +47,8 @@
</script>
<!-- /Link list -->
<tr>
- <td nowrap="nowrap">{$lang_insert_link_target}:</td>
- <td><select name="target" style="width: 200px">
+ <td nowrap="nowrap"><label for="target">{$lang_insert_link_target}</label></td>
+ <td><select id="target" name="target" style="width: 200px">
<option value="_self">{$lang_insert_link_target_same}</option>
<option value="_blank">{$lang_insert_link_target_blank}</option>
<script language="javascript">
@@ -88,26 +72,29 @@
</select></td>
</tr>
<tr>
- <td nowrap="nowrap">{$lang_theme_insert_link_titlefield}:</td>
- <td><input name="linktitle" type="text" id="linktitle" value="" style="width: 200px"></td>
+ <td nowrap="nowrap"><label for="linktitle">{$lang_theme_insert_link_titlefield}</label></td>
+ <td><input id="linktitle" name="linktitle" type="text" value="" style="width: 200px"></td>
</tr>
<tr id="styleSelectRow">
- <td><!--{$lang_class_name}:</td>
+ <td><label for="styleSelect">{$lang_class_name}</label></td>
<td>
<select id="styleSelect" name="styleSelect">
<option value="" selected>{$lang_theme_style_select}</option>
</select></td>
- <td align="right">&nbsp;</td>
- <td align="right">&nbsp;--></td>
</tr>
- <tr>
- <td><input type="submit" id="insert" name="insert" value="{$lang_insert}" onclick="insertLink();">
- </td>
- <td align="right"><input type="button" id="cancel" name="cancel" value="{$lang_cancel}" onclick="tinyMCEPopup.close();"></td>
- </tr>
- </table></td>
- </tr>
- </table>
+ </table>
+ </div>
+ </div>
+
+ <div class="mceActionPanel">
+ <div style="float: left">
+ <input type="button" id="cancel" name="cancel" value="{$lang_cancel}" onclick="tinyMCEPopup.close();" />
+ </div>
+
+ <div style="float: right">
+ <input type="submit" id="insert" name="insert" value="{$lang_insert}" onclick="insertLink();" />
+ </div>
+ </div>
</form>
</body>
</html>
diff --git a/wp-inst/wp-includes/js/tinymce/themes/advanced/source_editor.htm b/wp-inst/wp-includes/js/tinymce/themes/advanced/source_editor.htm
index d8329ad..630c721 100644
--- a/wp-inst/wp-includes/js/tinymce/themes/advanced/source_editor.htm
+++ b/wp-inst/wp-includes/js/tinymce/themes/advanced/source_editor.htm
@@ -4,30 +4,9 @@
<title>{$lang_theme_code_title}</title>
<script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
<script language="javascript" type="text/javascript" src="jscripts/source_editor.js"></script>
- <style type="text/css">
- #insert, #cancel {
- font: 13px Verdana, Arial, Helvetica, sans-serif;
- height: auto;
- width: auto;
- background-color: transparent;
- background-image: url(../../../../../wp-admin/images/fade-butt.png);
- background-repeat: repeat;
- border: 3px double;
- border-right-color: rgb(153, 153, 153);
- border-bottom-color: rgb(153, 153, 153);
- border-left-color: rgb(204, 204, 204);
- border-top-color: rgb(204, 204, 204);
- color: rgb(51, 51, 51);
- padding: 0.25em 0.75em;
- }
- #insert:active, #cancel:active {
- background: #f4f4f4;
- border-left-color: #999;
- border-top-color: #999;
- }
- </style>
+ <base target="_self" />
</head>
-<body onload="tinyMCEPopup.executeOnLoad('onLoadInit();');document.getElementById('htmlSource').focus();" onresize="resizeInputs();" style="display: none">
+<body onload="tinyMCEPopup.executeOnLoad('onLoadInit();');document.body.style.display='';document.getElementById('htmlSource').focus();" onresize="resizeInputs();" style="display: none">
<form name="source" onsubmit="saveContent();" action="#">
<div style="float: left" class="title">{$lang_theme_code_title}</div>
@@ -35,15 +14,15 @@
<script language="javascript" type="text/javascript">renderWordWrap();</script>
</div>
- <textarea name="htmlSource" id="htmlSource" rows="15" cols="100" style="width: 100%; height: 100%; font-family: 'Courier New',Courier,mono; font-size: 12px;" dir="ltr" wrap="soft"></textarea>
+ <textarea name="htmlSource" id="htmlSource" rows="15" cols="100" style="width: 100%; height: 100%; font-family: 'Courier New',Courier,mono; font-size: 12px" dir="ltr" wrap="off"></textarea>
<div class="mceActionPanel">
<div style="float: left">
- <input type="button" name="insert" value="{$lang_update}" onclick="saveContent();" id="insert" />
+ <input type="button" name="cancel" value="{$lang_cancel}" onclick="tinyMCEPopup.close();" id="cancel" />
</div>
<div style="float: right">
- <input type="button" name="cancel" value="{$lang_cancel}" onclick="tinyMCEPopup.close();" id="cancel" />
+ <input type="submit" name="insert" value="{$lang_update}" onclick="saveContent();" id="insert" />
</div>
</div>
</form>
diff --git a/wp-inst/wp-includes/js/tinymce/tiny_mce.js b/wp-inst/wp-includes/js/tinymce/tiny_mce.js
index 4e92fdc..9fbf19f 100644
--- a/wp-inst/wp-includes/js/tinymce/tiny_mce.js
+++ b/wp-inst/wp-includes/js/tinymce/tiny_mce.js
@@ -1,19 +1,13 @@
-/**
- * $RCSfile: tiny_mce_src.js,v $
- * $Revision: 1.281 $
- * $Date: 2005/12/02 08:12:07 $
- *
- * @author Moxiecode
- * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.
- */
-
-function TinyMCE() {
+
+/* file:jscripts/tiny_mce/classes/TinyMCE_Engine.class.js */
+
+function TinyMCE_Engine() {
this.majorVersion = "2";
- this.minorVersion = "0";
- this.releaseDate = "2005-12-01";
+ this.minorVersion = "0.5.1";
+ this.releaseDate = "2006-03-22";
this.instances = new Array();
- this.stickyClassesLookup = new Array();
+ this.switchClassCache = new Array();
this.windowArgs = new Array();
this.loadedFiles = new Array();
this.configs = new Array();
@@ -32,6 +26,12 @@ function TinyMCE() {
this.isNS7 = ua.indexOf('Netscape/7') != -1;
this.isNS71 = ua.indexOf('Netscape/7.1') != -1;
this.dialogCounter = 0;
+ this.plugins = new Array();
+ this.themes = new Array();
+ this.menus = new Array();
+ this.loadedPlugins = new Array();
+ this.buttonMap = new Array();
+ this.isLoaded = false;
// Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those
if (this.isOpera) {
@@ -44,3425 +44,3578 @@ function TinyMCE() {
this.idCounter = 0;
};
-TinyMCE.prototype.defParam = function(key, def_val) {
- this.settings[key] = tinyMCE.getParam(key, def_val);
-};
+TinyMCE_Engine.prototype = {
+ init : function(settings) {
+ var theme;
-TinyMCE.prototype.init = function(settings) {
- var theme;
+ this.settings = settings;
- this.settings = settings;
+ // Check if valid browser has execcommand support
+ if (typeof(document.execCommand) == 'undefined')
+ return;
- // Check if valid browser has execcommand support
- if (typeof(document.execCommand) == 'undefined')
- return;
+ // Get script base path
+ if (!tinyMCE.baseURL) {
+ var elements = document.getElementsByTagName('script');
- // Get script base path
- if (!tinyMCE.baseURL) {
- var elements = document.getElementsByTagName('script');
+ for (var i=0; i<elements.length; i++) {
+ if (elements[i].src && (elements[i].src.indexOf("tiny_mce.js") != -1 || elements[i].src.indexOf("tiny_mce_dev.js") != -1 || elements[i].src.indexOf("tiny_mce_src.js") != -1 || elements[i].src.indexOf("tiny_mce_gzip") != -1)) {
+ var src = elements[i].src;
- for (var i=0; i<elements.length; i++) {
- if (elements[i].src && (elements[i].src.indexOf("tiny_mce.js") != -1 || elements[i].src.indexOf("tiny_mce_src.js") != -1 || elements[i].src.indexOf("tiny_mce_gzip") != -1)) {
- var src = elements[i].src;
+ tinyMCE.srcMode = (src.indexOf('_src') != -1 || src.indexOf('_dev') != -1) ? '_src' : '';
+ tinyMCE.gzipMode = src.indexOf('_gzip') != -1;
+ src = src.substring(0, src.lastIndexOf('/'));
- tinyMCE.srcMode = (src.indexOf('_src') != -1) ? '_src' : '';
- src = src.substring(0, src.lastIndexOf('/'));
+ if (settings.exec_mode == "src" || settings.exec_mode == "normal")
+ tinyMCE.srcMode = settings.exec_mode == "src" ? '_src' : '';
- tinyMCE.baseURL = src;
- break;
+ tinyMCE.baseURL = src;
+ break;
+ }
}
}
- }
- // Get document base path
- this.documentBasePath = document.location.href;
- if (this.documentBasePath.indexOf('?') != -1)
- this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.indexOf('?'));
- this.documentURL = this.documentBasePath;
- this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.lastIndexOf('/'));
-
- // If not HTTP absolute
- if (tinyMCE.baseURL.indexOf('://') == -1 && tinyMCE.baseURL.charAt(0) != '/') {
- // If site absolute
- tinyMCE.baseURL = this.documentBasePath + "/" + tinyMCE.baseURL;
- }
+ // Get document base path
+ this.documentBasePath = document.location.href;
+ if (this.documentBasePath.indexOf('?') != -1)
+ this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.indexOf('?'));
+ this.documentURL = this.documentBasePath;
+ this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.lastIndexOf('/'));
+
+ // If not HTTP absolute
+ if (tinyMCE.baseURL.indexOf('://') == -1 && tinyMCE.baseURL.charAt(0) != '/') {
+ // If site absolute
+ tinyMCE.baseURL = this.documentBasePath + "/" + tinyMCE.baseURL;
+ }
- // Set default values on settings
- this.defParam("mode", "none");
- this.defParam("theme", "advanced");
- this.defParam("plugins", "", true);
- this.defParam("language", "en");
- this.defParam("docs_language", this.settings['language']);
- this.defParam("elements", "");
- this.defParam("textarea_trigger", "mce_editable");
- this.defParam("editor_selector", "");
- this.defParam("editor_deselector", "mceNoEditor");
- this.defParam("valid_elements", "+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong/b[class|style],-em/i[class|style],-strike[class|style],-u[class|style],+p[style|dir|class|align],-ol[class|style],-ul[class|style],-li[class|style],br,img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border=0|alt|title|hspace|vspace|width|height|align],-sub[style|class],-sup[style|class],-blockquote[dir|style],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],-td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[style|class|align],-pre[class|align|style],address[class|align|style],-h1[style|dir|class|align],-h2[style|dir|class|align],-h3[style|dir|class|align],-h4[style|dir|class|align],-h5[style|dir|class|align],-h6[style|dir|class|align],hr[class|style],font[face|size|style|id|class|dir|color]");
- this.defParam("extended_valid_elements", "");
- this.defParam("invalid_elements", "");
- this.defParam("encoding", "");
- this.defParam("urlconverter_callback", tinyMCE.getParam("urlconvertor_callback", "TinyMCE.prototype.convertURL"));
- this.defParam("save_callback", "");
- this.defParam("debug", false);
- this.defParam("force_br_newlines", false);
- this.defParam("force_p_newlines", true);
- this.defParam("add_form_submit_trigger", true);
- this.defParam("relative_urls", true);
- this.defParam("remove_script_host", true);
- this.defParam("focus_alert", true);
- this.defParam("document_base_url", this.documentURL);
- this.defParam("visual", true);
- this.defParam("visual_table_class", "mceVisualAid");
- this.defParam("setupcontent_callback", "");
- this.defParam("fix_content_duplication", true);
- this.defParam("custom_undo_redo", true);
- this.defParam("custom_undo_redo_levels", -1);
- this.defParam("custom_undo_redo_keyboard_shortcuts", true);
- this.defParam("verify_css_classes", false);
- this.defParam("verify_html", true);
- this.defParam("apply_source_formatting", false);
- this.defParam("directionality", "ltr");
- this.defParam("cleanup_on_startup", false);
- this.defParam("inline_styles", false);
- this.defParam("convert_newlines_to_brs", false);
- this.defParam("auto_reset_designmode", true);
- this.defParam("entities", "160,nbsp,38,amp,34,quot,162,cent,8364,euro,163,pound,165,yen,169,copy,174,reg,8482,trade,8240,permil,181,micro,183,middot,8226,bull,8230,hellip,8242,prime,8243,Prime,167,sect,182,para,223,szlig,8249,lsaquo,8250,rsaquo,171,laquo,187,raquo,8216,lsquo,8217,rsquo,8220,ldquo,8221,rdquo,8218,sbquo,8222,bdquo,60,lt,62,gt,8804,le,8805,ge,8211,ndash,8212,mdash,175,macr,8254,oline,164,curren,166,brvbar,168,uml,161,iexcl,191,iquest,710,circ,732,tilde,176,deg,8722,minus,177,plusmn,247,divide,8260,frasl,215,times,185,sup1,178,sup2,179,sup3,188,frac14,189,frac12,190,frac34,402,fnof,8747,int,8721,sum,8734,infin,8730,radic,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8712,isin,8713,notin,8715,ni,8719,prod,8743,and,8744,or,172,not,8745,cap,8746,cup,8706,part,8704,forall,8707,exist,8709,empty,8711,nabla,8727,lowast,8733,prop,8736,ang,180,acute,184,cedil,170,ordf,186,ordm,8224,dagger,8225,Dagger,192,Agrave,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,202,Ecirc,203,Euml,204,Igrave,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,212,Ocirc,213,Otilde,214,Ouml,216,Oslash,338,OElig,217,Ugrave,219,Ucirc,220,Uuml,376,Yuml,222,THORN,224,agrave,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,234,ecirc,235,euml,236,igrave,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,244,ocirc,245,otilde,246,ouml,248,oslash,339,oelig,249,ugrave,251,ucirc,252,uuml,254,thorn,255,yuml,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,8501,alefsym,982,piv,8476,real,977,thetasym,978,upsih,8472,weierp,8465,image,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8756,there4,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,173,shy,233,eacute,237,iacute,243,oacute,250,uacute,193,Aacute,225,aacute,201,Eacute,205,Iacute,211,Oacute,218,Uacute,221,Yacute,253,yacute");
- this.defParam("entity_encoding", "named");
- this.defParam("cleanup_callback", "");
- this.defParam("add_unload_trigger", true);
- this.defParam("ask", false);
- this.defParam("nowrap", false);
- this.defParam("auto_resize", false);
- this.defParam("auto_focus", false);
- this.defParam("cleanup", true);
- this.defParam("remove_linebreaks", true);
- this.defParam("button_tile_map", false);
- this.defParam("submit_patch", true);
- this.defParam("browsers", "msie,safari,gecko,opera");
- this.defParam("dialog_type", "window");
- this.defParam("accessibility_warnings", true);
- this.defParam("merge_styles_invalid_parents", "");
- this.defParam("force_hex_style_colors", true);
- this.defParam("trim_span_elements", true);
- this.defParam("convert_fonts_to_spans", false);
- this.defParam("doctype", '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">');
- this.defParam("font_size_classes", '');
- this.defParam("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large');
- this.defParam("event_elements", 'a,img');
- this.defParam("convert_urls", true);
- this.defParam("table_inline_editing", false);
- this.defParam("object_resizing", true);
-
- // Browser check IE
- if (this.isMSIE && this.settings['browsers'].indexOf('msie') == -1)
- return;
+ // Set default values on settings
+ this._def("mode", "none");
+ this._def("theme", "advanced");
+ this._def("plugins", "", true);
+ this._def("language", "en");
+ this._def("docs_language", this.settings['language']);
+ this._def("elements", "");
+ this._def("textarea_trigger", "mce_editable");
+ this._def("editor_selector", "");
+ this._def("editor_deselector", "mceNoEditor");
+ this._def("valid_elements", "+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong/-b[class|style],-em/-i[class|style],-strike[class|style],-u[class|style],#p[id|style|dir|class|align],-ol[class|style],-ul[class|style],-li[class|style],br,img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border|alt=|title|hspace|vspace|width|height|align],-sub[style|class],-sup[style|class],-blockquote[dir|style],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],-td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[style|class|align],-pre[class|align|style],address[class|align|style],-h1[id|style|dir|class|align],-h2[id|style|dir|class|align],-h3[id|style|dir|class|align],-h4[id|style|dir|class|align],-h5[id|style|dir|class|align],-h6[id|style|dir|class|align],hr[class|style],-font[face|size|style|id|class|dir|color],dd[id|class|title|style|dir|lang],dl[id|class|title|style|dir|lang],dt[id|class|title|style|dir|lang]");
+ this._def("extended_valid_elements", "");
+ this._def("invalid_elements", "");
+ this._def("encoding", "");
+ this._def("urlconverter_callback", tinyMCE.getParam("urlconvertor_callback", "TinyMCE_Engine.prototype.convertURL"));
+ this._def("save_callback", "");
+ this._def("debug", false);
+ this._def("force_br_newlines", false);
+ this._def("force_p_newlines", true);
+ this._def("add_form_submit_trigger", true);
+ this._def("relative_urls", true);
+ this._def("remove_script_host", true);
+ this._def("focus_alert", true);
+ this._def("document_base_url", this.documentURL);
+ this._def("visual", true);
+ this._def("visual_table_class", "mceVisualAid");
+ this._def("setupcontent_callback", "");
+ this._def("fix_content_duplication", true);
+ this._def("custom_undo_redo", true);
+ this._def("custom_undo_redo_levels", -1);
+ this._def("custom_undo_redo_keyboard_shortcuts", true);
+ this._def("custom_undo_redo_restore_selection", true);
+ this._def("verify_html", true);
+ this._def("apply_source_formatting", false);
+ this._def("directionality", "ltr");
+ this._def("cleanup_on_startup", false);
+ this._def("inline_styles", false);
+ this._def("convert_newlines_to_brs", false);
+ this._def("auto_reset_designmode", true);
+ this._def("entities", "160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,34,quot,38,amp,60,lt,62,gt,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro", true);
+ this._def("entity_encoding", "named");
+ this._def("cleanup_callback", "");
+ this._def("add_unload_trigger", true);
+ this._def("ask", false);
+ this._def("nowrap", false);
+ this._def("auto_resize", false);
+ this._def("auto_focus", false);
+ this._def("cleanup", true);
+ this._def("remove_linebreaks", true);
+ this._def("button_tile_map", false);
+ this._def("submit_patch", true);
+ this._def("browsers", "msie,safari,gecko,opera", true);
+ this._def("dialog_type", "window");
+ this._def("accessibility_warnings", true);
+ this._def("accessibility_focus", true);
+ this._def("merge_styles_invalid_parents", "");
+ this._def("force_hex_style_colors", true);
+ this._def("trim_span_elements", true);
+ this._def("convert_fonts_to_spans", false);
+ this._def("doctype", '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">');
+ this._def("font_size_classes", '');
+ this._def("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large', true);
+ this._def("event_elements", 'a,img', true);
+ this._def("convert_urls", true);
+ this._def("table_inline_editing", false);
+ this._def("object_resizing", true);
+ this._def("custom_shortcuts", true);
+ this._def("convert_on_click", false);
+ this._def("content_css", '');
+ this._def("fix_list_elements", false);
+ this._def("fix_table_elements", false);
+
+ // Browser check IE
+ if (this.isMSIE && this.settings['browsers'].indexOf('msie') == -1)
+ return;
- // Browser check Gecko
- if (this.isGecko && this.settings['browsers'].indexOf('gecko') == -1)
- return;
+ // Browser check Gecko
+ if (this.isGecko && this.settings['browsers'].indexOf('gecko') == -1)
+ return;
- // Browser check Safari
- if (this.isSafari && this.settings['browsers'].indexOf('safari') == -1)
- return;
+ // Browser check Safari
+ if (this.isSafari && this.settings['browsers'].indexOf('safari') == -1)
+ return;
- // Browser check Opera
- if (this.isOpera && this.settings['browsers'].indexOf('opera') == -1)
- return;
+ // Browser check Opera
+ if (this.isOpera && this.settings['browsers'].indexOf('opera') == -1)
+ return;
- // If not super absolute make it so
- var baseHREF = tinyMCE.settings['document_base_url'];
- var h = document.location.href;
- var p = h.indexOf('://');
- if (p > 0 && document.location.protocol != "file:") {
- p = h.indexOf('/', p + 3);
- h = h.substring(0, p);
+ // If not super absolute make it so
+ var baseHREF = tinyMCE.settings['document_base_url'];
+ var h = document.location.href;
+ var p = h.indexOf('://');
+ if (p > 0 && document.location.protocol != "file:") {
+ p = h.indexOf('/', p + 3);
+ h = h.substring(0, p);
- if (baseHREF.indexOf('://') == -1)
- baseHREF = h + baseHREF;
+ if (baseHREF.indexOf('://') == -1)
+ baseHREF = h + baseHREF;
- tinyMCE.settings['document_base_url'] = baseHREF;
- tinyMCE.settings['document_base_prefix'] = h;
- }
+ tinyMCE.settings['document_base_url'] = baseHREF;
+ tinyMCE.settings['document_base_prefix'] = h;
+ }
- // Trim away query part
- if (baseHREF.indexOf('?') != -1)
- baseHREF = baseHREF.substring(0, baseHREF.indexOf('?'));
+ // Trim away query part
+ if (baseHREF.indexOf('?') != -1)
+ baseHREF = baseHREF.substring(0, baseHREF.indexOf('?'));
- this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/";
+ this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/";
- theme = this.settings['theme'];
- this.blockRegExp = new RegExp("^(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|blockquote|center|dl|dir|fieldset|form|noscript|noframes|menu|isindex)$", "i");
- this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);
- this.uniqueURL = 'http://tinymce.moxiecode.cp/mce_temp_url'; // Make unique URL non real URL
- this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>';
+ theme = this.settings['theme'];
+ this.blockRegExp = new RegExp("^(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|blockquote|center|dl|dir|fieldset|form|noscript|noframes|menu|isindex)$", "i");
+ this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);
+ this.uniqueURL = 'http://tinymce.moxiecode.cp/mce_temp_url'; // Make unique URL non real URL
+ this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>';
+ this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup');
- // Theme url
- this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme;
+ // Theme url
+ this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme;
- if (!tinyMCE.isMSIE)
- this.settings['force_br_newlines'] = false;
+ if (!tinyMCE.isMSIE)
+ this.settings['force_br_newlines'] = false;
- if (tinyMCE.getParam("content_css", false)) {
- var cssPath = tinyMCE.getParam("content_css", "");
+ if (tinyMCE.getParam("popups_css", false)) {
+ var cssPath = tinyMCE.getParam("popups_css", "");
- // Is relative
- if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
- this.settings['content_css'] = this.documentBasePath + "/" + cssPath;
- else
- this.settings['content_css'] = cssPath;
- } else
- this.settings['content_css'] = '';
+ // Is relative
+ if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
+ this.settings['popups_css'] = this.documentBasePath + "/" + cssPath;
+ else
+ this.settings['popups_css'] = cssPath;
+ } else
+ this.settings['popups_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css";
- if (tinyMCE.getParam("popups_css", false)) {
- var cssPath = tinyMCE.getParam("popups_css", "");
+ if (tinyMCE.getParam("editor_css", false)) {
+ var cssPath = tinyMCE.getParam("editor_css", "");
- // Is relative
- if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
- this.settings['popups_css'] = this.documentBasePath + "/" + cssPath;
- else
- this.settings['popups_css'] = cssPath;
- } else
- this.settings['popups_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css";
+ // Is relative
+ if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
+ this.settings['editor_css'] = this.documentBasePath + "/" + cssPath;
+ else
+ this.settings['editor_css'] = cssPath;
+ } else
+ this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";
- if (tinyMCE.getParam("editor_css", false)) {
- var cssPath = tinyMCE.getParam("editor_css", "");
+ if (tinyMCE.settings['debug']) {
+ var msg = "Debug: \n";
- // Is relative
- if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
- this.settings['editor_css'] = this.documentBasePath + "/" + cssPath;
- else
- this.settings['editor_css'] = cssPath;
- } else
- this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";
+ msg += "baseURL: " + this.baseURL + "\n";
+ msg += "documentBasePath: " + this.documentBasePath + "\n";
+ msg += "content_css: " + this.settings['content_css'] + "\n";
+ msg += "popups_css: " + this.settings['popups_css'] + "\n";
+ msg += "editor_css: " + this.settings['editor_css'] + "\n";
- if (tinyMCE.settings['debug']) {
- var msg = "Debug: \n";
+ alert(msg);
+ }
- msg += "baseURL: " + this.baseURL + "\n";
- msg += "documentBasePath: " + this.documentBasePath + "\n";
- msg += "content_css: " + this.settings['content_css'] + "\n";
- msg += "popups_css: " + this.settings['popups_css'] + "\n";
- msg += "editor_css: " + this.settings['editor_css'] + "\n";
+ // Only do this once
+ if (this.configs.length == 0) {
+ // Is Safari enabled
+ if (this.isSafari && this.getParam('safari_warning', false))
+ alert("Safari support is very limited and should be considered experimental.\nSo there is no need to even submit bugreports on this early version.\nYou can disable this message by setting: safari_warning option to false");
- alert(msg);
- }
+ if (typeof(TinyMCECompressed) == "undefined") {
+ tinyMCE.addEvent(window, "DOMContentLoaded", TinyMCE_Engine.prototype.onLoad);
- // Init HTML cleanup
- this._initCleanup();
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ if (document.body)
+ tinyMCE.addEvent(document.body, "readystatechange", TinyMCE_Engine.prototype.onLoad);
+ else
+ tinyMCE.addEvent(document, "readystatechange", TinyMCE_Engine.prototype.onLoad);
+ }
- // Only do this once
- if (this.configs.length == 0) {
- // Is Safari enabled
- if (this.isSafari && this.getParam('safari_warning', true))
- alert("Safari support is very limited and should be considered experimental.\nSo there is no need to even submit bugreports on this early version.\nYou can disable this message by setting: safari_warning option to false");
+ tinyMCE.addEvent(window, "load", TinyMCE_Engine.prototype.onLoad);
+ tinyMCE._addUnloadEvents();
+ }
+ }
- tinyMCE.addEvent(window, "load", TinyMCE.prototype.onLoad);
+ this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings['theme'] + '/editor_template' + tinyMCE.srcMode + '.js');
+ this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings['language'] + '.js');
+ this.loadCSS(this.settings['editor_css']);
+ // Add plugins
+ var p = tinyMCE.getParam('plugins', '', true, ',');
+ if (p.length > 0) {
+ for (var i=0; i<p.length; i++) {
+ if (p[i].charAt(0) != '-')
+ this.loadScript(tinyMCE.baseURL + '/plugins/' + p[i] + '/editor_plugin' + tinyMCE.srcMode + '.js');
+ }
+ }
+
+ // Setup entities
+ settings['cleanup_entities'] = new Array();
+ var entities = tinyMCE.getParam('entities', '', true, ',');
+ for (var i=0; i<entities.length; i+=2)
+ settings['cleanup_entities']['c' + entities[i]] = entities[i+1];
+
+ // Save away this config
+ settings['index'] = this.configs.length;
+ this.configs[this.configs.length] = settings;
+ },
+
+ _addUnloadEvents : function() {
if (tinyMCE.isMSIE) {
if (tinyMCE.settings['add_unload_trigger']) {
- tinyMCE.addEvent(window, "unload", TinyMCE.prototype.unloadHandler);
- tinyMCE.addEvent(window.document, "beforeunload", TinyMCE.prototype.unloadHandler);
+ tinyMCE.addEvent(window, "unload", TinyMCE_Engine.prototype.unloadHandler);
+ tinyMCE.addEvent(window.document, "beforeunload", TinyMCE_Engine.prototype.unloadHandler);
}
} else {
if (tinyMCE.settings['add_unload_trigger'])
tinyMCE.addEvent(window, "unload", function () {tinyMCE.triggerSave(true, true);});
}
- }
-
- this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings['theme'] + '/editor_template' + tinyMCE.srcMode + '.js');
- this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings['language'] + '.js');
- this.loadCSS(this.settings['editor_css']);
+ },
- // Add plugins
- var themePlugins = tinyMCE.getParam('plugins', '', true, ',');
- if (this.settings['plugins'] != '') {
- for (var i=0; i<themePlugins.length; i++)
- this.loadScript(tinyMCE.baseURL + '/plugins/' + themePlugins[i] + '/editor_plugin' + tinyMCE.srcMode + '.js');
- }
+ _def : function(key, def_val, t) {
+ var v = tinyMCE.getParam(key, def_val);
- // Setup entities
- settings['cleanup_entities'] = new Array();
- var entities = tinyMCE.getParam('entities', '', true, ',');
- for (var i=0; i<entities.length; i+=2)
- settings['cleanup_entities']['c' + entities[i]] = entities[i+1];
+ v = t ? v.replace(/\s+/g,"") : v;
- // Save away this config
- settings['index'] = this.configs.length;
- this.configs[this.configs.length] = settings;
-};
+ this.settings[key] = v;
+ },
-TinyMCE.prototype.loadScript = function(url) {
- for (var i=0; i<this.loadedFiles.length; i++) {
- if (this.loadedFiles[i] == url)
- return;
- }
+ hasPlugin : function(n) {
+ return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null;
+ },
- document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></script>');
+ addPlugin : function(n, p) {
+ var op = this.plugins[n];
- this.loadedFiles[this.loadedFiles.length] = url;
-};
+ // Use the previous plugin object base URL used when loading external plugins
+ p.baseURL = op ? op.baseURL : tinyMCE.baseURL + "/plugins/" + n;
+ this.plugins[n] = p;
+ },
-TinyMCE.prototype.loadCSS = function(url) {
- for (var i=0; i<this.loadedFiles.length; i++) {
- if (this.loadedFiles[i] == url)
- return;
- }
-
- document.write('<link href="' + url + '" rel="stylesheet" type="text/css" />');
+ setPluginBaseURL : function(n, u) {
+ var op = this.plugins[n];
- this.loadedFiles[this.loadedFiles.length] = url;
-};
-
-TinyMCE.prototype.importCSS = function(doc, css_file) {
- if (css_file == '')
- return;
+ if (op)
+ op.baseURL = u;
+ else
+ this.plugins[n] = {baseURL : u};
+ },
+
+ loadPlugin : function(n, u) {
+ u = u.indexOf('.js') != -1 ? u.substring(0, u.lastIndexOf('/')) : u;
+ u = u.charAt(u.length-1) == '/' ? u.substring(0, u.length-1) : u;
+ this.plugins[n] = {baseURL : u};
+ this.loadScript(u + "/editor_plugin" + (tinyMCE.srcMode ? '_src' : '') + ".js");
+ },
+
+ hasTheme : function(n) {
+ return typeof(this.themes[n]) != "undefined" && this.themes[n] != null;
+ },
+
+ addTheme : function(n, t) {
+ this.themes[n] = t;
+ },
+
+ addMenu : function(n, m) {
+ this.menus[n] = m;
+ },
+
+ hasMenu : function(n) {
+ return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null;
+ },
+
+ loadScript : function(url) {
+ for (var i=0; i<this.loadedFiles.length; i++) {
+ if (this.loadedFiles[i] == url)
+ return;
+ }
- if (typeof(doc.createStyleSheet) == "undefined") {
- var elm = doc.createElement("link");
+ document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></script>');
- elm.rel = "stylesheet";
- elm.href = css_file;
+ this.loadedFiles[this.loadedFiles.length] = url;
+ },
- if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0)
- headArr[0].appendChild(elm);
- } else
- var styleSheet = doc.createStyleSheet(css_file);
-};
+ loadCSS : function(url) {
+ var ar = url.replace(/\s+/, '').split(',');
+ var lflen = 0, csslen = 0;
+ var skip = false;
+ var x = 0, i = 0;
-TinyMCE.prototype.confirmAdd = function(e, settings) {
- var elm = tinyMCE.isMSIE ? event.srcElement : e.target;
- var elementId = elm.name ? elm.name : elm.id;
+ for (x = 0,csslen = ar.length; x<csslen; x++) {
+ ignore_css = false;
- tinyMCE.settings = settings;
+ if (ar[x] != null && ar[x] != 'null' && ar[x].length > 0) {
+ /* Make sure it doesn't exist. */
+ for (i=0, lflen=this.loadedFiles.length; i<lflen; i++) {
+ if (this.loadedFiles[i] == ar[x]) {
+ skip = true;
+ break;
+ }
+ }
- if (!elm.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm']))
- tinyMCE.addMCEControl(elm, elementId);
+ if (!skip) {
+ document.write('<link href="' + ar[x] + '" rel="stylesheet" type="text/css" />');
+ this.loadedFiles[this.loadedFiles.length] = ar[x];
+ }
+ }
+ }
+ },
- elm.setAttribute('mce_noask', 'true');
-};
+ importCSS : function(doc, css) {
+ var css_ary = css.replace(/\s+/, '').split(',');
+ var csslen, elm, headArr, x, css_file;
-TinyMCE.prototype.updateContent = function(form_element_name) {
- // Find MCE instance linked to given form element and copy it's value
- var formElement = document.getElementById(form_element_name);
- for (var n in tinyMCE.instances) {
- var inst = tinyMCE.instances[n];
- if (!tinyMCE.isInstance(inst))
- continue;
+ for (x = 0, csslen = css_ary.length; x<csslen; x++) {
+ css_file = css_ary[x];
- inst.switchSettings();
+ if (css_file != null && css_file != 'null' && css_file.length > 0) {
+ // Is relative, make absolute
+ if (css_file.indexOf('://') == -1 && css_file.charAt(0) != '/')
+ css_file = this.documentBasePath + "/" + css_file;
- if (inst.formElement == formElement) {
- var doc = inst.getDoc();
+ if (typeof(doc.createStyleSheet) == "undefined") {
+ elm = doc.createElement("link");
- tinyMCE._setHTML(doc, inst.formElement.value);
+ elm.rel = "stylesheet";
+ elm.href = css_file;
- if (!tinyMCE.isMSIE)
- doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid);
+ if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0)
+ headArr[0].appendChild(elm);
+ } else
+ doc.createStyleSheet(css_file);
+ }
}
- }
-};
-
-TinyMCE.prototype.addMCEControl = function(replace_element, form_element_name, target_document) {
- var id = "mce_editor_" + tinyMCE.idCounter++;
- var inst = new TinyMCEControl(tinyMCE.settings);
+ },
- inst.editorId = id;
- this.instances[id] = inst;
-
- inst.onAdd(replace_element, form_element_name, target_document);
-};
+ confirmAdd : function(e, settings) {
+ var elm = tinyMCE.isMSIE ? event.srcElement : e.target;
+ var elementId = elm.name ? elm.name : elm.id;
-TinyMCE.prototype.triggerSave = function(skip_cleanup, skip_callback) {
- // Cleanup and set all form fields
- for (var n in tinyMCE.instances) {
- var inst = tinyMCE.instances[n];
- if (!tinyMCE.isInstance(inst))
- continue;
+ tinyMCE.settings = settings;
- inst.switchSettings();
+ if (tinyMCE.settings['convert_on_click'] || (!elm.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm'])))
+ tinyMCE.addMCEControl(elm, elementId);
- tinyMCE.settings['preformatted'] = false;
+ elm.setAttribute('mce_noask', 'true');
+ },
- // Default to false
- if (typeof(skip_cleanup) == "undefined")
- skip_cleanup = false;
+ updateContent : function(form_element_name) {
+ // Find MCE instance linked to given form element and copy it's value
+ var formElement = document.getElementById(form_element_name);
+ for (var n in tinyMCE.instances) {
+ var inst = tinyMCE.instances[n];
+ if (!tinyMCE.isInstance(inst))
+ continue;
- // Default to false
- if (typeof(skip_callback) == "undefined")
- skip_callback = false;
+ inst.switchSettings();
- tinyMCE._setHTML(inst.getDoc(), inst.getBody().innerHTML);
+ if (inst.formElement == formElement) {
+ var doc = inst.getDoc();
+
+ tinyMCE._setHTML(doc, inst.formElement.value);
- // Remove visual aids when cleanup is disabled
- if (inst.settings['cleanup'] == false) {
- tinyMCE.handleVisualAid(inst.getBody(), true, false, inst);
- tinyMCE._setEventsEnabled(inst.getBody(), true);
+ if (!tinyMCE.isMSIE)
+ doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid);
+ }
}
+ },
- tinyMCE._customCleanup(inst, "submit_content_dom", inst.contentWindow.document.body);
- var htm = skip_cleanup ? inst.getBody().innerHTML : tinyMCE._cleanupHTML(inst, inst.getDoc(), this.settings, inst.getBody(), this.visualAid, true);
- htm = tinyMCE._customCleanup(inst, "submit_content", htm);
+ addMCEControl : function(replace_element, form_element_name, target_document) {
+ var id = "mce_editor_" + tinyMCE.idCounter++;
+ var inst = new TinyMCE_Control(tinyMCE.settings);
- if (tinyMCE.settings["encoding"] == "xml" || tinyMCE.settings["encoding"] == "html")
- htm = tinyMCE.convertStringToXML(htm);
+ inst.editorId = id;
+ this.instances[id] = inst;
- if (!skip_callback && tinyMCE.settings['save_callback'] != "")
- var content = eval(tinyMCE.settings['save_callback'] + "(inst.formTargetElementId,htm,inst.getBody());");
+ inst._onAdd(replace_element, form_element_name, target_document);
+ },
- // Use callback content if available
- if ((typeof(content) != "undefined") && content != null)
- htm = content;
-
- // Replace some weird entities (Bug: #1056343)
- htm = tinyMCE.regexpReplace(htm, "&#40;", "(", "gi");
- htm = tinyMCE.regexpReplace(htm, "&#41;", ")", "gi");
- htm = tinyMCE.regexpReplace(htm, "&#59;", ";", "gi");
- htm = tinyMCE.regexpReplace(htm, "&#34;", "&quot;", "gi");
- htm = tinyMCE.regexpReplace(htm, "&#94;", "^", "gi");
+ removeMCEControl : function(editor_id) {
+ var inst = tinyMCE.getInstanceById(editor_id);
- if (inst.formElement)
- inst.formElement.value = htm;
- }
-};
+ if (inst) {
+ inst.switchSettings();
-TinyMCE.prototype._setEventsEnabled = function(node, state) {
- var events = new Array('onfocus','onblur','onclick','ondblclick',
- 'onmousedown','onmouseup','onmouseover','onmousemove',
- 'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup');
+ editor_id = inst.editorId;
+ var html = tinyMCE.getContent(editor_id);
- var evs = tinyMCE.settings['event_elements'].split(',');
- for (var y=0; y<evs.length; y++){
- var elms = node.getElementsByTagName(evs[y]);
- for (var i=0; i<elms.length; i++) {
- var event = "";
+ // Remove editor instance from instances array
+ var tmpInstances = new Array();
+ for (var instanceName in tinyMCE.instances) {
+ var instance = tinyMCE.instances[instanceName];
+ if (!tinyMCE.isInstance(instance))
+ continue;
- for (var x=0; x<events.length; x++) {
- if ((event = tinyMCE.getAttrib(elms[i], events[x])) != '') {
- event = tinyMCE.cleanupEventStr("" + event);
+ if (instanceName != editor_id)
+ tmpInstances[instanceName] = instance;
+ }
+ tinyMCE.instances = tmpInstances;
- if (!state)
- event = "return true;" + event;
- else
- event = event.replace(/^return true;/gi, '');
+ tinyMCE.selectedElement = null;
+ tinyMCE.selectedInstance = null;
+
+ // Remove element
+ var replaceElement = document.getElementById(editor_id + "_parent");
+ var oldTargetElement = inst.oldTargetElement;
+ var targetName = oldTargetElement.nodeName.toLowerCase();
+
+ if (targetName == "textarea" || targetName == "input") {
+ // Just show the old text area
+ replaceElement.parentNode.removeChild(replaceElement);
+ oldTargetElement.style.display = "inline";
+ oldTargetElement.value = html;
+ } else {
+ oldTargetElement.innerHTML = html;
+ oldTargetElement.style.display = 'block';
- elms[i].removeAttribute(events[x]);
- elms[i].setAttribute(events[x], event);
- }
+ replaceElement.parentNode.insertBefore(oldTargetElement, replaceElement);
+ replaceElement.parentNode.removeChild(replaceElement);
}
}
- }
-};
+ },
-TinyMCE.prototype.resetForm = function(form_index) {
- var formObj = document.forms[form_index];
-
- for (var n in tinyMCE.instances) {
- var inst = tinyMCE.instances[n];
- if (!tinyMCE.isInstance(inst))
- continue;
+ triggerSave : function(skip_cleanup, skip_callback) {
+ var inst, n;
- inst.switchSettings();
-
- for (var i=0; i<formObj.elements.length; i++) {
- if (inst.formTargetElementId == formObj.elements[i].name)
- inst.getBody().innerHTML = inst.startContent;
- }
- }
-};
+ // Default to false
+ if (typeof(skip_cleanup) == "undefined")
+ skip_cleanup = false;
-TinyMCE.prototype.execInstanceCommand = function(editor_id, command, user_interface, value, focus) {
- var inst = tinyMCE.getInstanceById(editor_id);
- if (inst) {
- if (typeof(focus) == "undefined")
- focus = true;
+ // Default to false
+ if (typeof(skip_callback) == "undefined")
+ skip_callback = false;
- if (focus)
- inst.contentWindow.focus();
+ // Cleanup and set all form fields
+ for (n in tinyMCE.instances) {
+ inst = tinyMCE.instances[n];
- // Reset design mode if lost
- inst.autoResetDesignMode();
+ if (!tinyMCE.isInstance(inst))
+ continue;
- this.selectedElement = inst.getFocusElement();
- this.selectedInstance = inst;
- tinyMCE.execCommand(command, user_interface, value);
+ inst.triggerSave(skip_cleanup, skip_callback);
+ }
+ },
- // Cancel event so it doesn't call onbeforeonunlaod
- if (tinyMCE.isMSIE && window.event != null)
- tinyMCE.cancelEvent(window.event);
- }
-};
+ resetForm : function(form_index) {
+ var i, inst, n, formObj = document.forms[form_index];
-TinyMCE.prototype.execCommand = function(command, user_interface, value) {
- // Default input
- user_interface = user_interface ? user_interface : false;
- value = value ? value : null;
+ for (n in tinyMCE.instances) {
+ inst = tinyMCE.instances[n];
- if (tinyMCE.selectedInstance)
- tinyMCE.selectedInstance.switchSettings();
+ if (!tinyMCE.isInstance(inst))
+ continue;
- switch (command) {
- case 'mceHelp':
- var template = new Array();
+ inst.switchSettings();
- template['file'] = 'about.htm';
- template['width'] = 480;
- template['height'] = 380;
+ for (i=0; i<formObj.elements.length; i++) {
+ if (inst.formTargetElementId == formObj.elements[i].name)
+ inst.getBody().innerHTML = inst.startContent;
+ }
+ }
+ },
- tinyMCE.openWindow(template, {
- tinymce_version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion,
- tinymce_releasedate : tinyMCE.releaseDate,
- inline : "yes"
- });
- return;
+ execInstanceCommand : function(editor_id, command, user_interface, value, focus) {
+ var inst = tinyMCE.getInstanceById(editor_id);
+ if (inst) {
+ if (typeof(focus) == "undefined")
+ focus = true;
- case 'mceFocus':
- var inst = tinyMCE.getInstanceById(value);
- if (inst)
+ if (focus)
inst.contentWindow.focus();
- return;
- case "mceAddControl":
- case "mceAddEditor":
- tinyMCE.addMCEControl(tinyMCE._getElementById(value), value);
- return;
+ // Reset design mode if lost
+ inst.autoResetDesignMode();
- case "mceAddFrameControl":
- tinyMCE.addMCEControl(tinyMCE._getElementById(value), value['element'], value['document']);
- return;
+ this.selectedElement = inst.getFocusElement();
+ this.selectedInstance = inst;
+ tinyMCE.execCommand(command, user_interface, value);
- case "mceRemoveControl":
- case "mceRemoveEditor":
- tinyMCE.removeMCEControl(value);
- return;
+ // Cancel event so it doesn't call onbeforeonunlaod
+ if (tinyMCE.isMSIE && window.event != null)
+ tinyMCE.cancelEvent(window.event);
+ }
+ },
- case "mceResetDesignMode":
- // Resets the designmode state of the editors in Gecko
- if (!tinyMCE.isMSIE) {
- for (var n in tinyMCE.instances) {
- if (!tinyMCE.isInstance(tinyMCE.instances[n]))
- continue;
+ execCommand : function(command, user_interface, value) {
+ // Default input
+ user_interface = user_interface ? user_interface : false;
+ value = value ? value : null;
- try {
- tinyMCE.instances[n].getDoc().designMode = "on";
- } catch (e) {
- // Ignore any errors
- }
- }
- }
+ if (tinyMCE.selectedInstance)
+ tinyMCE.selectedInstance.switchSettings();
+ switch (command) {
+ case 'mceHelp':
+ tinyMCE.openWindow({
+ file : 'about.htm',
+ width : 480,
+ height : 380
+ }, {
+ tinymce_version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion,
+ tinymce_releasedate : tinyMCE.releaseDate,
+ inline : "yes"
+ });
return;
- }
- if (this.selectedInstance) {
- this.selectedInstance.execCommand(command, user_interface, value);
- } else if (tinyMCE.settings['focus_alert'])
- alert(tinyMCELang['lang_focus_alert']);
-};
-
-TinyMCE.prototype.eventPatch = function(editor_id) {
- // Remove odd, error
- if (typeof(tinyMCE) == "undefined")
- return true;
+ case 'mceFocus':
+ var inst = tinyMCE.getInstanceById(value);
+ if (inst)
+ inst.contentWindow.focus();
+ return;
- for (var i=0; i<document.frames.length; i++) {
- try {
- if (document.frames[i].event) {
- var event = document.frames[i].event;
+ case "mceAddControl":
+ case "mceAddEditor":
+ tinyMCE.addMCEControl(tinyMCE._getElementById(value), value);
+ return;
- if (!event.target)
- event.target = event.srcElement;
+ case "mceAddFrameControl":
+ tinyMCE.addMCEControl(tinyMCE._getElementById(value['element'], value['document']), value['element'], value['document']);
+ return;
- TinyMCE.prototype.handleEvent(event);
+ case "mceRemoveControl":
+ case "mceRemoveEditor":
+ tinyMCE.removeMCEControl(value);
return;
- }
- } catch (ex) {
- // Ignore error if iframe is pointing to external URL
- }
- }
-};
-TinyMCE.prototype.unloadHandler = function() {
- tinyMCE.triggerSave(true, true);
-};
+ case "mceResetDesignMode":
+ // Resets the designmode state of the editors in Gecko
+ if (!tinyMCE.isMSIE) {
+ for (var n in tinyMCE.instances) {
+ if (!tinyMCE.isInstance(tinyMCE.instances[n]))
+ continue;
+
+ try {
+ tinyMCE.instances[n].getDoc().designMode = "on";
+ } catch (e) {
+ // Ignore any errors
+ }
+ }
+ }
-TinyMCE.prototype.addEventHandlers = function(editor_id) {
- if (tinyMCE.isMSIE) {
- var doc = document.frames[editor_id].document;
-
- // Event patch
- tinyMCE.addEvent(doc, "keypress", TinyMCE.prototype.eventPatch);
- tinyMCE.addEvent(doc, "keyup", TinyMCE.prototype.eventPatch);
- tinyMCE.addEvent(doc, "keydown", TinyMCE.prototype.eventPatch);
- tinyMCE.addEvent(doc, "mouseup", TinyMCE.prototype.eventPatch);
- tinyMCE.addEvent(doc, "click", TinyMCE.prototype.eventPatch);
- } else {
- var inst = tinyMCE.instances[editor_id];
- var doc = inst.getDoc();
+ return;
+ }
- inst.switchSettings();
+ if (this.selectedInstance) {
+ this.selectedInstance.execCommand(command, user_interface, value);
+ } else if (tinyMCE.settings['focus_alert'])
+ alert(tinyMCELang['lang_focus_alert']);
+ },
- tinyMCE.addEvent(doc, "keypress", tinyMCE.handleEvent);
- tinyMCE.addEvent(doc, "keydown", tinyMCE.handleEvent);
- tinyMCE.addEvent(doc, "keyup", tinyMCE.handleEvent);
- tinyMCE.addEvent(doc, "click", tinyMCE.handleEvent);
- tinyMCE.addEvent(doc, "mouseup", tinyMCE.handleEvent);
- tinyMCE.addEvent(doc, "mousedown", tinyMCE.handleEvent);
- tinyMCE.addEvent(doc, "focus", tinyMCE.handleEvent);
- tinyMCE.addEvent(doc, "blur", tinyMCE.handleEvent);
+ _createIFrame : function(replace_element, doc, win) {
+ var iframe, id = replace_element.getAttribute("id");
+ var aw, ah;
- eval('try { doc.designMode = "On"; } catch(e) {}');
- }
-};
+ if (typeof(doc) == "undefined")
+ doc = document;
-TinyMCE.prototype._createIFrame = function(replace_element) {
- var iframe = document.createElement("iframe");
- var id = replace_element.getAttribute("id");
- var aw, ah;
+ if (typeof(win) == "undefined")
+ win = window;
- aw = "" + tinyMCE.settings['area_width'];
- ah = "" + tinyMCE.settings['area_height'];
+ iframe = doc.createElement("iframe");
- if (aw.indexOf('%') == -1) {
- aw = parseInt(aw);
- aw = aw < 0 ? 300 : aw;
- aw = aw + "px";
- }
+ aw = "" + tinyMCE.settings['area_width'];
+ ah = "" + tinyMCE.settings['area_height'];
- if (ah.indexOf('%') == -1) {
- ah = parseInt(ah);
- ah = ah < 0 ? 240 : ah;
- ah = ah + "px";
- }
+ if (aw.indexOf('%') == -1) {
+ aw = parseInt(aw);
+ aw = aw < 0 ? 300 : aw;
+ aw = aw + "px";
+ }
- iframe.setAttribute("id", id);
- //iframe.setAttribute("className", "mceEditorArea");
- iframe.setAttribute("border", "0");
- iframe.setAttribute("frameBorder", "0");
- iframe.setAttribute("marginWidth", "0");
- iframe.setAttribute("marginHeight", "0");
- iframe.setAttribute("leftMargin", "0");
- iframe.setAttribute("topMargin", "0");
- iframe.setAttribute("width", aw);
- iframe.setAttribute("height", ah);
- iframe.setAttribute("allowtransparency", "true");
-
- if (tinyMCE.settings["auto_resize"])
- iframe.setAttribute("scrolling", "no");
-
- // Must have a src element in MSIE HTTPs breaks aswell as absoute URLs
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
- iframe.setAttribute("src", this.settings['default_document']);
-
- iframe.style.width = aw;
- iframe.style.height = ah;
-
- // MSIE 5.0 issue
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
- replace_element.outerHTML = iframe.outerHTML;
- else
- replace_element.parentNode.replaceChild(iframe, replace_element);
+ if (ah.indexOf('%') == -1) {
+ ah = parseInt(ah);
+ ah = ah < 0 ? 240 : ah;
+ ah = ah + "px";
+ }
- if (tinyMCE.isMSIE)
- return window.frames[id];
- else
- return iframe;
-};
+ iframe.setAttribute("id", id);
+ iframe.setAttribute("className", "mceEditorIframe");
+ iframe.setAttribute("border", "0");
+ iframe.setAttribute("frameBorder", "0");
+ iframe.setAttribute("marginWidth", "0");
+ iframe.setAttribute("marginHeight", "0");
+ iframe.setAttribute("leftMargin", "0");
+ iframe.setAttribute("topMargin", "0");
+ iframe.setAttribute("width", aw);
+ iframe.setAttribute("height", ah);
+ iframe.setAttribute("allowtransparency", "true");
+
+ if (tinyMCE.settings["auto_resize"])
+ iframe.setAttribute("scrolling", "no");
+
+ // Must have a src element in MSIE HTTPs breaks aswell as absoute URLs
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ iframe.setAttribute("src", this.settings['default_document']);
+
+ iframe.style.width = aw;
+ iframe.style.height = ah;
+
+ // MSIE 5.0 issue
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ replace_element.outerHTML = iframe.outerHTML;
+ else
+ replace_element.parentNode.replaceChild(iframe, replace_element);
-TinyMCE.prototype.setupContent = function(editor_id) {
- var inst = tinyMCE.instances[editor_id];
- var doc = inst.getDoc();
- var head = doc.getElementsByTagName('head').item(0);
- var content = inst.startContent;
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ return win.frames[id];
+ else
+ return iframe;
+ },
- tinyMCE.operaOpacityCounter = 100 * tinyMCE.idCounter;
+ setupContent : function(editor_id) {
+ var inst = tinyMCE.instances[editor_id];
+ var doc = inst.getDoc();
+ var head = doc.getElementsByTagName('head').item(0);
+ var content = inst.startContent;
- inst.switchSettings();
+ inst.switchSettings();
- // Not loaded correctly hit it again, Mozilla bug #997860
- if (!tinyMCE.isMSIE && tinyMCE.getParam("setupcontent_reload", false) && doc.title != "blank_page") {
- // This part will remove the designMode status
- // Failes first time in Firefox 1.5b2 on Mac
- try {doc.location.href = tinyMCE.baseURL + "/blank.htm";} catch (ex) {}
- window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 1000);
- return;
- }
+ // Not loaded correctly hit it again, Mozilla bug #997860
+ if (!tinyMCE.isMSIE && tinyMCE.getParam("setupcontent_reload", false) && doc.title != "blank_page") {
+ // This part will remove the designMode status
+ // Failes first time in Firefox 1.5b2 on Mac
+ try {doc.location.href = tinyMCE.baseURL + "/blank.htm";} catch (ex) {}
+ window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 1000);
+ return;
+ }
- if (!head) {
- window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 10);
- return;
- }
+ if (!head) {
+ window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 10);
+ return;
+ }
- // Import theme specific content CSS the user specific
- tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/themes/" + inst.settings['theme'] + "/css/editor_content.css");
- tinyMCE.importCSS(inst.getDoc(), inst.settings['content_css']);
- tinyMCE.executeCallback('init_instance_callback', '_initInstance', 0, inst);
+ // Import theme specific content CSS the user specific
+ tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/themes/" + inst.settings['theme'] + "/css/editor_content.css");
+ tinyMCE.importCSS(inst.getDoc(), inst.settings['content_css']);
+ tinyMCE.dispatchCallback(inst, 'init_instance_callback', 'initInstance', inst);
- // Setup span styles
- if (tinyMCE.getParam("convert_fonts_to_spans"))
- inst.getDoc().body.setAttribute('id', 'mceSpanFonts');
+ // Setup keyboard shortcuts
+ if (tinyMCE.getParam('custom_undo_redo_keyboard_shortcuts')) {
+ inst.addShortcut('ctrl', 'z', 'lang_undo_desc', 'Undo');
+ inst.addShortcut('ctrl', 'y', 'lang_redo_desc', 'Redo');
+ }
- if (tinyMCE.settings['nowrap'])
- doc.body.style.whiteSpace = "nowrap";
+ // Add default shortcuts for gecko
+ if (tinyMCE.isGecko) {
+ inst.addShortcut('ctrl', 'b', 'lang_bold_desc', 'Bold');
+ inst.addShortcut('ctrl', 'i', 'lang_italic_desc', 'Italic');
+ inst.addShortcut('ctrl', 'u', 'lang_underline_desc', 'Underline');
+ }
- doc.body.dir = this.settings['directionality'];
- doc.editorId = editor_id;
+ // Setup span styles
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ inst.getDoc().body.setAttribute('id', 'mceSpanFonts');
- // Add on document element in Mozilla
- if (!tinyMCE.isMSIE)
- doc.documentElement.editorId = editor_id;
+ if (tinyMCE.settings['nowrap'])
+ doc.body.style.whiteSpace = "nowrap";
- // Setup base element
- var base = doc.createElement("base");
- base.setAttribute('href', tinyMCE.settings['base_href']);
- head.appendChild(base);
+ doc.body.dir = this.settings['directionality'];
+ doc.editorId = editor_id;
- // Replace new line characters to BRs
- if (tinyMCE.settings['convert_newlines_to_brs']) {
- content = tinyMCE.regexpReplace(content, "\r\n", "<br />", "gi");
- content = tinyMCE.regexpReplace(content, "\r", "<br />", "gi");
- content = tinyMCE.regexpReplace(content, "\n", "<br />", "gi");
- }
+ // Add on document element in Mozilla
+ if (!tinyMCE.isMSIE)
+ doc.documentElement.editorId = editor_id;
- // Open closed anchors
-// content = content.replace(new RegExp('<a(.*?)/>', 'gi'), '<a$1></a>');
+ inst.setBaseHREF(tinyMCE.settings['base_href']);
- // Call custom cleanup code
- content = tinyMCE.storeAwayURLs(content);
- content = tinyMCE._customCleanup(inst, "insert_to_editor", content);
+ // Replace new line characters to BRs
+ if (tinyMCE.settings['convert_newlines_to_brs']) {
+ content = tinyMCE.regexpReplace(content, "\r\n", "<br />", "gi");
+ content = tinyMCE.regexpReplace(content, "\r", "<br />", "gi");
+ content = tinyMCE.regexpReplace(content, "\n", "<br />", "gi");
+ }
- if (tinyMCE.isMSIE) {
- // Ugly!!!
- window.setInterval('try{tinyMCE.getCSSClasses(document.frames["' + editor_id + '"].document, "' + editor_id + '");}catch(e){}', 500);
+ // Open closed anchors
+ // content = content.replace(new RegExp('<a(.*?)/>', 'gi'), '<a$1></a>');
- if (tinyMCE.settings["force_br_newlines"])
- document.frames[editor_id].document.styleSheets[0].addRule("p", "margin: 0px;");
+ // Call custom cleanup code
+ content = tinyMCE.storeAwayURLs(content);
+ content = tinyMCE._customCleanup(inst, "insert_to_editor", content);
- var body = document.frames[editor_id].document.body;
+ if (tinyMCE.isMSIE) {
+ // Ugly!!!
+ window.setInterval('try{tinyMCE.getCSSClasses(tinyMCE.instances["' + editor_id + '"].getDoc(), "' + editor_id + '");}catch(e){}', 500);
- tinyMCE.addEvent(body, "beforepaste", TinyMCE.prototype.eventPatch);
- tinyMCE.addEvent(body, "beforecut", TinyMCE.prototype.eventPatch);
+ if (tinyMCE.settings["force_br_newlines"])
+ doc.styleSheets[0].addRule("p", "margin: 0;");
- body.editorId = editor_id;
- }
+ var body = inst.getBody();
+ body.editorId = editor_id;
+ }
- content = tinyMCE.cleanupHTMLCode(content);
+ content = tinyMCE.cleanupHTMLCode(content);
- // Fix for bug #958637
- if (!tinyMCE.isMSIE) {
- var contentElement = inst.getDoc().createElement("body");
- var doc = inst.getDoc();
+ // Fix for bug #958637
+ if (!tinyMCE.isMSIE) {
+ var contentElement = inst.getDoc().createElement("body");
+ var doc = inst.getDoc();
- contentElement.innerHTML = content;
+ contentElement.innerHTML = content;
+
+ // Remove weridness!
+ if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt'])
+ content = content.replace(new RegExp('&lt;&gt;', 'g'), "");
+
+ if (tinyMCE.settings['cleanup_on_startup'])
+ tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement));
+ else {
+ // Convert all strong/em to b/i
+ content = tinyMCE.regexpReplace(content, "<strong", "<b", "gi");
+ content = tinyMCE.regexpReplace(content, "<em(/?)>", "<i$1>", "gi");
+ content = tinyMCE.regexpReplace(content, "<em ", "<i ", "gi");
+ content = tinyMCE.regexpReplace(content, "</strong>", "</b>", "gi");
+ content = tinyMCE.regexpReplace(content, "</em>", "</i>", "gi");
+ tinyMCE.setInnerHTML(inst.getBody(), content);
+ }
- // Remove weridness!
- if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt'])
- content = content.replace(new RegExp('&lt;&gt;', 'g'), "");
+ tinyMCE.convertAllRelativeURLs(inst.getBody());
+ } else {
+ if (tinyMCE.settings['cleanup_on_startup']) {
+ tinyMCE._setHTML(inst.getDoc(), content);
- if (tinyMCE.settings['cleanup_on_startup'])
- tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement));
- else {
- // Convert all strong/em to b/i
- content = tinyMCE.regexpReplace(content, "<strong", "<b", "gi");
- content = tinyMCE.regexpReplace(content, "<em(/?)>", "<i$1>", "gi");
- content = tinyMCE.regexpReplace(content, "<em ", "<i ", "gi");
- content = tinyMCE.regexpReplace(content, "</strong>", "</b>", "gi");
- content = tinyMCE.regexpReplace(content, "</em>", "</i>", "gi");
- tinyMCE.setInnerHTML(inst.getBody(), content);
+ // Produces permission denied error in MSIE 5.5
+ eval('try {tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody()));} catch(e) {}');
+ } else
+ tinyMCE._setHTML(inst.getDoc(), content);
}
- inst.convertAllRelativeURLs();
- } else {
- if (tinyMCE.settings['cleanup_on_startup']) {
- tinyMCE._setHTML(inst.getDoc(), content);
-
- // Produces permission denied error in MSIE 5.5
- eval('try {tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody()));} catch(e) {}');
- } else
- tinyMCE._setHTML(inst.getDoc(), content);
- }
-
- // Fix for bug #957681
- //inst.getDoc().designMode = inst.getDoc().designMode;
+ // Fix for bug #957681
+ //inst.getDoc().designMode = inst.getDoc().designMode;
- // Setup element references
- var parentElm = document.getElementById(inst.editorId + '_parent');
- if (parentElm.lastChild.nodeName == "INPUT")
- inst.formElement = tinyMCE.isGecko ? parentElm.firstChild : parentElm.lastChild;
- else
+ // Setup element references
+ var parentElm = inst.targetDoc.getElementById(inst.editorId + '_parent');
inst.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling;
- tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst);
- tinyMCE.executeCallback('setupcontent_callback', '_setupContent', 0, editor_id, inst.getBody(), inst.getDoc());
+ tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst);
+ tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc());
- // Re-add design mode on mozilla
- if (!tinyMCE.isMSIE)
- TinyMCE.prototype.addEventHandlers(editor_id);
+ // Re-add design mode on mozilla
+ if (!tinyMCE.isMSIE)
+ tinyMCE.addEventHandlers(inst);
- // Add blur handler
- if (tinyMCE.isMSIE)
- tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE.prototype.eventPatch);
+ // Add blur handler
+ if (tinyMCE.isMSIE) {
+ tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE_Engine.prototype._eventPatch);
+ tinyMCE.addEvent(inst.getBody(), "beforedeactivate", TinyMCE_Engine.prototype._eventPatch); // Bug #1439953
+
+ // Workaround for drag drop/copy paste base href bug
+ if (!tinyMCE.isOpera) {
+ tinyMCE.addEvent(doc.body, "mousemove", TinyMCE_Engine.prototype.onMouseMove);
+ tinyMCE.addEvent(doc.body, "beforepaste", TinyMCE_Engine.prototype._eventPatch);
+ tinyMCE.addEvent(doc.body, "drop", TinyMCE_Engine.prototype._eventPatch);
+ }
+ }
- // Trigger node change, this call locks buttons for tables and so forth
- tinyMCE.selectedInstance = inst;
- tinyMCE.selectedElement = inst.contentWindow.document.body;
+ // Trigger node change, this call locks buttons for tables and so forth
+ tinyMCE.selectedInstance = inst;
+ tinyMCE.selectedElement = inst.contentWindow.document.body;
- if (!inst.isHidden())
- tinyMCE.triggerNodeChange(false, true);
+ // Call custom DOM cleanup
+ tinyMCE._customCleanup(inst, "insert_to_editor_dom", inst.getBody());
+ tinyMCE._customCleanup(inst, "setup_content_dom", inst.getBody());
+ tinyMCE._setEventsEnabled(inst.getBody(), false);
+ tinyMCE.cleanupAnchors(inst.getDoc());
- // Call custom DOM cleanup
- tinyMCE._customCleanup(inst, "insert_to_editor_dom", inst.getBody());
- tinyMCE._customCleanup(inst, "setup_content_dom", inst.getBody());
- tinyMCE._setEventsEnabled(inst.getBody(), false);
- tinyMCE.cleanupAnchors(inst.getDoc());
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertSpansToFonts(inst.getDoc());
- if (tinyMCE.getParam("convert_fonts_to_spans"))
- tinyMCE.convertSpansToFonts(inst.getDoc());
+ inst.startContent = tinyMCE.trim(inst.getBody().innerHTML);
+ inst.undoRedo.add({ content : inst.startContent });
- inst.startContent = tinyMCE.trim(inst.getBody().innerHTML);
- inst.undoLevels[inst.undoLevels.length] = inst.startContent;
+ tinyMCE.selectedInstance = inst;
+ tinyMCE.triggerNodeChange(false, true);
+ },
- tinyMCE.operaOpacityCounter = -1;
-};
+ storeAwayURLs : function(s) {
+ // Remove all mce_src, mce_href and replace them with new ones
+ // s = s.replace(new RegExp('mce_src\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
+ // s = s.replace(new RegExp('mce_href\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
-TinyMCE.prototype.cleanupHTMLCode = function(s) {
- s = s.replace(/<p \/>/gi, '<p>&nbsp;</p>');
- s = s.replace(/<p>\s*<\/p>/gi, '<p>&nbsp;</p>');
+ if (!s.match(/(mce_src|mce_href)/gi, s)) {
+ s = s.replace(new RegExp('src\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'src="$1" mce_src="$1"');
+ s = s.replace(new RegExp('href\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'href="$1" mce_href="$1"');
+ }
- // Open closed tags like <b/> to <b></b>
-// tinyMCE.debug("f:" + s);
- s = s.replace(/<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([a-z]*)([^\\|>]*?)\/>/gi, '<$1$2$3></$1$2>');
-// tinyMCE.debug("e:" + s);
+ return s;
+ },
- // Remove trailing space <b > to <b>
- s = s.replace(new RegExp('\\s+></', 'gi'), '></');
+ removeTinyMCEFormElements : function(form_obj) {
+ // Check if form is valid
+ if (typeof(form_obj) == "undefined" || form_obj == null)
+ return;
- // Close tags <img></img> to <img/>
- s = s.replace(/<(img|br|hr)(.*?)><\/(img|br|hr)>/gi, '<$1$2 />');
+ // If not a form, find the form
+ if (form_obj.nodeName != "FORM") {
+ if (form_obj.form)
+ form_obj = form_obj.form;
+ else
+ form_obj = tinyMCE.getParentElement(form_obj, "form");
+ }
- // Weird MSIE bug, <p><hr /></p> breaks runtime?
- if (tinyMCE.isMSIE)
- s = s.replace(/<p><hr \/><\/p>/gi, "<hr>");
+ // Still nothing
+ if (form_obj == null)
+ return;
- // Convert relative anchors to absolute URLs ex: #something to file.htm#something
- s = s.replace(new RegExp('(href=\"?)(\\s*?#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#");
+ // Disable all UI form elements that TinyMCE created
+ for (var i=0; i<form_obj.elements.length; i++) {
+ var elementId = form_obj.elements[i].name ? form_obj.elements[i].name : form_obj.elements[i].id;
- return s;
-};
+ if (elementId.indexOf('mce_editor_') == 0)
+ form_obj.elements[i].disabled = true;
+ }
+ },
-TinyMCE.prototype.storeAwayURLs = function(s) {
- // Remove all mce_src, mce_href and replace them with new ones
- s = s.replace(new RegExp('mce_src\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
- s = s.replace(new RegExp('mce_href\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
- s = s.replace(new RegExp('src\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'src="$1" mce_src="$1"');
- s = s.replace(new RegExp('href\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'href="$1" mce_href="$1"');
+ handleEvent : function(e) {
+ var inst = tinyMCE.selectedInstance;
- return s;
-};
+ // Remove odd, error
+ if (typeof(tinyMCE) == "undefined")
+ return true;
-TinyMCE.prototype.cancelEvent = function(e) {
- if (tinyMCE.isMSIE) {
- e.returnValue = false;
- e.cancelBubble = true;
- } else
- e.preventDefault();
-};
+ //tinyMCE.debug(e.type + " " + e.target.nodeName + " " + (e.relatedTarget ? e.relatedTarget.nodeName : ""));
-TinyMCE.prototype.removeTinyMCEFormElements = function(form_obj) {
- // Check if form is valid
- if (typeof(form_obj) == "undefined" || form_obj == null)
- return;
+ if (tinyMCE.executeCallback(tinyMCE.selectedInstance, 'handle_event_callback', 'handleEvent', e))
+ return false;
- // If not a form, find the form
- if (form_obj.nodeName != "FORM") {
- if (form_obj.form)
- form_obj = form_obj.form;
- else
- form_obj = tinyMCE.getParentElement(form_obj, "form");
- }
+ switch (e.type) {
+ case "beforedeactivate": // Was added due to bug #1439953
+ case "blur":
+ if (tinyMCE.selectedInstance)
+ tinyMCE.selectedInstance.execCommand('mceEndTyping');
- // Still nothing
- if (form_obj == null)
- return;
+ tinyMCE.hideMenus();
- // Disable all UI form elements that TinyMCE created
- for (var i=0; i<form_obj.elements.length; i++) {
- var elementId = form_obj.elements[i].name ? form_obj.elements[i].name : form_obj.elements[i].id;
+ return;
- if (elementId.indexOf('mce_editor_') == 0)
- form_obj.elements[i].disabled = true;
- }
-};
+ // Workaround for drag drop/copy paste base href bug
+ case "drop":
+ case "beforepaste":
+ if (tinyMCE.selectedInstance)
+ tinyMCE.selectedInstance.setBaseHREF(null);
-TinyMCE.prototype.accessibleEventHandler = function(e) {
- var win = this._win;
- e = tinyMCE.isMSIE ? win.event : e;
- var elm = tinyMCE.isMSIE ? e.srcElement : e.target;
+ window.setTimeout("tinyMCE.selectedInstance.setBaseHREF(tinyMCE.settings['base_href']);", 1);
+ return;
- // Piggyback onchange
- if (elm.nodeName == "SELECT" && !elm.oldonchange) {
- elm.oldonchange = elm.onchange;
- elm.onchange = null;
- }
+ case "submit":
+ tinyMCE.removeTinyMCEFormElements(tinyMCE.isMSIE ? window.event.srcElement : e.target);
+ tinyMCE.triggerSave();
+ tinyMCE.isNotDirty = true;
+ return;
- // Execute onchange and remove piggyback
- if (e.keyCode == 13 || e.keyCode == 32) {
- elm.onchange = elm.oldonchange;
- elm.onchange();
- elm.oldonchange = null;
- tinyMCE.cancelEvent(e);
- }
-};
+ case "reset":
+ var formObj = tinyMCE.isMSIE ? window.event.srcElement : e.target;
-TinyMCE.prototype.addSelectAccessibility = function(e, select, win) {
- // Add event handlers
- if (!select._isAccessible) {
- select.onkeydown = tinyMCE.accessibleEventHandler;
- select._isAccessible = true;
- select._win = win;
- }
-};
+ for (var i=0; i<document.forms.length; i++) {
+ if (document.forms[i] == formObj)
+ window.setTimeout('tinyMCE.resetForm(' + i + ');', 10);
+ }
-TinyMCE.prototype.handleEvent = function(e) {
- // Remove odd, error
- if (typeof(tinyMCE) == "undefined")
- return true;
+ return;
- //tinyMCE.debug(e.type + " " + e.target.nodeName + " " + (e.relatedTarget ? e.relatedTarget.nodeName : ""));
+ case "keypress":
+ if (inst && inst.handleShortcut(e))
+ return false;
- switch (e.type) {
- case "blur":
- if (tinyMCE.selectedInstance)
- tinyMCE.selectedInstance.execCommand('mceEndTyping');
+ if (e.target.editorId) {
+ tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
+ } else {
+ if (e.target.ownerDocument.editorId)
+ tinyMCE.selectedInstance = tinyMCE.instances[e.target.ownerDocument.editorId];
+ }
- return;
+ if (tinyMCE.selectedInstance)
+ tinyMCE.selectedInstance.switchSettings();
- case "submit":
- tinyMCE.removeTinyMCEFormElements(tinyMCE.isMSIE ? window.event.srcElement : e.target);
- tinyMCE.triggerSave();
- tinyMCE.isNotDirty = true;
- return;
+ // Insert P element
+ if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && e.keyCode == 13 && !e.shiftKey) {
+ // Insert P element instead of BR
+ if (TinyMCE_ForceParagraphs._insertPara(tinyMCE.selectedInstance, e)) {
+ // Cancel event
+ tinyMCE.execCommand("mceAddUndoLevel");
+ tinyMCE.cancelEvent(e);
+ return false;
+ }
+ }
- case "reset":
- var formObj = tinyMCE.isMSIE ? window.event.srcElement : e.target;
+ // Handle backspace
+ if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
+ // Insert P element instead of BR
+ if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) {
+ // Cancel event
+ tinyMCE.execCommand("mceAddUndoLevel");
+ tinyMCE.cancelEvent(e);
+ return false;
+ }
+ }
- for (var i=0; i<document.forms.length; i++) {
- if (document.forms[i] == formObj)
- window.setTimeout('tinyMCE.resetForm(' + i + ');', 10);
- }
+ // Return key pressed
+ if (tinyMCE.isMSIE && tinyMCE.settings['force_br_newlines'] && e.keyCode == 13) {
+ if (e.target.editorId)
+ tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
- return;
+ if (tinyMCE.selectedInstance) {
+ var sel = tinyMCE.selectedInstance.getDoc().selection;
+ var rng = sel.createRange();
- case "keypress":
- if (e.target.editorId) {
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
- } else {
- if (e.target.ownerDocument.editorId)
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.ownerDocument.editorId];
- }
+ if (tinyMCE.getParentElement(rng.parentElement(), "li") != null)
+ return false;
- if (tinyMCE.selectedInstance)
- tinyMCE.selectedInstance.switchSettings();
+ // Cancel event
+ e.returnValue = false;
+ e.cancelBubble = true;
- // Insert space instead of &nbsp;
-/* if (tinyMCE.isGecko && e.charCode == 32) {
- if (tinyMCE.selectedInstance._insertSpace()) {
- // Cancel event
- e.preventDefault();
- return false;
+ // Insert BR element
+ rng.pasteHTML("<br />");
+ rng.collapse(false);
+ rng.select();
+
+ tinyMCE.execCommand("mceAddUndoLevel");
+ tinyMCE.triggerNodeChange(false);
+ return false;
+ }
}
- }*/
- // Insert P element
- if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && e.keyCode == 13 && !e.shiftKey) {
- // Insert P element instead of BR
- if (tinyMCE.selectedInstance._insertPara(e)) {
- // Cancel event
- tinyMCE.execCommand("mceAddUndoLevel");
- tinyMCE.cancelEvent(e);
- return false;
+ // Backspace or delete
+ if (e.keyCode == 8 || e.keyCode == 46) {
+ tinyMCE.selectedElement = e.target;
+ tinyMCE.linkElement = tinyMCE.getParentElement(e.target, "a");
+ tinyMCE.imgElement = tinyMCE.getParentElement(e.target, "img");
+ tinyMCE.triggerNodeChange(false);
}
- }
- // Handle backspace
- if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
- // Insert P element instead of BR
- if (tinyMCE.selectedInstance._handleBackSpace(e.type)) {
- // Cancel event
- tinyMCE.execCommand("mceAddUndoLevel");
- tinyMCE.cancelEvent(e);
+ return false;
+ break;
+
+ case "keyup":
+ case "keydown":
+ tinyMCE.hideMenus();
+ tinyMCE.hasMouseMoved = false;
+
+ if (inst && inst.handleShortcut(e))
return false;
- }
- }
- // Mozilla custom key handling
- if (tinyMCE.isGecko && (e.ctrlKey && !e.altKey) && tinyMCE.settings['custom_undo_redo']) {
- if (tinyMCE.settings['custom_undo_redo_keyboard_shortcuts']) {
- if (e.charCode == 122) { // Ctrl+Z
- tinyMCE.selectedInstance.execCommand("Undo");
- tinyMCE.cancelEvent(e);
- return false;
- }
+ if (e.target.editorId)
+ tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
+ else
+ return;
- if (e.charCode == 121) { // Ctrl+Y
- tinyMCE.selectedInstance.execCommand("Redo");
- tinyMCE.cancelEvent(e);
+ if (tinyMCE.selectedInstance)
+ tinyMCE.selectedInstance.switchSettings();
+
+ var inst = tinyMCE.selectedInstance;
+
+ // Handle backspace
+ if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
+ // Insert P element instead of BR
+ if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) {
+ // Cancel event
+ tinyMCE.execCommand("mceAddUndoLevel");
+ e.preventDefault();
return false;
}
}
- if (e.charCode == 98) { // Ctrl+B
- tinyMCE.selectedInstance.execCommand("Bold");
- tinyMCE.cancelEvent(e);
- return false;
- }
-
- if (e.charCode == 105) { // Ctrl+I
- tinyMCE.selectedInstance.execCommand("Italic");
- tinyMCE.cancelEvent(e);
- return false;
+ tinyMCE.selectedElement = null;
+ tinyMCE.selectedNode = null;
+ var elm = tinyMCE.selectedInstance.getFocusElement();
+ tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a");
+ tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img");
+ tinyMCE.selectedElement = elm;
+
+ // Update visualaids on tabs
+ if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9)
+ tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings['visual'], tinyMCE.selectedInstance);
+
+ // Fix empty elements on return/enter, check where enter occured
+ if (tinyMCE.isMSIE && e.type == "keydown" && e.keyCode == 13)
+ tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement();
+
+ // Fix empty elements on return/enter
+ if (tinyMCE.isMSIE && e.type == "keyup" && e.keyCode == 13) {
+ var elm = tinyMCE.enterKeyElement;
+ if (elm) {
+ var re = new RegExp('^HR|IMG|BR$','g'); // Skip these
+ var dre = new RegExp('^H[1-6]$','g'); // Add double on these
+
+ if (!elm.hasChildNodes() && !re.test(elm.nodeName)) {
+ if (dre.test(elm.nodeName))
+ elm.innerHTML = "&nbsp;&nbsp;";
+ else
+ elm.innerHTML = "&nbsp;";
+ }
+ }
}
- if (e.charCode == 117) { // Ctrl+U
- tinyMCE.selectedInstance.execCommand("Underline");
- tinyMCE.cancelEvent(e);
- return false;
+ // Check if it's a position key
+ var keys = tinyMCE.posKeyCodes;
+ var posKey = false;
+ for (var i=0; i<keys.length; i++) {
+ if (keys[i] == e.keyCode) {
+ posKey = true;
+ break;
+ }
}
- if (e.charCode == 118) { // Ctrl+V
- tinyMCE.selectedInstance.execCommand("mceInsertContent", false, '<geckopastefix/>');
+ // MSIE custom key handling
+ if (tinyMCE.isMSIE && tinyMCE.settings['custom_undo_redo']) {
+ var keys = new Array(8,46); // Backspace,Delete
+ for (var i=0; i<keys.length; i++) {
+ if (keys[i] == e.keyCode) {
+ if (e.type == "keyup")
+ tinyMCE.triggerNodeChange(false);
+ }
+ }
}
- }
- // Return key pressed
- if (tinyMCE.isMSIE && tinyMCE.settings['force_br_newlines'] && e.keyCode == 13) {
- if (e.target.editorId)
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
+ // If Ctrl key
+ if (e.keyCode == 17)
+ return true;
- if (tinyMCE.selectedInstance) {
- var sel = tinyMCE.selectedInstance.getDoc().selection;
- var rng = sel.createRange();
+ // Handle Undo/Redo when typing content
- if (tinyMCE.getParentElement(rng.parentElement(), "li") != null)
- return false;
+ // Start typing (non position key)
+ if (!posKey && e.type == "keyup")
+ tinyMCE.execCommand("mceStartTyping");
- // Cancel event
- e.returnValue = false;
- e.cancelBubble = true;
+ // Store undo bookmark
+ if (e.type == "keydown" && (posKey || e.ctrlKey) && inst)
+ inst.undoBookmark = inst.selection.getBookmark();
- // Insert BR element
- rng.pasteHTML("<br />");
- rng.collapse(false);
- rng.select();
+ // End typing (position key) or some Ctrl event
+ if (e.type == "keyup" && (posKey || e.ctrlKey))
+ tinyMCE.execCommand("mceEndTyping");
- tinyMCE.execCommand("mceAddUndoLevel");
+ if (posKey && e.type == "keyup")
tinyMCE.triggerNodeChange(false);
- return false;
- }
- }
- // Backspace or delete
- if (e.keyCode == 8 || e.keyCode == 46) {
- tinyMCE.selectedElement = e.target;
- tinyMCE.linkElement = tinyMCE.getParentElement(e.target, "a");
- tinyMCE.imgElement = tinyMCE.getParentElement(e.target, "img");
- tinyMCE.triggerNodeChange(false);
- }
+ if (tinyMCE.isMSIE && e.ctrlKey)
+ window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
+ break;
- return false;
- break;
+ case "mousedown":
+ case "mouseup":
+ case "click":
+ case "focus":
+ tinyMCE.hideMenus();
- case "keyup":
- case "keydown":
- if (e.target.editorId)
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
- else
- return;
+ if (tinyMCE.selectedInstance) {
+ tinyMCE.selectedInstance.switchSettings();
+ tinyMCE.selectedInstance.isFocused = true;
+ }
- if (tinyMCE.selectedInstance)
- tinyMCE.selectedInstance.switchSettings();
+ // Check instance event trigged on
+ var targetBody = tinyMCE.getParentElement(e.target, "body");
+ for (var instanceName in tinyMCE.instances) {
+ if (!tinyMCE.isInstance(tinyMCE.instances[instanceName]))
+ continue;
- var inst = tinyMCE.selectedInstance;
+ var inst = tinyMCE.instances[instanceName];
- // Handle backspace
- if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
- // Insert P element instead of BR
- if (tinyMCE.selectedInstance._handleBackSpace(e.type)) {
- // Cancel event
- tinyMCE.execCommand("mceAddUndoLevel");
- e.preventDefault();
- return false;
- }
- }
+ // Reset design mode if lost (on everything just in case)
+ inst.autoResetDesignMode();
- tinyMCE.selectedElement = null;
- tinyMCE.selectedNode = null;
- var elm = tinyMCE.selectedInstance.getFocusElement();
- tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a");
- tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img");
- tinyMCE.selectedElement = elm;
-
- // Update visualaids on tabs
- if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9)
- tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings['visual'], tinyMCE.selectedInstance);
-
- // Fix empty elements on return/enter, check where enter occured
- if (tinyMCE.isMSIE && e.type == "keydown" && e.keyCode == 13)
- tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement();
-
- // Fix empty elements on return/enter
- if (tinyMCE.isMSIE && e.type == "keyup" && e.keyCode == 13) {
- var elm = tinyMCE.enterKeyElement;
- if (elm) {
- var re = new RegExp('^HR|IMG|BR$','g'); // Skip these
- var dre = new RegExp('^H[1-6]$','g'); // Add double on these
-
- if (!elm.hasChildNodes() && !re.test(elm.nodeName)) {
- if (dre.test(elm.nodeName))
- elm.innerHTML = "&nbsp;&nbsp;";
- else
- elm.innerHTML = "&nbsp;";
+ if (inst.getBody() == targetBody) {
+ tinyMCE.selectedInstance = inst;
+ tinyMCE.selectedElement = e.target;
+ tinyMCE.linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
+ tinyMCE.imgElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "img");
+ break;
}
}
- }
- // Check if it's a position key
- var keys = tinyMCE.posKeyCodes;
- var posKey = false;
- for (var i=0; i<keys.length; i++) {
- if (keys[i] == e.keyCode) {
- posKey = true;
- break;
- }
- }
+ // Add first bookmark location
+ if (!tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark)
+ tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark = tinyMCE.selectedInstance.selection.getBookmark();
- // MSIE custom key handling
- if (tinyMCE.isMSIE && tinyMCE.settings['custom_undo_redo']) {
- var keys = new Array(8,46); // Backspace,Delete
- for (var i=0; i<keys.length; i++) {
- if (keys[i] == e.keyCode) {
- if (e.type == "keyup")
- tinyMCE.triggerNodeChange(false);
- }
- }
+ if (tinyMCE.isSafari) {
+ tinyMCE.selectedInstance.lastSafariSelection = tinyMCE.selectedInstance.selection.getBookmark();
+ tinyMCE.selectedInstance.lastSafariSelectedElement = tinyMCE.selectedElement;
- if (tinyMCE.settings['custom_undo_redo_keyboard_shortcuts']) {
- if (e.keyCode == 90 && (e.ctrlKey && !e.altKey) && e.type == "keydown") { // Ctrl+Z
- tinyMCE.selectedInstance.execCommand("Undo");
- tinyMCE.triggerNodeChange(false);
- }
+ var lnk = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
- if (e.keyCode == 89 && (e.ctrlKey && !e.altKey) && e.type == "keydown") { // Ctrl+Y
- tinyMCE.selectedInstance.execCommand("Redo");
- tinyMCE.triggerNodeChange(false);
+ // Patch the darned link
+ if (lnk && e.type == "mousedown") {
+ lnk.setAttribute("mce_real_href", lnk.getAttribute("href"));
+ lnk.setAttribute("href", "javascript:void(0);");
}
- if ((e.keyCode == 90 || e.keyCode == 89) && (e.ctrlKey && !e.altKey)) {
- // Cancel event
- e.returnValue = false;
- e.cancelBubble = true;
- return false;
+ // Patch back
+ if (lnk && e.type == "click") {
+ window.setTimeout(function() {
+ lnk.setAttribute("href", lnk.getAttribute("mce_real_href"));
+ lnk.removeAttribute("mce_real_href");
+ }, 10);
}
}
- }
- // If undo/redo key
- if ((e.keyCode == 90 || e.keyCode == 89) && (e.ctrlKey && !e.altKey))
- return true;
+ // Reset selected node
+ if (e.type != "focus")
+ tinyMCE.selectedNode = null;
- // If Ctrl key
- if (e.keyCode == 17)
- return true;
+ tinyMCE.triggerNodeChange(false);
+ tinyMCE.execCommand("mceEndTyping");
- // Handle Undo/Redo when typing content
+ if (e.type == "mouseup")
+ tinyMCE.execCommand("mceAddUndoLevel");
- // Start typing (non position key)
- if (!posKey && e.type == "keyup")
- tinyMCE.execCommand("mceStartTyping");
+ // Just in case
+ if (!tinyMCE.selectedInstance && e.target.editorId)
+ tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
- // End typing (position key) or some Ctrl event
- if (e.type == "keyup" && (posKey || e.ctrlKey))
- tinyMCE.execCommand("mceEndTyping");
+ return false;
+ break;
+ }
+ },
- if (posKey && e.type == "keyup")
- tinyMCE.triggerNodeChange(false);
+ getButtonHTML : function(id, lang, img, cmd, ui, val) {
+ var h = '', m, x;
- if (tinyMCE.isMSIE && e.ctrlKey)
- window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
- break;
+ cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\'';
- case "mousedown":
- case "mouseup":
- case "click":
- case "focus":
- if (tinyMCE.selectedInstance)
- tinyMCE.selectedInstance.switchSettings();
+ if (typeof(ui) != "undefined" && ui != null)
+ cmd += ',' + ui;
- // Check instance event trigged on
- var targetBody = tinyMCE.getParentElement(e.target, "body");
- for (var instanceName in tinyMCE.instances) {
- if (!tinyMCE.isInstance(tinyMCE.instances[instanceName]))
- continue;
+ if (typeof(val) != "undefined" && val != null)
+ cmd += ",'" + val + "'";
- var inst = tinyMCE.instances[instanceName];
+ cmd += ');';
- // Reset design mode if lost (on everything just in case)
- inst.autoResetDesignMode();
+ // Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled
+ if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isMSIE || tinyMCE.isOpera) && (m = this.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) {
+ // Tiled button
+ x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20);
+ h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceTiledButton mceButtonNormal" target="_self">';
+ h += '<img src="{$themeurl}/images/spacer.gif" style="background-position: ' + x + 'px 0" title="{$' + lang + '}" />';
+ h += '</a>';
+ } else {
+ // Normal button
+ h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceButtonNormal" target="_self">';
+ h += '<img src="' + img + '" title="{$' + lang + '}" />';
+ h += '</a>';
+ }
- if (inst.getBody() == targetBody) {
- tinyMCE.selectedInstance = inst;
- tinyMCE.selectedElement = e.target;
- tinyMCE.linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
- tinyMCE.imgElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "img");
- break;
- }
- }
+ return h;
+ },
- if (tinyMCE.isSafari) {
- tinyMCE.selectedInstance.lastSafariSelection = tinyMCE.selectedInstance.getBookmark();
- tinyMCE.selectedInstance.lastSafariSelectedElement = tinyMCE.selectedElement;
+ addButtonMap : function(m) {
+ var i, a = m.replace(/\s+/, '').split(',');
- var lnk = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
+ for (i=0; i<a.length; i++)
+ this.buttonMap[a[i]] = i;
+ },
- // Patch the darned link
- if (lnk && e.type == "mousedown") {
- lnk.setAttribute("mce_real_href", lnk.getAttribute("href"));
- lnk.setAttribute("href", "javascript:void(0);");
- }
+ submitPatch : function() {
+ tinyMCE.removeTinyMCEFormElements(this);
+ tinyMCE.triggerSave();
+ this.mceOldSubmit();
+ tinyMCE.isNotDirty = true;
+ },
+
+ onLoad : function() {
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera && window.event.type == "readystatechange" && document.readyState != "complete")
+ return true;
+
+ if (tinyMCE.isLoaded)
+ return true;
+
+ tinyMCE.isLoaded = true;
+
+ tinyMCE.dispatchCallback(null, 'onpageload', 'onPageLoad');
+
+ for (var c=0; c<tinyMCE.configs.length; c++) {
+ tinyMCE.settings = tinyMCE.configs[c];
- // Patch back
- if (lnk && e.type == "click") {
- window.setTimeout(function() {
- lnk.setAttribute("href", lnk.getAttribute("mce_real_href"));
- lnk.removeAttribute("mce_real_href");
- }, 10);
+ var selector = tinyMCE.getParam("editor_selector");
+ var deselector = tinyMCE.getParam("editor_deselector");
+ var elementRefAr = new Array();
+
+ // Add submit triggers
+ if (document.forms && tinyMCE.settings['add_form_submit_trigger'] && !tinyMCE.submitTriggers) {
+ for (var i=0; i<document.forms.length; i++) {
+ var form = document.forms[i];
+
+ tinyMCE.addEvent(form, "submit", TinyMCE_Engine.prototype.handleEvent);
+ tinyMCE.addEvent(form, "reset", TinyMCE_Engine.prototype.handleEvent);
+ tinyMCE.submitTriggers = true; // Do it only once
+
+ // Patch the form.submit function
+ if (tinyMCE.settings['submit_patch']) {
+ try {
+ form.mceOldSubmit = form.submit;
+ form.submit = TinyMCE_Engine.prototype.submitPatch;
+ } catch (e) {
+ // Do nothing
+ }
+ }
}
}
- // Reset selected node
- if (e.type != "focus")
- tinyMCE.selectedNode = null;
+ // Add editor instances based on mode
+ var mode = tinyMCE.settings['mode'];
+ switch (mode) {
+ case "exact":
+ var elements = tinyMCE.getParam('elements', '', true, ',');
- tinyMCE.triggerNodeChange(false);
- tinyMCE.execCommand("mceEndTyping");
+ for (var i=0; i<elements.length; i++) {
+ var element = tinyMCE._getElementById(elements[i]);
+ var trigger = element ? element.getAttribute(tinyMCE.settings['textarea_trigger']) : "";
- if (e.type == "mouseup")
- tinyMCE.execCommand("mceAddUndoLevel");
+ if (tinyMCE.getAttrib(element, "class").indexOf(deselector) != -1)
+ continue;
- // Just in case
- if (!tinyMCE.selectedInstance && e.target.editorId)
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
+ if (trigger == "false")
+ continue;
- return false;
- break;
- } // end switch
-}; // end function
+ if ((tinyMCE.settings['ask'] || tinyMCE.settings['convert_on_click']) && element) {
+ elementRefAr[elementRefAr.length] = element;
+ continue;
+ }
-TinyMCE.prototype.switchClass = function(element, class_name, lock_state) {
- var lockChanged = false;
+ if (element)
+ tinyMCE.addMCEControl(element, elements[i]);
+ else if (tinyMCE.settings['debug'])
+ alert("Error: Could not find element by id or name: " + elements[i]);
+ }
+ break;
- if (typeof(lock_state) != "undefined" && element != null) {
- element.classLock = lock_state;
- lockChanged = true;
- }
+ case "specific_textareas":
+ case "textareas":
+ var nodeList = document.getElementsByTagName("textarea");
- if (element != null && (lockChanged || !element.classLock)) {
- element.oldClassName = element.className;
- element.className = class_name;
- }
-};
+ for (var i=0; i<nodeList.length; i++) {
+ var elm = nodeList.item(i);
+ var trigger = elm.getAttribute(tinyMCE.settings['textarea_trigger']);
-TinyMCE.prototype.restoreAndSwitchClass = function(element, class_name) {
- if (element != null && !element.classLock) {
- this.restoreClass(element);
- this.switchClass(element, class_name);
- }
-};
+ if (selector != '' && tinyMCE.getAttrib(elm, "class").indexOf(selector) == -1)
+ continue;
-TinyMCE.prototype.switchClassSticky = function(element_name, class_name, lock_state) {
- var element, lockChanged = false;
+ if (selector != '')
+ trigger = selector != "" ? "true" : "";
- // Performance issue
- if (!this.stickyClassesLookup[element_name])
- this.stickyClassesLookup[element_name] = document.getElementById(element_name);
+ if (tinyMCE.getAttrib(elm, "class").indexOf(deselector) != -1)
+ continue;
-// element = document.getElementById(element_name);
- element = this.stickyClassesLookup[element_name];
+ if ((mode == "specific_textareas" && trigger == "true") || (mode == "textareas" && trigger != "false"))
+ elementRefAr[elementRefAr.length] = elm;
+ }
+ break;
+ }
- if (typeof(lock_state) != "undefined" && element != null) {
- element.classLock = lock_state;
- lockChanged = true;
- }
+ for (var i=0; i<elementRefAr.length; i++) {
+ var element = elementRefAr[i];
+ var elementId = element.name ? element.name : element.id;
- if (element != null && (lockChanged || !element.classLock)) {
- element.className = class_name;
- element.oldClassName = class_name;
+ if (tinyMCE.settings['ask'] || tinyMCE.settings['convert_on_click']) {
+ // Focus breaks in Mozilla
+ if (tinyMCE.isGecko) {
+ var settings = tinyMCE.settings;
- // Fix opacity in Opera
- if (tinyMCE.isOpera) {
- if (class_name == "mceButtonDisabled") {
- var suffix = "";
+ tinyMCE.addEvent(element, "focus", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);});
- if (!element.mceOldSrc)
- element.mceOldSrc = element.src;
+ if (element.nodeName != "TEXTAREA" && element.nodeName != "INPUT")
+ tinyMCE.addEvent(element, "click", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);});
+ // tinyMCE.addEvent(element, "mouseover", function (e) {window.setTimeout(function() {TinyMCE_Engine.prototype.confirmAdd(e, settings);}, 10);});
+ } else {
+ var settings = tinyMCE.settings;
- if (this.operaOpacityCounter > -1)
- suffix = '?rnd=' + this.operaOpacityCounter++;
+ tinyMCE.addEvent(element, "focus", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); });
+ tinyMCE.addEvent(element, "click", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); });
+ // tinyMCE.addEvent(element, "mouseenter", function () { TinyMCE_Engine.prototype.confirmAdd(null, settings); });
+ }
+ } else
+ tinyMCE.addMCEControl(element, elementId);
+ }
- element.src = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/images/opacity.png" + suffix;
- element.style.backgroundImage = "url('" + element.mceOldSrc + "')";
- } else {
- if (element.mceOldSrc) {
- element.src = element.mceOldSrc;
- element.parentNode.style.backgroundImage = "";
- element.mceOldSrc = null;
- }
+ // Handle auto focus
+ if (tinyMCE.settings['auto_focus']) {
+ window.setTimeout(function () {
+ var inst = tinyMCE.getInstanceById(tinyMCE.settings['auto_focus']);
+ inst.selection.selectNode(inst.getBody(), true, true);
+ inst.contentWindow.focus();
+ }, 10);
}
+
+ tinyMCE.dispatchCallback(null, 'oninit', 'onInit');
}
- }
-};
+ },
-TinyMCE.prototype.restoreClass = function(element) {
- if (element != null && element.oldClassName && !element.classLock) {
- element.className = element.oldClassName;
- element.oldClassName = null;
- }
-};
+ isInstance : function(o) {
+ return o != null && typeof(o) == "object" && o.isTinyMCE_Control;
+ },
-TinyMCE.prototype.setClassLock = function(element, lock_state) {
- if (element != null)
- element.classLock = lock_state;
-};
+ getParam : function(name, default_value, strip_whitespace, split_chr) {
+ var value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
-TinyMCE.prototype.addEvent = function(obj, name, handler) {
- if (tinyMCE.isMSIE) {
- obj.attachEvent("on" + name, handler);
- } else
- obj.addEventListener(name, handler, false);
-};
+ // Fix bool values
+ if (value == "true" || value == "false")
+ return (value == "true");
-TinyMCE.prototype.submitPatch = function() {
- tinyMCE.removeTinyMCEFormElements(this);
- tinyMCE.triggerSave();
- this.mceOldSubmit();
- tinyMCE.isNotDirty = true;
-};
+ if (strip_whitespace)
+ value = tinyMCE.regexpReplace(value, "[ \t\r\n]", "");
-TinyMCE.prototype.onLoad = function() {
- for (var c=0; c<tinyMCE.configs.length; c++) {
- tinyMCE.settings = tinyMCE.configs[c];
+ if (typeof(split_chr) != "undefined" && split_chr != null) {
+ value = value.split(split_chr);
+ var outArray = new Array();
- var selector = tinyMCE.getParam("editor_selector");
- var deselector = tinyMCE.getParam("editor_deselector");
- var elementRefAr = new Array();
+ for (var i=0; i<value.length; i++) {
+ if (value[i] && value[i] != "")
+ outArray[outArray.length] = value[i];
+ }
- // Add submit triggers
- if (document.forms && tinyMCE.settings['add_form_submit_trigger'] && !tinyMCE.submitTriggers) {
- for (var i=0; i<document.forms.length; i++) {
- var form = document.forms[i];
+ value = outArray;
+ }
- tinyMCE.addEvent(form, "submit", TinyMCE.prototype.handleEvent);
- tinyMCE.addEvent(form, "reset", TinyMCE.prototype.handleEvent);
- tinyMCE.submitTriggers = true; // Do it only once
+ return value;
+ },
- // Patch the form.submit function
- if (tinyMCE.settings['submit_patch']) {
- try {
- form.mceOldSubmit = form.submit;
- form.submit = TinyMCE.prototype.submitPatch;
- } catch (e) {
- // Do nothing
- }
- }
- }
+ getLang : function(name, default_value, parse_entities, va) {
+ var v = (typeof(tinyMCELang[name]) == "undefined") ? default_value : tinyMCELang[name], n;
+
+ if (parse_entities)
+ v = tinyMCE.entityDecode(v);
+
+ if (va) {
+ for (n in va)
+ v = this.replaceVar(v, n, va[n]);
}
- // Add editor instances based on mode
- var mode = tinyMCE.settings['mode'];
- switch (mode) {
- case "exact":
- var elements = tinyMCE.getParam('elements', '', true, ',');
+ return v;
+ },
- for (var i=0; i<elements.length; i++) {
- var element = tinyMCE._getElementById(elements[i]);
- var trigger = element ? element.getAttribute(tinyMCE.settings['textarea_trigger']) : "";
+ entityDecode : function(s) {
+ var e = document.createElement("div");
+ e.innerHTML = s;
+ return e.innerHTML;
+ },
- if (tinyMCE.getAttrib(element, "class").indexOf(deselector) != -1)
- continue;
+ addToLang : function(prefix, ar) {
+ for (var key in ar) {
+ if (typeof(ar[key]) == 'function')
+ continue;
- if (trigger == "false")
- continue;
+ tinyMCELang[(key.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = ar[key];
+ }
- if (tinyMCE.settings['ask'] && element) {
- elementRefAr[elementRefAr.length] = element;
- continue;
- }
+ // for (var key in ar)
+ // tinyMCELang[(key.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = "|" + ar[key] + "|";
+ },
- if (element)
- tinyMCE.addMCEControl(element, elements[i]);
- else if (tinyMCE.settings['debug'])
- alert("Error: Could not find element by id or name: " + elements[i]);
- }
- break;
+ triggerNodeChange : function(focus, setup_content) {
+ if (tinyMCE.selectedInstance) {
+ var inst = tinyMCE.selectedInstance;
+ var editorId = inst.editorId;
+ var elm = (typeof(setup_content) != "undefined" && setup_content) ? tinyMCE.selectedElement : inst.getFocusElement();
+ var undoIndex = -1;
+ var undoLevels = -1;
+ var anySelection = false;
+ var selectedText = inst.selection.getSelectedText();
- case "specific_textareas":
- case "textareas":
- var nodeList = document.getElementsByTagName("textarea");
+ if (setup_content && tinyMCE.isGecko && inst.isHidden())
+ elm = inst.getBody();
- for (var i=0; i<nodeList.length; i++) {
- var elm = nodeList.item(i);
- var trigger = elm.getAttribute(tinyMCE.settings['textarea_trigger']);
+ inst.switchSettings();
- if (selector != '' && tinyMCE.getAttrib(elm, "class").indexOf(selector) == -1)
- continue;
+ if (tinyMCE.settings["auto_resize"]) {
+ var doc = inst.getDoc();
- if (selector != '')
- trigger = selector != "" ? "true" : "";
+ inst.iframeElement.style.width = doc.body.offsetWidth + "px";
+ inst.iframeElement.style.height = doc.body.offsetHeight + "px";
+ }
- if (tinyMCE.getAttrib(elm, "class").indexOf(deselector) != -1)
- continue;
+ if (tinyMCE.selectedElement)
+ anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (selectedText && selectedText.length > 0);
- if ((mode == "specific_textareas" && trigger == "true") || (mode == "textareas" && trigger != "false"))
- elementRefAr[elementRefAr.length] = elm;
- }
- break;
+ if (tinyMCE.settings['custom_undo_redo']) {
+ undoIndex = inst.undoRedo.undoIndex;
+ undoLevels = inst.undoRedo.undoLevels.length;
+ }
+
+ tinyMCE.dispatchCallback(inst, 'handle_node_change_callback', 'handleNodeChange', editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection, setup_content);
}
- for (var i=0; i<elementRefAr.length; i++) {
- var element = elementRefAr[i];
- var elementId = element.name ? element.name : element.id;
+ if (this.selectedInstance && (typeof(focus) == "undefined" || focus))
+ this.selectedInstance.contentWindow.focus();
+ },
- if (tinyMCE.settings['ask']) {
- // Focus breaks in Mozilla
- if (tinyMCE.isGecko) {
- var settings = tinyMCE.settings;
+ _customCleanup : function(inst, type, content) {
+ var pl, po, i;
- tinyMCE.addEvent(element, "focus", function (e) {window.setTimeout(function() {TinyMCE.prototype.confirmAdd(e, settings);}, 10);});
- } else {
- var settings = tinyMCE.settings;
+ // Call custom cleanup
+ var customCleanup = tinyMCE.settings['cleanup_callback'];
+ if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined")
+ content = eval(customCleanup + "(type, content, inst);");
- tinyMCE.addEvent(element, "focus", function () { TinyMCE.prototype.confirmAdd(null, settings); });
- }
- } else
- tinyMCE.addMCEControl(element, elementId);
- }
+ // Trigger plugin cleanups
+ pl = inst.plugins;
+ for (i=0; i<pl.length; i++) {
+ po = tinyMCE.plugins[pl[i]];
- // Handle auto focus
- if (tinyMCE.settings['auto_focus']) {
- window.setTimeout(function () {
- var inst = tinyMCE.getInstanceById(tinyMCE.settings['auto_focus']);
- inst.selectNode(inst.getBody(), true, true);
- inst.contentWindow.focus();
- }, 10);
+ if (po && po.cleanup)
+ content = po.cleanup(type, content, inst);
}
- tinyMCE.executeCallback('oninit', '_oninit', 0);
- }
-};
+ return content;
+ },
-TinyMCE.prototype.removeMCEControl = function(editor_id) {
- var inst = tinyMCE.getInstanceById(editor_id);
+ setContent : function(h) {
+ if (tinyMCE.selectedInstance) {
+ tinyMCE.selectedInstance.execCommand('mceSetContent', false, h);
+ tinyMCE.selectedInstance.repaint();
+ }
+ },
- if (inst) {
- inst.switchSettings();
+ importThemeLanguagePack : function(name) {
+ if (typeof(name) == "undefined")
+ name = tinyMCE.settings['theme'];
- editor_id = inst.editorId;
- var html = tinyMCE.getContent(editor_id);
+ tinyMCE.loadScript(tinyMCE.baseURL + '/themes/' + name + '/langs/' + tinyMCE.settings['language'] + '.js');
+ },
- // Remove editor instance from instances array
- var tmpInstances = new Array();
- for (var instanceName in tinyMCE.instances) {
- var instance = tinyMCE.instances[instanceName];
- if (!tinyMCE.isInstance(instance))
- continue;
+ importPluginLanguagePack : function(name, valid_languages) {
+ var lang = "en", b = tinyMCE.baseURL + '/plugins/' + name;
- if (instanceName != editor_id)
- tmpInstances[instanceName] = instance;
+ valid_languages = valid_languages.split(',');
+ for (var i=0; i<valid_languages.length; i++) {
+ if (tinyMCE.settings['language'] == valid_languages[i])
+ lang = tinyMCE.settings['language'];
}
- tinyMCE.instances = tmpInstances;
- tinyMCE.selectedElement = null;
- tinyMCE.selectedInstance = null;
-
- // Remove element
- var replaceElement = document.getElementById(editor_id + "_parent");
- var oldTargetElement = inst.oldTargetElement;
- var targetName = oldTargetElement.nodeName.toLowerCase();
-
- if (targetName == "textarea" || targetName == "input") {
- // Just show the old text area
- replaceElement.parentNode.removeChild(replaceElement);
- oldTargetElement.style.display = "inline";
- oldTargetElement.value = html;
- } else {
- oldTargetElement.innerHTML = html;
+ if (this.plugins[name])
+ b = this.plugins[name].baseURL;
+
+ tinyMCE.loadScript(b + '/langs/' + lang + '.js');
+ },
+
+ applyTemplate : function(h, as) {
+ var i, s, ar = h.match(new RegExp('\\{\\$[a-z0-9_]+\\}', 'gi'));
- replaceElement.parentNode.insertBefore(oldTargetElement, replaceElement);
- replaceElement.parentNode.removeChild(replaceElement);
+ if (ar && ar.length > 0) {
+ for (i=ar.length-1; i>=0; i--) {
+ s = ar[i].substring(2, ar[i].length-1);
+
+ if (s.indexOf('lang_') == 0 && tinyMCELang[s])
+ h = tinyMCE.replaceVar(h, s, tinyMCELang[s]);
+ else if (as && as[s])
+ h = tinyMCE.replaceVar(h, s, as[s]);
+ else if (tinyMCE.settings[s])
+ h = tinyMCE.replaceVar(h, s, tinyMCE.settings[s]);
+ }
}
- }
-};
-TinyMCE.prototype._cleanupElementName = function(element_name, element) {
- var name = "";
+ h = tinyMCE.replaceVar(h, "themeurl", tinyMCE.themeURL);
- element_name = element_name.toLowerCase();
+ return h;
+ },
- // Never include body
- if (element_name == "body")
- return null;
+ replaceVar : function(h, r, v) {
+ return h.replace(new RegExp('{\\\$' + r + '}', 'g'), v);
+ },
- // If verification mode
- if (tinyMCE.cleanup_verify_html) {
- // Check if invalid element
- for (var i=0; i<tinyMCE.cleanup_invalidElements.length; i++) {
- if (tinyMCE.cleanup_invalidElements[i] == element_name)
- return null;
- }
+ openWindow : function(template, args) {
+ var html, width, height, x, y, resizable, scrollbars, url;
- // Check if valid element
- var validElement = false;
- var elementAttribs = null;
- for (var i=0; i<tinyMCE.cleanup_validElements.length && !elementAttribs; i++) {
- for (var x=0, n=tinyMCE.cleanup_validElements[i][0].length; x<n; x++) {
- var elmMatch = tinyMCE.cleanup_validElements[i][0][x];
-
- if (elmMatch.charAt(0) == '+' || elmMatch.charAt(0) == '-')
- elmMatch = elmMatch.substring(1);
-
- // Handle wildcard/regexp
- if (elmMatch.match(new RegExp('\\*|\\?|\\+', 'g')) != null) {
- elmMatch = elmMatch.replace(new RegExp('\\?', 'g'), '(\\S?)');
- elmMatch = elmMatch.replace(new RegExp('\\+', 'g'), '(\\S+)');
- elmMatch = elmMatch.replace(new RegExp('\\*', 'g'), '(\\S*)');
- elmMatch = "^" + elmMatch + "$";
- if (element_name.match(new RegExp(elmMatch, 'g'))) {
- elementAttribs = tinyMCE.cleanup_validElements[i];
- validElement = true;
- break;
- }
- }
+ args['mce_template_file'] = template['file'];
+ args['mce_width'] = template['width'];
+ args['mce_height'] = template['height'];
+ tinyMCE.windowArgs = args;
- // Handle non regexp
- if (element_name == elmMatch) {
- elementAttribs = tinyMCE.cleanup_validElements[i];
- validElement = true;
- element_name = elementAttribs[0][0];
- break;
- }
- }
- }
+ html = template['html'];
+ if (!(width = parseInt(template['width'])))
+ width = 320;
- if (!validElement)
- return null;
- }
+ if (!(height = parseInt(template['height'])))
+ height = 200;
- if (element_name.charAt(0) == '+' || element_name.charAt(0) == '-')
- name = element_name.substring(1);
+ // Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!!
+ if (tinyMCE.isMSIE)
+ height += 40;
+ else
+ height += 20;
- // Special Mozilla stuff
- if (!tinyMCE.isMSIE) {
- // Fix for bug #958498
- if (name == "strong" && !tinyMCE.cleanup_on_save)
- element_name = "b";
- else if (name == "em" && !tinyMCE.cleanup_on_save)
- element_name = "i";
- }
+ x = parseInt(screen.width / 2.0) - (width / 2.0);
+ y = parseInt(screen.height / 2.0) - (height / 2.0);
- var elmData = new Object();
+ resizable = (args && args['resizable']) ? args['resizable'] : "no";
+ scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no";
- elmData.element_name = element_name;
- elmData.valid_attribs = elementAttribs;
+ if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1)
+ url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file'];
+ else
+ url = template['file'];
- return elmData;
-};
+ // Replace all args as variables in URL
+ for (var name in args) {
+ if (typeof(args[name]) == 'function')
+ continue;
+
+ url = tinyMCE.replaceVar(url, name, escape(args[name]));
+ }
-/**
- * This function moves CSS styles to/from attributes.
- */
-TinyMCE.prototype._moveStyle = function(elm, style, attrib) {
- if (tinyMCE.cleanup_inline_styles) {
- var val = tinyMCE.getAttrib(elm, attrib);
+ if (html) {
+ html = tinyMCE.replaceVar(html, "css", this.settings['popups_css']);
+ html = tinyMCE.applyTemplate(html, args);
- if (val != '') {
- val = '' + val;
+ var win = window.open("", "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,minimizable=" + resizable + ",modal=yes,width=" + width + ",height=" + height + ",resizable=" + resizable);
+ if (win == null) {
+ alert(tinyMCELang['lang_popup_blocked']);
+ return;
+ }
- switch (attrib) {
- case "background":
- val = "url('" + val + "')";
- break;
+ win.document.write(html);
+ win.document.close();
+ win.resizeTo(width, height);
+ win.focus();
+ } else {
+ if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && resizable != 'yes' && tinyMCE.settings["dialog_type"] == "modal") {
+ height += 10;
- case "bordercolor":
- if (elm.style.borderStyle == '' || elm.style.borderStyle == 'none')
- elm.style.borderStyle = 'solid';
- break;
+ var features = "resizable:" + resizable
+ + ";scroll:"
+ + scrollbars + ";status:yes;center:yes;help:no;dialogWidth:"
+ + width + "px;dialogHeight:" + height + "px;";
- case "border":
- case "width":
- case "height":
- if (attrib == "border" && elm.style.borderWidth > 0)
- return;
+ window.showModalDialog(url, window, features);
+ } else {
+ var modal = (resizable == "yes") ? "no" : "yes";
- if (val.indexOf('%') == -1)
- val += 'px';
- break;
+ if (tinyMCE.isGecko && tinyMCE.isMac)
+ modal = "no";
+
+ if (template['close_previous'] != "no")
+ try {tinyMCE.lastWindow.close();} catch (ex) {}
- case "vspace":
- case "hspace":
- elm.style.marginTop = val + "px";
- elm.style.marginBottom = val + "px";
- elm.removeAttribute(attrib);
+ var win = window.open(url, "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=" + modal + ",minimizable=" + resizable + ",modal=" + modal + ",width=" + width + ",height=" + height + ",resizable=" + resizable);
+ if (win == null) {
+ alert(tinyMCELang['lang_popup_blocked']);
return;
+ }
- case "align":
- if (elm.nodeName == "IMG") {
- if (tinyMCE.isMSIE)
- elm.style.styleFloat = val;
- else
- elm.style.cssFloat = val;
- } else
- elm.style.textAlign = val;
+ if (template['close_previous'] != "no")
+ tinyMCE.lastWindow = win;
- elm.removeAttribute(attrib);
- return;
- }
+ eval('try { win.resizeTo(width, height); } catch(e) { }');
- if (val != '') {
- eval('elm.style.' + style + ' = val;');
- elm.removeAttribute(attrib);
+ // Make it bigger if statusbar is forced
+ if (tinyMCE.isGecko) {
+ if (win.document.defaultView.statusbar.visible)
+ win.resizeBy(0, tinyMCE.isMac ? 10 : 24);
+ }
+
+ win.focus();
}
}
- } else {
- if (style == '')
+ },
+
+ closeWindow : function(win) {
+ win.close();
+ },
+
+ getVisualAidClass : function(class_name, state) {
+ var aidClass = tinyMCE.settings['visual_table_class'];
+
+ if (typeof(state) == "undefined")
+ state = tinyMCE.settings['visual'];
+
+ // Split
+ var classNames = new Array();
+ var ar = class_name.split(' ');
+ for (var i=0; i<ar.length; i++) {
+ if (ar[i] == aidClass)
+ ar[i] = "";
+
+ if (ar[i] != "")
+ classNames[classNames.length] = ar[i];
+ }
+
+ if (state)
+ classNames[classNames.length] = aidClass;
+
+ // Glue
+ var className = "";
+ for (var i=0; i<classNames.length; i++) {
+ if (i > 0)
+ className += " ";
+
+ className += classNames[i];
+ }
+
+ return className;
+ },
+
+ handleVisualAid : function(el, deep, state, inst) {
+ if (!el)
return;
- var val = eval('elm.style.' + style) == '' ? tinyMCE.getAttrib(elm, attrib) : eval('elm.style.' + style);
- val = val == null ? '' : '' + val;
+ var tableElement = null;
- switch (attrib) {
- // Always move background to style
- case "background":
- if (val.indexOf('url') == -1 && val != '')
- val = "url('" + val + "');";
+ switch (el.nodeName) {
+ case "TABLE":
+ var oldW = el.style.width;
+ var oldH = el.style.height;
+ var bo = tinyMCE.getAttrib(el, "border");
- if (val != '') {
- elm.style.backgroundImage = val;
- elm.removeAttribute(attrib);
- }
- return;
+ bo = bo == "" || bo == "0" ? true : false;
- case "border":
- case "width":
- case "height":
- val = val.replace('px', '');
- break;
+ tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo));
- case "align":
- if (tinyMCE.getAttrib(elm, 'align') == '') {
- if (elm.nodeName == "IMG") {
- if (tinyMCE.isMSIE && elm.style.styleFloat != '') {
- val = elm.style.styleFloat;
- style = 'styleFloat';
- } else if (tinyMCE.isGecko && elm.style.cssFloat != '') {
- val = elm.style.cssFloat;
- style = 'cssFloat';
- }
+ el.style.width = oldW;
+ el.style.height = oldH;
+
+ for (var y=0; y<el.rows.length; y++) {
+ for (var x=0; x<el.rows[y].cells.length; x++) {
+ var cn = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el.rows[y].cells[x], "class"), state && bo);
+ tinyMCE.setAttrib(el.rows[y].cells[x], "class", cn);
}
}
+
+ break;
+
+ case "A":
+ var anchorName = tinyMCE.getAttrib(el, "name");
+
+ if (anchorName != '' && state) {
+ el.title = anchorName;
+ el.className = 'mceItemAnchor';
+ } else if (anchorName != '' && !state)
+ el.className = '';
+
break;
}
- if (val != '') {
- elm.removeAttribute(attrib);
- elm.setAttribute(attrib, val);
- eval('elm.style.' + style + ' = "";');
+ if (deep && el.hasChildNodes()) {
+ for (var i=0; i<el.childNodes.length; i++)
+ tinyMCE.handleVisualAid(el.childNodes[i], deep, state, inst);
}
- }
-};
+ },
-TinyMCE.prototype._cleanupAttribute = function(valid_attributes, element_name, attribute_node, element_node) {
- var attribName = attribute_node.nodeName.toLowerCase();
- var attribValue = attribute_node.nodeValue;
- var attribMustBeValue = null;
- var verified = false;
+ /*
+ applyClassesToFonts : function(doc, size) {
+ var f = doc.getElementsByTagName("font");
+ for (var i=0; i<f.length; i++) {
+ var s = tinyMCE.getAttrib(f[i], "size");
- // Mozilla attibute, remove them
- if (attribName.indexOf('moz_') != -1)
- return null;
+ if (s != "")
+ tinyMCE.setAttrib(f[i], 'class', "mceItemFont" + s);
+ }
- if (!tinyMCE.cleanup_on_save && (attribName == "mce_href" || attribName == "mce_src"))
- return {name : attribName, value : attribValue};
-
- // Verify attrib
- if (tinyMCE.cleanup_verify_html && !verified) {
- for (var i=1; i<valid_attributes.length; i++) {
- var attribMatch = valid_attributes[i][0];
- var re = null;
-
- // Build regexp from wildcard
- if (attribMatch.match(new RegExp('\\*|\\?|\\+', 'g')) != null) {
- attribMatch = attribMatch.replace(new RegExp('\\?', 'g'), '(\\S?)');
- attribMatch = attribMatch.replace(new RegExp('\\+', 'g'), '(\\S+)');
- attribMatch = attribMatch.replace(new RegExp('\\*', 'g'), '(\\S*)');
- attribMatch = "^" + attribMatch + "$";
- re = new RegExp(attribMatch, 'g');
- }
+ if (typeof(size) != "undefined") {
+ var css = "";
- if ((re && attribName.match(re) != null) || attribName == attribMatch) {
- verified = true;
- attribMustBeValue = valid_attributes[i][3];
- break;
+ for (var x=0; x<doc.styleSheets.length; x++) {
+ for (var i=0; i<doc.styleSheets[x].rules.length; i++) {
+ if (doc.styleSheets[x].rules[i].selectorText == '#mceSpanFonts .mceItemFont' + size) {
+ css = doc.styleSheets[x].rules[i].style.cssText;
+ break;
+ }
+ }
+
+ if (css != "")
+ break;
}
- }
- if (!verified)
- return false;
- } else
- verified = true;
+ if (doc.styleSheets[0].rules[0].selectorText == "FONT")
+ doc.styleSheets[0].removeRule(0);
- // Treat some attribs diffrent
- switch (attribName) {
- case "size":
- if (tinyMCE.isMSIE5 && element_name == "font")
- attribValue = element_node.size;
- break;
+ doc.styleSheets[0].addRule("FONT", css, 0);
+ }
+ },
+ */
- case "width":
- case "height":
- case "border":
- // Old MSIE needs this
- if (tinyMCE.isMSIE5)
- attribValue = eval("element_node." + attribName);
- break;
+ fixGeckoBaseHREFBug : function(m, e, h) {
+ var nl, i;
- case "shape":
- attribValue = attribValue.toLowerCase();
- break;
+ if (tinyMCE.isGecko) {
+ if (m == 1) {
+ h = h.replace(/\ssrc=/gi, " xsrc=");
+ h = h.replace(/\shref=/gi, " xhref=");
- case "cellspacing":
- if (tinyMCE.isMSIE5)
- attribValue = element_node.cellSpacing;
- break;
+ return h;
+ } else {
+ var el = new Array('a','img','select','area','iframe','base','input','script','embed','object','link');
- case "cellpadding":
- if (tinyMCE.isMSIE5)
- attribValue = element_node.cellPadding;
- break;
+ for (var a=0; a<el.length; a++) {
+ var n = e.getElementsByTagName(el[a]);
- case "color":
- if (tinyMCE.isMSIE5 && element_name == "font")
- attribValue = element_node.color;
- break;
+ for (i=0; i<n.length; i++) {
+ var xsrc = tinyMCE.getAttrib(n[i], "xsrc");
+ var xhref = tinyMCE.getAttrib(n[i], "xhref");
- case "class":
- // Remove mceItem classes from anchors
- if (tinyMCE.cleanup_on_save && attribValue.indexOf('mceItemAnchor') != -1)
- attribValue = attribValue.replace(/mceItem[a-z0-9]+/gi, '');
+ if (xsrc != "") {
+ n[i].src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc);
+ n[i].removeAttribute("xsrc");
+ }
- if (element_name == "table" || element_name == "td" || element_name == "th") {
- // Handle visual aid
- if (tinyMCE.cleanup_visual_table_class != "")
- attribValue = tinyMCE.getVisualAidClass(attribValue, !tinyMCE.cleanup_on_save);
+ if (xhref != "") {
+ n[i].href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xhref);
+ n[i].removeAttribute("xhref");
+ }
+ }
+ }
}
+ }
- if (!tinyMCE._verifyClass(element_node) || attribValue == "")
- return null;
+ return h;
+ },
- break;
+ _setHTML : function(doc, html_content) {
+ // Force closed anchors open
+ //html_content = html_content.replace(new RegExp('<a(.*?)/>', 'gi'), '<a$1></a>');
- case "onfocus":
- case "onblur":
- case "onclick":
- case "ondblclick":
- case "onmousedown":
- case "onmouseup":
- case "onmouseover":
- case "onmousemove":
- case "onmouseout":
- case "onkeypress":
- case "onkeydown":
- case "onkeydown":
- case "onkeyup":
- attribValue = tinyMCE.cleanupEventStr("" + attribValue);
-
- if (attribValue.indexOf('return false;') == 0)
- attribValue = attribValue.substring(14);
+ html_content = tinyMCE.cleanupHTMLCode(html_content);
- break;
-
- case "style":
- attribValue = tinyMCE.serializeStyle(tinyMCE.parseStyle(tinyMCE.getAttrib(element_node, "style")));
- break;
+ // Try innerHTML if it fails use pasteHTML in MSIE
+ try {
+ tinyMCE.setInnerHTML(doc.body, html_content);
+ } catch (e) {
+ if (this.isMSIE)
+ doc.body.createTextRange().pasteHTML(html_content);
+ }
- // Convert the URLs of these
- case "href":
- case "src":
- case "longdesc":
- attribValue = tinyMCE.getAttrib(element_node, attribName);
+ // Content duplication bug fix
+ if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) {
+ // Remove P elements in P elements
+ var paras = doc.getElementsByTagName("P");
+ for (var i=0; i<paras.length; i++) {
+ var node = paras[i];
+ while ((node = node.parentNode) != null) {
+ if (node.nodeName == "P")
+ node.outerHTML = node.innerHTML;
+ }
+ }
- // Use mce_href instead
- var href = tinyMCE.getAttrib(element_node, "mce_href");
- if (attribName == "href" && href != "")
- attribValue = href;
+ // Content duplication bug fix (Seems to be word crap)
+ var html = doc.body.innerHTML;
+/*
+ if (html.indexOf('="mso') != -1) {
+ for (var i=0; i<doc.body.all.length; i++) {
+ var el = doc.body.all[i];
+ el.removeAttribute("className","",0);
+ el.removeAttribute("style","",0);
+ }
- // Use mce_src instead
- var src = tinyMCE.getAttrib(element_node, "mce_src");
- if (attribName == "src" && src != "")
- attribValue = src;
+ html = doc.body.innerHTML;
+ html = tinyMCE.regexpReplace(html, "<o:p><\/o:p>", "<br />");
+ html = tinyMCE.regexpReplace(html, "<o:p>&nbsp;<\/o:p>", "");
+ html = tinyMCE.regexpReplace(html, "<st1:.*?>", "");
+ html = tinyMCE.regexpReplace(html, "<p><\/p>", "");
+ html = tinyMCE.regexpReplace(html, "<p><\/p>\r\n<p><\/p>", "");
+ html = tinyMCE.regexpReplace(html, "<p>&nbsp;<\/p>", "<br />");
+ html = tinyMCE.regexpReplace(html, "<p>\s*(<p>\s*)?", "<p>");
+ html = tinyMCE.regexpReplace(html, "<\/p>\s*(<\/p>\s*)?", "</p>");
+ }*/
- // Always use absolute URLs within TinyMCE
- if (!tinyMCE.cleanup_on_save)
- attribValue = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], attribValue);
- else if (tinyMCE.getParam('convert_urls'))
- attribValue = eval(tinyMCE.cleanup_urlconverter_callback + "(attribValue, element_node, tinyMCE.cleanup_on_save);");
+ // Always set the htmlText output
+ tinyMCE.setInnerHTML(doc.body, html);
+ }
- break;
+ tinyMCE.cleanupAnchors(doc);
- case "colspan":
- case "rowspan":
- // Not needed
- if (attribValue == "1")
- return null;
- break;
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertSpansToFonts(doc);
+ },
- // Skip these
- case "_moz-userdefined":
- case "editorid":
- case "mce_href":
- case "mce_src":
+ getEditorId : function(form_element) {
+ var inst = this.getInstanceById(form_element);
+ if (!inst)
return null;
- }
- // Not the must be value
- if (attribMustBeValue != null) {
- var isCorrect = false;
- for (var i=0; i<attribMustBeValue.length; i++) {
- if (attribValue == attribMustBeValue[i]) {
- isCorrect = true;
- break;
+ return inst.editorId;
+ },
+
+ getInstanceById : function(editor_id) {
+ var inst = this.instances[editor_id];
+ if (!inst) {
+ for (var n in tinyMCE.instances) {
+ var instance = tinyMCE.instances[n];
+ if (!tinyMCE.isInstance(instance))
+ continue;
+
+ if (instance.formTargetElementId == editor_id) {
+ inst = instance;
+ break;
+ }
}
}
- if (!isCorrect)
- return null;
- }
+ return inst;
+ },
- var attrib = new Object();
+ queryInstanceCommandValue : function(editor_id, command) {
+ var inst = tinyMCE.getInstanceById(editor_id);
+ if (inst)
+ return inst.queryCommandValue(command);
- attrib.name = attribName;
- attrib.value = attribValue;
+ return false;
+ },
- return attrib;
-};
+ queryInstanceCommandState : function(editor_id, command) {
+ var inst = tinyMCE.getInstanceById(editor_id);
+ if (inst)
+ return inst.queryCommandState(command);
-TinyMCE.prototype.clearArray = function(ar) {
- // Since stupid people tend to extend core objects like
- // Array with their own crap I needed to make functions that clean away
- // this junk so the arrays get clean and nice as they should be
- for (var key in ar)
- ar[key] = null;
-};
+ return null;
+ },
-TinyMCE.prototype.isInstance = function(inst) {
- return inst != null && typeof(inst) == "object" && inst.isTinyMCEControl;
-};
+ setWindowArg : function(n, v) {
+ this.windowArgs[n] = v;
+ },
-TinyMCE.prototype.parseStyle = function(str) {
- var ar = new Array();
+ getWindowArg : function(n, d) {
+ return (typeof(this.windowArgs[n]) == "undefined") ? d : this.windowArgs[n];
+ },
- if (str == null)
- return ar;
+ getCSSClasses : function(editor_id, doc) {
+ var output = new Array();
- var st = str.split(';');
+ // Is cached, use that
+ if (typeof(tinyMCE.cssClasses) != "undefined")
+ return tinyMCE.cssClasses;
- tinyMCE.clearArray(ar);
+ if (typeof(editor_id) == "undefined" && typeof(doc) == "undefined") {
+ var instance;
- for (var i=0; i<st.length; i++) {
- if (st[i] == '')
- continue;
+ for (var instanceName in tinyMCE.instances) {
+ instance = tinyMCE.instances[instanceName];
+ if (!tinyMCE.isInstance(instance))
+ continue;
- var re = new RegExp('^\\s*([^:]*):\\s*(.*)\\s*$');
- var pa = st[i].replace(re, '$1||$2').split('||');
-//tinyMCE.debug(str, pa[0] + "=" + pa[1], st[i].replace(re, '$1||$2'));
- if (pa.length == 2)
- ar[pa[0].toLowerCase()] = pa[1];
- }
+ break;
+ }
- return ar;
-};
+ doc = instance.getDoc();
+ }
-TinyMCE.prototype.compressStyle = function(ar, pr, sf, res) {
- var box = new Array();
+ if (typeof(doc) == "undefined") {
+ var instance = tinyMCE.getInstanceById(editor_id);
+ doc = instance.getDoc();
+ }
- box[0] = ar[pr + '-top' + sf];
- box[1] = ar[pr + '-left' + sf];
- box[2] = ar[pr + '-right' + sf];
- box[3] = ar[pr + '-bottom' + sf];
+ if (doc) {
+ var styles = tinyMCE.isMSIE ? doc.styleSheets : doc.styleSheets;
+
+ if (styles && styles.length > 0) {
+ for (var x=0; x<styles.length; x++) {
+ var csses = null;
+
+ // Just ignore any errors
+ eval("try {var csses = tinyMCE.isMSIE ? doc.styleSheets(" + x + ").rules : doc.styleSheets[" + x + "].cssRules;} catch(e) {}");
+ if (!csses)
+ return new Array();
+
+ for (var i=0; i<csses.length; i++) {
+ var selectorText = csses[i].selectorText;
+
+ // Can be multiple rules per selector
+ if (selectorText) {
+ var rules = selectorText.split(',');
+ for (var c=0; c<rules.length; c++) {
+ // Invalid rule
+ if (rules[c].indexOf(' ') != -1 || rules[c].indexOf(':') != -1 || rules[c].indexOf('mceItem') != -1)
+ continue;
+
+ if (rules[c] == "." + tinyMCE.settings['visual_table_class'] || rules[c].indexOf('mceEditable') != -1 || rules[c].indexOf('mceNonEditable') != -1)
+ continue;
+
+ // Is class rule
+ if (rules[c].indexOf('.') != -1) {
+ //alert(rules[c].substring(rules[c].indexOf('.')));
+ output[output.length] = rules[c].substring(rules[c].indexOf('.')+1);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
- for (var i=0; i<box.length; i++) {
- if (box[i] == null)
- return;
+ // Cache em
+ if (output.length > 0)
+ tinyMCE.cssClasses = output;
- for (var a=0; a<box.length; a++) {
- if (box[a] != box[i])
- return;
- }
- }
+ return output;
+ },
- // They are all the same
- ar[res] = box[0];
- ar[pr + '-top' + sf] = null;
- ar[pr + '-left' + sf] = null;
- ar[pr + '-right' + sf] = null;
- ar[pr + '-bottom' + sf] = null;
-};
+ regexpReplace : function(in_str, reg_exp, replace_str, opts) {
+ if (in_str == null)
+ return in_str;
-TinyMCE.prototype.serializeStyle = function(ar) {
- var str = "";
+ if (typeof(opts) == "undefined")
+ opts = 'g';
- // Compress box
- tinyMCE.compressStyle(ar, "border", "", "border");
- tinyMCE.compressStyle(ar, "border", "-width", "border-width");
- tinyMCE.compressStyle(ar, "border", "-color", "border-color");
+ var re = new RegExp(reg_exp, opts);
+ return in_str.replace(re, replace_str);
+ },
- for (var key in ar) {
- var val = ar[key];
- if (typeof(val) == 'function')
- continue;
+ trim : function(s) {
+ return s.replace(/^\s*|\s*$/g, "");
+ },
- if (val != null && val != '') {
- val = '' + val; // Force string
+ cleanupEventStr : function(s) {
+ s = "" + s;
+ s = s.replace('function anonymous()\n{\n', '');
+ s = s.replace('\n}', '');
+ s = s.replace(/^return true;/gi, ''); // Remove event blocker
- // Fix style URL
- val = val.replace(new RegExp("url\\(\\'?([^\\']*)\\'?\\)", 'gi'), "url('$1')");
+ return s;
+ },
- // Convert URL
- if (val.indexOf('url(') != -1 && tinyMCE.getParam('convert_urls')) {
- var m = new RegExp("url\\('(.*?)'\\)").exec(val);
+ getControlHTML : function(c) {
+ var i, l, n, o, v;
- if (m.length > 1)
- val = "url('" + eval(tinyMCE.getParam('urlconverter_callback') + "(m[1], null, true);") + "')";
- }
+ l = tinyMCE.plugins;
+ for (n in l) {
+ o = l[n];
- // Force HEX colors
- if (tinyMCE.getParam("force_hex_style_colors"))
- val = tinyMCE.convertRGBToHex(val, true);
+ if (o.getControlHTML && (v = o.getControlHTML(c)) != '')
+ return tinyMCE.replaceVar(v, "pluginurl", o.baseURL);
+ }
- if (val != "url('')")
- str += key.toLowerCase() + ": " + val + "; ";
+ o = tinyMCE.themes[tinyMCE.settings['theme']];
+ if (o.getControlHTML && (v = o.getControlHTML(c)) != '')
+ return v;
+
+ return '';
+ },
+
+ evalFunc : function(f, idx, a) {
+ var s = '(', i;
+
+ for (i=idx; i<a.length; i++) {
+ s += 'a[' + i + ']';
+
+ if (i < a.length-1)
+ s += ',';
}
- }
- if (new RegExp('; $').test(str))
- str = str.substring(0, str.length - 2);
+ s += ');';
- return str;
-};
+ return eval("f" + s);
+ },
-TinyMCE.prototype.convertRGBToHex = function(s, k) {
- if (s.toLowerCase().indexOf('rgb') != -1) {
- var re = new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)", "gi");
- var rgb = s.replace(re, "$1,$2,$3,$4,$5").split(',');
- if (rgb.length == 5) {
- r = parseInt(rgb[1]).toString(16);
- g = parseInt(rgb[2]).toString(16);
- b = parseInt(rgb[3]).toString(16);
+ dispatchCallback : function(i, p, n) {
+ return this.callFunc(i, p, n, 0, this.dispatchCallback.arguments);
+ },
- r = r.length == 1 ? '0' + r : r;
- g = g.length == 1 ? '0' + g : g;
- b = b.length == 1 ? '0' + b : b;
+ executeCallback : function(i, p, n) {
+ return this.callFunc(i, p, n, 1, this.executeCallback.arguments);
+ },
- s = "#" + r + g + b;
+ execCommandCallback : function(i, p, n) {
+ return this.callFunc(i, p, n, 2, this.execCommandCallback.arguments);
+ },
- if (k)
- s = rgb[0] + s + rgb[4];
- }
- }
+ callFunc : function(ins, p, n, m, a) {
+ var l, i, on, o, s, v;
- return s;
-};
+ s = m == 2;
-TinyMCE.prototype.convertHexToRGB = function(s) {
- if (s.indexOf('#') != -1) {
- s = s.replace(new RegExp('[^0-9A-F]', 'gi'), '');
- return "rgb(" + parseInt(s.substring(0, 2), 16) + "," + parseInt(s.substring(2, 4), 16) + "," + parseInt(s.substring(4, 6), 16) + ")";
- }
+ l = tinyMCE.getParam(p, '');
- return s;
-};
+ if (l != '' && (v = tinyMCE.evalFunc(typeof(l) == "function" ? l : eval(l), 3, a)) == s && m > 0)
+ return true;
-TinyMCE.prototype._verifyClass = function(node) {
- // Sometimes the class gets set to null, weird Gecko bug?
- if (tinyMCE.isGecko) {
- var className = node.getAttribute('class');
- if (!className)
- return false;
- }
+ if (ins != null) {
+ for (i=0, l = ins.plugins; i<l.length; i++) {
+ o = tinyMCE.plugins[l[i]];
- // Trim CSS class
- if (tinyMCE.isMSIE)
- var className = node.getAttribute('className');
-
- if (tinyMCE.cleanup_verify_css_classes && tinyMCE.cleanup_on_save) {
- var csses = tinyMCE.getCSSClasses();
- nonDefinedCSS = true;
- for (var c=0; c<csses.length; c++) {
- if (csses[c] == className) {
- nonDefinedCSS = false;
- break;
+ if (o[n] && (v = tinyMCE.evalFunc(o[n], 3, a)) == s && m > 0)
+ return true;
}
}
- if (nonDefinedCSS && className.indexOf('mce_') != 0) {
- node.removeAttribute('className');
- node.removeAttribute('class');
- return false;
+ l = tinyMCE.themes;
+ for (on in l) {
+ o = l[on];
+
+ if (o[n] && (v = tinyMCE.evalFunc(o[n], 3, a)) == s && m > 0)
+ return true;
}
- }
- return true;
-};
+ return false;
+ },
-TinyMCE.prototype.cleanupNode = function(node) {
- var output = "";
+ xmlEncode : function(s) {
+ s = "" + s;
+ s = s.replace(/&/g, '&amp;');
+ s = s.replace(new RegExp('"', 'g'), '&quot;');
+ s = s.replace(/\'/g, '&#39;'); // &apos; is not working in MSIE
+ s = s.replace(/</g, '&lt;');
+ s = s.replace(/>/g, '&gt;');
- switch (node.nodeType) {
- case 1: // Element
- var elementData = tinyMCE._cleanupElementName(node.nodeName, node);
- var elementName = elementData ? elementData.element_name : null;
- var elementValidAttribs = elementData ? elementData.valid_attribs : null;
- var elementAttribs = "";
- var openTag = false, nonEmptyTag = false;
+ return s;
+ },
- if (elementName != null && elementName.charAt(0) == '+') {
- elementName = elementName.substring(1);
- openTag = true;
- }
+ extend : function(p, np) {
+ var o = {};
- if (elementName != null && elementName.charAt(0) == '-') {
- elementName = elementName.substring(1);
- nonEmptyTag = true;
- }
+ o.parent = p;
- // Checking DOM tree for MSIE weirdness!!
- if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) {
- var lookup = tinyMCE.cleanup_elementLookupTable;
+ for (n in p)
+ o[n] = p[n];
- for (var i=0; i<lookup.length; i++) {
- // Found element reference else were, hmm?
- if (lookup[i] == node)
- return output;
- }
+ for (n in np)
+ o[n] = np[n];
- // Add element to lookup table
- lookup[lookup.length] = node;
- }
+ return o;
+ },
- // Element not valid (only render children)
- if (!elementName) {
- if (node.hasChildNodes()) {
- for (var i=0; i<node.childNodes.length; i++)
- output += this.cleanupNode(node.childNodes[i]);
- }
+ hideMenus : function() {
+ var e = tinyMCE.lastSelectedMenuBtn;
- return output;
- }
+ if (tinyMCE.lastMenu) {
+ tinyMCE.lastMenu.hide();
+ tinyMCE.lastMenu = null;
+ }
- if (tinyMCE.cleanup_on_save) {
- if (node.nodeName == "A" && node.className == "mceItemAnchor") {
- if (node.hasChildNodes()) {
- for (var i=0; i<node.childNodes.length; i++)
- output += this.cleanupNode(node.childNodes[i]);
- }
+ if (e) {
+ tinyMCE.switchClass(e, tinyMCE.lastMenuBtnClass);
+ tinyMCE.lastSelectedMenuBtn = null;
+ }
+ }
+};
- return '<a name="' + this.convertStringToXML(node.getAttribute("name")) + '"></a>' + output;
- }
- }
+// Global instances
+var TinyMCE = TinyMCE_Engine; // Compatiblity with gzip compressors
+var tinyMCE = new TinyMCE_Engine();
+var tinyMCELang = {};
- // Remove deprecated attributes
- var re = new RegExp("^(TABLE|TD|TR)$");
- if (re.test(node.nodeName)) {
- // Move attrib to style
- if ((node.nodeName != "TABLE" || tinyMCE.cleanup_inline_styles) && (width = tinyMCE.getAttrib(node, "width")) != '') {
- node.style.width = width.indexOf('%') != -1 ? width : width.replace(/[^0-9]/gi, '') + "px";
- node.removeAttribute("width");
- }
+/* file:jscripts/tiny_mce/classes/TinyMCE_Control.class.js */
- // Is table and not inline
- if ((node.nodeName == "TABLE" && !tinyMCE.cleanup_inline_styles) && node.style.width != '') {
- tinyMCE.setAttrib(node, "width", node.style.width.replace('px',''));
- node.style.width = '';
- }
+function TinyMCE_Control(settings) {
+ var t, i, to, fu, p, x, fn, fu, pn, s = settings;
- // Move attrib to style
- if ((height = tinyMCE.getAttrib(node, "height")) != '') {
- height = "" + height; // Force string
- node.style.height = height.indexOf('%') != -1 ? height : height.replace(/[^0-9]/gi, '') + "px";
- node.removeAttribute("height");
- }
- }
+ this.undoRedoLevel = true;
+ this.isTinyMCE_Control = true;
- // Handle inline/outline styles
- if (tinyMCE.cleanup_inline_styles) {
- var re = new RegExp("^(TABLE|TD|TR|IMG|HR)$");
- if (re.test(node.nodeName) && tinyMCE.getAttrib(node, "class").indexOf('mceItem') == -1) {
- tinyMCE._moveStyle(node, 'width', 'width');
- tinyMCE._moveStyle(node, 'height', 'height');
- tinyMCE._moveStyle(node, 'borderWidth', 'border');
- tinyMCE._moveStyle(node, '', 'vspace');
- tinyMCE._moveStyle(node, '', 'hspace');
- tinyMCE._moveStyle(node, 'textAlign', 'align');
- tinyMCE._moveStyle(node, 'backgroundColor', 'bgColor');
- tinyMCE._moveStyle(node, 'borderColor', 'borderColor');
- tinyMCE._moveStyle(node, 'backgroundImage', 'background');
-
- // Refresh element in old MSIE
- if (tinyMCE.isMSIE5)
- node.outerHTML = node.outerHTML;
- } else if (tinyMCE.isBlockElement(node))
- tinyMCE._moveStyle(node, 'textAlign', 'align');
-
- if (node.nodeName == "FONT")
- tinyMCE._moveStyle(node, 'color', 'color');
- }
+ // Default settings
+ this.settings = s;
+ this.settings['theme'] = tinyMCE.getParam("theme", "default");
+ this.settings['width'] = tinyMCE.getParam("width", -1);
+ this.settings['height'] = tinyMCE.getParam("height", -1);
+ this.selection = new TinyMCE_Selection(this);
+ this.undoRedo = new TinyMCE_UndoRedo(this);
+ this.cleanup = new TinyMCE_Cleanup();
+ this.shortcuts = new Array();
+ this.hasMouseMoved = false;
+
+ this.cleanup.init({
+ valid_elements : s.valid_elements,
+ extended_valid_elements : s.extended_valid_elements,
+ entities : s.entities,
+ entity_encoding : s.entity_encoding,
+ debug : s.cleanup_debug,
+ url_converter : 'TinyMCE_Cleanup.prototype._urlConverter',
+ indent : s.apply_source_formatting,
+ invalid_elements : s.invalid_elements,
+ verify_html : s.verify_html,
+ fix_content_duplication : s.fix_content_duplication
+ });
+
+ // Wrap old theme
+ t = this.settings['theme'];
+ if (!tinyMCE.hasTheme(t)) {
+ fn = tinyMCE.callbacks;
+ to = {};
+
+ for (i=0; i<fn.length; i++) {
+ if ((fu = window['TinyMCE_' + t + "_" + fn[i]]))
+ to[fn[i]] = fu;
+ }
- // Set attrib data
- if (elementValidAttribs) {
- for (var a=1; a<elementValidAttribs.length; a++) {
- var attribName, attribDefaultValue, attribForceValue, attribValue;
+ tinyMCE.addTheme(t, to);
+ }
- attribName = elementValidAttribs[a][0];
- attribDefaultValue = elementValidAttribs[a][1];
- attribForceValue = elementValidAttribs[a][2];
+ // Wrap old plugins
+ this.plugins = new Array();
+ p = tinyMCE.getParam('plugins', '', true, ',');
+ if (p.length > 0) {
+ for (i=0; i<p.length; i++) {
+ pn = p[i];
- if (attribDefaultValue != null || attribForceValue != null) {
- var attribValue = node.getAttribute(attribName);
+ if (pn.charAt(0) == '-')
+ pn = pn.substring(1);
- if (node.getAttribute(attribName) == null || node.getAttribute(attribName) == "")
- attribValue = attribDefaultValue;
+ if (!tinyMCE.hasPlugin(pn)) {
+ fn = tinyMCE.callbacks;
+ to = {};
- attribValue = attribForceValue ? attribForceValue : attribValue;
+ for (x=0; x<fn.length; x++) {
+ if ((fu = window['TinyMCE_' + pn + "_" + fn[x]]))
+ to[fn[x]] = fu;
+ }
- // Is to generate id
- if (attribValue == "{$uid}")
- attribValue = "uid_" + (tinyMCE.cleanup_idCount++);
+ tinyMCE.addPlugin(pn, to);
+ }
- // Add visual aid class
- if (attribName == "class")
- attribValue = tinyMCE.getVisualAidClass(attribValue, tinyMCE.cleanup_on_save);
+ this.plugins[this.plugins.length] = pn;
+ }
+ }
+};
- node.setAttribute(attribName, attribValue);
- //alert(attribName + "=" + attribValue);
- }
- }
- }
+TinyMCE_Control.prototype = {
+ hasPlugin : function(n) {
+ var i;
- if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && elementName == "style")
- return "<style>" + node.innerHTML + "</style>";
+ for (i=0; i<this.plugins.length; i++) {
+ if (this.plugins[i] == n)
+ return true;
+ }
- // Remove empty tables
- if (elementName == "table" && !node.hasChildNodes())
- return "";
+ return false;
+ },
- // Handle element attributes
- if (node.attributes.length > 0) {
- var lastAttrib = "";
+ addPlugin : function(n, p) {
+ if (!this.hasPlugin(n)) {
+ tinyMCE.addPlugin(n, p);
+ this.plugins[this.plugins.length] = n;
+ }
+ },
- for (var i=0; i<node.attributes.length; i++) {
- if (node.attributes[i].specified) {
- // Is the attrib already processed (removed duplicate attributes in opera TD[align=left])
- if (tinyMCE.isOpera) {
- if (node.attributes[i].nodeName == lastAttrib)
- continue;
+ repaint : function() {
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ return;
- lastAttrib = node.attributes[i].nodeName;
- }
+ try {
+ var s = this.selection;
+ var b = s.getBookmark(true);
+ this.getBody().style.display = 'none';
+ this.getDoc().execCommand('selectall', false, null);
+ this.getSel().collapseToStart();
+ this.getBody().style.display = 'block';
+ s.moveToBookmark(b);
+ } catch (ex) {
+ // Ignore
+ }
+ },
- // tinyMCE.debug(node.nodeName, node.attributes[i].nodeName, node.attributes[i].nodeValue, node.innerHTML);
- var attrib = tinyMCE._cleanupAttribute(elementValidAttribs, elementName, node.attributes[i], node);
- if (attrib && attrib.value != "")
- elementAttribs += " " + attrib.name + "=" + '"' + this.convertStringToXML("" + attrib.value) + '"';
- }
- }
- }
+ switchSettings : function() {
+ if (tinyMCE.configs.length > 1 && tinyMCE.currentConfig != this.settings['index']) {
+ tinyMCE.settings = this.settings;
+ tinyMCE.currentConfig = this.settings['index'];
+ }
+ },
- // MSIE table summary fix (MSIE 5.5)
- if (tinyMCE.isMSIE && elementName == "table" && node.getAttribute("summary") != null && elementAttribs.indexOf('summary') == -1) {
- var summary = tinyMCE.getAttrib(node, 'summary');
- if (summary != '')
- elementAttribs += " summary=" + '"' + this.convertStringToXML(summary) + '"';
- }
+ getBody : function() {
+ return this.getDoc().body;
+ },
- // Handle missing attributes in MSIE 5.5
- if (tinyMCE.isMSIE5 && /^(td|img|a)$/.test(elementName)) {
- var ma = new Array("scope", "longdesc", "hreflang", "charset", "type");
+ getDoc : function() {
+ return this.contentWindow.document;
+ },
- for (var u=0; u<ma.length; u++) {
- if (node.getAttribute(ma[u]) != null) {
- var s = tinyMCE.getAttrib(node, ma[u]);
+ getWin : function() {
+ return this.contentWindow;
+ },
- if (s != '')
- elementAttribs += " " + ma[u] + "=" + '"' + this.convertStringToXML(s) + '"';
- }
- }
- }
+ addShortcut : function(m, k, d, cmd, ui, va) {
+ var n = typeof(k) == "number", ie = tinyMCE.isMSIE, c, sc, i;
+ var scl = this.shortcuts;
- // MSIE form element issue
- if (tinyMCE.isMSIE && elementName == "input") {
- if (node.type) {
- if (!elementAttribs.match(/ type=/g))
- elementAttribs += " type=" + '"' + node.type + '"';
- }
+ if (!tinyMCE.getParam('custom_shortcuts'))
+ return false;
- if (node.value) {
- if (!elementAttribs.match(/ value=/g))
- elementAttribs += " value=" + '"' + node.value + '"';
- }
+ m = m.toLowerCase();
+ k = ie && !n ? k.toUpperCase() : k;
+ c = n ? null : k.charCodeAt(0);
+ d = d && d.indexOf('lang_') == 0 ? tinyMCE.getLang(d) : d;
+
+ sc = {
+ alt : m.indexOf('alt') != -1,
+ ctrl : m.indexOf('ctrl') != -1,
+ shift : m.indexOf('shift') != -1,
+ charCode : c,
+ keyCode : n ? k : (ie ? c : null),
+ desc : d,
+ cmd : cmd,
+ ui : ui,
+ val : va
+ };
+
+ for (i=0; i<scl.length; i++) {
+ if (sc.alt == scl[i].alt && sc.ctrl == scl[i].ctrl && sc.shift == scl[i].shift
+ && sc.charCode == scl[i].charCode && sc.keyCode == scl[i].keyCode) {
+ return false;
}
+ }
- // Add nbsp to some elements
- if ((elementName == "p" || elementName == "td") && (node.innerHTML == "" || node.innerHTML == "&nbsp;"))
- return "<" + elementName + elementAttribs + ">" + this.convertStringToXML(String.fromCharCode(160)) + "</" + elementName + ">";
-
- // Is MSIE script element
- if (tinyMCE.isMSIE && elementName == "script")
- return "<" + elementName + elementAttribs + ">" + node.text + "</" + elementName + ">";
-
- // Clean up children
- if (node.hasChildNodes()) {
- // If not empty span
- if (!(elementName == "span" && elementAttribs == "" && tinyMCE.getParam("trim_span_elements"))) {
- // Force BR
- if (elementName == "p" && tinyMCE.cleanup_force_br_newlines)
- output += "<div" + elementAttribs + ">";
- else
- output += "<" + elementName + elementAttribs + ">";
- }
+ scl[scl.length] = sc;
- for (var i=0; i<node.childNodes.length; i++)
- output += this.cleanupNode(node.childNodes[i]);
+ return true;
+ },
- // If not empty span
- if (!(elementName == "span" && elementAttribs == "" && tinyMCE.getParam("trim_span_elements"))) {
- // Force BR
- if (elementName == "p" && tinyMCE.cleanup_force_br_newlines)
- output += "</div><br />";
- else
- output += "</" + elementName + ">";
- }
- } else {
- if (!nonEmptyTag) {
- if (openTag)
- output += "<" + elementName + elementAttribs + "></" + elementName + ">";
- else
- output += "<" + elementName + elementAttribs + " />";
- }
- }
+ handleShortcut : function(e) {
+ var i, s = this.shortcuts, o;
- return output;
+ for (i=0; i<s.length; i++) {
+ o = s[i];
+ if (o.alt == e.altKey && o.ctrl == e.ctrlKey && (o.keyCode == e.keyCode || o.charCode == e.charCode)) {
+ if (o.cmd && (e.type == "keydown" || (e.type == "keypress" && !tinyMCE.isOpera)))
+ tinyMCE.execCommand(o.cmd, o.ui, o.val);
- case 3: // Text
- // Do not convert script elements
- if (node.parentNode.nodeName == "SCRIPT" || node.parentNode.nodeName == "NOSCRIPT" || node.parentNode.nodeName == "STYLE")
- return node.nodeValue;
+ tinyMCE.cancelEvent(e);
+ return true;
+ }
+ }
- return this.convertStringToXML(node.nodeValue);
+ return false;
+ },
- case 8: // Comment
- return "<!--" + node.nodeValue + "-->";
+ autoResetDesignMode : function() {
+ // Add fix for tab/style.display none/block problems in Gecko
+ if (!tinyMCE.isMSIE && this.isHidden() && tinyMCE.getParam('auto_reset_designmode'))
+ eval('try { this.getDoc().designMode = "On"; } catch(e) {}');
+ },
- default: // Unknown
- return "[UNKNOWN NODETYPE " + node.nodeType + "]";
- }
-};
+ isHidden : function() {
+ if (tinyMCE.isMSIE)
+ return false;
-TinyMCE.prototype.convertStringToXML = function(html_data) {
- var output = "";
+ var s = this.getSel();
- for (var i=0; i<html_data.length; i++) {
- var chr = html_data.charCodeAt(i);
+ // Weird, wheres that cursor selection?
+ return (!s || !s.rangeCount || s.rangeCount == 0);
+ },
- // Numeric entities
- if (tinyMCE.settings['entity_encoding'] == "numeric") {
- if (chr > 127)
- output += '&#' + chr + ";";
- else
- output += String.fromCharCode(chr);
+ isDirty : function() {
+ // Is content modified and not in a submit procedure
+ return this.startContent != tinyMCE.trim(this.getBody().innerHTML) && !tinyMCE.isNotDirty;
+ },
- continue;
+ _mergeElements : function(scmd, pa, ch, override) {
+ if (scmd == "removeformat") {
+ pa.className = "";
+ pa.style.cssText = "";
+ ch.className = "";
+ ch.style.cssText = "";
+ return;
}
- // Raw entities
- if (tinyMCE.settings['entity_encoding'] == "raw") {
- output += String.fromCharCode(chr);
- continue;
+ var st = tinyMCE.parseStyle(tinyMCE.getAttrib(pa, "style"));
+ var stc = tinyMCE.parseStyle(tinyMCE.getAttrib(ch, "style"));
+ var className = tinyMCE.getAttrib(pa, "class");
+
+ className += " " + tinyMCE.getAttrib(ch, "class");
+
+ if (override) {
+ for (var n in st) {
+ if (typeof(st[n]) == 'function')
+ continue;
+
+ stc[n] = st[n];
+ }
+ } else {
+ for (var n in stc) {
+ if (typeof(stc[n]) == 'function')
+ continue;
+
+ st[n] = stc[n];
+ }
}
- // Named entities
- if (typeof(tinyMCE.settings['cleanup_entities']["c" + chr]) != 'undefined' && tinyMCE.settings['cleanup_entities']["c" + chr] != '')
- output += '&' + tinyMCE.settings['cleanup_entities']["c" + chr] + ';';
- else
- output += '' + String.fromCharCode(chr);
- }
+ tinyMCE.setAttrib(pa, "style", tinyMCE.serializeStyle(st));
+ tinyMCE.setAttrib(pa, "class", tinyMCE.trim(className));
+ ch.className = "";
+ ch.style.cssText = "";
+ ch.removeAttribute("class");
+ ch.removeAttribute("style");
+ },
- return output;
-};
+ _setUseCSS : function(b) {
+ var d = this.getDoc();
-TinyMCE.prototype._getCleanupElementName = function(chunk) {
- var pos;
+ try {d.execCommand("useCSS", false, !b);} catch (ex) {}
+ try {d.execCommand("styleWithCSS", false, b);} catch (ex) {}
- if (chunk.charAt(0) == '+')
- chunk = chunk.substring(1);
+ if (!tinyMCE.getParam("table_inline_editing"))
+ try {d.execCommand('enableInlineTableEditing', false, "false");} catch (ex) {}
- if (chunk.charAt(0) == '-')
- chunk = chunk.substring(1);
+ if (!tinyMCE.getParam("object_resizing"))
+ try {d.execCommand('enableObjectResizing', false, "false");} catch (ex) {}
+ },
- if ((pos = chunk.indexOf('/')) != -1)
- chunk = chunk.substring(0, pos);
+ execCommand : function(command, user_interface, value) {
+ var doc = this.getDoc();
+ var win = this.getWin();
+ var focusElm = this.getFocusElement();
- if ((pos = chunk.indexOf('[')) != -1)
- chunk = chunk.substring(0, pos);
+ // Is non udno specific command
+ if (!new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command))
+ this.undoBookmark = null;
- return chunk;
-};
+ if (this.lastSafariSelection && !new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command)) {
+ this.selection.moveToBookmark(this.lastSafariSelection);
+ tinyMCE.selectedElement = this.lastSafariSelectedElement;
+ }
-TinyMCE.prototype._initCleanup = function() {
- // Parse valid elements and attributes
- var validElements = tinyMCE.settings["valid_elements"];
- validElements = validElements.split(',');
-
- // Handle extended valid elements
- var extendedValidElements = tinyMCE.settings["extended_valid_elements"];
- extendedValidElements = extendedValidElements.split(',');
- for (var i=0; i<extendedValidElements.length; i++) {
- var elementName = this._getCleanupElementName(extendedValidElements[i]);
- var skipAdd = false;
-
- // Check if it's defined before, if so override that one
- for (var x=0; x<validElements.length; x++) {
- if (this._getCleanupElementName(validElements[x]) == elementName) {
- validElements[x] = extendedValidElements[i];
- skipAdd = true;
- break;
- }
+ // Mozilla issue
+ if (!tinyMCE.isMSIE && !this.useCSS) {
+ this._setUseCSS(false);
+ this.useCSS = true;
}
- if (!skipAdd)
- validElements[validElements.length] = extendedValidElements[i];
- }
+ //debug("command: " + command + ", user_interface: " + user_interface + ", value: " + value);
+ this.contentDocument = doc; // <-- Strange, unless this is applied Mozilla 1.3 breaks
- for (var i=0; i<validElements.length; i++) {
- var item = validElements[i];
+ if (tinyMCE.execCommandCallback(this, 'execcommand_callback', 'execCommand', this.editorId, this.getBody(), command, user_interface, value))
+ return;
- item = item.replace('[','|');
- item = item.replace(']','');
+ // Fix align on images
+ if (focusElm && focusElm.nodeName == "IMG") {
+ var align = focusElm.getAttribute('align');
+ var img = command == "JustifyCenter" ? focusElm.cloneNode(false) : focusElm;
- // Split and convert
- var attribs = item.split('|');
- for (var x=0; x<attribs.length; x++)
- attribs[x] = attribs[x].toLowerCase();
+ switch (command) {
+ case "JustifyLeft":
+ if (align == 'left')
+ img.removeAttribute('align');
+ else
+ img.setAttribute('align', 'left');
- // Handle change elements
- attribs[0] = attribs[0].split('/');
+ // Remove the div
+ var div = focusElm.parentNode;
+ if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)
+ div.parentNode.replaceChild(img, div);
- // Handle default attribute values
- for (var x=1; x<attribs.length; x++) {
- var attribName = attribs[x];
- var attribDefault = null;
- var attribForce = null;
- var attribMustBe = null;
+ this.selection.selectNode(img);
+ this.repaint();
+ tinyMCE.triggerNodeChange();
+ return;
- // Default value
- if ((pos = attribName.indexOf('=')) != -1) {
- attribDefault = attribName.substring(pos+1);
- attribName = attribName.substring(0, pos);
- }
+ case "JustifyCenter":
+ img.removeAttribute('align');
- // Force check
- if ((pos = attribName.indexOf(':')) != -1) {
- attribForce = attribName.substring(pos+1);
- attribName = attribName.substring(0, pos);
- }
+ // Is centered
+ var div = tinyMCE.getParentElement(focusElm, "div");
+ if (div && div.style.textAlign == "center") {
+ // Remove div
+ if (div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)
+ div.parentNode.replaceChild(img, div);
+ } else {
+ // Add div
+ var div = this.getDoc().createElement("div");
+ div.style.textAlign = 'center';
+ div.appendChild(img);
+ focusElm.parentNode.replaceChild(div, focusElm);
+ }
- // Force check
- if ((pos = attribName.indexOf('<')) != -1) {
- attribMustBe = attribName.substring(pos+1).split('?');
- attribName = attribName.substring(0, pos);
- }
+ this.selection.selectNode(img);
+ this.repaint();
+ tinyMCE.triggerNodeChange();
+ return;
- attribs[x] = new Array(attribName, attribDefault, attribForce, attribMustBe);
- }
+ case "JustifyRight":
+ if (align == 'right')
+ img.removeAttribute('align');
+ else
+ img.setAttribute('align', 'right');
- validElements[i] = attribs;
- }
+ // Remove the div
+ var div = focusElm.parentNode;
+ if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)
+ div.parentNode.replaceChild(img, div);
- var invalidElements = tinyMCE.settings['invalid_elements'].split(',');
- for (var i=0; i<invalidElements.length; i++)
- invalidElements[i] = invalidElements[i].toLowerCase();
+ this.selection.selectNode(img);
+ this.repaint();
+ tinyMCE.triggerNodeChange();
+ return;
+ }
+ }
- // Set these for performance
- tinyMCE.settings['cleanup_validElements'] = validElements;
- tinyMCE.settings['cleanup_invalidElements'] = invalidElements;
-};
+ if (tinyMCE.settings['force_br_newlines']) {
+ var alignValue = "";
-TinyMCE.prototype._cleanupHTML = function(inst, doc, config, element, visual, on_save) {
- if (!tinyMCE.settings['cleanup']) {
- tinyMCE.handleVisualAid(inst.getBody(), true, false, inst);
+ if (doc.selection.type != "Control") {
+ switch (command) {
+ case "JustifyLeft":
+ alignValue = "left";
+ break;
- var html = element.innerHTML;
+ case "JustifyCenter":
+ alignValue = "center";
+ break;
- // Remove mce_href/mce_src
- html = html.replace(new RegExp('(mce_href|mce_src)=".*?"', 'gi'), '');
- html = html.replace(/\s+>/gi, '>');
+ case "JustifyFull":
+ alignValue = "justify";
+ break;
- return html;
- }
+ case "JustifyRight":
+ alignValue = "right";
+ break;
+ }
- if (on_save && tinyMCE.getParam("convert_fonts_to_spans"))
- tinyMCE.convertFontsToSpans(doc);
+ if (alignValue != "") {
+ var rng = doc.selection.createRange();
- // Call custom cleanup code
- tinyMCE._customCleanup(inst, on_save ? "get_from_editor_dom" : "insert_to_editor_dom", doc.body);
+ if ((divElm = tinyMCE.getParentElement(rng.parentElement(), "div")) != null)
+ divElm.setAttribute("align", alignValue);
+ else if (rng.pasteHTML && rng.htmlText.length > 0)
+ rng.pasteHTML('<div align="' + alignValue + '">' + rng.htmlText + "</div>");
- // Move bgcolor to style
- var n = doc.getElementsByTagName("font");
- for (var i=0; i<n.length; i++) {
- var c = "";
- if ((c = tinyMCE.getAttrib(n[i], "bgcolor")) != "") {
- n[i].style.backgroundColor = c;
- tinyMCE.setAttrib(n[i], "bgcolor", "");
+ tinyMCE.triggerNodeChange();
+ return;
+ }
+ }
}
- }
- // Set these for performance
- tinyMCE.cleanup_validElements = tinyMCE.settings['cleanup_validElements'];
- tinyMCE.cleanup_invalidElements = tinyMCE.settings['cleanup_invalidElements'];
- tinyMCE.cleanup_verify_html = tinyMCE.settings['verify_html'];
- tinyMCE.cleanup_force_br_newlines = tinyMCE.settings['force_br_newlines'];
- tinyMCE.cleanup_urlconverter_callback = tinyMCE.settings['urlconverter_callback'];
- tinyMCE.cleanup_verify_css_classes = tinyMCE.settings['verify_css_classes'];
- tinyMCE.cleanup_visual_table_class = tinyMCE.settings['visual_table_class'];
- tinyMCE.cleanup_apply_source_formatting = tinyMCE.settings['apply_source_formatting'];
- tinyMCE.cleanup_inline_styles = tinyMCE.settings['inline_styles'];
- tinyMCE.cleanup_visual_aid = visual;
- tinyMCE.cleanup_on_save = on_save;
- tinyMCE.cleanup_idCount = 0;
- tinyMCE.cleanup_elementLookupTable = new Array();
-
- var startTime = new Date().getTime();
-
- // Cleanup madness that breaks the editor in MSIE
- if (tinyMCE.isMSIE) {
- // Remove null ids from HR elements, results in runtime error
- var nodes = element.getElementsByTagName("hr");
- for (var i=0; i<nodes.length; i++) {
- if (nodes[i].id == "null")
- nodes[i].removeAttribute("id");
- }
+ switch (command) {
+ case "mceRepaint":
+ this.repaint();
+ return true;
- tinyMCE.setInnerHTML(element, tinyMCE.regexpReplace(element.innerHTML, '<p>[ \n\r]*<hr.*>[ \n\r]*</p>', '<hr />', 'gi'));
- tinyMCE.setInnerHTML(element, tinyMCE.regexpReplace(element.innerHTML, '<!([^-(DOCTYPE)]* )|<!/[^-]*>', '', 'gi'));
- }
+ case "InsertUnorderedList":
+ case "InsertOrderedList":
+ var tag = (command == "InsertUnorderedList") ? "ul" : "ol";
- var html = this.cleanupNode(element);
+ if (tinyMCE.isSafari)
+ this.execCommand("mceInsertContent", false, "<" + tag + "><li>&nbsp;</li><" + tag + ">");
+ else
+ this.getDoc().execCommand(command, user_interface, value);
- if (tinyMCE.settings['debug'])
- tinyMCE.debug("Cleanup process executed in: " + (new Date().getTime()-startTime) + " ms.");
+ tinyMCE.triggerNodeChange();
+ break;
- // Remove pesky HR paragraphs and other crap
- html = tinyMCE.regexpReplace(html, '<p><hr /></p>', '<hr />');
- html = tinyMCE.regexpReplace(html, '<p>&nbsp;</p><hr /><p>&nbsp;</p>', '<hr />');
- html = tinyMCE.regexpReplace(html, '<td>\\s*<br />\\s*</td>', '<td>&nbsp;</td>');
- html = tinyMCE.regexpReplace(html, '<p>\\s*<br />\\s*</p>', '<p>&nbsp;</p>');
- html = tinyMCE.regexpReplace(html, '<p>\\s*&nbsp;\\s*<br />\\s*&nbsp;\\s*</p>', '<p>&nbsp;</p>');
- html = tinyMCE.regexpReplace(html, '<p>\\s*&nbsp;\\s*<br />\\s*</p>', '<p>&nbsp;</p>');
- html = tinyMCE.regexpReplace(html, '<p>\\s*<br />\\s*&nbsp;\\s*</p>', '<p>&nbsp;</p>');
+ case "Strikethrough":
+ if (tinyMCE.isSafari)
+ this.execCommand("mceInsertContent", false, "<strike>" + this.selection.getSelectedHTML() + "</strike>");
+ else
+ this.getDoc().execCommand(command, user_interface, value);
- // Remove empty anchors
- html = html.replace(new RegExp('<a>(.*?)</a>', 'gi'), '$1');
+ tinyMCE.triggerNodeChange();
+ break;
- // Remove some mozilla crap
- if (!tinyMCE.isMSIE)
- html = html.replace(new RegExp('<o:p _moz-userdefined="" />', 'g'), "");
+ case "mceSelectNode":
+ this.selection.selectNode(value);
+ tinyMCE.triggerNodeChange();
+ tinyMCE.selectedNode = value;
+ break;
- if (tinyMCE.settings['remove_linebreaks'])
- html = html.replace(new RegExp('\r|\n', 'g'), ' ');
+ case "FormatBlock":
+ if (value == null || value == "") {
+ var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address");
- if (tinyMCE.getParam('apply_source_formatting')) {
- html = html.replace(new RegExp('<(p|div)([^>]*)>', 'g'), "\n<$1$2>\n");
- html = html.replace(new RegExp('<\/(p|div)([^>]*)>', 'g'), "\n</$1$2>\n");
- html = html.replace(new RegExp('<br />', 'g'), "<br />\n");
- }
+ if (elm)
+ this.execCommand("mceRemoveNode", false, elm);
+ } else {
+ if (value == '<div>' && tinyMCE.isGecko)
+ value = 'div';
- if (tinyMCE.settings['force_br_newlines']) {
- var re = new RegExp('<p>&nbsp;</p>', 'g');
- html = html.replace(re, "<br />");
- }
+ this.getDoc().execCommand("FormatBlock", false, value);
+ }
- if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt']) {
- // Remove weridness!
- var re = new RegExp('&lt;&gt;', 'g');
- html = html.replace(re, "");
- }
+ tinyMCE.triggerNodeChange();
- // Call custom cleanup code
- html = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", html);
+ break;
- // Emtpy node, return empty
- var chk = tinyMCE.regexpReplace(html, "[ \t\r\n]", "").toLowerCase();
- if (chk == "<br/>" || chk == "<br>" || chk == "<p>&nbsp;</p>" || chk == "<p>&#160;</p>" || chk == "<p></p>")
- html = "";
+ case "mceRemoveNode":
+ if (!value)
+ value = tinyMCE.getParentElement(this.getFocusElement());
- if (tinyMCE.settings["preformatted"])
- return "<pre>" + html + "</pre>";
+ if (tinyMCE.isMSIE) {
+ value.outerHTML = value.innerHTML;
+ } else {
+ var rng = value.ownerDocument.createRange();
+ rng.setStartBefore(value);
+ rng.setEndAfter(value);
+ rng.deleteContents();
+ rng.insertNode(rng.createContextualFragment(value.innerHTML));
+ }
- return html;
-};
+ tinyMCE.triggerNodeChange();
-TinyMCE.prototype.insertLink = function(href, target, title, onclick, style_class) {
- tinyMCE.execCommand('mceBeginUndoLevel');
+ break;
- if (this.selectedInstance && this.selectedElement && this.selectedElement.nodeName.toLowerCase() == "img") {
- var doc = this.selectedInstance.getDoc();
- var linkElement = tinyMCE.getParentElement(this.selectedElement, "a");
- var newLink = false;
+ case "mceSelectNodeDepth":
+ var parentNode = this.getFocusElement();
+ for (var i=0; parentNode; i++) {
+ if (parentNode.nodeName.toLowerCase() == "body")
+ break;
- if (!linkElement) {
- linkElement = doc.createElement("a");
- newLink = true;
- }
+ if (parentNode.nodeName.toLowerCase() == "#text") {
+ i--;
+ parentNode = parentNode.parentNode;
+ continue;
+ }
- var mhref = href;
- var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, linkElement);");
- mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
+ if (i == value) {
+ this.selection.selectNode(parentNode, false);
+ tinyMCE.triggerNodeChange();
+ tinyMCE.selectedNode = parentNode;
+ return;
+ }
- tinyMCE.setAttrib(linkElement, 'href', thref);
- tinyMCE.setAttrib(linkElement, 'mce_href', mhref);
- tinyMCE.setAttrib(linkElement, 'target', target);
- tinyMCE.setAttrib(linkElement, 'title', title);
- tinyMCE.setAttrib(linkElement, 'onclick', onclick);
- tinyMCE.setAttrib(linkElement, 'class', style_class);
+ parentNode = parentNode.parentNode;
+ }
- if (newLink) {
- linkElement.appendChild(this.selectedElement.cloneNode(true));
- this.selectedElement.parentNode.replaceChild(linkElement, this.selectedElement);
- }
+ break;
- return;
- }
+ case "SetStyleInfo":
+ var rng = this.getRng();
+ var sel = this.getSel();
+ var scmd = value['command'];
+ var sname = value['name'];
+ var svalue = value['value'] == null ? '' : value['value'];
+ //var svalue = value['value'] == null ? '' : value['value'];
+ var wrapper = value['wrapper'] ? value['wrapper'] : "span";
+ var parentElm = null;
+ var invalidRe = new RegExp("^BODY|HTML$", "g");
+ var invalidParentsRe = tinyMCE.settings['merge_styles_invalid_parents'] != '' ? new RegExp(tinyMCE.settings['merge_styles_invalid_parents'], "gi") : null;
+
+ // Whole element selected check
+ if (tinyMCE.isMSIE) {
+ // Control range
+ if (rng.item)
+ parentElm = rng.item(0);
+ else {
+ var pelm = rng.parentElement();
+ var prng = doc.selection.createRange();
+ prng.moveToElementText(pelm);
+
+ if (rng.htmlText == prng.htmlText || rng.boundingWidth == 0) {
+ if (invalidParentsRe == null || !invalidParentsRe.test(pelm.nodeName))
+ parentElm = pelm;
+ }
+ }
+ } else {
+ var felm = this.getFocusElement();
+ if (sel.isCollapsed || (new RegExp('td|tr|tbody|table', 'gi').test(felm.nodeName) && sel.anchorNode == felm.parentNode))
+ parentElm = felm;
+ }
- if (!this.linkElement && this.selectedInstance) {
- if (tinyMCE.isSafari) {
- tinyMCE.execCommand("mceInsertContent", false, '<a href="' + tinyMCE.uniqueURL + '">' + this.selectedInstance.getSelectedHTML() + '</a>');
- } else
- this.selectedInstance.contentDocument.execCommand("createlink", false, tinyMCE.uniqueURL);
+ // Whole element selected
+ if (parentElm && !invalidRe.test(parentElm.nodeName)) {
+ if (scmd == "setstyle")
+ tinyMCE.setStyleAttrib(parentElm, sname, svalue);
- tinyMCE.linkElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);
+ if (scmd == "setattrib")
+ tinyMCE.setAttrib(parentElm, sname, svalue);
- var elementArray = this.getElementsByAttributeValue(this.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);
+ if (scmd == "removeformat") {
+ parentElm.style.cssText = '';
+ tinyMCE.setAttrib(parentElm, 'class', '');
+ }
- for (var i=0; i<elementArray.length; i++) {
- var mhref = href;
- var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, elementArray[i]);");
- mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
+ // Remove style/attribs from all children
+ var ch = tinyMCE.getNodeTree(parentElm, new Array(), 1);
+ for (var z=0; z<ch.length; z++) {
+ if (ch[z] == parentElm)
+ continue;
- tinyMCE.setAttrib(elementArray[i], 'href', thref);
- tinyMCE.setAttrib(elementArray[i], 'mce_href', mhref);
- tinyMCE.setAttrib(elementArray[i], 'target', target);
- tinyMCE.setAttrib(elementArray[i], 'title', title);
- tinyMCE.setAttrib(elementArray[i], 'onclick', onclick);
- tinyMCE.setAttrib(elementArray[i], 'class', style_class);
- }
+ if (scmd == "setstyle")
+ tinyMCE.setStyleAttrib(ch[z], sname, '');
- tinyMCE.linkElement = elementArray[0];
- }
+ if (scmd == "setattrib")
+ tinyMCE.setAttrib(ch[z], sname, '');
- if (this.linkElement) {
- var mhref = href;
- href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, this.linkElement);");
- mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
-
- tinyMCE.setAttrib(this.linkElement, 'href', href);
- tinyMCE.setAttrib(this.linkElement, 'mce_href', mhref);
- tinyMCE.setAttrib(this.linkElement, 'target', target);
- tinyMCE.setAttrib(this.linkElement, 'title', title);
- tinyMCE.setAttrib(this.linkElement, 'onclick', onclick);
- tinyMCE.setAttrib(this.linkElement, 'class', style_class);
- }
+ if (scmd == "removeformat") {
+ ch[z].style.cssText = '';
+ tinyMCE.setAttrib(ch[z], 'class', '');
+ }
+ }
+ } else {
+ this._setUseCSS(false); // Bug in FF when running in fullscreen
+ doc.execCommand("FontName", false, "#mce_temp_font#");
+ var elementArray = tinyMCE.getElementsByAttributeValue(this.getBody(), "font", "face", "#mce_temp_font#");
- tinyMCE.execCommand('mceEndUndoLevel');
-};
+ // Change them all
+ for (var x=0; x<elementArray.length; x++) {
+ elm = elementArray[x];
+ if (elm) {
+ var spanElm = doc.createElement(wrapper);
-TinyMCE.prototype.insertImage = function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) {
- tinyMCE.execCommand('mceBeginUndoLevel');
+ if (scmd == "setstyle")
+ tinyMCE.setStyleAttrib(spanElm, sname, svalue);
- if (src == "")
- return;
+ if (scmd == "setattrib")
+ tinyMCE.setAttrib(spanElm, sname, svalue);
- if (!this.imgElement && tinyMCE.isSafari) {
- var html = "";
+ if (scmd == "removeformat") {
+ spanElm.style.cssText = '';
+ tinyMCE.setAttrib(spanElm, 'class', '');
+ }
- html += '<img src="' + src + '" alt="' + alt + '"';
- html += ' border="' + border + '" hspace="' + hspace + '"';
- html += ' vspace="' + vspace + '" width="' + width + '"';
- html += ' height="' + height + '" align="' + align + '" title="' + title + '" onmouseover="' + onmouseover + '" onmouseout="' + onmouseout + '" />';
+ if (elm.hasChildNodes()) {
+ for (var i=0; i<elm.childNodes.length; i++)
+ spanElm.appendChild(elm.childNodes[i].cloneNode(true));
+ }
- tinyMCE.execCommand("mceInsertContent", false, html);
- } else {
- if (!this.imgElement && this.selectedInstance) {
- if (tinyMCE.isSafari)
- tinyMCE.execCommand("mceInsertContent", false, '<img src="' + tinyMCE.uniqueURL + '" />');
- else
- this.selectedInstance.contentDocument.execCommand("insertimage", false, tinyMCE.uniqueURL);
+ spanElm.setAttribute("mce_new", "true");
+ elm.parentNode.replaceChild(spanElm, elm);
- tinyMCE.imgElement = this.getElementByAttributeValue(this.selectedInstance.contentDocument.body, "img", "src", tinyMCE.uniqueURL);
- }
- }
+ // Remove style/attribs from all children
+ var ch = tinyMCE.getNodeTree(spanElm, new Array(), 1);
+ for (var z=0; z<ch.length; z++) {
+ if (ch[z] == spanElm)
+ continue;
- if (this.imgElement) {
- var needsRepaint = false;
- var msrc = src;
+ if (scmd == "setstyle")
+ tinyMCE.setStyleAttrib(ch[z], sname, '');
- src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, tinyMCE.imgElement);");
+ if (scmd == "setattrib")
+ tinyMCE.setAttrib(ch[z], sname, '');
- if (tinyMCE.getParam('convert_urls'))
- msrc = src;
+ if (scmd == "removeformat") {
+ ch[z].style.cssText = '';
+ tinyMCE.setAttrib(ch[z], 'class', '');
+ }
+ }
+ }
+ }
+ }
- if (onmouseover && onmouseover != "")
- onmouseover = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, tinyMCE.imgElement);") + "';";
+ // Cleaup wrappers
+ var nodes = doc.getElementsByTagName(wrapper);
+ for (var i=nodes.length-1; i>=0; i--) {
+ var elm = nodes[i];
+ var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true";
- if (onmouseout && onmouseout != "")
- onmouseout = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, tinyMCE.imgElement);") + "';";
+ elm.removeAttribute("mce_new");
- // Use alt as title if it's undefined
- if (typeof(title) == "undefined")
- title = alt;
+ // Is only child a element
+ if (elm.childNodes && elm.childNodes.length == 1 && elm.childNodes[0].nodeType == 1) {
+ //tinyMCE.debug("merge1" + isNew);
+ this._mergeElements(scmd, elm, elm.childNodes[0], isNew);
+ continue;
+ }
- if (width != this.imgElement.getAttribute("width") || height != this.imgElement.getAttribute("height") || align != this.imgElement.getAttribute("align"))
- needsRepaint = true;
+ // Is I the only child
+ if (elm.parentNode.childNodes.length == 1 && !invalidRe.test(elm.nodeName) && !invalidRe.test(elm.parentNode.nodeName)) {
+ //tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName);
+ if (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName))
+ this._mergeElements(scmd, elm.parentNode, elm, false);
+ }
+ }
- tinyMCE.setAttrib(this.imgElement, 'src', src);
- tinyMCE.setAttrib(this.imgElement, 'mce_src', msrc);
- tinyMCE.setAttrib(this.imgElement, 'alt', alt);
- tinyMCE.setAttrib(this.imgElement, 'title', title);
- tinyMCE.setAttrib(this.imgElement, 'align', align);
- tinyMCE.setAttrib(this.imgElement, 'border', border, true);
- tinyMCE.setAttrib(this.imgElement, 'hspace', hspace, true);
- tinyMCE.setAttrib(this.imgElement, 'vspace', vspace, true);
- tinyMCE.setAttrib(this.imgElement, 'width', width, true);
- tinyMCE.setAttrib(this.imgElement, 'height', height, true);
- tinyMCE.setAttrib(this.imgElement, 'onmouseover', onmouseover);
- tinyMCE.setAttrib(this.imgElement, 'onmouseout', onmouseout);
+ // Remove empty wrappers
+ var nodes = doc.getElementsByTagName(wrapper);
+ for (var i=nodes.length-1; i>=0; i--) {
+ var elm = nodes[i];
+ var isEmpty = true;
+
+ // Check if it has any attribs
+ var tmp = doc.createElement("body");
+ tmp.appendChild(elm.cloneNode(false));
+
+ // Is empty span, remove it
+ tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), '');
+ //tinyMCE.debug(tmp.innerHTML);
+ if (new RegExp('<span>', 'gi').test(tmp.innerHTML)) {
+ for (var x=0; x<elm.childNodes.length; x++) {
+ if (elm.parentNode != null)
+ elm.parentNode.insertBefore(elm.childNodes[x].cloneNode(true), elm);
+ }
- // Fix for bug #989846 - Image resize bug
- if (width && width != "")
- this.imgElement.style.pixelWidth = width;
+ elm.parentNode.removeChild(elm);
+ }
+ }
- if (height && height != "")
- this.imgElement.style.pixelHeight = height;
+ // Re add the visual aids
+ if (scmd == "removeformat")
+ tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
- if (needsRepaint)
- tinyMCE.selectedInstance.repaint();
- }
+ tinyMCE.triggerNodeChange();
- tinyMCE.execCommand('mceEndUndoLevel');
-};
+ break;
-TinyMCE.prototype.getElementByAttributeValue = function(node, element_name, attrib, value) {
- var elements = this.getElementsByAttributeValue(node, element_name, attrib, value);
- if (elements.length == 0)
- return null;
+ case "FontName":
+ if (value == null) {
+ var s = this.getSel();
- return elements[0];
-};
+ // Find font and select it
+ if (tinyMCE.isGecko && s.isCollapsed) {
+ var f = tinyMCE.getParentElement(this.getFocusElement(), "font");
-TinyMCE.prototype.getElementsByAttributeValue = function(node, element_name, attrib, value) {
- var elements = new Array();
+ if (f != null)
+ this.selection.selectNode(f, false);
+ }
- if (node && node.nodeName.toLowerCase() == element_name) {
- if (node.getAttribute(attrib) && node.getAttribute(attrib).indexOf(value) != -1)
- elements[elements.length] = node;
- }
+ // Remove format
+ this.getDoc().execCommand("RemoveFormat", false, null);
- if (node && node.hasChildNodes()) {
- for (var x=0, n=node.childNodes.length; x<n; x++) {
- var childElements = this.getElementsByAttributeValue(node.childNodes[x], element_name, attrib, value);
- for (var i=0, m=childElements.length; i<m; i++)
- elements[elements.length] = childElements[i];
- }
- }
+ // Collapse range if font was found
+ if (f != null && tinyMCE.isGecko) {
+ var r = this.getRng().cloneRange();
+ r.collapse(true);
+ s.removeAllRanges();
+ s.addRange(r);
+ }
+ } else
+ this.getDoc().execCommand('FontName', false, value);
- return elements;
-};
+ if (tinyMCE.isGecko)
+ window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
-TinyMCE.prototype.isBlockElement = function(node) {
- return node != null && node.nodeType == 1 && this.blockRegExp.test(node.nodeName);
-};
+ return;
-TinyMCE.prototype.getParentBlockElement = function(node) {
- // Search up the tree for block element
- while (node) {
- if (this.blockRegExp.test(node.nodeName))
- return node;
+ case "FontSize":
+ this.getDoc().execCommand('FontSize', false, value);
- node = node.parentNode;
- }
+ if (tinyMCE.isGecko)
+ window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
- return null;
-};
+ return;
-TinyMCE.prototype.getNodeTree = function(node, node_array, type, node_name) {
- if (typeof(type) == "undefined" || node.nodeType == type && (typeof(node_name) == "undefined" || node.nodeName == node_name))
- node_array[node_array.length] = node;
+ case "forecolor":
+ this.getDoc().execCommand('forecolor', false, value);
+ break;
- if (node.hasChildNodes()) {
- for (var i=0; i<node.childNodes.length; i++)
- tinyMCE.getNodeTree(node.childNodes[i], node_array, type, node_name);
- }
+ case "HiliteColor":
+ if (tinyMCE.isGecko) {
+ this._setUseCSS(true);
+ this.getDoc().execCommand('hilitecolor', false, value);
+ this._setUseCSS(false);
+ } else
+ this.getDoc().execCommand('BackColor', false, value);
+ break;
- return node_array;
-};
+ case "Cut":
+ case "Copy":
+ case "Paste":
+ var cmdFailed = false;
-TinyMCE.prototype.getParentElement = function(node, names, attrib_name, attrib_value) {
- if (typeof(names) == "undefined") {
- if (node.nodeType == 1)
- return node;
+ // Try executing command
+ eval('try {this.getDoc().execCommand(command, user_interface, value);} catch (e) {cmdFailed = true;}');
- // Find parent node that is a element
- while ((node = node.parentNode) != null && node.nodeType != 1) ;
+ if (tinyMCE.isOpera && cmdFailed)
+ alert('Currently not supported by your browser, use keyboard shortcuts instead.');
- return node;
- }
+ // Alert error in gecko if command failed
+ if (tinyMCE.isGecko && cmdFailed) {
+ // Confirm more info
+ if (confirm(tinyMCE.entityDecode(tinyMCE.getLang('lang_clipboard_msg'))))
+ window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html', 'mceExternal');
- var namesAr = names.split(',');
+ return;
+ } else
+ tinyMCE.triggerNodeChange();
+ break;
- if (node == null)
- return null;
+ case "mceSetContent":
+ if (!value)
+ value = "";
- do {
- for (var i=0; i<namesAr.length; i++) {
- if (node.nodeName.toLowerCase() == namesAr[i].toLowerCase() || names == "*") {
- if (typeof(attrib_name) == "undefined")
- return node;
- else if (node.getAttribute(attrib_name)) {
- if (typeof(attrib_value) == "undefined") {
- if (node.getAttribute(attrib_name) != "")
- return node;
- } else if (node.getAttribute(attrib_name) == attrib_value)
- return node;
- }
- }
- }
- } while ((node = node.parentNode) != null);
+ // Call custom cleanup code
+ value = tinyMCE.storeAwayURLs(value);
+ value = tinyMCE._customCleanup(this, "insert_to_editor", value);
+ tinyMCE._setHTML(doc, value);
+ tinyMCE.setInnerHTML(doc.body, tinyMCE._cleanupHTML(this, doc, tinyMCE.settings, doc.body));
+ tinyMCE.convertAllRelativeURLs(doc.body);
- return null;
-};
+ // When editing always use fonts internaly
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertSpansToFonts(doc);
-TinyMCE.prototype.convertURL = function(url, node, on_save) {
- var prot = document.location.protocol;
- var host = document.location.hostname;
- var port = document.location.port;
+ tinyMCE.handleVisualAid(doc.body, true, this.visualAid, this);
+ tinyMCE._setEventsEnabled(doc.body, false);
+ return true;
- // Pass through file protocol
- if (prot == "file:")
- return url;
+ case "mceCleanup":
+ var b = this.selection.getBookmark();
+ tinyMCE._setHTML(this.contentDocument, this.getBody().innerHTML);
+ tinyMCE.setInnerHTML(this.getBody(), tinyMCE._cleanupHTML(this, this.contentDocument, this.settings, this.getBody(), this.visualAid));
+ tinyMCE.convertAllRelativeURLs(doc.body);
- // Something is wrong, remove weirdness
- url = tinyMCE.regexpReplace(url, '(http|https):///', '/');
+ // When editing always use fonts internaly
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertSpansToFonts(doc);
- // Mailto link or anchor (Pass through)
- if (url.indexOf('mailto:') != -1 || url.indexOf('javascript:') != -1 || tinyMCE.regexpReplace(url,'[ \t\r\n\+]|%20','').charAt(0) == "#")
- return url;
+ tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
+ tinyMCE._setEventsEnabled(this.getBody(), false);
+ this.repaint();
+ this.selection.moveToBookmark(b);
+ tinyMCE.triggerNodeChange();
+ break;
- // Fix relative/Mozilla
- if (!tinyMCE.isMSIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/')
- return tinyMCE.settings['base_href'] + url;
+ case "mceReplaceContent":
+ // Force empty string
+ if (!value)
+ value = '';
- // Handle relative URLs
- if (on_save && tinyMCE.getParam('relative_urls')) {
- var curl = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], url);
- if (curl.charAt(0) == '/')
- curl = tinyMCE.settings['document_base_prefix'] + curl;
+ this.getWin().focus();
- var urlParts = tinyMCE.parseURL(curl);
- var tmpUrlParts = tinyMCE.parseURL(tinyMCE.settings['document_base_url']);
+ var selectedText = "";
- // Force relative
- if (urlParts['host'] == tmpUrlParts['host'] && (urlParts['port'] == tmpUrlParts['port']))
- return tinyMCE.convertAbsoluteURLToRelativeURL(tinyMCE.settings['document_base_url'], curl);
- }
+ if (tinyMCE.isMSIE) {
+ var rng = doc.selection.createRange();
+ selectedText = rng.text;
+ } else
+ selectedText = this.getSel().toString();
- // Handle absolute URLs
- if (!tinyMCE.getParam('relative_urls')) {
- var urlParts = tinyMCE.parseURL(url);
- var baseUrlParts = tinyMCE.parseURL(tinyMCE.settings['base_href']);
+ if (selectedText.length > 0) {
+ value = tinyMCE.replaceVar(value, "selection", selectedText);
+ tinyMCE.execCommand('mceInsertContent', false, value);
+ }
- // Force absolute URLs from relative URLs
- url = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], url);
+ tinyMCE.triggerNodeChange();
+ break;
- // If anchor and path is the same page
- if (urlParts['anchor'] && urlParts['path'] == baseUrlParts['path'])
- return "#" + urlParts['anchor'];
- }
+ case "mceSetAttribute":
+ if (typeof(value) == 'object') {
+ var targetElms = (typeof(value['targets']) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value['targets'];
+ var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms);
- // Remove current domain
- if (tinyMCE.getParam('remove_script_host')) {
- var start = "", portPart = "";
+ if (targetNode) {
+ targetNode.setAttribute(value['name'], value['value']);
+ tinyMCE.triggerNodeChange();
+ }
+ }
+ break;
- if (port != "")
- portPart = ":" + port;
+ case "mceSetCSSClass":
+ this.execCommand("SetStyleInfo", false, {command : "setattrib", name : "class", value : value});
+ break;
- start = prot + "//" + host + portPart + "/";
+ case "mceInsertRawHTML":
+ var key = 'tiny_mce_marker';
- if (url.indexOf(start) == 0)
- url = url.substring(start.length-1);
- }
+ this.execCommand('mceBeginUndoLevel');
- return url;
-};
+ // Insert marker key
+ this.execCommand('mceInsertContent', false, key);
-/**
- * Parses a URL in to its diffrent components.
- */
-TinyMCE.prototype.parseURL = function(url_str) {
- var urlParts = new Array();
+ // Store away scroll pos
+ var scrollX = this.getDoc().body.scrollLeft + this.getDoc().documentElement.scrollLeft;
+ var scrollY = this.getDoc().body.scrollTop + this.getDoc().documentElement.scrollTop;
- if (url_str) {
- var pos, lastPos;
+ // Find marker and replace with RAW HTML
+ var html = this.getBody().innerHTML;
+ if ((pos = html.indexOf(key)) != -1)
+ tinyMCE.setInnerHTML(this.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length));
- // Parse protocol part
- pos = url_str.indexOf('://');
- if (pos != -1) {
- urlParts['protocol'] = url_str.substring(0, pos);
- lastPos = pos + 3;
- }
+ // Restore scoll pos
+ this.contentWindow.scrollTo(scrollX, scrollY);
- // Find port or path start
- for (var i=lastPos; i<url_str.length; i++) {
- var chr = url_str.charAt(i);
+ this.execCommand('mceEndUndoLevel');
- if (chr == ':')
break;
- if (chr == '/')
- break;
- }
- pos = i;
+ case "mceInsertContent":
+ // Force empty string
+ if (!value)
+ value = '';
- // Get host
- urlParts['host'] = url_str.substring(lastPos, pos);
+ var insertHTMLFailed = false;
+ this.getWin().focus();
- // Get port
- urlParts['port'] = "";
- lastPos = pos;
- if (url_str.charAt(pos) == ':') {
- pos = url_str.indexOf('/', lastPos);
- urlParts['port'] = url_str.substring(lastPos+1, pos);
- }
+ if (tinyMCE.isGecko || tinyMCE.isOpera) {
+ try {
+ // Is plain text or HTML, &amp;, &nbsp; etc will be encoded wrong in FF
+ if (value.indexOf('<') == -1 && !value.match(/(&#38;|&#160;|&#60;|&#62;)/g)) {
+ var r = this.getRng();
+ var n = this.getDoc().createTextNode(tinyMCE.entityDecode(value));
+ var s = this.getSel();
+ var r2 = r.cloneRange();
+
+ // Insert text at cursor position
+ s.removeAllRanges();
+ r.deleteContents();
+ r.insertNode(n);
+
+ // Move the cursor to the end of text
+ r2.selectNode(n);
+ r2.collapse(false);
+ s.removeAllRanges();
+ s.addRange(r2);
+ } else {
+ value = tinyMCE.fixGeckoBaseHREFBug(1, this.getDoc(), value);
+ this.getDoc().execCommand('inserthtml', false, value);
+ tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value);
+ }
+ } catch (ex) {
+ insertHTMLFailed = true;
+ }
- // Get path
- lastPos = pos;
- pos = url_str.indexOf('?', lastPos);
+ if (!insertHTMLFailed) {
+ tinyMCE.triggerNodeChange();
+ return;
+ }
+ }
- if (pos == -1)
- pos = url_str.indexOf('#', lastPos);
+ // Ugly hack in Opera due to non working "inserthtml"
+ if (tinyMCE.isOpera && insertHTMLFailed) {
+ this.getDoc().execCommand("insertimage", false, tinyMCE.uniqueURL);
+ var ar = tinyMCE.getElementsByAttributeValue(this.getBody(), "img", "src", tinyMCE.uniqueURL);
+ ar[0].outerHTML = value;
+ return;
+ }
- if (pos == -1)
- pos = url_str.length;
+ if (!tinyMCE.isMSIE) {
+ var isHTML = value.indexOf('<') != -1;
+ var sel = this.getSel();
+ var rng = this.getRng();
- urlParts['path'] = url_str.substring(lastPos, pos);
+ if (isHTML) {
+ if (tinyMCE.isSafari) {
+ var tmpRng = this.getDoc().createRange();
- // Get query
- lastPos = pos;
- if (url_str.charAt(pos) == '?') {
- pos = url_str.indexOf('#');
- pos = (pos == -1) ? url_str.length : pos;
- urlParts['query'] = url_str.substring(lastPos+1, pos);
- }
+ tmpRng.setStart(this.getBody(), 0);
+ tmpRng.setEnd(this.getBody(), 0);
- // Get anchor
- lastPos = pos;
- if (url_str.charAt(pos) == '#') {
- pos = url_str.length;
- urlParts['anchor'] = url_str.substring(lastPos+1, pos);
- }
- }
+ value = tmpRng.createContextualFragment(value);
+ } else
+ value = rng.createContextualFragment(value);
+ } else {
+ // Setup text node
+ var el = document.createElement("div");
+ el.innerHTML = value;
+ value = el.firstChild.nodeValue;
+ value = doc.createTextNode(value);
+ }
- return urlParts;
-};
+ // Insert plain text in Safari
+ if (tinyMCE.isSafari && !isHTML) {
+ this.execCommand('InsertText', false, value.nodeValue);
+ tinyMCE.triggerNodeChange();
+ return true;
+ } else if (tinyMCE.isSafari && isHTML) {
+ rng.deleteContents();
+ rng.insertNode(value);
+ tinyMCE.triggerNodeChange();
+ return true;
+ }
-TinyMCE.prototype.serializeURL = function(up) {
- var url = "";
+ rng.deleteContents();
- if (up['protocol'])
- url += up['protocol'] + "://";
+ // If target node is text do special treatment, (Mozilla 1.3 fix)
+ if (rng.startContainer.nodeType == 3) {
+ var node = rng.startContainer.splitText(rng.startOffset);
+ node.parentNode.insertBefore(value, node);
+ } else
+ rng.insertNode(value);
- if (up['host'])
- url += up['host'];
+ if (!isHTML) {
+ // Removes weird selection trails
+ sel.selectAllChildren(doc.body);
+ sel.removeAllRanges();
- if (up['port'])
- url += ":" + up['port'];
+ // Move cursor to end of content
+ var rng = doc.createRange();
- if (up['path'])
- url += up['path'];
+ rng.selectNode(value);
+ rng.collapse(false);
- if (up['query'])
- url += "?" + up['query'];
+ sel.addRange(rng);
+ } else
+ rng.collapse(false);
- if (up['anchor'])
- url += "#" + up['anchor'];
+ tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value);
+ } else {
+ var rng = doc.selection.createRange();
+ var c = value.indexOf('<!--') != -1;
- return url;
-};
+ // Fix comment bug, add tag before comments
+ if (c)
+ value = tinyMCE.uniqueTag + value;
-/**
- * Converts an absolute path to relative path.
- */
-TinyMCE.prototype.convertAbsoluteURLToRelativeURL = function(base_url, url_to_relative) {
- var baseURL = this.parseURL(base_url);
- var targetURL = this.parseURL(url_to_relative);
- var strTok1;
- var strTok2;
- var breakPoint = 0;
- var outPath = "";
- var forceSlash = false;
+ if (rng.item)
+ rng.item(0).outerHTML = value;
+ else
+ rng.pasteHTML(value);
- if (targetURL.path == "")
- targetURL.path = "/";
- else
- forceSlash = true;
+ // Remove unique tag
+ if (c) {
+ var e = this.getDoc().getElementById('mceTMPElement');
+ e.parentNode.removeChild(e);
+ }
+ }
- // Crop away last path part
- base_url = baseURL.path.substring(0, baseURL.path.lastIndexOf('/'));
- strTok1 = base_url.split('/');
- strTok2 = targetURL.path.split('/');
+ tinyMCE.triggerNodeChange();
+ break;
- if (strTok1.length >= strTok2.length) {
- for (var i=0; i<strTok1.length; i++) {
- if (i >= strTok2.length || strTok1[i] != strTok2[i]) {
- breakPoint = i + 1;
+ case "mceStartTyping":
+ if (tinyMCE.settings['custom_undo_redo'] && this.undoRedo.typingUndoIndex == -1) {
+ this.undoRedo.typingUndoIndex = this.undoRedo.undoIndex;
+ this.execCommand('mceAddUndoLevel');
+ //tinyMCE.debug("mceStartTyping");
+ }
break;
- }
- }
- }
- if (strTok1.length < strTok2.length) {
- for (var i=0; i<strTok2.length; i++) {
- if (i >= strTok1.length || strTok1[i] != strTok2[i]) {
- breakPoint = i + 1;
+ case "mceEndTyping":
+ if (tinyMCE.settings['custom_undo_redo'] && this.undoRedo.typingUndoIndex != -1) {
+ this.execCommand('mceAddUndoLevel');
+ this.undoRedo.typingUndoIndex = -1;
+ //tinyMCE.debug("mceEndTyping");
+ }
break;
- }
- }
- }
- if (breakPoint == 1)
- return targetURL.path;
+ case "mceBeginUndoLevel":
+ this.undoRedoLevel = false;
+ break;
- for (var i=0; i<(strTok1.length-(breakPoint-1)); i++)
- outPath += "../";
+ case "mceEndUndoLevel":
+ this.undoRedoLevel = true;
+ this.execCommand('mceAddUndoLevel');
+ break;
- for (var i=breakPoint-1; i<strTok2.length; i++) {
- if (i != (breakPoint-1))
- outPath += "/" + strTok2[i];
- else
- outPath += strTok2[i];
- }
+ case "mceAddUndoLevel":
+ if (tinyMCE.settings['custom_undo_redo'] && this.undoRedoLevel) {
+ if (this.undoRedo.add())
+ tinyMCE.triggerNodeChange(false);
+ }
+ break;
- targetURL.protocol = null;
- targetURL.host = null;
- targetURL.port = null;
- targetURL.path = outPath == "" && forceSlash ? "/" : outPath;
+ case "Undo":
+ if (tinyMCE.settings['custom_undo_redo']) {
+ tinyMCE.execCommand("mceEndTyping");
+ this.undoRedo.undo();
+ tinyMCE.triggerNodeChange();
+ } else
+ this.getDoc().execCommand(command, user_interface, value);
+ break;
- // Remove document prefix from local anchors
- var fileName = baseURL.path;
- var pos;
+ case "Redo":
+ if (tinyMCE.settings['custom_undo_redo']) {
+ tinyMCE.execCommand("mceEndTyping");
+ this.undoRedo.redo();
+ tinyMCE.triggerNodeChange();
+ } else
+ this.getDoc().execCommand(command, user_interface, value);
+ break;
- if ((pos = fileName.lastIndexOf('/')) != -1)
- fileName = fileName.substring(pos + 1);
+ case "mceToggleVisualAid":
+ this.visualAid = !this.visualAid;
+ tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
+ tinyMCE.triggerNodeChange();
+ break;
- // Is local anchor
- if (fileName == targetURL.path && targetURL.anchor != "")
- targetURL.path = "";
+ case "Indent":
+ this.getDoc().execCommand(command, user_interface, value);
+ tinyMCE.triggerNodeChange();
+ if (tinyMCE.isMSIE) {
+ var n = tinyMCE.getParentElement(this.getFocusElement(), "blockquote");
+ do {
+ if (n && n.nodeName == "BLOCKQUOTE") {
+ n.removeAttribute("dir");
+ n.removeAttribute("style");
+ }
+ } while (n != null && (n = n.parentNode) != null);
+ }
+ break;
- return this.serializeURL(targetURL);
-};
+ case "removeformat":
+ var text = this.selection.getSelectedText();
-TinyMCE.prototype.convertRelativeToAbsoluteURL = function(base_url, relative_url) {
- var baseURL = TinyMCE.prototype.parseURL(base_url);
- var relURL = TinyMCE.prototype.parseURL(relative_url);
+ if (tinyMCE.isOpera) {
+ this.getDoc().execCommand("RemoveFormat", false, null);
+ return;
+ }
- if (relative_url == "" || relative_url.charAt(0) == '/' || relative_url.indexOf('://') != -1 || relative_url.indexOf('mailto:') != -1 || relative_url.indexOf('javascript:') != -1)
- return relative_url;
+ if (tinyMCE.isMSIE) {
+ try {
+ var rng = doc.selection.createRange();
+ rng.execCommand("RemoveFormat", false, null);
+ } catch (e) {
+ // Do nothing
+ }
- // Split parts
- baseURLParts = baseURL['path'].split('/');
- relURLParts = relURL['path'].split('/');
+ this.execCommand("SetStyleInfo", false, {command : "removeformat"});
+ } else {
+ this.getDoc().execCommand(command, user_interface, value);
- // Remove empty chunks
- var newBaseURLParts = new Array();
- for (var i=baseURLParts.length-1; i>=0; i--) {
- if (baseURLParts[i].length == 0)
- continue;
+ this.execCommand("SetStyleInfo", false, {command : "removeformat"});
+ }
- newBaseURLParts[newBaseURLParts.length] = baseURLParts[i];
- }
- baseURLParts = newBaseURLParts.reverse();
+ // Remove class
+ if (text.length == 0)
+ this.execCommand("mceSetCSSClass", false, "");
- // Merge relURLParts chunks
- var newRelURLParts = new Array();
- var numBack = 0;
- for (var i=relURLParts.length-1; i>=0; i--) {
- if (relURLParts[i].length == 0 || relURLParts[i] == ".")
- continue;
+ tinyMCE.triggerNodeChange();
+ break;
- if (relURLParts[i] == '..') {
- numBack++;
- continue;
- }
+ default:
+ this.getDoc().execCommand(command, user_interface, value);
- if (numBack > 0) {
- numBack--;
- continue;
+ if (tinyMCE.isGecko)
+ window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
+ else
+ tinyMCE.triggerNodeChange();
}
- newRelURLParts[newRelURLParts.length] = relURLParts[i];
- }
-
- relURLParts = newRelURLParts.reverse();
+ // Add undo level after modification
+ if (command != "mceAddUndoLevel" && command != "Undo" && command != "Redo" && command != "mceStartTyping" && command != "mceEndTyping")
+ tinyMCE.execCommand("mceAddUndoLevel");
+ },
- // Remove end from absolute path
- var len = baseURLParts.length-numBack;
- var absPath = (len <= 0 ? "" : "/") + baseURLParts.slice(0, len).join('/') + "/" + relURLParts.join('/');
- var start = "", end = "";
+ queryCommandValue : function(c) {
+ try {
+ return this.getDoc().queryCommandValue(c);
+ } catch (e) {
+ return null;
+ }
+ },
- // Build output URL
- relURL.protocol = baseURL.protocol;
- relURL.host = baseURL.host;
- relURL.port = baseURL.port;
+ queryCommandState : function(c) {
+ return this.getDoc().queryCommandState(c);
+ },
- // Re-add trailing slash if it's removed
- if (relURL.path.charAt(relURL.path.length-1) == "/")
- absPath += "/";
+ _onAdd : function(replace_element, form_element_name, target_document) {
+ var hc, th, to, editorTemplate;
- relURL.path = absPath;
+ th = this.settings['theme'];
+ to = tinyMCE.themes[th];
- return TinyMCE.prototype.serializeURL(relURL);
-};
+ var targetDoc = target_document ? target_document : document;
-TinyMCE.prototype.getParam = function(name, default_value, strip_whitespace, split_chr) {
- var value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
+ this.targetDoc = targetDoc;
- // Fix bool values
- if (value == "true" || value == "false")
- return (value == "true");
+ tinyMCE.themeURL = tinyMCE.baseURL + "/themes/" + this.settings['theme'];
+ this.settings['themeurl'] = tinyMCE.themeURL;
- if (strip_whitespace)
- value = tinyMCE.regexpReplace(value, "[ \t\r\n]", "");
+ if (!replace_element) {
+ alert("Error: Could not find the target element.");
+ return false;
+ }
- if (typeof(split_chr) != "undefined" && split_chr != null) {
- value = value.split(split_chr);
- var outArray = new Array();
+ if (to.getEditorTemplate)
+ editorTemplate = to.getEditorTemplate(this.settings, this.editorId);
- for (var i=0; i<value.length; i++) {
- if (value[i] && value[i] != "")
- outArray[outArray.length] = value[i];
- }
+ var deltaWidth = editorTemplate['delta_width'] ? editorTemplate['delta_width'] : 0;
+ var deltaHeight = editorTemplate['delta_height'] ? editorTemplate['delta_height'] : 0;
+ var html = '<span id="' + this.editorId + '_parent" class="mceEditorContainer">' + editorTemplate['html'];
- value = outArray;
- }
+ html = tinyMCE.replaceVar(html, "editor_id", this.editorId);
+ this.settings['default_document'] = tinyMCE.baseURL + "/blank.htm";
- return value;
-};
+ this.settings['old_width'] = this.settings['width'];
+ this.settings['old_height'] = this.settings['height'];
-TinyMCE.prototype.getLang = function(name, default_value, parse_entities) {
- var value = (typeof(tinyMCELang[name]) == "undefined") ? default_value : tinyMCELang[name];
+ // Set default width, height
+ if (this.settings['width'] == -1)
+ this.settings['width'] = replace_element.offsetWidth;
- if (parse_entities)
- value = tinyMCE.entityDecode(value);
+ if (this.settings['height'] == -1)
+ this.settings['height'] = replace_element.offsetHeight;
- return value;
-};
+ // Try the style width
+ if (this.settings['width'] == 0)
+ this.settings['width'] = replace_element.style.width;
-TinyMCE.prototype.entityDecode = function(s) {
- var e = document.createElement("div");
- e.innerHTML = s;
- return e.innerHTML;
-};
+ // Try the style height
+ if (this.settings['height'] == 0)
+ this.settings['height'] = replace_element.style.height;
-TinyMCE.prototype.addToLang = function(prefix, ar) {
- for (var key in ar) {
- if (typeof(ar[key]) == 'function')
- continue;
+ // If no width/height then default to 320x240, better than nothing
+ if (this.settings['width'] == 0)
+ this.settings['width'] = 320;
- tinyMCELang[(key.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = ar[key];
- }
+ if (this.settings['height'] == 0)
+ this.settings['height'] = 240;
-// for (var key in ar)
-// tinyMCELang[(key.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = "|" + ar[key] + "|";
-};
+ this.settings['area_width'] = parseInt(this.settings['width']);
+ this.settings['area_height'] = parseInt(this.settings['height']);
+ this.settings['area_width'] += deltaWidth;
+ this.settings['area_height'] += deltaHeight;
-TinyMCE.prototype.replaceVar = function(replace_haystack, replace_var, replace_str) {
- var re = new RegExp('{\\\$' + replace_var + '}', 'g');
- return replace_haystack.replace(re, replace_str);
-};
+ // Special % handling
+ if (("" + this.settings['width']).indexOf('%') != -1)
+ this.settings['area_width'] = "100%";
-TinyMCE.prototype.replaceVars = function(replace_haystack, replace_vars) {
- for (var key in replace_vars) {
- var value = replace_vars[key];
- if (typeof(value) == 'function')
- continue;
+ if (("" + this.settings['height']).indexOf('%') != -1)
+ this.settings['area_height'] = "100%";
- replace_haystack = tinyMCE.replaceVar(replace_haystack, key, value);
- }
+ if (("" + replace_element.style.width).indexOf('%') != -1) {
+ this.settings['width'] = replace_element.style.width;
+ this.settings['area_width'] = "100%";
+ }
- return replace_haystack;
-};
+ if (("" + replace_element.style.height).indexOf('%') != -1) {
+ this.settings['height'] = replace_element.style.height;
+ this.settings['area_height'] = "100%";
+ }
-TinyMCE.prototype.triggerNodeChange = function(focus, setup_content) {
- if (tinyMCE.settings['handleNodeChangeCallback']) {
- if (tinyMCE.selectedInstance) {
- var inst = tinyMCE.selectedInstance;
- var editorId = inst.editorId;
- var elm = (typeof(setup_content) != "undefined" && setup_content) ? tinyMCE.selectedElement : inst.getFocusElement();
- var undoIndex = -1;
- var undoLevels = -1;
- var anySelection = false;
- var selectedText = inst.getSelectedText();
+ html = tinyMCE.applyTemplate(html);
- inst.switchSettings();
+ this.settings['width'] = this.settings['old_width'];
+ this.settings['height'] = this.settings['old_height'];
- if (tinyMCE.settings["auto_resize"]) {
- var doc = inst.getDoc();
+ this.visualAid = this.settings['visual'];
+ this.formTargetElementId = form_element_name;
- inst.iframeElement.style.width = doc.body.offsetWidth + "px";
- inst.iframeElement.style.height = doc.body.offsetHeight + "px";
- }
+ // Get replace_element contents
+ if (replace_element.nodeName == "TEXTAREA" || replace_element.nodeName == "INPUT")
+ this.startContent = replace_element.value;
+ else
+ this.startContent = replace_element.innerHTML;
- if (tinyMCE.selectedElement)
- anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (selectedText && selectedText.length > 0);
+ // If not text area or input
+ if (replace_element.nodeName != "TEXTAREA" && replace_element.nodeName != "INPUT") {
+ this.oldTargetElement = replace_element;
- if (tinyMCE.settings['custom_undo_redo']) {
- undoIndex = inst.undoIndex;
- undoLevels = inst.undoLevels.length;
+ // Debug mode
+ if (tinyMCE.settings['debug']) {
+ hc = '<textarea wrap="off" id="' + form_element_name + '" name="' + form_element_name + '" cols="100" rows="15"></textarea>';
+ } else {
+ hc = '<input type="hidden" type="text" id="' + form_element_name + '" name="' + form_element_name + '" />';
+ this.oldTargetElement.style.display = "none";
}
- tinyMCE.executeCallback('handleNodeChangeCallback', '_handleNodeChange', 0, editorId, elm, undoIndex, undoLevels, inst.visualAid, anySelection, setup_content);
- }
- }
+ html += '</span>';
- if (this.selectedInstance && (typeof(focus) == "undefined" || focus))
- this.selectedInstance.contentWindow.focus();
-};
+ if (tinyMCE.isGecko)
+ html = hc + html;
+ else
+ html += hc;
-TinyMCE.prototype._customCleanup = function(inst, type, content) {
- // Call custom cleanup
- var customCleanup = tinyMCE.settings['cleanup_callback'];
- if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined")
- content = eval(customCleanup + "(type, content, inst);");
-
- // Trigger plugin cleanups
- var plugins = tinyMCE.getParam('plugins', '', true, ',');
- for (var i=0; i<plugins.length; i++) {
- if (eval("typeof(TinyMCE_" + plugins[i] + "_cleanup)") != "undefined")
- content = eval("TinyMCE_" + plugins[i] + "_cleanup(type, content, inst);");
- }
+ // Output HTML and set editable
+ if (tinyMCE.isGecko) {
+ var rng = replace_element.ownerDocument.createRange();
+ rng.setStartBefore(replace_element);
- return content;
-};
+ var fragment = rng.createContextualFragment(html);
+ tinyMCE.insertAfter(fragment, replace_element);
+ } else
+ replace_element.insertAdjacentHTML("beforeBegin", html);
+ } else {
+ html += '</span>';
-TinyMCE.prototype.getContent = function(editor_id) {
- if (typeof(editor_id) != "undefined")
- tinyMCE.selectedInstance = tinyMCE.getInstanceById(editor_id);
+ // Just hide the textarea element
+ this.oldTargetElement = replace_element;
- if (tinyMCE.selectedInstance) {
- var old = this.selectedInstance.getBody().innerHTML;
- var html = tinyMCE._cleanupHTML(this.selectedInstance, this.selectedInstance.getDoc(), tinyMCE.settings, this.selectedInstance.getBody(), false, true);
- tinyMCE.setInnerHTML(this.selectedInstance.getBody(), old);
- return html;
- }
+ if (!tinyMCE.settings['debug'])
+ this.oldTargetElement.style.display = "none";
- return null;
-};
+ // Output HTML and set editable
+ if (tinyMCE.isGecko) {
+ var rng = replace_element.ownerDocument.createRange();
+ rng.setStartBefore(replace_element);
-TinyMCE.prototype.setContent = function(html_content) {
- if (tinyMCE.selectedInstance) {
- tinyMCE.selectedInstance.execCommand('mceSetContent', false, html_content);
- tinyMCE.selectedInstance.repaint();
- }
-};
+ var fragment = rng.createContextualFragment(html);
+ tinyMCE.insertAfter(fragment, replace_element);
+ } else
+ replace_element.insertAdjacentHTML("beforeBegin", html);
+ }
-TinyMCE.prototype.importThemeLanguagePack = function(name) {
- if (typeof(name) == "undefined")
- name = tinyMCE.settings['theme'];
+ // Setup iframe
+ var dynamicIFrame = false;
+ var tElm = targetDoc.getElementById(this.editorId);
- tinyMCE.loadScript(tinyMCE.baseURL + '/themes/' + name + '/langs/' + tinyMCE.settings['language'] + '.js');
-};
+ if (!tinyMCE.isMSIE) {
+ if (tElm && tElm.nodeName == "SPAN") {
+ tElm = tinyMCE._createIFrame(tElm, targetDoc);
+ dynamicIFrame = true;
+ }
-TinyMCE.prototype.importPluginLanguagePack = function(name, valid_languages) {
- var lang = "en";
+ this.targetElement = tElm;
+ this.iframeElement = tElm;
+ this.contentDocument = tElm.contentDocument;
+ this.contentWindow = tElm.contentWindow;
- valid_languages = valid_languages.split(',');
- for (var i=0; i<valid_languages.length; i++) {
- if (tinyMCE.settings['language'] == valid_languages[i])
- lang = tinyMCE.settings['language'];
- }
+ //this.getDoc().designMode = "on";
+ } else {
+ if (tElm && tElm.nodeName == "SPAN")
+ tElm = tinyMCE._createIFrame(tElm, targetDoc, targetDoc.parentWindow);
+ else
+ tElm = targetDoc.frames[this.editorId];
- tinyMCE.loadScript(tinyMCE.baseURL + '/plugins/' + name + '/langs/' + lang + '.js');
-};
+ this.targetElement = tElm;
+ this.iframeElement = targetDoc.getElementById(this.editorId);
-/**
- * Adds themeurl, settings and lang to HTML code.
- */
-TinyMCE.prototype.applyTemplate = function(html, args) {
- html = tinyMCE.replaceVar(html, "themeurl", tinyMCE.themeURL);
+ if (tinyMCE.isOpera) {
+ this.contentDocument = this.iframeElement.contentDocument;
+ this.contentWindow = this.iframeElement.contentWindow;
+ dynamicIFrame = true;
+ } else {
+ this.contentDocument = tElm.window.document;
+ this.contentWindow = tElm.window;
+ }
- if (typeof(args) != "undefined")
- html = tinyMCE.replaceVars(html, args);
+ this.getDoc().designMode = "on";
+ }
- html = tinyMCE.replaceVars(html, tinyMCE.settings);
- html = tinyMCE.replaceVars(html, tinyMCELang);
+ // Setup base HTML
+ var doc = this.contentDocument;
+ if (dynamicIFrame) {
+ var html = tinyMCE.getParam('doctype') + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + tinyMCE.settings['base_href'] + '" /><title>blank_page</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body class="mceContentBody"></body></html>';
+
+ try {
+ if (!this.isHidden())
+ this.getDoc().designMode = "on";
+
+ doc.open();
+ doc.write(html);
+ doc.close();
+ } catch (e) {
+ // Failed Mozilla 1.3
+ this.getDoc().location.href = tinyMCE.baseURL + "/blank.htm";
+ }
+ }
- return html;
-};
+ // This timeout is needed in MSIE 5.5 for some odd reason
+ // it seems that the document.frames isn't initialized yet?
+ if (tinyMCE.isMSIE)
+ window.setTimeout("tinyMCE.addEventHandlers(tinyMCE.instances[\"" + this.editorId + "\"]);", 1);
-TinyMCE.prototype.openWindow = function(template, args) {
- var html, width, height, x, y, resizable, scrollbars, url;
+ tinyMCE.setupContent(this.editorId, true);
- args['mce_template_file'] = template['file'];
- args['mce_width'] = template['width'];
- args['mce_height'] = template['height'];
- tinyMCE.windowArgs = args;
+ return true;
+ },
- html = template['html'];
- if (!(width = parseInt(template['width'])))
- width = 320;
+ setBaseHREF : function(u) {
+ var h, b, d, nl;
- if (!(height = parseInt(template['height'])))
- height = 200;
+ d = this.getDoc();
+ nl = d.getElementsByTagName("base");
+ b = nl.length > 0 ? nl[0] : null;
- // Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!!
- if (tinyMCE.isMSIE)
- height += 40;
- else
- height += 20;
+ if (!b) {
+ nl = d.getElementsByTagName("head");
+ h = nl.length > 0 ? nl[0] : null;
- x = parseInt(screen.width / 2.0) - (width / 2.0);
- y = parseInt(screen.height / 2.0) - (height / 2.0);
+ b = d.createElement("base");
+ b.setAttribute('href', u);
+ h.appendChild(b);
+ } else {
+ if (u == "" || u == null)
+ b.parentNode.removeChild(b);
+ else
+ b.setAttribute('href', u);
+ }
+ },
- resizable = (args && args['resizable']) ? args['resizable'] : "no";
- scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no";
+ getFocusElement : function() {
+ return this.selection.getFocusElement();
+ },
- if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1)
- url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file'];
- else
- url = template['file'];
+ getSel : function() {
+ return this.selection.getSel();
+ },
- // Replace all args as variables in URL
- for (var name in args) {
- if (typeof(args[name]) == 'function')
- continue;
+ getRng : function() {
+ return this.selection.getRng();
+ },
- url = tinyMCE.replaceVar(url, name, escape(args[name]));
- }
+ triggerSave : function(skip_cleanup, skip_callback) {
+ this.switchSettings();
- if (html) {
- html = tinyMCE.replaceVar(html, "css", this.settings['popups_css']);
- html = tinyMCE.applyTemplate(html, args);
+ tinyMCE.settings['preformatted'] = false;
- var win = window.open("", "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=yes,minimizable=" + resizable + ",modal=yes,width=" + width + ",height=" + height + ",resizable=" + resizable);
- if (win == null) {
- alert(tinyMCELang['lang_popup_blocked']);
- return;
- }
+ // Default to false
+ if (typeof(skip_cleanup) == "undefined")
+ skip_cleanup = false;
- win.document.write(html);
- win.document.close();
- win.resizeTo(width, height);
- win.focus();
- } else {
- if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && resizable != 'yes' && tinyMCE.settings["dialog_type"] == "modal") {
- var features = "resizable:" + resizable
- + ";scroll:"
- + scrollbars + ";status:yes;center:yes;help:no;dialogWidth:"
- + width + "px;dialogHeight:" + height + "px;";
+ // Default to false
+ if (typeof(skip_callback) == "undefined")
+ skip_callback = false;
- window.showModalDialog(url, window, features);
- } else {
- var modal = (resizable == "yes") ? "no" : "yes";
+ tinyMCE._setHTML(this.getDoc(), this.getBody().innerHTML);
- if (tinyMCE.isGecko && tinyMCE.isMac)
- modal = "no";
+ // Remove visual aids when cleanup is disabled
+ if (this.settings['cleanup'] == false) {
+ tinyMCE.handleVisualAid(this.getBody(), true, false, this);
+ tinyMCE._setEventsEnabled(this.getBody(), true);
+ }
- if (template['close_previous'] != "no")
- try {tinyMCE.lastWindow.close();} catch (ex) {}
+ tinyMCE._customCleanup(this, "submit_content_dom", this.contentWindow.document.body);
+ var htm = skip_cleanup ? this.getBody().innerHTML : tinyMCE._cleanupHTML(this, this.getDoc(), this.settings, this.getBody(), tinyMCE.visualAid, true, true);
+ htm = tinyMCE._customCleanup(this, "submit_content", htm);
- var win = window.open(url, "mcePopup" + new Date().getTime(), "top=" + y + ",left=" + x + ",scrollbars=" + scrollbars + ",dialog=" + modal + ",minimizable=" + resizable + ",modal=" + modal + ",width=" + width + ",height=" + height + ",resizable=" + resizable);
- if (win == null) {
- alert(tinyMCELang['lang_popup_blocked']);
- return;
- }
+ if (!skip_callback && tinyMCE.settings['save_callback'] != "")
+ var content = eval(tinyMCE.settings['save_callback'] + "(this.formTargetElementId,htm,this.getBody());");
- if (template['close_previous'] != "no")
- tinyMCE.lastWindow = win;
+ // Use callback content if available
+ if ((typeof(content) != "undefined") && content != null)
+ htm = content;
- eval('try { win.resizeTo(width, height); } catch(e) { }');
+ // Replace some weird entities (Bug: #1056343)
+ htm = tinyMCE.regexpReplace(htm, "&#40;", "(", "gi");
+ htm = tinyMCE.regexpReplace(htm, "&#41;", ")", "gi");
+ htm = tinyMCE.regexpReplace(htm, "&#59;", ";", "gi");
+ htm = tinyMCE.regexpReplace(htm, "&#34;", "&quot;", "gi");
+ htm = tinyMCE.regexpReplace(htm, "&#94;", "^", "gi");
- // Make it bigger if statusbar is forced
- if (tinyMCE.isGecko) {
- if (win.document.defaultView.statusbar.visible)
- win.resizeBy(0, tinyMCE.isMac ? 10 : 24);
- }
+ if (this.formElement)
+ this.formElement.value = htm;
- win.focus();
- }
+ if (tinyMCE.isSafari && this.formElement)
+ this.formElement.innerText = htm;
}
};
-TinyMCE.prototype.closeWindow = function(win) {
- win.close();
-};
-
-TinyMCE.prototype.getVisualAidClass = function(class_name, state) {
- var aidClass = tinyMCE.settings['visual_table_class'];
+/* file:jscripts/tiny_mce/classes/TinyMCE_Cleanup.class.js */
- if (typeof(state) == "undefined")
- state = tinyMCE.settings['visual'];
+TinyMCE_Engine.prototype.cleanupHTMLCode = function(s) {
+ s = s.replace(/<p \/>/gi, '<p>&nbsp;</p>');
+ s = s.replace(/<p>\s*<\/p>/gi, '<p>&nbsp;</p>');
- // Split
- var classNames = new Array();
- var ar = class_name.split(' ');
- for (var i=0; i<ar.length; i++) {
- if (ar[i] == aidClass)
- ar[i] = "";
+ // Open closed tags like <b/> to <b></b>
+// tinyMCE.debug("f:" + s);
+ s = s.replace(/<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|font|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([a-z]*)([^\\|>]*?)\/>/gi, '<$1$2$3></$1$2>');
+// tinyMCE.debug("e:" + s);
- if (ar[i] != "")
- classNames[classNames.length] = ar[i];
- }
+ // Remove trailing space <b > to <b>
+ s = s.replace(new RegExp('\\s+></', 'gi'), '></');
- if (state)
- classNames[classNames.length] = aidClass;
+ // Close tags <img></img> to <img/>
+ s = s.replace(/<(img|br|hr)(.*?)><\/(img|br|hr)>/gi, '<$1$2 />');
- // Glue
- var className = "";
- for (var i=0; i<classNames.length; i++) {
- if (i > 0)
- className += " ";
+ // Weird MSIE bug, <p><hr /></p> breaks runtime?
+ if (tinyMCE.isMSIE)
+ s = s.replace(/<p><hr \/><\/p>/gi, "<hr>");
- className += classNames[i];
- }
+ // Convert relative anchors to absolute URLs ex: #something to file.htm#something
+ if (tinyMCE.getParam('convert_urls'))
+ s = s.replace(new RegExp('(href=\"?)(\\s*?#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#");
- return className;
+ return s;
};
-TinyMCE.prototype.handleVisualAid = function(el, deep, state, inst) {
- if (!el)
- return;
+TinyMCE_Engine.prototype.parseStyle = function(str) {
+ var ar = new Array();
- var tableElement = null;
+ if (str == null)
+ return ar;
- switch (el.nodeName) {
- case "TABLE":
- var oldW = el.style.width;
- var oldH = el.style.height;
- var bo = tinyMCE.getAttrib(el, "border");
+ var st = str.split(';');
- bo = bo == "" || bo == "0" ? true : false;
+ tinyMCE.clearArray(ar);
- tinyMCE.setAttrib(el, "class", tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el, "class"), state && bo));
+ for (var i=0; i<st.length; i++) {
+ if (st[i] == '')
+ continue;
- el.style.width = oldW;
- el.style.height = oldH;
+ var re = new RegExp('^\\s*([^:]*):\\s*(.*)\\s*$');
+ var pa = st[i].replace(re, '$1||$2').split('||');
+//tinyMCE.debug(str, pa[0] + "=" + pa[1], st[i].replace(re, '$1||$2'));
+ if (pa.length == 2)
+ ar[pa[0].toLowerCase()] = pa[1];
+ }
- for (var y=0; y<el.rows.length; y++) {
- for (var x=0; x<el.rows[y].cells.length; x++) {
- var cn = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(el.rows[y].cells[x], "class"), state && bo);
- tinyMCE.setAttrib(el.rows[y].cells[x], "class", cn);
- }
- }
+ return ar;
+};
- break;
+TinyMCE_Engine.prototype.compressStyle = function(ar, pr, sf, res) {
+ var box = new Array();
- case "A":
- var anchorName = tinyMCE.getAttrib(el, "name");
+ box[0] = ar[pr + '-top' + sf];
+ box[1] = ar[pr + '-left' + sf];
+ box[2] = ar[pr + '-right' + sf];
+ box[3] = ar[pr + '-bottom' + sf];
- if (anchorName != '' && state) {
- el.title = anchorName;
- el.className = 'mceItemAnchor';
- } else if (anchorName != '' && !state)
- el.className = '';
+ for (var i=0; i<box.length; i++) {
+ if (box[i] == null)
+ return;
- break;
+ for (var a=0; a<box.length; a++) {
+ if (box[a] != box[i])
+ return;
+ }
}
- if (deep && el.hasChildNodes()) {
- for (var i=0; i<el.childNodes.length; i++)
- tinyMCE.handleVisualAid(el.childNodes[i], deep, state, inst);
- }
+ // They are all the same
+ ar[res] = box[0];
+ ar[pr + '-top' + sf] = null;
+ ar[pr + '-left' + sf] = null;
+ ar[pr + '-right' + sf] = null;
+ ar[pr + '-bottom' + sf] = null;
};
-TinyMCE.prototype.getAttrib = function(elm, name, default_value) {
- if (typeof(default_value) == "undefined")
- default_value = "";
+TinyMCE_Engine.prototype.serializeStyle = function(ar) {
+ var str = "";
- // Not a element
- if (!elm || elm.nodeType != 1)
- return default_value;
+ // Compress box
+ tinyMCE.compressStyle(ar, "border", "", "border");
+ tinyMCE.compressStyle(ar, "border", "-width", "border-width");
+ tinyMCE.compressStyle(ar, "border", "-color", "border-color");
- var v = elm.getAttribute(name);
+ for (var key in ar) {
+ var val = ar[key];
- // Try className for class attrib
- if (name == "class" && !v)
- v = elm.className;
+ if (typeof(val) == 'function')
+ continue;
- // Workaround for a issue with Firefox 1.5rc2+
- if (tinyMCE.isGecko && name == "src" && elm.src != null && elm.src != "")
- v = elm.src;
+ if (key.indexOf('mso-') == 0)
+ continue;
- // Workaround for a issue with Firefox 1.5rc2+
- if (tinyMCE.isGecko && name == "href" && elm.href != null && elm.href != "")
- v = elm.href;
+ if (val != null && val != '') {
+ val = '' + val; // Force string
- if (name == "style" && !tinyMCE.isOpera)
- v = elm.style.cssText;
+ // Fix style URL
+ val = val.replace(new RegExp("url\\(\\'?([^\\']*)\\'?\\)", 'gi'), "url('$1')");
- return (v && v != "") ? v : default_value;
-};
+ // Convert URL
+ if (val.indexOf('url(') != -1 && tinyMCE.getParam('convert_urls')) {
+ var m = new RegExp("url\\('(.*?)'\\)").exec(val);
-TinyMCE.prototype.setAttrib = function(element, name, value, fix_value) {
- if (typeof(value) == "number" && value != null)
- value = "" + value;
+ if (m.length > 1)
+ val = "url('" + eval(tinyMCE.getParam('urlconverter_callback') + "(m[1], null, true);") + "')";
+ }
- if (fix_value) {
- if (value == null)
- value = "";
+ // Force HEX colors
+ if (tinyMCE.getParam("force_hex_style_colors"))
+ val = tinyMCE.convertRGBToHex(val, true);
- var re = new RegExp('[^0-9%]', 'g');
- value = value.replace(re, '');
+ if (val != "url('')")
+ str += key.toLowerCase() + ": " + val + "; ";
+ }
}
- if (name == "style")
- element.style.cssText = value;
-
- if (name == "class")
- element.className = value;
+ if (new RegExp('; $').test(str))
+ str = str.substring(0, str.length - 2);
- if (value != null && value != "" && value != -1)
- element.setAttribute(name, value);
- else
- element.removeAttribute(name);
+ return str;
};
-TinyMCE.prototype.setStyleAttrib = function(elm, name, value) {
- eval('elm.style.' + name + '=value;');
+TinyMCE_Engine.prototype.convertRGBToHex = function(s, k) {
+ if (s.toLowerCase().indexOf('rgb') != -1) {
+ var re = new RegExp("(.*?)rgb\\s*?\\(\\s*?([0-9]+).*?,\\s*?([0-9]+).*?,\\s*?([0-9]+).*?\\)(.*?)", "gi");
+ var rgb = s.replace(re, "$1,$2,$3,$4,$5").split(',');
+ if (rgb.length == 5) {
+ r = parseInt(rgb[1]).toString(16);
+ g = parseInt(rgb[2]).toString(16);
+ b = parseInt(rgb[3]).toString(16);
- // Style attrib deleted
- if (tinyMCE.isMSIE && value == null || value == '') {
- var str = tinyMCE.serializeStyle(tinyMCE.parseStyle(elm.style.cssText));
- elm.style.cssText = str;
- elm.setAttribute("style", str);
+ r = r.length == 1 ? '0' + r : r;
+ g = g.length == 1 ? '0' + g : g;
+ b = b.length == 1 ? '0' + b : b;
+
+ s = "#" + r + g + b;
+
+ if (k)
+ s = rgb[0] + s + rgb[4];
+ }
+ }
+
+ return s;
+};
+
+TinyMCE_Engine.prototype.convertHexToRGB = function(s) {
+ if (s.indexOf('#') != -1) {
+ s = s.replace(new RegExp('[^0-9A-F]', 'gi'), '');
+ return "rgb(" + parseInt(s.substring(0, 2), 16) + "," + parseInt(s.substring(2, 4), 16) + "," + parseInt(s.substring(4, 6), 16) + ")";
}
+
+ return s;
};
-TinyMCE.prototype.convertSpansToFonts = function(doc) {
+TinyMCE_Engine.prototype.convertSpansToFonts = function(doc) {
var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(',');
var h = doc.body.innerHTML;
@@ -3501,7 +3654,7 @@ TinyMCE.prototype.convertSpansToFonts = function(doc) {
}
};
-TinyMCE.prototype.convertFontsToSpans = function(doc) {
+TinyMCE_Engine.prototype.convertFontsToSpans = function(doc) {
var sizes = tinyMCE.getParam('font_size_style_values').replace(/\s+/, '').split(',');
var h = doc.body.innerHTML;
@@ -3548,2534 +3701,2737 @@ TinyMCE.prototype.convertFontsToSpans = function(doc) {
}
};
-/*
-TinyMCE.prototype.applyClassesToFonts = function(doc, size) {
- var f = doc.getElementsByTagName("font");
- for (var i=0; i<f.length; i++) {
- var s = tinyMCE.getAttrib(f[i], "size");
+TinyMCE_Engine.prototype.cleanupAnchors = function(doc) {
+ var i, cn, x, an = doc.getElementsByTagName("a");
- if (s != "")
- tinyMCE.setAttrib(f[i], 'class', "mceItemFont" + s);
+ for (i=0; i<an.length; i++) {
+ if (tinyMCE.getAttrib(an[i], "name") != "" && tinyMCE.getAttrib(an[i], "href") == "") {
+ cn = an[i].childNodes;
+
+ for (x=cn.length-1; x>=0; x--)
+ tinyMCE.insertAfter(cn[x], an[i]);
+ }
}
+};
- if (typeof(size) != "undefined") {
- var css = "";
+TinyMCE_Engine.prototype.getContent = function(editor_id) {
+ var h;
- for (var x=0; x<doc.styleSheets.length; x++) {
- for (var i=0; i<doc.styleSheets[x].rules.length; i++) {
- if (doc.styleSheets[x].rules[i].selectorText == '#mceSpanFonts .mceItemFont' + size) {
- css = doc.styleSheets[x].rules[i].style.cssText;
- break;
- }
- }
+ if (typeof(editor_id) != "undefined")
+ tinyMCE.selectedInstance = tinyMCE.getInstanceById(editor_id);
- if (css != "")
- break;
- }
+ if (tinyMCE.selectedInstance) {
+ h = tinyMCE._cleanupHTML(this.selectedInstance, this.selectedInstance.getDoc(), tinyMCE.settings, this.selectedInstance.getBody(), false, true);
- if (doc.styleSheets[0].rules[0].selectorText == "FONT")
- doc.styleSheets[0].removeRule(0);
+ // When editing always use fonts internaly
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertSpansToFonts(this.selectedInstance.getDoc());
- doc.styleSheets[0].addRule("FONT", css, 0);
+ return h;
}
-};
-*/
-TinyMCE.prototype.setInnerHTML = function(e, h) {
- if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
- e.innerHTML = tinyMCE.uniqueTag + h;
- e.firstChild.removeNode(true);
- } else {
- h = this.fixGeckoBaseHREFBug(1, e, h);
- e.innerHTML = h;
- this.fixGeckoBaseHREFBug(2, e, h);
- }
+ return null;
};
-TinyMCE.prototype.fixGeckoBaseHREFBug = function(m, e, h) {
- if (tinyMCE.isGecko) {
- if (m == 1) {
- h = h.replace(/\ssrc=/gi, " xsrc=");
- h = h.replace(/\shref=/gi, " xhref=");
+TinyMCE_Engine.prototype._fixListElements = function(d) {
+ var nl, x, a = ['ol', 'ul'], i, n, p, r = new RegExp('^(OL|UL)$'), np;
- return h;
- } else {
- if (h.indexOf(' xsrc') != -1) {
- var n = e.getElementsByTagName("img");
- for (var i=0; i<n.length; i++) {
- var xsrc = tinyMCE.getAttrib(n[i], "xsrc");
-
- if (xsrc != "") {
- n[i].src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc);
- n[i].removeAttribute("xsrc");
- }
- }
-
- // Select image form fields
- var n = e.getElementsByTagName("select");
- for (var i=0; i<n.length; i++) {
- var xsrc = tinyMCE.getAttrib(n[i], "xsrc");
+ for (x=0; x<a.length; x++) {
+ nl = d.getElementsByTagName(a[x]);
- if (xsrc != "") {
- n[i].src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc);
- n[i].removeAttribute("xsrc");
- }
- }
+ for (i=0; i<nl.length; i++) {
+ n = nl[i];
+ p = n.parentNode;
- // iframes
- var n = e.getElementsByTagName("iframe");
- for (var i=0; i<n.length; i++) {
- var xsrc = tinyMCE.getAttrib(n[i], "xsrc");
+ if (r.test(p.nodeName)) {
+ np = tinyMCE.prevNode(n, 'LI');
- if (xsrc != "") {
- n[i].src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc);
- n[i].removeAttribute("xsrc");
- }
- }
+ if (!np) {
+ np = d.createElement('li');
+ np.innerHTML = '&nbsp;';
+ np.appendChild(n);
+ p.insertBefore(np, p.firstChild);
+ } else
+ np.appendChild(n);
}
+ }
+ }
+};
- if (h.indexOf(' xhref') != -1) {
- var n = e.getElementsByTagName("a");
- for (var i=0; i<n.length; i++) {
- var xhref = tinyMCE.getAttrib(n[i], "xhref");
+TinyMCE_Engine.prototype._fixTables = function(d) {
+ var nl, i, n, p, np, x, t;
- if (xhref != "") {
- n[i].href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xhref);
- n[i].removeAttribute("xhref");
- }
- }
- }
+ nl = d.getElementsByTagName('table');
+ for (i=0; i<nl.length; i++) {
+ n = nl[i];
+
+ if ((p = tinyMCE.getParentElement(n, 'p,div,h1,h2,h3,h4,h5,h6')) != null) {
+ np = p.cloneNode(false);
+ np.removeAttribute('id');
+
+ t = n;
+
+ while ((n = n.nextSibling))
+ np.appendChild(n);
+
+ tinyMCE.insertAfter(np, p);
+ tinyMCE.insertAfter(t, p);
}
}
-
- return h;
};
-TinyMCE.prototype.getOuterHTML = function(e) {
- if (tinyMCE.isMSIE)
- return e.outerHTML;
+TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual, on_save, on_submit) {
+ var h, d, t1, t2, t3, t4, t5, c, s;
- var d = e.ownerDocument.createElement("body");
- d.appendChild(e);
- return d.innerHTML;
-};
+ if (!tinyMCE.getParam('cleanup'))
+ return elm.innerHTML;
-TinyMCE.prototype.setOuterHTML = function(doc, e, h) {
- if (tinyMCE.isMSIE) {
- e.outerHTML = h;
- return;
- }
+ on_save = typeof(on_save) == 'undefined' ? false : on_save;
- var d = e.ownerDocument.createElement("body");
- d.innerHTML = h;
- e.parentNode.replaceChild(d.firstChild, e);
-};
+ c = inst.cleanup;
+ s = inst.settings;
+ d = c.settings.debug;
+
+ if (d)
+ t1 = new Date().getTime();
+
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertFontsToSpans(doc);
-TinyMCE.prototype.insertAfter = function(nc, rc){
- if (rc.nextSibling)
- rc.parentNode.insertBefore(nc, rc.nextSibling);
+ if (tinyMCE.getParam("fix_list_elements"))
+ tinyMCE._fixListElements(doc);
+
+ if (tinyMCE.getParam("fix_table_elements"))
+ tinyMCE._fixTables(doc);
+
+ // Call custom cleanup code
+ tinyMCE._customCleanup(inst, on_save ? "get_from_editor_dom" : "insert_to_editor_dom", doc.body);
+
+ if (d)
+ t2 = new Date().getTime();
+
+ c.settings.on_save = on_save;
+ //for (var i=0; i<100; i++)
+
+ c.idCount = 0;
+ c.serializationId++;
+ c.serializedNodes = new Array();
+ c.sourceIndex = -1;
+
+ if (s.cleanup_serializer == "xml")
+ h = c.serializeNodeAsXML(elm);
else
- rc.parentNode.appendChild(nc);
-};
+ h = c.serializeNodeAsHTML(elm);
+
+ if (d)
+ t3 = new Date().getTime();
+
+ // Post processing
+ h = h.replace(/<\/?(body|head|html)[^>]*>/gi, '');
+ h = h.replace(new RegExp(' (rowspan="1"|colspan="1")', 'g'), '');
+ h = h.replace(/<p><hr \/><\/p>/g, '<hr />');
+ h = h.replace(/<p>(&nbsp;|&#160;)<\/p><hr \/><p>(&nbsp;|&#160;)<\/p>/g, '<hr />');
+ h = h.replace(/<td>\s*<br \/>\s*<\/td>/g, '<td>&nbsp;</td>');
+ h = h.replace(/<p>\s*<br \/>\s*<\/p>/g, '<p>&nbsp;</p>');
+ h = h.replace(/<p>\s*(&nbsp;|&#160;)\s*<br \/>\s*(&nbsp;|&#160;)\s*<\/p>/g, '<p>&nbsp;</p>');
+ h = h.replace(/<p>\s*(&nbsp;|&#160;)\s*<br \/>\s*<\/p>/g, '<p>&nbsp;</p>');
+ h = h.replace(/<p>\s*<br \/>\s*&nbsp;\s*<\/p>/g, '<p>&nbsp;</p>');
+ h = h.replace(/<a>(.*?)<\/a>/g, '$1');
+ h = h.replace(/<p([^>]*)>\s*<\/p>/g, '<p$1>&nbsp;</p>');
+
+ // Clean body
+ if (/^\s*(<br \/>|<p>&nbsp;<\/p>|<p>&#160;<\/p>|<p><\/p>)\s*$/.test(h))
+ h = '';
+
+ // If preformatted
+ if (s.preformatted) {
+ h = h.replace(/^<pre>/, '');
+ h = h.replace(/<\/pre>$/, '');
+ h = '<pre>' + h + '</pre>';
+ }
+
+ // Gecko specific processing
+ if (tinyMCE.isGecko) {
+ h = h.replace(/<o:p _moz-userdefined="" \/>/g, '');
+ h = h.replace(/<td([^>]*)>\s*<br \/>\s*<\/td>/g, '<td$1>&nbsp;</td>');
+ }
-TinyMCE.prototype.cleanupAnchors = function(doc) {
- var an = doc.getElementsByTagName("a");
+ if (s.force_br_newlines)
+ h = h.replace(/<p>(&nbsp;|&#160;)<\/p>/g, '<br />');
- for (var i=0; i<an.length; i++) {
- if (tinyMCE.getAttrib(an[i], "name") != "") {
- var cn = an[i].childNodes;
- for (var x=cn.length-1; x>=0; x--)
- tinyMCE.insertAfter(cn[x], an[i]);
- }
+ // Call custom cleanup code
+ h = tinyMCE._customCleanup(inst, on_save ? "get_from_editor" : "insert_to_editor", h);
+
+ // Remove internal classes
+ if (on_save) {
+ h = h.replace(new RegExp(' ?(mceItem[a-zA-Z0-9]*|' + s.visual_table_class + ')', 'g'), '');
+ h = h.replace(new RegExp(' ?class=""', 'g'), '');
}
+
+ if (s.remove_linebreaks && !c.settings.indent)
+ h = h.replace(/\n|\r/g, ' ');
+
+ if (d)
+ t4 = new Date().getTime();
+
+ if (on_save && c.settings.indent)
+ h = c.formatHTML(h);
+
+ // If encoding (not recommended option)
+ if (on_submit && (s.encoding == "xml" || s.encoding == "html"))
+ h = c.xmlEncode(h);
+
+ if (d)
+ t5 = new Date().getTime();
+
+ if (c.settings.debug)
+ tinyMCE.debug("Cleanup in ms: Pre=" + (t2-t1) + ", Serialize: " + (t3-t2) + ", Post: " + (t4-t3) + ", Format: " + (t5-t4) + ", Sum: " + (t5-t1) + ".");
+
+ return h;
};
-TinyMCE.prototype._setHTML = function(doc, html_content) {
- // Force closed anchors open
- //html_content = html_content.replace(new RegExp('<a(.*?)/>', 'gi'), '<a$1></a>');
+function TinyMCE_Cleanup() {
+ this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
+ this.rules = tinyMCE.clearArray(new Array());
+
+ // Default config
+ this.settings = {
+ indent_elements : 'head,table,tbody,thead,tfoot,form,tr,ul,ol,blockquote,object',
+ newline_before_elements : 'h1,h2,h3,h4,h5,h6,pre,address,div,ul,ol,li,meta,option,area,title,link,base,script,td',
+ newline_after_elements : 'br,hr,p,pre,address,div,ul,ol,meta,option,area,link,base,script',
+ newline_before_after_elements : 'html,head,body,table,thead,tbody,tfoot,tr,form,ul,ol,blockquote,p,object,param,hr,div',
+ indent_char : '\t',
+ indent_levels : 1,
+ entity_encoding : 'raw',
+ valid_elements : '*[*]',
+ entities : '',
+ url_converter : '',
+ invalid_elements : '',
+ verify_html : false
+ };
+
+ this.vElements = tinyMCE.clearArray(new Array());
+ this.vElementsRe = '';
+ this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|BUTTON)$/;
+ this.codeElementsRe = /^(SCRIPT|STYLE)$/;
+ this.serializationId = 0;
+ this.mceAttribs = {
+ href : 'mce_href',
+ src : 'mce_src',
+ type : 'mce_type'
+ };
+}
+
+TinyMCE_Cleanup.prototype = {
+ init : function(s) {
+ var n, a, i, ir, or, st;
+
+ for (n in s)
+ this.settings[n] = s[n];
+
+ // Setup code formating
+ s = this.settings;
+
+ // Setup regexps
+ this.inRe = this._arrayToRe(s.indent_elements.split(','), '', '^<(', ')[^>]*');
+ this.ouRe = this._arrayToRe(s.indent_elements.split(','), '', '^<\\/(', ')[^>]*');
+ this.nlBeforeRe = this._arrayToRe(s.newline_before_elements.split(','), 'gi', '<(', ')([^>]*)>');
+ this.nlAfterRe = this._arrayToRe(s.newline_after_elements.split(','), 'gi', '<(', ')([^>]*)>');
+ this.nlBeforeAfterRe = this._arrayToRe(s.newline_before_after_elements.split(','), 'gi', '<(\\/?)(', ')([^>]*)>');
+
+ if (s.invalid_elements != '')
+ this.iveRe = this._arrayToRe(s.invalid_elements.toUpperCase().split(','), 'g', '^(', ')$');
+ else
+ this.iveRe = null;
- html_content = tinyMCE.cleanupHTMLCode(html_content);
+ // Setup separator
+ st = '';
+ for (i=0; i<s.indent_levels; i++)
+ st += s.indent_char;
- // Try innerHTML if it fails use pasteHTML in MSIE
- try {
- tinyMCE.setInnerHTML(doc.body, html_content);
- } catch (e) {
- if (this.isMSIE)
- doc.body.createTextRange().pasteHTML(html_content);
- }
+ this.inStr = st;
- // Content duplication bug fix
- if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) {
- // Remove P elements in P elements
- var paras = doc.getElementsByTagName("P");
- for (var i=0; i<paras.length; i++) {
- var node = paras[i];
- while ((node = node.parentNode) != null) {
- if (node.nodeName == "P")
- node.outerHTML = node.innerHTML;
- }
+ // If verify_html if false force *[*]
+ if (!s.verify_html) {
+ s.valid_elements = '*[*]';
+ s.extended_valid_elements = '';
}
- // Content duplication bug fix (Seems to be word crap)
- var html = doc.body.innerHTML;
+ this.fillStr = s.entity_encoding == "named" ? "&nbsp;" : "&#160;";
+ this.idCount = 0;
+ },
- if (html.indexOf('="mso') != -1) {
- for (var i=0; i<doc.body.all.length; i++) {
- var el = doc.body.all[i];
- el.removeAttribute("className","",0);
- el.removeAttribute("style","",0);
- }
+ addRuleStr : function(s) {
+ var r = this.parseRuleStr(s);
+ var n;
- html = doc.body.innerHTML;
- html = tinyMCE.regexpReplace(html, "<o:p><\/o:p>", "<br />");
- html = tinyMCE.regexpReplace(html, "<o:p>&nbsp;<\/o:p>", "");
- html = tinyMCE.regexpReplace(html, "<st1:.*?>", "");
- html = tinyMCE.regexpReplace(html, "<p><\/p>", "");
- html = tinyMCE.regexpReplace(html, "<p><\/p>\r\n<p><\/p>", "");
- html = tinyMCE.regexpReplace(html, "<p>&nbsp;<\/p>", "<br />");
- html = tinyMCE.regexpReplace(html, "<p>\s*(<p>\s*)?", "<p>");
- html = tinyMCE.regexpReplace(html, "<\/p>\s*(<\/p>\s*)?", "</p>");
+ for (n in r) {
+ if (r[n])
+ this.rules[n] = r[n];
}
- // Always set the htmlText output
- tinyMCE.setInnerHTML(doc.body, html);
- }
+ this.vElements = tinyMCE.clearArray(new Array());
- tinyMCE.cleanupAnchors(doc);
+ for (n in this.rules) {
+ if (this.rules[n])
+ this.vElements[this.vElements.length] = this.rules[n].tag;
+ }
- if (tinyMCE.getParam("convert_fonts_to_spans"))
- tinyMCE.convertSpansToFonts(doc);
-};
+ this.vElementsRe = this._arrayToRe(this.vElements, '');
+ },
-TinyMCE.prototype.getImageSrc = function(str) {
- var pos = -1;
+ parseRuleStr : function(s) {
+ var ta, p, r, a, i, x, px, t, tn, y, av, or = tinyMCE.clearArray(new Array()), dv;
- if (!str)
- return "";
+ if (s == null || s.length == 0)
+ return or;
- if ((pos = str.indexOf('this.src=')) != -1) {
- var src = str.substring(pos + 10);
+ ta = s.split(',');
+ for (x=0; x<ta.length; x++) {
+ s = ta[x];
+ if (s.length == 0)
+ continue;
- src = src.substring(0, src.indexOf('\''));
+ // Split tag/attrs
+ p = this.split(/\[|\]/, s);
+ if (p == null || p.length < 1)
+ t = s.toUpperCase();
+ else
+ t = p[0].toUpperCase();
+
+ // Handle all tag names
+ tn = this.split('/', t);
+ for (y=0; y<tn.length; y++) {
+ r = {};
+
+ r.tag = tn[y];
+ r.forceAttribs = null;
+ r.defaultAttribs = null;
+ r.validAttribValues = null;
+
+ // Handle prefixes
+ px = r.tag.charAt(0);
+ r.forceOpen = px == '+';
+ r.removeEmpty = px == '-';
+ r.fill = px == '#';
+ r.tag = r.tag.replace(/\+|-|#/g, '');
+ r.oTagName = tn[0].replace(/\+|-|#/g, '').toLowerCase();
+ r.isWild = new RegExp('\\*|\\?|\\+', 'g').test(r.tag);
+ r.validRe = new RegExp(this._wildcardToRe('^' + r.tag + '$'));
+
+ // Setup valid attributes
+ if (p.length > 1) {
+ r.vAttribsRe = '^(';
+ a = this.split(/\|/, p[1]);
+
+ for (i=0; i<a.length; i++) {
+ t = a[i];
+
+ av = /(=|:|<)(.*?)$/.exec(t);
+ t = t.replace(/(=|:|<).*?$/, '');
+ if (av && av.length > 0) {
+ if (av[0].charAt(0) == ':') {
+ if (!r.forceAttribs)
+ r.forceAttribs = tinyMCE.clearArray(new Array());
+
+ r.forceAttribs[t.toLowerCase()] = av[0].substring(1);
+ } else if (av[0].charAt(0) == '=') {
+ if (!r.defaultAttribs)
+ r.defaultAttribs = tinyMCE.clearArray(new Array());
+
+ dv = av[0].substring(1);
+
+ r.defaultAttribs[t.toLowerCase()] = dv == "" ? "mce_empty" : dv;
+ } else if (av[0].charAt(0) == '<') {
+ if (!r.validAttribValues)
+ r.validAttribValues = tinyMCE.clearArray(new Array());
+
+ r.validAttribValues[t.toLowerCase()] = this._arrayToRe(this.split('?', av[0].substring(1)), '');
+ }
+ }
- return src;
- }
+ r.vAttribsRe += '' + t.toLowerCase() + (i != a.length - 1 ? '|' : '');
- return "";
-};
+ a[i] = t.toLowerCase();
+ }
-TinyMCE.prototype._getElementById = function(element_id) {
- var elm = document.getElementById(element_id);
- if (!elm) {
- // Check for element in forms
- for (var j=0; j<document.forms.length; j++) {
- for (var k=0; k<document.forms[j].elements.length; k++) {
- if (document.forms[j].elements[k].name == element_id) {
- elm = document.forms[j].elements[k];
- break;
+ r.vAttribsRe += ')$';
+ r.vAttribsRe = this._wildcardToRe(r.vAttribsRe);
+ r.vAttribsReIsWild = new RegExp('\\*|\\?|\\+', 'g').test(r.vAttribsRe);
+ r.vAttribsRe = new RegExp(r.vAttribsRe);
+ r.vAttribs = a.reverse();
+
+ //tinyMCE.debug(r.tag, r.oTagName, r.vAttribsRe, r.vAttribsReWC);
+ } else {
+ r.vAttribsRe = '';
+ r.vAttribs = tinyMCE.clearArray(new Array());
+ r.vAttribsReIsWild = false;
}
+
+ or[r.tag] = r;
}
}
- }
- return elm;
-};
+ return or;
+ },
-TinyMCE.prototype.getEditorId = function(form_element) {
- var inst = this.getInstanceById(form_element);
- if (!inst)
- return null;
+ serializeNodeAsXML : function(n) {
+ var s, b;
- return inst.editorId;
-};
+ if (!this.xmlDoc) {
+ if (this.isMSIE) {
+ try {this.xmlDoc = new ActiveXObject('MSXML2.DOMDocument');} catch (e) {}
-TinyMCE.prototype.getInstanceById = function(editor_id) {
- var inst = this.instances[editor_id];
- if (!inst) {
- for (var n in tinyMCE.instances) {
- var instance = tinyMCE.instances[n];
- if (!tinyMCE.isInstance(instance))
- continue;
+ if (!this.xmlDoc)
+ try {this.xmlDoc = new ActiveXObject('Microsoft.XmlDom');} catch (e) {}
+ } else
+ this.xmlDoc = document.implementation.createDocument('', '', null);
- if (instance.formTargetElementId == editor_id) {
- inst = instance;
- break;
- }
+ if (!this.xmlDoc)
+ alert("Error XML Parser could not be found.");
}
- }
- return inst;
-};
+ if (this.xmlDoc.firstChild)
+ this.xmlDoc.removeChild(this.xmlDoc.firstChild);
-TinyMCE.prototype.queryInstanceCommandValue = function(editor_id, command) {
- var inst = tinyMCE.getInstanceById(editor_id);
- if (inst)
- return inst.queryCommandValue(command);
+ b = this.xmlDoc.createElement("html");
+ b = this.xmlDoc.appendChild(b);
- return false;
-};
+ this._convertToXML(n, b);
-TinyMCE.prototype.queryInstanceCommandState = function(editor_id, command) {
- var inst = tinyMCE.getInstanceById(editor_id);
- if (inst)
- return inst.queryCommandState(command);
+ if (this.isMSIE)
+ return this.xmlDoc.xml;
+ else
+ return new XMLSerializer().serializeToString(this.xmlDoc);
+ },
- return null;
-};
+ _convertToXML : function(n, xn) {
+ var xd, el, i, l, cn, at, no, hc = false;
-TinyMCE.prototype.setWindowArg = function(name, value) {
- this.windowArgs[name] = value;
-};
+ if (this._isDuplicate(n))
+ return;
-TinyMCE.prototype.getWindowArg = function(name, default_value) {
- return (typeof(this.windowArgs[name]) == "undefined") ? default_value : this.windowArgs[name];
-};
+ xd = this.xmlDoc;
-TinyMCE.prototype.getCSSClasses = function(editor_id, doc) {
- var output = new Array();
+ switch (n.nodeType) {
+ case 1: // Element
+ hc = n.hasChildNodes();
- // Is cached, use that
- if (typeof(tinyMCE.cssClasses) != "undefined")
- return tinyMCE.cssClasses;
+ el = xd.createElement(n.nodeName.toLowerCase());
- if (typeof(editor_id) == "undefined" && typeof(doc) == "undefined") {
- var instance;
+ at = n.attributes;
+ for (i=at.length-1; i>-1; i--) {
+ no = at[i];
- for (var instanceName in tinyMCE.instances) {
- instance = tinyMCE.instances[instanceName];
- if (!tinyMCE.isInstance(instance))
- continue;
+ if (no.specified && no.nodeValue)
+ el.setAttribute(no.nodeName.toLowerCase(), no.nodeValue);
+ }
- break;
+ if (!hc && !this.closeElementsRe.test(n.nodeName))
+ el.appendChild(xd.createTextNode(""));
+
+ xn = xn.appendChild(el);
+ break;
+
+ case 3: // Text
+ xn.appendChild(xd.createTextNode(n.nodeValue));
+ return;
+
+ case 8: // Comment
+ xn.appendChild(xd.createComment(n.nodeValue));
+ return;
}
- doc = instance.getDoc();
- }
+ if (hc) {
+ cn = n.childNodes;
- if (typeof(doc) == "undefined") {
- var instance = tinyMCE.getInstanceById(editor_id);
- doc = instance.getDoc();
- }
+ for (i=0, l=cn.length; i<l; i++)
+ this._convertToXML(cn[i], xn);
+ }
+ },
- if (doc) {
- var styles = tinyMCE.isMSIE ? doc.styleSheets : doc.styleSheets;
+ serializeNodeAsHTML : function(n) {
+ var en, no, h = '', i, l, r, cn, va = false, f = false, at, hc;
- if (styles && styles.length > 0) {
- for (var x=0; x<styles.length; x++) {
- var csses = null;
+ this._setupRules(); // Will initialize cleanup rules
- // Just ignore any errors
- eval("try {var csses = tinyMCE.isMSIE ? doc.styleSheets(" + x + ").rules : doc.styleSheets[" + x + "].cssRules;} catch(e) {}");
- if (!csses)
- return new Array();
+ if (this._isDuplicate(n))
+ return '';
- for (var i=0; i<csses.length; i++) {
- var selectorText = csses[i].selectorText;
+ switch (n.nodeType) {
+ case 1: // Element
+ hc = n.hasChildNodes();
- // Can be multiple rules per selector
- if (selectorText) {
- var rules = selectorText.split(',');
- for (var c=0; c<rules.length; c++) {
- // Invalid rule
- if (rules[c].indexOf(' ') != -1 || rules[c].indexOf(':') != -1 || rules[c].indexOf('mceItem') != -1)
- continue;
+ // MSIE sometimes produces <//tag>
+ if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && n.nodeName.indexOf('/') != -1)
+ break;
- if (rules[c] == "." + tinyMCE.settings['visual_table_class'])
- continue;
+ if (this.vElementsRe.test(n.nodeName) && (!this.iveRe || !this.iveRe.test(n.nodeName))) {
+ va = true;
- // Is class rule
- if (rules[c].indexOf('.') != -1) {
- //alert(rules[c].substring(rules[c].indexOf('.')));
- output[output.length] = rules[c].substring(rules[c].indexOf('.')+1);
+ r = this.rules[n.nodeName];
+ if (!r) {
+ at = this.rules;
+ for (no in at) {
+ if (at[no] && at[no].validRe.test(n.nodeName)) {
+ r = at[no];
+ break;
}
}
}
+
+ en = r.isWild ? n.nodeName.toLowerCase() : r.oTagName;
+ f = r.fill;
+
+ if (r.removeEmpty && !hc)
+ return "";
+
+ h += '<' + en;
+
+ if (r.vAttribsReIsWild) {
+ // Serialize wildcard attributes
+ at = n.attributes;
+ for (i=at.length-1; i>-1; i--) {
+ no = at[i];
+ if (no.specified && r.vAttribsRe.test(no.nodeName))
+ h += this._serializeAttribute(n, r, no.nodeName);
+ }
+ } else {
+ // Serialize specific attributes
+ for (i=r.vAttribs.length-1; i>-1; i--)
+ h += this._serializeAttribute(n, r, r.vAttribs[i]);
+ }
+
+ // Serialize mce_ atts
+ if (!this.settings.on_save) {
+ at = this.mceAttribs;
+
+ for (no in at) {
+ if (at[no])
+ h += this._serializeAttribute(n, r, at[no]);
+ }
+ }
+
+ // Close these
+ if (this.closeElementsRe.test(n.nodeName))
+ return h + ' />';
+
+ h += '>';
+
+ if (this.isMSIE && this.codeElementsRe.test(n.nodeName))
+ h += n.innerHTML;
}
- }
+ break;
+
+ case 3: // Text
+ if (n.parentNode && this.codeElementsRe.test(n.parentNode.nodeName))
+ return this.isMSIE ? '' : n.nodeValue;
+
+ return this.xmlEncode(n.nodeValue);
+
+ case 8: // Comment
+ return "<!--" + this._trimComment(n.nodeValue) + "-->";
}
- }
- // Cache em
- if (output.length > 0)
- tinyMCE.cssClasses = output;
+ if (hc) {
+ cn = n.childNodes;
- return output;
-};
+ for (i=0, l=cn.length; i<l; i++)
+ h += this.serializeNodeAsHTML(cn[i]);
+ }
-TinyMCE.prototype.regexpReplace = function(in_str, reg_exp, replace_str, opts) {
- if (in_str == null)
- return in_str;
+ // Fill empty nodes
+ if (f && !hc)
+ h += this.fillStr;
- if (typeof(opts) == "undefined")
- opts = 'g';
+ // End element
+ if (va)
+ h += '</' + en + '>';
- var re = new RegExp(reg_exp, opts);
- return in_str.replace(re, replace_str);
-};
+ return h;
+ },
-TinyMCE.prototype.trim = function(str) {
- return str.replace(/^\s*|\s*$/g, "");
-};
+ _serializeAttribute : function(n, r, an) {
+ var av = '', t, os = this.settings.on_save;
-TinyMCE.prototype.cleanupEventStr = function(str) {
- str = "" + str;
- str = str.replace('function anonymous()\n{\n', '');
- str = str.replace('\n}', '');
- str = str.replace(/^return true;/gi, ''); // Remove event blocker
+ if (os && (an.indexOf('mce_') == 0 || an.indexOf('_moz') == 0))
+ return '';
- return str;
-};
+ if (os && this.mceAttribs[an])
+ av = this._getAttrib(n, this.mceAttribs[an]);
-TinyMCE.prototype.getAbsPosition = function(node) {
- var pos = new Object();
+ if (av.length == 0)
+ av = this._getAttrib(n, an);
- pos.absLeft = pos.absTop = 0;
+ if (av.length == 0 && r.defaultAttribs && (t = r.defaultAttribs[an])) {
+ av = t;
- var parentNode = node;
- while (parentNode) {
- pos.absLeft += parentNode.offsetLeft;
- pos.absTop += parentNode.offsetTop;
+ if (av == "mce_empty")
+ return " " + an + '=""';
+ }
- parentNode = parentNode.offsetParent;
- }
+ if (r.forceAttribs && (t = r.forceAttribs[an]))
+ av = t;
- return pos;
-};
+ if (os && av.length != 0 && this.settings.url_converter.length != 0 && /^(src|href|longdesc)$/.test(an))
+ av = eval(this.settings.url_converter + '(this, n, av)');
-TinyMCE.prototype.getControlHTML = function(control_name) {
- var themePlugins = tinyMCE.getParam('plugins', '', true, ',');
- var templateFunction;
+ if (av.length != 0 && r.validAttribValues && r.validAttribValues[an] && !r.validAttribValues[an].test(av))
+ return "";
- // Is it defined in any plugins
- for (var i=themePlugins.length; i>=0; i--) {
- templateFunction = 'TinyMCE_' + themePlugins[i] + "_getControlHTML";
- if (eval("typeof(" + templateFunction + ")") != 'undefined') {
- var html = eval(templateFunction + "('" + control_name + "');");
- if (html != "")
- return tinyMCE.replaceVar(html, "pluginurl", tinyMCE.baseURL + "/plugins/" + themePlugins[i]);
- }
- }
+ if (av.length != 0 && av == "{$uid}")
+ av = "uid_" + (this.idCount++);
- return eval('TinyMCE_' + tinyMCE.settings['theme'] + "_getControlHTML" + "('" + control_name + "');");
-};
+ if (av.length != 0)
+ return " " + an + "=" + '"' + this.xmlEncode(av) + '"';
-TinyMCE.prototype._themeExecCommand = function(editor_id, element, command, user_interface, value) {
- var themePlugins = tinyMCE.getParam('plugins', '', true, ',');
- var templateFunction;
+ return "";
+ },
+
+ formatHTML : function(h) {
+ var s = this.settings, p = '', i = 0, li = 0, o = '', l;
+
+ h = h.replace(/\r/g, ''); // Windows sux, isn't carriage return a thing of the past :)
+ h = '\n' + h;
+ h = h.replace(new RegExp('\\n\\s+', 'gi'), '\n'); // Remove previous formatting
+ h = h.replace(this.nlBeforeRe, '\n<$1$2>');
+ h = h.replace(this.nlAfterRe, '<$1$2>\n');
+ h = h.replace(this.nlBeforeAfterRe, '\n<$1$2$3>\n');
+ h += '\n';
+
+ //tinyMCE.debug(h);
+
+ while ((i = h.indexOf('\n', i + 1)) != -1) {
+ if ((l = h.substring(li + 1, i)).length != 0) {
+ if (this.ouRe.test(l) && p.length >= s.indent_levels)
+ p = p.substring(s.indent_levels);
+
+ o += p + l + '\n';
+
+ if (this.inRe.test(l))
+ p += this.inStr;
+ }
- // Is it defined in any plugins
- for (var i=themePlugins.length; i>=0; i--) {
- templateFunction = 'TinyMCE_' + themePlugins[i] + "_execCommand";
- if (eval("typeof(" + templateFunction + ")") != 'undefined') {
- if (eval(templateFunction + "(editor_id, element, command, user_interface, value);"))
- return true;
+ li = i;
}
- }
- // Theme funtion
- templateFunction = 'TinyMCE_' + tinyMCE.settings['theme'] + "_execCommand";
- if (eval("typeof(" + templateFunction + ")") != 'undefined')
- return eval(templateFunction + "(editor_id, element, command, user_interface, value);");
+ //tinyMCE.debug(h);
- // Pass to normal
- return false;
-};
+ return o;
+ },
-TinyMCE.prototype._getThemeFunction = function(suffix, skip_plugins) {
- if (skip_plugins)
- return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix;
+ xmlEncode : function(s) {
+ var i, l, e, o = '', c;
- var themePlugins = tinyMCE.getParam('plugins', '', true, ',');
- var templateFunction;
+ this._setupEntities(); // Will intialize lookup table
- // Is it defined in any plugins
- for (var i=themePlugins.length; i>=0; i--) {
- templateFunction = 'TinyMCE_' + themePlugins[i] + suffix;
- if (eval("typeof(" + templateFunction + ")") != 'undefined')
- return templateFunction;
- }
+ switch (this.settings.entity_encoding) {
+ case "raw":
+ return tinyMCE.xmlEncode(s);
- return 'TinyMCE_' + tinyMCE.settings['theme'] + suffix;
-};
+ case "named":
+ for (i=0, l=s.length; i<l; i++) {
+ c = s.charCodeAt(i);
+ e = this.entities[c];
+ // &apos; is not working in MSIE
+ // More info: http://www.w3.org/TR/xhtml1/#C_16
+ if (c == 39) {
+ o += "&#39;";
+ continue;
+ }
-TinyMCE.prototype.isFunc = function(func_name) {
- if (func_name == null || func_name == "")
- return false;
+ if (e && e != '')
+ o += '&' + e + ';';
+ else
+ o += String.fromCharCode(c);
+ }
- return eval("typeof(" + func_name + ")") != "undefined";
-};
+ return o;
-TinyMCE.prototype.exec = function(func_name, args) {
- var str = func_name + '(';
+ case "numeric":
+ for (i=0, l=s.length; i<l; i++) {
+ c = s.charCodeAt(i);
- // Add all arguments
- for (var i=3; i<args.length; i++) {
- str += 'args[' + i + ']';
+ if (c > 127 || c == 60 || c == 62 || c == 38 || c == 39 || c == 34)
+ o += '&#' + c + ";";
+ else
+ o += String.fromCharCode(c);
+ }
- if (i < args.length-1)
- str += ',';
- }
+ return o;
+ }
- str += ');';
+ return s;
+ },
- return eval(str);
-};
+ split : function(re, s) {
+ var c = s.split(re);
+ var i, l, o = new Array();
-TinyMCE.prototype.executeCallback = function(param, suffix, mode) {
- switch (mode) {
- // No chain
- case 0:
- var state = false;
-
- // Execute each plugin callback
- var plugins = tinyMCE.getParam('plugins', '', true, ',');
- for (var i=0; i<plugins.length; i++) {
- var func = "TinyMCE_" + plugins[i] + suffix;
- if (tinyMCE.isFunc(func)) {
- tinyMCE.exec(func, this.executeCallback.arguments);
- state = true;
- }
- }
+ for (i=0, l=c.length; i<l; i++) {
+ if (c[i] != '')
+ o[i] = c[i];
+ }
- // Execute theme callback
- var func = 'TinyMCE_' + tinyMCE.settings['theme'] + suffix;
- if (tinyMCE.isFunc(func)) {
- tinyMCE.exec(func, this.executeCallback.arguments);
- state = true;
- }
+ return o;
+ },
- // Execute settings callback
- var func = tinyMCE.getParam(param, '');
- if (tinyMCE.isFunc(func)) {
- tinyMCE.exec(func, this.executeCallback.arguments);
- state = true;
- }
+ _trimComment : function(s) {
+ // Make xsrc, xhref as src and href again
+ if (tinyMCE.isGecko) {
+ s = s.replace(/\sxsrc=/gi, " src=");
+ s = s.replace(/\sxhref=/gi, " href=");
+ }
- return state;
+ // Remove mce_src, mce_href
+ s = s.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), "");
+ s = s.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), "");
- // Chain mode
- case 1:
- // Execute each plugin callback
- var plugins = tinyMCE.getParam('plugins', '', true, ',');
- for (var i=0; i<plugins.length; i++) {
- var func = "TinyMCE_" + plugins[i] + suffix;
- if (tinyMCE.isFunc(func)) {
- if (tinyMCE.exec(func, this.executeCallback.arguments))
- return true;
- }
- }
+ return s;
+ },
- // Execute theme callback
- var func = 'TinyMCE_' + tinyMCE.settings['theme'] + suffix;
- if (tinyMCE.isFunc(func)) {
- if (tinyMCE.exec(func, this.executeCallback.arguments))
- return true;
- }
+ _getAttrib : function(e, n, d) {
+ if (typeof(d) == "undefined")
+ d = "";
- // Execute settings callback
- var func = tinyMCE.getParam(param, '');
- if (tinyMCE.isFunc(func)) {
- if (tinyMCE.exec(func, this.executeCallback.arguments))
- return true;
- }
+ if (!e || e.nodeType != 1)
+ return d;
- return false;
- }
-};
+ var v = e.getAttribute(n, 0);
-TinyMCE.prototype.debug = function() {
- var msg = "";
+ if (n == "class" && !v)
+ v = e.className;
- var elm = document.getElementById("tinymce_debug");
- if (!elm) {
- var debugDiv = document.createElement("div");
- debugDiv.setAttribute("className", "debugger");
- debugDiv.className = "debugger";
- debugDiv.innerHTML = '\
- Debug output:\
- <textarea id="tinymce_debug" style="width: 100%; height: 300px" wrap="nowrap"></textarea>';
+ if (this.isMSIE && n == "http-equiv")
+ v = e.httpEquiv;
- document.body.appendChild(debugDiv);
- elm = document.getElementById("tinymce_debug");
- }
+ if (n == "style" && !tinyMCE.isOpera)
+ v = e.style.cssText;
- var args = this.debug.arguments;
- for (var i=0; i<args.length; i++) {
- msg += args[i];
- if (i<args.length-1)
- msg += ', ';
- }
+ if (n == 'style')
+ v = tinyMCE.serializeStyle(tinyMCE.parseStyle(v));
- elm.value += msg + "\n";
-};
+ if (this.settings.on_save && n.indexOf('on') != -1 && this.settings.on_save && v && v != "")
+ v = tinyMCE.cleanupEventStr(v);
-// TinyMCEControl
-function TinyMCEControl(settings) {
- // Undo levels
- this.undoLevels = new Array();
- this.undoIndex = 0;
- this.typingUndoIndex = -1;
- this.undoRedo = true;
- this.isTinyMCEControl = true;
+ return (v && v != "") ? '' + v : d;
+ },
- // Default settings
- this.settings = settings;
- this.settings['theme'] = tinyMCE.getParam("theme", "default");
- this.settings['width'] = tinyMCE.getParam("width", -1);
- this.settings['height'] = tinyMCE.getParam("height", -1);
-};
+ _urlConverter : function(c, n, v) {
+ if (!c.settings.on_save)
+ return tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings.base_href, v);
+ else if (tinyMCE.getParam('convert_urls'))
+ return eval(tinyMCE.settings.urlconverter_callback + "(v, n, true);");
-TinyMCEControl.prototype.repaint = function() {
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
- return;
+ return v;
+ },
- // Ugly mozilla hack to remove ghost resize handles
- try {
- this.getBody().style.display = 'none';
- this.getDoc().execCommand('selectall', false, null);
- this.getSel().collapseToStart();
- this.getBody().style.display = 'block';
- } catch (ex) {
- // Could I care less!!
- }
-};
+ _arrayToRe : function(a, op, be, af) {
+ var i, r;
-TinyMCEControl.prototype.switchSettings = function() {
- if (tinyMCE.configs.length > 1 && tinyMCE.currentConfig != this.settings['index']) {
- tinyMCE.settings = this.settings;
- tinyMCE.currentConfig = this.settings['index'];
- }
-};
+ op = typeof(op) == "undefined" ? "gi" : op;
+ be = typeof(be) == "undefined" ? "^(" : be;
+ af = typeof(af) == "undefined" ? ")$" : af;
-TinyMCEControl.prototype.convertAllRelativeURLs = function() {
- var body = this.getBody();
+ r = be;
- // Convert all image URL:s to absolute URL
- var elms = body.getElementsByTagName("img");
- for (var i=0; i<elms.length; i++) {
- var src = tinyMCE.getAttrib(elms[i], 'src');
+ for (i=0; i<a.length; i++)
+ r += this._wildcardToRe(a[i]) + (i != a.length-1 ? "|" : "");
- var msrc = tinyMCE.getAttrib(elms[i], 'mce_src');
- if (msrc != "")
- src = msrc;
+ r += af;
- if (src != "") {
- src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], src);
- elms[i].setAttribute("src", src);
+ return new RegExp(r, op);
+ },
+
+ _wildcardToRe : function(s) {
+ s = s.replace(/\?/g, '(\\S?)');
+ s = s.replace(/\+/g, '(\\S+)');
+ s = s.replace(/\*/g, '(\\S*)');
+
+ return s;
+ },
+
+ _setupEntities : function() {
+ var n, a, i, s = this.settings;
+
+ // Setup entities
+ if (!this.entitiesDone) {
+ if (s.entity_encoding == "named") {
+ n = tinyMCE.clearArray(new Array());
+ a = this.split(',', s.entities);
+ for (i=0; i<a.length; i+=2)
+ n[a[i]] = a[i+1];
+
+ this.entities = n;
+ }
+
+ this.entitiesDone = true;
}
- }
+ },
- // Convert all link URL:s to absolute URL
- var elms = body.getElementsByTagName("a");
- for (var i=0; i<elms.length; i++) {
- var href = tinyMCE.getAttrib(elms[i], 'href');
+ _setupRules : function() {
+ var s = this.settings;
- var mhref = tinyMCE.getAttrib(elms[i], 'mce_href');
- if (mhref != "")
- href = mhref;
+ // Setup default rule
+ if (!this.rulesDone) {
+ this.addRuleStr(s.valid_elements);
+ this.addRuleStr(s.extended_valid_elements);
- if (href && href != "") {
- href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], href);
- elms[i].setAttribute("href", href);
+ this.rulesDone = true;
}
- }
-};
+ },
-TinyMCEControl.prototype.getSelectedHTML = function() {
- if (tinyMCE.isSafari) {
- // Not realy perfect!!
+ _isDuplicate : function(n) {
+ var i;
- return this.getRng().toString();
- }
+ if (!this.settings.fix_content_duplication)
+ return false;
- var elm = document.createElement("body");
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera && n.nodeType == 1) {
+ // Mark elements
+ if (n.mce_serialized == this.serializationId)
+ return true;
- if (tinyMCE.isGecko)
- elm.appendChild(this.getRng().cloneContents());
- else
- elm.innerHTML = this.getRng().htmlText;
+ n.setAttribute('mce_serialized', this.serializationId);
+ } else {
+ // Search lookup table for text nodes and comments
+ for (i=0; i<this.serializedNodes.length; i++) {
+ if (this.serializedNodes[i] == n)
+ return true;
+ }
- return tinyMCE._cleanupHTML(this, this.contentDocument, this.settings, elm, this.visualAid);
+ this.serializedNodes[this.serializedNodes.length] = n;
+ }
+
+ return false;
+ }
};
-TinyMCEControl.prototype.getBookmark = function() {
- var rng = this.getRng();
+/* file:jscripts/tiny_mce/classes/TinyMCE_DOMUtils.class.js */
- if (tinyMCE.isSafari)
- return rng;
+TinyMCE_Engine.prototype.getElementByAttributeValue = function(n, e, a, v) {
+ return (n = this.getElementsByAttributeValue(n, e, a, v)).length == 0 ? null : n[0];
+};
- if (tinyMCE.isMSIE)
- return rng;
+TinyMCE_Engine.prototype.getElementsByAttributeValue = function(n, e, a, v) {
+ var i, nl = n.getElementsByTagName(e), o = new Array();
- if (tinyMCE.isGecko)
- return rng.cloneRange();
+ for (i=0; i<nl.length; i++) {
+ if (tinyMCE.getAttrib(nl[i], a).indexOf(v) != -1)
+ o[o.length] = nl[i];
+ }
- return null;
+ return o;
};
-TinyMCEControl.prototype.moveToBookmark = function(bookmark) {
- if (tinyMCE.isSafari) {
- var sel = this.getSel().realSelection;
+TinyMCE_Engine.prototype.isBlockElement = function(n) {
+ return n != null && n.nodeType == 1 && this.blockRegExp.test(n.nodeName);
+};
- sel.setBaseAndExtent(bookmark.startContainer, bookmark.startOffset, bookmark.endContainer, bookmark.endOffset);
+TinyMCE_Engine.prototype.getParentBlockElement = function(n) {
+ while (n) {
+ if (this.isBlockElement(n))
+ return n;
- return true;
+ n = n.parentNode;
}
- if (tinyMCE.isMSIE)
- return bookmark.select();
+ return null;
+};
- if (tinyMCE.isGecko) {
- var rng = this.getDoc().createRange();
- var sel = this.getSel();
+TinyMCE_Engine.prototype.insertAfter = function(n, r){
+ if (r.nextSibling)
+ r.parentNode.insertBefore(n, r.nextSibling);
+ else
+ r.parentNode.appendChild(n);
+};
- rng.setStart(bookmark.startContainer, bookmark.startOffset);
- rng.setEnd(bookmark.endContainer, bookmark.endOffset);
+TinyMCE_Engine.prototype.setInnerHTML = function(e, h) {
+ var i, nl, n;
- sel.removeAllRanges();
- sel.addRange(rng);
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ // Since MSIE handles invalid HTML better that valid XHTML we
+ // need to make some things invalid. <hr /> gets converted to <hr>.
+ h = h.replace(/\s\/>/g, '>');
- return true;
- }
+ // Since MSIE auto generated emtpy P tags some times we must tell it to keep the real ones
+ h = h.replace(/<p([^>]*)>\u00A0?<\/p>/gi, '<p$1 mce_keep="true">&nbsp;</p>'); // Keep empty paragraphs
+ h = h.replace(/<p([^>]*)>&nbsp;<\/p>/gi, '<p$1 mce_keep="true">&nbsp;</p>'); // Keep empty paragraphs
- return false;
-};
+ // Remove first comment
+ e.innerHTML = tinyMCE.uniqueTag + h;
+ e.firstChild.removeNode(true);
-TinyMCEControl.prototype.getSelectedText = function() {
- if (tinyMCE.isMSIE) {
- var doc = this.getDoc();
+ // Remove weird auto generated empty paragraphs unless it's supposed to be there
+ nl = e.getElementsByTagName("p");
+ for (i=nl.length-1; i>=0; i--) {
+ n = nl[i];
- if (doc.selection.type == "Text") {
- var rng = doc.selection.createRange();
- selectedText = rng.text;
- } else
- selectedText = '';
+ if (n.nodeName == 'P' && !n.hasChildNodes() && !n.mce_keep)
+ n.parentNode.removeChild(n);
+ }
} else {
- var sel = this.getSel();
-
- if (sel && sel.toString)
- selectedText = sel.toString();
- else
- selectedText = '';
+ h = this.fixGeckoBaseHREFBug(1, e, h);
+ e.innerHTML = h;
+ this.fixGeckoBaseHREFBug(2, e, h);
}
+};
+
+TinyMCE_Engine.prototype.getOuterHTML = function(e) {
+ if (tinyMCE.isMSIE)
+ return e.outerHTML;
- return selectedText;
+ var d = e.ownerDocument.createElement("body");
+ d.appendChild(e);
+ return d.innerHTML;
};
-TinyMCEControl.prototype.selectNode = function(node, collapse, select_text_node, to_start) {
- if (!node)
+TinyMCE_Engine.prototype.setOuterHTML = function(e, h) {
+ if (tinyMCE.isMSIE) {
+ e.outerHTML = h;
return;
+ }
+
+ var d = e.ownerDocument.createElement("body");
+ d.innerHTML = h;
+ e.parentNode.replaceChild(d.firstChild, e);
+};
- if (typeof(collapse) == "undefined")
- collapse = true;
+TinyMCE_Engine.prototype._getElementById = function(id, d) {
+ var e, i, j, f;
- if (typeof(select_text_node) == "undefined")
- select_text_node = false;
+ if (typeof(d) == "undefined")
+ d = document;
- if (typeof(to_start) == "undefined")
- to_start = true;
+ e = d.getElementById(id);
+ if (!e) {
+ f = d.forms;
- if (tinyMCE.isMSIE) {
- var rng = this.getBody().createTextRange();
+ for (i=0; i<f.length; i++) {
+ for (j=0; j<f[i].elements.length; j++) {
+ if (f[i].elements[j].name == id) {
+ e = f[i].elements[j];
+ break;
+ }
+ }
+ }
+ }
- try {
- rng.moveToElementText(node);
+ return e;
+};
- if (collapse)
- rng.collapse(to_start);
+TinyMCE_Engine.prototype.getNodeTree = function(n, na, t, nn) {
+ var i;
- rng.select();
- } catch (e) {
- // Throws illigal agrument in MSIE some times
- }
- } else {
- var sel = this.getSel();
+ if (typeof(t) == "undefined" || n.nodeType == t && (typeof(nn) == "undefined" || n.nodeName == nn))
+ na[na.length] = n;
- if (!sel)
- return;
+ if (n.hasChildNodes()) {
+ for (i=0; i<n.childNodes.length; i++)
+ tinyMCE.getNodeTree(n.childNodes[i], na, t, nn);
+ }
- if (tinyMCE.isSafari) {
- sel.realSelection.setBaseAndExtent(node, 0, node, node.innerText.length);
+ return na;
+};
- if (collapse) {
- if (to_start)
- sel.realSelection.collapseToStart();
- else
- sel.realSelection.collapseToEnd();
- }
+TinyMCE_Engine.prototype.getParentElement = function(node, names, attrib_name, attrib_value) {
+ if (typeof(names) == "undefined") {
+ if (node.nodeType == 1)
+ return node;
- this.scrollToNode(node);
+ // Find parent node that is a element
+ while ((node = node.parentNode) != null && node.nodeType != 1) ;
- return;
- }
+ return node;
+ }
- var rng = this.getDoc().createRange();
+ if (node == null)
+ return null;
- if (select_text_node) {
- // Find first textnode in tree
- var nodes = tinyMCE.getNodeTree(node, new Array(), 3);
- if (nodes.length > 0)
- rng.selectNodeContents(nodes[0]);
- else
- rng.selectNodeContents(node);
- } else
- rng.selectNode(node);
+ var namesAr = names.toUpperCase().split(',');
- if (collapse) {
- // Special treatment of textnode collapse
- if (!to_start && node.nodeType == 3) {
- rng.setStart(node, node.nodeValue.length);
- rng.setEnd(node, node.nodeValue.length);
- } else
- rng.collapse(to_start);
+ do {
+ for (var i=0; i<namesAr.length; i++) {
+ if (node.nodeName == namesAr[i] || names == "*") {
+ if (typeof(attrib_name) == "undefined")
+ return node;
+ else if (node.getAttribute(attrib_name)) {
+ if (typeof(attrib_value) == "undefined") {
+ if (node.getAttribute(attrib_name) != "")
+ return node;
+ } else if (node.getAttribute(attrib_name) == attrib_value)
+ return node;
+ }
+ }
}
+ } while ((node = node.parentNode) != null);
- sel.removeAllRanges();
- sel.addRange(rng);
- }
+ return null;
+};
- this.scrollToNode(node);
+TinyMCE_Engine.prototype.getAttrib = function(elm, name, default_value) {
+ if (typeof(default_value) == "undefined")
+ default_value = "";
- // Set selected element
- tinyMCE.selectedElement = null;
- if (node.nodeType == 1)
- tinyMCE.selectedElement = node;
-};
+ // Not a element
+ if (!elm || elm.nodeType != 1)
+ return default_value;
-TinyMCEControl.prototype.scrollToNode = function(node) {
- // Scroll to node position
- var pos = tinyMCE.getAbsPosition(node);
- var doc = this.getDoc();
- var scrollX = doc.body.scrollLeft + doc.documentElement.scrollLeft;
- var scrollY = doc.body.scrollTop + doc.documentElement.scrollTop;
- var height = tinyMCE.isMSIE ? document.getElementById(this.editorId).style.pixelHeight : this.targetElement.clientHeight;
-
- // Only scroll if out of visible area
- if (!tinyMCE.settings['auto_resize'] && !(pos.absTop > scrollY && pos.absTop < (scrollY - 25 + height)))
- this.contentWindow.scrollTo(pos.absLeft, pos.absTop - height + 25);
-};
+ var v = elm.getAttribute(name);
-TinyMCEControl.prototype.getBody = function() {
- return this.getDoc().body;
-};
+ // Try className for class attrib
+ if (name == "class" && !v)
+ v = elm.className;
-TinyMCEControl.prototype.getDoc = function() {
- return this.contentWindow.document;
-};
+ // Workaround for a issue with Firefox 1.5rc2+
+ if (tinyMCE.isGecko && name == "src" && elm.src != null && elm.src != "")
+ v = elm.src;
+
+ // Workaround for a issue with Firefox 1.5rc2+
+ if (tinyMCE.isGecko && name == "href" && elm.href != null && elm.href != "")
+ v = elm.href;
+
+ if (name == "http-equiv" && tinyMCE.isMSIE)
+ v = elm.httpEquiv;
-TinyMCEControl.prototype.getWin = function() {
- return this.contentWindow;
+ if (name == "style" && !tinyMCE.isOpera)
+ v = elm.style.cssText;
+
+ return (v && v != "") ? v : default_value;
};
-TinyMCEControl.prototype.getSel = function() {
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
- return this.getDoc().selection;
+TinyMCE_Engine.prototype.setAttrib = function(element, name, value, fix_value) {
+ if (typeof(value) == "number" && value != null)
+ value = "" + value;
- var sel = this.contentWindow.getSelection();
+ if (fix_value) {
+ if (value == null)
+ value = "";
- // Fake getRangeAt
- if (tinyMCE.isSafari && !sel.getRangeAt) {
- var newSel = new Object();
- var doc = this.getDoc();
+ var re = new RegExp('[^0-9%]', 'g');
+ value = value.replace(re, '');
+ }
- function getRangeAt(idx) {
- var rng = new Object();
+ if (name == "style")
+ element.style.cssText = value;
- rng.startContainer = this.focusNode;
- rng.endContainer = this.anchorNode;
- rng.commonAncestorContainer = this.focusNode;
- rng.createContextualFragment = function (html) {
- // Seems to be a tag
- if (html.charAt(0) == '<') {
- var elm = doc.createElement("div");
+ if (name == "class")
+ element.className = value;
- elm.innerHTML = html;
+ if (value != null && value != "" && value != -1)
+ element.setAttribute(name, value);
+ else
+ element.removeAttribute(name);
+};
- return elm.firstChild;
- }
+TinyMCE_Engine.prototype.setStyleAttrib = function(elm, name, value) {
+ eval('elm.style.' + name + '=value;');
- return doc.createTextNode("UNSUPPORTED, DUE TO LIMITATIONS IN SAFARI!");
- };
+ // Style attrib deleted
+ if (tinyMCE.isMSIE && value == null || value == '') {
+ var str = tinyMCE.serializeStyle(tinyMCE.parseStyle(elm.style.cssText));
+ elm.style.cssText = str;
+ elm.setAttribute("style", str);
+ }
+};
- rng.deleteContents = function () {
- doc.execCommand("Delete", false, "");
- };
+TinyMCE_Engine.prototype.switchClass = function(ei, c) {
+ var e;
- return rng;
- }
+ if (tinyMCE.switchClassCache[ei])
+ e = tinyMCE.switchClassCache[ei];
+ else
+ e = tinyMCE.switchClassCache[ei] = document.getElementById(ei);
- // Patch selection
+ if (e) {
+ // Keep tile mode
+ if (tinyMCE.settings.button_tile_map && e.className && e.className.indexOf('mceTiledButton') == 0)
+ c = 'mceTiledButton ' + c;
- newSel.focusNode = sel.baseNode;
- newSel.focusOffset = sel.baseOffset;
- newSel.anchorNode = sel.extentNode;
- newSel.anchorOffset = sel.extentOffset;
- newSel.getRangeAt = getRangeAt;
- newSel.text = "" + sel;
- newSel.realSelection = sel;
+ e.className = c;
+ }
+};
- newSel.toString = function () {return this.text;};
+TinyMCE_Engine.prototype.getAbsPosition = function(n) {
+ var p = {absLeft : 0, absTop : 0};
- return newSel;
+ while (n) {
+ p.absLeft += n.offsetLeft;
+ p.absTop += n.offsetTop;
+ n = n.offsetParent;
}
- return sel;
+ return p;
};
-TinyMCEControl.prototype.getRng = function() {
- var sel = this.getSel();
- if (sel == null)
- return null;
+TinyMCE_Engine.prototype.prevNode = function(e, n) {
+ var a = n.split(','), i;
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
- return sel.createRange();
+ while ((e = e.previousSibling) != null) {
+ for (i=0; i<a.length; i++) {
+ if (e.nodeName == a[i])
+ return e;
+ }
+ }
- if (tinyMCE.isSafari) {
- var rng = this.getDoc().createRange();
- var sel = this.getSel().realSelection;
+ return null;
+};
- rng.setStart(sel.baseNode, sel.baseOffset);
- rng.setEnd(sel.extentNode, sel.extentOffset);
+TinyMCE_Engine.prototype.nextNode = function(e, n) {
+ var a = n.split(','), i;
- return rng;
+ while ((e = e.nextSibling) != null) {
+ for (i=0; i<a.length; i++) {
+ if (e.nodeName == a[i])
+ return e;
+ }
}
- return this.getSel().getRangeAt(0);
+ return null;
};
-TinyMCEControl.prototype._insertPara = function(e) {
- function isEmpty(para) {
- function isEmptyHTML(html) {
- return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == "";
+/* file:jscripts/tiny_mce/classes/TinyMCE_URL.class.js */
+
+TinyMCE_Engine.prototype.parseURL = function(url_str) {
+ var urlParts = new Array();
+
+ if (url_str) {
+ var pos, lastPos;
+
+ // Parse protocol part
+ pos = url_str.indexOf('://');
+ if (pos != -1) {
+ urlParts['protocol'] = url_str.substring(0, pos);
+ lastPos = pos + 3;
}
- // Check for images
- if (para.getElementsByTagName("img").length > 0)
- return false;
+ // Find port or path start
+ for (var i=lastPos; i<url_str.length; i++) {
+ var chr = url_str.charAt(i);
- // Check for tables
- if (para.getElementsByTagName("table").length > 0)
- return false;
+ if (chr == ':')
+ break;
- // Check for HRs
- if (para.getElementsByTagName("hr").length > 0)
- return false;
+ if (chr == '/')
+ break;
+ }
+ pos = i;
- // Check all textnodes
- var nodes = tinyMCE.getNodeTree(para, new Array(), 3);
- for (var i=0; i<nodes.length; i++) {
- if (!isEmptyHTML(nodes[i].nodeValue))
- return false;
+ // Get host
+ urlParts['host'] = url_str.substring(lastPos, pos);
+
+ // Get port
+ urlParts['port'] = "";
+ lastPos = pos;
+ if (url_str.charAt(pos) == ':') {
+ pos = url_str.indexOf('/', lastPos);
+ urlParts['port'] = url_str.substring(lastPos+1, pos);
}
- // No images, no tables, no hrs, no text content then it's empty
- return true;
- }
+ // Get path
+ lastPos = pos;
+ pos = url_str.indexOf('?', lastPos);
- var doc = this.getDoc();
- var sel = this.getSel();
- var win = this.contentWindow;
- var rng = sel.getRangeAt(0);
- var body = doc.body;
- var rootElm = doc.documentElement;
- var self = this;
- var blockName = "P";
+ if (pos == -1)
+ pos = url_str.indexOf('#', lastPos);
-// tinyMCE.debug(body.innerHTML);
+ if (pos == -1)
+ pos = url_str.length;
-// debug(e.target, sel.anchorNode.nodeName, sel.focusNode.nodeName, rng.startContainer, rng.endContainer, rng.commonAncestorContainer, sel.anchorOffset, sel.focusOffset, rng.toString());
+ urlParts['path'] = url_str.substring(lastPos, pos);
- // Setup before range
- var rngBefore = doc.createRange();
- rngBefore.setStart(sel.anchorNode, sel.anchorOffset);
- rngBefore.collapse(true);
+ // Get query
+ lastPos = pos;
+ if (url_str.charAt(pos) == '?') {
+ pos = url_str.indexOf('#');
+ pos = (pos == -1) ? url_str.length : pos;
+ urlParts['query'] = url_str.substring(lastPos+1, pos);
+ }
- // Setup after range
- var rngAfter = doc.createRange();
- rngAfter.setStart(sel.focusNode, sel.focusOffset);
- rngAfter.collapse(true);
+ // Get anchor
+ lastPos = pos;
+ if (url_str.charAt(pos) == '#') {
+ pos = url_str.length;
+ urlParts['anchor'] = url_str.substring(lastPos+1, pos);
+ }
+ }
- // Setup start/end points
- var direct = rngBefore.compareBoundaryPoints(rngBefore.START_TO_END, rngAfter) < 0;
- var startNode = direct ? sel.anchorNode : sel.focusNode;
- var startOffset = direct ? sel.anchorOffset : sel.focusOffset;
- var endNode = direct ? sel.focusNode : sel.anchorNode;
- var endOffset = direct ? sel.focusOffset : sel.anchorOffset;
+ return urlParts;
+};
- startNode = startNode.nodeName == "BODY" ? startNode.firstChild : startNode;
- endNode = endNode.nodeName == "BODY" ? endNode.firstChild : endNode;
+TinyMCE_Engine.prototype.serializeURL = function(up) {
+ var o = "";
- // tinyMCE.debug(startNode, endNode);
+ if (up['protocol'])
+ o += up['protocol'] + "://";
- // Get block elements
- var startBlock = tinyMCE.getParentBlockElement(startNode);
- var endBlock = tinyMCE.getParentBlockElement(endNode);
+ if (up['host'])
+ o += up['host'];
- // Use current block name
- if (startBlock != null) {
- blockName = startBlock.nodeName;
+ if (up['port'])
+ o += ":" + up['port'];
- // Use P instead
- if (blockName == "TD" || blockName == "TABLE" || (blockName == "DIV" && new RegExp('left|right', 'gi').test(startBlock.style.cssFloat)))
- blockName = "P";
- }
+ if (up['path'])
+ o += up['path'];
- // Within a list use normal behaviour
- if (tinyMCE.getParentElement(startBlock, "OL,UL") != null)
- return false;
+ if (up['query'])
+ o += "?" + up['query'];
- // Within a table create new paragraphs
- if ((startBlock != null && startBlock.nodeName == "TABLE") || (endBlock != null && endBlock.nodeName == "TABLE"))
- startBlock = endBlock = null;
+ if (up['anchor'])
+ o += "#" + up['anchor'];
- // Setup new paragraphs
- var paraBefore = (startBlock != null && startBlock.nodeName == blockName) ? startBlock.cloneNode(false) : doc.createElement(blockName);
- var paraAfter = (endBlock != null && endBlock.nodeName == blockName) ? endBlock.cloneNode(false) : doc.createElement(blockName);
+ return o;
+};
- // Is header, then force paragraph under
- if (/^(H[1-6])$/.test(blockName))
- paraAfter = doc.createElement("p");
+TinyMCE_Engine.prototype.convertAbsoluteURLToRelativeURL = function(base_url, url_to_relative) {
+ var baseURL = this.parseURL(base_url);
+ var targetURL = this.parseURL(url_to_relative);
+ var strTok1;
+ var strTok2;
+ var breakPoint = 0;
+ var outPath = "";
+ var forceSlash = false;
- // Setup chop nodes
- var startChop = startNode;
- var endChop = endNode;
+ if (targetURL.path == "")
+ targetURL.path = "/";
+ else
+ forceSlash = true;
- // Get startChop node
- node = startChop;
- do {
- if (node == body || node.nodeType == 9 || tinyMCE.isBlockElement(node))
- break;
+ // Crop away last path part
+ base_url = baseURL.path.substring(0, baseURL.path.lastIndexOf('/'));
+ strTok1 = base_url.split('/');
+ strTok2 = targetURL.path.split('/');
- startChop = node;
- } while ((node = node.previousSibling ? node.previousSibling : node.parentNode));
+ if (strTok1.length >= strTok2.length) {
+ for (var i=0; i<strTok1.length; i++) {
+ if (i >= strTok2.length || strTok1[i] != strTok2[i]) {
+ breakPoint = i + 1;
+ break;
+ }
+ }
+ }
- // Get endChop node
- node = endChop;
- do {
- if (node == body || node.nodeType == 9 || tinyMCE.isBlockElement(node))
- break;
+ if (strTok1.length < strTok2.length) {
+ for (var i=0; i<strTok2.length; i++) {
+ if (i >= strTok1.length || strTok1[i] != strTok2[i]) {
+ breakPoint = i + 1;
+ break;
+ }
+ }
+ }
- endChop = node;
- } while ((node = node.nextSibling ? node.nextSibling : node.parentNode));
+ if (breakPoint == 1)
+ return targetURL.path;
- // Fix when only a image is within the TD
- if (startChop.nodeName == "TD")
- startChop = startChop.firstChild;
+ for (var i=0; i<(strTok1.length-(breakPoint-1)); i++)
+ outPath += "../";
- if (endChop.nodeName == "TD")
- endChop = endChop.lastChild;
+ for (var i=breakPoint-1; i<strTok2.length; i++) {
+ if (i != (breakPoint-1))
+ outPath += "/" + strTok2[i];
+ else
+ outPath += strTok2[i];
+ }
- // If not in a block element
- if (startBlock == null) {
- // Delete selection
- rng.deleteContents();
- sel.removeAllRanges();
+ targetURL.protocol = null;
+ targetURL.host = null;
+ targetURL.port = null;
+ targetURL.path = outPath == "" && forceSlash ? "/" : outPath;
- if (startChop != rootElm && endChop != rootElm) {
- // Insert paragraph before
- rngBefore = rng.cloneRange();
+ // Remove document prefix from local anchors
+ var fileName = baseURL.path;
+ var pos;
- if (startChop == body)
- rngBefore.setStart(startChop, 0);
- else
- rngBefore.setStartBefore(startChop);
+ if ((pos = fileName.lastIndexOf('/')) != -1)
+ fileName = fileName.substring(pos + 1);
- paraBefore.appendChild(rngBefore.cloneContents());
+ // Is local anchor
+ if (fileName == targetURL.path && targetURL.anchor != "")
+ targetURL.path = "";
- // Insert paragraph after
- if (endChop.parentNode.nodeName == blockName)
- endChop = endChop.parentNode;
+ // If empty and not local anchor force slash
+ if (targetURL.path == "" && !targetURL.anchor)
+ targetURL.path = "/";
- // If not after image
- //if (rng.startContainer.nodeName != "BODY" && rng.endContainer.nodeName != "BODY")
- rng.setEndAfter(endChop);
+ return this.serializeURL(targetURL);
+};
- if (endChop.nodeName != "#text" && endChop.nodeName != "BODY")
- rngBefore.setEndAfter(endChop);
+TinyMCE_Engine.prototype.convertRelativeToAbsoluteURL = function(base_url, relative_url) {
+ var baseURL = this.parseURL(base_url);
+ var relURL = this.parseURL(relative_url);
- var contents = rng.cloneContents();
- if (contents.firstChild && (contents.firstChild.nodeName == blockName || contents.firstChild.nodeName == "BODY"))
- paraAfter.innerHTML = contents.firstChild.innerHTML;
- else
- paraAfter.appendChild(contents);
+ if (relative_url == "" || relative_url.charAt(0) == '/' || relative_url.indexOf('://') != -1 || relative_url.indexOf('mailto:') != -1 || relative_url.indexOf('javascript:') != -1)
+ return relative_url;
- // Check if it's a empty paragraph
- if (isEmpty(paraBefore))
- paraBefore.innerHTML = "&nbsp;";
+ // Split parts
+ baseURLParts = baseURL['path'].split('/');
+ relURLParts = relURL['path'].split('/');
- // Check if it's a empty paragraph
- if (isEmpty(paraAfter))
- paraAfter.innerHTML = "&nbsp;";
+ // Remove empty chunks
+ var newBaseURLParts = new Array();
+ for (var i=baseURLParts.length-1; i>=0; i--) {
+ if (baseURLParts[i].length == 0)
+ continue;
- // Delete old contents
- rng.deleteContents();
- rngAfter.deleteContents();
- rngBefore.deleteContents();
+ newBaseURLParts[newBaseURLParts.length] = baseURLParts[i];
+ }
+ baseURLParts = newBaseURLParts.reverse();
- // Insert new paragraphs
- paraAfter.normalize();
- rngBefore.insertNode(paraAfter);
- paraBefore.normalize();
- rngBefore.insertNode(paraBefore);
+ // Merge relURLParts chunks
+ var newRelURLParts = new Array();
+ var numBack = 0;
+ for (var i=relURLParts.length-1; i>=0; i--) {
+ if (relURLParts[i].length == 0 || relURLParts[i] == ".")
+ continue;
- // tinyMCE.debug("1: ", paraBefore.innerHTML, paraAfter.innerHTML);
- } else {
- body.innerHTML = "<" + blockName + ">&nbsp;</" + blockName + "><" + blockName + ">&nbsp;</" + blockName + ">";
- paraAfter = body.childNodes[1];
+ if (relURLParts[i] == '..') {
+ numBack++;
+ continue;
}
- this.selectNode(paraAfter, true, true);
+ if (numBack > 0) {
+ numBack--;
+ continue;
+ }
- return true;
+ newRelURLParts[newRelURLParts.length] = relURLParts[i];
}
- // Place first part within new paragraph
- if (startChop.nodeName == blockName)
- rngBefore.setStart(startChop, 0);
- else
- rngBefore.setStartBefore(startChop);
+ relURLParts = newRelURLParts.reverse();
- rngBefore.setEnd(startNode, startOffset);
- paraBefore.appendChild(rngBefore.cloneContents());
+ // Remove end from absolute path
+ var len = baseURLParts.length-numBack;
+ var absPath = (len <= 0 ? "" : "/") + baseURLParts.slice(0, len).join('/') + "/" + relURLParts.join('/');
+ var start = "", end = "";
- // Place secound part within new paragraph
- rngAfter.setEndAfter(endChop);
- rngAfter.setStart(endNode, endOffset);
- var contents = rngAfter.cloneContents();
+ // Build output URL
+ relURL.protocol = baseURL.protocol;
+ relURL.host = baseURL.host;
+ relURL.port = baseURL.port;
- if (contents.firstChild && contents.firstChild.nodeName == blockName) {
-/* var nodes = contents.firstChild.childNodes;
- for (var i=0; i<nodes.length; i++) {
- //tinyMCE.debug(nodes[i].nodeName);
- if (nodes[i].nodeName != "BODY")
- paraAfter.appendChild(nodes[i]);
- }
-*/
- paraAfter.innerHTML = contents.firstChild.innerHTML;
- } else
- paraAfter.appendChild(contents);
+ // Re-add trailing slash if it's removed
+ if (relURL.path.charAt(relURL.path.length-1) == "/")
+ absPath += "/";
- // Check if it's a empty paragraph
- if (isEmpty(paraBefore))
- paraBefore.innerHTML = "&nbsp;";
+ relURL.path = absPath;
- // Check if it's a empty paragraph
- if (isEmpty(paraAfter))
- paraAfter.innerHTML = "&nbsp;";
+ return this.serializeURL(relURL);
+};
- // Create a range around everything
- var rng = doc.createRange();
+TinyMCE_Engine.prototype.convertURL = function(url, node, on_save) {
+ var prot = document.location.protocol;
+ var host = document.location.hostname;
+ var port = document.location.port;
- if (!startChop.previousSibling && startChop.parentNode.nodeName.toUpperCase() == blockName) {
- rng.setStartBefore(startChop.parentNode);
- } else {
- if (rngBefore.startContainer.nodeName.toUpperCase() == blockName && rngBefore.startOffset == 0)
- rng.setStartBefore(rngBefore.startContainer);
- else
- rng.setStart(rngBefore.startContainer, rngBefore.startOffset);
- }
+ // Pass through file protocol
+ if (prot == "file:")
+ return url;
- if (!endChop.nextSibling && endChop.parentNode.nodeName.toUpperCase() == blockName)
- rng.setEndAfter(endChop.parentNode);
- else
- rng.setEnd(rngAfter.endContainer, rngAfter.endOffset);
+ // Something is wrong, remove weirdness
+ url = tinyMCE.regexpReplace(url, '(http|https):///', '/');
- // Delete all contents and insert new paragraphs
- rng.deleteContents();
- rng.insertNode(paraAfter);
- rng.insertNode(paraBefore);
- //tinyMCE.debug("2", paraBefore.innerHTML, paraAfter.innerHTML);
+ // Mailto link or anchor (Pass through)
+ if (url.indexOf('mailto:') != -1 || url.indexOf('javascript:') != -1 || tinyMCE.regexpReplace(url,'[ \t\r\n\+]|%20','').charAt(0) == "#")
+ return url;
- // Normalize
- paraAfter.normalize();
- paraBefore.normalize();
+ // Fix relative/Mozilla
+ if (!tinyMCE.isMSIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/')
+ return tinyMCE.settings['base_href'] + url;
- this.selectNode(paraAfter, true, true);
+ // Handle relative URLs
+ if (on_save && tinyMCE.getParam('relative_urls')) {
+ var curl = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], url);
+ if (curl.charAt(0) == '/')
+ curl = tinyMCE.settings['document_base_prefix'] + curl;
- return true;
-};
+ var urlParts = tinyMCE.parseURL(curl);
+ var tmpUrlParts = tinyMCE.parseURL(tinyMCE.settings['document_base_url']);
-TinyMCEControl.prototype._handleBackSpace = function(evt_type) {
- var doc = this.getDoc();
- var sel = this.getSel();
- if (sel == null)
- return false;
+ // Force relative
+ if (urlParts['host'] == tmpUrlParts['host'] && (urlParts['port'] == tmpUrlParts['port']))
+ return tinyMCE.convertAbsoluteURLToRelativeURL(tinyMCE.settings['document_base_url'], curl);
+ }
- var rng = sel.getRangeAt(0);
- var node = rng.startContainer;
- var elm = node.nodeType == 3 ? node.parentNode : node;
+ // Handle absolute URLs
+ if (!tinyMCE.getParam('relative_urls')) {
+ var urlParts = tinyMCE.parseURL(url);
+ var baseUrlParts = tinyMCE.parseURL(tinyMCE.settings['base_href']);
- if (node == null)
- return;
+ // Force absolute URLs from relative URLs
+ url = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], url);
- // Empty node, wrap contents in paragraph
- if (elm && elm.nodeName == "") {
- var para = doc.createElement("p");
+ // If anchor and path is the same page
+ if (urlParts['anchor'] && urlParts['path'] == baseUrlParts['path'])
+ return "#" + urlParts['anchor'];
+ }
- while (elm.firstChild)
- para.appendChild(elm.firstChild);
+ // Remove current domain
+ if (tinyMCE.getParam('remove_script_host')) {
+ var start = "", portPart = "";
- elm.parentNode.insertBefore(para, elm);
- elm.parentNode.removeChild(elm);
+ if (port != "")
+ portPart = ":" + port;
- var rng = rng.cloneRange();
- rng.setStartBefore(node.nextSibling);
- rng.setEndAfter(node.nextSibling);
- rng.extractContents();
+ start = prot + "//" + host + portPart + "/";
- this.selectNode(node.nextSibling, true, true);
+ if (url.indexOf(start) == 0)
+ url = url.substring(start.length-1);
}
- // Remove empty paragraphs
- var para = tinyMCE.getParentBlockElement(node);
- if (para != null && para.nodeName.toLowerCase() == 'p' && evt_type == "keypress") {
- var htm = para.innerHTML;
- var block = tinyMCE.getParentBlockElement(node);
-
- // Empty node, we do the killing!!
- if (htm == "" || htm == "&nbsp;" || block.nodeName.toLowerCase() == "li") {
- var prevElm = para.previousSibling;
+ return url;
+};
- while (prevElm != null && prevElm.nodeType != 1)
- prevElm = prevElm.previousSibling;
+TinyMCE_Engine.prototype.convertAllRelativeURLs = function(body) {
+ // Convert all image URL:s to absolute URL
+ var elms = body.getElementsByTagName("img");
+ for (var i=0; i<elms.length; i++) {
+ var src = tinyMCE.getAttrib(elms[i], 'src');
- if (prevElm == null)
- return false;
+ var msrc = tinyMCE.getAttrib(elms[i], 'mce_src');
+ if (msrc != "")
+ src = msrc;
- // Get previous elements last text node
- var nodes = tinyMCE.getNodeTree(prevElm, new Array(), 3);
- var lastTextNode = nodes.length == 0 ? null : nodes[nodes.length-1];
+ if (src != "") {
+ src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], src);
+ elms[i].setAttribute("src", src);
+ }
+ }
- // Select the last text node and move curstor to end
- if (lastTextNode != null)
- this.selectNode(lastTextNode, true, false, false);
+ // Convert all link URL:s to absolute URL
+ var elms = body.getElementsByTagName("a");
+ for (var i=0; i<elms.length; i++) {
+ var href = tinyMCE.getAttrib(elms[i], 'href');
- // Remove the empty paragrapsh
- para.parentNode.removeChild(para);
+ var mhref = tinyMCE.getAttrib(elms[i], 'mce_href');
+ if (mhref != "")
+ href = mhref;
- //debug("within p element" + para.innerHTML);
- //showHTML(this.getBody().innerHTML);
- return true;
+ if (href && href != "") {
+ href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], href);
+ elms[i].setAttribute("href", href);
}
}
+};
- // Remove BR elements
-/* while (node != null && (node = node.nextSibling) != null) {
- if (node.nodeName.toLowerCase() == 'br')
- node.parentNode.removeChild(node);
- else if (node.nodeType == 1) // Break at other element
- break;
- }*/
+/* file:jscripts/tiny_mce/classes/TinyMCE_Array.class.js */
- //showHTML(this.getBody().innerHTML);
+TinyMCE_Engine.prototype.clearArray = function(a) {
+ for (var k in a)
+ a[k] = null;
- return false;
+ return a;
};
-TinyMCEControl.prototype._insertSpace = function() {
- return true;
-};
+/* file:jscripts/tiny_mce/classes/TinyMCE_Event.class.js */
-TinyMCEControl.prototype.autoResetDesignMode = function() {
- // Add fix for tab/style.display none/block problems in Gecko
- if (!tinyMCE.isMSIE && tinyMCE.settings['auto_reset_designmode'] && this.isHidden())
- eval('try { this.getDoc().designMode = "On"; } catch(e) {}');
-};
+TinyMCE_Engine.prototype._setEventsEnabled = function(node, state) {
+ var events = new Array('onfocus','onblur','onclick','ondblclick',
+ 'onmousedown','onmouseup','onmouseover','onmousemove',
+ 'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup');
-TinyMCEControl.prototype.isHidden = function() {
- if (tinyMCE.isMSIE)
- return false;
+ var evs = tinyMCE.settings['event_elements'].split(',');
+ for (var y=0; y<evs.length; y++){
+ var elms = node.getElementsByTagName(evs[y]);
+ for (var i=0; i<elms.length; i++) {
+ var event = "";
- var sel = this.getSel();
+ for (var x=0; x<events.length; x++) {
+ if ((event = tinyMCE.getAttrib(elms[i], events[x])) != '') {
+ event = tinyMCE.cleanupEventStr("" + event);
- // Weird, wheres that cursor selection?
- return (!sel || !sel.rangeCount || sel.rangeCount == 0);
-};
+ if (!state)
+ event = "return true;" + event;
+ else
+ event = event.replace(/^return true;/gi, '');
-TinyMCEControl.prototype.isDirty = function() {
- // Is content modified and not in a submit procedure
- return this.startContent != tinyMCE.trim(this.getBody().innerHTML) && !tinyMCE.isNotDirty;
+ elms[i].removeAttribute(events[x]);
+ elms[i].setAttribute(events[x], event);
+ }
+ }
+ }
+ }
};
-TinyMCEControl.prototype._mergeElements = function(scmd, pa, ch, override) {
- if (scmd == "removeformat") {
- pa.className = "";
- pa.style.cssText = "";
- ch.className = "";
- ch.style.cssText = "";
- return;
- }
+TinyMCE_Engine.prototype._eventPatch = function(editor_id) {
+ var n, inst, win, e;
- var st = tinyMCE.parseStyle(tinyMCE.getAttrib(pa, "style"));
- var stc = tinyMCE.parseStyle(tinyMCE.getAttrib(ch, "style"));
- var className = tinyMCE.getAttrib(pa, "class");
+ // Remove odd, error
+ if (typeof(tinyMCE) == "undefined")
+ return true;
- className += " " + tinyMCE.getAttrib(ch, "class");
+ try {
+ // Try selected instance first
+ if (tinyMCE.selectedInstance) {
+ win = tinyMCE.selectedInstance.getWin();
- if (override) {
- for (var n in st) {
- if (typeof(st[n]) == 'function')
- continue;
+ if (win && win.event) {
+ e = win.event;
- stc[n] = st[n];
+ if (!e.target)
+ e.target = e.srcElement;
+
+ TinyMCE_Engine.prototype.handleEvent(e);
+ return;
+ }
}
- } else {
- for (var n in stc) {
- if (typeof(stc[n]) == 'function')
+
+ // Search for it
+ for (n in tinyMCE.instances) {
+ inst = tinyMCE.instances[n];
+
+ if (!tinyMCE.isInstance(inst))
continue;
- st[n] = stc[n];
+ tinyMCE.selectedInstance = inst;
+ win = inst.getWin();
+
+ if (win && win.event) {
+ e = win.event;
+
+ if (!e.target)
+ e.target = e.srcElement;
+
+ TinyMCE_Engine.prototype.handleEvent(e);
+ return;
+ }
}
+ } catch (ex) {
+ // Ignore error if iframe is pointing to external URL
}
+};
- tinyMCE.setAttrib(pa, "style", tinyMCE.serializeStyle(st));
- tinyMCE.setAttrib(pa, "class", tinyMCE.trim(className));
- ch.className = "";
- ch.style.cssText = "";
- ch.removeAttribute("class");
- ch.removeAttribute("style");
+TinyMCE_Engine.prototype.unloadHandler = function() {
+ tinyMCE.triggerSave(true, true);
};
-TinyMCEControl.prototype.setUseCSS = function(b) {
- var doc = this.getDoc();
- try {doc.execCommand("useCSS", false, !b);} catch (ex) {}
- try {doc.execCommand("styleWithCSS", false, b);} catch (ex) {}
+TinyMCE_Engine.prototype.addEventHandlers = function(inst) {
+ var doc = inst.getDoc();
- if (!tinyMCE.getParam("table_inline_editing"))
- try {doc.execCommand('enableInlineTableEditing', false, "false");} catch (ex) {}
+ inst.switchSettings();
- if (!tinyMCE.getParam("object_resizing"))
- try {doc.execCommand('enableObjectResizing', false, "false");} catch (ex) {}
+ if (tinyMCE.isMSIE) {
+ tinyMCE.addEvent(doc, "keypress", TinyMCE_Engine.prototype._eventPatch);
+ tinyMCE.addEvent(doc, "keyup", TinyMCE_Engine.prototype._eventPatch);
+ tinyMCE.addEvent(doc, "keydown", TinyMCE_Engine.prototype._eventPatch);
+ tinyMCE.addEvent(doc, "mouseup", TinyMCE_Engine.prototype._eventPatch);
+ tinyMCE.addEvent(doc, "click", TinyMCE_Engine.prototype._eventPatch);
+ } else {
+ tinyMCE.addEvent(doc, "keypress", tinyMCE.handleEvent);
+ tinyMCE.addEvent(doc, "keydown", tinyMCE.handleEvent);
+ tinyMCE.addEvent(doc, "keyup", tinyMCE.handleEvent);
+ tinyMCE.addEvent(doc, "click", tinyMCE.handleEvent);
+ tinyMCE.addEvent(doc, "mouseup", tinyMCE.handleEvent);
+ tinyMCE.addEvent(doc, "mousedown", tinyMCE.handleEvent);
+ tinyMCE.addEvent(doc, "focus", tinyMCE.handleEvent);
+ tinyMCE.addEvent(doc, "blur", tinyMCE.handleEvent);
+
+ eval('try { doc.designMode = "On"; } catch(e) {}'); // Force designmode
+ }
};
-TinyMCEControl.prototype.execCommand = function(command, user_interface, value) {
- var doc = this.getDoc();
- var win = this.getWin();
- var focusElm = this.getFocusElement();
+TinyMCE_Engine.prototype.onMouseMove = function() {
+ var inst;
- if (this.lastSafariSelection && !new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command)) {
- this.moveToBookmark(this.lastSafariSelection);
- tinyMCE.selectedElement = this.lastSafariSelectedElement;
- }
+ if (!tinyMCE.hasMouseMoved) {
+ inst = tinyMCE.selectedInstance;
- // Mozilla issue
- if (!tinyMCE.isMSIE && !this.useCSS) {
- this.setUseCSS(false);
- this.useCSS = true;
+ // Workaround for bug #1437457 (Odd MSIE bug)
+ if (inst.isFocused) {
+ inst.undoBookmark = inst.selection.getBookmark();
+ tinyMCE.hasMouseMoved = true;
+ }
}
- //debug("command: " + command + ", user_interface: " + user_interface + ", value: " + value);
- this.contentDocument = doc; // <-- Strange, unless this is applied Mozilla 1.3 breaks
-
- // Call theme execcommand
- if (tinyMCE._themeExecCommand(this.editorId, this.getBody(), command, user_interface, value))
- return;
+// tinyMCE.cancelEvent(inst.getWin().event);
+// return false;
+};
- // Fix align on images
- if (focusElm && focusElm.nodeName == "IMG") {
- var align = focusElm.getAttribute('align');
- var img = command == "JustifyCenter" ? focusElm.cloneNode(false) : focusElm;
+TinyMCE_Engine.prototype.cancelEvent = function(e) {
+ if (tinyMCE.isMSIE) {
+ e.returnValue = false;
+ e.cancelBubble = true;
+ } else
+ e.preventDefault();
+};
- switch (command) {
- case "JustifyLeft":
- if (align == 'left')
- img.removeAttribute('align');
- else
- img.setAttribute('align', 'left');
+TinyMCE_Engine.prototype.addEvent = function(o, n, h) {
+ if (o.attachEvent)
+ o.attachEvent("on" + n, h);
+ else
+ o.addEventListener(n, h, false);
+};
- // Remove the div
- var div = focusElm.parentNode;
- if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)
- div.parentNode.replaceChild(img, div);
+TinyMCE_Engine.prototype.addSelectAccessibility = function(e, s, w) {
+ // Add event handlers
+ if (!s._isAccessible) {
+ s.onkeydown = tinyMCE.accessibleEventHandler;
+ s.onblur = tinyMCE.accessibleEventHandler;
+ s._isAccessible = true;
+ s._win = w;
+ }
- this.selectNode(img);
- this.repaint();
- tinyMCE.triggerNodeChange();
- return;
+ return false;
+};
- case "JustifyCenter":
- img.removeAttribute('align');
+TinyMCE_Engine.prototype.accessibleEventHandler = function(e) {
+ var win = this._win;
+ e = tinyMCE.isMSIE ? win.event : e;
+ var elm = tinyMCE.isMSIE ? e.srcElement : e.target;
- // Is centered
- var div = tinyMCE.getParentElement(focusElm, "div");
- if (div && div.style.textAlign == "center") {
- // Remove div
- if (div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)
- div.parentNode.replaceChild(img, div);
- } else {
- // Add div
- var div = this.getDoc().createElement("div");
- div.style.textAlign = 'center';
- div.appendChild(img);
- focusElm.parentNode.replaceChild(div, focusElm);
- }
+ // Unpiggyback onchange on blur
+ if (e.type == "blur") {
+ if (elm.oldonchange) {
+ elm.onchange = elm.oldonchange;
+ elm.oldonchange = null;
+ }
- this.selectNode(img);
- this.repaint();
- tinyMCE.triggerNodeChange();
- return;
+ return true;
+ }
- case "JustifyRight":
- if (align == 'right')
- img.removeAttribute('align');
- else
- img.setAttribute('align', 'right');
+ // Piggyback onchange
+ if (elm.nodeName == "SELECT" && !elm.oldonchange) {
+ elm.oldonchange = elm.onchange;
+ elm.onchange = null;
+ }
- // Remove the div
- var div = focusElm.parentNode;
- if (div && div.nodeName == "DIV" && div.childNodes.length == 1 && div.parentNode)
- div.parentNode.replaceChild(img, div);
+ // Execute onchange and remove piggyback
+ if (e.keyCode == 13 || e.keyCode == 32) {
+ elm.onchange = elm.oldonchange;
+ elm.onchange();
+ elm.oldonchange = null;
- this.selectNode(img);
- this.repaint();
- tinyMCE.triggerNodeChange();
- return;
- }
+ tinyMCE.cancelEvent(e);
+ return false;
}
- if (tinyMCE.settings['force_br_newlines']) {
- var alignValue = "";
+ return true;
+};
- if (doc.selection.type != "Control") {
- switch (command) {
- case "JustifyLeft":
- alignValue = "left";
- break;
+/* file:jscripts/tiny_mce/classes/TinyMCE_Selection.class.js */
- case "JustifyCenter":
- alignValue = "center";
- break;
+function TinyMCE_Selection(inst) {
+ this.instance = inst;
+};
- case "JustifyFull":
- alignValue = "justify";
- break;
+TinyMCE_Selection.prototype = {
+ getSelectedHTML : function() {
+ var inst = this.instance;
+ var e, r = this.getRng(), h;
- case "JustifyRight":
- alignValue = "right";
- break;
- }
+ if (tinyMCE.isSafari) {
+ // Not realy perfect!!
+ return r.toString();
+ }
- if (alignValue != "") {
- var rng = doc.selection.createRange();
+ e = document.createElement("body");
- if ((divElm = tinyMCE.getParentElement(rng.parentElement(), "div")) != null)
- divElm.setAttribute("align", alignValue);
- else if (rng.pasteHTML && rng.htmlText.length > 0)
- rng.pasteHTML('<div align="' + alignValue + '">' + rng.htmlText + "</div>");
+ if (tinyMCE.isGecko)
+ e.appendChild(r.cloneContents());
+ else
+ e.innerHTML = r.htmlText;
- tinyMCE.triggerNodeChange();
- return;
- }
- }
- }
+ h = tinyMCE._cleanupHTML(inst, inst.contentDocument, inst.settings, e, e, false, true, false);
- switch (command) {
- case "mceRepaint":
- this.repaint();
- return true;
+ // When editing always use fonts internaly
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertSpansToFonts(inst.getDoc());
- case "mceStoreSelection":
- this.selectionBookmark = this.getBookmark();
- return true;
+ return h;
+ },
- case "mceRestoreSelection":
- this.moveToBookmark(this.selectionBookmark);
- return true;
+ getSelectedText : function() {
+ var inst = this.instance;
+ var d, r, s, t;
- case "InsertUnorderedList":
- case "InsertOrderedList":
- var tag = (command == "InsertUnorderedList") ? "ul" : "ol";
-
- if (tinyMCE.isSafari)
- this.execCommand("mceInsertContent", false, "<" + tag + "><li>&nbsp;</li><" + tag + ">");
- else
- this.getDoc().execCommand(command, user_interface, value);
+ if (tinyMCE.isMSIE) {
+ d = inst.getDoc();
- tinyMCE.triggerNodeChange();
- break;
+ if (d.selection.type == "Text") {
+ r = d.selection.createRange();
+ t = r.text;
+ } else
+ t = '';
+ } else {
+ s = this.getSel();
- case "Strikethrough":
- if (tinyMCE.isSafari)
- this.execCommand("mceInsertContent", false, "<strike>" + this.getSelectedHTML() + "</strike>");
+ if (s && s.toString)
+ t = s.toString();
else
- this.getDoc().execCommand(command, user_interface, value);
+ t = '';
+ }
- tinyMCE.triggerNodeChange();
- break;
+ return t;
+ },
- case "mceSelectNode":
- this.selectNode(value);
- tinyMCE.triggerNodeChange();
- tinyMCE.selectedNode = value;
- break;
+ getBookmark : function(simple) {
+ var rng = this.getRng();
+ var doc = this.instance.getDoc();
+ var sp, le, s, e, nl, i, si, ei;
+ var trng, sx, sy, xx = -999999999;
- case "FormatBlock":
- if (value == null || value == "") {
- var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address");
+ // Skip Opera for now
+ if (tinyMCE.isOpera)
+ return null;
- if (elm)
- this.execCommand("mceRemoveNode", false, elm);
- } else
- this.getDoc().execCommand("FormatBlock", false, value);
+ sx = doc.body.scrollLeft + doc.documentElement.scrollLeft;
+ sy = doc.body.scrollTop + doc.documentElement.scrollTop;
- tinyMCE.triggerNodeChange();
+ if (tinyMCE.isSafari || tinyMCE.isGecko)
+ return {rng : rng, scrollX : sx, scrollY : sy};
- break;
+ if (tinyMCE.isMSIE) {
+ if (simple)
+ return {rng : rng};
- case "mceRemoveNode":
- if (!value)
- value = tinyMCE.getParentElement(this.getFocusElement());
+ if (rng.item) {
+ e = rng.item(0);
- if (tinyMCE.isMSIE) {
- value.outerHTML = value.innerHTML;
+ nl = doc.getElementsByTagName(e.nodeName);
+ for (i=0; i<nl.length; i++) {
+ if (e == nl[i]) {
+ sp = i;
+ break;
+ }
+ }
+
+ return {
+ tag : e.nodeName,
+ index : sp,
+ scrollX : sx,
+ scrollY : sy
+ };
} else {
- var rng = value.ownerDocument.createRange();
- rng.setStartBefore(value);
- rng.setEndAfter(value);
- rng.deleteContents();
- rng.insertNode(rng.createContextualFragment(value.innerHTML));
+ trng = rng.duplicate();
+ trng.collapse(true);
+ sp = Math.abs(trng.move('character', xx));
+
+ trng = rng.duplicate();
+ trng.collapse(false);
+ le = Math.abs(trng.move('character', xx)) - sp;
+
+ return {
+ start : sp,
+ length : le,
+ scrollX : sx,
+ scrollY : sy
+ };
}
+ }
- tinyMCE.triggerNodeChange();
+ if (tinyMCE.isGecko) {
+ s = tinyMCE.getParentElement(rng.startContainer);
+ for (si=0; si<s.childNodes.length && s.childNodes[si] != rng.startContainer; si++) ;
- break;
+ nl = doc.getElementsByTagName(s.nodeName);
+ for (i=0; i<nl.length; i++) {
+ if (s == nl[i]) {
+ sp = i;
+ break;
+ }
+ }
- case "mceSelectNodeDepth":
- var parentNode = this.getFocusElement();
- for (var i=0; parentNode; i++) {
- if (parentNode.nodeName.toLowerCase() == "body")
- break;
+ e = tinyMCE.getParentElement(rng.endContainer);
+ for (ei=0; ei<e.childNodes.length && e.childNodes[ei] != rng.endContainer; ei++) ;
- if (parentNode.nodeName.toLowerCase() == "#text") {
- i--;
- parentNode = parentNode.parentNode;
- continue;
- }
+ nl = doc.getElementsByTagName(e.nodeName);
+ for (i=0; i<nl.length; i++) {
+ if (e == nl[i]) {
+ le = i;
+ break;
+ }
+ }
- if (i == value) {
- this.selectNode(parentNode, false);
- tinyMCE.triggerNodeChange();
- tinyMCE.selectedNode = parentNode;
- return;
- }
+ //tinyMCE.debug(s.nodeName, sp, rng.startOffset, '-' , e.nodeName, le, rng.endOffset);
+ //tinyMCE.debug(sx, sy);
+
+ return {
+ startTag : s.nodeName,
+ start : sp,
+ startIndex : si,
+ endTag : e.nodeName,
+ end : le,
+ endIndex : ei,
+ startOffset : rng.startOffset,
+ endOffset : rng.endOffset,
+ scrollX : sx,
+ scrollY : sy
+ };
+ }
+
+ return null;
+ },
+
+ moveToBookmark : function(bookmark) {
+ var rng, nl, i;
+ var inst = this.instance;
+ var doc = inst.getDoc();
+ var win = inst.getWin();
+ var sel = this.getSel();
- parentNode = parentNode.parentNode;
+ if (!bookmark)
+ return false;
+
+ if (tinyMCE.isSafari) {
+ sel.setBaseAndExtent(bookmark.startContainer, bookmark.startOffset, bookmark.endContainer, bookmark.endOffset);
+ return true;
+ }
+
+ if (tinyMCE.isMSIE) {
+ if (bookmark.rng) {
+ bookmark.rng.select();
+ return true;
}
- break;
+ win.focus();
- case "SetStyleInfo":
- var rng = this.getRng();
- var sel = this.getSel();
- var scmd = value['command'];
- var sname = value['name'];
- var svalue = value['value'] == null ? '' : value['value'];
- //var svalue = value['value'] == null ? '' : value['value'];
- var wrapper = value['wrapper'] ? value['wrapper'] : "span";
- var parentElm = null;
- var invalidRe = new RegExp("^BODY|HTML$", "g");
- var invalidParentsRe = tinyMCE.settings['merge_styles_invalid_parents'] != '' ? new RegExp(tinyMCE.settings['merge_styles_invalid_parents'], "gi") : null;
-
- // Whole element selected check
- if (tinyMCE.isMSIE) {
- // Control range
- if (rng.item)
- parentElm = rng.item(0);
- else {
- var pelm = rng.parentElement();
- var prng = doc.selection.createRange();
- prng.moveToElementText(pelm);
-
- if (rng.htmlText == prng.htmlText || rng.boundingWidth == 0) {
- if (invalidParentsRe == null || !invalidParentsRe.test(pelm.nodeName))
- parentElm = pelm;
- }
- }
+ if (bookmark.tag) {
+ rng = inst.getBody().createControlRange();
+
+ nl = doc.getElementsByTagName(bookmark.tag);
+
+ if (nl.length > bookmark.index)
+ rng.addElement(nl[bookmark.index]);
} else {
- var felm = this.getFocusElement();
- if (sel.isCollapsed || (/td|tr|tbody|table/ig.test(felm.nodeName) && sel.anchorNode == felm.parentNode))
- parentElm = felm;
+ rng = inst.getSel().createRange();
+ rng.moveToElementText(inst.getBody());
+ rng.collapse(true);
+ rng.moveStart('character', bookmark.start);
+ rng.moveEnd('character', bookmark.length);
}
- // Whole element selected
- if (parentElm && !invalidRe.test(parentElm.nodeName)) {
- if (scmd == "setstyle")
- tinyMCE.setStyleAttrib(parentElm, sname, svalue);
+ rng.select();
- if (scmd == "setattrib")
- tinyMCE.setAttrib(parentElm, sname, svalue);
+ win.scrollTo(bookmark.scrollX, bookmark.scrollY);
+ return true;
+ }
- if (scmd == "removeformat") {
- parentElm.style.cssText = '';
- tinyMCE.setAttrib(parentElm, 'class', '');
- }
+ if (tinyMCE.isGecko && bookmark.rng) {
+ sel.removeAllRanges();
+ sel.addRange(bookmark.rng);
+ win.scrollTo(bookmark.scrollX, bookmark.scrollY);
+ return true;
+ }
- // Remove style/attribs from all children
- var ch = tinyMCE.getNodeTree(parentElm, new Array(), 1);
- for (var z=0; z<ch.length; z++) {
- if (ch[z] == parentElm)
- continue;
+ if (tinyMCE.isGecko) {
+ // try {
+ rng = doc.createRange();
- if (scmd == "setstyle")
- tinyMCE.setStyleAttrib(ch[z], sname, '');
+ nl = doc.getElementsByTagName(bookmark.startTag);
+ if (nl.length > bookmark.start)
+ rng.setStart(nl[bookmark.start].childNodes[bookmark.startIndex], bookmark.startOffset);
- if (scmd == "setattrib")
- tinyMCE.setAttrib(ch[z], sname, '');
+ nl = doc.getElementsByTagName(bookmark.endTag);
+ if (nl.length > bookmark.end)
+ rng.setEnd(nl[bookmark.end].childNodes[bookmark.endIndex], bookmark.endOffset);
- if (scmd == "removeformat") {
- ch[z].style.cssText = '';
- tinyMCE.setAttrib(ch[z], 'class', '');
- }
- }
- } else {
- doc.execCommand("fontname", false, "#mce_temp_font#");
- var elementArray = tinyMCE.getElementsByAttributeValue(this.getBody(), "font", "face", "#mce_temp_font#");
+ sel.removeAllRanges();
+ sel.addRange(rng);
+ /* } catch {
+ // Ignore
+ }*/
- // Change them all
- for (var x=0; x<elementArray.length; x++) {
- elm = elementArray[x];
- if (elm) {
- var spanElm = doc.createElement(wrapper);
+ win.scrollTo(bookmark.scrollX, bookmark.scrollY);
+ return true;
+ }
- if (scmd == "setstyle")
- tinyMCE.setStyleAttrib(spanElm, sname, svalue);
+ return false;
+ },
- if (scmd == "setattrib")
- tinyMCE.setAttrib(spanElm, sname, svalue);
+ selectNode : function(node, collapse, select_text_node, to_start) {
+ var inst = this.instance, sel, rng, nodes;
- if (scmd == "removeformat") {
- spanElm.style.cssText = '';
- tinyMCE.setAttrib(spanElm, 'class', '');
- }
+ if (!node)
+ return;
- if (elm.hasChildNodes()) {
- for (var i=0; i<elm.childNodes.length; i++)
- spanElm.appendChild(elm.childNodes[i].cloneNode(true));
- }
+ if (typeof(collapse) == "undefined")
+ collapse = true;
- spanElm.setAttribute("mce_new", "true");
- elm.parentNode.replaceChild(spanElm, elm);
+ if (typeof(select_text_node) == "undefined")
+ select_text_node = false;
- // Remove style/attribs from all children
- var ch = tinyMCE.getNodeTree(spanElm, new Array(), 1);
- for (var z=0; z<ch.length; z++) {
- if (ch[z] == spanElm)
- continue;
+ if (typeof(to_start) == "undefined")
+ to_start = true;
- if (scmd == "setstyle")
- tinyMCE.setStyleAttrib(ch[z], sname, '');
+ if (tinyMCE.isMSIE) {
+ rng = inst.getBody().createTextRange();
- if (scmd == "setattrib")
- tinyMCE.setAttrib(ch[z], sname, '');
+ try {
+ rng.moveToElementText(node);
- if (scmd == "removeformat") {
- ch[z].style.cssText = '';
- tinyMCE.setAttrib(ch[z], 'class', '');
- }
- }
- }
- }
+ if (collapse)
+ rng.collapse(to_start);
+
+ rng.select();
+ } catch (e) {
+ // Throws illigal agrument in MSIE some times
}
+ } else {
+ sel = this.getSel();
- // Cleaup wrappers
- var nodes = doc.getElementsByTagName(wrapper);
- for (var i=nodes.length-1; i>=0; i--) {
- var elm = nodes[i];
- var isNew = tinyMCE.getAttrib(elm, "mce_new") == "true";
+ if (!sel)
+ return;
- elm.removeAttribute("mce_new");
+ if (tinyMCE.isSafari) {
+ sel.setBaseAndExtent(node, 0, node, node.innerText.length);
- // Is only child a element
- if (elm.childNodes && elm.childNodes.length == 1 && elm.childNodes[0].nodeType == 1) {
- //tinyMCE.debug("merge1" + isNew);
- this._mergeElements(scmd, elm, elm.childNodes[0], isNew);
- continue;
+ if (collapse) {
+ if (to_start)
+ sel.collapseToStart();
+ else
+ sel.collapseToEnd();
}
- // Is I the only child
- if (elm.parentNode.childNodes.length == 1 && !invalidRe.test(elm.nodeName) && !invalidRe.test(elm.parentNode.nodeName)) {
- //tinyMCE.debug("merge2" + isNew + "," + elm.nodeName + "," + elm.parentNode.nodeName);
- if (invalidParentsRe == null || !invalidParentsRe.test(elm.parentNode.nodeName))
- this._mergeElements(scmd, elm.parentNode, elm, false);
- }
+ this.scrollToNode(node);
+
+ return;
}
- // Remove empty wrappers
- var nodes = doc.getElementsByTagName(wrapper);
- for (var i=nodes.length-1; i>=0; i--) {
- var elm = nodes[i];
- var isEmpty = true;
-
- // Check if it has any attribs
- var tmp = doc.createElement("body");
- tmp.appendChild(elm.cloneNode(false));
-
- // Is empty span, remove it
- tmp.innerHTML = tmp.innerHTML.replace(new RegExp('style=""|class=""', 'gi'), '');
- //tinyMCE.debug(tmp.innerHTML);
- if (new RegExp('<span>', 'gi').test(tmp.innerHTML)) {
- for (var x=0; x<elm.childNodes.length; x++) {
- if (elm.parentNode != null)
- elm.parentNode.insertBefore(elm.childNodes[x].cloneNode(true), elm);
- }
+ rng = inst.getDoc().createRange();
- elm.parentNode.removeChild(elm);
- }
- }
+ if (select_text_node) {
+ // Find first textnode in tree
+ nodes = tinyMCE.getNodeTree(node, new Array(), 3);
+ if (nodes.length > 0)
+ rng.selectNodeContents(nodes[0]);
+ else
+ rng.selectNodeContents(node);
+ } else
+ rng.selectNode(node);
- // Re add the visual aids
- if (scmd == "removeformat")
- tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
+ if (collapse) {
+ // Special treatment of textnode collapse
+ if (!to_start && node.nodeType == 3) {
+ rng.setStart(node, node.nodeValue.length);
+ rng.setEnd(node, node.nodeValue.length);
+ } else
+ rng.collapse(to_start);
+ }
- tinyMCE.triggerNodeChange();
+ sel.removeAllRanges();
+ sel.addRange(rng);
+ }
- break;
+ this.scrollToNode(node);
- case "FontName":
- if (value == null) {
- var s = this.getSel();
+ // Set selected element
+ tinyMCE.selectedElement = null;
+ if (node.nodeType == 1)
+ tinyMCE.selectedElement = node;
+ },
- // Find font and select it
- if (tinyMCE.isGecko && s.isCollapsed) {
- var f = tinyMCE.getParentElement(this.getFocusElement(), "font");
+ scrollToNode : function(node) {
+ var inst = this.instance;
+ var pos, doc, scrollX, scrollY, height;
- if (f != null)
- this.selectNode(f, false);
- }
+ // Scroll to node position
+ pos = tinyMCE.getAbsPosition(node);
+ doc = inst.getDoc();
+ scrollX = doc.body.scrollLeft + doc.documentElement.scrollLeft;
+ scrollY = doc.body.scrollTop + doc.documentElement.scrollTop;
+ height = tinyMCE.isMSIE ? document.getElementById(inst.editorId).style.pixelHeight : inst.targetElement.clientHeight;
- // Remove format
- this.getDoc().execCommand("RemoveFormat", false, null);
+ // Only scroll if out of visible area
+ if (!tinyMCE.settings['auto_resize'] && !(pos.absTop > scrollY && pos.absTop < (scrollY - 25 + height)))
+ inst.contentWindow.scrollTo(pos.absLeft, pos.absTop - height + 25);
+ },
- // Collapse range if font was found
- if (f != null && tinyMCE.isGecko) {
- var r = this.getRng().cloneRange();
- r.collapse(true);
- s.removeAllRanges();
- s.addRange(r);
- }
- } else
- this.getDoc().execCommand('FontName', false, value);
+ getSel : function() {
+ var inst = this.instance;
- if (tinyMCE.isGecko)
- window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ return inst.getDoc().selection;
- return;
+ return inst.contentWindow.getSelection();
+ },
- case "FontSize":
- this.getDoc().execCommand('FontSize', false, value);
+ getRng : function() {
+ var inst = this.instance;
+ var sel = this.getSel();
- if (tinyMCE.isGecko)
- window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
+ if (sel == null)
+ return null;
- return;
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ return sel.createRange();
- case "forecolor":
- this.getDoc().execCommand('forecolor', false, value);
- break;
+ if (tinyMCE.isSafari && !sel.getRangeAt)
+ return '' + window.getSelection();
- case "HiliteColor":
- if (tinyMCE.isGecko) {
- this.setUseCSS(true);
- this.getDoc().execCommand('hilitecolor', false, value);
- this.setUseCSS(false);
- } else
- this.getDoc().execCommand('BackColor', false, value);
- break;
+ return sel.getRangeAt(0);
+ },
- case "Cut":
- case "Copy":
- case "Paste":
- var cmdFailed = false;
+ getFocusElement : function() {
+ var inst = this.instance;
- // Try executing command
- eval('try {this.getDoc().execCommand(command, user_interface, value);} catch (e) {cmdFailed = true;}');
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ var doc = inst.getDoc();
+ var rng = doc.selection.createRange();
- if (tinyMCE.isOpera && cmdFailed)
- alert('Currently not supported by your browser, use keyboard shortcuts instead.');
+ // if (rng.collapse)
+ // rng.collapse(true);
- // Alert error in gecko if command failed
- if (tinyMCE.isGecko && cmdFailed) {
- // Confirm more info
- if (confirm(tinyMCE.getLang('lang_clipboard_msg')))
- window.open('http://www.mozilla.org/editor/midasdemo/securityprefs.html', 'mceExternal');
+ var elm = rng.item ? rng.item(0) : rng.parentElement();
+ } else {
+ if (inst.isHidden())
+ return inst.getBody();
- return;
- } else
- tinyMCE.triggerNodeChange();
- break;
-
- case "mceSetContent":
- if (!value)
- value = "";
-
- // Call custom cleanup code
- value = tinyMCE.storeAwayURLs(value);
- //value = tinyMCE._customCleanup(this, "insert_to_editor", value);
- tinyMCE._setHTML(doc, value);
- tinyMCE.setInnerHTML(doc.body, tinyMCE._cleanupHTML(this, doc, tinyMCE.settings, doc.body));
- this.convertAllRelativeURLs();
- tinyMCE.handleVisualAid(doc.body, true, this.visualAid, this);
- tinyMCE._setEventsEnabled(doc.body, false);
- return true;
+ var sel = this.getSel();
+ var rng = this.getRng();
- case "mceLink":
- var selectedText = "";
+ if (!sel || !rng)
+ return null;
- if (tinyMCE.isMSIE) {
- var rng = doc.selection.createRange();
- selectedText = rng.text;
- } else
- selectedText = this.getSel().toString();
+ var elm = rng.commonAncestorContainer;
+ //var elm = (sel && sel.anchorNode) ? sel.anchorNode : null;
- if (!tinyMCE.linkElement) {
- if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0))
- return;
+ // Handle selection a image or other control like element such as anchors
+ if (!rng.collapsed) {
+ // Is selection small
+ if (rng.startContainer == rng.endContainer) {
+ if (rng.startOffset - rng.endOffset < 2) {
+ if (rng.startContainer.hasChildNodes())
+ elm = rng.startContainer.childNodes[rng.startOffset];
+ }
+ }
}
- var href = "", target = "", title = "", onclick = "", action = "insert", style_class = "";
+ // Get the element parent of the node
+ elm = tinyMCE.getParentElement(elm);
- if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a")
- tinyMCE.linkElement = tinyMCE.selectedElement;
+ //if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img")
+ // elm = tinyMCE.selectedElement;
+ }
- // Is anchor not a link
- if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "")
- tinyMCE.linkElement = null;
+ return elm;
+ }
+};
- if (tinyMCE.linkElement) {
- href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href');
- target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target');
- title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title');
- onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');
- style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class');
+/* file:jscripts/tiny_mce/classes/TinyMCE_UndoRedo.class.js */
- // Try old onclick to if copy/pasted content
- if (onclick == "")
- onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');
+function TinyMCE_UndoRedo(inst) {
+ this.instance = inst;
+ this.undoLevels = new Array();
+ this.undoIndex = 0;
+ this.typingUndoIndex = -1;
+ this.undoRedo = true;
+};
- onclick = tinyMCE.cleanupEventStr(onclick);
+TinyMCE_UndoRedo.prototype = {
+ add : function(l) {
+ var b;
- href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");
+ if (l) {
+ this.undoLevels[this.undoLevels.length] = l;
+ return true;
+ }
- // Use mce_href if defined
- mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href');
- if (mceRealHref != "") {
- href = mceRealHref;
+ var inst = this.instance;
- if (tinyMCE.getParam('convert_urls'))
- href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");
- }
+ if (this.typingUndoIndex != -1) {
+ this.undoIndex = this.typingUndoIndex;
+ // tinyMCE.debug("Override: " + this.undoIndex);
+ }
- action = "update";
- }
+ var newHTML = tinyMCE.trim(inst.getBody().innerHTML);
+ if (this.undoLevels[this.undoIndex] && newHTML != this.undoLevels[this.undoIndex].content) {
+ //tinyMCE.debug(newHTML, this.undoLevels[this.undoIndex]);
- if (this.settings['insertlink_callback']) {
- var returnVal = eval(this.settings['insertlink_callback'] + "(href, target, title, onclick, action, style_class);");
- if (returnVal && returnVal['href'])
- tinyMCE.insertLink(returnVal['href'], returnVal['target'], returnVal['title'], returnVal['onclick'], returnVal['style_class']);
- } else {
- tinyMCE.openWindow(this.insertLinkTemplate, {href : href, target : target, title : title, onclick : onclick, action : action, className : style_class, inline : "yes"});
- }
- break;
+ tinyMCE.dispatchCallback(inst, 'onchange_callback', 'onChange', inst);
- case "mceImage":
- var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = "";
- var title = "", onmouseover = "", onmouseout = "", action = "insert";
- var img = tinyMCE.imgElement;
+ // Time to compress
+ var customUndoLevels = tinyMCE.settings['custom_undo_redo_levels'];
+ if (customUndoLevels != -1 && this.undoLevels.length > customUndoLevels) {
+ for (var i=0; i<this.undoLevels.length-1; i++) {
+ //tinyMCE.debug(this.undoLevels[i] + "=" + this.undoLevels[i+1]);
+ this.undoLevels[i] = this.undoLevels[i+1];
+ }
- if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") {
- img = tinyMCE.selectedElement;
- tinyMCE.imgElement = img;
+ this.undoLevels.length--;
+ this.undoIndex--;
}
- if (img) {
- // Is it a internal MCE visual aid image, then skip this one.
- if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0)
- return;
+ b = inst.undoBookmark;
+ if (!b)
+ b = inst.selection.getBookmark();
- src = tinyMCE.getAttrib(img, 'src');
- alt = tinyMCE.getAttrib(img, 'alt');
+ this.undoIndex++;
+ this.undoLevels[this.undoIndex] = {
+ content : newHTML,
+ bookmark : b
+ };
- // Try polling out the title
- if (alt == "")
- alt = tinyMCE.getAttrib(img, 'title');
+ this.undoLevels.length = this.undoIndex + 1;
- // Fix width/height attributes if the styles is specified
- if (tinyMCE.isGecko) {
- var w = img.style.width;
- if (w != null && w != "")
- img.setAttribute("width", w);
+ //tinyMCE.debug("level added" + this.undoIndex);
+ return true;
- var h = img.style.height;
- if (h != null && h != "")
- img.setAttribute("height", h);
- }
+ // tinyMCE.debug(this.undoIndex + "," + (this.undoLevels.length-1));
+ }
- border = tinyMCE.getAttrib(img, 'border');
- hspace = tinyMCE.getAttrib(img, 'hspace');
- vspace = tinyMCE.getAttrib(img, 'vspace');
- width = tinyMCE.getAttrib(img, 'width');
- height = tinyMCE.getAttrib(img, 'height');
- align = tinyMCE.getAttrib(img, 'align');
- onmouseover = tinyMCE.getAttrib(img, 'onmouseover');
- onmouseout = tinyMCE.getAttrib(img, 'onmouseout');
- title = tinyMCE.getAttrib(img, 'title');
-
- // Is realy specified?
- if (tinyMCE.isMSIE) {
- width = img.attributes['width'].specified ? width : "";
- height = img.attributes['height'].specified ? height : "";
- }
+ return false;
+ },
+
+ undo : function() {
+ var inst = this.instance;
+
+ // Do undo
+ if (this.undoIndex > 0) {
+ this.undoIndex--;
+ tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content);
+ inst.repaint();
+ if (inst.settings.custom_undo_redo_restore_selection)
+ inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark);
+ }
- onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover));
- onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout));
+ // tinyMCE.debug("Undo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex);
+ },
- src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
+ redo : function() {
+ var inst = this.instance;
- // Use mce_src if defined
- mceRealSrc = tinyMCE.getAttrib(img, 'mce_src');
- if (mceRealSrc != "") {
- src = mceRealSrc;
+ tinyMCE.execCommand("mceEndTyping");
- if (tinyMCE.getParam('convert_urls'))
- src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
- }
+ if (this.undoIndex < (this.undoLevels.length-1)) {
+ this.undoIndex++;
+ tinyMCE.setInnerHTML(inst.getBody(), this.undoLevels[this.undoIndex].content);
+ inst.repaint();
+// if (this.undoIndex > 0)
+// inst.selection.moveToBookmark(this.undoLevels[this.undoIndex-1].bookmark);
+ if (inst.settings.custom_undo_redo_restore_selection)
+ inst.selection.moveToBookmark(this.undoLevels[this.undoIndex].bookmark);
+ // tinyMCE.debug("Redo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex);
+ }
- if (onmouseover != "")
- onmouseover = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, img, true);");
+ tinyMCE.triggerNodeChange();
+ }
+};
- if (onmouseout != "")
- onmouseout = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, img, true);");
+/* file:jscripts/tiny_mce/classes/TinyMCE_ForceParagraphs.class.js */
- action = "update";
+var TinyMCE_ForceParagraphs = {
+ _insertPara : function(inst, e) {
+ function isEmpty(para) {
+ function isEmptyHTML(html) {
+ return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == "";
}
- if (this.settings['insertimage_callback']) {
- var returnVal = eval(this.settings['insertimage_callback'] + "(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);");
- if (returnVal && returnVal['src'])
- tinyMCE.insertImage(returnVal['src'], returnVal['alt'], returnVal['border'], returnVal['hspace'], returnVal['vspace'], returnVal['width'], returnVal['height'], returnVal['align'], returnVal['title'], returnVal['onmouseover'], returnVal['onmouseout']);
- } else
- tinyMCE.openWindow(this.insertImageTemplate, {src : src, alt : alt, border : border, hspace : hspace, vspace : vspace, width : width, height : height, align : align, title : title, onmouseover : onmouseover, onmouseout : onmouseout, action : action, inline : "yes"});
- break;
-
- case "mceCleanup":
- tinyMCE._setHTML(this.contentDocument, this.getBody().innerHTML);
- tinyMCE.setInnerHTML(this.getBody(), tinyMCE._cleanupHTML(this, this.contentDocument, this.settings, this.getBody(), this.visualAid));
- this.convertAllRelativeURLs();
- tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
- tinyMCE._setEventsEnabled(this.getBody(), false);
- this.repaint();
- tinyMCE.triggerNodeChange();
- break;
-
- case "mceReplaceContent":
- this.getWin().focus();
-
- var selectedText = "";
-
- if (tinyMCE.isMSIE) {
- var rng = doc.selection.createRange();
- selectedText = rng.text;
- } else
- selectedText = this.getSel().toString();
+ // Check for images
+ if (para.getElementsByTagName("img").length > 0)
+ return false;
+
+ // Check for tables
+ if (para.getElementsByTagName("table").length > 0)
+ return false;
- if (selectedText.length > 0) {
- value = tinyMCE.replaceVar(value, "selection", selectedText);
- tinyMCE.execCommand('mceInsertContent', false, value);
+ // Check for HRs
+ if (para.getElementsByTagName("hr").length > 0)
+ return false;
+
+ // Check all textnodes
+ var nodes = tinyMCE.getNodeTree(para, new Array(), 3);
+ for (var i=0; i<nodes.length; i++) {
+ if (!isEmptyHTML(nodes[i].nodeValue))
+ return false;
}
- tinyMCE.triggerNodeChange();
- break;
+ // No images, no tables, no hrs, no text content then it's empty
+ return true;
+ }
- case "mceSetAttribute":
- if (typeof(value) == 'object') {
- var targetElms = (typeof(value['targets']) == "undefined") ? "p,img,span,div,td,h1,h2,h3,h4,h5,h6,pre,address" : value['targets'];
- var targetNode = tinyMCE.getParentElement(this.getFocusElement(), targetElms);
+ var doc = inst.getDoc();
+ var sel = inst.getSel();
+ var win = inst.contentWindow;
+ var rng = sel.getRangeAt(0);
+ var body = doc.body;
+ var rootElm = doc.documentElement;
+ var blockName = "P";
+
+ // tinyMCE.debug(body.innerHTML);
+
+ // debug(e.target, sel.anchorNode.nodeName, sel.focusNode.nodeName, rng.startContainer, rng.endContainer, rng.commonAncestorContainer, sel.anchorOffset, sel.focusOffset, rng.toString());
+
+ // Setup before range
+ var rngBefore = doc.createRange();
+ rngBefore.setStart(sel.anchorNode, sel.anchorOffset);
+ rngBefore.collapse(true);
+
+ // Setup after range
+ var rngAfter = doc.createRange();
+ rngAfter.setStart(sel.focusNode, sel.focusOffset);
+ rngAfter.collapse(true);
+
+ // Setup start/end points
+ var direct = rngBefore.compareBoundaryPoints(rngBefore.START_TO_END, rngAfter) < 0;
+ var startNode = direct ? sel.anchorNode : sel.focusNode;
+ var startOffset = direct ? sel.anchorOffset : sel.focusOffset;
+ var endNode = direct ? sel.focusNode : sel.anchorNode;
+ var endOffset = direct ? sel.focusOffset : sel.anchorOffset;
+
+ startNode = startNode.nodeName == "BODY" ? startNode.firstChild : startNode;
+ endNode = endNode.nodeName == "BODY" ? endNode.firstChild : endNode;
+
+ // tinyMCE.debug(startNode, endNode);
+
+ // Get block elements
+ var startBlock = tinyMCE.getParentBlockElement(startNode);
+ var endBlock = tinyMCE.getParentBlockElement(endNode);
+
+ // Use current block name
+ if (startBlock != null) {
+ blockName = startBlock.nodeName;
+
+ // Use P instead
+ if (blockName == "TD" || blockName == "TABLE" || (blockName == "DIV" && new RegExp('left|right', 'gi').test(startBlock.style.cssFloat)))
+ blockName = "P";
+ }
- if (targetNode) {
- targetNode.setAttribute(value['name'], value['value']);
- tinyMCE.triggerNodeChange();
- }
- }
- break;
+ // Within a list use normal behaviour
+ if (tinyMCE.getParentElement(startBlock, "OL,UL") != null)
+ return false;
- case "mceSetCSSClass":
- this.execCommand("SetStyleInfo", false, {command : "setattrib", name : "class", value : value});
- break;
+ // Within a table create new paragraphs
+ if ((startBlock != null && startBlock.nodeName == "TABLE") || (endBlock != null && endBlock.nodeName == "TABLE"))
+ startBlock = endBlock = null;
- case "mceInsertRawHTML":
- var key = 'tiny_mce_marker';
+ // Setup new paragraphs
+ var paraBefore = (startBlock != null && startBlock.nodeName == blockName) ? startBlock.cloneNode(false) : doc.createElement(blockName);
+ var paraAfter = (endBlock != null && endBlock.nodeName == blockName) ? endBlock.cloneNode(false) : doc.createElement(blockName);
- this.execCommand('mceBeginUndoLevel');
+ // Is header, then force paragraph under
+ if (/^(H[1-6])$/.test(blockName))
+ paraAfter = doc.createElement("p");
- // Insert marker key
- this.execCommand('mceInsertContent', false, key);
+ // Setup chop nodes
+ var startChop = startNode;
+ var endChop = endNode;
- // Store away scroll pos
- var scrollX = this.getDoc().body.scrollLeft + this.getDoc().documentElement.scrollLeft;
- var scrollY = this.getDoc().body.scrollTop + this.getDoc().documentElement.scrollTop;
+ // Get startChop node
+ node = startChop;
+ do {
+ if (node == body || node.nodeType == 9 || tinyMCE.isBlockElement(node))
+ break;
- // Find marker and replace with RAW HTML
- var html = this.getBody().innerHTML;
- if ((pos = html.indexOf(key)) != -1)
- tinyMCE.setInnerHTML(this.getBody(), html.substring(0, pos) + value + html.substring(pos + key.length));
+ startChop = node;
+ } while ((node = node.previousSibling ? node.previousSibling : node.parentNode));
- // Restore scoll pos
- this.contentWindow.scrollTo(scrollX, scrollY);
+ // Get endChop node
+ node = endChop;
+ do {
+ if (node == body || node.nodeType == 9 || tinyMCE.isBlockElement(node))
+ break;
- this.execCommand('mceEndUndoLevel');
+ endChop = node;
+ } while ((node = node.nextSibling ? node.nextSibling : node.parentNode));
- break;
+ // Fix when only a image is within the TD
+ if (startChop.nodeName == "TD")
+ startChop = startChop.firstChild;
- case "mceInsertContent":
- var insertHTMLFailed = false;
- this.getWin().focus();
-/* WP
- if (tinyMCE.isGecko || tinyMCE.isOpera) {
- try {
- // Is plain text or HTML
- if (value.indexOf('<') == -1) {
- var r = this.getRng();
- var n = this.getDoc().createTextNode(tinyMCE.entityDecode(value));
- var s = this.getSel();
- var r2 = r.cloneRange();
-
- // Insert text at cursor position
- s.removeAllRanges();
- r.deleteContents();
- r.insertNode(n);
+ if (endChop.nodeName == "TD")
+ endChop = endChop.lastChild;
- // Move the cursor to the end of text
- r2.selectNode(n);
- r2.collapse(false);
- s.removeAllRanges();
- s.addRange(r2);
- } else {
- value = tinyMCE.fixGeckoBaseHREFBug(1, this.getDoc(), value);
- this.getDoc().execCommand('inserthtml', false, value);
- tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value);
- }
- } catch (ex) {
- insertHTMLFailed = true;
- }
+ // If not in a block element
+ if (startBlock == null) {
+ // Delete selection
+ rng.deleteContents();
+ sel.removeAllRanges();
- if (!insertHTMLFailed) {
- tinyMCE.triggerNodeChange();
- return;
- }
- }
-*/
- // Ugly hack in Opera due to non working "inserthtml"
- if (tinyMCE.isOpera && insertHTMLFailed) {
- this.getDoc().execCommand("insertimage", false, tinyMCE.uniqueURL);
- var ar = tinyMCE.getElementsByAttributeValue(this.getBody(), "img", "src", tinyMCE.uniqueURL);
- ar[0].outerHTML = value;
- return;
- }
+ if (startChop != rootElm && endChop != rootElm) {
+ // Insert paragraph before
+ rngBefore = rng.cloneRange();
- if (!tinyMCE.isMSIE) {
- var isHTML = value.indexOf('<') != -1;
- var sel = this.getSel();
- var rng = this.getRng();
+ if (startChop == body)
+ rngBefore.setStart(startChop, 0);
+ else
+ rngBefore.setStartBefore(startChop);
- if (isHTML) {
- if (tinyMCE.isSafari) {
- var tmpRng = this.getDoc().createRange();
+ paraBefore.appendChild(rngBefore.cloneContents());
- tmpRng.setStart(this.getBody(), 0);
- tmpRng.setEnd(this.getBody(), 0);
+ // Insert paragraph after
+ if (endChop.parentNode.nodeName == blockName)
+ endChop = endChop.parentNode;
- value = tmpRng.createContextualFragment(value);
- } else
- value = rng.createContextualFragment(value);
- } else {
- // Setup text node
- var el = document.createElement("div");
- el.innerHTML = value;
- value = el.firstChild.nodeValue;
- value = doc.createTextNode(value);
- }
+ // If not after image
+ //if (rng.startContainer.nodeName != "BODY" && rng.endContainer.nodeName != "BODY")
+ rng.setEndAfter(endChop);
- // Insert plain text in Safari
- if (tinyMCE.isSafari && !isHTML) {
- this.execCommand('InsertText', false, value.nodeValue);
- tinyMCE.triggerNodeChange();
- return true;
- } else if (tinyMCE.isSafari && isHTML) {
- rng.deleteContents();
- rng.insertNode(value);
- tinyMCE.triggerNodeChange();
- return true;
- }
+ if (endChop.nodeName != "#text" && endChop.nodeName != "BODY")
+ rngBefore.setEndAfter(endChop);
- rng.deleteContents();
+ var contents = rng.cloneContents();
+ if (contents.firstChild && (contents.firstChild.nodeName == blockName || contents.firstChild.nodeName == "BODY"))
+ paraAfter.innerHTML = contents.firstChild.innerHTML;
+ else
+ paraAfter.appendChild(contents);
- // If target node is text do special treatment, (Mozilla 1.3 fix)
- if (rng.startContainer.nodeType == 3) {
- var node = rng.startContainer.splitText(rng.startOffset);
- node.parentNode.insertBefore(value, node);
- } else
- rng.insertNode(value);
+ // Check if it's a empty paragraph
+ if (isEmpty(paraBefore))
+ paraBefore.innerHTML = "&nbsp;";
- if (!isHTML) {
- // Removes weird selection trails
- sel.selectAllChildren(doc.body);
- sel.removeAllRanges();
+ // Check if it's a empty paragraph
+ if (isEmpty(paraAfter))
+ paraAfter.innerHTML = "&nbsp;";
- // Move cursor to end of content
- var rng = doc.createRange();
+ // Delete old contents
+ rng.deleteContents();
+ rngAfter.deleteContents();
+ rngBefore.deleteContents();
- rng.selectNode(value);
- rng.collapse(false);
+ // Insert new paragraphs
+ paraAfter.normalize();
+ rngBefore.insertNode(paraAfter);
+ paraBefore.normalize();
+ rngBefore.insertNode(paraBefore);
- sel.addRange(rng);
- } else
- rng.collapse(false);
+ // tinyMCE.debug("1: ", paraBefore.innerHTML, paraAfter.innerHTML);
} else {
- var rng = doc.selection.createRange();
- var c = value.indexOf('<!--') != -1;
+ body.innerHTML = "<" + blockName + ">&nbsp;</" + blockName + "><" + blockName + ">&nbsp;</" + blockName + ">";
+ paraAfter = body.childNodes[1];
+ }
- // Fix comment bug, add tag before comments
- if (c)
- value = tinyMCE.uniqueTag + value;
+ inst.selection.selectNode(paraAfter, true, true);
- if (rng.item)
- rng.item(0).outerHTML = value;
- else
- rng.pasteHTML(value);
+ return true;
+ }
- // Remove unique tag
- if (c) {
- var e = this.getDoc().getElementById('mceTMPElement');
- e.parentNode.removeChild(e);
- }
+ // Place first part within new paragraph
+ if (startChop.nodeName == blockName)
+ rngBefore.setStart(startChop, 0);
+ else
+ rngBefore.setStartBefore(startChop);
+
+ rngBefore.setEnd(startNode, startOffset);
+ paraBefore.appendChild(rngBefore.cloneContents());
+
+ // Place secound part within new paragraph
+ rngAfter.setEndAfter(endChop);
+ rngAfter.setStart(endNode, endOffset);
+ var contents = rngAfter.cloneContents();
+
+ if (contents.firstChild && contents.firstChild.nodeName == blockName) {
+ /* var nodes = contents.firstChild.childNodes;
+ for (var i=0; i<nodes.length; i++) {
+ //tinyMCE.debug(nodes[i].nodeName);
+ if (nodes[i].nodeName != "BODY")
+ paraAfter.appendChild(nodes[i]);
}
+ */
+ paraAfter.innerHTML = contents.firstChild.innerHTML;
+ } else
+ paraAfter.appendChild(contents);
- tinyMCE.triggerNodeChange();
- break;
+ // Check if it's a empty paragraph
+ if (isEmpty(paraBefore))
+ paraBefore.innerHTML = "&nbsp;";
- case "mceStartTyping":
- if (tinyMCE.settings['custom_undo_redo'] && this.typingUndoIndex == -1) {
- this.typingUndoIndex = this.undoIndex;
- this.execCommand('mceAddUndoLevel');
- //tinyMCE.debug("mceStartTyping");
- }
- break;
+ // Check if it's a empty paragraph
+ if (isEmpty(paraAfter))
+ paraAfter.innerHTML = "&nbsp;";
- case "mceEndTyping":
- if (tinyMCE.settings['custom_undo_redo'] && this.typingUndoIndex != -1) {
- this.execCommand('mceAddUndoLevel');
- this.typingUndoIndex = -1;
- //tinyMCE.debug("mceEndTyping");
- }
- break;
+ // Create a range around everything
+ var rng = doc.createRange();
- case "mceBeginUndoLevel":
- this.undoRedo = false;
- break;
+ if (!startChop.previousSibling && startChop.parentNode.nodeName.toUpperCase() == blockName) {
+ rng.setStartBefore(startChop.parentNode);
+ } else {
+ if (rngBefore.startContainer.nodeName.toUpperCase() == blockName && rngBefore.startOffset == 0)
+ rng.setStartBefore(rngBefore.startContainer);
+ else
+ rng.setStart(rngBefore.startContainer, rngBefore.startOffset);
+ }
- case "mceEndUndoLevel":
- this.undoRedo = true;
- this.execCommand('mceAddUndoLevel');
- break;
+ if (!endChop.nextSibling && endChop.parentNode.nodeName.toUpperCase() == blockName)
+ rng.setEndAfter(endChop.parentNode);
+ else
+ rng.setEnd(rngAfter.endContainer, rngAfter.endOffset);
- case "mceAddUndoLevel":
- if (tinyMCE.settings['custom_undo_redo'] && this.undoRedo) {
- // tinyMCE.debug("add level");
+ // Delete all contents and insert new paragraphs
+ rng.deleteContents();
+ rng.insertNode(paraAfter);
+ rng.insertNode(paraBefore);
+ //tinyMCE.debug("2", paraBefore.innerHTML, paraAfter.innerHTML);
- if (this.typingUndoIndex != -1) {
- this.undoIndex = this.typingUndoIndex;
- // tinyMCE.debug("Override: " + this.undoIndex);
- }
+ // Normalize
+ paraAfter.normalize();
+ paraBefore.normalize();
- var newHTML = tinyMCE.trim(this.getBody().innerHTML);
- if (newHTML != this.undoLevels[this.undoIndex]) {
- tinyMCE.executeCallback('onchange_callback', '_onchange', 0, this);
+ inst.selection.selectNode(paraAfter, true, true);
- // Time to compress
- var customUndoLevels = tinyMCE.settings['custom_undo_redo_levels'];
- if (customUndoLevels != -1 && this.undoLevels.length > customUndoLevels) {
- for (var i=0; i<this.undoLevels.length-1; i++) {
- //tinyMCE.debug(this.undoLevels[i] + "=" + this.undoLevels[i+1]);
- this.undoLevels[i] = this.undoLevels[i+1];
- }
+ return true;
+ },
- this.undoLevels.length--;
- this.undoIndex--;
- }
+ _handleBackSpace : function(inst) {
+ var r = inst.getRng();
+ var sn = r.startContainer;
- this.undoIndex++;
- this.undoLevels[this.undoIndex] = newHTML;
- this.undoLevels.length = this.undoIndex + 1;
+ if (sn && sn.nextSibling && sn.nextSibling.nodeName == "BR")
+ sn.nextSibling.parentNode.removeChild(sn.nextSibling);
- // tinyMCE.debug("level added" + this.undoIndex);
- tinyMCE.triggerNodeChange(false);
+ return false;
+ }
+};
- // tinyMCE.debug(this.undoIndex + "," + (this.undoLevels.length-1));
- }
- }
- break;
+/* file:jscripts/tiny_mce/classes/TinyMCE_Layer.class.js */
- case "Undo":
- if (tinyMCE.settings['custom_undo_redo']) {
- tinyMCE.execCommand("mceEndTyping");
+function TinyMCE_Layer(id, bm) {
+ this.id = id;
+ this.blockerElement = null;
+ this.events = false;
+ this.element = null;
+ this.blockMode = typeof(bm) != 'undefined' ? bm : true;
+};
- // Do undo
- if (this.undoIndex > 0) {
- this.undoIndex--;
- tinyMCE.setInnerHTML(this.getBody(), this.undoLevels[this.undoIndex]);
- this.repaint();
- }
+TinyMCE_Layer.prototype = {
+ moveRelativeTo : function(re, p) {
+ var rep = this.getAbsPosition(re);
+ var w = parseInt(re.offsetWidth);
+ var h = parseInt(re.offsetHeight);
+ var e = this.getElement();
+ var ew = parseInt(e.offsetWidth);
+ var eh = parseInt(e.offsetHeight);
+ var x, y;
- // tinyMCE.debug("Undo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex);
- tinyMCE.triggerNodeChange();
- } else
- this.getDoc().execCommand(command, user_interface, value);
- break;
+ switch (p) {
+ case "tl":
+ x = rep.absLeft;
+ y = rep.absTop;
+ break;
- case "Redo":
- if (tinyMCE.settings['custom_undo_redo']) {
- tinyMCE.execCommand("mceEndTyping");
+ case "tr":
+ x = rep.absLeft + w;
+ y = rep.absTop;
+ break;
- if (this.undoIndex < (this.undoLevels.length-1)) {
- this.undoIndex++;
- tinyMCE.setInnerHTML(this.getBody(), this.undoLevels[this.undoIndex]);
- this.repaint();
- // tinyMCE.debug("Redo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex);
- }
+ case "bl":
+ x = rep.absLeft;
+ y = rep.absTop + h;
+ break;
- tinyMCE.triggerNodeChange();
- } else
- this.getDoc().execCommand(command, user_interface, value);
- break;
+ case "br":
+ x = rep.absLeft + w;
+ y = rep.absTop + h;
+ break;
- case "mceToggleVisualAid":
- this.visualAid = !this.visualAid;
- tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
- tinyMCE.triggerNodeChange();
- break;
+ case "cc":
+ x = rep.absLeft + (w / 2) - (ew / 2);
+ y = rep.absTop + (h / 2) - (eh / 2);
+ break;
+ }
- case "Indent":
- this.getDoc().execCommand(command, user_interface, value);
- tinyMCE.triggerNodeChange();
- if (tinyMCE.isMSIE) {
- var n = tinyMCE.getParentElement(this.getFocusElement(), "blockquote");
- do {
- if (n && n.nodeName == "BLOCKQUOTE") {
- n.removeAttribute("dir");
- n.removeAttribute("style");
- }
- } while (n != null && (n = n.parentNode) != null);
- }
- break;
+ this.moveTo(x, y);
+ },
- case "removeformat":
- var text = this.getSelectedText();
+ moveBy : function(x, y) {
+ var e = this.getElement();
+ this.moveTo(parseInt(e.style.left) + x, parseInt(e.style.top) + y);
+ },
- if (tinyMCE.isOpera) {
- this.getDoc().execCommand("RemoveFormat", false, null);
- return;
- }
+ moveTo : function(x, y) {
+ var e = this.getElement();
- if (tinyMCE.isMSIE) {
- try {
- var rng = doc.selection.createRange();
- rng.execCommand("RemoveFormat", false, null);
- } catch (e) {
- // Do nothing
- }
+ e.style.left = x + "px";
+ e.style.top = y + "px";
- this.execCommand("SetStyleInfo", false, {command : "removeformat"});
- } else {
- this.getDoc().execCommand(command, user_interface, value);
+ this.updateBlocker();
+ },
- this.execCommand("SetStyleInfo", false, {command : "removeformat"});
- }
+ resizeBy : function(w, h) {
+ var e = this.getElement();
+ this.resizeTo(parseInt(e.style.width) + w, parseInt(e.style.height) + h);
+ },
- // Remove class
- if (text.length == 0)
- this.execCommand("mceSetCSSClass", false, "");
+ resizeTo : function(w, h) {
+ var e = this.getElement();
- tinyMCE.triggerNodeChange();
- break;
+ e.style.width = w + "px";
+ e.style.height = h + "px";
- default:
- this.getDoc().execCommand(command, user_interface, value);
+ this.updateBlocker();
+ },
- if (tinyMCE.isGecko)
- window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
- else
- tinyMCE.triggerNodeChange();
- }
+ show : function() {
+ this.getElement().style.display = 'block';
+ this.updateBlocker();
+ },
- // Add undo level after modification
- if (command != "mceAddUndoLevel" && command != "Undo" && command != "Redo" && command != "mceStartTyping" && command != "mceEndTyping")
- tinyMCE.execCommand("mceAddUndoLevel");
-};
+ hide : function() {
+ this.getElement().style.display = 'none';
+ this.updateBlocker();
+ },
-TinyMCEControl.prototype.queryCommandValue = function(command) {
- try {
- return this.getDoc().queryCommandValue(command);
- } catch (ex) {
- return null;
- }
-};
+ isVisible : function() {
+ return this.getElement().style.display == 'block';
+ },
-TinyMCEControl.prototype.queryCommandState = function(command) {
- return this.getDoc().queryCommandState(command);
-};
+ getElement : function() {
+ if (!this.element)
+ this.element = document.getElementById(this.id);
-TinyMCEControl.prototype.onAdd = function(replace_element, form_element_name, target_document) {
- var targetDoc = target_document ? target_document : document;
+ return this.element;
+ },
- this.targetDoc = targetDoc;
+ setBlockMode : function(s) {
+ this.blockMode = s;
+ },
- tinyMCE.themeURL = tinyMCE.baseURL + "/themes/" + this.settings['theme'];
- this.settings['themeurl'] = tinyMCE.themeURL;
+ updateBlocker : function() {
+ var e, b, x, y, w, h;
- if (!replace_element) {
- alert("Error: Could not find the target element.");
- return false;
- }
+ b = this.getBlocker();
+ if (b) {
+ if (this.blockMode) {
+ e = this.getElement();
+ x = this.parseInt(e.style.left);
+ y = this.parseInt(e.style.top);
+ w = this.parseInt(e.offsetWidth);
+ h = this.parseInt(e.offsetHeight);
- var templateFunction = tinyMCE._getThemeFunction('_getInsertLinkTemplate');
- if (eval("typeof(" + templateFunction + ")") != 'undefined')
- this.insertLinkTemplate = eval(templateFunction + '(this.settings);');
+ b.style.left = x + 'px';
+ b.style.top = y + 'px';
+ b.style.width = w + 'px';
+ b.style.height = h + 'px';
+ b.style.display = e.style.display;
+ } else
+ b.style.display = 'none';
+ }
+ },
- var templateFunction = tinyMCE._getThemeFunction('_getInsertImageTemplate');
- if (eval("typeof(" + templateFunction + ")") != 'undefined')
- this.insertImageTemplate = eval(templateFunction + '(this.settings);');
+ getBlocker : function() {
+ var d, b;
- var templateFunction = tinyMCE._getThemeFunction('_getEditorTemplate');
- if (eval("typeof(" + templateFunction + ")") == 'undefined') {
- alert("Error: Could not find the template function: " + templateFunction);
- return false;
- }
+ if (!this.blockerElement && this.blockMode) {
+ d = document;
+ b = d.createElement("iframe");
+
+ b.style.cssText = 'display: none; position: absolute; left: 0; top: 0';
+ b.src = 'javascript:false;';
+ b.frameBorder = '0';
+ b.scrolling = 'no';
+
+ d.body.appendChild(b);
+ this.blockerElement = b;
+ }
- var editorTemplate = eval(templateFunction + '(this.settings, this.editorId);');
+ return this.blockerElement;
+ },
- var deltaWidth = editorTemplate['delta_width'] ? editorTemplate['delta_width'] : 0;
- var deltaHeight = editorTemplate['delta_height'] ? editorTemplate['delta_height'] : 0;
- var html = '<span id="' + this.editorId + '_parent">' + editorTemplate['html'];
+ getAbsPosition : function(n) {
+ var p = {absLeft : 0, absTop : 0};
- var templateFunction = tinyMCE._getThemeFunction('_handleNodeChange', true);
- if (eval("typeof(" + templateFunction + ")") != 'undefined')
- this.settings['handleNodeChangeCallback'] = templateFunction;
+ while (n) {
+ p.absLeft += n.offsetLeft;
+ p.absTop += n.offsetTop;
+ n = n.offsetParent;
+ }
- html = tinyMCE.replaceVar(html, "editor_id", this.editorId);
- this.settings['default_document'] = tinyMCE.baseURL + "/blank.htm";
+ return p;
+ },
- this.settings['old_width'] = this.settings['width'];
- this.settings['old_height'] = this.settings['height'];
+ create : function(n, c, p) {
+ var d = document, e = d.createElement(n);
- // Set default width, height
- if (this.settings['width'] == -1)
- this.settings['width'] = replace_element.offsetWidth;
+ e.setAttribute('id', this.id);
- if (this.settings['height'] == -1)
- this.settings['height'] = replace_element.offsetHeight;
+ if (c)
+ e.className = c;
- // Try the style width
- if (this.settings['width'] == 0)
- this.settings['width'] = replace_element.style.width;
+ if (!p)
+ p = d.body;
- // Try the style height
- if (this.settings['height'] == 0)
- this.settings['height'] = replace_element.style.height;
+ p.appendChild(e);
- // If no width/height then default to 320x240, better than nothing
- if (this.settings['width'] == 0)
- this.settings['width'] = 320;
+ return this.element = e;
+ },
+/*
+ addCSSClass : function(e, c) {
+ this.removeCSSClass(e, c);
+ var a = this.explode(' ', e.className);
+ a[a.length] = c;
+ e.className = a.join(' ');
+ },
+
+ removeCSSClass : function(e, c) {
+ var a = this.explode(' ', e.className), i;
+
+ for (i=0; i<a.length; i++) {
+ if (a[i] == c)
+ a[i] = '';
+ }
- if (this.settings['height'] == 0)
- this.settings['height'] = 240;
+ e.className = a.join(' ');
+ },
- this.settings['area_width'] = parseInt(this.settings['width']);
- this.settings['area_height'] = parseInt(this.settings['height']);
- this.settings['area_width'] += deltaWidth;
- this.settings['area_height'] += deltaHeight;
+ explode : function(d, s) {
+ var ar = s.split(d);
+ var oar = new Array();
- // Special % handling
- if (("" + this.settings['width']).indexOf('%') != -1)
- this.settings['area_width'] = "100%";
+ for (var i = 0; i<ar.length; i++) {
+ if (ar[i] != "")
+ oar[oar.length] = ar[i];
+ }
- if (("" + this.settings['height']).indexOf('%') != -1)
- this.settings['area_height'] = "100%";
+ return oar;
+ },
+*/
- if (("" + replace_element.style.width).indexOf('%') != -1) {
- this.settings['width'] = replace_element.style.width;
- this.settings['area_width'] = "100%";
- }
+ parseInt : function(s) {
+ if (s == null || s == '')
+ return 0;
- if (("" + replace_element.style.height).indexOf('%') != -1) {
- this.settings['height'] = replace_element.style.height;
- this.settings['area_height'] = "100%";
+ return parseInt(s);
}
+};
- html = tinyMCE.applyTemplate(html);
+/* file:jscripts/tiny_mce/classes/TinyMCE_Menu.class.js */
- this.settings['width'] = this.settings['old_width'];
- this.settings['height'] = this.settings['old_height'];
+function TinyMCE_Menu() {
+ var id;
- this.visualAid = this.settings['visual'];
- this.formTargetElementId = form_element_name;
+ if (typeof(tinyMCE.menuCounter) == "undefined")
+ tinyMCE.menuCounter = 0;
- // Get replace_element contents
- if (replace_element.nodeName == "TEXTAREA" || replace_element.nodeName == "INPUT")
- this.startContent = replace_element.value;
- else
- this.startContent = replace_element.innerHTML;
+ id = "mc_menu_" + tinyMCE.menuCounter++;
- // If not text area
- if (replace_element.nodeName.toLowerCase() != "textarea") {
- this.oldTargetElement = replace_element.cloneNode(true);
+ TinyMCE_Layer.call(this, id, true);
- // Debug mode
- if (tinyMCE.settings['debug'])
- html += '<textarea wrap="off" id="' + form_element_name + '" name="' + form_element_name + '" cols="100" rows="15"></textarea>';
- else
- html += '<input type="hidden" type="text" id="' + form_element_name + '" name="' + form_element_name + '" />';
+ this.id = id;
+ this.items = new Array();
+ this.needsUpdate = true;
+};
- html += '</span>';
+// Extends the TinyMCE_Layer class
+TinyMCE_Menu.prototype = tinyMCE.extend(TinyMCE_Layer.prototype, {
+ init : function(s) {
+ var n;
- // Output HTML and set editable
- if (!tinyMCE.isMSIE) {
- var rng = replace_element.ownerDocument.createRange();
- rng.setStartBefore(replace_element);
+ // Default params
+ this.settings = {
+ separator_class : 'mceMenuSeparator',
+ title_class : 'mceMenuTitle',
+ disabled_class : 'mceMenuDisabled',
+ menu_class : 'mceMenu',
+ drop_menu : true
+ };
- var fragment = rng.createContextualFragment(html);
- replace_element.parentNode.replaceChild(fragment, replace_element);
- } else
- replace_element.outerHTML = html;
- } else {
- html += '</span>';
+ for (n in s)
+ this.settings[n] = s[n];
- // Just hide the textarea element
- this.oldTargetElement = replace_element;
+ this.create('div', this.settings.menu_class);
+ },
- if (!tinyMCE.settings['debug'])
- this.oldTargetElement.style.display = "none";
+ clear : function() {
+ this.items = new Array();
+ },
- // Output HTML and set editable
- if (!tinyMCE.isMSIE) {
- var rng = replace_element.ownerDocument.createRange();
- rng.setStartBefore(replace_element);
+ addTitle : function(t) {
+ this.add({type : 'title', text : t});
+ },
- var fragment = rng.createContextualFragment(html);
+ addDisabled : function(t) {
+ this.add({type : 'disabled', text : t});
+ },
- if (tinyMCE.isGecko)
- tinyMCE.insertAfter(fragment, replace_element);
- else
- replace_element.parentNode.insertBefore(fragment, replace_element);
- } else
- replace_element.insertAdjacentHTML("beforeBegin", html);
- }
+ addSeparator : function() {
+ this.add({type : 'separator'});
+ },
- // Setup iframe
- var dynamicIFrame = false;
- var tElm = targetDoc.getElementById(this.editorId);
+ addItem : function(t, js) {
+ this.add({text : t, js : js});
+ },
- if (!tinyMCE.isMSIE) {
- if (tElm && tElm.nodeName.toLowerCase() == "span") {
- tElm = tinyMCE._createIFrame(tElm);
- dynamicIFrame = true;
- }
+ add : function(mi) {
+ this.items[this.items.length] = mi;
+ this.needsUpdate = true;
+ },
- this.targetElement = tElm;
- this.iframeElement = tElm;
- this.contentDocument = tElm.contentDocument;
- this.contentWindow = tElm.contentWindow;
+ update : function() {
+ var e = this.getElement(), h = '', i, t, m = this.items, s = this.settings;
- //this.getDoc().designMode = "on";
- } else {
- if (tElm && tElm.nodeName.toLowerCase() == "span")
- tElm = tinyMCE._createIFrame(tElm);
- else
- tElm = targetDoc.frames[this.editorId];
+ if (this.settings.drop_menu)
+ h += '<span class="mceMenuLine"></span>';
- this.targetElement = tElm;
- this.iframeElement = targetDoc.getElementById(this.editorId);
+ h += '<table border="0" cellpadding="0" cellspacing="0">';
- if (tinyMCE.isOpera) {
- this.contentDocument = this.iframeElement.contentDocument;
- this.contentWindow = this.iframeElement.contentWindow;
- dynamicIFrame = true;
- } else {
- this.contentDocument = tElm.window.document;
- this.contentWindow = tElm.window;
- }
+ for (i=0; i<m.length; i++) {
+ t = tinyMCE.xmlEncode(m[i].text);
+ c = m[i].class_name ? ' class="' + m[i].class_name + '"' : '';
- this.getDoc().designMode = "on";
- }
+ switch (m[i].type) {
+ case 'separator':
+ h += '<tr class="' + s.separator_class + '"><td>';
+ break;
- // Setup base HTML
- var doc = this.contentDocument;
- if (dynamicIFrame) {
- var html = tinyMCE.getParam('doctype') + '<html><head xmlns="http://www.w3.org/1999/xhtml"><base href="' + tinyMCE.settings['base_href'] + '" /><title>blank_page</title><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body class="mceContentBody"></body></html>';
+ case 'title':
+ h += '<tr class="' + s.title_class + '"><td><span' + c +'>' + t + '</span>';
+ break;
- try {
- if (!this.isHidden())
- this.getDoc().designMode = "on";
+ case 'disabled':
+ h += '<tr class="' + s.disabled_class + '"><td><span' + c +'>' + t + '</span>';
+ break;
- doc.open();
- doc.write(html);
- doc.close();
- } catch (e) {
- // Failed Mozilla 1.3
- this.getDoc().location.href = tinyMCE.baseURL + "/blank.htm";
+ default:
+ h += '<tr><td><a href="javascript:void(0);" onmousedown="' + tinyMCE.xmlEncode(m[i].js) + ';return false;"><span' + c +'>' + t + '</span></a>';
+ }
+
+ h += '</td></tr>';
}
- }
- // This timeout is needed in MSIE 5.5 for some odd reason
- // it seems that the document.frames isn't initialized yet?
- if (tinyMCE.isMSIE)
- window.setTimeout("TinyMCE.prototype.addEventHandlers('" + this.editorId + "');", 1);
+ h += '</table>';
- tinyMCE.setupContent(this.editorId, true);
+ e.innerHTML = h;
- return true;
-};
+ this.needsUpdate = false;
+ this.updateBlocker();
+ },
-TinyMCEControl.prototype.getFocusElement = function() {
- if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
- var doc = this.getDoc();
- var rng = doc.selection.createRange();
+ show : function() {
+ var nl, i;
-// if (rng.collapse)
-// rng.collapse(true);
+ if (tinyMCE.lastMenu == this)
+ return;
- var elm = rng.item ? rng.item(0) : rng.parentElement();
- } else {
- if (this.isHidden())
- return this.getBody();
+ if (this.needsUpdate)
+ this.update();
- var sel = this.getSel();
- var rng = this.getRng();
+ if (tinyMCE.lastMenu && tinyMCE.lastMenu != this)
+ tinyMCE.lastMenu.hide();
- var elm = rng.commonAncestorContainer;
- //var elm = (sel && sel.anchorNode) ? sel.anchorNode : null;
+ this.parent.show.call(this);
- // Handle selection a image or other control like element such as anchors
- if (!rng.collapsed) {
- // Is selection small
- if (rng.startContainer == rng.endContainer) {
- if (rng.startOffset - rng.endOffset < 2) {
- if (rng.startContainer.hasChildNodes())
- elm = rng.startContainer.childNodes[rng.startOffset];
- }
- }
+ if (!tinyMCE.isOpera) {
+ // Accessibility stuff
+/* nl = this.getElement().getElementsByTagName("a");
+ if (nl.length > 0)
+ nl[0].focus();*/
}
- // Get the element parent of the node
- elm = tinyMCE.getParentElement(elm);
+ tinyMCE.lastMenu = this;
+ }
+});
+
+/* file:jscripts/tiny_mce/classes/TinyMCE_Debug.class.js */
+
+TinyMCE_Engine.prototype.debug = function() {
+ var m = "", e, a, i;
- //if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img")
- // elm = tinyMCE.selectedElement;
+ e = document.getElementById("tinymce_debug");
+ if (!e) {
+ var d = document.createElement("div");
+ d.setAttribute("className", "debugger");
+ d.className = "debugger";
+ d.innerHTML = 'Debug output:<textarea id="tinymce_debug" style="width: 100%; height: 300px" wrap="nowrap" mce_editable="false"></textarea>';
+
+ document.body.appendChild(d);
+ e = document.getElementById("tinymce_debug");
}
- return elm;
-};
+ a = this.debug.arguments;
+ for (i=0; i<a.length; i++) {
+ m += a[i];
+ if (i<a.length-1)
+ m += ', ';
+ }
-// Global instances
-var tinyMCE = new TinyMCE();
-var tinyMCELang = new Array();
+ e.value += m + "\n";
+};
diff --git a/wp-inst/wp-includes/js/tinymce/tiny_mce_gzip.php b/wp-inst/wp-includes/js/tinymce/tiny_mce_gzip.php
index 4a5050b..e975389 100644
--- a/wp-inst/wp-includes/js/tinymce/tiny_mce_gzip.php
+++ b/wp-inst/wp-includes/js/tinymce/tiny_mce_gzip.php
@@ -1,154 +1,329 @@
<?php
- /**
- * $RCSfile: tiny_mce_gzip.php,v $
- * $Revision: $
- * $Date: $
- *
- * @version 1.02
- * @author Moxiecode
- * @copyright Copyright © 2005, Moxiecode Systems AB, All rights reserved.
- *
- * This file compresses the TinyMCE JavaScript using GZip and
- * enables the browser to do two requests instead of one for each .js file.
- * Notice: This script defaults the button_tile_map option to true for extra performance.
- *
- * Todo:
- * - Add local file cache for the GZip:ed version.
- */
-
- /* Heavily edited to add flexibilty in WordPress */
- @ require('../../../wp-config.php');
-
- function wp_translate_tinymce_lang($text) {
- if ( ! function_exists('__') ) {
- return $text;
- } else {
- $search1 = "/^tinyMCELang\\[(['\"])(.*)\\1\]( ?= ?)(['\"])(.*)\\4/Uem";
- $replace1 = "'tinyMCELang[\\1\\2\\1]\\3'.stripslashes('\\4').__('\\5').stripslashes('\\4')";
-
- $search2 = "/ : (['\"])(.*)\\1/Uem";
- $replace2 = "' : '.stripslashes('\\1').__('\\2').stripslashes('\\1')";
-
- $search = array($search1, $search2);
- $replace = array($replace1, $replace2);
-
- $text = preg_replace($search, $replace, $text);
-
- return $text;
- }
- }
+/**
+ * $RCSfile: tiny_mce_gzip.php,v $
+ * $Revision: $
+ * $Date: $
+ *
+ * @version 1.08
+ * @author Moxiecode
+ * @copyright Copyright © 2005-2006, Moxiecode Systems AB, All rights reserved.
+ *
+ * This file compresses the TinyMCE JavaScript using GZip and
+ * enables the browser to do two requests instead of one for each .js file.
+ * Notice: This script defaults the button_tile_map option to true for extra performance.
+ */
+
+@require_once('../../../wp-config.php');
+
+// gzip_compression();
+
+function wp_tinymce_lang($path) {
+ global $language;
+
+ $text = '';
+
+ // Look for xx_YY.js, xx_yy.js, xx.js
+ $file = realpath(sprintf($path, $language));
+ if ( file_exists($file) )
+ $text = file_get_contents($file);
+ $file = realpath(sprintf($path, strtolower($language)));
+ if ( file_exists($file) )
+ $text = file_get_contents($file);
+ $file = realpath(sprintf($path, substr($language, 0, 2)));
+ if ( file_exists($file) )
+ $text = file_get_contents($file);
+
+
+ // Fall back on en.js
+ if ( empty($text) )
+ $text = file_get_contents(realpath(sprintf($path, 'en')));
+
+ // Send lang file through gettext
+ if ( function_exists('__') && strtolower(substr($language, 0, 2)) != 'en' ) {
+ $search1 = "/^tinyMCELang\\[(['\"])(.*)\\1\]( ?= ?)(['\"])(.*)\\4/Uem";
+ $replace1 = "'tinyMCELang[\\1\\2\\1]\\3'.stripslashes('\\4').__('\\5').stripslashes('\\4')";
- function wp_compact_tinymce_js($text) {
- // This function was custom-made for TinyMCE 2.0, not expected to work with any other JS.
+ $search2 = "/\\s:\\s(['\"])(.*)\\1(,|\\s*})/Uem";
+ $replace2 = "' : '.stripslashes('\\1').__('\\2foo').stripslashes('\\1').'\\3'";
- // Strip comments
- $text = preg_replace("!(^|\s+)//.*$!m", '', $text);
- $text = preg_replace("!/\*.*?\*/!s", '', $text);
+ $search = array($search1, $search2);
+ $replace = array($replace1, $replace2);
- // Strip leading tabs, carriage returns and unnecessary line breaks.
- $text = preg_replace("!^\t+!m", '', $text);
- $text = str_replace("\r", '', $text);
- $text = preg_replace("!(^|{|}|;|:|\))\n!m", '\\1', $text);
+ $text = preg_replace($search, $replace, $text);
return $text;
}
- // General options
- $expiresOffset = 3600 * 24 * 30; // 30 days util client cache expires
+ return $text;
+}
- gzip_compression();
+function wp_compact_tinymce_js($text) {
+ // This function was custom-made for TinyMCE 2.0, not expected to work with any other JS.
+
+ // Strip comments
+ $text = preg_replace("!(^|\s+)//.*$!m", '', $text);
+ $text = preg_replace("!/\*.*?\*/!s", '', $text);
+
+ // Strip leading tabs, carriage returns and unnecessary line breaks.
+ $text = preg_replace("!^\t+!m", '', $text);
+ $text = str_replace("\r", '', $text);
+ $text = preg_replace("!(^|{|}|;|:|\))\n!m", '\\1', $text);
+
+ return "$text\n";
+}
+
+
+// General options
+$suffix = ""; // Set to "_src" to use source version
+$expiresOffset = 3600 * 24 * 10; // 10 days util client cache expires
+$diskCache = false; // If you enable this option gzip files will be cached on disk.
+$cacheDir = realpath("."); // Absolute directory path to where cached gz files will be stored
+$debug = false; // Enable this option if you need debuging info
+
+// Headers
+header("Content-type: text/javascript; charset: UTF-8");
+// header("Cache-Control: must-revalidate");
+header("Vary: Accept-Encoding"); // Handle proxies
+header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT");
+
+// Get data to load
+$theme = isset($_GET['theme']) ? TinyMCE_cleanInput($_GET['theme']) : "";
+$language = isset($_GET['language']) ? TinyMCE_cleanInput($_GET['language']) : "";
+$plugins = isset($_GET['plugins']) ? TinyMCE_cleanInput($_GET['plugins']) : "";
+$lang = isset($_GET['lang']) ? TinyMCE_cleanInput($_GET['lang']) : "en";
+$index = isset($_GET['index']) ? TinyMCE_cleanInput($_GET['index']) : -1;
+$cacheKey = md5($theme . $language . $plugins . $lang . $index . $debug);
+$cacheFile = $cacheDir == "" ? "" : $cacheDir . "/" . "tinymce_" . $cacheKey . ".gz";
+$cacheData = "";
+
+// Patch older versions of PHP < 4.3.0
+if (!function_exists('file_get_contents')) {
+ function file_get_contents($filename) {
+ $fd = fopen($filename, 'rb');
+ $content = fread($fd, filesize($filename));
+ fclose($fd);
+ return $content;
+ }
+}
- // Output rest of headers
- header("Content-type: text/javascript; charset: UTF-8");
- header("Vary: Accept-Encoding"); // Handle proxies
- header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT");
+// Security check function, can only contain a-z 0-9 , _ - and whitespace.
+function TinyMCE_cleanInput($str) {
+ return preg_replace("/[^0-9a-z\-_,]+/i", "", $str); // Remove anything but 0-9,a-z,-_
+}
- // Write main script
- $tinymce = file_get_contents(realpath("tiny_mce.js"));
- echo wp_compact_tinymce_js($tinymce);
- echo "\n\n";
+function TinyMCE_echo($str) {
+ global $cacheData, $diskCache;
- // Remove some functions
- echo "\n/* WP cancels all TinyMCE language and import handling */\n";
- echo "TinyMCE.prototype.importThemeLanguagePack = function() {};\n";
- echo "TinyMCE.prototype.importPluginLanguagePack = function() {};\n\n";
- echo "TinyMCE.prototype.loadScript = function() {};\n";
+ if ($diskCache)
+ $cacheData .= $str;
+ else
+ echo $str;
+}
+
+// Only gzip the contents if clients and server support it
+$encodings = array();
+
+if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
+ $encodings = explode(',', strtolower(preg_replace("/\s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING'])));
+
+// Check for gzip header or northon internet securities
+if ((in_array('gzip', $encodings) || in_array('x-gzip', $encodings) || isset($_SERVER['---------------'])) && function_exists('ob_gzhandler') && !ini_get('zlib.output_compression')) {
+ $enc = in_array('x-gzip', $encodings) ? "x-gzip" : "gzip";
+
+ // Use cached file if it exists but not in debug mode
+ if (file_exists($cacheFile) && !$debug) {
+ header("Content-Encoding: " . $enc);
+ echo file_get_contents($cacheFile);
+ die;
+ }
+
+ if (!$diskCache)
+ ob_start("ob_gzhandler");
+} else
+ $diskCache = false;
+
+if ($index > -1) {
+ // Write main script and patch some things
+ if ($index == 0) {
+ TinyMCE_echo(wp_compact_tinymce_js(file_get_contents(realpath("tiny_mce" . $suffix . ".js")))); // WP
+ TinyMCE_echo('TinyMCE.prototype.orgLoadScript = TinyMCE.prototype.loadScript;');
+ TinyMCE_echo('TinyMCE.prototype.loadScript = function() {};var realTinyMCE = tinyMCE;');
+ } else
+ TinyMCE_echo('tinyMCE = realTinyMCE;');
+
+ // Do init based on index
+ TinyMCE_echo("tinyMCE.init(tinyMCECompressed.configs[" . $index . "]);");
+
+ // Load external plugins
+ if ($index == 0)
+ TinyMCE_echo("tinyMCECompressed.loadPlugins();");
// Load theme, language pack and theme language packs
- $theme = apply_filters('mce_theme', 'advanced');
- echo wp_compact_tinymce_js(file_get_contents(realpath("themes/" . $theme . "/editor_template.js")));
- echo wp_translate_tinymce_lang(file_get_contents(realpath("themes/" . $theme . "/langs/en.js")));
- echo wp_translate_tinymce_lang(file_get_contents(realpath("langs/en.js")));
+ if ($theme) {
+ TinyMCE_echo(wp_compact_tinymce_js(file_get_contents(realpath("themes/" . $theme . "/editor_template" . $suffix . ".js")))); // WP
+ TinyMCE_echo(wp_tinymce_lang("themes/" . $theme . "/langs/%s.js")); // WP
+ }
+
+ /* WP if ($language) WP */
+ TinyMCE_echo(wp_tinymce_lang("langs/%s.js")); // WP
// Load all plugins and their language packs
- $plugins = apply_filters('mce_plugins', array('wordpress', 'autosave', 'wphelp'));
+ $plugins = explode(",", $plugins);
foreach ($plugins as $plugin) {
- $pluginFile = realpath("plugins/" . $plugin . "/editor_plugin.js");
- $languageFile = realpath("plugins/" . $plugin . "/langs/en.js");
+ $pluginFile = realpath("plugins/" . $plugin . "/editor_plugin" . $suffix . ".js");
+ /* WP $languageFile = realpath("plugins/" . $plugin . "/langs/" . $lang . ".js"); WP */
if ($pluginFile)
- echo file_get_contents($pluginFile);
+ TinyMCE_echo(file_get_contents($pluginFile));
- if ($languageFile)
- echo wp_translate_tinymce_lang(file_get_contents($languageFile));
+ /* WP if ($languageFile) WP */
+ TinyMCE_echo(wp_tinymce_lang("plugins/" . $plugin . "/langs/%s.js")); // WP
}
- // Set up init variables
-// if ( current_user_can('unfiltered_html') ) // Use the full XHTML set provided in the docs
- $valid_elements = 'a[accesskey|charset|class|coords|dir<ltr?rtl|href|hreflang|id|lang|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev|shape<circle?default?poly?rect|style|tabindex|title|target|type],abbr[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],acronym[class|dir<ltr?rtl|id|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],address[class|align|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],applet[align<bottom?left?middle?right?top|alt|archive|class|code|codebase|height|hspace|id|name|object|style|title|vspace|width],area[accesskey|alt|class|coords|dir<ltr?rtl|href|id|lang|nohref<nohref|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|shape<circle?default?poly?rect|style|tabindex|title|target],base[href|target],basefont[color|face|id|size],bdo[class|dir<ltr?rtl|id|lang|style|title],big[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],blockquote[dir|style|cite|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],body[alink|background|bgcolor|class|dir<ltr?rtl|id|lang|link|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onload|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onunload|style|title|text|vlink],br[class|clear<all?left?none?right|id|style|title],button[accesskey|class|dir<ltr?rtl|disabled<disabled|id|lang|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|tabindex|title|type|value],caption[align<bottom?left?right?top|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],center[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],'
- . 'cite[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],code[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],col[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|span|style|title|valign<baseline?bottom?middle?top|width],colgroup[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|span|style|title|valign<baseline?bottom?middle?top|width],dd[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],del[cite|class|datetime|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],dfn[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],dir[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],-div[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],dl[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],dt[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],-em/i[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],'
- . 'fieldset[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],font[class|color|dir<ltr?rtl|face|id|lang|size|style|title],form[accept|accept-charset|action|class|dir<ltr?rtl|enctype|id|lang|method<get?post|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onreset|onsubmit|style|title|target],frame[class|frameborder|id|longdesc|marginheight|marginwidth|name|noresize<noresize|scrolling<auto?no?yes|src|style|title],frameset[class|cols|id|onload|onunload|rows|style|title],h1[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],h2[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],h3[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],h4[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],h5[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],h6[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],head[dir<ltr?rtl|lang|profile],hr[align<center?left?right|class|dir<ltr?rtl|id|lang|noshade<noshade|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|size|style|title|width],html[dir<ltr?rtl|lang|version],'
- . 'iframe[align<bottom?left?middle?right?top|class|frameborder|height|id|longdesc|marginheight|marginwidth|name|scrolling<auto?no?yes|src|style|title|width],img[align<bottom?left?middle?right?top|alt|border|class|dir<ltr?rtl|height|hspace|id|ismap<ismap|lang|longdesc|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|src|style|title|usemap|vspace|width],input[accept|accesskey|align<bottom?left?middle?right?top|alt|checked<checked|class|dir<ltr?rtl|disabled<disabled|id|ismap<ismap|lang|maxlength|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect|readonly<readonly|size|src|style|tabindex|title|type<button?checkbox?file?hidden?image?password?radio?reset?submit?text|usemap|value],ins[cite|class|datetime|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],isindex[class|dir<ltr?rtl|id|lang|prompt|style|title],kbd[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],label[accesskey|class|dir<ltr?rtl|for|id|lang|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],legend[align<bottom?left?right?top|accesskey|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],li[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|type|value],link[charset|class|dir<ltr?rtl|href|hreflang|id|lang|media|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rel|rev|style|title|target|type],map[class|dir<ltr?rtl|id|lang|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],'
- . 'menu[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],meta[content|dir<ltr?rtl|http-equiv|lang|name|scheme],noframes[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],noscript[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],object[align<bottom?left?middle?right?top|archive|border|class|classid|codebase|codetype|data|declare|dir<ltr?rtl|height|hspace|id|lang|name|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|standby|style|tabindex|title|type|usemap|vspace|width],ol[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|start|style|title|type],optgroup[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],option[class|dir<ltr?rtl|disabled<disabled|id|label|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|selected<selected|style|title|value],p[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],param[id|name|type|value|valuetype<DATA?OBJECT?REF],pre/listing/plaintext/xmp[align|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|width],q[cite|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],'
- . 's[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],samp[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],script[charset|defer|language|src|type],select[class|dir<ltr?rtl|disabled<disabled|id|lang|multiple<multiple|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|size|style|tabindex|title],small[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],span[align<center?justify?left?right|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],strike[class|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],-strong/b[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],style[dir<ltr?rtl|lang|media|title|type],sub[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],sup[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],table[align<center?left?right|bgcolor|border|cellpadding|cellspacing|class|dir<ltr?rtl|frame|height|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rules|style|summary|title|width],'
- . 'tbody[align<center?char?justify?left?right|char|class|charoff|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|valign<baseline?bottom?middle?top],td[abbr|align<center?char?justify?left?right|axis|bgcolor|char|charoff|class|colspan|dir<ltr?rtl|headers|height|id|lang|nowrap<nowrap|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rowspan|scope<col?colgroup?row?rowgroup|style|title|valign<baseline?bottom?middle?top|width],textarea[accesskey|class|cols|dir<ltr?rtl|disabled<disabled|id|lang|name|onblur|onclick|ondblclick|onfocus|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onselect|readonly<readonly|rows|style|tabindex|title],tfoot[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|valign<baseline?bottom?middle?top],th[abbr|align<center?char?justify?left?right|axis|bgcolor|char|charoff|class|colspan|dir<ltr?rtl|headers|height|id|lang|nowrap<nowrap|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|rowspan|scope<col?colgroup?row?rowgroup|style|title|valign<baseline?bottom?middle?top|width],thead[align<center?char?justify?left?right|char|charoff|class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|valign<baseline?bottom?middle?top],'
- . 'title[dir<ltr?rtl|lang],tr[abbr|align<center?char?justify?left?right|bgcolor|char|charoff|class|rowspan|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|valign<baseline?bottom?middle?top],tt[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],u[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title],ul[class|compact<compact|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title|type],var[class|dir<ltr?rtl|id|lang|onclick|ondblclick|onkeydown|onkeypress|onkeyup|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|style|title]';
-// else // Use a much smaller set
-// $valid_elements = '-a[id|href|title|rel],-strong/b,-em/i,-strike,-del,-u,p[class|align|dir],-ol,-ul,-li,br,img[class|src|alt|title|width|height|align],-sub,-sup,-blockquote[dir],-table[border|cellspacing|cellpadding|width|height|class|align|dir],thead[class|rowspan|width|height|align|valign|dir],tr[class|rowspan|width|height|align|valign|dir],th[dir|class|colspan|rowspan|width|height|align|valign|scope],td[dir|class|colspan|rowspan|width|height|align|valign],-div[dir|class|align],-span[class|align],-pre[class],-code[class],-address,-h1[class|align|dir],-h2[class|align|dir],-h3[class|align|dir],-h4[class|align|dir],-h5[class|align|dir],-h6[class|align|dir],hr';
- $valid_elements = apply_filters('mce_valid_elements', $valid_elements);
- $plugins = implode($plugins, ',');
- $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'separator', 'bullist', 'numlist', 'outdent', 'indent', 'separator', 'justifyleft', 'justifycenter', 'justifyright' ,'separator', 'link', 'unlink', 'image', 'wordpress', 'separator', 'undo', 'redo', 'code', 'wphelp'));
- $mce_buttons = implode($mce_buttons, ',');
- $mce_buttons_2 = apply_filters('mce_buttons_2', array());
- $mce_buttons_2 = implode($mce_buttons_2, ',');
- $mce_buttons_3 = apply_filters('mce_buttons_3', array());
- $mce_buttons_3 = implode($mce_buttons_3, ',');
- $mce_browsers = apply_filters('mce_browsers', array('msie', 'gecko', 'opera'));
- $mce_browsers = implode($mce_browsers, ',');
+ // Reset tinyMCE compressor engine
+ TinyMCE_echo("tinyMCE = tinyMCECompressed;");
+
+ // Write to cache
+ if ($diskCache) {
+ // Calculate compression ratio and debug target output path
+ if ($debug) {
+ $ratio = round(100 - strlen(gzencode($cacheData, 9, FORCE_GZIP)) / strlen($cacheData) * 100.0);
+ TinyMCE_echo("alert('TinyMCE was compressed by " . $ratio . "%.\\nOutput cache file: " . $cacheFile . "');");
+ }
+
+ $cacheData = gzencode($cacheData, 9, FORCE_GZIP);
+
+ // Write to file if possible
+ $fp = @fopen($cacheFile, "wb");
+ if ($fp) {
+ fwrite($fp, $cacheData);
+ fclose($fp);
+ }
+
+ // Output
+ header("Content-Encoding: " . $enc);
+ echo $cacheData;
+ }
+
+ die;
+}
?>
-initArray = {
- mode : "specific_textareas",
- textarea_trigger : "title",
- width : "100%",
- theme : "advanced",
- theme_advanced_buttons1 : "<?php echo $mce_buttons; ?>",
- theme_advanced_buttons2 : "<?php echo $mce_buttons_2; ?>",
- theme_advanced_buttons3 : "<?php echo $mce_buttons_3; ?>",
- theme_advanced_toolbar_location : "top",
- theme_advanced_toolbar_align : "left",
- theme_advanced_path_location : "bottom",
- theme_advanced_resizing : true,
- browsers : "<?php echo $mce_browsers; ?>",
- dialog_type : "modal",
- theme_advanced_resize_horizontal : false,
- entity_encoding : "raw",
- relative_urls : false,
- remove_script_host : false,
- force_p_newlines : true,
- force_br_newlines : false,
- convert_newlines_to_brs : false,
- remove_linebreaks : true,
- save_callback : "wp_save_callback",
- valid_elements : "<?php echo $valid_elements; ?>",
-<?php do_action('mce_options'); ?>
- plugins : "<?php echo $plugins; ?>"
+function TinyMCECompressed() {
+ this.configs = new Array();
+ this.loadedFiles = new Array();
+ this.externalPlugins = new Array();
+ this.loadAdded = false;
+ this.isLoaded = false;
+}
+
+TinyMCECompressed.prototype.init = function(settings) {
+ var elements = document.getElementsByTagName('script');
+ var scriptURL = "";
+
+ for (var i=0; i<elements.length; i++) {
+ if (elements[i].src && elements[i].src.indexOf("tiny_mce_gzip.php") != -1) {
+ scriptURL = elements[i].src;
+ break;
+ }
+ }
+
+ settings["theme"] = typeof(settings["theme"]) != "undefined" ? settings["theme"] : "default";
+ settings["plugins"] = typeof(settings["plugins"]) != "undefined" ? settings["plugins"] : "";
+ settings["language"] = typeof(settings["language"]) != "undefined" ? settings["language"] : "en";
+ settings["button_tile_map"] = typeof(settings["button_tile_map"]) != "undefined" ? settings["button_tile_map"] : true;
+ this.configs[this.configs.length] = settings;
+ this.settings = settings;
+
+ scriptURL += (scriptURL.indexOf('?') == -1) ? '?' : '&';
+ scriptURL += "theme=" + escape(this.getOnce(settings["theme"])) + "&language=" + escape(this.getOnce(settings["language"])) + "&plugins=" + escape(this.getOnce(settings["plugins"])) + "&lang=" + settings["language"] + "&index=" + escape(this.configs.length-1);
+ document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + scriptURL + '"></script>');
+
+ if (!this.loadAdded) {
+ tinyMCE.addEvent(window, "DOMContentLoaded", TinyMCECompressed.prototype.onLoad);
+ tinyMCE.addEvent(window, "load", TinyMCECompressed.prototype.onLoad);
+ this.loadAdded = true;
+ }
+}
+
+TinyMCECompressed.prototype.onLoad = function() {
+ if (tinyMCE.isLoaded)
+ return true;
+
+ tinyMCE = realTinyMCE;
+ TinyMCE_Engine.prototype.onLoad();
+ tinyMCE._addUnloadEvents();
+
+ tinyMCE.isLoaded = true;
+}
+
+TinyMCECompressed.prototype.addEvent = function(o, n, h) {
+ if (o.attachEvent)
+ o.attachEvent("on" + n, h);
+ else
+ o.addEventListener(n, h, false);
+}
+
+TinyMCECompressed.prototype.getOnce = function(str) {
+ var ar = str.replace(/\s+/g, '').split(',');
+
+ for (var i=0; i<ar.length; i++) {
+ if (ar[i] == '' || ar[i].charAt(0) == '-') {
+ ar[i] = null;
+ continue;
+ }
+
+ // Skip load
+ for (var x=0; x<this.loadedFiles.length; x++) {
+ if (this.loadedFiles[x] == ar[i])
+ ar[i] = null;
+ }
+
+ this.loadedFiles[this.loadedFiles.length] = ar[i];
+ }
+
+ // Glue
+ str = "";
+ for (var i=0; i<ar.length; i++) {
+ if (ar[i] == null)
+ continue;
+
+ str += ar[i];
+
+ if (i != ar.length-1)
+ str += ",";
+ }
+
+ return str;
};
-<?php
- // For people who really REALLY know what they're doing with TinyMCE
- do_action('tinymce_before_init');
-?>
+TinyMCECompressed.prototype.loadPlugins = function() {
+ var i, ar;
-tinyMCE.init(initArray);
+ TinyMCE.prototype.loadScript = TinyMCE.prototype.orgLoadScript;
+ tinyMCE = realTinyMCE;
+
+ ar = tinyMCECompressed.externalPlugins;
+ for (i=0; i<ar.length; i++)
+ tinyMCE.loadPlugin(ar[i].name, ar[i].url);
+
+ TinyMCE.prototype.loadScript = function() {};
+};
+
+TinyMCECompressed.prototype.loadPlugin = function(n, u) {
+ this.externalPlugins[this.externalPlugins.length] = {name : n, url : u};
+};
+
+TinyMCECompressed.prototype.importPluginLanguagePack = function(n, v) {
+ tinyMCE = realTinyMCE;
+ TinyMCE.prototype.loadScript = TinyMCE.prototype.orgLoadScript;
+ tinyMCE.importPluginLanguagePack(n, v);
+};
+
+TinyMCECompressed.prototype.addPlugin = function(n, p) {
+ tinyMCE = realTinyMCE;
+ tinyMCE.addPlugin(n, p);
+};
+var tinyMCE = new TinyMCECompressed();
+var tinyMCECompressed = tinyMCE;
diff --git a/wp-inst/wp-includes/js/tinymce/tiny_mce_popup.js b/wp-inst/wp-includes/js/tinymce/tiny_mce_popup.js
index 58b3964..c5864e6 100644
--- a/wp-inst/wp-includes/js/tinymce/tiny_mce_popup.js
+++ b/wp-inst/wp-includes/js/tinymce/tiny_mce_popup.js
@@ -1,22 +1,25 @@
-/**
- * $RCSfile: tiny_mce_popup.js,v $
- * $Revision: 1.18 $
- * $Date: 2005/10/29 19:13:20 $
- *
- * @author Moxiecode
- * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.
- */
+
+// Some global instances, this will be filled later
var tinyMCE = null, tinyMCELang = null;
-function TinyMCEPopup() {
+
+function TinyMCE_Popup() {
};
-TinyMCEPopup.prototype.init = function() {
+
+TinyMCE_Popup.prototype.init = function() {
var win = window.opener ? window.opener : window.dialogArguments;
+ var inst;
- if (!win)
- win = top;
+ if (!win) {
+ // Try parent
+ win = parent.parent;
+
+ // Try top
+ if (typeof(win.tinyMCE) == "undefined")
+ win = top;
+ }
window.opener = win;
this.windowOpener = win;
@@ -31,15 +34,16 @@ TinyMCEPopup.prototype.init = function() {
return;
}
+ inst = tinyMCE.selectedInstance;
this.isWindow = tinyMCE.getWindowArg('mce_inside_iframe', false) == false;
- this.storeSelection = tinyMCE.isMSIE && !this.isWindow && tinyMCE.getWindowArg('mce_store_selection', true);
+ this.storeSelection = (tinyMCE.isMSIE && !tinyMCE.isOpera) && !this.isWindow && tinyMCE.getWindowArg('mce_store_selection', true);
if (this.isWindow)
window.focus();
// Store selection
if (this.storeSelection)
- tinyMCE.selectedInstance.execCommand('mceStoreSelection');
+ inst.selectionBookmark = inst.selection.getBookmark(true);
// Setup dir
if (tinyMCELang['lang_dir'])
@@ -63,23 +67,24 @@ TinyMCEPopup.prototype.init = function() {
tinyMCE.addEvent(window, "load", this.onLoad);
};
-TinyMCEPopup.prototype.onLoad = function() {
- var body = document.body;
+
+TinyMCE_Popup.prototype.onLoad = function() {
+ var dir, i, elms, body = document.body;
body.onkeydown = function (e) {
e = e ? e : window.event;
if ( e.keyCode == 27 && !e.shiftKey && !e.controlKey && !e.altKey ) {
- tinyMCEPopup.close();
+ tinyMCE.closeWindow(window);
}
}
if (tinyMCE.getWindowArg('mce_replacevariables', true))
body.innerHTML = tinyMCE.applyTemplate(body.innerHTML, tinyMCE.windowArgs);
- var dir = tinyMCE.selectedInstance.settings['directionality'];
- if (dir == "rtl") {
- var elms = document.forms[0].elements;
- for (var i=0; i<elms.length; i++) {
+ dir = tinyMCE.selectedInstance.settings['directionality'];
+ if (dir == "rtl" && document.forms && document.forms.length > 0) {
+ elms = document.forms[0].elements;
+ for (i=0; i<elms.length; i++) {
if ((elms[i].type == "text" || elms[i].type == "textarea") && elms[i].getAttribute("dir") != "ltr")
elms[i].dir = dir;
}
@@ -89,19 +94,20 @@ TinyMCEPopup.prototype.onLoad = function() {
body.style.display = 'block';
// Execute real onload (Opera fix)
- if (tinyMCEPopup.onLoadEval != "") {
+ if (tinyMCEPopup.onLoadEval != "")
eval(tinyMCEPopup.onLoadEval);
- }
};
-TinyMCEPopup.prototype.executeOnLoad = function(str) {
+
+TinyMCE_Popup.prototype.executeOnLoad = function(str) {
if (tinyMCE.isOpera)
this.onLoadEval = str;
else
eval(str);
};
-TinyMCEPopup.prototype.resizeToInnerSize = function() {
+
+TinyMCE_Popup.prototype.resizeToInnerSize = function() {
// Netscape 7.1 workaround
if (this.isWindow && tinyMCE.isNS71) {
window.resizeBy(0, 10);
@@ -118,13 +124,13 @@ TinyMCEPopup.prototype.resizeToInnerSize = function() {
// Remove margin
oldMargin = body.style.margin;
- body.style.margin = '0px';
+ body.style.margin = '0';
// Create wrapper
wrapper = doc.createElement("div");
wrapper.id = 'mcBodyWrapper';
wrapper.style.display = 'none';
- wrapper.style.margin = '0px';
+ wrapper.style.margin = '0';
// Wrap body elements
nodes = doc.body.childNodes;
@@ -146,7 +152,7 @@ TinyMCEPopup.prototype.resizeToInnerSize = function() {
iframe.src = document.location.href.toLowerCase().indexOf('https') == -1 ? "about:blank" : tinyMCE.settings['default_document'];
iframe.width = "100%";
iframe.height = "100%";
- iframe.style.margin = '0px';
+ iframe.style.margin = '0';
// Add iframe
doc.body.appendChild(iframe);
@@ -167,7 +173,8 @@ TinyMCEPopup.prototype.resizeToInnerSize = function() {
}
};
-TinyMCEPopup.prototype.resizeToContent = function() {
+
+TinyMCE_Popup.prototype.resizeToContent = function() {
var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
@@ -197,31 +204,42 @@ TinyMCEPopup.prototype.resizeToContent = function() {
}
};
-TinyMCEPopup.prototype.getWindowArg = function(name, default_value) {
+
+TinyMCE_Popup.prototype.getWindowArg = function(name, default_value) {
return tinyMCE.getWindowArg(name, default_value);
};
-TinyMCEPopup.prototype.execCommand = function(command, user_interface, value) {
- var inst = tinyMCE.selectedInstance;
- // Restore selection
+TinyMCE_Popup.prototype.restoreSelection = function() {
if (this.storeSelection) {
+ var inst = tinyMCE.selectedInstance;
+
inst.getWin().focus();
- inst.execCommand('mceRestoreSelection');
+
+ if (inst.selectionBookmark)
+ inst.selection.moveToBookmark(inst.selectionBookmark);
}
+};
+
+TinyMCE_Popup.prototype.execCommand = function(command, user_interface, value) {
+ var inst = tinyMCE.selectedInstance;
+
+ this.restoreSelection();
inst.execCommand(command, user_interface, value);
// Store selection
if (this.storeSelection)
- inst.execCommand('mceStoreSelection');
+ inst.selectionBookmark = inst.selection.getBookmark(true);
};
-TinyMCEPopup.prototype.close = function() {
+
+TinyMCE_Popup.prototype.close = function() {
tinyMCE.closeWindow(window);
};
-TinyMCEPopup.prototype.pickColor = function(e, element_id) {
+
+TinyMCE_Popup.prototype.pickColor = function(e, element_id) {
tinyMCE.selectedInstance.execCommand('mceColorPicker', true, {
element_id : element_id,
document : document,
@@ -230,7 +248,8 @@ TinyMCEPopup.prototype.pickColor = function(e, element_id) {
});
};
-TinyMCEPopup.prototype.openBrowser = function(element_id, type, option) {
+
+TinyMCE_Popup.prototype.openBrowser = function(element_id, type, option) {
var cb = tinyMCE.getParam(option, tinyMCE.getParam("file_browser_callback"));
var url = document.getElementById(element_id).value;
@@ -245,6 +264,6 @@ TinyMCEPopup.prototype.openBrowser = function(element_id, type, option) {
};
// Setup global instance
-var tinyMCEPopup = new TinyMCEPopup();
+var tinyMCEPopup = new TinyMCE_Popup();
tinyMCEPopup.init();
diff --git a/wp-inst/wp-includes/js/tinymce/utils/form_utils.js b/wp-inst/wp-includes/js/tinymce/utils/form_utils.js
index 639b681..0481815 100644
--- a/wp-inst/wp-includes/js/tinymce/utils/form_utils.js
+++ b/wp-inst/wp-includes/js/tinymce/utils/form_utils.js
@@ -1,22 +1,22 @@
/**
* $RCSfile: form_utils.js,v $
- * $Revision: 1.5 $
- * $Date: 2005/10/25 16:01:51 $
+ * $Revision: 1.10 $
+ * $Date: 2006/03/22 12:21:24 $
*
* Various form utilitiy functions.
*
* @author Moxiecode
- * @copyright Copyright © 2005, Moxiecode Systems AB, All rights reserved.
+ * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
*/
function getColorPickerHTML(id, target_form_element) {
var html = "";
html += '<a id="' + id + '_link" href="javascript:void(0);" onkeydown="pickColor(event,\'' + target_form_element +'\');" onmousedown="pickColor(event,\'' + target_form_element +'\');return false;">';
- html += '<img id="' + id + '" src="../../themes/advanced/images/color.gif"';
- html += ' onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');"';
- html += ' onmouseout="tinyMCE.restoreClass(this);"';
- html += ' onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');"';
+ html += '<img id="' + id + '" src="../../themes/' + tinyMCE.getParam("theme") + '/images/color.gif"';
+ html += ' onmouseover="this.className=\'mceButtonOver\'"';
+ html += ' onmouseout="this.className=\'mceButtonNormal\'"';
+ html += ' onmousedown="this.className=\'mceButtonDown\'"';
html += ' width="20" height="16" border="0" title="' + tinyMCE.getLang('lang_browse') + '"';
html += ' class="mceButtonNormal" alt="' + tinyMCE.getLang('lang_browse') + '" /></a>';
@@ -57,10 +57,10 @@ function getBrowserHTML(id, target_form_element, type, prefix) {
var html = "";
html += '<a id="' + id + '_link" href="javascript:openBrower(\'' + id + '\',\'' + target_form_element + '\', \'' + type + '\',\'' + option + '\');" onmousedown="return false;">';
- html += '<img id="' + id + '" src="../../themes/advanced/images/browse.gif"';
- html += ' onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');"';
- html += ' onmouseout="tinyMCE.restoreClass(this);"';
- html += ' onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');"';
+ html += '<img id="' + id + '" src="../../themes/' + tinyMCE.getParam("theme") + '/images/browse.gif"';
+ html += ' onmouseover="this.className=\'mceButtonOver\';"';
+ html += ' onmouseout="this.className=\'mceButtonNormal\';"';
+ html += ' onmousedown="this.className=\'mceButtonDown\';"';
html += ' width="20" height="18" border="0" title="' + tinyMCE.getLang('lang_browse') + '"';
html += ' class="mceButtonNormal" alt="' + tinyMCE.getLang('lang_browse') + '" /></a>';
@@ -74,7 +74,7 @@ function openBrower(img_id, target_form_element, type, option) {
tinyMCEPopup.openBrowser(target_form_element, type, option);
}
-function selectByValue(form_obj, field_name, value, add_custom) {
+function selectByValue(form_obj, field_name, value, add_custom, ignore_case) {
if (!form_obj || !form_obj.elements[field_name])
return;
@@ -84,7 +84,7 @@ function selectByValue(form_obj, field_name, value, add_custom) {
for (var i=0; i<sel.options.length; i++) {
var option = sel.options[i];
- if (option.value == value) {
+ if (option.value == value || (ignore_case && option.value.toLowerCase() == value.toLowerCase())) {
option.selected = true;
found = true;
} else
@@ -109,8 +109,13 @@ function getSelectValue(form_obj, field_name) {
return elm.options[elm.selectedIndex].value;
}
+function addSelectValue(form_obj, field_name, name, value) {
+ var s = form_obj.elements[field_name];
+ var o = new Option(name, value);
+ s.options[s.options.length] = o;
+}
+
function addClassesToList(list_id, specific_option) {
-return;
// Setup class droplist
var styleSelectElm = document.getElementById(list_id);
var styles = tinyMCE.getParam('theme_advanced_styles', false);
diff --git a/wp-inst/wp-includes/js/tinymce/utils/mctabs.js b/wp-inst/wp-includes/js/tinymce/utils/mctabs.js
index 9554f8f..c159360 100644
--- a/wp-inst/wp-includes/js/tinymce/utils/mctabs.js
+++ b/wp-inst/wp-includes/js/tinymce/utils/mctabs.js
@@ -1,12 +1,12 @@
/**
* $RCSfile: mctabs.js,v $
- * $Revision: 1.1 $
- * $Date: 2005/08/01 18:36:35 $
+ * $Revision: 1.2 $
+ * $Date: 2006/02/06 20:11:09 $
*
* Moxiecode DHTML Tabs script.
*
* @author Moxiecode
- * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.
+ * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
*/
function MCTabs() {
diff --git a/wp-inst/wp-includes/js/tinymce/utils/validate.js b/wp-inst/wp-includes/js/tinymce/utils/validate.js
index 95ae4d3..747b62b 100644
--- a/wp-inst/wp-includes/js/tinymce/utils/validate.js
+++ b/wp-inst/wp-includes/js/tinymce/utils/validate.js
@@ -1,12 +1,12 @@
/**
* $RCSfile: validate.js,v $
- * $Revision: 1.2 $
- * $Date: 2005/08/13 12:20:37 $
+ * $Revision: 1.3 $
+ * $Date: 2006/02/06 20:11:09 $
*
* Various form validation methods.
*
* @author Moxiecode
- * @copyright Copyright © 2005, Moxiecode Systems AB, All rights reserved.
+ * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
*/
function testRegExp(form_name, element_name, re) {
diff --git a/wp-inst/wp-includes/js/tinymce/wp-mce-help.php b/wp-inst/wp-includes/js/tinymce/wp-mce-help.php
index a193ab9..ffe385f 100644
--- a/wp-inst/wp-includes/js/tinymce/wp-mce-help.php
+++ b/wp-inst/wp-includes/js/tinymce/wp-mce-help.php
@@ -118,29 +118,27 @@ require_once('../../../wp-config.php');
<div id="content1">
<h2><?php _e('Rich Editing Basics') ?></h2>
- <p><?php _e('<em>Rich editing</em>, also called WYSIWYG for What You See Is What You Get, means your text is formatted as you type. The rich editor creates HTML code behind the scenes while you concentrate on writing. Font styles, links and images all appear just as they will on the internet.') ?></p>
- <p><?php _e('WordPress includes TinyMCE, a rich editor that works well in most web browsers used today. It is powerful but it has limitations. Pasting text from other word processors may not give the results you expect. If you do not like the way the rich editor works, you may turn it off in the My Profile form, under Users in the admin menu.') ?></p>
- <p><?php _e('Because HTML code depends on the less-than character (&lt;) to render web pages, this character is reserved for HTML code. If you want a "<" to be visible on your site, you must encode it as "&amp;lt;" without the quotes.') ?></p>
+ <p><?php _e('<em>Rich editing</em>, also called WYSIWYG for What You See Is What You Get, means your text is formatted as you type. The rich editor creates HTML code behind the scenes while you concentrate on writing. Font styles, links and images all appear approximately as they will on the internet.') ?></p>
+ <p><?php _e('WordPress includes a rich HTML editor that works well in most web browsers used today. It is powerful but it has limitations. Pasting text from other word processors may not give the results you expect. If you do not like the way the rich editor works, you may turn it off in the Your Profile and Personal Options form, under Users in the admin menu.') ?></p>
</div>
<div id="content2" class="hidden">
<h2><?php _e('Advanced Rich Editing') ?></h2>
<h3><?php _e('Images and Attachments') ?></h3>
- <p><?php _e('Some (not all) browsers allow you to drag images and other items directly into the editor. Most <a href="http://www.mozilla.org/products/firefox/" title="Mozilla.org, home of the Firefox web browser" target="_blank">Firefox</a> users can drag images from the uploading box (directly below the editor) and see their images instantly, complete with a link. If you cannot do this, use your clipboard Copy and Paste functions to insert the image and link tags. The rich editor will display the images after you have saved the post or used the HTML Editor to refresh the display.') ?></p>
+ <p><?php _e('There is a button in the editor toolbar for inserting images that are already hosted somewhere on the internet. If you have a URL for an image, click this button and enter the URL in the box which appears.') ?></p>
+ <p><?php _e('If you need to upload an image or sound file from your computer, you can use the uploading tool below the editor. The tool will attempt to create a thumbnail-sized image when you upload an image. To insert your uploaded image into the post, first click on the thumbnail to reveal a menu of options. Clicking on a "Using.." or "Linked..." option will change that option. For instance, you might want to use the thumbnail in the post and link it to a page showing the original with a caption. When you have selected the options you like, click "Send to Editor" and your image or file will appear in the post you are editing.</p>') ?>
<h3><?php _e('HTML in the Rich Editor') ?></h3>
- <p><?php _e('When you want to include HTML elements that are not generated by the toolbar buttons, you must enter it by hand. Examples are &lt;pre> and &lt;code>. Simply type the code into the editor. If the code is valid and allowed by the editor, you should see it rendered the next time you update the display, usually by saving or using the HTML Editor. If you want to display "&lt;" on the web, you must encode it as "&amp;lt;" in the editor.') ?></p>
- <h3><?php _e('The HTML Editor') ?></h3>
- <p><?php _e('The editor will not always understand your intentions as your editing gets more complex. Use the HTML Editor to sort out any rough spots, such as extra elements or attributes. WordPress will strip all empty &lt;p> tags and &lt;br /> tags in favor of simple newline characters. However, it will preserve any tag such as this: &lt;p class="anyclass">&lt;/p>. When using the HTML editor, all less-thans are double-encoded: &amp;amp;lt;. This ensures they display as &amp;lt; in the rich editor and &lt; on the web.') ?></p>
+ <p><?php _e('Any HTML entered directly into the rich editor will show up as text when the post is viewed. What you see is what you get. When you want to include HTML elements that cannot be generated with the toolbar buttons, you must enter it by hand in the HTML editor. Examples are tables and &lt;code&gt;. To do this, click the HTML button and edit the code, then click Update. If the code is valid and understood by the editor, you should see it rendered immediately.') ?></p>
</div>
<div id="content3" class="hidden">
<h2><?php _e('Writing at Full Speed') ?></h2>
<p><?php _e('Rather than reaching for your mouse to click on the toolbar, use these access keys. Windows and Linux use Alt+&lt;letter>. Macintosh uses Ctrl+&lt;letter>.') ?></p>
<table id="keys" width="100%" border="0">
- <tr class="top"><th class="key center"><?php _e('Key') ?></th><th class="left"><?php _e('Action') ?></th><th class="key center"><?php _e('Key') ?></th><th class="left"><?php _e('Action') ?></th></tr>
- <tr><th>b</th><td><strong><?php _e('Bold') ?></strong></td><th>f</th><td class="align left"><?php _e('Align Left') ?></td></tr>
- <tr><th>i</th><td><em><?php _e('Italic') ?></em></td><th>c</th><td class="align center"><?php _e('Align Center') ?></td></tr>
- <tr><th>d</th><td><strike><?php _e('Strikethrough') ?></strike></td><th>r</th><td class="align right"><?php _e('Align Right') ?></td></tr>
+ <tr class="top"><th class="key center"><?php _e('Letter') ?></th><th class="left"><?php _e('Action') ?></th><th class="key center"><?php _e('Letter') ?></th><th class="left"><?php _e('Action') ?></th></tr>
+ <tr><th>n</th><td><?php _e('Check Spelling') ?></td><th>f</th><td class="align left"><?php _e('Align Left') ?></td></tr>
+ <tr><th>j</th><td><?php _e('Justify Text') ?></td><th>c</th><td class="align center"><?php _e('Align Center') ?></td></tr>
+ <tr><th>k</th><td><strike><?php _e('Strikethrough') ?></strike></td><th>r</th><td class="align right"><?php _e('Align Right') ?></td></tr>
<tr><th>l</th><td><b>&bull;</b> <?php _e('List') ?></td><th>a</th><td><?php _e('Insert <span class="anchor">Anchor</span>') ?></td></tr>
<tr><th>o</th><td>1. <?php _e('List') ?></td><th>s</th><td><?php _e('Unlink Anchor') ?></td></tr>
<tr><th>q</th><td>&rarr;<?php _e('Quote/Indent') ?></td><th>m</th><td><?php _e('Insert Image') ?></td></tr>
diff --git a/wp-inst/wp-includes/js/tw-sack.js b/wp-inst/wp-includes/js/tw-sack.js
index cb275e1..f93f2a4 100644
--- a/wp-inst/wp-includes/js/tw-sack.js
+++ b/wp-inst/wp-includes/js/tw-sack.js
@@ -1,133 +1,193 @@
-/* Simple AJAX Code-Kit (SACK) */
+/* Simple AJAX Code-Kit (SACK) v1.6.1 */
/* ©2005 Gregory Wild-Smith */
/* www.twilightuniverse.com */
-/* Software licenced under a modified X11 licence, see documentation or authors website for more details */
+/* Software licenced under a modified X11 licence,
+ see documentation or authors website for more details */
-function sack(file){
- this.AjaxFailedAlert = "Your browser does not support the enhanced functionality of this website, and therefore you will have an experience that differs from the intended one.\n";
- this.requestFile = file;
- this.method = "POST";
- this.URLString = "";
- this.encodeURIString = true;
- this.execute = false;
+function sack(file) {
+ this.xmlhttp = null;
- this.onLoading = function() { };
- this.onLoaded = function() { };
- this.onInteractive = function() { };
- this.onCompletion = function() { };
+ this.resetData = function() {
+ this.method = "POST";
+ this.queryStringSeparator = "?";
+ this.argumentSeparator = "&";
+ this.URLString = "";
+ this.encodeURIString = true;
+ this.execute = false;
+ this.element = null;
+ this.elementObj = null;
+ this.requestFile = file;
+ this.vars = new Object();
+ this.responseStatus = new Array(2);
+ };
+
+ this.resetFunctions = function() {
+ this.onLoading = function() { };
+ this.onLoaded = function() { };
+ this.onInteractive = function() { };
+ this.onCompletion = function() { };
+ this.onError = function() { };
+ this.onFail = function() { };
+ };
+
+ this.reset = function() {
+ this.resetFunctions();
+ this.resetData();
+ };
this.createAJAX = function() {
try {
this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
+ } catch (e1) {
try {
this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
- } catch (err) {
+ } catch (e2) {
this.xmlhttp = null;
}
}
- if(!this.xmlhttp && typeof XMLHttpRequest != "undefined")
- this.xmlhttp = new XMLHttpRequest();
- if (!this.xmlhttp){
- this.failed = true;
+
+ if (! this.xmlhttp) {
+ if (typeof XMLHttpRequest != "undefined") {
+ this.xmlhttp = new XMLHttpRequest();
+ } else {
+ this.failed = true;
+ }
}
};
this.setVar = function(name, value){
- if (this.URLString.length < 3){
- this.URLString = name + "=" + value;
+ this.vars[name] = Array(value, false);
+ };
+
+ this.encVar = function(name, value, returnvars) {
+ if (true == returnvars) {
+ return Array(encodeURIComponent(name), encodeURIComponent(value));
} else {
- this.URLString += "&" + name + "=" + value;
+ this.vars[encodeURIComponent(name)] = Array(encodeURIComponent(value), true);
}
}
- this.encVar = function(name, value){
- var varString = encodeURIComponent(name) + "=" + encodeURIComponent(value);
- return varString;
+ this.processURLString = function(string, encode) {
+ encoded = encodeURIComponent(this.argumentSeparator);
+ regexp = new RegExp(this.argumentSeparator + "|" + encoded);
+ varArray = string.split(regexp);
+ for (i = 0; i < varArray.length; i++){
+ urlVars = varArray[i].split("=");
+ if (true == encode){
+ this.encVar(urlVars[0], urlVars[1]);
+ } else {
+ this.setVar(urlVars[0], urlVars[1]);
+ }
+ }
}
- this.encodeURLString = function(string){
- varArray = string.split('&');
- for (i = 0; i < varArray.length; i++){
- urlVars = varArray[i].split('=');
- if (urlVars[0].indexOf('amp;') != -1){
- urlVars[0] = urlVars[0].substring(4);
+ this.createURLString = function(urlstring) {
+ if (this.encodeURIString && this.URLString.length) {
+ this.processURLString(this.URLString, true);
+ }
+
+ if (urlstring) {
+ if (this.URLString.length) {
+ this.URLString += this.argumentSeparator + urlstring;
+ } else {
+ this.URLString = urlstring;
+ }
+ }
+
+ // prevents caching of URLString
+ this.setVar("rndval", new Date().getTime());
+
+ urlstringtemp = new Array();
+ for (key in this.vars) {
+ if (false == this.vars[key][1] && true == this.encodeURIString) {
+ encoded = this.encVar(key, this.vars[key][0], true);
+ delete this.vars[key];
+ this.vars[encoded[0]] = Array(encoded[1], true);
+ key = encoded[0];
}
- varArray[i] = this.encVar(urlVars[0],urlVars[1]);
+
+ urlstringtemp[urlstringtemp.length] = key + "=" + this.vars[key][0];
+ }
+ if (urlstring){
+ this.URLString += this.argumentSeparator + urlstringtemp.join(this.argumentSeparator);
+ } else {
+ this.URLString += urlstringtemp.join(this.argumentSeparator);
}
- return varArray.join('&');
}
- this.runResponse = function(){
+ this.runResponse = function() {
eval(this.response);
}
- this.runAJAX = function(urlstring){
- this.responseStatus = new Array(2);
- if(this.failed && this.AjaxFailedAlert){
- alert(this.AjaxFailedAlert);
+ this.runAJAX = function(urlstring) {
+ if (this.failed) {
+ this.onFail();
} else {
- if (urlstring){
- if (this.URLString.length){
- this.URLString = this.URLString + "&" + urlstring;
- } else {
- this.URLString = urlstring;
- }
+ this.createURLString(urlstring);
+ if (this.element) {
+ this.elementObj = document.getElementById(this.element);
}
- if (this.encodeURIString){
- var timeval = new Date().getTime();
- this.URLString = this.encodeURLString(this.URLString);
- this.setVar("rndval", timeval);
- }
- if (this.element) { this.elementObj = document.getElementById(this.element); }
if (this.xmlhttp) {
var self = this;
if (this.method == "GET") {
- var totalurlstring = this.requestFile + "?" + this.URLString;
+ totalurlstring = this.requestFile + this.queryStringSeparator + this.URLString;
this.xmlhttp.open(this.method, totalurlstring, true);
} else {
this.xmlhttp.open(this.method, this.requestFile, true);
- }
- if (this.method == "POST"){
- try {
- this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded')
- } catch (e) {}
+ try {
+ this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
+ } catch (e) { }
}
- this.xmlhttp.send(this.URLString);
this.xmlhttp.onreadystatechange = function() {
- switch (self.xmlhttp.readyState){
+ switch (self.xmlhttp.readyState) {
case 1:
self.onLoading();
- break;
+ break;
case 2:
self.onLoaded();
- break;
+ break;
case 3:
self.onInteractive();
- break;
+ break;
case 4:
self.response = self.xmlhttp.responseText;
self.responseXML = self.xmlhttp.responseXML;
self.responseStatus[0] = self.xmlhttp.status;
self.responseStatus[1] = self.xmlhttp.statusText;
- self.onCompletion();
- if(self.execute){ self.runResponse(); }
+
+ if (self.execute) {
+ self.runResponse();
+ }
+
if (self.elementObj) {
- var elemNodeName = self.elementObj.nodeName;
+ elemNodeName = self.elementObj.nodeName;
elemNodeName.toLowerCase();
- if (elemNodeName == "input" || elemNodeName == "select" || elemNodeName == "option" || elemNodeName == "textarea"){
+ if (elemNodeName == "input"
+ || elemNodeName == "select"
+ || elemNodeName == "option"
+ || elemNodeName == "textarea") {
self.elementObj.value = self.response;
} else {
self.elementObj.innerHTML = self.response;
}
}
+ if (self.responseStatus[0] == "200") {
+ self.onCompletion();
+ } else {
+ self.onError();
+ }
+
self.URLString = "";
- break;
+ break;
}
};
+
+ this.xmlhttp.send(this.URLString);
}
}
};
-this.createAJAX();
+
+ this.reset();
+ this.createAJAX();
}
diff --git a/wp-inst/wp-includes/links.php b/wp-inst/wp-includes/links.php
deleted file mode 100644
index 861801f..0000000
--- a/wp-inst/wp-includes/links.php
+++ /dev/null
@@ -1,580 +0,0 @@
-<?php
-
-/** function get_linksbyname()
- ** Gets the links associated with category 'cat_name'.
- ** Parameters:
- ** cat_name (default 'noname') - The category name to use. If no
- ** match is found uses all
- ** before (default '') - the html to output before the link
- ** after (default '<br />') - the html to output after the link
- ** between (default ' ') - the html to output between the link/image
- ** and it's description. Not used if no image or show_images == true
- ** show_images (default true) - whether to show images (if defined).
- ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
- ** 'url', 'description' or 'rating'. Or maybe owner. If you start the
- ** name with an underscore the order will be reversed.
- ** You can also specify 'rand' as the order which will return links in a
- ** random order.
- ** show_description (default true) - whether to show the description if
- ** show_images=false/not defined
- ** show_rating (default false) - show rating stars/chars
- ** limit (default -1) - Limit to X entries. If not specified, all entries
- ** are shown.
- ** show_updated (default 0) - whether to show last updated timestamp
- */
-function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />',
- $between = " ", $show_images = true, $orderby = 'id',
- $show_description = true, $show_rating = false,
- $limit = -1, $show_updated = 0) {
- global $wpdb;
- $cat_id = -1;
- $results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
- if ($results) {
- foreach ($results as $result) {
- $cat_id = $result->cat_id;
- }
- }
- get_links($cat_id, $before, $after, $between, $show_images, $orderby,
- $show_description, $show_rating, $limit, $show_updated);
-}
-
-function bool_from_yn($yn) {
- if ($yn == 'Y') return 1;
- return 0;
-}
-
-/** function wp_get_linksbyname()
- ** Gets the links associated with the named category.
- ** Parameters:
- ** category (no default) - The category to use.
- **/
-function wp_get_linksbyname($category, $args = '') {
- global $wpdb;
-
- $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
- . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
- . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_name='$category'");
-
- if (! $cat) {
- return;
- }
-
- if (empty($args)) {
- if ($cat->sort_desc == 'Y') {
- $cat->sort_order = '_'.$cat->sort_order;
- }
- get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all,
- $cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order,
- bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating),
- $cat->list_limit, bool_from_yn($cat->show_updated));
- } else {
- $args = add_query_arg('category', $cat->cat_id, $args);
- wp_get_links($args);
- }
-} // end wp_get_linksbyname
-
-/** function wp_get_links()
- ** Gets the links associated with category n.
- ** Parameters:
- ** category (no default) - The category to use.
- ** or:
- ** a query string
- **/
-function wp_get_links($args = '') {
- global $wpdb;
-
- if (!empty($args) && false === strpos($args, '=')) {
- // If args is not a query string, it's a category id.
- $category = $args;
- $cat = $wpdb->get_row("SELECT cat_id, cat_name, auto_toggle, show_images, show_description, "
- . " show_rating, show_updated, sort_order, sort_desc, text_before_link, text_after_link, "
- . " text_after_all, list_limit FROM $wpdb->linkcategories WHERE cat_id=$category");
- if ($cat) {
- if ($cat->sort_desc == 'Y') {
- $cat->sort_order = '_'.$cat->sort_order;
- }
- get_links($cat->cat_id, $cat->text_before_link, $cat->text_after_all,
- $cat->text_after_link, bool_from_yn($cat->show_images), $cat->sort_order,
- bool_from_yn($cat->show_description), bool_from_yn($cat->show_rating),
- $cat->list_limit, bool_from_yn($cat->show_updated));
- }
- } else {
- parse_str($args);
-
- if (! isset($category)) $category = -1;
- if (! isset($before)) $before = '';
- if (! isset($after)) $after = '<br />';
- if (! isset($between)) $between = ' ';
- if (! isset($show_images)) $show_images = true;
- if (! isset($orderby)) $orderby = 'name';
- if (! isset($show_description)) $show_description = true;
- if (! isset($show_rating)) $show_rating = false;
- if (! isset($limit)) $limit = -1;
- if (! isset($show_updated)) $show_updated = 1;
- if (! isset($echo)) $echo = true;
-
- return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo);
- }
-} // end wp_get_links
-
-/** function get_links()
- ** Gets the links associated with category n.
- ** Parameters:
- ** category (default -1) - The category to use. If no category supplied
- ** uses all
- ** before (default '') - the html to output before the link
- ** after (default '<br />') - the html to output after the link
- ** between (default ' ') - the html to output between the link/image
- ** and its description. Not used if no image or show_images == true
- ** show_images (default true) - whether to show images (if defined).
- ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
- ** 'url', 'description', or 'rating'. Or maybe owner. If you start the
- ** name with an underscore the order will be reversed.
- ** You can also specify 'rand' as the order which will return links in a
- ** random order.
- ** show_description (default true) - whether to show the description if
- ** show_images=false/not defined .
- ** show_rating (default false) - show rating stars/chars
- ** limit (default -1) - Limit to X entries. If not specified, all entries
- ** are shown.
- ** show_updated (default 0) - whether to show last updated timestamp
- ** echo (default true) - whether to echo the results, or return them instead
- */
-function get_links($category = -1,
- $before = '',
- $after = '<br />',
- $between = ' ',
- $show_images = true,
- $orderby = 'name',
- $show_description = true,
- $show_rating = false,
- $limit = -1,
- $show_updated = 1,
- $echo = true) {
-
- global $wpdb;
-
- $direction = ' ASC';
- $category_query = '';
- if ($category != -1) {
- $category_query = " AND link_category = $category ";
- }
- if (get_settings('links_recently_updated_time')) {
- $recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL " . get_settings('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated ";
- } else {
- $recently_updated_test = '';
- }
- if ($show_updated) {
- $get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f ";
- }
-
- $orderby = strtolower($orderby);
- if ($orderby == '')
- $orderby = 'id';
- if (substr($orderby, 0, 1) == '_') {
- $direction = ' DESC';
- $orderby = substr($orderby, 1);
- }
-
- switch($orderby) {
- case 'length':
- $length = ", CHAR_LENGTH(link_name) AS length";
- break;
- case 'rand':
- $orderby = 'rand()';
- break;
- default:
- $orderby = " link_" . $orderby;
- }
-
- if (!isset($length)) {
- $length = '';
- }
-
- $sql = "SELECT link_url, link_name, link_image, link_target, link_description, link_rating, link_rel $length $recently_updated_test $get_updated FROM $wpdb->links WHERE link_visible = 'Y' " . $category_query;
- $sql .= ' ORDER BY ' . $orderby . $direction;
- /* The next 2 lines implement LIMIT TO processing */
- if ($limit != -1)
- $sql .= " LIMIT $limit";
- $cached_results = wp_cache_get( md5( $sql ), 'general');
- if ( is_array( $cached_results ) == false || ( is_array( $cached_results ) == true && ( get_option( 'links_last_updated' ) != false && $cached_results[ 'time' ] < get_option( 'links_last_updated' ) ) ) ) {
- $results = $wpdb->get_results($sql);
- wp_cache_set( md5( $sql ), array( 'results' => $results, 'time' => time() ), 'general', 360 );
- } else {
- $results = $cached_results[ 'results' ];
- }
- if (!$results) {
- return;
- }
-
- $output = '';
-
- foreach ($results as $row) {
- if (!isset($row->recently_updated)) $row->recently_updated = false;
- $output .= $before;
- if ($show_updated && $row->recently_updated) {
- $output .= get_settings('links_recently_updated_prepend');
- }
-
- $the_link = '#';
- if (!empty($row->link_url))
- $the_link = wp_specialchars($row->link_url);
-
- $rel = $row->link_rel;
- if ($rel != '') {
- $rel = ' rel="' . $rel . '"';
- }
-
- $desc = wp_specialchars($row->link_description, ENT_QUOTES);
- $name = wp_specialchars($row->link_name, ENT_QUOTES);
- $title = $desc;
-
- if ($show_updated) {
- if (substr($row->link_updated_f, 0, 2) != '00') {
- $title .= ' (Last updated ' . date(get_settings('links_updated_date_format'), $row->link_updated_f + (get_settings('gmt_offset') * 3600)) . ')';
- }
- }
-
- if ('' != $title) {
- $title = ' title="' . $title . '"';
- }
-
- $alt = ' alt="' . $name . '"';
-
- $target = $row->link_target;
- if ('' != $target) {
- $target = ' target="' . $target . '"';
- }
-
- $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>';
-
- if (($row->link_image != null) && $show_images) {
- if (strstr($row->link_image, 'http'))
- $output .= "<img src=\"$row->link_image\" $alt $title />";
- else // If it's a relative path
- $output .= "<img src=\"" . get_settings('siteurl') . "$row->link_image\" $alt $title />";
- } else {
- $output .= $name;
- }
-
- $output .= '</a>';
-
- if ($show_updated && $row->recently_updated) {
- $output .= get_settings('links_recently_updated_append');
- }
-
- if ($show_description && ($desc != '')) {
- $output .= $between . $desc;
- }
- $output .= "$after\n";
- } // end while
-
- if ($echo) {
- echo $output;
- } else {
- return $output;
- }
-}
-
-
-/** function get_linkobjectsbyname()
- ** Gets an array of link objects associated with category 'cat_name'.
- ** Parameters:
- ** cat_name (default 'noname') - The category name to use. If no
- ** match is found uses all
- ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
- ** 'url', 'description', or 'rating'. Or maybe owner. If you start the
- ** name with an underscore the order will be reversed.
- ** You can also specify 'rand' as the order which will return links in a
- ** random order.
- ** limit (default -1) - Limit to X entries. If not specified, all entries
- ** are shown.
- **
- ** Use this like:
- ** $links = get_linkobjectsbyname('fred');
- ** foreach ($links as $link) {
- ** echo '<li>'.$link->link_name.'</li>';
- ** }
- **/
-function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) {
- global $wpdb;
- $cat_id = -1;
- $results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
- if ($results) {
- foreach ($results as $result) {
- $cat_id = $result->cat_id;
- }
- }
- return get_linkobjects($cat_id, $orderby, $limit);
-}
-
-/** function get_linkobjects()
- ** Gets an array of link objects associated with category n.
- ** Parameters:
- ** category (default -1) - The category to use. If no category supplied
- ** uses all
- ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
- ** 'url', 'description', or 'rating'. Or maybe owner. If you start the
- ** name with an underscore the order will be reversed.
- ** You can also specify 'rand' as the order which will return links in a
- ** random order.
- ** limit (default -1) - Limit to X entries. If not specified, all entries
- ** are shown.
- **
- ** Use this like:
- ** $links = get_linkobjects(1);
- ** if ($links) {
- ** foreach ($links as $link) {
- ** echo '<li>'.$link->link_name.'<br />'.$link->link_description.'</li>';
- ** }
- ** }
- ** Fields are:
- ** link_id
- ** link_url
- ** link_name
- ** link_image
- ** link_target
- ** link_category
- ** link_description
- ** link_visible
- ** link_owner
- ** link_rating
- ** link_updated
- ** link_rel
- ** link_notes
- **/
-function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
- global $wpdb;
-
- $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'";
- if ($category != -1) {
- $sql .= " AND link_category = $category ";
- }
- if ($orderby == '')
- $orderby = 'id';
- if (substr($orderby,0,1) == '_') {
- $direction = ' DESC';
- $orderby = substr($orderby,1);
- }
- if (strcasecmp('rand',$orderby) == 0) {
- $orderby = 'rand()';
- } else {
- $orderby = " link_" . $orderby;
- }
- $sql .= ' ORDER BY ' . $orderby;
- $sql .= $direction;
- /* The next 2 lines implement LIMIT TO processing */
- if ($limit != -1)
- $sql .= " LIMIT $limit";
-
- $results = $wpdb->get_results($sql);
- if ($results) {
- foreach ($results as $result) {
- $result->link_url = $result->link_url;
- $result->link_name = $result->link_name;
- $result->link_description = $result->link_description;
- $result->link_notes = $result->link_notes;
- $newresults[] = $result;
- }
- }
- return $newresults;
-}
-
-function get_linkrating($link) {
- return apply_filters('link_rating', $link->link_rating);
-}
-
-
-/** function get_linksbyname_withrating()
- ** Gets the links associated with category 'cat_name' and display rating stars/chars.
- ** Parameters:
- ** cat_name (default 'noname') - The category name to use. If no
- ** match is found uses all
- ** before (default '') - the html to output before the link
- ** after (default '<br />') - the html to output after the link
- ** between (default ' ') - the html to output between the link/image
- ** and it's description. Not used if no image or show_images == true
- ** show_images (default true) - whether to show images (if defined).
- ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
- ** 'url' or 'description'. Or maybe owner. If you start the
- ** name with an underscore the order will be reversed.
- ** You can also specify 'rand' as the order which will return links in a
- ** random order.
- ** show_description (default true) - whether to show the description if
- ** show_images=false/not defined
- ** limit (default -1) - Limit to X entries. If not specified, all entries
- ** are shown.
- ** show_updated (default 0) - whether to show last updated timestamp
- */
-function get_linksbyname_withrating($cat_name = "noname", $before = '',
- $after = '<br />', $between = " ",
- $show_images = true, $orderby = 'id',
- $show_description = true, $limit = -1, $show_updated = 0) {
-
- get_linksbyname($cat_name, $before, $after, $between, $show_images,
- $orderby, $show_description, true, $limit, $show_updated);
-}
-
-/** function get_links_withrating()
- ** Gets the links associated with category n and display rating stars/chars.
- ** Parameters:
- ** category (default -1) - The category to use. If no category supplied
- ** uses all
- ** before (default '') - the html to output before the link
- ** after (default '<br />') - the html to output after the link
- ** between (default ' ') - the html to output between the link/image
- ** and it's description. Not used if no image or show_images == true
- ** show_images (default true) - whether to show images (if defined).
- ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name',
- ** 'url' or 'description'. Or maybe owner. If you start the
- ** name with an underscore the order will be reversed.
- ** You can also specify 'rand' as the order which will return links in a
- ** random order.
- ** show_description (default true) - whether to show the description if
- ** show_images=false/not defined .
- ** limit (default -1) - Limit to X entries. If not specified, all entries
- ** are shown.
- ** show_updated (default 0) - whether to show last updated timestamp
- */
-function get_links_withrating($category = -1, $before = '', $after = '<br />',
- $between = " ", $show_images = true,
- $orderby = 'id', $show_description = true,
- $limit = -1, $show_updated = 0) {
-
- get_links($category, $before, $after, $between, $show_images, $orderby,
- $show_description, true, $limit, $show_updated);
-}
-
-/** function get_linkcatname()
- ** Gets the name of category n.
- ** Parameters: id (default 0) - The category to get. If no category supplied
- ** uses 0
- */
-function get_linkcatname($id = 0) {
- global $wpdb;
- $cat_name = '';
- if ('' != $id) {
- $cat_name = $wpdb->get_var("SELECT cat_name FROM $wpdb->linkcategories WHERE cat_id=$id");
- }
- return $cat_name;
-}
-
-/** function get_get_autotoggle()
- ** Gets the auto_toggle setting of category n.
- ** Parameters: id (default 0) - The category to get. If no category supplied
- ** uses 0
- */
-function get_autotoggle($id = 0) {
- global $wpdb;
- $auto_toggle = $wpdb->get_var("SELECT auto_toggle FROM $wpdb->linkcategories WHERE cat_id=$id");
- if ('' == $auto_toggle)
- $auto_toggle = 'N';
- return $auto_toggle;
-}
-
-/** function links_popup_script()
- ** This function contributed by Fullo -- http://sprite.csr.unibo.it/fullo/
- ** Show the link to the links popup and the number of links
- ** Parameters:
- ** text (default Links) - the text of the link
- ** width (default 400) - the width of the popup window
- ** height (default 400) - the height of the popup window
- ** file (default linkspopup.php) - the page to open in the popup window
- ** count (default true) - the number of links in the db
- */
-function links_popup_script($text = 'Links', $width=400, $height=400,
- $file='links.all.php', $count = true) {
- if ($count == true) {
- $counts = $wpdb->get_var("SELECT count(*) FROM $wpdb->links");
- }
-
- $javascript = "<a href=\"#\" " .
- " onclick=\"javascript:window.open('$file?popup=1', '_blank', " .
- "'width=$width,height=$height,scrollbars=yes,status=no'); " .
- " return false\">";
- $javascript .= $text;
-
- if ($count == true) {
- $javascript .= " ($counts)";
- }
-
- $javascript .="</a>\n\n";
- echo $javascript;
-}
-
-
-/*
- * function get_links_list()
- *
- * added by Dougal
- *
- * Output a list of all links, listed by category, using the
- * settings in $wpdb->linkcategories and output it as a nested
- * HTML unordered list.
- *
- * Parameters:
- * order (default 'name') - Sort link categories by 'name' or 'id'
- * hide_if_empty (default true) - Supress listing empty link categories
- */
-function get_links_list($order = 'name', $hide_if_empty = 'obsolete') {
- global $wpdb;
-
- $order = strtolower($order);
-
- // Handle link category sorting
- if (substr($order,0,1) == '_') {
- $direction = ' DESC';
- $order = substr($order,1);
- }
-
- // if 'name' wasn't specified, assume 'id':
- $cat_order = ('name' == $order) ? 'cat_name' : 'cat_id';
-
- if (!isset($direction)) $direction = '';
- // Fetch the link category data as an array of hashesa
-
- $q = "
- SELECT DISTINCT link_category, cat_name, show_images,
- show_description, show_rating, show_updated, sort_order,
- sort_desc, list_limit
- FROM `$wpdb->links`
- LEFT JOIN `$wpdb->linkcategories` ON (link_category = cat_id)
- WHERE link_visible = 'Y'
- AND list_limit <> 0
- ORDER BY $cat_order $direction ";
-
- $cached_results = wp_cache_get( md5( $q ), 'general');
- if ( is_array( $cached_results ) == false || ( is_array( $cached_results ) == true && ( get_option( 'links_last_updated' ) != false && $cached_results[ 'time' ] < get_option( 'links_last_updated' ) ) ) ) {
- $cats = $wpdb->get_results($q, ARRAY_A);
- wp_cache_set( md5( $q ), array( 'results' => $cats, 'time' => time() ), 'general', 360 );
- } else {
- $cats = $cached_results[ 'results' ];
- }
-
- // Display each category
- if ($cats) {
- foreach ($cats as $cat) {
- // Handle each category.
- // First, fix the sort_order info
- $orderby = $cat['sort_order'];
- $orderby = (bool_from_yn($cat['sort_desc'])?'_':'') . $orderby;
-
- // Display the category name
- echo ' <li id="linkcat-' . $cat['link_category'] . '"><h2>' . $cat['cat_name'] . "</h2>\n\t<ul>\n";
- // Call get_links() with all the appropriate params
- get_links($cat['link_category'],
- '<li>',"</li>","\n",
- bool_from_yn($cat['show_images']),
- $orderby,
- bool_from_yn($cat['show_description']),
- bool_from_yn($cat['show_rating']),
- $cat['list_limit'],
- bool_from_yn($cat['show_updated']));
-
- // Close the last category
- echo "\n\t</ul>\n</li>\n";
- }
- }
-}
-
-?>
diff --git a/wp-inst/wp-includes/pluggable-functions.php b/wp-inst/wp-includes/pluggable-functions.php
index b1b78f4..4d6f061 100644
--- a/wp-inst/wp-includes/pluggable-functions.php
+++ b/wp-inst/wp-includes/pluggable-functions.php
@@ -26,7 +26,7 @@ function wp_set_current_user($id, $name = '') {
}
endif;
-if ( !function_exists('current_user') ) :
+if ( !function_exists('wp_get_current_user') ) :
function wp_get_current_user() {
global $current_user;
@@ -226,6 +226,7 @@ function auth_redirect() {
!wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true)) ||
(empty($_COOKIE[USER_COOKIE])) ) {
nocache_headers();
+
header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
exit();
}
@@ -233,18 +234,43 @@ function auth_redirect() {
endif;
if ( !function_exists('check_admin_referer') ) :
-function check_admin_referer() {
+function check_admin_referer($action = -1) {
+ global $pagenow, $menu, $submenu, $parent_file, $submenu_file;;
$adminurl = strtolower(get_settings('siteurl')).'/wp-admin';
$referer = strtolower($_SERVER['HTTP_REFERER']);
- if (!strstr($referer, $adminurl))
- die(__('Sorry, you need to <a href="http://codex.wordpress.org/Enable_Sending_Referrers">enable sending referrers</a> for this feature to work.'));
- do_action('check_admin_referer');
-}
-endif;
+ if ( !wp_verify_nonce($_REQUEST['_wpnonce'], $action) &&
+ !(-1 == $action && strstr($referer, $adminurl)) ) {
+ if ( $referer )
+ $adminurl = $referer;
+ $title = __('WordPress Confirmation');
+ require_once(ABSPATH . '/wp-admin/admin-header.php');
+ // Remove extra layer of slashes.
+ $_POST = stripslashes_deep($_POST );
+ if ( $_POST ) {
+ $q = http_build_query($_POST);
+ $q = explode( ini_get('arg_separator.output'), $q);
+ $html .= "\t<form method='post' action='$pagenow'>\n";
+ foreach ( (array) $q as $a ) {
+ $v = substr(strstr($a, '='), 1);
+ $k = substr($a, 0, -(strlen($v)+1));
+ $html .= "\t\t<input type='hidden' name='" . wp_specialchars( urldecode($k), 1 ) . "' value='" . wp_specialchars( urldecode($v), 1 ) . "' />\n";
+ }
+ $html .= "\t\t<input type='hidden' name='_wpnonce' value='" . wp_create_nonce($action) . "' />\n";
+ $html .= "\t\t<div id='message' class='confirm fade'>\n\t\t<p>" . __('Are you sure you want to do this?') . "</p>\n\t\t<p><a href='$adminurl'>" . __('No') . "</a> <input type='submit' value='" . __('Yes') . "' /></p>\n\t\t</div>\n\t</form>\n";
+ } else {
+ $html .= "\t<div id='message' class='confirm fade'>\n\t<p>" . __('Are you sure you want to do this?') . "</p>\n\t<p><a href='$adminurl'>" . __('No') . "</a> <a href='" . add_query_arg( '_wpnonce', wp_create_nonce($action), $_SERVER['REQUEST_URI'] ) . "'>" . __('Yes') . "</a></p>\n\t</div>\n";
+ }
+ $html .= "</body>\n</html>";
+ echo $html;
+ include_once(ABSPATH . '/wp-admin/admin-footer.php');
+ die();
+ }
+ do_action('check_admin_referer', $action);
+}endif;
if ( !function_exists('check_ajax_referer') ) :
function check_ajax_referer() {
- $cookie = explode(';', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie
+ $cookie = explode('; ', urldecode(empty($_POST['cookie']) ? $_GET['cookie'] : $_POST['cookie'])); // AJAX scripts must pass cookie=document.cookie
foreach ( $cookie as $tasty ) {
if ( false !== strpos($tasty, USER_COOKIE) )
$user = substr(strstr($tasty, '='), 1);
@@ -465,4 +491,51 @@ function wp_new_user_notification($user_id, $plaintext_pass = '') {
}
endif;
+if ( !function_exists('wp_verify_nonce') ) :
+function wp_verify_nonce($nonce, $action = -1) {
+ $user = wp_get_current_user();
+ $uid = $user->id;
+
+ $i = ceil(time() / 43200);
+
+ //Allow for expanding range, but only do one check if we can
+ if( substr(wp_hash($i . $action . $uid), -12, 10) == $nonce || substr(wp_hash(($i - 1) . $action . $uid), -12, 10) == $nonce )
+ return true;
+ return false;
+}
+endif;
+
+if ( !function_exists('wp_create_nonce') ) :
+function wp_create_nonce($action = -1) {
+ $user = wp_get_current_user();
+ $uid = $user->id;
+
+ $i = ceil(time() / 43200);
+
+ return substr(wp_hash($i . $action . $uid), -12, 10);
+}
+endif;
+
+if ( !function_exists('wp_salt') ) :
+function wp_salt() {
+ $salt = get_option('secret');
+ if ( empty($salt) )
+ $salt = DB_PASSWORD . DB_USER . DB_NAME . DB_HOST . ABSPATH;
+
+ return $salt;
+}
+endif;
+
+if ( !function_exists('wp_hash') ) :
+function wp_hash($data) {
+ $salt = wp_salt();
+
+ if ( function_exists('hash_hmac') ) {
+ return hash_hmac('md5', $data, $salt);
+ } else {
+ return md5($data . $salt);
+ }
+}
+endif;
+
?>
diff --git a/wp-inst/wp-includes/query.php b/wp-inst/wp-includes/query.php
index aa7069c..510a7ab 100644
--- a/wp-inst/wp-includes/query.php
+++ b/wp-inst/wp-includes/query.php
@@ -157,6 +157,12 @@ function is_preview() {
return $wp_query->is_preview;
}
+function is_robots() {
+ global $wp_query;
+
+ return $wp_query->is_robots;
+}
+
function is_search () {
global $wp_query;
@@ -272,6 +278,7 @@ class WP_Query {
var $is_comments_popup = false;
var $is_admin = false;
var $is_attachment = false;
+ var $is_robots = false;
function init_query_flags() {
$this->is_single = false;
@@ -292,6 +299,7 @@ class WP_Query {
$this->is_paged = false;
$this->is_admin = false;
$this->is_attachment = false;
+ $this->is_robots = false;
}
function init () {
@@ -321,6 +329,11 @@ class WP_Query {
$this->query_vars = $qv;
}
+ if ( ! empty($qv['robots']) ) {
+ $this->is_robots = true;
+ return;
+ }
+
if ('404' == $qv['error']) {
$this->is_404 = true;
if ( !empty($query) ) {
@@ -697,6 +710,7 @@ class WP_Query {
$cat_array = preg_split('/[,\s]+/', $q['cat']);
$in_cats = $out_cats = '';
foreach ( $cat_array as $cat ) {
+ $cat = intval($cat);
$in = strstr($cat, '-') ? false : true;
$cat = trim($cat, '-');
if ( $in )
@@ -828,13 +842,23 @@ class WP_Query {
} else {
$where .= " AND (post_type = '$post_type' AND (post_status = 'publish'";
- if ( is_admin() )
+ if ( is_admin() ) {
$where .= " OR post_status = 'future' OR post_status = 'draft'";
- if ( is_user_logged_in() )
- $where .= " OR post_author = $user_ID AND post_status = 'private'))";
- else
- $where .= '))';
+ if ( is_user_logged_in() ) {
+ if ( 'post' == $post_type )
+ $cap = 'edit_private_posts';
+ else
+ $cap = 'edit_private_pages';
+
+ if ( current_user_can($cap) )
+ $where .= "OR post_status = 'private'";
+ else
+ $where .= " OR post_author = $user_ID AND post_status = 'private'";
+ }
+ }
+
+ $where .= '))';
}
// Apply filters on where and join prior to paging so that any
diff --git a/wp-inst/wp-includes/registration-functions.php b/wp-inst/wp-includes/registration-functions.php
index 59849e3..a0860bd 100644
--- a/wp-inst/wp-includes/registration-functions.php
+++ b/wp-inst/wp-includes/registration-functions.php
@@ -33,6 +33,7 @@ function wp_insert_user($userdata) {
// Are we updating or creating?
if ( !empty($ID) ) {
+ $ID = (int) $ID;
$update = true;
} else {
$update = false;
@@ -41,15 +42,39 @@ function wp_insert_user($userdata) {
}
$user_login = sanitize_user($user_login, true);
+ $user_login = apply_filters('pre_user_login', $user_login);
if ( empty($user_nicename) )
$user_nicename = sanitize_title( $user_login );
+ $user_nicename = apply_filters('pre_user_nicename', $user_nicename);
+
+ if ( empty($user_url) )
+ $user_url = '';
+ $user_url = apply_filters('pre_user_url', $user_url);
+
+ if ( empty($user_email) )
+ $user_email = '';
+ $user_email = apply_filters('pre_user_email', $user_email);
if ( empty($display_name) )
$display_name = $user_login;
+ $display_name = apply_filters('pre_user_display_name', $display_name);
if ( empty($nickname) )
$nickname = $user_login;
+ $nickname = apply_filters('pre_user_nickname', $nickname);
+
+ if ( empty($first_name) )
+ $first_name = '';
+ $first_name = apply_filters('pre_user_first_name', $first_name);
+
+ if ( empty($last_name) )
+ $last_name = '';
+ $last_name = apply_filters('pre_user_last_name', $last_name);
+
+ if ( empty($description) )
+ $description = '';
+ $description = apply_filters('pre_user_description', $description);
if ( empty($user_registered) )
$user_registered = gmdate('Y-m-d H:i:s');
diff --git a/wp-inst/wp-includes/rewrite.php b/wp-inst/wp-includes/rewrite.php
index f46de2a..4a6c631 100644
--- a/wp-inst/wp-includes/rewrite.php
+++ b/wp-inst/wp-includes/rewrite.php
@@ -696,6 +696,9 @@ class WP_Rewrite {
return $rewrite;
}
+ // robots.txt
+ $robots_rewrite = array('robots.txt$' => $this->index . '?robots=1');
+
// Post
$post_rewrite = $this->generate_rewrite_rules($this->permalink_structure, EP_PERMALINK);
$post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
@@ -730,7 +733,7 @@ class WP_Rewrite {
$page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
// Put them together.
- $this->rules = array_merge($page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
+ $this->rules = array_merge($robots_rewrite, $page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite, $this->extra_rules);
do_action('generate_rewrite_rules', array(&$this));
$this->rules = apply_filters('rewrite_rules_array', $this->rules);
diff --git a/wp-inst/wp-includes/script-loader.php b/wp-inst/wp-includes/script-loader.php
index 1d23393..f7be9e0 100644
--- a/wp-inst/wp-includes/script-loader.php
+++ b/wp-inst/wp-includes/script-loader.php
@@ -19,11 +19,11 @@ class WP_Scripts {
$this->add( 'wp_tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('tiny_mce'), '04162006' );
if ( is_admin() ) {
$this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' );
- $this->add( 'listman', '/wp-admin/list-manipulation-js.php', array('sack', 'fat'), '3733' );
+ $this->add( 'listman', '/wp-admin/list-manipulation-js.php', array('sack', 'fat'), '3850' ); // Make changeset # the correct one
$this->add( 'ajaxcat', '/wp-admin/cat-js.php', array('listman'), '3684' );
$this->add( 'admin-categories', '/wp-admin/categories.js', array('listman'), '3684' );
$this->add( 'admin-custom-fields', '/wp-admin/custom-fields.js', array('listman'), '3733' );
- $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3736' );
+ $this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3850' ); // Make changeset # the correct one
$this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '3684' );
$this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' );
}
diff --git a/wp-inst/wp-includes/template-functions-author.php b/wp-inst/wp-includes/template-functions-author.php
index 313bffc..daa1678 100644
--- a/wp-inst/wp-includes/template-functions-author.php
+++ b/wp-inst/wp-includes/template-functions-author.php
@@ -156,26 +156,18 @@ function get_author_link($echo = false, $author_id, $author_nicename) {
}
function wp_list_authors($args = '') {
- parse_str($args, $r);
+ if ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
- if ( !isset($r['optioncount']) )
- $r['optioncount'] = false;
- if ( !isset($r['exclude_admin']) )
- $r['exclude_admin'] = true;
- if ( !isset($r['show_fullname']) )
- $r['show_fullname'] = false;
- if ( !isset($r['hide_empty']) )
- $r['hide_empty'] = true;
- if ( !isset($r['feed']) )
- $r['feed'] = '';
- if ( !isset($r['feed_image']) )
- $r['feed_image'] = '';
+ $defaults = array('optioncount' => false, 'exclude_admin' => true, 'show_fullname' => false, 'hide_empty' => true,
+ 'feed' => '', 'feed_image' => '');
+ $r = array_merge($defaults, $r);
+ extract($r);
- list_authors($r['optioncount'], $r['exclude_admin'], $r['show_fullname'], $r['hide_empty'], $r['feed'], $r['feed_image']);
-}
-
-function list_authors($optioncount = false, $exclude_admin = true, $show_fullname = false, $hide_empty = true, $feed = '', $feed_image = '') {
global $wpdb;
+ // TODO: Move select to get_authors().
$query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name";
$authors = $wpdb->get_results($query);
diff --git a/wp-inst/wp-includes/template-functions-general.php b/wp-inst/wp-includes/template-functions-general.php
index ef74e9b..1830c4d 100644
--- a/wp-inst/wp-includes/template-functions-general.php
+++ b/wp-inst/wp-includes/template-functions-general.php
@@ -505,8 +505,8 @@ function get_calendar($initial = true) {
// Get days with posts
$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
- FROM $wpdb->posts WHERE MONTH(post_date) = $thismonth
- AND YEAR(post_date) = $thisyear
+ FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth'
+ AND YEAR(post_date) = '$thisyear'
AND post_type = 'post' AND post_status = 'publish'
AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
if ( $dayswithposts ) {
diff --git a/wp-inst/wp-includes/template-functions-post.php b/wp-inst/wp-includes/template-functions-post.php
index 461d6e5..40e3b32 100644
--- a/wp-inst/wp-includes/template-functions-post.php
+++ b/wp-inst/wp-includes/template-functions-post.php
@@ -83,7 +83,7 @@ function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_
$content = $pages[$page-1];
$content = explode('<!--more-->', $content, 2);
- if ( (preg_match('/<!--noteaser-->/', $post->post_content) && ((!$multipage) || ($page==1))) )
+ if ( (false !== strpos($post->post_content, '<!--noteaser-->') && ((!$multipage) || ($page==1))) )
$stripteaser = 1;
$teaser = $content[0];
if ( ($more) && ($stripteaser) )
@@ -93,7 +93,7 @@ function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_
if ( $more )
$output .= '<a id="more-'.$id.'"></a>'.$content[1];
else
- $output .= ' <a href="'. get_permalink() . "#more-$id\">$more_link_text</a>";
+ $output = balanceTags($output . ' <a href="'. get_permalink() . "#more-$id\">$more_link_text</a>");
}
if ( $preview ) // preview fix for javascript bug with foreign languages
$output = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $output);
diff --git a/wp-inst/wp-includes/template-loader.php b/wp-inst/wp-includes/template-loader.php
index 3f799e1..8b44d89 100644
--- a/wp-inst/wp-includes/template-loader.php
+++ b/wp-inst/wp-includes/template-loader.php
@@ -1,7 +1,10 @@
<?php
if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
do_action('template_redirect');
- if ( is_feed() ) {
+ if ( is_robots() ) {
+ do_action('do_robots');
+ exit;
+ } else if ( is_feed() ) {
do_feed();
exit;
} else if ( is_trackback() ) {
@@ -55,7 +58,10 @@ if ( defined('WP_USE_THEMES') && constant('WP_USE_THEMES') ) {
}
} else {
// Process feeds and trackbacks even if not using themes.
- if ( is_feed() ) {
+ if ( is_robots() ) {
+ do_action('do_robots');
+ exit;
+ } else if ( is_feed() ) {
do_feed();
exit;
} else if ( is_trackback() ) {
diff --git a/wp-inst/wp-includes/version.php b/wp-inst/wp-includes/version.php
index 0f08c70..9e9a82d 100644
--- a/wp-inst/wp-includes/version.php
+++ b/wp-inst/wp-includes/version.php
@@ -3,6 +3,6 @@
// This just holds the version number, in a separate file so we can bump it without cluttering the SVN
$wp_version = 'wordpress-mu-1.0'; // Let's just avoid confusion
-$wp_db_version = 3673;
+$wp_db_version = 3845;
?>
diff --git a/wp-inst/wp-includes/wpmu-functions.php b/wp-inst/wp-includes/wpmu-functions.php
index 00725fe..9351456 100644
--- a/wp-inst/wp-includes/wpmu-functions.php
+++ b/wp-inst/wp-includes/wpmu-functions.php
@@ -173,14 +173,15 @@ function get_blog_details( $id ) {
if ( $details )
return unserialize( $details );
-
+
$details = $wpdb->get_row( "SELECT * FROM $wpdb->blogs WHERE blog_id = '$id' /* get_blog_details */" );
-
+
if ( !$details )
return false;
- $details->blogname = stripslashes( $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name = 'blogname'" ) );
- $details->siteurl = $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name = 'siteurl'" );
+ $details->blogname = get_blog_option($id, 'blogname');
+ $details->siteurl = get_blog_option($id, 'siteurl');
+
wp_cache_set( $id, serialize( $details ), 'blog-details' );
$key = md5( $details->domain . $details->path );
@@ -192,23 +193,18 @@ function get_blog_details( $id ) {
function refresh_blog_details( $id ) {
global $wpdb, $wpmuBaseTablePrefix;
- if ( defined('WP_INSTALLING') )
- return;
-
- $details = $wpdb->get_row( "SELECT * FROM $wpdb->blogs WHERE blog_id = '$id' /* refresh_blog_details */" );
- $details->blogname = stripslashes( $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name = 'blogname'" ) );
- $details->siteurl = $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name = 'siteurl'" );
+ $details = get_blog_details( $id );
wp_cache_delete( $id , 'blog-details' );
$key = md5( $details->domain . $details->path );
wp_cache_delete( $key , 'blog-lookup' );
- return $details;
+ //return $details;
}
function get_current_user_id() {
global $current_user;
- return $current_user->data->ID;
+ return $current_user->ID;
}
function is_site_admin( $user_login = false ) {
@@ -220,7 +216,7 @@ function is_site_admin( $user_login = false ) {
if ( $user_login )
$user_login = sanitize_user( $user_login );
else
- $user_login = $current_user->data->user_login;
+ $user_login = $current_user->user_login;
$site_admins = get_site_option( 'site_admins', array('admin') );
if( in_array( $user_login, $site_admins ) )
@@ -431,17 +427,16 @@ function get_blogs_of_user( $id ) {
global $wpdb, $wpmuBaseTablePrefix;
$user = get_userdata( $id );
+ $blogs = array();
$i = 0;
foreach ( $user as $key => $value ) {
- $i++;;
-
if ( strstr( $key, '_capabilities') && strstr( $key, 'wp_') ) {
preg_match('/wp_(\d+)_capabilities/', $key, $match);
$blog = get_blog_details( $match[1] );
if ( $blog && isset( $blog->domain ) ) {
- $blogs[$i]->userblog_id = $match[1];
- $blogs[$i]->domain = $blog->domain;
+ $blogs[$match[1]]->userblog_id = $match[1];
+ $blogs[$match[1]]->domain = $blog->domain;
} else { // Temporary fix for people who don't get usermeta cleaned up when a blog is deleted
delete_usermeta( $id, "wp_{$match[1]}_capabilities" );
delete_usermeta( $id, "wp_{$match[1]}_user_level" );
@@ -453,18 +448,11 @@ function get_blogs_of_user( $id ) {
}
function is_archived( $id ) {
- global $wpdb;
- $details = get_blog_details( $id );
- if( $details ) {
- return $details->archived;
- }
- return $wpdb->get_var( "SELECT archived FROM {$wpdb->blogs} WHERE blog_id = '$id'" );
+ return get_blog_status($id, 'archived');
}
function update_archived( $id, $archived ) {
- global $wpdb;
- $wpdb->query( "UPDATE {$wpdb->blogs} SET archived = '{$archived}' WHERE blog_id = '$id'" );
- refresh_blog_details( $id );
+ update_blog_status($id, 'archived', $archived);
return $archived;
}
@@ -472,10 +460,10 @@ function update_archived( $id, $archived ) {
function update_blog_status( $id, $pref, $value ) {
global $wpdb;
- $wpdb->query( "UPDATE {$wpdb->blogs} SET {$pref} = '{$value}' WHERE blog_id = '$id'" );
- $wpdb->query( "UPDATE {$wpdb->blogs} SET last_updated = NOW() WHERE blog_id = '$id'" );
- refresh_blog_details( $id );
+ $wpdb->query( "UPDATE {$wpdb->blogs} SET {$pref} = '{$value}', last_updated = NOW() WHERE blog_id = '$id'" );
+ refresh_blog_details($id);
+
if( $pref == 'spam' ) {
if( $value == 1 ) {
do_action( "make_spam_blog", $id );
@@ -850,67 +838,89 @@ function validate_email( $email, $check_domain = true) {
return false;
}
-function wpmu_validate_signup($blog_id, $blog_title, $user_name, $user_email) {
- global $wpdb, $domain, $base;
+function wpmu_validate_user_signup($user_name, $user_email) {
+ global $wpdb;
$errors = new WP_Error();
- $illegal_names = get_site_option( "illegal_names" );
- if( $illegal_names == false ) {
- $illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator" );
- add_site_option( "illegal_names", $illegal_names );
- }
- // Validate username and email unless a user object was passed in.
- if ( ! is_object($user_name) ) {
- $user_name = sanitize_title($user_name);
+ $user_name = sanitize_title($user_name);
- if ( empty( $user_name ) )
- $errors->add('user_name', __("Please enter a username"));
+ if ( empty( $user_name ) )
+ $errors->add('user_name', __("Please enter a username"));
- preg_match( "/[a-zA-Z0-9]+/", $user_name, $maybe );
+ preg_match( "/[a-zA-Z0-9]+/", $user_name, $maybe );
- if( $blog_id != $maybe[0] ) {
- $errors->add('user_name', __("Only letters and numbers allowed"));
- }
+ if( $user_name != $maybe[0] ) {
+ $errors->add('user_name', __("Only letters and numbers allowed"));
+ }
- if( in_array( $blog_id, $illegal_names ) == true ) {
- $errors->add('user_name', __("That username is not allowed"));
- }
+ $illegal_names = get_site_option( "illegal_names" );
+ if( in_array( $user_name, $illegal_names ) == true ) {
+ $errors->add('user_name', __("That username is not allowed"));
+ }
- if( strlen( $blog_id ) < 4 ) {
- $errors->add('user_name', __("Username must be at least 4 characters"));
- }
+ if( strlen( $user_name ) < 4 ) {
+ $errors->add('user_name', __("Username must be at least 4 characters"));
+ }
- if ( strpos( " " . $user_name, "_" ) != false )
- $errors->add('user_name', __("Sorry, usernames may not contain the character '_'!"));
+ if ( strpos( " " . $user_name, "_" ) != false )
+ $errors->add('user_name', __("Sorry, usernames may not contain the character '_'!"));
- // all numeric?
- preg_match( '/[0-9]*/', $user_name, $match );
- if ( $match[0] == $user_name )
- $errors->add('user_name', __("Sorry, usernames must have letters too!"));
+ // all numeric?
+ preg_match( '/[0-9]*/', $user_name, $match );
+ if ( $match[0] == $user_name )
+ $errors->add('user_name', __("Sorry, usernames must have letters too!"));
- if ( !is_email( $user_email ) )
- $errors->add('user_email', __("Please enter a correct email address"));
+ if ( !is_email( $user_email ) )
+ $errors->add('user_email', __("Please enter a correct email address"));
- if ( !validate_email( $user_email ) )
- $errors->add('user_email', __("Please check your email address."));
+ if ( !validate_email( $user_email ) )
+ $errors->add('user_email', __("Please check your email address."));
- $limited_email_domains = get_site_option( 'limited_email_domains' );
- if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
- $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
- if( in_array( $emaildomain, $limited_email_domains ) == false ) {
- $errors->add('user_email', __("Sorry, that email address is not allowed!"));
- }
+ $limited_email_domains = get_site_option( 'limited_email_domains' );
+ if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
+ $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
+ if( in_array( $emaildomain, $limited_email_domains ) == false ) {
+ $errors->add('user_email', __("Sorry, that email address is not allowed!"));
}
+ }
- // Check if the username has been used already.
- if ( username_exists($user_name) )
- $errors->add('user_name', __("Sorry, that username already exists!"));
+ // Check if the username has been used already.
+ if ( username_exists($user_name) )
+ $errors->add('user_name', __("Sorry, that username already exists!"));
- // Check if the email address has been used already.
- //if ( email_exists($user_email) )
- // $errors->add('user_email', __("Sorry, that email address is already used!"));
+ // Check if the email address has been used already.
+ //if ( email_exists($user_email) )
+ // $errors->add('user_email', __("Sorry, that email address is already used!"));
+ // Has someone already signed up for this username?
+ // TODO: Check email too?
+ $signup = $wpdb->get_row("SELECT * FROM $wpdb->signups WHERE user_login = '$user_name'");
+ if ( ! empty($signup) ) {
+ $registered_at = mysql2date('U', $signup->registered);
+ $now = current_time( 'timestamp', true );
+ $diff = $now - $registered_at;
+ // If registered more than two days ago, cancel registration and let this signup go through.
+ if ( $diff > 172800 ) {
+ $wpdb->query("DELETE FROM $wpdb->signups WHERE user_login = '$user_name'");
+ } else {
+ $errors->add('user_name', __("That username is currently reserved but may be available in a couple days."));
+ }
+ }
+
+ $result = array('user_name' => $user_name, 'user_email' => $user_email, 'errors' => $errors);
+
+ return apply_filters('wpmu_validate_user_signup', $result);
+}
+
+function wpmu_validate_blog_signup($blog_id, $blog_title, $user = '') {
+ global $wpdb, $domain, $base;
+
+ $errors = new WP_Error();
+ $illegal_names = get_site_option( "illegal_names" );
+ if( $illegal_names == false ) {
+ $illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator" );
+ add_site_option( "illegal_names", $illegal_names );
}
$blog_id = sanitize_title($blog_id);
@@ -945,19 +955,18 @@ function wpmu_validate_signup($blog_id, $blog_title, $user_name, $user_email) {
$errors->add('blog_title', __("Please enter a blog title"));
// Check if the domain has been used already.
- if ( constant( 'VHOST' ) == 'yes' ) {
- $mydomain = "$blog_id.$domain";
- $base = '/';
- } else {
- $mydomain = $domain;
- $base = "/$blog_id/";
- }
+ $mydomain = "$blog_id.$domain";
if ( domain_exists($mydomain, $base) )
$errors->add('blog_id', __("Sorry, that blog already exists!"));
+ if ( username_exists($blog_id) ) {
+ if ( !is_object($user) && ( $user->user_login != $blog_id ) )
+ $errors->add('blog_id', __("Sorry, that blog is reserved!"));
+ }
+
// Has someone already signed up for this domain?
// TODO: Check email too?
- $signup = $wpdb->get_row("SELECT * FROM $wpdb->signups WHERE domain = '$mydomain' AND path = '$base'");
+ $signup = $wpdb->get_row("SELECT * FROM $wpdb->signups WHERE domain = '$mydomain'");
if ( ! empty($signup) ) {
$registered_at = mysql2date('U', $signup->registered);
$now = current_time( 'timestamp', true );
@@ -970,15 +979,15 @@ function wpmu_validate_signup($blog_id, $blog_title, $user_name, $user_email) {
}
}
- $result = array('domain' => $mydomain, 'path' => $base, 'blog_id' => $blog_id, 'blog_title' => $blog_title, 'user_name' => $user_name, 'user_email' => $user_email,
+ $result = array('domain' => $mydomain, 'path' => $base, 'blog_id' => $blog_id, 'blog_title' => $blog_title,
'errors' => $errors);
- return apply_filters('wpmu_validate_signup', $result);
+ return apply_filters('wpmu_validate_blog_signup', $result);
}
// Record signup information for future activation. wpmu_validate_signup() should be run
// on the inputs before calling wpmu_signup().
-function wpmu_signup($domain, $path, $title, $user, $user_email, $meta = '') {
+function wpmu_signup_blog($domain, $path, $title, $user, $user_email, $meta = '') {
global $wpdb;
$key = substr( md5( time() . rand() . $domain ), 0, 16 );
@@ -990,11 +999,23 @@ function wpmu_signup($domain, $path, $title, $user, $user_email, $meta = '') {
$wpdb->query( "INSERT INTO $wpdb->signups ( domain, path, title, user_login, user_email, registered, activation_key, meta )
VALUES ( '$domain', '$path', '$title', '$user', '$user_email', '$registered', '$key', '$meta' )" );
- wpmu_signup_notification($domain, $path, $title, $user, $user_email, $key, $meta);
+ wpmu_signup_blog_notification($domain, $path, $title, $user, $user_email, $key, $meta);
+}
+
+function wpmu_signup_user($user, $user_email, $meta = '') {
+ global $wpdb;
+
+ $key = substr( md5( time() . rand() . $user_email ), 0, 16 );
+ $registered = current_time('mysql', true);
+ $meta = serialize($meta);
+ $wpdb->query( "INSERT INTO $wpdb->signups ( domain, path, title, user_login, user_email, registered, activation_key, meta )
+ VALUES ( '', '', '', '$user', '$user_email', '$registered', '$key', '$meta' )" );
+
+ wpmu_signup_user_notification($user, $user_email, $key, $meta);
}
// Notify user of signup success.
-function wpmu_signup_notification($domain, $path, $title, $user, $user_email, $key, $meta = '') {
+function wpmu_signup_blog_notification($domain, $path, $title, $user, $user_email, $key, $meta = '') {
// Send email with activation link.
$message_headers = 'From: ' . stripslashes($title) . ' <support@' . $_SERVER[ 'SERVER_NAME' ] . '>';
$message = sprintf(__("To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your blog here:\n\n%s"),
@@ -1004,7 +1025,17 @@ function wpmu_signup_notification($domain, $path, $title, $user, $user_email, $k
wp_mail($user_email, $subject, $message, $message_headers);
}
-function wpmu_activate_blog($key) {
+function wpmu_signup_user_notification($user, $user_email, $key, $meta = '') {
+ // Send email with activation link.
+ $message_headers = 'From: ' . stripslashes($user) . ' <support@' . $_SERVER[ 'SERVER_NAME' ] . '>';
+ $message = sprintf(__("To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\n"),
+ "http://{$_SERVER[ 'SERVER_NAME' ]}/wp-activate.php?key=$key", "http://{$_SERVER[ 'SERVER_NAME' ]}");
+ // TODO: Don't hard code activation link.
+ $subject = sprintf(__('Activate %s'), $user);
+ wp_mail($user_email, $subject, $message, $message_headers);
+}
+
+function wpmu_activate_signup($key) {
global $wpdb;
$result = array();
@@ -1028,16 +1059,22 @@ function wpmu_activate_blog($key) {
if ( ! $user_id )
return new WP_Error('create_user', __('Could not create user'));
+ $now = current_time('mysql', true);
+
+ if ( empty($signup->domain) ) {
+ $wpdb->query("UPDATE $wpdb->signups SET active = '1', activated = '$now' WHERE activation_key = '$key'");
+ wpmu_welcome_user_notification($user_id, $password, $meta);
+ do_action('wpmu_activate_user', $user_id, $password, $meta);
+ return array('user_id' => $user_id, 'password' => $password, 'meta' => $meta);
+ }
+
$meta = unserialize($signup->meta);
-
$blog_id = wpmu_create_blog($signup->domain, $signup->path, $signup->title, $user_id, $meta);
// TODO: What to do if we create a user but cannot create a blog?
if ( is_wp_error($blog_id) )
return $blog_id;
- //$wpdb->query("DELETE FROM $wpdb->signups WHERE activation_key = '$key'");
- $now = current_time('mysql', true);
$wpdb->query("UPDATE $wpdb->signups SET active = '1', activated = '$now' WHERE activation_key = '$key'");
wpmu_welcome_notification($blog_id, $user_id, $password, $signup->title, $meta);
@@ -1064,11 +1101,12 @@ function wpmu_create_user( $user_name, $password, $email) {
update_user_option($user_id, 'capabilities', '');
update_user_option($user_id, 'user_level', '');
+ do_action( 'wpmu_new_user', $user_id );
+
return $user_id;
}
function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id = 1) {
- global $wp_queries;
$domain = addslashes( $domain );
$title = addslashes( $title );
$user_id = (int) $user_id;
@@ -1125,7 +1163,7 @@ function insert_blog($domain, $path, $site_id) {
// Install an empty blog. wpdb should already be switched.
function install_blog($blog_id, $blog_title = '') {
- global $wpdb, $table_prefix, $wp_queries;
+ global $wpdb, $table_prefix;
$wpdb->hide_errors();
require_once( ABSPATH . 'wp-admin/upgrade-functions.php');
@@ -1137,7 +1175,6 @@ function install_blog($blog_id, $blog_title = '') {
// Set everything up
make_db_current_silent();
- //make_db_current();
populate_options();
// fix url.
@@ -1169,18 +1206,6 @@ function install_blog_defaults($blog_id, $user_id) {
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_owner, link_rss) VALUES ('http://wordpress.com/', 'WordPress.com', 1, '$user_id', 'http://wordpress.com/feed/');");
$wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_owner, link_rss) VALUES ('http://wordpress.org/', 'WordPress.org', 1, '$user_id', 'http://wordpress.org/development/feed/');");
- // Invite
- $invitee_id = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = '{$_POST[ 'u' ]}_invited_by' AND user_id = '0'" );
- if( $invitee_id ) {
- $invitee_user_login = $wpdb->get_row( "SELECT user_login, user_email FROM {$wpdb->users} WHERE ID = '$invitee_id'" );
- $invitee_blog = $wpdb->get_row( "SELECT blog_id, meta_value from {$wpdb->blogs}, {$wpdb->usermeta} WHERE user_id = '$invitee_id' AND meta_key = 'source_domain' AND {$wpdb->usermeta}.meta_value = {$wpdb->blogs}.domain" );
- if( $invitee_blog )
- $invitee_siteurl = $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$invitee_blog->blog_id}_options WHERE option_name = 'siteurl'" );
- }
-
- if( $invitee_siteurl && $invitee_user_login )
- $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_owner, link_rss) VALUES ('{$invitee_siteurl}', '" . ucfirst( $invitee_user_login->user_login ) . "', 1, '$user_id', '');");
-
// First post
$now = date('Y-m-d H:i:s');
$now_gmt = gmdate('Y-m-d H:i:s');
@@ -1249,7 +1274,7 @@ SITE_NAME" ) );
$welcome_email = str_replace( "PASSWORD", $password, $welcome_email );
$welcome_email = apply_filters( "update_welcome_email", $welcome_email, $blog_id, $user_id, $password, $title, $meta);
- $message_headers = 'From: ' . $title . ' <wordpress@' . $_SERVER[ 'SERVER_NAME' ] . '>';
+ $message_headers = 'From: ' . $title . ' <support@' . $_SERVER[ 'SERVER_NAME' ] . '>';
$message = $welcome_email;
if( empty( $current_site->site_name ) )
$current_site->site_name = "WordPress MU";
@@ -1257,4 +1282,35 @@ SITE_NAME" ) );
wp_mail($user->user_email, $subject, $message, $message_headers);
}
+function wpmu_welcome_user_notification($user_id, $password, $meta = '') {
+ global $current_site;
+
+ $welcome_email = __( "Dear User,
+
+Your new account is setup.
+
+You can log in with the following information:
+Username: USERNAME
+Password: PASSWORD
+
+Thanks!
+
+--The WordPress Team
+SITE_NAME" );
+
+ $user = new WP_User($user_id);
+
+ $welcome_email = apply_filters( "update_welcome_user_email", $welcome_email, $user_id, $password, $meta);
+ $welcome_email = str_replace( "SITE_NAME", $current_site->site_name, $welcome_email );
+ $welcome_email = str_replace( "USERNAME", $user->user_login, $welcome_email );
+ $welcome_email = str_replace( "PASSWORD", $password, $welcome_email );
+
+ $message_headers = 'From: ' . $title . ' <support@' . $_SERVER[ 'SERVER_NAME' ] . '>';
+ $message = $welcome_email;
+ if( empty( $current_site->site_name ) )
+ $current_site->site_name = "WordPress MU";
+ $subject = sprintf(__('New %s User: %s'), $current_site->site_name, $user->user_login);
+ wp_mail($user->user_email, $subject, $message, $message_headers);
+}
+
?>
diff --git a/wp-inst/wp-login.php b/wp-inst/wp-login.php
index 4ee8d50..86c5912 100644
--- a/wp-inst/wp-login.php
+++ b/wp-inst/wp-login.php
@@ -4,6 +4,9 @@ require( dirname(__FILE__) . '/wp-config.php' );
$action = $_REQUEST['action'];
$error = '';
+if ( isset($_GET['key']) )
+ $action = 'resetpass';
+
nocache_headers();
header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
@@ -101,14 +104,14 @@ do_action('retreive_password', $user_login); // Misspelled and deprecated.
do_action('retrieve_password', $user_login);
// Generate something random for a password... md5'ing current time with a rand salt
- $key = substr( md5( uniqid( microtime() ) ), 0, 50);
+ $key = substr( md5( uniqid( microtime() ) ), 0, 8);
// now insert the new pass md5'd into the db
$wpdb->query("UPDATE $wpdb->users SET user_activation_key = '$key' WHERE user_login = '$user_login'");
$message = __('Someone has asked to reset the password for the following site and username.') . "\r\n\r\n";
$message .= get_option('siteurl') . "\r\n\r\n";
$message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n";
$message .= __('To reset your password visit the following address, otherwise just ignore this email and nothing will happen.') . "\r\n\r\n";
- $message .= get_settings('siteurl') . "/wp-login.php?action=resetpass&key=$key\r\n";
+ $message .= get_settings('siteurl') . "/wp-login.php?action=rp&key=$key\r\n";
$m = wp_mail($user_email, sprintf(__('[%s] Password Reset'), get_settings('blogname')), $message);
@@ -125,7 +128,7 @@ do_action('retrieve_password', $user_login);
break;
case 'resetpass' :
-
+case 'rp' :
// Generate something random for a password... md5'ing current time with a rand salt
$key = preg_replace('/a-z0-9/i', '', $_GET['key']);
if ( empty($key) )
diff --git a/wp-inst/wp-rss2.php b/wp-inst/wp-rss2.php
index 8f42aca..75c1d59 100644
--- a/wp-inst/wp-rss2.php
+++ b/wp-inst/wp-rss2.php
@@ -51,6 +51,6 @@ $more = 1;
<?php rss_enclosure(); ?>
<?php do_action('rss2_item'); ?>
</item>
- <?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
+ <?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && !is_date()) { break; } } } ?>
</channel>
</rss>
diff --git a/wp-inst/wp-settings.php b/wp-inst/wp-settings.php
index 8a12855..edf5803 100644
--- a/wp-inst/wp-settings.php
+++ b/wp-inst/wp-settings.php
@@ -75,28 +75,26 @@ if ( defined('WP_CACHE') )
define('WPINC', 'wp-includes');
require_once (ABSPATH . WPINC . '/wp-db.php');
-$wpdb->blogs = 'wp_blogs';
-$wpdb->users = 'wp_users';
-$wpdb->usermeta = 'wp_usermeta';
-$wpdb->site = 'wp_site';
-$wpdb->sitemeta = 'wp_sitemeta';
-$wpdb->sitecategories = 'wp_sitecategories';
+$wpdb->blogs = $table_prefix . 'blogs';
+$wpdb->users = $table_prefix . 'users';
+$wpdb->usermeta = $table_prefix . 'usermeta';
+$wpdb->site = $table_prefix . 'site';
+$wpdb->sitemeta = $table_prefix . 'sitemeta';
+$wpdb->sitecategories = $table_prefix . 'sitecategories';
+$wpdb->signups = $table_prefix . 'signups';
require_once ( ABSPATH . 'wpmu-settings.php' );
-
-// Table names
$wpdb->siteid = $site_id;
$wpdb->blogid = $blog_id;
$wpdb->posts = $table_prefix . 'posts';
$wpdb->categories = $table_prefix . 'categories';
$wpdb->post2cat = $table_prefix . 'post2cat';
$wpdb->comments = $table_prefix . 'comments';
-$wpdb->links = $table_prefix . 'links';
$wpdb->link2cat = $table_prefix . 'link2cat';
+$wpdb->links = $table_prefix . 'links';
$wpdb->linkcategories = $table_prefix . 'linkcategories';
$wpdb->options = $table_prefix . 'options';
$wpdb->postmeta = $table_prefix . 'postmeta';
-$wpdb->signups = $table_prefix . 'signups';
$wpdb->prefix = $table_prefix;
if ( defined('CUSTOM_USER_TABLE') )
@@ -111,6 +109,7 @@ $tableusers = $wpdb->users;
$tablecategories = $wpdb->categories;
$tablepost2cat = $wpdb->post2cat;
$tablecomments = $wpdb->comments;
+$tablelink2cat = $wpdb->link2cat;
$tablelinks = $wpdb->links;
$tablelinkcategories = $wpdb->linkcategories;
$tableoptions = $wpdb->options;
@@ -156,19 +155,21 @@ require (ABSPATH . WPINC . '/template-functions-general.php');
require (ABSPATH . WPINC . '/template-functions-links.php');
require (ABSPATH . WPINC . '/template-functions-author.php');
require (ABSPATH . WPINC . '/template-functions-post.php');
-require (ABSPATH . WPINC . '/template-functions-category.php');
+require (ABSPATH . WPINC . '/category.php');
+require (ABSPATH . WPINC . '/category-template.php');
require (ABSPATH . WPINC . '/comment.php');
require (ABSPATH . WPINC . '/comment-template.php');
require (ABSPATH . WPINC . '/rewrite.php');
require (ABSPATH . WPINC . '/feed-functions.php');
-require (ABSPATH . WPINC . '/template-functions-bookmarks.php');
+require (ABSPATH . WPINC . '/bookmark.php');
+require (ABSPATH . WPINC . '/bookmark-template.php');
require (ABSPATH . WPINC . '/kses.php');
require (ABSPATH . WPINC . '/cron.php');
require (ABSPATH . WPINC . '/version.php');
require (ABSPATH . WPINC . '/deprecated.php');
+require (ABSPATH . WPINC . '/script-loader.php');
require_once( ABSPATH . WPINC . '/wpmu-functions.php' );
-require_once( ABSPATH . WPINC . '/registration-functions.php');
if( defined( "WP_INSTALLING" ) == false ) {
$current_site->site_name = get_site_option('site_name');
@@ -194,11 +195,17 @@ if( is_array( $plugins ) ) {
}
$wpdb->show_errors();
-$is_archived = get_settings( "is_archived" );
-if( $is_archived == 'yes' ) {
- update_archived( $wpdb->blogid, 1 );
- die( "This blog has been archived or suspended temporarily. Please check back later." );
-}
+if ( '1' == $current_blog->deleted )
+ graceful_fail('This user has elected to delete their account and the content is no longer available.');
+
+if ( '2' == $current_blog->deleted )
+ graceful_fail("This blog has not been activated yet. If you are having problems activating your blog, please contact <a href='mailto:support@wordpress.com'>support@wordpress.com</a>.");
+
+if( $current_blog->archived == '1' )
+ graceful_fail( 'This blog has been archived or suspended.' );
+
+if( $current_blog->spam == '1' )
+ graceful_fail( 'This blog has been archived or suspended.' );
if (!strstr($_SERVER['PHP_SELF'], 'install.php') && !strstr($_SERVER['PHP_SELF'], 'wp-admin/import')) :
// Used to guarantee unique hash cookies
@@ -276,4 +283,4 @@ register_shutdown_function('shutdown_action_hook');
// Everything is loaded and initialized.
do_action('init');
-?> \ No newline at end of file
+?>
diff --git a/wp-inst/wpmu-settings.php b/wp-inst/wpmu-settings.php
index 5d82676..f0eeeae 100644
--- a/wp-inst/wpmu-settings.php
+++ b/wp-inst/wpmu-settings.php
@@ -1,5 +1,4 @@
<?php
-
if( defined( 'ABSPATH' ) == false )
die();
@@ -103,4 +102,4 @@ function is_installed() {
$table_prefix = $table_prefix . $blog_id . '_';
-?> \ No newline at end of file
+?>
diff --git a/wp-inst/xmlrpc.php b/wp-inst/xmlrpc.php
index aa1c520..0b7e1a4 100644
--- a/wp-inst/xmlrpc.php
+++ b/wp-inst/xmlrpc.php
@@ -242,7 +242,7 @@ class wp_xmlrpc_server extends IXR_Server {
$user_data = get_userdatabylogin($user_login);
$post_data = wp_get_single_post($post_ID, ARRAY_A);
- $categories = implode(',', wp_get_post_cats(1, $post_ID));
+ $categories = implode(',', wp_get_post_categories($post_ID));
$content = '<title>'.stripslashes($post_data['post_title']).'</title>';
$content .= '<category>'.$categories.'</category>';
@@ -285,7 +285,7 @@ class wp_xmlrpc_server extends IXR_Server {
foreach ($posts_list as $entry) {
$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
- $categories = implode(',', wp_get_post_cats(1, $entry['ID']));
+ $categories = implode(',', wp_get_post_categories($entry['ID']));
$content = '<title>'.stripslashes($entry['post_title']).'</title>';
$content .= '<category>'.$categories.'</category>';
@@ -695,7 +695,7 @@ class wp_xmlrpc_server extends IXR_Server {
$post_date = mysql2date('Ymd\TH:i:s', $postdata['post_date']);
$categories = array();
- $catids = wp_get_post_cats('', $post_ID);
+ $catids = wp_get_post_categories($post_ID);
foreach($catids as $catid) {
$categories[] = get_cat_name($catid);
}
@@ -755,7 +755,7 @@ class wp_xmlrpc_server extends IXR_Server {
$post_date = mysql2date('Ymd\TH:i:s', $entry['post_date']);
$categories = array();
- $catids = wp_get_post_cats('', $entry['ID']);
+ $catids = wp_get_post_categories($entry['ID']);
foreach($catids as $catid) {
$categories[] = get_cat_name($catid);
}
@@ -958,7 +958,7 @@ class wp_xmlrpc_server extends IXR_Server {
}
$categories = array();
- $catids = wp_get_post_cats('', intval($post_ID));
+ $catids = wp_get_post_categories(intval($post_ID));
// first listed category will be the primary category
$isPrimary = true;
foreach($catids as $catid) {
@@ -996,7 +996,7 @@ class wp_xmlrpc_server extends IXR_Server {
$catids[] = $cat['categoryId'];
}
- wp_set_post_cats('', $post_ID, $catids);
+ wp_set_post_categories($post_ID, $catids);
return true;
}
@@ -1079,7 +1079,7 @@ class wp_xmlrpc_server extends IXR_Server {
$postdata['post_status'] = 'publish';
// retain old cats
- $cats = wp_get_post_cats('',$post_ID);
+ $cats = wp_get_post_categories($post_ID);
$postdata['post_category'] = $cats;
$this->escape($postdata);