summaryrefslogtreecommitdiffstats
path: root/wp-includes
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-11-24 16:16:44 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-11-24 16:16:44 +0000
commit600b71019494e1c29898a620e58c0d2602f37b74 (patch)
tree21181d77ad4ebbcd42cd883e509c08a568d29514 /wp-includes
parent7935d0bd9ef23d32ae29a95bd6c3ea0b6eab2973 (diff)
downloadwordpress-mu-600b71019494e1c29898a620e58c0d2602f37b74.tar.gz
wordpress-mu-600b71019494e1c29898a620e58c0d2602f37b74.tar.xz
wordpress-mu-600b71019494e1c29898a620e58c0d2602f37b74.zip
WP Merge to 4524
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@810 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes')
-rw-r--r--wp-includes/author-template.php2
-rw-r--r--wp-includes/bookmark-template.php12
-rw-r--r--wp-includes/bookmark.php16
-rw-r--r--wp-includes/cache.php10
-rw-r--r--wp-includes/capabilities.php43
-rw-r--r--wp-includes/category-template.php8
-rw-r--r--wp-includes/category.php31
-rw-r--r--wp-includes/classes.php115
-rw-r--r--wp-includes/comment-template.php45
-rw-r--r--wp-includes/comment.php42
-rw-r--r--wp-includes/compat.php66
-rw-r--r--wp-includes/deprecated.php142
-rw-r--r--wp-includes/feed.php4
-rw-r--r--wp-includes/formatting.php165
-rw-r--r--wp-includes/functions.php60
-rw-r--r--wp-includes/general-template.php71
-rw-r--r--wp-includes/js/autosave.js.php12
-rw-r--r--wp-includes/js/list-manipulation-js.php18
-rw-r--r--wp-includes/js/tinymce/license.txt255
-rw-r--r--wp-includes/js/tinymce/plugins/autosave/editor_plugin.js8
-rw-r--r--wp-includes/js/tinymce/plugins/directionality/editor_plugin.js8
-rw-r--r--wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js10
-rw-r--r--wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js4
-rw-r--r--wp-includes/js/tinymce/plugins/paste/editor_plugin.js387
-rw-r--r--wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js4
-rw-r--r--wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js6
-rw-r--r--wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js2
-rw-r--r--wp-includes/js/tinymce/themes/advanced/charmap.htm2
-rw-r--r--wp-includes/js/tinymce/themes/advanced/color_picker.htm2
-rw-r--r--wp-includes/js/tinymce/themes/advanced/css/editor_content.css5
-rw-r--r--wp-includes/js/tinymce/themes/advanced/css/editor_popup.css4
-rw-r--r--wp-includes/js/tinymce/themes/advanced/css/editor_ui.css423
-rw-r--r--wp-includes/js/tinymce/themes/advanced/editor_template.js211
-rw-r--r--wp-includes/js/tinymce/themes/advanced/editor_template_src.js0
-rw-r--r--wp-includes/js/tinymce/themes/advanced/images/backcolor.gifbin174 -> 359 bytes
-rw-r--r--wp-includes/js/tinymce/themes/advanced/images/buttons.gifbin8399 -> 5662 bytes
-rw-r--r--wp-includes/js/tinymce/themes/advanced/images/forecolor.gifbin272 -> 342 bytes
-rw-r--r--wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js30
-rw-r--r--wp-includes/js/tinymce/themes/advanced/langs/en.js8
-rw-r--r--wp-includes/js/tinymce/tiny_mce.js2093
-rw-r--r--wp-includes/js/tinymce/tiny_mce_popup.js446
-rw-r--r--wp-includes/js/tinymce/utils/form_utils.js29
-rw-r--r--wp-includes/js/tinymce/utils/mclayer.js6
-rw-r--r--wp-includes/js/tinymce/utils/mctabs.js4
-rw-r--r--wp-includes/js/tinymce/utils/validate.js235
-rw-r--r--wp-includes/js/wp-ajax-js.php5
-rw-r--r--wp-includes/l10n.php2
-rw-r--r--wp-includes/link-template.php72
-rw-r--r--wp-includes/pluggable.php23
-rw-r--r--wp-includes/post.php160
-rw-r--r--wp-includes/query.php87
-rw-r--r--wp-includes/registration.php4
-rw-r--r--wp-includes/rewrite.php72
-rw-r--r--wp-includes/script-loader.php21
-rw-r--r--wp-includes/theme.php149
-rw-r--r--wp-includes/user.php2
-rw-r--r--wp-includes/wp-db.php2
-rw-r--r--wp-includes/wpmu-functions.php15
58 files changed, 3449 insertions, 2209 deletions
diff --git a/wp-includes/author-template.php b/wp-includes/author-template.php
index a98bc63..c76d44f 100644
--- a/wp-includes/author-template.php
+++ b/wp-includes/author-template.php
@@ -188,7 +188,7 @@ function wp_list_authors($args = '') {
$query = "SELECT ID, user_nicename from $wpdb->users " . ($exclude_admin ? "WHERE user_login <> 'admin' " : '') . "ORDER BY display_name";
$authors = $wpdb->get_results($query);
- foreach ( $authors as $author ) {
+ foreach ( (array) $authors as $author ) {
$author = get_userdata( $author->ID );
$posts = get_usernumposts($author->ID);
$name = $author->nickname;
diff --git a/wp-includes/bookmark-template.php b/wp-includes/bookmark-template.php
index 990aae1..93a4cf4 100644
--- a/wp-includes/bookmark-template.php
+++ b/wp-includes/bookmark-template.php
@@ -146,7 +146,7 @@ function get_links($category = -1,
}
function get_linkrating($link) {
- return apply_filters('link_rating', $link->link_rating);
+ return apply_filters('link_rating', $link->link_rating);
}
/** function get_linkcatname()
@@ -336,18 +336,20 @@ function wp_list_bookmarks($args = '') {
$bookmarks = get_bookmarks("limit=$limit&category={$cat->cat_ID}&show_updated=$show_updated&orderby=$orderby&order=$order&hide_invisible=$hide_invisible&show_updated=$show_updated");
if ( empty($bookmarks) )
continue;
- $output .= "<li id='linkcat-$cat->cat_ID' class='$class'>$title_before$cat->cat_name$title_after\n\t<ul>\n";
+ $output .= str_replace(array('%id', '%class'), array("linkcat-$cat->cat_ID", $class), $category_before);
+ $output .= "$title_before$cat->cat_name$title_after\n\t<ul>\n";
$output .= _walk_bookmarks($bookmarks, $r);
- $output .= "\n\t</ul>\n</li>\n";
+ $output .= "\n\t</ul>\n$category_after\n";
}
} else {
//output one single list using title_li for the title
$bookmarks = get_bookmarks("limit=$limit&category=$category&show_updated=$show_updated&orderby=$orderby&order=$order&hide_invisible=$hide_invisible&show_updated=$show_updated");
if ( !empty($bookmarks) ) {
- $output .= "<li id='linkuncat' class='$class'>$title_before$title_li$title_after\n\t<ul>\n";
+ $output .= str_replace(array('%id', '%class'), array("linkuncat", $class), $category_before);
+ $output .= "$title_before$title_li$title_after\n\t<ul>\n";
$output .= _walk_bookmarks($bookmarks, $r);
- $output .= "\n\t</ul>\n</li>\n";
+ $output .= "\n\t</ul>\n$category_after\n";
}
}
diff --git a/wp-includes/bookmark.php b/wp-includes/bookmark.php
index 306a33f..2824a89 100644
--- a/wp-includes/bookmark.php
+++ b/wp-includes/bookmark.php
@@ -35,6 +35,11 @@ function get_bookmarks($args = '') {
$r = array_merge($defaults, $r);
extract($r);
+ $key = md5( serialize( $r ) );
+ if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) )
+ if ( isset( $cache[ $key ] ) )
+ return apply_filters('get_bookmarks', $cache[ $key ], $r );
+
$inclusions = '';
if ( !empty($include) ) {
$exclude = ''; //ignore exclude, category, and category_name params if using include
@@ -128,7 +133,18 @@ function get_bookmarks($args = '') {
$query .= " LIMIT $limit";
$results = $wpdb->get_results($query);
+
+ $cache[ $key ] = $results;
+ wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
+
return apply_filters('get_bookmarks', $results, $r);
}
+function delete_get_bookmark_cache() {
+ wp_cache_delete( 'get_bookmarks', 'bookmark' );
+}
+add_action( 'add_link', 'delete_get_bookmark_cache' );
+add_action( 'edit_link', 'delete_get_bookmark_cache' );
+add_action( 'delete_link', 'delete_get_bookmark_cache' );
+
?>
diff --git a/wp-includes/cache.php b/wp-includes/cache.php
index 3a48521..6880624 100644
--- a/wp-includes/cache.php
+++ b/wp-includes/cache.php
@@ -30,9 +30,7 @@ function wp_cache_get($id, $flag = '') {
}
function wp_cache_init() {
- global $wp_object_cache;
-
- $wp_object_cache = new WP_Object_Cache();
+ $GLOBALS['wp_object_cache'] =& new WP_Object_Cache();
}
function wp_cache_replace($key, $data, $flag = '', $expire = 0) {
@@ -67,7 +65,7 @@ class WP_Object_Cache {
var $secret = '';
function acquire_lock() {
- // Acquire a write lock.
+ // Acquire a write lock.
$this->mutex = @fopen($this->cache_dir.$this->flock_filename, 'w');
if ( false == $this->mutex)
return false;
@@ -260,11 +258,11 @@ class WP_Object_Cache {
while ($index < count($stack)) {
# Get indexed directory from stack
$dir = $stack[$index];
-
+
$dh = @ opendir($dir);
if (!$dh)
return false;
-
+
while (($file = @ readdir($dh)) !== false) {
if ($file == '.' or $file == '..')
continue;
diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php
index adc1827..273dccc 100644
--- a/wp-includes/capabilities.php
+++ b/wp-includes/capabilities.php
@@ -130,7 +130,8 @@ class WP_Role {
class WP_User {
var $data;
- var $id = 0;
+ var $ID = 0;
+ var $id = 0; // Deprecated, use $ID instead.
var $caps = array();
var $cap_key;
var $roles = array();
@@ -193,7 +194,7 @@ class WP_User {
function add_role($role) {
$this->caps[$role] = true;
- update_usermeta($this->id, $this->cap_key, $this->caps);
+ update_usermeta($this->ID, $this->cap_key, $this->caps);
$this->get_role_caps();
$this->update_user_level_from_caps();
}
@@ -202,7 +203,7 @@ class WP_User {
if ( empty($this->roles[$role]) || (count($this->roles) <= 1) )
return;
unset($this->caps[$role]);
- update_usermeta($this->id, $this->cap_key, $this->caps);
+ update_usermeta($this->ID, $this->cap_key, $this->caps);
$this->get_role_caps();
}
@@ -215,42 +216,42 @@ class WP_User {
} else {
$this->roles = false;
}
- update_usermeta($this->id, $this->cap_key, $this->caps);
+ update_usermeta($this->ID, $this->cap_key, $this->caps);
$this->get_role_caps();
$this->update_user_level_from_caps();
}
function level_reduction($max, $item) {
- if(preg_match('/^level_(10|[0-9])$/i', $item, $matches)) {
- $level = intval($matches[1]);
- return max($max, $level);
- } else {
- return $max;
- }
+ if(preg_match('/^level_(10|[0-9])$/i', $item, $matches)) {
+ $level = intval($matches[1]);
+ return max($max, $level);
+ } else {
+ return $max;
+ }
}
function update_user_level_from_caps() {
- global $wpdb;
- $this->user_level = array_reduce(array_keys($this->allcaps), array(&$this, 'level_reduction'), 0);
- update_usermeta($this->id, $wpdb->prefix.'user_level', $this->user_level);
+ global $wpdb;
+ $this->user_level = array_reduce(array_keys($this->allcaps), array(&$this, 'level_reduction'), 0);
+ update_usermeta($this->ID, $wpdb->prefix.'user_level', $this->user_level);
}
function add_cap($cap, $grant = true) {
$this->caps[$cap] = $grant;
- update_usermeta($this->id, $this->cap_key, $this->caps);
+ update_usermeta($this->ID, $this->cap_key, $this->caps);
}
function remove_cap($cap) {
if ( empty($this->caps[$cap]) ) return;
unset($this->caps[$cap]);
- update_usermeta($this->id, $this->cap_key, $this->caps);
+ update_usermeta($this->ID, $this->cap_key, $this->caps);
}
function remove_all_caps() {
global $wpdb;
$this->caps = array();
- update_usermeta($this->id, $this->cap_key, '');
- update_usermeta($this->id, $wpdb->prefix.'user_level', '');
+ update_usermeta($this->ID, $this->cap_key, '');
+ update_usermeta($this->ID, $wpdb->prefix.'user_level', '');
$this->get_role_caps();
}
@@ -261,7 +262,7 @@ class WP_User {
$cap = $this->translate_level_to_cap($cap);
$args = array_slice(func_get_args(), 1);
- $args = array_merge(array($cap, $this->id), $args);
+ $args = array_merge(array($cap, $this->ID), $args);
$caps = call_user_func_array('map_meta_cap', $args);
// Must have ALL requested caps
$capabilities = apply_filters('user_has_cap', $this->allcaps, $caps, $args);
@@ -298,7 +299,7 @@ function map_meta_cap($cap, $user_id) {
$post = get_post($args[0]);
if ( 'page' == $post->post_type ) {
$args = array_merge(array('delete_page', $user_id), $args);
- return call_user_func_array('map_meta_cap', $args);
+ return call_user_func_array('map_meta_cap', $args);
}
$post_author_data = get_userdata($post->post_author);
//echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>";
@@ -352,7 +353,7 @@ function map_meta_cap($cap, $user_id) {
$post = get_post($args[0]);
if ( 'page' == $post->post_type ) {
$args = array_merge(array('edit_page', $user_id), $args);
- return call_user_func_array('map_meta_cap', $args);
+ return call_user_func_array('map_meta_cap', $args);
}
$post_author_data = get_userdata($post->post_author);
//echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>";
@@ -402,7 +403,7 @@ function map_meta_cap($cap, $user_id) {
$post = get_post($args[0]);
if ( 'page' == $post->post_type ) {
$args = array_merge(array('read_page', $user_id), $args);
- return call_user_func_array('map_meta_cap', $args);
+ return call_user_func_array('map_meta_cap', $args);
}
if ( 'private' != $post->post_status ) {
diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php
index c15a4f8..3c7d10e 100644
--- a/wp-includes/category-template.php
+++ b/wp-includes/category-template.php
@@ -187,8 +187,8 @@ function wp_dropdown_categories($args = '') {
$output .= "\t<option value='0'>$show_option_all</option>\n";
}
- if ( $show_option_none) {
- $show_option_none = apply_filters('list_cats', $show_option_none);
+ if ( $show_option_none) {
+ $show_option_none = apply_filters('list_cats', $show_option_none);
$output .= "\t<option value='-1'>$show_option_none</option>\n";
}
@@ -226,7 +226,7 @@ function wp_list_categories($args = '') {
extract($r);
$categories = get_categories($r);
-
+
$output = '';
if ( $title_li && 'list' == $style )
$output = '<li class="categories">' . $r['title_li'] . '<ul>';
@@ -249,7 +249,7 @@ function wp_list_categories($args = '') {
if ( $title_li && 'list' == $style )
$output .= '</ul></li>';
-
+
echo apply_filters('list_cats', $output);
}
diff --git a/wp-includes/category.php b/wp-includes/category.php
index 1d3f6e4..7b3e7ca 100644
--- a/wp-includes/category.php
+++ b/wp-includes/category.php
@@ -30,6 +30,11 @@ function &get_categories($args = '') {
$r['number'] = (int) $r['number'];
extract($r);
+ $key = md5( serialize( $r ) );
+ if ( $cache = wp_cache_get( 'get_categories', 'category' ) )
+ if ( isset( $cache[ $key ] ) )
+ return $cache[ $key ];
+
$where = 'cat_ID > 0';
$inclusions = '';
if ( !empty($include) ) {
@@ -119,9 +124,20 @@ function &get_categories($args = '') {
}
reset ( $categories );
+ $cache[ $key ] = $categories;
+ wp_cache_set( 'get_categories', $cache, 'category' );
+
return apply_filters('get_categories', $categories, $r);
}
+function delete_get_categories_cache() {
+ wp_cache_delete('get_categories', 'category');
+}
+add_action( 'wp_insert_post', 'delete_get_categories_cache' );
+add_action( 'edit_category', 'delete_get_categories_cache' );
+add_action( 'add_category', 'delete_get_categories_cache' );
+add_action( 'delete_category', 'delete_get_categories_cache' );
+
// Retrieves category data given a category ID or category object.
// Handles category caching.
function &get_category(&$category, $output = OBJECT) {
@@ -232,19 +248,4 @@ function &_get_cat_children($category_id, $categories) {
return $category_list;
}
-function cat_is_ancestor_of($cat1, $cat2) {
- if ( is_int($cat1) )
- $cat1 = & get_category($cat1);
- if ( is_int($cat2) )
- $cat2 = & get_category($cat2);
-
- if ( !$cat1->cat_ID || !$cat2->category_parent )
- return false;
-
- if ( $cat2->category_parent == $cat1->cat_ID )
- return true;
-
- return cat_is_ancestor_of($cat1, get_category($cat2->parent_category));
-}
-
?>
diff --git a/wp-includes/classes.php b/wp-includes/classes.php
index aa19f3c..966e42e 100644
--- a/wp-includes/classes.php
+++ b/wp-includes/classes.php
@@ -1,7 +1,7 @@
<?php
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', 'robots');
+ var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', '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('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type');
var $extra_query_vars = array();
@@ -12,7 +12,7 @@ class WP {
var $matched_rule;
var $matched_query;
var $did_permalink = false;
-
+
function add_query_var($qv) {
$this->public_query_vars[] = $qv;
}
@@ -96,7 +96,7 @@ class WP {
preg_match("!^$match!", urldecode($request_match), $matches)) {
// Got a match.
$this->matched_rule = $match;
-
+
// Trim the query of everything up to the '?'.
$query = preg_replace("!^.+\?!", '', $query);
@@ -178,16 +178,26 @@ class WP {
@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
} else {
// We're showing a feed, so WP is indeed the only thing that last changed
- if ( $this->query_vars['withcomments'] )
+ if ( $this->query_vars['withcomments']
+ || ( !$this->query_vars['withoutcomments']
+ && ( $this->query_vars['p']
+ || $this->query_vars['name']
+ || $this->query_vars['page_id']
+ || $this->query_vars['pagename']
+ || $this->query_vars['attachment']
+ || $this->query_vars['attachment_id']
+ )
+ )
+ )
$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0).' GMT';
- else
+ else
$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
$wp_etag = '"' . md5($wp_last_modified) . '"';
@header("Last-Modified: $wp_last_modified");
@header("ETag: $wp_etag");
// Support for Conditional GET
- if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
+ if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
$client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
else $client_etag = false;
@@ -249,8 +259,9 @@ class WP {
}
function query_posts() {
+ global $wp_the_query;
$this->build_query_string();
- query_posts($this->query_vars);
+ $wp_the_query->query($this->query_vars);
}
function handle_404() {
@@ -310,7 +321,7 @@ class WP_Error {
if ( empty($codes) )
return '';
- return $codes[0];
+ return $codes[0];
}
function get_error_messages($code = '') {
@@ -326,7 +337,7 @@ class WP_Error {
if ( isset($this->errors[$code]) )
return $this->errors[$code];
else
- return array();
+ return array();
}
function get_error_message($code = '') {
@@ -370,29 +381,29 @@ function is_wp_error($thing) {
// A class for displaying various tree-like structures. Extend the Walker class to use it, see examples at the bottom
-class Walker {
+class Walker {
var $tree_type;
var $db_fields;
-
+
//abstract callbacks
function start_lvl($output) { return $output; }
function end_lvl($output) { return $output; }
function start_el($output) { return $output; }
function end_el($output) { return $output; }
-
+
function walk($elements, $to_depth) {
$args = array_slice(func_get_args(), 2); $parents = array(); $depth = 1; $previous_element = ''; $output = '';
-
+
//padding at the end
$last_element->post_parent = 0;
$last_element->post_id = 0;
$elements[] = $last_element;
-
+
$id_field = $this->db_fields['id'];
$parent_field = $this->db_fields['parent'];
-
+
$flat = ($to_depth == -1) ? true : false;
-
+
foreach ( $elements as $element ) {
// If flat, start and end the element and skip the level checks.
if ( $flat) {
@@ -432,7 +443,7 @@ class Walker {
$cb_args = array_merge( array($output, $previous_element, $depth - 1), $args);
$output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
}
-
+
while ( $parent = array_shift($parents) ) {
$depth--;
if ( !$to_depth || ($depth < $to_depth) ) {
@@ -452,7 +463,7 @@ class Walker {
$output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
}
}
-
+
// Start the element.
if ( !$to_depth || ($depth <= $to_depth) ) {
if ( $element->$id_field != 0 ) {
@@ -460,10 +471,10 @@ class Walker {
$output = call_user_func_array(array(&$this, 'start_el'), $cb_args);
}
}
-
+
$previous_element = $element;
}
-
+
return $output;
}
}
@@ -471,19 +482,19 @@ class Walker {
class Walker_Page extends Walker {
var $tree_type = 'page';
var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
-
+
function start_lvl($output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "$indent<ul>\n";
return $output;
}
-
+
function end_lvl($output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
return $output;
}
-
+
function start_el($output, $page, $depth, $current_page, $show_date, $date_format) {
if ( $depth )
$indent = str_repeat("\t", $depth);
@@ -519,45 +530,45 @@ class Walker_PageDropdown extends Walker {
var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
function start_el($output, $page, $depth, $args) {
- $pad = str_repeat('&nbsp;', $depth * 3);
+ $pad = str_repeat('&nbsp;', $depth * 3);
- $output .= "\t<option value=\"$page->ID\"";
- if ( $page->ID == $args['selected'] )
- $output .= ' selected="selected"';
- $output .= '>';
- $title = wp_specialchars($page->post_title);
- $output .= "$pad$title";
- $output .= "</option>\n";
+ $output .= "\t<option value=\"$page->ID\"";
+ if ( $page->ID == $args['selected'] )
+ $output .= ' selected="selected"';
+ $output .= '>';
+ $title = wp_specialchars($page->post_title);
+ $output .= "$pad$title";
+ $output .= "</option>\n";
- return $output;
+ return $output;
}
}
class Walker_Category extends Walker {
var $tree_type = 'category';
var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this
-
+
function start_lvl($output, $depth, $args) {
if ( 'list' != $args['style'] )
return $output;
-
+
$indent = str_repeat("\t", $depth);
$output .= "$indent<ul class='children'>\n";
return $output;
}
-
+
function end_lvl($output, $depth, $args) {
if ( 'list' != $args['style'] )
return $output;
-
+
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
return $output;
}
-
+
function start_el($output, $category, $depth, $args) {
extract($args);
-
+
$link = '<a href="' . get_category_link($category->cat_ID) . '" ';
if ( $use_desc_for_title == 0 || empty($category->category_description) )
$link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name, 1)) . '"';
@@ -565,24 +576,24 @@ class Walker_Category extends Walker {
$link .= 'title="' . wp_specialchars(apply_filters('category_description',$category->category_description,$category),1) . '"';
$link .= '>';
$link .= apply_filters('list_cats', $category->cat_name, $category).'</a>';
-
+
if ( (! empty($feed_image)) || (! empty($feed)) ) {
$link .= ' ';
-
+
if ( empty($feed_image) )
$link .= '(';
-
+
$link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
-
+
if ( !empty($feed) ) {
$title = ' title="' . $feed . '"';
$alt = ' alt="' . $feed . '"';
$name = $feed;
$link .= $title;
}
-
+
$link .= '>';
-
+
if ( !empty($feed_image) )
$link .= "<img src='$feed_image' $alt$title" . ' />';
else
@@ -607,14 +618,14 @@ class Walker_Category extends Walker {
} else {
$output .= "\t$link<br />\n";
}
-
+
return $output;
}
-
+
function end_el($output, $page, $depth, $args) {
if ( 'list' != $args['style'] )
return $output;
-
+
$output .= "</li>\n";
return $output;
}
@@ -624,10 +635,10 @@ class Walker_Category extends Walker {
class Walker_CategoryDropdown extends Walker {
var $tree_type = 'category';
var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this
-
- function start_el($output, $category, $depth, $args) {
+
+ function start_el($output, $category, $depth, $args) {
$pad = str_repeat('&nbsp;', $depth * 3);
-
+
$cat_name = apply_filters('list_cats', $category->cat_name, $category);
$output .= "\t<option value=\"".$category->cat_ID."\"";
if ( $category->cat_ID == $args['selected'] )
@@ -641,7 +652,7 @@ class Walker_CategoryDropdown extends Walker {
$output .= '&nbsp;&nbsp;' . gmdate($format, $category->last_update_timestamp);
}
$output .= "</option>\n";
-
+
return $output;
}
}
@@ -688,7 +699,7 @@ class WP_Ajax_Response {
$action = $_POST['action'];
$x = '';
- $x .= "<response action='$action_$id'>"; // The action attribute in the xml output is formatted like a nonce action
+ $x .= "<response action='{$action}_$id'>"; // The action attribute in the xml output is formatted like a nonce action
$x .= "<$what id='$id'" . ( false !== $old_id ? "old_id='$old_id'>" : '>' );
$x .= $response;
$x .= $s;
diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php
index 8e8d457..3fee66a 100644
--- a/wp-includes/comment-template.php
+++ b/wp-includes/comment-template.php
@@ -93,7 +93,7 @@ function get_comment_date( $d = '' ) {
$date = mysql2date( get_option('date_format'), $comment->comment_date);
else
$date = mysql2date($d, $comment->comment_date);
- return apply_filters('get_comment_date', $date);
+ return apply_filters('get_comment_date', $date, $d);
}
function comment_date( $d = '' ) {
@@ -142,7 +142,7 @@ function get_comments_link() {
}
function comments_link( $file = '', $echo = true ) {
- echo get_comments_link();
+ echo get_comments_link();
}
function get_comments_number( $post_id = 0 ) {
@@ -161,17 +161,18 @@ function get_comments_number( $post_id = 0 ) {
return apply_filters('get_comments_number', $count);
}
-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 comments_number( $zero = false, $one = false, $more = false, $number = '' ) {
+ global $id;
+ $number = get_comments_number($id);
+
+ if ( $number > 1 )
+ $output = str_replace('%', $number, ( false === $more ) ? __('% Comments') : $more);
+ elseif ( $number == 0 )
+ $output = ( false === $zero ) ? __('No Comments') : $zero;
+ else // must be one
+ $output = ( false === $one ) ? __('1 Comment') : $one;
+
+ echo apply_filters('comments_number', $output, $number);
}
function get_comment_text() {
@@ -190,7 +191,7 @@ function get_comment_time( $d = '', $gmt = false ) {
$date = mysql2date(get_option('time_format'), $comment_date);
else
$date = mysql2date($d, $comment_date);
- return apply_filters('get_comment_time', $date);
+ return apply_filters('get_comment_time', $date, $d, $gmt);
}
function comment_time( $d = '' ) {
@@ -239,9 +240,9 @@ function trackback_url( $display = true ) {
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/">
+ 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";
@@ -264,7 +265,7 @@ function comments_open() {
function pings_open() {
global $post;
- if ( 'open' == $post->ping_status )
+ if ( 'open' == $post->ping_status )
return true;
else
return false;
@@ -298,7 +299,7 @@ function comments_template( $file = '/comments.php' ) {
}
function comments_popup_script($width=400, $height=400, $file='') {
- global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript;
+ global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript;
if (empty ($file)) {
$wpcommentspopupfile = ''; // Use the index.
@@ -306,9 +307,9 @@ function comments_popup_script($width=400, $height=400, $file='') {
$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;
+ $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') {
diff --git a/wp-includes/comment.php b/wp-includes/comment.php
index 5d991e2..557c46b 100644
--- a/wp-includes/comment.php
+++ b/wp-includes/comment.php
@@ -18,11 +18,11 @@ function check_comment($author, $email, $url, $comment, $user_ip, $user_agent, $
// Skip empty lines
if (empty($word)) { continue; }
- // Do some escaping magic so that '#' chars in the
+ // Do some escaping magic so that '#' chars in the
// spam words don't break things:
$word = preg_quote($word, '#');
- $pattern = "#$word#i";
+ $pattern = "#$word#i";
if ( preg_match($pattern, $author) ) return false;
if ( preg_match($pattern, $email) ) return false;
if ( preg_match($pattern, $url) ) return false;
@@ -103,9 +103,9 @@ function get_commentdata( $comment_ID, $no_cache = 0, $include_unapproved = fals
if ($no_cache) {
$query = "SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment_ID'";
if (false == $include_unapproved) {
- $query .= " AND comment_approved = '1'";
+ $query .= " AND comment_approved = '1'";
}
- $myrow = $wpdb->get_row($query, ARRAY_A);
+ $myrow = $wpdb->get_row($query, ARRAY_A);
} else {
$myrow['comment_ID'] = $postc->comment_ID;
$myrow['comment_post_ID'] = $postc->comment_post_ID;
@@ -157,7 +157,7 @@ function sanitize_comment_cookies() {
if ( isset($_COOKIE['comment_author_email_'.COOKIEHASH]) ) {
$comment_author_email = apply_filters('pre_comment_author_email', $_COOKIE['comment_author_email_'.COOKIEHASH]);
$comment_author_email = stripslashes($comment_author_email);
- $comment_author_email = wp_specialchars($comment_author_email, true);
+ $comment_author_email = wp_specialchars($comment_author_email, true);
$_COOKIE['comment_author_email_'.COOKIEHASH] = $comment_author_email;
}
@@ -243,11 +243,11 @@ function wp_blacklist_check($author, $email, $url, $comment, $user_ip, $user_age
// Skip empty lines
if ( empty($word) ) { continue; }
- // Do some escaping magic so that '#' chars in the
+ // Do some escaping magic so that '#' chars in the
// spam words don't break things:
$word = preg_quote($word, '#');
- $pattern = "#$word#i";
+ $pattern = "#$word#i";
if ( preg_match($pattern, $author ) ) return true;
if ( preg_match($pattern, $email ) ) return true;
if ( preg_match($pattern, $url ) ) return true;
@@ -328,9 +328,9 @@ function wp_insert_comment($commentdata) {
if ( ! isset($user_id) )
$user_id = 0;
- $result = $wpdb->query("INSERT INTO $wpdb->comments
+ $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
+ 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')
");
@@ -397,26 +397,26 @@ function wp_new_comment( $commentdata ) {
}
function wp_set_comment_status($comment_id, $comment_status) {
- global $wpdb;
+ global $wpdb;
- switch($comment_status) {
+ 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 '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)) {
+ }
+
+ if ($wpdb->query($query)) {
do_action('wp_set_comment_status', $comment_id, $comment_status);
$comment = get_comment($comment_id);
@@ -425,9 +425,9 @@ function wp_set_comment_status($comment_id, $comment_status) {
if( is_object( $c ) )
$wpdb->query( "UPDATE $wpdb->posts SET comment_count = '$c->c' WHERE ID = '$comment_post_ID'" );
return true;
- } else {
+ } else {
return false;
- }
+ }
}
function wp_update_comment($commentarr) {
@@ -582,7 +582,7 @@ function do_all_pings() {
$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';");
@@ -705,7 +705,7 @@ function pingback($content, $post_ID) {
$pingback_server_url = discover_pingback_server_uri($pagelinkedto, 2048);
if ($pingback_server_url) {
- @ set_time_limit( 60 );
+ @ set_time_limit( 60 );
// Now, the RPC call
debug_fwrite($log, "Page Linked To: $pagelinkedto \n");
debug_fwrite($log, 'Page Linked From: ');
diff --git a/wp-includes/compat.php b/wp-includes/compat.php
index 3b64dfb..997307f 100644
--- a/wp-includes/compat.php
+++ b/wp-includes/compat.php
@@ -36,13 +36,13 @@ if (!function_exists('ob_clean')) {
/* Added in PHP 4.3.0 */
function printr($var, $do_not_echo = false) {
- // from php.net/print_r user contributed notes
+ // from php.net/print_r user contributed notes
ob_start();
print_r($var);
$code = htmlentities(ob_get_contents());
ob_clean();
if (!$do_not_echo) {
- echo "<pre>$code</pre>";
+ echo "<pre>$code</pre>";
}
ob_end_clean();
return $code;
@@ -57,11 +57,11 @@ if ( !function_exists('file_get_contents') ) {
}
if (!defined('CASE_LOWER')) {
- define('CASE_LOWER', 0);
+ define('CASE_LOWER', 0);
}
if (!defined('CASE_UPPER')) {
- define('CASE_UPPER', 1);
+ define('CASE_UPPER', 1);
}
@@ -73,43 +73,43 @@ 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: 3901 $
+ * @version $Revision: 4495 $
* @since PHP 4.2.0
* @require PHP 4.0.0 (user_error)
*/
if (!function_exists('array_change_key_case')) {
- function array_change_key_case($input, $case = CASE_LOWER)
- {
- if (!is_array($input)) {
- user_error('array_change_key_case(): The argument should be an array',
- E_USER_WARNING);
- return false;
- }
-
- $output = array ();
- $keys = array_keys($input);
- $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper';
-
- foreach ($keys as $key) {
- $output[$casefunc($key)] = $input[$key];
- }
-
- return $output;
- }
+ function array_change_key_case($input, $case = CASE_LOWER)
+ {
+ if (!is_array($input)) {
+ user_error('array_change_key_case(): The argument should be an array',
+ E_USER_WARNING);
+ return false;
+ }
+
+ $output = array ();
+ $keys = array_keys($input);
+ $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper';
+
+ foreach ($keys as $key) {
+ $output[$casefunc($key)] = $input[$key];
+ }
+
+ return $output;
+ }
}
// 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);
- }
+ 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);
+ }
}
if ( !function_exists('_') ) {
diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php
index b75e07a..38b07ca 100644
--- a/wp-includes/deprecated.php
+++ b/wp-includes/deprecated.php
@@ -129,8 +129,8 @@ function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
$post_author_data = get_userdata($post->post_author);
if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' && $author_data->user_level < 2))
- || ($author_data->user_level > $post_author_data->user_level)
- || ($author_data->user_level >= 10) ) {
+ || ($author_data->user_level > $post_author_data->user_level)
+ || ($author_data->user_level >= 10) ) {
return true;
} else {
return false;
@@ -199,19 +199,19 @@ function user_can_edit_user($user_id, $other_user) {
** 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->categories 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);
+ $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->categories 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 wp_get_linksbyname()
@@ -252,16 +252,16 @@ function wp_get_linksbyname($category, $args = '') {
**/
// Deprecate in favor of get_linkz().
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'");
- // TODO: Fix me.
- if ($results) {
- foreach ($results as $result) {
- $cat_id = $result->cat_id;
- }
- }
- return get_linkobjects($cat_id, $orderby, $limit);
+ global $wpdb;
+ $cat_id = -1;
+ //$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'");
+ // TODO: Fix me.
+ if ($results) {
+ foreach ($results as $result) {
+ $cat_id = $result->cat_id;
+ }
+ }
+ return get_linkobjects($cat_id, $orderby, $limit);
}
/** function get_linkobjects()
@@ -301,40 +301,40 @@ function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit
**/
// Deprecate in favor of get_linkz().
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;
+ 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_linksbyname_withrating()
@@ -359,12 +359,12 @@ function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) {
** 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) {
+ $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);
+ get_linksbyname($cat_name, $before, $after, $between, $show_images,
+ $orderby, $show_description, true, $limit, $show_updated);
}
/** function get_links_withrating()
@@ -389,12 +389,12 @@ function get_linksbyname_withrating($cat_name = "noname", $before = '',
** 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) {
+ $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);
+ get_links($category, $before, $after, $between, $show_images, $orderby,
+ $show_description, true, $limit, $show_updated);
}
/** function get_get_autotoggle()
@@ -403,7 +403,7 @@ function get_links_withrating($category = -1, $before = '', $after = '<br />',
** uses 0
*/
function get_autotoggle($id = 0) {
- return 0;
+ return 0;
}
function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_order = 'asc', $file = '', $list = true, $optiondates = 0, $optioncount = 0, $hide_empty = 1, $use_desc_for_title = 1, $children=FALSE, $child_of=0, $categories=0, $recurse=0, $feed = '', $feed_image = '', $exclude = '', $hierarchical=FALSE) {
@@ -433,7 +433,7 @@ function wp_list_cats($args = '') {
$r['style'] = 'break';
$r['title_li'] = '';
- return wp_list_categories($r);
+ return wp_list_categories($r);
}
function dropdown_cats($optionall = 1, $all = 'All', $orderby = 'ID', $order = 'asc',
diff --git a/wp-includes/feed.php b/wp-includes/feed.php
index ec11d65..deebbea 100644
--- a/wp-includes/feed.php
+++ b/wp-includes/feed.php
@@ -135,9 +135,9 @@ function get_the_category_rss($type = 'rss') {
foreach ( (array) $categories as $category ) {
$category->cat_name = convert_chars($category->cat_name);
if ( 'rdf' == $type )
- $the_list .= "\n\t\t<dc:subject>$category->cat_name</dc:subject>\n";
+ $the_list .= "\n\t\t<dc:subject><![CDATA[$category->cat_name]]></dc:subject>\n";
else
- $the_list .= "\n\t\t<category>$category->cat_name</category>\n";
+ $the_list .= "\n\t\t<category><![CDATA[$category->cat_name]]></category>\n";
}
return apply_filters('the_category_rss', $the_list, $type);
}
diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php
index 7d083a8..14b100a 100644
--- a/wp-includes/formatting.php
+++ b/wp-includes/formatting.php
@@ -2,56 +2,47 @@
function wptexturize($text) {
global $wp_cockneyreplace;
+ $next = true;
$output = '';
- // Capture tags and everything inside them
- $textarr = preg_split("/(<.*>)/Us", $text, -1, PREG_SPLIT_DELIM_CAPTURE);
- $stop = count($textarr); $next = true; // loop stuff
- for ($i = 0; $i < $stop; $i++) {
- $curl = $textarr[$i];
+ $curl = '';
+ $textarr = preg_split('/(<.*>)/Us', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
+ $stop = count($textarr);
+
+ // if a plugin has provided an autocorrect array, use it
+ if ( isset($wp_cockneyreplace) ) {
+ $cockney = array_keys($wp_cockneyreplace);
+ $cockney_replace = array_values($wp_cockneyreplace);
+ } else {
+ $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round","'cause");
+ $cockneyreplace = array("&#8217;tain&#8217;t","&#8217;twere","&#8217;twas","&#8217;tis","&#8217;twill","&#8217;til","&#8217;bout","&#8217;nuff","&#8217;round","&#8217;cause");
+ }
- if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag
- $curl = str_replace('---', '&#8212;', $curl);
- $curl = str_replace(' -- ', ' &#8212; ', $curl);
- $curl = str_replace('--', '&#8211;', $curl);
- $curl = str_replace('xn&#8211;', 'xn--', $curl);
- $curl = str_replace('...', '&#8230;', $curl);
- $curl = str_replace('``', '&#8220;', $curl);
-
- // if a plugin has provided an autocorrect array, use it
- if ( isset($wp_cockneyreplace) ) {
- $cockney = array_keys($wp_cockneyreplace);
- $cockney_replace = array_values($wp_cockneyreplace);
- } else {
- $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round","'cause");
- $cockneyreplace = array("&#8217;tain&#8217;t","&#8217;twere","&#8217;twas","&#8217;tis","&#8217;twill","&#8217;til","&#8217;bout","&#8217;nuff","&#8217;round","&#8217;cause");
- }
+ $static_characters = array_merge(array('---', ' -- ', '--', 'xn&#8211;', '...', '``', '\'s', '\'\'', ' (tm)'), $cockney);
+ $static_replacements = array_merge(array('&#8212;', ' &#8212; ', '&#8211;', 'xn--', '&#8230;', '&#8220;', '&#8217;s', '&#8221;', ' &#8482;'), $cockneyreplace);
- $curl = str_replace($cockney, $cockneyreplace, $curl);
+ $dynamic_characters = array('/\'(\d\d(?:&#8217;|\')?s)/', '/(\s|\A|")\'/', '/(\d+)"/', '/(\d+)\'/', '/(\S)\'([^\'\s])/', '/(\s|\A)"(?!\s)/', '/"(\s|\S|\Z)/', '/\'([\s.]|\Z)/', '/(\d+)x(\d+)/');
+ $dynamic_replacements = array('&#8217;$1','$1&#8216;', '$1&#8243;', '$1&#8242;', '$1&#8217;$2', '$1&#8220;$2', '&#8221;$1', '&#8217;$1', '$1&#215;$2');
- $curl = preg_replace("/'s/", '&#8217;s', $curl);
- $curl = preg_replace("/'(\d\d(?:&#8217;|')?s)/", "&#8217;$1", $curl);
- $curl = preg_replace('/(\s|\A|")\'/', '$1&#8216;', $curl);
- $curl = preg_replace('/(\d+)"/', '$1&#8243;', $curl);
- $curl = preg_replace("/(\d+)'/", '$1&#8242;', $curl);
- $curl = preg_replace("/(\S)'([^'\s])/", "$1&#8217;$2", $curl);
- $curl = preg_replace('/(\s|\A)"(?!\s)/', '$1&#8220;$2', $curl);
- $curl = preg_replace('/"(\s|\S|\Z)/', '&#8221;$1', $curl);
- $curl = preg_replace("/'([\s.]|\Z)/", '&#8217;$1', $curl);
- $curl = preg_replace("/ \(tm\)/i", ' &#8482;', $curl);
- $curl = str_replace("''", '&#8221;', $curl);
+ for ( $i = 0; $i < $stop; $i++ ) {
+ $curl = $textarr[$i];
- $curl = preg_replace('/(\d+)x(\d+)/', "$1&#215;$2", $curl);
+ if (isset($curl{0}) && '<' != $curl{0} && $next) { // If it's not a tag
+ // static strings
+ $curl = str_replace($static_characters, $static_replacements, $curl);
+ // regular expressions
+ $curl = preg_replace($dynamic_characters, $dynamic_replacements, $curl);
} elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) {
- // strstr is fast
$next = false;
} else {
$next = true;
}
+
$curl = preg_replace('/&([^#])(?![a-zA-Z1-4]{1,8};)/', '&#038;$1', $curl);
$output .= $curl;
}
- return $output;
+
+ return $output;
}
function clean_pre($text) {
@@ -65,18 +56,18 @@ function wpautop($pee, $br = 1) {
$pee = $pee . "\n"; // just to make things a little easier, pad the end
$pee = preg_replace('|<br />\s*<br />|', "\n\n", $pee);
// Space things out a little
- $pee = preg_replace('!(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "\n$1", $pee);
+ $pee = preg_replace('!(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "\n$1", $pee);
$pee = preg_replace('!(</(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])>)!', "$1\n\n", $pee);
- $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
+ $pee = str_replace(array("\r\n", "\r"), "\n", $pee); // cross-platform newlines
$pee = preg_replace("/\n\n+/", "\n\n", $pee); // take care of duplicates
- $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
- $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
+ $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "<p>$1</p>\n", $pee); // make paragraphs, including one at the end
+ $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
$pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
$pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
$pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
$pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
$pee = preg_replace('!<p>\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)!', "$1", $pee);
- $pee = preg_replace('!(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee);
+ $pee = preg_replace('!(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee);
if ($br) {
$pee = preg_replace('/<(script|style).*?<\/\\1>/se', 'str_replace("\n", "<WPPreserveNewline />", "\\0")', $pee);
$pee = preg_replace('|(?<!<br />)\s*\n|', "<br />\n", $pee); // optionally make line breaks
@@ -86,7 +77,7 @@ function wpautop($pee, $br = 1) {
$pee = preg_replace('!<br />(\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)!', '$1', $pee);
$pee = preg_replace('!(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') . stripslashes(clean_pre('$2')) . '</pre>' ", $pee);
- return $pee;
+ return $pee;
}
@@ -109,7 +100,9 @@ function seems_utf8($Str) { # by bmorel at ssi dot fr
function wp_specialchars( $text, $quotes = 0 ) {
// Like htmlspecialchars except don't double-encode HTML entities
- $text = preg_replace('/&([^#])(?![a-z1-4]{1,8};)/', '&#038;$1', $text);
+ $text = str_replace('&&', '&#038;&', $text);
+ $text = str_replace('&&', '&#038;&', $text);
+ $text = preg_replace('/&(?:$|([^#])(?![a-z1-4]{1,8};))/', '&#038;$1', $text);
$text = str_replace('<', '&lt;', $text);
$text = str_replace('>', '&gt;', $text);
if ( 'double' === $quotes ) {
@@ -124,35 +117,35 @@ function wp_specialchars( $text, $quotes = 0 ) {
}
function utf8_uri_encode( $utf8_string ) {
- $unicode = '';
- $values = array();
- $num_octets = 1;
-
- for ($i = 0; $i < strlen( $utf8_string ); $i++ ) {
-
- $value = ord( $utf8_string[ $i ] );
-
- if ( $value < 128 ) {
- $unicode .= chr($value);
- } else {
- if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
-
- $values[] = $value;
-
- if ( count( $values ) == $num_octets ) {
+ $unicode = '';
+ $values = array();
+ $num_octets = 1;
+
+ for ($i = 0; $i < strlen( $utf8_string ); $i++ ) {
+
+ $value = ord( $utf8_string[ $i ] );
+
+ if ( $value < 128 ) {
+ $unicode .= chr($value);
+ } else {
+ if ( count( $values ) == 0 ) $num_octets = ( $value < 224 ) ? 2 : 3;
+
+ $values[] = $value;
+
+ if ( count( $values ) == $num_octets ) {
if ($num_octets == 3) {
- $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]);
+ $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]) . '%' . dechex($values[2]);
} else {
- $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]);
+ $unicode .= '%' . dechex($values[0]) . '%' . dechex($values[1]);
}
$values = array();
$num_octets = 1;
- }
- }
- }
+ }
+ }
+ }
- return $unicode;
+ return $unicode;
}
function remove_accents($string) {
@@ -348,7 +341,7 @@ function sanitize_title_with_dashes($title) {
return $title;
}
-function convert_chars($content, $flag = 'obsolete') {
+function convert_chars($content, $flag = 'obsolete') {
// Translation of invalid Unicode references range to valid range
$wp_htmltranswinuni = array(
'&#128;' => '&#8364;', // the Euro sign
@@ -414,22 +407,22 @@ function funky_javascript_fix($text) {
/*
balanceTags
-
+
Balances Tags of string using a modified stack.
-
+
@param text Text to be balanced
@return Returns balanced text
@author Leonard Lin (leonard@acm.org)
@version v1.1
@date November 4, 2001
@license GPL v2.0
- @notes
- @changelog
+ @notes
+ @changelog
--- Modified by Scott Reilly (coffee2code) 02 Aug 2004
- 1.2 ***TODO*** Make better - change loop condition to $text
- 1.1 Fixed handling of append/stack pop order of end text
- Added Cleaning Hooks
- 1.0 First Version
+ 1.2 ***TODO*** Make better - change loop condition to $text
+ 1.1 Fixed handling of append/stack pop order of end text
+ Added Cleaning Hooks
+ 1.0 First Version
*/
function balanceTags($text, $is_comment = 0, $force = false) {
@@ -455,7 +448,7 @@ function balanceTags($text, $is_comment = 0, $force = false) {
if ($regex[1][0] == "/") { // End Tag
$tag = strtolower(substr($regex[1],1));
// if too many closing tags
- if($stacksize <= 0) {
+ if($stacksize <= 0) {
$tag = '';
//or close to be safe $tag = '/' . $tag;
}
@@ -512,7 +505,7 @@ function balanceTags($text, $is_comment = 0, $force = false) {
}
$newtext .= substr($text,0,$i) . $tag;
$text = substr($text,$i+$l);
- }
+ }
// Clear Tag Queue
$newtext .= $tagqueue;
@@ -561,10 +554,10 @@ function backslashit($string) {
}
function trailingslashit($string) {
- if ( '/' != substr($string, -1)) {
- $string .= '/';
- }
- return $string;
+ if ( '/' != substr($string, -1)) {
+ $string .= '/';
+ }
+ return $string;
}
function addslashes_gpc($gpc) {
@@ -580,11 +573,11 @@ function addslashes_gpc($gpc) {
function stripslashes_deep($value)
{
- $value = is_array($value) ?
- array_map('stripslashes_deep', $value) :
- stripslashes($value);
+ $value = is_array($value) ?
+ array_map('stripslashes_deep', $value) :
+ stripslashes($value);
- return $value;
+ return $value;
}
function antispambot($emailaddy, $mailto=0) {
@@ -740,7 +733,7 @@ function sanitize_email($email) {
return preg_replace('/[^a-z0-9+_.@-]/i', '', $email);
}
-function human_time_diff( $from, $to = '' ) {
+function human_time_diff( $from, $to = '' ) {
if ( empty($to) )
$to = time();
$diff = (int) abs($to - $from);
@@ -754,7 +747,7 @@ function human_time_diff( $from, $to = '' ) {
$hours = round($diff / 3600);
if ($hours <= 1)
$since = __('1 hour');
- else
+ else
$since = sprintf( __('%s hours'), $hours );
} elseif ($diff >= 86400) {
$days = round($diff / 86400);
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index e87724a..f6ba499 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -12,7 +12,7 @@ function mysql2date($dateformatstring, $mysqlstring, $translate = true) {
if( 'U' == $dateformatstring )
return $i;
-
+
if ( -1 == $i || false == $i )
$i = 0;
@@ -479,7 +479,7 @@ function wp_get_http_headers( $url, $red = 1 ) {
@set_time_limit( 60 );
if ( $red > 5 )
- return false;
+ return false;
$parts = parse_url( $url );
$file = $parts['path'] . ($parts['query'] ? '?'.$parts['query'] : '');
@@ -508,9 +508,9 @@ function wp_get_http_headers( $url, $red = 1 ) {
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 );
+ $code = $headers['response'];
+ if ( ('302' == $code || '301' == $code) && isset($headers['location']) )
+ return wp_get_http_headers( $headers['location'], ++$red );
return $headers;
}
@@ -573,9 +573,22 @@ function update_post_category_cache($post_ids) {
return;
if ( is_array($post_ids) )
- $post_ids = implode(',', $post_ids);
+ $post_id_list = implode(',', $post_ids);
+
+ $post_id_array = (array) explode(',', $post_ids);
+ $count = count( $post_id_array);
+ for ( $i = 0; $i < $count; $i++ ) {
+ $post_id = $post_id_array[ $i ];
+ if ( isset( $category_cache[$blog_id][$post_id] ) ) {
+ unset( $post_id_array[ $i ] );
+ continue;
+ }
+ }
+ if ( count( $post_id_array ) == 0 )
+ return;
+ $post_id_list = join( ',', $post_id_array ); // with already cached stuff removed
- $dogs = $wpdb->get_results("SELECT post_id, category_id FROM $wpdb->post2cat WHERE post_id IN ($post_ids)");
+ $dogs = $wpdb->get_results("SELECT post_id, category_id FROM $wpdb->post2cat WHERE post_id IN ($post_id_list)");
if ( empty($dogs) )
return;
@@ -611,11 +624,24 @@ function update_postmeta_cache($post_id_list = '') {
// We should validate this comma-separated list for the upcoming SQL query
$post_id_list = preg_replace('|[^0-9,]|', '', $post_id_list);
+ if ( empty( $post_id_list ) )
+ return false;
+
// we're marking each post as having its meta cached (with no keys... empty array), to prevent posts with no meta keys from being queried again
// any posts that DO have keys will have this empty array overwritten with a proper array, down below
- $post_id_array = explode(',', $post_id_list);
- foreach ( (array) $post_id_array as $pid )
- $post_meta_cache[$blogi_id][$pid] = array();
+ $post_id_array = (array) explode(',', $post_id_list);
+ $count = count( $post_id_array);
+ for ( $i = 0; $i < $count; $i++ ) {
+ $post_id = $post_id_array[ $i ];
+ if ( isset( $post_meta_cache[$blog_id][$post_id] ) ) { // If the meta is already cached
+ unset( $post_id_array[ $i ] );
+ continue;
+ }
+ $post_meta_cache[$blog_id][$post_id] = array();
+ }
+ if ( count( $post_id_array ) == 0 )
+ return;
+ $post_id_list = join( ',', $post_id_array ); // with already cached stuff removeds
// Get post-meta info
if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) {
@@ -755,7 +781,7 @@ function add_magic_quotes($array) {
function wp_remote_fopen( $uri ) {
if ( ini_get('allow_url_fopen') ) {
- $fp = fopen( $uri, 'r' );
+ $fp = @fopen( $uri, 'r' );
if ( !$fp )
return false;
$linea = '';
@@ -797,9 +823,9 @@ function status_header( $header ) {
$text = 'Gone';
if ( substr(php_sapi_name(), 0, 3) == 'cgi' )
- @header("Status: $header $text");
- else
@header("HTTP/1.1 $header $text");
+ else
+ @header("Status: $header $text");
}
function nocache_headers() {
@@ -822,8 +848,8 @@ function get_num_queries() {
}
function bool_from_yn($yn) {
- if ($yn == 'Y') return 1;
- return 0;
+ if ($yn == 'Y') return 1;
+ return 0;
}
function do_feed() {
@@ -836,7 +862,7 @@ function do_feed() {
$feed = 'rss2';
$for_comments = false;
- if ( is_singular() || get_query_var('withcomments') == 1 || $feed == 'comments-rss2' ) {
+ if ( 1 != get_query_var('withoutcomments') && ( is_singular() || get_query_var('withcomments') == 1 || $feed == 'comments-rss2' ) ) {
$feed = 'rss2';
$for_comments = true;
}
@@ -980,7 +1006,7 @@ function wp_upload_dir() {
return array('error' => $message);
}
- $uploads = array('path' => $dir, 'url' => $url, 'error' => false);
+ $uploads = array('path' => $dir, 'url' => $url, 'error' => false);
return apply_filters('upload_dir', $uploads);
}
diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php
index 4849360..017cedb 100644
--- a/wp-includes/general-template.php
+++ b/wp-includes/general-template.php
@@ -426,6 +426,15 @@ function calendar_week_mod($num) {
function get_calendar($initial = true) {
global $wpdb, $m, $monthnum, $year, $timedifference, $wp_locale, $posts;
+ $key = md5( $m . $monthnum . $year );
+ if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
+ if ( isset( $cache[ $key ] ) ) {
+ echo $cache[ $key ];
+ return;
+ }
+ }
+
+ ob_start();
// Quick check. If we have no posts at all, abort!
if ( !$posts ) {
$gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
@@ -475,7 +484,7 @@ function get_calendar($initial = true) {
FROM $wpdb->posts
WHERE post_date > '$thisyear-$thismonth-01'
AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' )
- AND post_type = 'post' AND post_status = 'publish'
+ AND post_type = 'post' AND post_status = 'publish'
ORDER BY post_date ASC
LIMIT 1");
@@ -599,7 +608,22 @@ function get_calendar($initial = true) {
echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>';
echo "\n\t</tr>\n\t</tbody>\n\t</table>";
+
+ $output = ob_get_contents();
+ ob_end_clean();
+ echo $output;
+ $cache[ $key ] = $output;
+ wp_cache_set( 'get_calendar', $cache, 'calendar' );
+}
+
+function delete_get_calendar_cache() {
+ wp_cache_delete( 'get_calendar', 'calendar' );
}
+add_action( 'save_post', 'delete_get_calendar_cache' );
+add_action( 'delete_post', 'delete_get_calendar_cache' );
+add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
+add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
+add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
function allowed_tags() {
@@ -763,30 +787,12 @@ function rich_edit_exists() {
}
function user_can_richedit() {
- $can = true;
+ global $wp_rich_edit;
+
+ if ( !isset($wp_rich_edit) )
+ $wp_rich_edit = ( 'true' == get_user_option('rich_editing') && !preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) && rich_edit_exists() ) ? true : false;
- if ( 'true' != get_user_option('rich_editing') || preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) )
- $can = false;
-
- return apply_filters('user_can_richedit', $can);
-}
-
-function user_can_switchedit() {
- $can = true;
-
- $ua = $_SERVER['HTTP_USER_AGENT'];
-
- if (
- !user_can_richedit() ||
- ( // Mozilla Test
- strstr($ua, 'Mozilla/5.0') &&
- !strstr($ua, 'ompatible') &&
- !strstr($ua, 'irefox')
- )
- )
- $can = false;
-
- return apply_filters('user_can_switchedit', $can);
+ return apply_filters('user_can_richedit', $wp_rich_edit);
}
function the_editor($content, $id = 'content', $prev_id = 'title') {
@@ -799,19 +805,24 @@ function the_editor($content, $id = 'content', $prev_id = 'title') {
if ( user_can_richedit() ) :
add_filter('the_editor_content', 'wp_richedit_pre');
- if ( user_can_switchedit() ) :
+ // The following line moves the border so that the active button "attaches" to the toolbar. Only IE needs it.
?>
+ <style type="text/css">
+ #postdivrich table, #postdivrich #quicktags {border-top: none;}
+ #quicktags {border-bottom: none; padding-bottom: 2px; margin-bottom: -1px;}
+ #edButtons {border-bottom: 1px solid #ccc;}
+ </style>
<div id='edButtons' style='display:none;'>
<div class='zerosize'><input accesskey='e' type='button' onclick='switchEditors("<?php echo $id; ?>")' /></div>
- <input id='edButtonPreview' class='edButtonFore' type='button' value='<?php _e('Editor'); ?>' />
- <input id='edButtonHTML' class='edButtonBack' type='button' value='<?php _e('HTML'); ?>' onclick='switchEditors("<?php echo $id; ?>")' />
+ <input id='edButtonPreview' class='edButtonFore' type='button' value='<?php _e('Visual'); ?>' />
+ <input id='edButtonHTML' class='edButtonBack' type='button' value='<?php _e('Code'); ?>' onclick='switchEditors("<?php echo $id; ?>")' />
</div>
<script type="text/javascript">
if ( typeof tinyMCE != "undefined" && tinyMCE.configs.length > 0 )
document.getElementById('edButtons').style.display = 'block';
</script>
- <?php endif; endif; ?>
+ <?php endif; ?>
<div id="quicktags">
<?php wp_print_scripts( 'quicktags' ); ?>
<script type="text/javascript">edToolbar()</script>
@@ -846,9 +857,7 @@ function the_editor($content, $id = 'content', $prev_id = 'title') {
</script>
<?php
- $class = user_can_switchedit() ? 'switched' : 'unswitched';
-
- $the_editor = apply_filters('the_editor', "<div class='$class'><textarea class='mceEditor' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n");
+ $the_editor = apply_filters('the_editor', "<div><textarea class='mceEditor' $rows cols='40' name='$id' tabindex='2' id='$id'>%s</textarea></div>\n");
$the_editor_content = apply_filters('the_editor_content', $content);
printf($the_editor, $the_editor_content);
diff --git a/wp-includes/js/autosave.js.php b/wp-includes/js/autosave.js.php
index c360318..2e76230 100644
--- a/wp-includes/js/autosave.js.php
+++ b/wp-includes/js/autosave.js.php
@@ -3,10 +3,20 @@ cache_javascript_headers();
?>
var autosaveLast = '';
var autosavePeriodical;
+
function autosave_start_timer() {
var form = $('post');
autosaveLast = form.post_title.value+form.content.value;
- autosavePeriodical = new PeriodicalExecuter(autosave, <?php echo apply_filters('autosave_interval', '60'); ?>);
+ autosavePeriodical = new PeriodicalExecuter(autosave, <?php echo apply_filters('autosave_interval', '120'); ?>);
+ //Disable autosave after the form has been submitted
+ if(form.addEventListener) {
+ form.addEventListener("submit", function () { autosavePeriodical.currentlyExecuting = true; }, false);
+ }
+ if(form.attachEvent) {
+ $('save').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; });
+ $('publish').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; });
+ $('deletepost').attachEvent("onclick", function () { autosavePeriodical.currentlyExecuting = true; });
+ }
}
addLoadEvent(autosave_start_timer)
diff --git a/wp-includes/js/list-manipulation-js.php b/wp-includes/js/list-manipulation-js.php
index 6c89d5f..112d19f 100644
--- a/wp-includes/js/list-manipulation-js.php
+++ b/wp-includes/js/list-manipulation-js.php
@@ -1,8 +1,4 @@
-<?php
-@require_once('../../wp-config.php');
-cache_javascript_headers();
-$handler = get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php';
-?>
+<?php @require_once('../../wp-config.php'); cache_javascript_headers(); ?>
addLoadEvent(function(){theList=new listMan();});
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);}
@@ -10,7 +6,7 @@ function dimSomething(what,id,dimClass,obj){if(!obj)obj=theList;return obj.ajaxD
var listMan = Class.create();
Object.extend(listMan.prototype, {
ajaxRespEl: 'ajax-response',
- ajaxHandler: '<?php echo $handler; ?>',
+ ajaxHandler: false,
inputData: '',
clearInputs: [],
showLink: true,
@@ -51,16 +47,18 @@ Object.extend(listMan.prototype, {
if ( tempObj.showLink )
tempObj.showLink = id;
});
+ ajaxAdd.myResponseElement.update(tempObj.showLink ? ( "<div id='jumplink' class='updated fade'><p><a href='#" + what + '-' + tempObj.showLink + "'><?php _e('Jump to new item'); ?></a></p></div>" ) : '');
}
- ajaxAdd.myResponseElement.update(tempObj.showLink ? ( "<div id='jumplink' class='updated fade'><p><a href='#" + what + '-' + tempObj.showLink + "'><?php _e('Jump to new item'); ?></a></p></div>" ) : '');
if ( tempObj.addComplete && typeof tempObj.addComplete == 'function' )
tempObj.addComplete( what, where, update, transport );
tempObj.recolorList();
ajaxAdd.restoreInputs = null;
});
- ajaxAdd.addOnWPError( function(transport) { tempObj.restoreForm(ajaxAdd.restoreInputs); });
+ if ( !update )
+ ajaxAdd.addOnWPError( function(transport) { tempObj.restoreForm(ajaxAdd.restoreInputs); });
ajaxAdd.request(ajaxAdd.url);
- this.clear();
+ if ( !update )
+ this.clear();
return false;
},
@@ -262,7 +260,5 @@ function killSubmit ( code, e ) {
}
}
}
-//Pretty func adapted from ALA http://www.alistapart.com/articles/gettingstartedwithajax
-function getNodeValue(tree,el){try { var r = tree.getElementsByTagName(el)[0].firstChild.nodeValue; } catch(err) { var r = null; } return r; }
//Generic but lame JS closure
function encloseFunc(f){var a=arguments[1];return function(){return f(a);}}
diff --git a/wp-includes/js/tinymce/license.txt b/wp-includes/js/tinymce/license.txt
index 3b0396a..60d6d4c 100644
--- a/wp-includes/js/tinymce/license.txt
+++ b/wp-includes/js/tinymce/license.txt
@@ -1,13 +1,14 @@
- GNU LIBRARY GENERAL PUBLIC LICENSE
- Version 2, June 1991
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
- Copyright (C) 1991 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
-[This is the first released version of the library GPL. It is
- numbered 2 because it goes with version 2 of the ordinary GPL.]
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
Preamble
@@ -16,97 +17,109 @@ freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
- This license, the Library General Public License, applies to some
-specially designated Free Software Foundation software, and to any
-other libraries whose authors decide to use it. You can use it for
-your libraries, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if
-you distribute copies of the library, or if you modify it.
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
-code. If you link a program with the library, you must provide
-complete object files to the recipients so that they can relink them
-with the library, after making changes to the library and recompiling
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
- Our method of protecting your rights has two steps: (1) copyright
-the library, and (2) offer you this license which gives you legal
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
- Also, for each distributor's protection, we want to make certain
-that everyone understands that there is no warranty for this free
-library. If the library is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original
-version, so that any problems introduced by others will not reflect on
-the original authors' reputations.
-.
- Finally, any free program is threatened constantly by software
-patents. We wish to avoid the danger that companies distributing free
-software will individually obtain patent licenses, thus in effect
-transforming the program into proprietary software. To prevent this,
-we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
-
- Most GNU software, including some libraries, is covered by the ordinary
-GNU General Public License, which was designed for utility programs. This
-license, the GNU Library General Public License, applies to certain
-designated libraries. This license is quite different from the ordinary
-one; be sure to read it in full, and don't assume that anything in it is
-the same as in the ordinary license.
-
- The reason we have a separate public license for some libraries is that
-they blur the distinction we usually make between modifying or adding to a
-program and simply using it. Linking a program with a library, without
-changing the library, is in some sense simply using the library, and is
-analogous to running a utility program or application program. However, in
-a textual and legal sense, the linked executable is a combined work, a
-derivative of the original library, and the ordinary General Public License
-treats it as such.
-
- Because of this blurred distinction, using the ordinary General
-Public License for libraries did not effectively promote software
-sharing, because most developers did not use the libraries. We
-concluded that weaker conditions might promote sharing better.
-
- However, unrestricted linking of non-free programs would deprive the
-users of those programs of all benefit from the free status of the
-libraries themselves. This Library General Public License is intended to
-permit developers of non-free programs to use free libraries, while
-preserving your freedom as a user of such programs to change the free
-libraries that are incorporated in them. (We have not seen how to achieve
-this as regards changes in header files, but we have achieved it as regards
-changes in the actual functions of the Library.) The hope is that this
-will lead to faster development of free libraries.
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
-former contains code derived from the library, while the latter only
-works together with the library.
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
- Note that it is possible for a library to be covered by the ordinary
-General Public License rather than by this special one.
-.
- GNU LIBRARY GENERAL PUBLIC LICENSE
+ GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
- 0. This License Agreement applies to any software library which
-contains a notice placed by the copyright holder or other authorized
-party saying it may be distributed under the terms of this Library
-General Public License (also called "this License"). Each licensee is
-addressed as "you".
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
@@ -145,7 +158,7 @@ Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
-.
+
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
@@ -203,7 +216,7 @@ instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
-.
+
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
@@ -254,8 +267,8 @@ Library will still fall under Section 6.)
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
-.
- 6. As an exception to the Sections above, you may also compile or
+
+ 6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
@@ -282,23 +295,31 @@ of these things:
Library will not necessarily be able to recompile the application
to use the modified definitions.)
- b) Accompany the work with a written offer, valid for at
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
- c) If distribution of the work is made by offering access to copy
+ d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
- d) Verify that the user has already received a copy of these
+ e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
-the source code distributed need not include anything that is normally
-distributed (in either source or binary form) with the major
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
@@ -308,7 +329,7 @@ restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
-.
+
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
@@ -347,9 +368,9 @@ Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
+You are not responsible for enforcing compliance by third parties with
this License.
-.
+
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
@@ -390,7 +411,7 @@ excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
-versions of the Library General Public License from time to time.
+versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
@@ -401,7 +422,7 @@ conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
-.
+
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
@@ -435,3 +456,49 @@ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js b/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js
index 4b88d2e..68563f9 100644
--- a/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js
@@ -1,20 +1,18 @@
/**
- * $RCSfile: editor_plugin_src.js,v $
- * $Revision: 1.11 $
- * $Date: 2006/03/22 12:21:21 $
+ * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
*/
/* Import plugin specific language pack */
-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');
+tinyMCE.importPluginLanguagePack('autosave');
var TinyMCE_AutoSavePlugin = {
getInfo : function() {
return {
longname : 'Auto save',
- author : 'Moxiecode Systems',
+ author : 'Moxiecode Systems AB',
authorurl : 'http://tinymce.moxiecode.com',
infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html',
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
diff --git a/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js b/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
index ad0fa87..c8a6295 100644
--- a/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
@@ -1,20 +1,18 @@
/**
- * $RCSfile: editor_plugin_src.js,v $
- * $Revision: 1.16 $
- * $Date: 2006/02/10 21:34:28 $
+ * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
*/
/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('directionality', 'en,tr,sv,fr_ca,zh_cn,cs,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,pl,nl,fr,pt_br');
+tinyMCE.importPluginLanguagePack('directionality');
var TinyMCE_DirectionalityPlugin = {
getInfo : function() {
return {
longname : 'Directionality',
- author : 'Moxiecode Systems',
+ author : 'Moxiecode Systems AB',
authorurl : 'http://tinymce.moxiecode.com',
infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html',
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
index 74d1805..c005a9e 100644
--- a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js
@@ -1,7 +1,5 @@
/**
- * $RCSfile: editor_plugin_src.js,v $
- * $Revision: 1.8 $
- * $Date: 2006/02/06 20:02:38 $
+ * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
*
* Moxiecode DHTML Windows script.
*
@@ -15,7 +13,7 @@ var TinyMCE_InlinePopupsPlugin = {
getInfo : function() {
return {
longname : 'Inline Popups',
- author : 'Moxiecode Systems',
+ author : 'Moxiecode Systems AB',
authorurl : 'http://tinymce.moxiecode.com',
infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_inlinepopups.html',
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
@@ -436,7 +434,7 @@ TinyMCE_Windows.prototype.onLoad = function(name) {
TinyMCE_Windows.prototype.createFloatingIFrame = function(id_prefix, left, top, width, height, html) {
var iframe = document.createElement("iframe");
- var div = document.createElement("div");
+ var div = document.createElement("div"), doc;
width = parseInt(width);
height = parseInt(height)+1;
@@ -488,7 +486,7 @@ TinyMCE_Windows.prototype.createFloatingIFrame = function(id_prefix, left, top,
if (this.isSafari) {
// Give Safari some time to setup
window.setTimeout(function() {
- doc = window.frames[id_prefix + '_iframe'].document;
+ var doc = window.frames[id_prefix + '_iframe'].document;
doc.open();
doc.write(html);
doc.close();
diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js b/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js
index a88ffd7..325d293 100644
--- a/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js
+++ b/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js
@@ -1,7 +1,5 @@
/**
- * $RCSfile: mcwindows.js,v $
- * $Revision: 1.2 $
- * $Date: 2005/10/18 13:59:43 $
+ * $Id: mcwindows.js 18 2006-06-29 14:11:23Z spocke $
*
* Moxiecode DHTML Windows script.
*
diff --git a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
index d9bd215..de5edbe 100644
--- a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
@@ -1 +1,386 @@
-tinyMCE.importPluginLanguagePack('paste','en,tr,sv,cs,zh_cn,fr_ca,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,fi,es,cy,is,pl,nl,fr,pt_br');var TinyMCE_PastePlugin={getInfo:function(){return{longname:'Paste text/word',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_paste.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},initInstance:function(inst){if(tinyMCE.isMSIE&&tinyMCE.getParam("paste_auto_cleanup_on_paste",false))tinyMCE.addEvent(inst.getBody(),"paste",TinyMCE_PastePlugin._handlePasteEvent);},getControlHTML:function(cn){switch(cn){case"pastetext":return tinyMCE.getButtonHTML(cn,'lang_paste_text_desc','{$pluginurl}/images/pastetext.gif','mcePasteText',true);case"pasteword":return tinyMCE.getButtonHTML(cn,'lang_paste_word_desc','{$pluginurl}/images/pasteword.gif','mcePasteWord',true);case"selectall":return tinyMCE.getButtonHTML(cn,'lang_selectall_desc','{$pluginurl}/images/selectall.gif','mceSelectAll',true);}return'';},execCommand:function(editor_id,element,command,user_interface,value){switch(command){case"mcePasteText":if(user_interface){if((tinyMCE.isMSIE&&!tinyMCE.isOpera)&&!tinyMCE.getParam('paste_use_dialog',false))TinyMCE_PastePlugin._insertText(clipboardData.getData("Text"),true);else{var template=new Array();template['file']='../../plugins/paste/pastetext.htm';template['width']=450;template['height']=400;var plain_text="";tinyMCE.openWindow(template,{editor_id:editor_id,plain_text:plain_text,resizable:"yes",scrollbars:"no",inline:"yes",mceDo:'insert'});}}else TinyMCE_PastePlugin._insertText(value['html'],value['linebreaks']);return true;case"mcePasteWord":if(user_interface){if((tinyMCE.isMSIE&&!tinyMCE.isOpera)&&!tinyMCE.getParam('paste_use_dialog',false)){var html=TinyMCE_PastePlugin._clipboardHTML();if(html&&html.length>0)TinyMCE_PastePlugin._insertWordContent(html);}else{var template=new Array();template['file']='../../plugins/paste/pasteword.htm';template['width']=450;template['height']=400;var plain_text="";tinyMCE.openWindow(template,{editor_id:editor_id,plain_text:plain_text,resizable:"yes",scrollbars:"no",inline:"yes",mceDo:'insert'});}}else TinyMCE_PastePlugin._insertWordContent(value);return true;case"mceSelectAll":tinyMCE.execInstanceCommand(editor_id,'selectall');return true;}return false;},_handlePasteEvent:function(e){switch(e.type){case"paste":var html=TinyMCE_PastePlugin._clipboardHTML();var r,inst=tinyMCE.selectedInstance;if(inst&&(r=inst.getRng())&&r.text.length>0)tinyMCE.execCommand('delete');if(html&&html.length>0)tinyMCE.execCommand('mcePasteWord',false,html);tinyMCE.cancelEvent(e);return false;}return true;},_insertText:function(content,bLinebreaks){if(content&&content.length>0){if(bLinebreaks){if(tinyMCE.getParam("paste_create_paragraphs",true)){var rl=tinyMCE.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);content=tinyMCE.regexpReplace(content,"\r\n\r\n","</p><p>","gi");content=tinyMCE.regexpReplace(content,"\r\r","</p><p>","gi");content=tinyMCE.regexpReplace(content,"\n\n","</p><p>","gi");if((pos=content.indexOf('</p><p>'))!=-1){tinyMCE.execCommand("Delete");var node=tinyMCE.selectedInstance.getFocusElement();var breakElms=new Array();do{if(node.nodeType==1){if(node.nodeName=="TD"||node.nodeName=="BODY")break;breakElms[breakElms.length]=node;}}while(node=node.parentNode);var before="",after="</p>";before+=content.substring(0,pos);for(var i=0;i<breakElms.length;i++){before+="</"+breakElms[i].nodeName+">";after+="<"+breakElms[(breakElms.length-1)-i].nodeName+">";}before+="<p>";content=before+content.substring(pos+7)+after;}}if(tinyMCE.getParam("paste_create_linebreaks",true)){content=tinyMCE.regexpReplace(content,"\r\n","<br />","gi");content=tinyMCE.regexpReplace(content,"\r","<br />","gi");content=tinyMCE.regexpReplace(content,"\n","<br />","gi");}}tinyMCE.execCommand("mceInsertRawHTML",false,content);}},_insertWordContent:function(content){if(content&&content.length>0){var bull=String.fromCharCode(8226);var middot=String.fromCharCode(183);var cb;if((cb=tinyMCE.getParam("paste_insert_word_content_callback",""))!="")content=eval(cb+"('before', content)");var rl=tinyMCE.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);if(tinyMCE.getParam("paste_convert_headers_to_strong",false)){content=content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>','gi'),'<p><b>$1</b></p>');}content=content.replace(new RegExp('tab-stops: list [0-9]+.0pt">','gi'),'">'+"--list--");content=content.replace(new RegExp(bull+"(.*?)<BR>","gi"),"<p>"+middot+"$1</p>");content=content.replace(new RegExp('<SPAN style="mso-list: Ignore">','gi'),"<span>"+bull);content=content.replace(/<o:p><\/o:p>/gi,"");content=content.replace(new RegExp('<br style="page-break-before: always;.*>','gi'),'-- page break --');content=content.replace(new RegExp('<(!--)([^>]*)(--)>','g'),"");if(tinyMCE.getParam("paste_remove_spans",true))content=content.replace(/<\/?span[^>]*>/gi,"");if(tinyMCE.getParam("paste_remove_styles",true))content=content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)','gi'),"<$1$3");content=content.replace(/<\/?font[^>]*>/gi,"");switch(tinyMCE.getParam("paste_strip_class_attributes","all")){case"all":content=content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi,"<$1$3");break;case"mso":content=content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)','gi'),"<$1$3");break;}content=content.replace(new RegExp('href="?'+TinyMCE_PastePlugin._reEscape(""+document.location)+'','gi'),'href="'+tinyMCE.settings['document_base_url']);content=content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3");content=content.replace(/<\\?\?xml[^>]*>/gi,"");content=content.replace(/<\/?\w+:[^>]*>/gi,"");content=content.replace(/-- page break --\s*<p>&nbsp;<\/p>/gi,"");content=content.replace(/-- page break --/gi,"");if(!tinyMCE.settings['force_p_newlines']){content=content.replace('','','gi');content=content.replace('</p>','<br /><br />','gi');}if(!tinyMCE.isMSIE&&!tinyMCE.settings['force_p_newlines']){content=content.replace(/<\/?p[^>]*>/gi,"");}content=content.replace(/<\/?div[^>]*>/gi,"");if(tinyMCE.getParam("paste_convert_middot_lists",true)){var div=document.createElement("div");div.innerHTML=content;var className=tinyMCE.getParam("paste_unindented_list_class","unIndentedList");while(TinyMCE_PastePlugin._convertMiddots(div,"--list--"));while(TinyMCE_PastePlugin._convertMiddots(div,middot,className));while(TinyMCE_PastePlugin._convertMiddots(div,bull));content=div.innerHTML;}if(tinyMCE.getParam("paste_convert_headers_to_strong",false)){content=content.replace(/<h[1-6]>&nbsp;<\/h[1-6]>/gi,'<p>&nbsp;&nbsp;</p>');content=content.replace(/<h[1-6]>/gi,'<p><b>');content=content.replace(/<\/h[1-6]>/gi,'</b></p>');content=content.replace(/<b>&nbsp;<\/b>/gi,'<b>&nbsp;&nbsp;</b>');content=content.replace(/^(&nbsp;)*/gi,'');}content=content.replace(/--list--/gi,"");if((cb=tinyMCE.getParam("paste_insert_word_content_callback",""))!="")content=eval(cb+"('after', content)");tinyMCE.execCommand("mceInsertContent",false,content);window.setTimeout('tinyMCE.execCommand("mceCleanup");',1);}},_reEscape:function(s){var l="?.\\*[](){}+^$:";var o="";for(var i=0;i<s.length;i++){var c=s.charAt(i);if(l.indexOf(c)!=-1)o+='\\'+c;else o+=c;}return o;},_convertMiddots:function(div,search,class_name){var mdot=String.fromCharCode(183);var bull=String.fromCharCode(8226);var nodes=div.getElementsByTagName("p");var prevul;for(var i=0;i<nodes.length;i++){var p=nodes[i];if(p.innerHTML.indexOf(search)==0){var ul=document.createElement("ul");if(class_name)ul.className=class_name;var li=document.createElement("li");li.innerHTML=p.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--|&nbsp;',"gi"),'');ul.appendChild(li);var np=p.nextSibling;while(np){if(np.nodeType==3&&new RegExp('^\\s$','m').test(np.nodeValue)){np=np.nextSibling;continue;}if(search==mdot){if(np.nodeType==1&&new RegExp('^o(\\s+|&nbsp;)').test(np.innerHTML)){if(!prevul){prevul=ul;ul=document.createElement("ul");prevul.appendChild(ul);}np.innerHTML=np.innerHTML.replace(/^o/,'');}else{if(prevul){ul=prevul;prevul=null;}if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}}else{if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}var cp=np.nextSibling;var li=document.createElement("li");li.innerHTML=np.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--|&nbsp;',"gi"),'');np.parentNode.removeChild(np);ul.appendChild(li);np=cp;}p.parentNode.replaceChild(ul,p);return true;}}return false;},_clipboardHTML:function(){var div=document.getElementById('_TinyMCE_clipboardHTML');if(!div){var div=document.createElement('DIV');div.id='_TinyMCE_clipboardHTML';with(div.style){visibility='hidden';overflow='hidden';position='absolute';width=1;height=1;}document.body.appendChild(div);}div.innerHTML='';var rng=document.body.createTextRange();rng.moveToElementText(div);rng.execCommand('Paste');var html=div.innerHTML;div.innerHTML='';return html;}};tinyMCE.addPlugin("paste",TinyMCE_PastePlugin);
+/**
+ * $Id: editor_plugin_src.js 126 2006-10-22 16:19:55Z spocke $
+ *
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
+ */
+
+/* Import plugin specific language pack */
+tinyMCE.importPluginLanguagePack('paste');
+
+var TinyMCE_PastePlugin = {
+ getInfo : function() {
+ return {
+ longname : 'Paste text/word',
+ author : 'Moxiecode Systems AB',
+ authorurl : 'http://tinymce.moxiecode.com',
+ infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_paste.html',
+ version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
+ };
+ },
+
+ initInstance : function(inst) {
+ if (tinyMCE.isMSIE && tinyMCE.getParam("paste_auto_cleanup_on_paste", false))
+ tinyMCE.addEvent(inst.getBody(), "paste", TinyMCE_PastePlugin._handlePasteEvent);
+ },
+
+ getControlHTML : function(cn) {
+ switch (cn) {
+ case "pastetext":
+ return tinyMCE.getButtonHTML(cn, 'lang_paste_text_desc', '{$pluginurl}/images/pastetext.gif', 'mcePasteText', true);
+
+ case "pasteword":
+ return tinyMCE.getButtonHTML(cn, 'lang_paste_word_desc', '{$pluginurl}/images/pasteword.gif', 'mcePasteWord', true);
+
+ case "selectall":
+ return tinyMCE.getButtonHTML(cn, 'lang_selectall_desc', '{$pluginurl}/images/selectall.gif', 'mceSelectAll', true);
+ }
+
+ return '';
+ },
+
+ execCommand : function(editor_id, element, command, user_interface, value) {
+ switch (command) {
+ case "mcePasteText":
+ if (user_interface) {
+ if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && !tinyMCE.getParam('paste_use_dialog', false))
+ TinyMCE_PastePlugin._insertText(clipboardData.getData("Text"), true);
+ else {
+ var template = new Array();
+ template['file'] = '../../plugins/paste/pastetext.htm'; // Relative to theme
+ template['width'] = 450;
+ template['height'] = 400;
+ var plain_text = "";
+ tinyMCE.openWindow(template, {editor_id : editor_id, plain_text: plain_text, resizable : "yes", scrollbars : "no", inline : "yes", mceDo : 'insert'});
+ }
+ } else
+ TinyMCE_PastePlugin._insertText(value['html'], value['linebreaks']);
+
+ return true;
+
+ case "mcePasteWord":
+ if (user_interface) {
+ if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && !tinyMCE.getParam('paste_use_dialog', false)) {
+ TinyMCE_PastePlugin._insertWordContent(TinyMCE_PastePlugin._clipboardHTML());
+ } else {
+ var template = new Array();
+ template['file'] = '../../plugins/paste/pasteword.htm'; // Relative to theme
+ template['width'] = 450;
+ template['height'] = 400;
+ var plain_text = "";
+ tinyMCE.openWindow(template, {editor_id : editor_id, plain_text: plain_text, resizable : "yes", scrollbars : "no", inline : "yes", mceDo : 'insert'});
+ }
+ } else
+ TinyMCE_PastePlugin._insertWordContent(value);
+
+ return true;
+
+ case "mceSelectAll":
+ tinyMCE.execInstanceCommand(editor_id, 'selectall');
+ return true;
+
+ }
+
+ // Pass to next handler in chain
+ return false;
+ },
+
+ // Private plugin internal methods
+
+ _handlePasteEvent : function(e) {
+ switch (e.type) {
+ case "paste":
+ var html = TinyMCE_PastePlugin._clipboardHTML();
+ var r, inst = tinyMCE.selectedInstance;
+
+ // Removes italic, strong etc, the if was needed due to bug #1437114
+ if (inst && (r = inst.getRng()) && r.text.length > 0)
+ tinyMCE.execCommand('delete');
+
+ if (html && html.length > 0)
+ tinyMCE.execCommand('mcePasteWord', false, html);
+
+ tinyMCE.cancelEvent(e);
+ return false;
+ }
+
+ return true;
+ },
+
+ _insertText : function(content, bLinebreaks) {
+ if (content && content.length > 0) {
+ if (bLinebreaks) {
+ // Special paragraph treatment
+ if (tinyMCE.getParam("paste_create_paragraphs", true)) {
+ var rl = tinyMCE.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');
+ for (var i=0; i<rl.length; i+=2)
+ content = content.replace(new RegExp(rl[i], 'gi'), rl[i+1]);
+
+ content = tinyMCE.regexpReplace(content, "\r\n\r\n", "</p><p>", "gi");
+ content = tinyMCE.regexpReplace(content, "\r\r", "</p><p>", "gi");
+ content = tinyMCE.regexpReplace(content, "\n\n", "</p><p>", "gi");
+
+ // Has paragraphs
+ if ((pos = content.indexOf('</p><p>')) != -1) {
+ tinyMCE.execCommand("Delete");
+
+ var node = tinyMCE.selectedInstance.getFocusElement();
+
+ // Get list of elements to break
+ var breakElms = new Array();
+
+ do {
+ if (node.nodeType == 1) {
+ // Don't break tables and break at body
+ if (node.nodeName == "TD" || node.nodeName == "BODY")
+ break;
+
+ breakElms[breakElms.length] = node;
+ }
+ } while(node = node.parentNode);
+
+ var before = "", after = "</p>";
+ before += content.substring(0, pos);
+
+ for (var i=0; i<breakElms.length; i++) {
+ before += "</" + breakElms[i].nodeName + ">";
+ after += "<" + breakElms[(breakElms.length-1)-i].nodeName + ">";
+ }
+
+ before += "<p>";
+ content = before + content.substring(pos+7) + after;
+ }
+ }
+
+ if (tinyMCE.getParam("paste_create_linebreaks", true)) {
+ content = tinyMCE.regexpReplace(content, "\r\n", "<br />", "gi");
+ content = tinyMCE.regexpReplace(content, "\r", "<br />", "gi");
+ content = tinyMCE.regexpReplace(content, "\n", "<br />", "gi");
+ }
+ }
+
+ tinyMCE.execCommand("mceInsertRawHTML", false, content);
+ }
+ },
+
+ _insertWordContent : function(content) {
+ if (content && content.length > 0) {
+ // Cleanup Word content
+ var bull = String.fromCharCode(8226);
+ var middot = String.fromCharCode(183);
+ var cb;
+
+ if ((cb = tinyMCE.getParam("paste_insert_word_content_callback", "")) != "")
+ content = eval(cb + "('before', content)");
+
+ var rl = tinyMCE.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');
+ for (var i=0; i<rl.length; i+=2)
+ content = content.replace(new RegExp(rl[i], 'gi'), rl[i+1]);
+
+ if (tinyMCE.getParam("paste_convert_headers_to_strong", false)) {
+ content = content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>', 'gi'), '<p><b>$1</b></p>');
+ }
+
+ content = content.replace(new RegExp('tab-stops: list [0-9]+.0pt">', 'gi'), '">' + "--list--");
+ content = content.replace(new RegExp(bull + "(.*?)<BR>", "gi"), "<p>" + middot + "$1</p>");
+ content = content.replace(new RegExp('<SPAN style="mso-list: Ignore">', 'gi'), "<span>" + bull); // Covert to bull list
+ content = content.replace(/<o:p><\/o:p>/gi, "");
+ content = content.replace(new RegExp('<br style="page-break-before: always;.*>', 'gi'), '-- page break --'); // Replace pagebreaks
+ content = content.replace(new RegExp('<(!--)([^>]*)(--)>', 'g'), ""); // Word comments
+
+ if (tinyMCE.getParam("paste_remove_spans", true))
+ content = content.replace(/<\/?span[^>]*>/gi, "");
+
+ if (tinyMCE.getParam("paste_remove_styles", true))
+ content = content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)', 'gi'), "<$1$3");
+
+ content = content.replace(/<\/?font[^>]*>/gi, "");
+
+ // Strips class attributes.
+ switch (tinyMCE.getParam("paste_strip_class_attributes", "all")) {
+ case "all":
+ content = content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3");
+ break;
+
+ case "mso":
+ content = content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)', 'gi'), "<$1$3");
+ break;
+ }
+
+ content = content.replace(new RegExp('href="?' + TinyMCE_PastePlugin._reEscape("" + document.location) + '', 'gi'), 'href="' + tinyMCE.settings['document_base_url']);
+ content = content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3");
+ content = content.replace(/<\\?\?xml[^>]*>/gi, "");
+ content = content.replace(/<\/?\w+:[^>]*>/gi, "");
+ content = content.replace(/-- page break --\s*<p>&nbsp;<\/p>/gi, ""); // Remove pagebreaks
+ content = content.replace(/-- page break --/gi, ""); // Remove pagebreaks
+
+ // content = content.replace(/\/?&nbsp;*/gi, ""); &nbsp;
+ // content = content.replace(/<p>&nbsp;<\/p>/gi, '');
+
+ if (!tinyMCE.settings['force_p_newlines']) {
+ content = content.replace('', '' ,'gi');
+ content = content.replace('</p>', '<br /><br />' ,'gi');
+ }
+
+ if (!tinyMCE.isMSIE && !tinyMCE.settings['force_p_newlines']) {
+ content = content.replace(/<\/?p[^>]*>/gi, "");
+ }
+
+ content = content.replace(/<\/?div[^>]*>/gi, "");
+
+ // Convert all middlot lists to UL lists
+ if (tinyMCE.getParam("paste_convert_middot_lists", true)) {
+ var div = document.createElement("div");
+ div.innerHTML = content;
+
+ // Convert all middot paragraphs to li elements
+ var className = tinyMCE.getParam("paste_unindented_list_class", "unIndentedList");
+
+ while (TinyMCE_PastePlugin._convertMiddots(div, "--list--")) ; // bull
+ while (TinyMCE_PastePlugin._convertMiddots(div, middot, className)) ; // Middot
+ while (TinyMCE_PastePlugin._convertMiddots(div, bull)) ; // bull
+
+ content = div.innerHTML;
+ }
+
+ // Replace all headers with strong and fix some other issues
+ if (tinyMCE.getParam("paste_convert_headers_to_strong", false)) {
+ content = content.replace(/<h[1-6]>&nbsp;<\/h[1-6]>/gi, '<p>&nbsp;&nbsp;</p>');
+ content = content.replace(/<h[1-6]>/gi, '<p><b>');
+ content = content.replace(/<\/h[1-6]>/gi, '</b></p>');
+ content = content.replace(/<b>&nbsp;<\/b>/gi, '<b>&nbsp;&nbsp;</b>');
+ content = content.replace(/^(&nbsp;)*/gi, '');
+ }
+
+ content = content.replace(/--list--/gi, ""); // Remove --list--
+
+ if ((cb = tinyMCE.getParam("paste_insert_word_content_callback", "")) != "")
+ content = eval(cb + "('after', content)");
+
+ // Insert cleaned content
+ tinyMCE.execCommand("mceInsertContent", false, content);
+
+ if (tinyMCE.getParam('paste_force_cleanup_wordpaste', true))
+ window.setTimeout('tinyMCE.execCommand("mceCleanup");', 1); // Do normal cleanup detached from this thread
+ }
+ },
+
+ _reEscape : function(s) {
+ var l = "?.\\*[](){}+^$:";
+ var o = "";
+
+ for (var i=0; i<s.length; i++) {
+ var c = s.charAt(i);
+
+ if (l.indexOf(c) != -1)
+ o += '\\' + c;
+ else
+ o += c;
+ }
+
+ return o;
+ },
+
+ _convertMiddots : function(div, search, class_name) {
+ var mdot = String.fromCharCode(183);
+ var bull = String.fromCharCode(8226);
+
+ var nodes = div.getElementsByTagName("p");
+ var prevul;
+ for (var i=0; i<nodes.length; i++) {
+ var p = nodes[i];
+
+ // Is middot
+ if (p.innerHTML.indexOf(search) == 0) {
+ var ul = document.createElement("ul");
+
+ if (class_name)
+ ul.className = class_name;
+
+ // Add the first one
+ var li = document.createElement("li");
+ li.innerHTML = p.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--|&nbsp;', "gi"), '');
+ ul.appendChild(li);
+
+ // Add the rest
+ var np = p.nextSibling;
+ while (np) {
+ // If the node is whitespace, then
+ // ignore it and continue on.
+ if (np.nodeType == 3 && new RegExp('^\\s$', 'm').test(np.nodeValue)) {
+ np = np.nextSibling;
+ continue;
+ }
+
+ if (search == mdot) {
+ if (np.nodeType == 1 && new RegExp('^o(\\s+|&nbsp;)').test(np.innerHTML)) {
+ // Second level of nesting
+ if (!prevul) {
+ prevul = ul;
+ ul = document.createElement("ul");
+ prevul.appendChild(ul);
+ }
+ np.innerHTML = np.innerHTML.replace(/^o/, '');
+ } else {
+ // Pop the stack if we're going back up to the first level
+ if (prevul) {
+ ul = prevul;
+ prevul = null;
+ }
+ // Not element or middot paragraph
+ if (np.nodeType != 1 || np.innerHTML.indexOf(search) != 0)
+ break;
+ }
+ } else {
+ // Not element or middot paragraph
+ if (np.nodeType != 1 || np.innerHTML.indexOf(search) != 0)
+ break;
+ }
+
+ var cp = np.nextSibling;
+ var li = document.createElement("li");
+ li.innerHTML = np.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--|&nbsp;', "gi"), '');
+ np.parentNode.removeChild(np);
+ ul.appendChild(li);
+ np = cp;
+ }
+
+ p.parentNode.replaceChild(ul, p);
+
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ _clipboardHTML : function() {
+ var div = document.getElementById('_TinyMCE_clipboardHTML');
+
+ if (!div) {
+ var div = document.createElement('DIV');
+ div.id = '_TinyMCE_clipboardHTML';
+
+ with (div.style) {
+ visibility = 'hidden';
+ overflow = 'hidden';
+ position = 'absolute';
+ width = 1;
+ height = 1;
+ }
+
+ document.body.appendChild(div);
+ }
+
+ div.innerHTML = '';
+ var rng = document.body.createTextRange();
+ rng.moveToElementText(div);
+ rng.execCommand('Paste');
+ var html = div.innerHTML;
+ div.innerHTML = '';
+ return html;
+ }
+};
+
+tinyMCE.addPlugin("paste", TinyMCE_PastePlugin);
+
diff --git a/wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js b/wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js
index 927745b..4c07691 100644
--- a/wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js
+++ b/wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js
@@ -15,6 +15,10 @@ function saveContent() {
function onLoadInit() {
tinyMCEPopup.resizeToInnerSize();
+ // Remove Gecko spellchecking
+ if (tinyMCE.isGecko)
+ document.body.spellcheck = tinyMCE.getParam("gecko_spellcheck");
+
resizeInputs();
}
diff --git a/wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js b/wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js
index c56ea81..b243a10 100644
--- a/wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js
+++ b/wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js
@@ -25,7 +25,13 @@ var wHeight=0, wWidth=0, owHeight=0, owWidth=0;
function initIframe(doc) {
var dir = tinyMCE.selectedInstance.settings['directionality'];
+
doc.body.dir = dir;
+
+ // Remove Gecko spellchecking
+ if (tinyMCE.isGecko)
+ doc.body.spellcheck = tinyMCE.getParam("gecko_spellcheck");
+
resizeInputs();
}
diff --git a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
index a596b83..ede6576 100644
--- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
@@ -575,7 +575,7 @@ function wpautop(pee) {
pee = pee.replace(new RegExp('(</(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])>)', 'gi'), "$1\n\n");
pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n");
pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n");
- pee = pee.replace(new RegExp('\n*([^\Z]+?)\\n{2}', 'mg'), "<p>$1</p>\n");
+ pee = pee.replace(new RegExp('([\\s\\S]+?)\\n\\n', 'mg'), "<p>$1</p>\n");
pee = pee.replace(new RegExp('<p>\\s*?</p>', 'gi'), '');
pee = pee.replace(new RegExp('<p>\\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\\s*</p>', 'gi'), "$1");
pee = pee.replace(new RegExp("<p>(<li.+?)</p>", 'gi'), "$1");
diff --git a/wp-includes/js/tinymce/themes/advanced/charmap.htm b/wp-includes/js/tinymce/themes/advanced/charmap.htm
index 9dac168..fbd472b 100644
--- a/wp-includes/js/tinymce/themes/advanced/charmap.htm
+++ b/wp-includes/js/tinymce/themes/advanced/charmap.htm
@@ -6,7 +6,7 @@
<script language="javascript" type="text/javascript" src="jscripts/charmap.js"></script>
<base target="_self" />
</head>
-<body onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('insert').focus();" style="display: none">
+<body onload="tinyMCEPopup.executeOnLoad('init();');" 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-includes/js/tinymce/themes/advanced/color_picker.htm b/wp-includes/js/tinymce/themes/advanced/color_picker.htm
index 725466e..e5fdc9f 100644
--- a/wp-includes/js/tinymce/themes/advanced/color_picker.htm
+++ b/wp-includes/js/tinymce/themes/advanced/color_picker.htm
@@ -5,7 +5,7 @@
<script language="javascript" type="text/javascript" src="jscripts/color_picker.js"></script>
<base target="_self" />
</head>
-<body onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('insert').focus();" style="margin: 3px; display: none">
+<body onload="tinyMCEPopup.executeOnLoad('init();');" style="margin: 3px; display: none">
<div align="center">
<script language="javascript" type="text/javascript">renderColorMap();</script>
</div>
diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_content.css b/wp-includes/js/tinymce/themes/advanced/css/editor_content.css
index 11f75df..182e791 100644
--- a/wp-includes/js/tinymce/themes/advanced/css/editor_content.css
+++ b/wp-includes/js/tinymce/themes/advanced/css/editor_content.css
@@ -14,6 +14,11 @@ body {
border: 1px dashed #BBBBBB !important;
}
+div.mceVisualAid {
+ background-image:url('../images/spacer.gif');
+ visibility: visible !important;
+}
+
.mceItemAnchor {
width: 12px;
line-height: 6px;
diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css b/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css
index 3b42925..079470c 100644
--- a/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css
+++ b/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css
@@ -312,6 +312,10 @@ h3 {
height: 190px;
}
+label.msg { display: none; }
+label.invalid { color: #EE0000; display: inline; }
+input.invalid { border: 1px solid #EE0000; }
+
/* Disables the advanced tab in the table plugin. */
/*
#table #advanced_tab {
diff --git a/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css b/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css
index 04fccc7..e70405d 100644
--- a/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css
+++ b/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css
@@ -1,348 +1,97 @@
/* 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: 0; margin: 0; padding: 0; background: transparent;
-}
-
-.mceSeparatorLine {
- border: 0;
- padding: 0;
- margin-left: 4px;
- margin-right: 2px;
-}
-
-.mceSelectList {
- font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
- font-size: 7pt !important;
- font-weight: normal;
- margin-top: 3px;
- padding: 0;
- display: inline;
- vertical-align: top;
- background-color: #F0F0EE;
-}
-
-.mceLabel, .mceLabelDisabled {
- font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
- font-size: 9pt;
-}
-
-.mceLabel {
- color: #000000;
-}
-
-.mceLabelDisabled {
- cursor: text;
- color: #999999;
-}
-
-.mceEditor {
- background: #F0F0EE;
- border: 1px solid #cccccc;
- padding: 0;
- margin: 0;
-}
-
-.mceEditorArea {
- font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
- background: #FFFFFF;
- padding: 0;
- margin: 0;
-}
-
-.mceToolbarTop, .mceToolbarBottom {
- background: #F0F0EE;
- line-height: 1px;
- font-size: 1px;
-}
-
-.mceToolbarTop {
- border-bottom: 1px solid #cccccc;
- padding-bottom: 1px;
-}
-
-.mceToolbarBottom {
- border-top: 1px solid #cccccc;
-}
-
-.mceStatusbarTop, .mceStatusbarBottom, .mceStatusbar {
- height: 20px;
-}
-
-.mceStatusbarTop .mceStatusbarPathText, .mceStatusbarBottom .mceStatusbarPathText, .mceStatusbar .mceStatusbarPathText {
- font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
- font-size: 9pt;
- padding: 2px;
- line-height: 16px;
- overflow: visible;
-}
-
-.mceStatusbarTop {
- border-bottom: 1px solid #cccccc;
-}
-
-.mceStatusbarBottom {
- border-top: 1px solid #cccccc;
-}
-
-.mceStatusbar {
- border-bottom: 1px solid #cccccc;
-}
-
-.mcePathItem, .mcePathItem:link, .mcePathItem:visited, .mcePathItem:hover {
- text-decoration: none;
- font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
- font-size: 9pt;
- color: #000000;
-}
-
-.mcePathItem:hover {
- text-decoration: underline;
-}
-
-.mceStatusbarPathText {
- float: left;
-}
-
-.mceStatusbarResize {
- float: right;
- background-image: url('../images/statusbar_resize.gif');
- background-repeat: no-repeat;
- width: 11px;
- height: 20px;
- cursor: se-resize;
-}
-
-.mceResizeBox {
- width: 10px;
- height: 10px;
- display: none;
- border: 1px dotted gray;
- margin: 0;
- padding: 0;
-}
+.mceToolbarTop a, .mceToolbarTop a:visited, .mceToolbarTop a:hover, .mceToolbarBottom a, .mceToolbarBottom a:visited, .mceToolbarBottom a:hover {border: 0; margin: 0; padding: 0; background: transparent;}
+.mceSeparatorLine {border: 0; padding: 0; margin-left: 4px; margin-right: 2px;}
+.mceSelectList {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 7pt !important; font-weight: normal; margin-top: 3px; padding: 0; display: inline; vertical-align: top; background-color: #F0F0EE;}
+.mceLabel, .mceLabelDisabled {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt;}
+.mceLabel {color: #000000;}
+.mceLabelDisabled {cursor: text; color: #999999;}
+.mceEditor {background: #F0F0EE; border: 1px solid #cccccc; padding: 0; margin: 0;}
+.mceEditorArea { font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; background: #FFFFFF; padding: 0; margin: 0; }
+.mceToolbarTop, .mceToolbarBottom {background: #F0F0EE; line-height: 1px; font-size: 1px;}
+.mceToolbarTop {border-bottom: 1px solid #cccccc; padding-bottom: 1px;}
+.mceToolbarBottom {border-top: 1px solid #cccccc;}
+.mceToolbarContainer {position: relative; left: 0; top: 0; display: block;}
+.mceStatusbarTop, .mceStatusbarBottom, .mceStatusbar {height: 20px;}
+.mceStatusbarTop .mceStatusbarPathText, .mceStatusbarBottom .mceStatusbarPathText, .mceStatusbar .mceStatusbarPathText {font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt; padding: 2px; line-height: 16px; overflow: visible;}
+.mceStatusbarTop {border-bottom: 1px solid #cccccc;}
+.mceStatusbarBottom {border-top: 1px solid #cccccc;}
+.mceStatusbar {border-bottom: 1px solid #cccccc;}
+.mcePathItem, .mcePathItem:link, .mcePathItem:visited, .mcePathItem:hover {text-decoration: none; font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; font-size: 9pt; color: #000000;}
+.mcePathItem:hover {text-decoration: underline;}
+.mceStatusbarPathText {float: left;}
+.mceStatusbarResize {float: right; background-image: url('../images/statusbar_resize.gif'); background-repeat: no-repeat; width: 11px; height: 20px; cursor: se-resize;}
+.mceResizeBox {width: 10px; height: 10px; display: none; border: 1px dotted gray; margin: 0; padding: 0;}
+.mceEditorIframe {border: 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;
-}
+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;}
/* 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;
-}
+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;}
+span.mceMenuHover img {border: 1px solid #0A246A; background-color: #B6BDD2;}
+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;
-}
+.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; text-decoration: none !important;}
+.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;}
+.mceColors table, .mceColors td {margin: 0; padding: 2px;}
+a.mceMoreColors {width: 130px; margin: 0; padding: 0; margin-left: 3px; margin-bottom: 3px; text-align: center; border: 1px solid white;}
+.mceColorPreview {position: absolute; left: 0; top: 0; margin-left: 3px; margin-top: 15px; width: 16px; height: 4px; background-color: red;}
+a.mceMoreColors:hover {border: 1px solid #0A246A;}
+.mceColors td a {width: 9px; height: 9px; overflow: hidden; border: 1px solid #808080;}
+
+/* MSIE 6 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; background-color: #B6BDD2; cursor: default;}
+* html .mceSelectList {margin-top: 2px;}
+* 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 a.mceMoreColors {width: 132px;}
+* html .mceColors td a {width: 10px; height: 10px;}
+* html .mceColorPreview {margin-left: 2px; margin-top: 14px;}
+
+/* MSIE 7 specific rules */
+
+*:first-child+html a.mceButtonNormal img, *:first-child+html a.mceButtonSelected img, *:first-child+html a.mceButtonDisabled img {border: 0 !important; margin-top: 2px; margin-bottom: 1px;}
+*:first-child+html a.mceButtonDisabled img {filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30); border: 0 !important;}
+*:first-child+html a.mceButtonDisabled {border: 1px solid #F0F0EE !important;}
+*:first-child+html a.mceButtonNormal, *:first-child+html a.mceButtonSelected {border: 1px solid #F0F0EE !important; cursor: default;}
+*:first-child+html a.mceButtonSelected {border: 1px solid #6779AA !important; background-color: #D4D5D8;}
+*:first-child+html a.mceButtonNormal:hover, *:first-child+html a.mceButtonSelected:hover {border: 1px solid #0A246A !important; background-color: #B6BDD2; cursor: default;}
+*:first-child+html .mceSelectList {margin-top: 2px;}
+*:first-child+html span.mceMenuButton, *:first-child+html span.mceMenuButtonFocus {position: relative; left: 0; top: 0;}
+*:first-child+html span.mceMenuButton img, *:first-child+html span.mceMenuButtonSelected img, *:first-child+html span.mceMenuButtonFocus img {position: relative; top: 1px;}
+*:first-child+html a.mceMoreColors {width: 132px;}
+*:first-child+html .mceColors td a {width: 10px; height: 10px;}
+*:first-child+html .mceColorPreview {margin: 0; padding-left: 4px; margin-top: 14px; width: 14px;}
diff --git a/wp-includes/js/tinymce/themes/advanced/editor_template.js b/wp-includes/js/tinymce/themes/advanced/editor_template.js
index 052914e..2285832 100644
--- a/wp-includes/js/tinymce/themes/advanced/editor_template.js
+++ b/wp-includes/js/tinymce/themes/advanced/editor_template.js
@@ -1,7 +1,5 @@
/**
- * $RCSfile: editor_template_src.js,v $
- * $Revision: 1.96 $
- * $Date: 2006/04/18 13:32:52 $
+ * $Id: editor_template_src.js 129 2006-10-23 09:45:17Z spocke $
*
* @author Moxiecode
* @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
@@ -12,6 +10,7 @@ tinyMCE.importThemeLanguagePack('advanced');
var TinyMCE_AdvancedTheme = {
// Private theme fields
+ _defColors : "000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF",
_autoImportCSSClasses : true,
_resizer : {},
_buttons : [
@@ -43,25 +42,28 @@ var TinyMCE_AdvancedTheme = {
['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],
+ ['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'forecolor', true],
+ ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'HiliteColor', 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',
+ _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,delete_table',
/**
* Returns HTML code for the specificed control.
*/
getControlHTML : function(button_name) {
- var i, x;
+ var i, x, but;
// Lookup button in button list
for (i=0; i<TinyMCE_AdvancedTheme._buttons.length; i++) {
- var but = TinyMCE_AdvancedTheme._buttons[i];
+ but = TinyMCE_AdvancedTheme._buttons[i];
+
+ if (but[0] == button_name && (button_name == "forecolor" || button_name == "backcolor"))
+ return tinyMCE.getMenuButtonHTML(but[0], but[2], '{$themeurl}/images/' + but[1], but[3] + "Menu", but[3], (but.length > 4 ? but[4] : false), (but.length > 5 ? but[5] : null));
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));
@@ -153,6 +155,18 @@ var TinyMCE_AdvancedTheme = {
*/
execCommand : function(editor_id, element, command, user_interface, value) {
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 true;
+
case "mceLink":
var inst = tinyMCE.getInstanceById(editor_id);
var doc = inst.getDoc();
@@ -317,41 +331,94 @@ var TinyMCE_AdvancedTheme = {
return true;
- case "mceForeColor":
- var template = new Array();
- var elm = tinyMCE.selectedInstance.getFocusElement();
- var inputColor = tinyMCE.getAttrib(elm, "color");
+ case "forecolor":
+ var fcp = new TinyMCE_Layer(editor_id + '_fcPreview', false), p, img, elm;
+
+ TinyMCE_AdvancedTheme._hideMenus(editor_id);
+
+ if (!fcp.exists()) {
+ fcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar'));
+ elm = fcp.getElement();
+ elm._editor_id = editor_id;
+ elm._command = "forecolor";
+ elm._switchId = editor_id + "_forecolor";
+ tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent);
+ tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent);
+ tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent);
+ }
+
+ img = tinyMCE.selectNodes(document.getElementById(editor_id + "_forecolor"), function(n) {return n.nodeName == "IMG";})[0];
+ p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar'));
+
+ fcp.moveTo(p.absLeft, p.absTop);
+ fcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).foreColor;
+ fcp.show();
+
+ return false;
+
+ case "forecolorMenu":
+ TinyMCE_AdvancedTheme._hideMenus(editor_id);
+
+ // Create color layer
+ var ml = new TinyMCE_Layer(editor_id + '_fcMenu');
- if (inputColor == '')
- inputColor = elm.style.color;
+ if (!ml.exists())
+ ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_text_colors', 'forecolor'));
- if (!inputColor)
- inputColor = "#000000";
+ tinyMCE.switchClass(editor_id + '_forecolor', 'mceMenuButtonFocus');
+ ml.moveRelativeTo(document.getElementById(editor_id + "_forecolor"), 'bl');
- template['file'] = 'color_picker.htm';
- template['width'] = 220;
- template['height'] = 190;
+ ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1);
- tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "forecolor", input_color : inputColor});
+ if (tinyMCE.isOpera)
+ ml.moveBy(0, -2);
+
+ ml.show();
return true;
- case "mceBackColor":
- var template = new Array();
- var elm = tinyMCE.selectedInstance.getFocusElement();
- var inputColor = elm.style.backgroundColor;
+ case "HiliteColor":
+ var bcp = new TinyMCE_Layer(editor_id + '_bcPreview', false), p, img;
+
+ TinyMCE_AdvancedTheme._hideMenus(editor_id);
+
+ if (!bcp.exists()) {
+ bcp.create('div', 'mceColorPreview', document.getElementById(editor_id + '_toolbar'));
+ elm = bcp.getElement();
+ elm._editor_id = editor_id;
+ elm._command = "HiliteColor";
+ elm._switchId = editor_id + "_backcolor";
+ tinyMCE.addEvent(elm, 'click', TinyMCE_AdvancedTheme._handleMenuEvent);
+ tinyMCE.addEvent(elm, 'mouseover', TinyMCE_AdvancedTheme._handleMenuEvent);
+ tinyMCE.addEvent(elm, 'mouseout', TinyMCE_AdvancedTheme._handleMenuEvent);
+ }
+
+ img = tinyMCE.selectNodes(document.getElementById(editor_id + "_backcolor"), function(n) {return n.nodeName == "IMG";})[0];
+ p = tinyMCE.getAbsPosition(img, document.getElementById(editor_id + '_toolbar'));
+
+ bcp.moveTo(p.absLeft, p.absTop);
+ bcp.getElement().style.backgroundColor = value != null ? value : tinyMCE.getInstanceById(editor_id).backColor;
+ bcp.show();
+
+ return false;
+
+ case "HiliteColorMenu":
+ TinyMCE_AdvancedTheme._hideMenus(editor_id);
+
+ // Create color layer
+ var ml = new TinyMCE_Layer(editor_id + '_bcMenu');
+
+ if (!ml.exists())
+ ml.create('div', 'mceMenu', document.body, TinyMCE_AdvancedTheme._getColorHTML(editor_id, 'theme_advanced_background_colors', 'HiliteColor'));
- if (!inputColor)
- inputColor = "#000000";
+ tinyMCE.switchClass(editor_id + '_backcolor', 'mceMenuButtonFocus');
+ ml.moveRelativeTo(document.getElementById(editor_id + "_backcolor"), 'bl');
- template['file'] = 'color_picker.htm';
- template['width'] = 220;
- template['height'] = 190;
+ ml.moveBy(tinyMCE.isMSIE && !tinyMCE.isOpera ? -1 : 1, -1);
- template['width'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width', 0);
- template['height'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height', 0);
+ if (tinyMCE.isOpera)
+ ml.moveBy(0, -2);
- tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "HiliteColor", input_color : inputColor});
- //mceBackColor
+ ml.show();
return true;
case "mceColorPicker":
@@ -433,7 +500,7 @@ var TinyMCE_AdvancedTheme = {
*/
getEditorTemplate : function(settings, editorId) {
function removeFromArray(in_array, remove_array) {
- var outArray = new Array();
+ var outArray = new Array(), skip;
for (var i=0; i<in_array.length; i++) {
skip = false;
@@ -530,10 +597,10 @@ var TinyMCE_AdvancedTheme = {
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>';
+ template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width_style};height:{$height_style}"><tbody>';
if (toolbarLocation == "top") {
- template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap">' + toolbarHTML + '</td></tr>';
+ template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
}
if (statusbarLocation == "top") {
@@ -544,7 +611,7 @@ var TinyMCE_AdvancedTheme = {
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>';
+ template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1"><span id="' + editorId + '_toolbar" class="mceToolbarContainer">' + toolbarHTML + '</span></td></tr>';
}
// External toolbar changes
@@ -615,9 +682,10 @@ var TinyMCE_AdvancedTheme = {
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++) {
+ curContainer = removeFromArray(curContainer, tinyMCE.getParam("theme_advanced_disable", "", true, ','));
+
+ for (var j=0; j<curContainer.length; j++)
curContainerHTML += tinyMCE.getControlHTML(curContainer[j]);
- }
if (curContainer.length > 0) {
curContainerHTML += "<br />";
@@ -664,10 +732,34 @@ var TinyMCE_AdvancedTheme = {
inst.addShortcut('ctrl', 'k', 'lang_link_desc', 'mceLink');
},
+ _handleMenuEvent : function(e) {
+ var te = tinyMCE.isMSIE ? window.event.srcElement : e.target;
+ tinyMCE._menuButtonEvent(e.type == "mouseover" ? "over" : "out", document.getElementById(te._switchId));
+
+ if (e.type == "click")
+ tinyMCE.execInstanceCommand(te._editor_id, te._command);
+ },
+
+ _hideMenus : function(id) {
+ var fcml = new TinyMCE_Layer(id + '_fcMenu'), bcml = new TinyMCE_Layer(id + '_bcMenu');
+
+ if (fcml.exists() && fcml.isVisible()) {
+ tinyMCE.switchClass(id + '_forecolor', 'mceMenuButton');
+ fcml.hide();
+ }
+
+ if (bcml.exists() && bcml.isVisible()) {
+ tinyMCE.switchClass(id + '_backcolor', 'mceMenuButton');
+ bcml.hide();
+ }
+ },
+
/**
* Node change handler.
*/
handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection, setup_content) {
+ var alignNode, breakOut, classNode;
+
function selectByValue(select_elm, value, first_index) {
first_index = typeof(first_index) == "undefined" ? false : true;
@@ -702,6 +794,7 @@ var TinyMCE_AdvancedTheme = {
var pathElm = document.getElementById(editor_id + "_path");
var inst = tinyMCE.getInstanceById(editor_id);
var doc = inst.getDoc();
+ TinyMCE_AdvancedTheme._hideMenus(editor_id);
if (pathElm) {
// Get node path
@@ -727,6 +820,9 @@ var TinyMCE_AdvancedTheme = {
var nodeName = path[i].nodeName.toLowerCase();
var nodeData = "";
+ if (nodeName.indexOf("html:") == 0)
+ nodeName = nodeName.substring(5);
+
if (nodeName == "b") {
nodeName = "strong";
}
@@ -781,7 +877,7 @@ var TinyMCE_AdvancedTheme = {
nodeData += "src: " + src + " ";
}
- if (getAttrib(path[i], 'href') != "") {
+ if (path[i].nodeName == 'A' && getAttrib(path[i], 'href') != "") {
var href = tinyMCE.getAttrib(path[i], "mce_href");
if (href == "")
@@ -790,9 +886,10 @@ var TinyMCE_AdvancedTheme = {
nodeData += "href: " + href + " ";
}
- if (nodeName == "img" && tinyMCE.getAttrib(path[i], "class").indexOf('mceItemFlash') != -1) {
- nodeName = "flash";
- nodeData = "src: " + path[i].getAttribute('title');
+ className = tinyMCE.getAttrib(path[i], "class");
+ if ((nodeName == "img" || nodeName == "span") && className.indexOf('mceItem') != -1) {
+ nodeName = className.replace(/mceItem([a-z]+)/gi, '$1').toLowerCase();
+ nodeData = path[i].getAttribute('title');
}
if (nodeName == "a" && (anchor = tinyMCE.getAttrib(path[i], "name")) != "") {
@@ -1027,7 +1124,7 @@ var TinyMCE_AdvancedTheme = {
break;
case "IMG":
- if (getAttrib(node, 'name').indexOf('mce_') != 0) {
+ if (getAttrib(node, 'name').indexOf('mce_') != 0 && tinyMCE.getAttrib(node, 'class').indexOf('mceItem') == -1) {
tinyMCE.switchClass(editor_id + '_image', 'mceButtonSelected');
}
break;
@@ -1148,6 +1245,9 @@ var TinyMCE_AdvancedTheme = {
inst.iframeElement.style.width = (iw + dx) + "px";
}
}
+
+ // Remove pesky table controls
+ inst.useCSS = false;
},
/**
@@ -1255,6 +1355,29 @@ var TinyMCE_AdvancedTheme = {
}
},
+ _getColorHTML : function(id, n, cm) {
+ var i, h, cl;
+
+ h = '<span class="mceMenuLine"></span>';
+ cl = tinyMCE.getParam(n, TinyMCE_AdvancedTheme._defColors).split(',');
+
+ h += '<table class="mceColors"><tr>';
+ for (i=0; i<cl.length; i++) {
+ c = 'tinyMCE.execInstanceCommand(\'' + id + '\', \'' + cm + '\', false, \'#' + cl[i] + '\');';
+ h += '<td><a href="javascript:' + c + '" style="background-color: #' + cl[i] + '" onclick="' + c + ';return false;"></a></td>';
+
+ if ((i+1) % 8 == 0)
+ h += '</tr><tr>';
+ }
+
+ h += '</tr></table>';
+ /*
+ h += '<a href="" class="mceMoreColors">More colors</a>';
+ */
+
+ return h;
+ },
+
_insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) {
tinyMCE.execCommand('mceBeginUndoLevel');
diff --git a/wp-includes/js/tinymce/themes/advanced/editor_template_src.js b/wp-includes/js/tinymce/themes/advanced/editor_template_src.js
deleted file mode 100644
index e69de29..0000000
--- a/wp-includes/js/tinymce/themes/advanced/editor_template_src.js
+++ /dev/null
diff --git a/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif b/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif
index 8a532e5..d03e206 100644
--- a/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif
+++ b/wp-includes/js/tinymce/themes/advanced/images/backcolor.gif
Binary files differ
diff --git a/wp-includes/js/tinymce/themes/advanced/images/buttons.gif b/wp-includes/js/tinymce/themes/advanced/images/buttons.gif
index 6196350..5ad99a7 100644
--- a/wp-includes/js/tinymce/themes/advanced/images/buttons.gif
+++ b/wp-includes/js/tinymce/themes/advanced/images/buttons.gif
Binary files differ
diff --git a/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif b/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif
index d5e3814..8b70361 100644
--- a/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif
+++ b/wp-includes/js/tinymce/themes/advanced/images/forecolor.gif
Binary files differ
diff --git a/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js b/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
index b7dadc6..8395340 100644
--- a/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
+++ b/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
@@ -3,29 +3,25 @@ function saveContent() {
tinyMCE.closeWindow(window);
}
-// Fixes some charcode issues
-function fixContent(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|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');*/
- return html;
-}
-
function onLoadInit() {
tinyMCEPopup.resizeToInnerSize();
- document.forms[0].htmlSource.value = fixContent(tinyMCE.getContent(tinyMCE.getWindowArg('editor_id')));
+ // Remove Gecko spellchecking
+ if (tinyMCE.isGecko)
+ document.body.spellcheck = tinyMCE.getParam("gecko_spellcheck");
+
+ document.getElementById('htmlSource').value = tinyMCE.getContent(tinyMCE.getWindowArg('editor_id'));
+
resizeInputs();
if (tinyMCE.getParam("theme_advanced_source_editor_wrap", true)) {
setWrap('soft');
- document.forms[0].wraped.checked = true;
+ document.getElementById('wraped').checked = true;
}
}
function setWrap(val) {
- var s = document.forms[0].htmlSource;
+ var s = document.getElementById('htmlSource');
s.wrap = val;
@@ -48,6 +44,8 @@ function toggleWordWrap(elm) {
var wHeight=0, wWidth=0, owHeight=0, owWidth=0;
function resizeInputs() {
+ var el = document.getElementById('htmlSource');
+
if (!tinyMCE.isMSIE) {
wHeight = self.innerHeight-80;
wWidth = self.innerWidth-16;
@@ -56,11 +54,7 @@ function resizeInputs() {
wWidth = document.body.clientWidth - 16;
}
- document.forms[0].htmlSource.style.height = Math.abs(wHeight) + 'px';
- document.forms[0].htmlSource.style.width = Math.abs(wWidth) + 'px';
+ el.style.height = Math.abs(wHeight) + 'px';
+ el.style.width = Math.abs(wWidth) + 'px';
}
-function renderWordWrap() {
- 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-includes/js/tinymce/themes/advanced/langs/en.js b/wp-includes/js/tinymce/themes/advanced/langs/en.js
index ca72676..fd915ea 100644
--- a/wp-includes/js/tinymce/themes/advanced/langs/en.js
+++ b/wp-includes/js/tinymce/themes/advanced/langs/en.js
@@ -38,6 +38,11 @@ theme_h3 : 'Heading 3',
theme_h4 : 'Heading 4',
theme_h5 : 'Heading 5',
theme_h6 : 'Heading 6',
+theme_blockquote : 'Blockquote',
+theme_code : 'Code',
+theme_samp : 'Code sample',
+theme_dt : 'Definition term ',
+theme_dd : 'Definition description',
theme_colorpicker_title : 'Select a color',
theme_colorpicker_apply : 'Apply',
theme_forecolor_desc : 'Select text color',
@@ -72,5 +77,6 @@ loaded_plugins : 'Loaded plugins',
help : 'Help',
not_set : '-- Not set --',
close : 'Close',
-toolbar_focus : 'Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X'
+toolbar_focus : 'Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X',
+invalid_data : 'Error: Invalid values entered, these are marked in red.'
});
diff --git a/wp-includes/js/tinymce/tiny_mce.js b/wp-includes/js/tinymce/tiny_mce.js
index 643aab4..ecd78a2 100644
--- a/wp-includes/js/tinymce/tiny_mce.js
+++ b/wp-includes/js/tinymce/tiny_mce.js
@@ -2,9 +2,11 @@
/* file:jscripts/tiny_mce/classes/TinyMCE_Engine.class.js */
function TinyMCE_Engine() {
+ var ua;
+
this.majorVersion = "2";
- this.minorVersion = "0.6.1";
- this.releaseDate = "2006-05-04";
+ this.minorVersion = "0.8";
+ this.releaseDate = "2006-10-23";
this.instances = new Array();
this.switchClassCache = new Array();
@@ -15,12 +17,17 @@ function TinyMCE_Engine() {
this.configs = new Array();
this.currentConfig = 0;
this.eventHandlers = new Array();
+ this.log = new Array();
+ this.undoLevels = [];
+ this.undoIndex = 0;
+ this.typingUndoIndex = -1;
// Browser check
- var ua = navigator.userAgent;
+ ua = navigator.userAgent;
this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
this.isMSIE5 = this.isMSIE && (ua.indexOf('MSIE 5') != -1);
this.isMSIE5_0 = this.isMSIE && (ua.indexOf('MSIE 5.0') != -1);
+ this.isMSIE7 = this.isMSIE && (ua.indexOf('MSIE 7') != -1);
this.isGecko = ua.indexOf('Gecko') != -1;
this.isSafari = ua.indexOf('Safari') != -1;
this.isOpera = ua.indexOf('Opera') != -1;
@@ -42,13 +49,20 @@ function TinyMCE_Engine() {
this.isSafari = false;
}
+ this.isIE = this.isMSIE;
+ this.isRealIE = this.isMSIE && !this.isOpera;
+
// TinyMCE editor id instance counter
this.idCounter = 0;
};
TinyMCE_Engine.prototype = {
init : function(settings) {
- var theme;
+ var theme, nl, baseHREF = "", i;
+
+ // IE 5.0x is no longer supported since 5.5, 6.0 and 7.0 now exists. We can't support old browsers forever, sorry.
+ if (this.isMSIE5_0)
+ return;
this.settings = settings;
@@ -60,6 +74,13 @@ TinyMCE_Engine.prototype = {
if (!tinyMCE.baseURL) {
var elements = document.getElementsByTagName('script');
+ // If base element found, add that infront of baseURL
+ nl = document.getElementsByTagName('base');
+ for (i=0; i<nl.length; i++) {
+ if (nl[i].href)
+ baseHREF = nl[i].href;
+ }
+
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;
@@ -71,7 +92,12 @@ TinyMCE_Engine.prototype = {
if (settings.exec_mode == "src" || settings.exec_mode == "normal")
tinyMCE.srcMode = settings.exec_mode == "src" ? '_src' : '';
- tinyMCE.baseURL = src;
+ // Force it absolute if page has a base href
+ if (baseHREF != "" && src.indexOf('://') == -1)
+ tinyMCE.baseURL = baseHREF + src;
+ else
+ tinyMCE.baseURL = src;
+
break;
}
}
@@ -100,7 +126,7 @@ TinyMCE_Engine.prototype = {
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("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],cite[title|id|class|style|dir|lang],abbr[title|id|class|style|dir|lang],acronym[title|id|class|style|dir|lang],del[title|id|class|style|dir|lang|datetime|cite],ins[title|id|class|style|dir|lang|datetime|cite]");
this._def("extended_valid_elements", "");
this._def("invalid_elements", "");
this._def("encoding", "");
@@ -122,6 +148,7 @@ TinyMCE_Engine.prototype = {
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("custom_undo_redo_global", false);
this._def("verify_html", true);
this._def("apply_source_formatting", false);
this._def("directionality", "ltr");
@@ -164,6 +191,7 @@ TinyMCE_Engine.prototype = {
this._def("strict_loading_mode", document.contentType == 'application/xhtml+xml');
this._def("hidden_tab_class", '');
this._def("display_tab_class", '');
+ this._def("gecko_spellcheck", false);
// Force strict loading mode to false on non Gecko browsers
if (this.isMSIE && !this.isOpera)
@@ -186,7 +214,7 @@ TinyMCE_Engine.prototype = {
return;
// If not super absolute make it so
- var baseHREF = tinyMCE.settings['document_base_url'];
+ baseHREF = tinyMCE.settings['document_base_url'];
var h = document.location.href;
var p = h.indexOf('://');
if (p > 0 && document.location.protocol != "file:") {
@@ -207,7 +235,10 @@ TinyMCE_Engine.prototype = {
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|dt|dd|dir|fieldset|form|noscript|noframes|menu|isindex|samp)$", "i");
+ this.inlineStrict = 'A|BR|SPAN|BDO|MAP|OBJECT|IMG|TT|I|B|BIG|SMALL|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|#text|#comment';
+ this.inlineTransitional = 'A|BR|SPAN|BDO|OBJECT|APPLET|IMG|MAP|IFRAME|TT|I|B|U|S|STRIKE|BIG|SMALL|FONT|BASEFONT|EM|STRONG|DFN|CODE|Q|SAMP|KBD|VAR|CITE|ABBR|ACRONYM|SUB|SUP|INPUT|SELECT|TEXTAREA|LABEL|BUTTON|#text|#comment';
+ this.blockElms = 'H[1-6]|P|DIV|ADDRESS|PRE|FORM|TABLE|LI|OL|UL|TD|BLOCKQUOTE|CENTER|DL|DT|DD|DIR|FIELDSET|FORM|NOSCRIPT|NOFRAMES|MENU|ISINDEX|SAMP';
+ this.blockRegExp = new RegExp("^(" + this.blockElms + ")$", "i");
this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);
this.uniqueURL = 'javascript:TINYMCE_UNIQUEURL();'; // Make unique URL non real URL
this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>';
@@ -216,7 +247,7 @@ TinyMCE_Engine.prototype = {
// Theme url
this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme;
- if (!tinyMCE.isMSIE)
+ if (!tinyMCE.isIE || tinyMCE.isOpera)
this.settings['force_br_newlines'] = false;
if (tinyMCE.getParam("popups_css", false)) {
@@ -238,8 +269,10 @@ TinyMCE_Engine.prototype = {
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";
+ } else {
+ if (this.settings.editor_css != '')
+ this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";
+ }
if (tinyMCE.settings['debug']) {
var msg = "Debug: \n";
@@ -255,14 +288,10 @@ TinyMCE_Engine.prototype = {
// 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");
-
if (typeof(TinyMCECompressed) == "undefined") {
tinyMCE.addEvent(window, "DOMContentLoaded", TinyMCE_Engine.prototype.onLoad);
- if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ if (tinyMCE.isRealIE) {
if (document.body)
tinyMCE.addEvent(document.body, "readystatechange", TinyMCE_Engine.prototype.onLoad);
else
@@ -288,10 +317,12 @@ TinyMCE_Engine.prototype = {
}
// 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];
+ if (tinyMCE.getParam('entity_encoding') == 'named') {
+ 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;
@@ -299,10 +330,18 @@ TinyMCE_Engine.prototype = {
// Start loading first one in chain
this.loadNextScript();
+
+ // Force flicker free CSS backgrounds in IE
+ if (this.isIE && !this.isOpera) {
+ try {
+ document.execCommand('BackgroundImageCache', false, true);
+ } catch (e) {
+ }
+ }
},
_addUnloadEvents : function() {
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
if (tinyMCE.settings['add_unload_trigger']) {
tinyMCE.addEvent(window, "unload", TinyMCE_Engine.prototype.unloadHandler);
tinyMCE.addEvent(window.document, "beforeunload", TinyMCE_Engine.prototype.unloadHandler);
@@ -316,7 +355,7 @@ TinyMCE_Engine.prototype = {
_def : function(key, def_val, t) {
var v = tinyMCE.getParam(key, def_val);
- v = t ? v.replace(/\s+/g,"") : v;
+ v = t ? v.replace(/\s+/g, "") : v;
this.settings[key] = v;
},
@@ -409,8 +448,6 @@ TinyMCE_Engine.prototype = {
var x = 0, i = 0, nl, le;
for (x = 0,csslen = ar.length; x<csslen; x++) {
- ignore_css = false;
-
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++) {
@@ -466,7 +503,7 @@ TinyMCE_Engine.prototype = {
},
confirmAdd : function(e, settings) {
- var elm = tinyMCE.isMSIE ? event.srcElement : e.target;
+ var elm = tinyMCE.isIE ? event.srcElement : e.target;
var elementId = elm.name ? elm.name : elm.id;
tinyMCE.settings = settings;
@@ -492,7 +529,7 @@ TinyMCE_Engine.prototype = {
tinyMCE._setHTML(doc, inst.formElement.value);
- if (!tinyMCE.isMSIE)
+ if (!tinyMCE.isIE)
doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid);
}
}
@@ -508,46 +545,62 @@ TinyMCE_Engine.prototype = {
inst._onAdd(replace_element, form_element_name, target_document);
},
+ removeInstance : function(ti) {
+ var t = [], n, i;
+
+ // Remove from instances
+ for (n in tinyMCE.instances) {
+ i = tinyMCE.instances[n];
+
+ if (tinyMCE.isInstance(i) && ti != i)
+ t[n] = i;
+ }
+
+ tinyMCE.instances = t;
+
+ // Remove from global undo/redo
+ n = [];
+ t = tinyMCE.undoLevels;
+
+ for (i=0; i<t.length; i++) {
+ if (t[i] != ti)
+ n.push(t[i]);
+ }
+
+ tinyMCE.undoLevels = n;
+ tinyMCE.undoIndex = n.length;
+
+ return ti;
+ },
+
removeMCEControl : function(editor_id) {
- var inst = tinyMCE.getInstanceById(editor_id);
+ var inst = tinyMCE.getInstanceById(editor_id), h, re, ot, tn;
if (inst) {
inst.switchSettings();
editor_id = inst.editorId;
- var html = tinyMCE.getContent(editor_id);
+ h = tinyMCE.getContent(editor_id);
- // 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;
-
- if (instanceName != editor_id)
- tmpInstances[instanceName] = instance;
- }
- tinyMCE.instances = tmpInstances;
+ this.removeInstance(inst);
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;
+ re = document.getElementById(editor_id + "_parent");
+ ot = inst.oldTargetElement;
+ tn = ot.nodeName.toLowerCase();
+
+ if (tn == "textarea" || tn == "input") {
+ re.parentNode.removeChild(re);
+ ot.style.display = "inline";
+ ot.value = h;
} else {
- oldTargetElement.innerHTML = html;
- oldTargetElement.style.display = 'block';
-
- replaceElement.parentNode.insertBefore(oldTargetElement, replaceElement);
- replaceElement.parentNode.removeChild(replaceElement);
+ ot.innerHTML = h;
+ ot.style.display = 'block';
+ re.parentNode.insertBefore(ot, re);
+ re.parentNode.removeChild(re);
}
}
},
@@ -593,52 +646,75 @@ TinyMCE_Engine.prototype = {
},
execInstanceCommand : function(editor_id, command, user_interface, value, focus) {
- var inst = tinyMCE.getInstanceById(editor_id);
+ var inst = tinyMCE.getInstanceById(editor_id), r;
+
if (inst) {
+ r = inst.selection.getRng();
+
if (typeof(focus) == "undefined")
focus = true;
- if (focus)
+ // IE bug lost focus on images in absolute divs Bug #1534575
+ if (focus && (!r || !r.item))
inst.contentWindow.focus();
// Reset design mode if lost
inst.autoResetDesignMode();
this.selectedElement = inst.getFocusElement();
- this.selectedInstance = inst;
+ inst.select();
tinyMCE.execCommand(command, user_interface, value);
// Cancel event so it doesn't call onbeforeonunlaod
- if (tinyMCE.isMSIE && window.event != null)
+ if (tinyMCE.isIE && window.event != null)
tinyMCE.cancelEvent(window.event);
}
},
execCommand : function(command, user_interface, value) {
+ var inst = tinyMCE.selectedInstance;
+
// Default input
user_interface = user_interface ? user_interface : false;
value = value ? value : null;
- if (tinyMCE.selectedInstance)
- tinyMCE.selectedInstance.switchSettings();
+ if (inst)
+ inst.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;
+ case "Undo":
+ if (this.getParam('custom_undo_redo_global')) {
+ if (this.undoIndex > 0) {
+ tinyMCE.nextUndoRedoAction = 'Undo';
+ inst = this.undoLevels[--this.undoIndex];
+ inst.select();
+
+ if (!tinyMCE.nextUndoRedoInstanceId)
+ inst.execCommand('Undo');
+ }
+ } else
+ inst.execCommand('Undo');
+ return true;
+
+ case "Redo":
+ if (this.getParam('custom_undo_redo_global')) {
+ if (this.undoIndex <= this.undoLevels.length - 1) {
+ tinyMCE.nextUndoRedoAction = 'Redo';
+ inst = this.undoLevels[this.undoIndex++];
+ inst.select();
+
+ if (!tinyMCE.nextUndoRedoInstanceId)
+ inst.execCommand('Redo');
+ }
+ } else
+ inst.execCommand('Redo');
+
+ return true;
case 'mceFocus':
var inst = tinyMCE.getInstanceById(value);
if (inst)
- inst.contentWindow.focus();
+ inst.getWin().focus();
return;
case "mceAddControl":
@@ -657,7 +733,7 @@ TinyMCE_Engine.prototype = {
case "mceResetDesignMode":
// Resets the designmode state of the editors in Gecko
- if (!tinyMCE.isMSIE) {
+ if (!tinyMCE.isIE) {
for (var n in tinyMCE.instances) {
if (!tinyMCE.isInstance(tinyMCE.instances[n]))
continue;
@@ -673,8 +749,8 @@ TinyMCE_Engine.prototype = {
return;
}
- if (this.selectedInstance) {
- this.selectedInstance.execCommand(command, user_interface, value);
+ if (inst) {
+ inst.execCommand(command, user_interface, value);
} else if (tinyMCE.settings['focus_alert'])
alert(tinyMCELang['lang_focus_alert']);
},
@@ -696,17 +772,18 @@ TinyMCE_Engine.prototype = {
if (aw.indexOf('%') == -1) {
aw = parseInt(aw);
- aw = aw < 0 ? 300 : aw;
+ aw = (isNaN(aw) || aw < 0) ? 300 : aw;
aw = aw + "px";
}
if (ah.indexOf('%') == -1) {
ah = parseInt(ah);
- ah = ah < 0 ? 240 : ah;
+ ah = (isNaN(ah) || ah < 0) ? 240 : ah;
ah = ah + "px";
}
iframe.setAttribute("id", id);
+ iframe.setAttribute("name", id);
iframe.setAttribute("class", "mceEditorIframe");
iframe.setAttribute("border", "0");
iframe.setAttribute("frameBorder", "0");
@@ -723,7 +800,7 @@ TinyMCE_Engine.prototype = {
iframe.setAttribute("scrolling", "no");
// Must have a src element in MSIE HTTPs breaks aswell as absoute URLs
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ if (tinyMCE.isRealIE)
iframe.setAttribute("src", this.settings['default_document']);
iframe.style.width = aw;
@@ -734,19 +811,19 @@ TinyMCE_Engine.prototype = {
iframe.style.marginBottom = '-5px';
// MSIE 5.0 issue
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ if (tinyMCE.isRealIE)
replace_element.outerHTML = iframe.outerHTML;
else
replace_element.parentNode.replaceChild(iframe, replace_element);
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ if (tinyMCE.isRealIE)
return win.frames[id];
else
return iframe;
},
setupContent : function(editor_id) {
- var inst = tinyMCE.instances[editor_id];
+ var inst = tinyMCE.instances[editor_id], i;
var doc = inst.getDoc();
var head = doc.getElementsByTagName('head').item(0);
var content = inst.startContent;
@@ -762,7 +839,7 @@ TinyMCE_Engine.prototype = {
inst.switchSettings();
// Not loaded correctly hit it again, Mozilla bug #997860
- if (!tinyMCE.isMSIE && tinyMCE.getParam("setupcontent_reload", false) && doc.title != "blank_page") {
+ if (!tinyMCE.isIE && 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) {}
@@ -786,6 +863,14 @@ TinyMCE_Engine.prototype = {
inst.addShortcut('ctrl', 'y', 'lang_redo_desc', 'Redo');
}
+ // BlockFormat shortcuts keys
+ for (i=1; i<=6; i++)
+ inst.addShortcut('ctrl', '' + i, '', 'FormatBlock', false, '<h' + i + '>');
+
+ inst.addShortcut('ctrl', '7', '', 'FormatBlock', false, '<p>');
+ inst.addShortcut('ctrl', '8', '', 'FormatBlock', false, '<div>');
+ inst.addShortcut('ctrl', '9', '', 'FormatBlock', false, '<address>');
+
// Add default shortcuts for gecko
if (tinyMCE.isGecko) {
inst.addShortcut('ctrl', 'b', 'lang_bold_desc', 'Bold');
@@ -795,7 +880,7 @@ TinyMCE_Engine.prototype = {
// Setup span styles
if (tinyMCE.getParam("convert_fonts_to_spans"))
- inst.getDoc().body.setAttribute('id', 'mceSpanFonts');
+ inst.getBody().setAttribute('id', 'mceSpanFonts');
if (tinyMCE.settings['nowrap'])
doc.body.style.whiteSpace = "nowrap";
@@ -804,7 +889,7 @@ TinyMCE_Engine.prototype = {
doc.editorId = editor_id;
// Add on document element in Mozilla
- if (!tinyMCE.isMSIE)
+ if (!tinyMCE.isIE)
doc.documentElement.editorId = editor_id;
inst.setBaseHREF(tinyMCE.settings['base_href']);
@@ -823,7 +908,7 @@ TinyMCE_Engine.prototype = {
content = tinyMCE.storeAwayURLs(content);
content = tinyMCE._customCleanup(inst, "insert_to_editor", content);
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
// Ugly!!!
window.setInterval('try{tinyMCE.getCSSClasses(tinyMCE.instances["' + editor_id + '"].getDoc(), "' + editor_id + '");}catch(e){}', 500);
@@ -837,7 +922,7 @@ TinyMCE_Engine.prototype = {
content = tinyMCE.cleanupHTMLCode(content);
// Fix for bug #958637
- if (!tinyMCE.isMSIE) {
+ if (!tinyMCE.isIE) {
var contentElement = inst.getDoc().createElement("body");
var doc = inst.getDoc();
@@ -849,15 +934,8 @@ TinyMCE_Engine.prototype = {
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");
+ else
tinyMCE.setInnerHTML(inst.getBody(), content);
- }
tinyMCE.convertAllRelativeURLs(inst.getBody());
} else {
@@ -881,11 +959,11 @@ TinyMCE_Engine.prototype = {
tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc());
// Re-add design mode on mozilla
- if (!tinyMCE.isMSIE)
+ if (!tinyMCE.isIE)
tinyMCE.addEventHandlers(inst);
// Add blur handler
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE_Engine.prototype._eventPatch);
tinyMCE.addEvent(inst.getBody(), "beforedeactivate", TinyMCE_Engine.prototype._eventPatch); // Bug #1439953
@@ -898,7 +976,7 @@ TinyMCE_Engine.prototype = {
}
// Trigger node change, this call locks buttons for tables and so forth
- tinyMCE.selectedInstance = inst;
+ inst.select();
tinyMCE.selectedElement = inst.contentWindow.document.body;
// Call custom DOM cleanup
@@ -917,19 +995,21 @@ TinyMCE_Engine.prototype = {
if (tinyMCE.isGecko) {
// Remove mce_src from textnodes and comments
tinyMCE.selectNodes(inst.getBody(), function(n) {
- if (n.nodeType == 3 || n.nodeType == 8) {
- n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), "");
- n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), "");
- }
+ if (n.nodeType == 3 || n.nodeType == 8)
+ n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), "");
return false;
});
}
+ // Remove Gecko spellchecking
+ if (tinyMCE.isGecko)
+ inst.getBody().spellcheck = tinyMCE.getParam("gecko_spellcheck");
+
// Cleanup any mess left from storyAwayURLs
tinyMCE._removeInternal(inst.getBody());
- tinyMCE.selectedInstance = inst;
+ inst.select();
tinyMCE.triggerNodeChange(false, true);
},
@@ -950,42 +1030,14 @@ TinyMCE_Engine.prototype = {
if (tinyMCE.isGecko) {
// Remove mce_src from textnodes and comments
tinyMCE.selectNodes(n, function(n) {
- if (n.nodeType == 3 || n.nodeType == 8) {
- n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), "");
- n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), "");
- }
+ if (n.nodeType == 3 || n.nodeType == 8)
+ n.nodeValue = n.nodeValue.replace(new RegExp('\\s(mce_src|mce_href)=\"[^\"]*\"', 'gi'), "");
return false;
});
}
},
- removeTinyMCEFormElements : function(form_obj) {
- // Check if form is valid
- if (typeof(form_obj) == "undefined" || form_obj == null)
- return;
-
- // 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");
- }
-
- // Still nothing
- if (form_obj == null)
- return;
-
- // 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;
-
- if (elementId.indexOf('mce_editor_') == 0)
- form_obj.elements[i].disabled = true;
- }
- },
-
handleEvent : function(e) {
var inst = tinyMCE.selectedInstance;
@@ -1016,7 +1068,7 @@ TinyMCE_Engine.prototype = {
// Fixes odd MSIE bug where drag/droping elements in a iframe with height 100% breaks
// This logic forces the width/height to be in pixels while the user is drag/dropping
- if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ if (tinyMCE.isRealIE) {
var ife = tinyMCE.selectedInstance.iframeElement;
/*if (ife.style.width.indexOf('%') != -1) {
@@ -1034,13 +1086,12 @@ TinyMCE_Engine.prototype = {
return;
case "submit":
- tinyMCE.removeTinyMCEFormElements(tinyMCE.isMSIE ? window.event.srcElement : e.target);
tinyMCE.triggerSave();
tinyMCE.isNotDirty = true;
return;
case "reset":
- var formObj = tinyMCE.isMSIE ? window.event.srcElement : e.target;
+ var formObj = tinyMCE.isIE ? window.event.srcElement : e.target;
for (var i=0; i<document.forms.length; i++) {
if (document.forms[i] == formObj)
@@ -1054,41 +1105,39 @@ TinyMCE_Engine.prototype = {
return false;
if (e.target.editorId) {
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
+ tinyMCE.instances[e.target.editorId].select();
} else {
if (e.target.ownerDocument.editorId)
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.ownerDocument.editorId];
+ tinyMCE.instances[e.target.ownerDocument.editorId].select();
}
if (tinyMCE.selectedInstance)
tinyMCE.selectedInstance.switchSettings();
// Insert P element
- if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && e.keyCode == 13 && !e.shiftKey) {
+ if ((tinyMCE.isGecko || tinyMCE.isOpera || tinyMCE.isSafari) && 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;
+ return tinyMCE.cancelEvent(e);
}
}
// Handle backspace
- if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
+ if ((tinyMCE.isGecko && !tinyMCE.isSafari) && 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;
+ return tinyMCE.cancelEvent(e);
}
}
// Return key pressed
- if (tinyMCE.isMSIE && tinyMCE.settings['force_br_newlines'] && e.keyCode == 13) {
+ if (tinyMCE.isIE && tinyMCE.settings['force_br_newlines'] && e.keyCode == 13) {
if (e.target.editorId)
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
+ tinyMCE.instances[e.target.editorId].select();
if (tinyMCE.selectedInstance) {
var sel = tinyMCE.selectedInstance.getDoc().selection;
@@ -1132,9 +1181,7 @@ TinyMCE_Engine.prototype = {
return false;
if (e.target.editorId)
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
- else
- return;
+ tinyMCE.instances[e.target.editorId].select();
if (tinyMCE.selectedInstance)
tinyMCE.selectedInstance.switchSettings();
@@ -1164,11 +1211,11 @@ TinyMCE_Engine.prototype = {
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)
+ if (tinyMCE.isIE && 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) {
+ if (tinyMCE.isIE && e.type == "keyup" && e.keyCode == 13) {
var elm = tinyMCE.enterKeyElement;
if (elm) {
var re = new RegExp('^HR|IMG|BR$','g'); // Skip these
@@ -1194,8 +1241,9 @@ TinyMCE_Engine.prototype = {
}
// MSIE custom key handling
- if (tinyMCE.isMSIE && tinyMCE.settings['custom_undo_redo']) {
+ if (tinyMCE.isIE && 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")
@@ -1210,9 +1258,15 @@ TinyMCE_Engine.prototype = {
// Handle Undo/Redo when typing content
- // Start typing (non position key)
- if (!posKey && e.type == "keyup")
- tinyMCE.execCommand("mceStartTyping");
+ if (tinyMCE.isGecko) {
+ // Start typing (not a position key or ctrl key, but ctrl+x and ctrl+p is ok)
+ if (!posKey && e.type == "keyup" && !e.ctrlKey || (e.ctrlKey && (e.keyCode == 86 || e.keyCode == 88)))
+ tinyMCE.execCommand("mceStartTyping");
+ } else {
+ // IE seems to be working better with this setting
+ if (!posKey && e.type == "keyup")
+ tinyMCE.execCommand("mceStartTyping");
+ }
// Store undo bookmark
if (e.type == "keydown" && (posKey || e.ctrlKey) && inst)
@@ -1225,13 +1279,14 @@ TinyMCE_Engine.prototype = {
if (posKey && e.type == "keyup")
tinyMCE.triggerNodeChange(false);
- if (tinyMCE.isMSIE && e.ctrlKey)
+ if (tinyMCE.isIE && e.ctrlKey)
window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
break;
case "mousedown":
case "mouseup":
case "click":
+ case "dblclick":
case "focus":
tinyMCE.hideMenus();
@@ -1241,7 +1296,7 @@ TinyMCE_Engine.prototype = {
}
// Check instance event trigged on
- var targetBody = tinyMCE.getParentElement(e.target, "body");
+ var targetBody = tinyMCE.getParentElement(e.target, "html");
for (var instanceName in tinyMCE.instances) {
if (!tinyMCE.isInstance(tinyMCE.instances[instanceName]))
continue;
@@ -1251,8 +1306,9 @@ TinyMCE_Engine.prototype = {
// Reset design mode if lost (on everything just in case)
inst.autoResetDesignMode();
- if (inst.getBody() == targetBody) {
- tinyMCE.selectedInstance = inst;
+ // Use HTML element since users might click outside of body element
+ if (inst.getBody().parentNode == targetBody) {
+ inst.select();
tinyMCE.selectedElement = e.target;
tinyMCE.linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
tinyMCE.imgElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "img");
@@ -1261,30 +1317,9 @@ TinyMCE_Engine.prototype = {
}
// Add first bookmark location
- if (!tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark)
+ if (!tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark && (e.type == "mouseup" || e.type == "dblclick"))
tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark = tinyMCE.selectedInstance.selection.getBookmark();
- if (tinyMCE.isSafari) {
- tinyMCE.selectedInstance.lastSafariSelection = tinyMCE.selectedInstance.selection.getBookmark();
- tinyMCE.selectedInstance.lastSafariSelectedElement = tinyMCE.selectedElement;
-
- var lnk = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
-
- // Patch the darned link
- if (lnk && e.type == "mousedown") {
- lnk.setAttribute("mce_real_href", lnk.getAttribute("href"));
- lnk.setAttribute("href", "javascript:void(0);");
- }
-
- // Patch back
- if (lnk && e.type == "click") {
- window.setTimeout(function() {
- lnk.setAttribute("href", lnk.getAttribute("mce_real_href"));
- lnk.removeAttribute("mce_real_href");
- }, 10);
- }
- }
-
// Reset selected node
if (e.type != "focus")
tinyMCE.selectedNode = null;
@@ -1297,7 +1332,7 @@ TinyMCE_Engine.prototype = {
// Just in case
if (!tinyMCE.selectedInstance && e.target.editorId)
- tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
+ tinyMCE.instances[e.target.editorId].select();
return false;
break;
@@ -1305,7 +1340,7 @@ TinyMCE_Engine.prototype = {
},
getButtonHTML : function(id, lang, img, cmd, ui, val) {
- var h = '', m, x;
+ var h = '', m, x, io = '';
cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\'';
@@ -1317,16 +1352,20 @@ TinyMCE_Engine.prototype = {
cmd += ');';
+ // Patch for IE7 bug with hover out not restoring correctly
+ if (tinyMCE.isRealIE)
+ io = 'onmouseover="tinyMCE.lastHover = this;"';
+
// 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)) {
+ if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isIE || 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 += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" ' + io + ' 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 += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" ' + io + ' class="mceButtonNormal" target="_self">';
h += '<img src="' + img + '" title="{$' + lang + '}" />';
h += '</a>';
}
@@ -1334,6 +1373,58 @@ TinyMCE_Engine.prototype = {
return h;
},
+ getMenuButtonHTML : function(id, lang, img, mcmd, cmd, ui, val) {
+ var h = '', m, x;
+
+ mcmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + mcmd + '\');';
+ cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\'';
+
+ if (typeof(ui) != "undefined" && ui != null)
+ cmd += ',' + ui;
+
+ if (typeof(val) != "undefined" && val != null)
+ cmd += ",'" + val + "'";
+
+ cmd += ');';
+
+ // 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.isIE || tinyMCE.isOpera) && (m = tinyMCE.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) {
+ x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20);
+
+ if (tinyMCE.isRealIE)
+ h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
+ else
+ h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">';
+
+ h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceTiledButton mceMenuButtonNormal" target="_self">';
+ h += '<img src="{$themeurl}/images/spacer.gif" style="width: 20px; height: 20px; background-position: ' + x + 'px 0" title="{$' + lang + '}" /></a>';
+ h += '<a href="javascript:' + mcmd + '" onclick="' + mcmd + 'return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" />';
+ h += '</a></span>';
+ } else {
+ if (tinyMCE.isRealIE)
+ h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton" onmouseover="tinyMCE._menuButtonEvent(\'over\',this);tinyMCE.lastHover = this;" onmouseout="tinyMCE._menuButtonEvent(\'out\',this);">';
+ else
+ h += '<span id="{$editor_id}_' + id + '" class="mceMenuButton">';
+
+ h += '<a href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceMenuButtonNormal" target="_self">';
+ h += '<img src="' + img + '" title="{$' + lang + '}" /></a>';
+ h += '<a href="javascript:' + mcmd + '" onclick="' + mcmd + 'return false;" onmousedown="return false;"><img src="{$themeurl}/images/button_menu.gif" title="{$' + lang + '}" class="mceMenuButton" />';
+ h += '</a></span>';
+ }
+
+ return h;
+ },
+
+ _menuButtonEvent : function(e, o) {
+ if (o.className == 'mceMenuButtonFocus')
+ return;
+
+ if (e == 'over')
+ o.className = o.className + ' mceMenuHover';
+ else
+ o.className = o.className.replace(/\s.*$/, '');
+ },
+
addButtonMap : function(m) {
var i, a = m.replace(/\s+/, '').split(',');
@@ -1342,20 +1433,21 @@ TinyMCE_Engine.prototype = {
},
submitPatch : function() {
- tinyMCE.removeTinyMCEFormElements(this);
tinyMCE.triggerSave();
- this.mceOldSubmit();
tinyMCE.isNotDirty = true;
+ this.mceOldSubmit();
},
onLoad : function() {
+ var r;
+
// Wait for everything to be loaded first
if (tinyMCE.settings.strict_loading_mode && this.loadingIndex != -1) {
window.setTimeout('tinyMCE.onLoad();', 1);
return;
}
- if (tinyMCE.isMSIE && !tinyMCE.isOpera && window.event.type == "readystatechange" && document.readyState != "complete")
+ if (tinyMCE.isRealIE && window.event.type == "readystatechange" && document.readyState != "complete")
return true;
if (tinyMCE.isLoaded)
@@ -1363,6 +1455,15 @@ TinyMCE_Engine.prototype = {
tinyMCE.isLoaded = true;
+ // IE produces JS error if TinyMCE is placed in a frame
+ // It seems to have something to do with the selection not beeing
+ // correctly initialized in IE so this hack solves the problem
+ if (tinyMCE.isRealIE && document.body) {
+ r = document.body.createTextRange();
+ r.collapse(true);
+ r.select();
+ }
+
tinyMCE.dispatchCallback(null, 'onpageload', 'onPageLoad');
for (var c=0; c<tinyMCE.configs.length; c++) {
@@ -1403,7 +1504,7 @@ TinyMCE_Engine.prototype = {
var element = tinyMCE._getElementById(elements[i]);
var trigger = element ? element.getAttribute(tinyMCE.settings['textarea_trigger']) : "";
- if (tinyMCE.getAttrib(element, "class").indexOf(deselector) != -1)
+ if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(element, "class")))
continue;
if (trigger == "false")
@@ -1429,13 +1530,13 @@ TinyMCE_Engine.prototype = {
var elm = nodeList.item(i);
var trigger = elm.getAttribute(tinyMCE.settings['textarea_trigger']);
- if (selector != '' && tinyMCE.getAttrib(elm, "class").indexOf(selector) == -1)
+ if (selector != '' && !new RegExp('\\b' + selector + '\\b').test(tinyMCE.getAttrib(elm, "class")))
continue;
if (selector != '')
trigger = selector != "" ? "true" : "";
- if (tinyMCE.getAttrib(elm, "class").indexOf(deselector) != -1)
+ if (new RegExp('\\b' + deselector + '\\b').test(tinyMCE.getAttrib(elm, "class")))
continue;
if ((mode == "specific_textareas" && trigger == "true") || (mode == "textareas" && trigger != "false"))
@@ -1475,7 +1576,7 @@ TinyMCE_Engine.prototype = {
var inst = tinyMCE.getInstanceById(tinyMCE.settings['auto_focus']);
inst.selection.selectNode(inst.getBody(), true, true);
inst.contentWindow.focus();
- }, 10);
+ }, 100);
}
tinyMCE.dispatchCallback(null, 'oninit', 'onInit');
@@ -1527,8 +1628,10 @@ TinyMCE_Engine.prototype = {
entityDecode : function(s) {
var e = document.createElement("div");
+
e.innerHTML = s;
- return e.innerHTML;
+
+ return e.firstChild.nodeValue;
},
addToLang : function(prefix, ar) {
@@ -1550,23 +1653,19 @@ TinyMCE_Engine.prototype = {
var inst = tinyMCE.selectedInstance;
var editorId = inst.editorId;
var elm = (typeof(setup_content) != "undefined" && setup_content) ? tinyMCE.selectedElement : inst.getFocusElement();
- var undoIndex = -1;
+ var undoIndex = -1, doc;
var undoLevels = -1;
var anySelection = false;
var selectedText = inst.selection.getSelectedText();
+ if (tinyMCE.settings.auto_resize)
+ inst.resizeToContent();
+
if (setup_content && tinyMCE.isGecko && inst.isHidden())
elm = inst.getBody();
inst.switchSettings();
- if (tinyMCE.settings["auto_resize"]) {
- var doc = inst.getDoc();
-
- inst.iframeElement.style.width = doc.body.offsetWidth + "px";
- inst.iframeElement.style.height = doc.body.offsetHeight + "px";
- }
-
if (tinyMCE.selectedElement)
anySelection = (tinyMCE.selectedElement.nodeName.toLowerCase() == "img") || (selectedText && selectedText.length > 0);
@@ -1590,6 +1689,11 @@ TinyMCE_Engine.prototype = {
if (customCleanup != "" && eval("typeof(" + customCleanup + ")") != "undefined")
content = eval(customCleanup + "(type, content, inst);");
+ // Trigger theme cleanup
+ po = tinyMCE.themes[tinyMCE.settings['theme']];
+ if (po && po.cleanup)
+ content = po.cleanup(type, content, inst);
+
// Trigger plugin cleanups
pl = inst.plugins;
for (i=0; i<pl.length; i++) {
@@ -1616,40 +1720,31 @@ TinyMCE_Engine.prototype = {
tinyMCE.loadScript(tinyMCE.baseURL + '/themes/' + name + '/langs/' + tinyMCE.settings['language'] + '.js');
},
- importPluginLanguagePack : function(name, valid_languages) {
- var lang = "en", b = tinyMCE.baseURL + '/plugins/' + name;
-
- 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'];
- }
+ importPluginLanguagePack : function(name) {
+ var b = tinyMCE.baseURL + '/plugins/' + name;
if (this.plugins[name])
b = this.plugins[name].baseURL;
- tinyMCE.loadScript(b + '/langs/' + lang + '.js');
+ tinyMCE.loadScript(b + '/langs/' + tinyMCE.settings['language'] + '.js');
},
applyTemplate : function(h, as) {
- var i, s, ar = h.match(new RegExp('\\{\\$[a-z0-9_]+\\}', 'gi'));
-
- 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]);
- }
- }
+ return h.replace(new RegExp('\\{\\$([a-z0-9_]+)\\}', 'gi'), function(m, s) {
+ if (s.indexOf('lang_') == 0 && tinyMCELang[s])
+ return tinyMCELang[s];
- h = tinyMCE.replaceVar(h, "themeurl", tinyMCE.themeURL);
+ if (as && as[s])
+ return as[s];
- return h;
+ if (tinyMCE.settings[s])
+ return tinyMCE.settings[s];
+
+ if (m == 'themeurl')
+ return tinyMCE.themeURL;
+
+ return m;
+ });
},
replaceVar : function(h, r, v) {
@@ -1672,7 +1767,7 @@ TinyMCE_Engine.prototype = {
height = 200;
// Add to height in M$ due to SP2 WHY DON'T YOU GUYS IMPLEMENT innerWidth of windows!!
- if (tinyMCE.isMSIE)
+ if (tinyMCE.isIE)
height += 40;
else
height += 20;
@@ -1711,7 +1806,7 @@ TinyMCE_Engine.prototype = {
win.resizeTo(width, height);
win.focus();
} else {
- if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && resizable != 'yes' && tinyMCE.settings["dialog_type"] == "modal") {
+ if ((tinyMCE.isRealIE) && resizable != 'yes' && tinyMCE.settings["dialog_type"] == "modal") {
height += 10;
var features = "resizable:" + resizable
@@ -1823,7 +1918,7 @@ TinyMCE_Engine.prototype = {
if (anchorName != '' && state) {
el.title = anchorName;
- el.className = 'mceItemAnchor';
+ tinyMCE.addCSSClass(el, 'mceItemAnchor');
} else if (anchorName != '' && !state)
el.className = '';
@@ -1870,7 +1965,7 @@ TinyMCE_Engine.prototype = {
*/
fixGeckoBaseHREFBug : function(m, e, h) {
- var nl, i, a, n, xsrc, xhref, el;
+ var xsrc, xhref;
if (tinyMCE.isGecko) {
if (m == 1) {
@@ -1879,38 +1974,40 @@ TinyMCE_Engine.prototype = {
return h;
} else {
- el = new Array('a','img','select','area','iframe','base','input','script','embed','object','link');
+ // Why bother if there is no src or href broken
+ if (!new RegExp('(src|href)=', 'g').test(h))
+ return h;
- for (a=0; a<el.length; a++) {
- n = e.getElementsByTagName(el[a]);
+ // Restore src and href that gets messed up by Gecko
+ tinyMCE.selectElements(e, 'A,IMG,SELECT,AREA,IFRAME,BASE,INPUT,SCRIPT,EMBED,OBJECT,LINK', function (n) {
+ xsrc = tinyMCE.getAttrib(n, "mce_tsrc");
+ xhref = tinyMCE.getAttrib(n, "mce_thref");
- for (i=0; i<n.length; i++) {
- xsrc = tinyMCE.getAttrib(n[i], "mce_tsrc");
- xhref = tinyMCE.getAttrib(n[i], "mce_thref");
-
- if (xsrc != "") {
- try {
- n[i].src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc);
- } catch (e) {
- // Ignore, Firefox cast exception if local file wasn't found
- }
-
- n[i].removeAttribute("mce_tsrc");
+ if (xsrc != "") {
+ try {
+ n.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc);
+ } catch (e) {
+ // Ignore, Firefox cast exception if local file wasn't found
}
- if (xhref != "") {
- try {
- n[i].href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xhref);
- } catch (e) {
- // Ignore, Firefox cast exception if local file wasn't found
- }
+ n.removeAttribute("mce_tsrc");
+ }
- n[i].removeAttribute("mce_thref");
+ if (xhref != "") {
+ try {
+ n.href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xhref);
+ } catch (e) {
+ // Ignore, Firefox cast exception if local file wasn't found
}
+
+ n.removeAttribute("mce_thref");
}
- }
- el = tinyMCE.selectNodes(e, function(n) {
+ return false;
+ });
+
+ // Restore text/comment nodes
+ tinyMCE.selectNodes(e, function(n) {
if (n.nodeType == 3 || n.nodeType == 8) {
n.nodeValue = n.nodeValue.replace(/\smce_tsrc=/gi, " src=");
n.nodeValue = n.nodeValue.replace(/\smce_thref=/gi, " href=");
@@ -1939,7 +2036,7 @@ TinyMCE_Engine.prototype = {
}
// Content duplication bug fix
- if (tinyMCE.isMSIE && tinyMCE.settings['fix_content_duplication']) {
+ if (tinyMCE.isIE && tinyMCE.settings['fix_content_duplication']) {
// Remove P elements in P elements
var paras = doc.getElementsByTagName("P");
for (var i=0; i<paras.length; i++) {
@@ -2065,7 +2162,7 @@ TinyMCE_Engine.prototype = {
var csses = null;
// Just ignore any errors
- eval("try {var csses = tinyMCE.isMSIE ? doc.styleSheets(" + x + ").rules : styles[" + x + "].cssRules;} catch(e) {}");
+ eval("try {var csses = tinyMCE.isIE ? doc.styleSheets(" + x + ").rules : styles[" + x + "].cssRules;} catch(e) {}");
if (!csses)
return new Array();
@@ -2158,7 +2255,7 @@ TinyMCE_Engine.prototype = {
return '';
},
- evalFunc : function(f, idx, a) {
+ evalFunc : function(f, idx, a, o) {
var s = '(', i;
for (i=idx; i<a.length; i++) {
@@ -2170,7 +2267,7 @@ TinyMCE_Engine.prototype = {
s += ');';
- return eval("f" + s);
+ return o ? eval("o." + f + s) : eval("f" + s);
},
dispatchCallback : function(i, p, n) {
@@ -2199,7 +2296,7 @@ TinyMCE_Engine.prototype = {
for (i=0, l = ins.plugins; i<l.length; i++) {
o = tinyMCE.plugins[l[i]];
- if (o[n] && (v = tinyMCE.evalFunc(o[n], 3, a)) == s && m > 0)
+ if (o[n] && (v = tinyMCE.evalFunc(n, 3, a, o)) == s && m > 0)
return true;
}
}
@@ -2208,7 +2305,7 @@ TinyMCE_Engine.prototype = {
for (on in l) {
o = l[on];
- if (o[n] && (v = tinyMCE.evalFunc(o[n], 3, a)) == s && m > 0)
+ if (o[n] && (v = tinyMCE.evalFunc(n, 3, a, o)) == s && m > 0)
return true;
}
@@ -2216,14 +2313,26 @@ TinyMCE_Engine.prototype = {
},
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;');
+ return s ? ('' + s).replace(new RegExp('[<>&"\']', 'g'), function (c, b) {
+ switch (c) {
+ case '&':
+ return '&amp;';
- return s;
+ case '"':
+ return '&quot;';
+
+ case '\'':
+ return '&#39;'; // &apos; is not working in MSIE
+
+ case '<':
+ return '&lt;';
+
+ case '>':
+ return '&gt;';
+ }
+
+ return c;
+ }) : s;
},
extend : function(p, np) {
@@ -2252,19 +2361,9 @@ TinyMCE_Engine.prototype = {
tinyMCE.switchClass(e, tinyMCE.lastMenuBtnClass);
tinyMCE.lastSelectedMenuBtn = null;
}
- },
-
- explode : function(d, s) {
- var ar = s.split(d), oar = new Array(), i;
-
- for (i = 0; i<ar.length; i++) {
- if (ar[i] != "")
- oar[oar.length] = ar[i];
- }
-
- return oar;
}
-};
+
+ };
// Global instances
var TinyMCE = TinyMCE_Engine; // Compatiblity with gzip compressors
@@ -2289,10 +2388,13 @@ function TinyMCE_Control(settings) {
this.cleanup = new TinyMCE_Cleanup();
this.shortcuts = new Array();
this.hasMouseMoved = false;
+ this.foreColor = this.backColor = "#999999";
+ this.data = {};
this.cleanup.init({
valid_elements : s.valid_elements,
extended_valid_elements : s.extended_valid_elements,
+ valid_child_elements : s.valid_child_elements,
entities : s.entities,
entity_encoding : s.entity_encoding,
debug : s.cleanup_debug,
@@ -2345,6 +2447,21 @@ function TinyMCE_Control(settings) {
};
TinyMCE_Control.prototype = {
+ selection : null,
+
+ settings : null,
+
+ cleanup : null,
+
+ getData : function(na) {
+ var o = this.data[na];
+
+ if (!o)
+ o = this.data[na] = {};
+
+ return o;
+ },
+
hasPlugin : function(n) {
var i;
@@ -2364,12 +2481,14 @@ TinyMCE_Control.prototype = {
},
repaint : function() {
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ var s, b, ex;
+
+ if (tinyMCE.isRealIE)
return;
try {
- var s = this.selection;
- var b = s.getBookmark(true);
+ s = this.selection;
+ b = s.getBookmark(true);
this.getBody().style.display = 'none';
this.getDoc().execCommand('selectall', false, null);
this.getSel().collapseToStart();
@@ -2387,11 +2506,24 @@ TinyMCE_Control.prototype = {
}
},
+ select : function() {
+ var oldInst = tinyMCE.selectedInstance;
+
+ if (oldInst != this) {
+ if (oldInst)
+ oldInst.execCommand('mceEndTyping');
+
+ tinyMCE.dispatchCallback(this, 'select_instance_callback', 'selectInstance', this, oldInst);
+ tinyMCE.selectedInstance = this;
+ }
+ },
+
getBody : function() {
- return this.getDoc().body;
+ return this.contentBody ? this.contentBody : this.getDoc().body;
},
getDoc : function() {
+// return this.contentDocument ? this.contentDocument : this.contentWindow.document; // Removed due to IE 5.5 ?
return this.contentWindow.document;
},
@@ -2399,9 +2531,34 @@ TinyMCE_Control.prototype = {
return this.contentWindow;
},
+ getContainerWin : function() {
+ return this.containerWindow ? this.containerWindow : window;
+ },
+
+ getViewPort : function() {
+ return tinyMCE.getViewPort(this.getWin());
+ },
+
+ getParentNode : function(n, f) {
+ return tinyMCE.getParentNode(n, f, this.getBody());
+ },
+
+ getParentElement : function(n, na, f) {
+ return tinyMCE.getParentElement(n, na, f, this.getBody());
+ },
+
+ getParentBlockElement : function(n) {
+ return tinyMCE.getParentBlockElement(n, this.getBody());
+ },
+
+ resizeToContent : function() {
+ var d = this.getDoc(), b = d.body, de = d.documentElement;
+
+ this.iframeElement.style.height = (tinyMCE.isRealIE) ? b.scrollHeight : de.offsetHeight + 'px';
+ },
+
addShortcut : function(m, k, d, cmd, ui, va) {
- var n = typeof(k) == "number", ie = tinyMCE.isMSIE, c, sc, i;
- var scl = this.shortcuts;
+ var n = typeof(k) == "number", ie = tinyMCE.isIE, c, sc, i, scl = this.shortcuts;
if (!tinyMCE.getParam('custom_shortcuts'))
return false;
@@ -2440,6 +2597,7 @@ TinyMCE_Control.prototype = {
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);
@@ -2454,15 +2612,17 @@ TinyMCE_Control.prototype = {
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) {}');
+ if (!tinyMCE.isIE && this.isHidden() && tinyMCE.getParam('auto_reset_designmode'))
+ eval('try { this.getDoc().designMode = "On"; this.useCSS = false; } catch(e) {}');
},
isHidden : function() {
- if (tinyMCE.isMSIE)
+ var s;
+
+ if (tinyMCE.isIE)
return false;
- var s = this.getSel();
+ s = this.getSel();
// Weird, wheres that cursor selection?
return (!s || !s.rangeCount || s.rangeCount == 0);
@@ -2470,7 +2630,7 @@ TinyMCE_Control.prototype = {
isDirty : function() {
// Is content modified and not in a submit procedure
- return this.startContent != tinyMCE.trim(this.getBody().innerHTML) && !tinyMCE.isNotDirty;
+ return tinyMCE.trim(this.startContent) != tinyMCE.trim(this.getBody().innerHTML) && !tinyMCE.isNotDirty;
},
_mergeElements : function(scmd, pa, ch, override) {
@@ -2486,7 +2646,8 @@ TinyMCE_Control.prototype = {
var stc = tinyMCE.parseStyle(tinyMCE.getAttrib(ch, "style"));
var className = tinyMCE.getAttrib(pa, "class");
- className += " " + tinyMCE.getAttrib(ch, "class");
+ // Removed class adding due to bug #1478272
+ className = tinyMCE.getAttrib(ch, "class");
if (override) {
for (var n in st) {
@@ -2526,21 +2687,14 @@ TinyMCE_Control.prototype = {
},
execCommand : function(command, user_interface, value) {
- var doc = this.getDoc();
- var win = this.getWin();
- var focusElm = this.getFocusElement();
+ var doc = this.getDoc(), win = this.getWin(), focusElm = this.getFocusElement();
- // Is non udno specific command
+ // Is not a undo specific command
if (!new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command))
this.undoBookmark = null;
- if (this.lastSafariSelection && !new RegExp('mceStartTyping|mceEndTyping|mceBeginUndoLevel|mceEndUndoLevel|mceAddUndoLevel', 'gi').test(command)) {
- this.selection.moveToBookmark(this.lastSafariSelection);
- tinyMCE.selectedElement = this.lastSafariSelectedElement;
- }
-
// Mozilla issue
- if (!tinyMCE.isMSIE && !this.useCSS) {
+ if (!tinyMCE.isIE && !this.useCSS) {
this._setUseCSS(false);
this.useCSS = true;
}
@@ -2654,24 +2808,39 @@ TinyMCE_Control.prototype = {
this.repaint();
return true;
- case "InsertUnorderedList":
- case "InsertOrderedList":
- var tag = (command == "InsertUnorderedList") ? "ul" : "ol";
+ case "unlink":
+ // Unlink if caret is inside link
+ if (tinyMCE.isGecko && this.getSel().isCollapsed) {
+ focusElm = tinyMCE.getParentElement(focusElm, 'A');
- if (tinyMCE.isSafari)
- this.execCommand("mceInsertContent", false, "<" + tag + "><li>&nbsp;</li><" + tag + ">");
- else
- this.getDoc().execCommand(command, user_interface, value);
+ if (focusElm)
+ this.selection.selectNode(focusElm, false);
+ }
+
+ this.getDoc().execCommand(command, user_interface, value);
+
+ tinyMCE.isGecko && this.getSel().collapseToEnd();
tinyMCE.triggerNodeChange();
+
+ return true;
+
+ case "FormatBlock":
+ if (!this.cleanup.isValid(value))
+ return true;
+
+ this.getDoc().execCommand(command, user_interface, value);
+ tinyMCE.triggerNodeChange();
break;
- case "Strikethrough":
- if (tinyMCE.isSafari)
- this.execCommand("mceInsertContent", false, "<strike>" + this.selection.getSelectedHTML() + "</strike>");
- else
- this.getDoc().execCommand(command, user_interface, value);
+ case "InsertUnorderedList":
+ case "InsertOrderedList":
+ this.getDoc().execCommand(command, user_interface, value);
+ tinyMCE.triggerNodeChange();
+ break;
+ case "Strikethrough":
+ this.getDoc().execCommand(command, user_interface, value);
tinyMCE.triggerNodeChange();
break;
@@ -2691,7 +2860,7 @@ TinyMCE_Control.prototype = {
if (tinyMCE.isGecko && new RegExp('<(div|blockquote|code|dt|dd|dl|samp)>', 'gi').test(value))
value = value.replace(/[^a-z]/gi, '');
- if (tinyMCE.isMSIE && new RegExp('blockquote|code|samp', 'gi').test(value)) {
+ if (tinyMCE.isIE && new RegExp('blockquote|code|samp', 'gi').test(value)) {
var b = this.selection.getBookmark();
this.getDoc().execCommand("FormatBlock", false, '<p>');
tinyMCE.renameElement(tinyMCE.getParentBlockElement(this.getFocusElement()), value);
@@ -2708,7 +2877,7 @@ TinyMCE_Control.prototype = {
if (!value)
value = tinyMCE.getParentElement(this.getFocusElement());
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
value.outerHTML = value.innerHTML;
} else {
var rng = value.ownerDocument.createRange();
@@ -2759,7 +2928,7 @@ TinyMCE_Control.prototype = {
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) {
+ if (tinyMCE.isIE) {
// Control range
if (rng.item)
parentElm = rng.item(0);
@@ -2953,10 +3122,20 @@ TinyMCE_Control.prototype = {
return;
case "forecolor":
+ value = value == null ? this.foreColor : value;
+ value = tinyMCE.trim(value);
+ value = value.charAt(0) != '#' ? (isNaN('0x' + value) ? value : '#' + value) : value;
+
+ this.foreColor = value;
this.getDoc().execCommand('forecolor', false, value);
break;
case "HiliteColor":
+ value = value == null ? this.backColor : value;
+ value = tinyMCE.trim(value);
+ value = value.charAt(0) != '#' ? (isNaN('0x' + value) ? value : '#' + value) : value;
+ this.backColor = value;
+
if (tinyMCE.isGecko) {
this._setUseCSS(true);
this.getDoc().execCommand('hilitecolor', false, value);
@@ -2994,9 +3173,14 @@ TinyMCE_Control.prototype = {
// 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);
+
+ if (this.getBody().nodeName == 'BODY')
+ tinyMCE._setHTML(doc, value);
+ else
+ this.getBody().innerHTML = value;
+
+ tinyMCE.setInnerHTML(this.getBody(), tinyMCE._cleanupHTML(this, doc, this.settings, this.getBody(), false, false, false, true));
+ tinyMCE.convertAllRelativeURLs(this.getBody());
// Cleanup any mess left from storyAwayURLs
tinyMCE._removeInternal(this.getBody());
@@ -3005,8 +3189,8 @@ TinyMCE_Control.prototype = {
if (tinyMCE.getParam("convert_fonts_to_spans"))
tinyMCE.convertSpansToFonts(doc);
- tinyMCE.handleVisualAid(doc.body, true, this.visualAid, this);
- tinyMCE._setEventsEnabled(doc.body, false);
+ tinyMCE.handleVisualAid(this.getBody(), true, this.visualAid, this);
+ tinyMCE._setEventsEnabled(this.getBody(), false);
return true;
case "mceCleanup":
@@ -3035,7 +3219,7 @@ TinyMCE_Control.prototype = {
var selectedText = "";
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
var rng = doc.selection.createRange();
selectedText = rng.text;
} else
@@ -3074,8 +3258,8 @@ TinyMCE_Control.prototype = {
this.execCommand('mceInsertContent', false, key);
// Store away scroll pos
- var scrollX = this.getDoc().body.scrollLeft + this.getDoc().documentElement.scrollLeft;
- var scrollY = this.getDoc().body.scrollTop + this.getDoc().documentElement.scrollTop;
+ var scrollX = this.getBody().scrollLeft + this.getDoc().documentElement.scrollLeft;
+ var scrollY = this.getBody().scrollTop + this.getDoc().documentElement.scrollTop;
// Find marker and replace with RAW HTML
var html = this.getBody().innerHTML;
@@ -3095,7 +3279,9 @@ TinyMCE_Control.prototype = {
value = '';
var insertHTMLFailed = false;
- this.getWin().focus();
+
+ // Removed since it produced problems in IE
+ // this.getWin().focus();
if (tinyMCE.isGecko || tinyMCE.isOpera) {
try {
@@ -3131,15 +3317,7 @@ TinyMCE_Control.prototype = {
}
}
- // 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 (!tinyMCE.isMSIE) {
+ if (!tinyMCE.isIE) {
var isHTML = value.indexOf('<') != -1;
var sel = this.getSel();
var rng = this.getRng();
@@ -3200,18 +3378,23 @@ TinyMCE_Control.prototype = {
tinyMCE.fixGeckoBaseHREFBug(2, this.getDoc(), value);
} else {
- var rng = doc.selection.createRange();
+ var rng = doc.selection.createRange(), tmpRng = null;
var c = value.indexOf('<!--') != -1;
// Fix comment bug, add tag before comments
if (c)
value = tinyMCE.uniqueTag + value;
+ // tmpRng = rng.duplicate(); // Store away range (Fixes Undo bookmark bug in IE)
+
if (rng.item)
rng.item(0).outerHTML = value;
else
rng.pasteHTML(value);
+ //if (tmpRng)
+ // tmpRng.select(); // Restore range (Fixes Undo bookmark bug in IE)
+
// Remove unique tag
if (c) {
var e = this.getDoc().getElementById('mceTMPElement');
@@ -3219,14 +3402,15 @@ TinyMCE_Control.prototype = {
}
}
+ tinyMCE.execCommand("mceAddUndoLevel");
tinyMCE.triggerNodeChange();
break;
case "mceStartTyping":
if (tinyMCE.settings['custom_undo_redo'] && this.undoRedo.typingUndoIndex == -1) {
this.undoRedo.typingUndoIndex = this.undoRedo.undoIndex;
+ tinyMCE.typingUndoIndex = tinyMCE.undoIndex;
this.execCommand('mceAddUndoLevel');
- //tinyMCE.debug("mceStartTyping");
}
break;
@@ -3234,8 +3418,9 @@ TinyMCE_Control.prototype = {
if (tinyMCE.settings['custom_undo_redo'] && this.undoRedo.typingUndoIndex != -1) {
this.execCommand('mceAddUndoLevel');
this.undoRedo.typingUndoIndex = -1;
- //tinyMCE.debug("mceEndTyping");
}
+
+ tinyMCE.typingUndoIndex = -1;
break;
case "mceBeginUndoLevel":
@@ -3281,7 +3466,8 @@ TinyMCE_Control.prototype = {
case "Indent":
this.getDoc().execCommand(command, user_interface, value);
tinyMCE.triggerNodeChange();
- if (tinyMCE.isMSIE) {
+
+ if (tinyMCE.isIE) {
var n = tinyMCE.getParentElement(this.getFocusElement(), "blockquote");
do {
if (n && n.nodeName == "BLOCKQUOTE") {
@@ -3300,7 +3486,7 @@ TinyMCE_Control.prototype = {
return;
}
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
try {
var rng = doc.selection.createRange();
rng.execCommand("RemoveFormat", false, null);
@@ -3406,21 +3592,30 @@ TinyMCE_Control.prototype = {
this.settings['area_width'] += deltaWidth;
this.settings['area_height'] += deltaHeight;
+ this.settings['width_style'] = "" + this.settings['width'];
+ this.settings['height_style'] = "" + this.settings['height'];
+
// Special % handling
if (("" + this.settings['width']).indexOf('%') != -1)
this.settings['area_width'] = "100%";
+ else
+ this.settings['width_style'] += 'px';
if (("" + this.settings['height']).indexOf('%') != -1)
this.settings['area_height'] = "100%";
+ else
+ this.settings['height_style'] += 'px';
if (("" + replace_element.style.width).indexOf('%') != -1) {
this.settings['width'] = replace_element.style.width;
this.settings['area_width'] = "100%";
+ this.settings['width_style'] = "100%";
}
if (("" + replace_element.style.height).indexOf('%') != -1) {
this.settings['height'] = replace_element.style.height;
this.settings['area_height'] = "100%";
+ this.settings['height_style'] = "100%";
}
html = tinyMCE.applyTemplate(html);
@@ -3489,7 +3684,7 @@ TinyMCE_Control.prototype = {
var dynamicIFrame = false;
var tElm = targetDoc.getElementById(this.editorId);
- if (!tinyMCE.isMSIE) {
+ if (!tinyMCE.isIE) {
// Node case is preserved in XML strict mode
if (tElm && (tElm.nodeName == "SPAN" || tElm.nodeName == "span")) {
tElm = tinyMCE._createIFrame(tElm, targetDoc);
@@ -3543,7 +3738,7 @@ TinyMCE_Control.prototype = {
// 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)
+ if (tinyMCE.isIE)
window.setTimeout("tinyMCE.addEventHandlers(tinyMCE.instances[\"" + this.editorId + "\"]);", 1);
tinyMCE.setupContent(this.editorId, true);
@@ -3573,6 +3768,25 @@ TinyMCE_Control.prototype = {
}
},
+ getHTML : function(r) {
+ var h, d = this.getDoc(), b = this.getBody();
+
+ if (r)
+ return b.innerHTML;
+
+ h = tinyMCE._cleanupHTML(this, d, this.settings, b, false, true, false, true);
+
+ if (tinyMCE.getParam("convert_fonts_to_spans"))
+ tinyMCE.convertSpansToFonts(d);
+
+ return h;
+ },
+
+ setHTML : function(h) {
+ this.execCommand('mceSetContent', false, h);
+ this.repaint();
+ },
+
getFocusElement : function() {
return this.selection.getFocusElement();
},
@@ -3586,13 +3800,13 @@ TinyMCE_Control.prototype = {
},
triggerSave : function(skip_cleanup, skip_callback) {
- var e, nl = new Array(), i, s;
+ var e, nl = [], i, s;
this.switchSettings();
s = tinyMCE.settings;
// Force hidden tabs visible while serializing
- if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ if (tinyMCE.isRealIE) {
e = this.iframeElement;
do {
@@ -3658,7 +3872,8 @@ TinyMCE_Control.prototype = {
nl[i].elm.className = s.hidden_tab_class;
}
}
-};
+
+ };
/* file:jscripts/tiny_mce/classes/TinyMCE_Cleanup.class.js */
@@ -3679,12 +3894,17 @@ TinyMCE_Engine.prototype.cleanupHTMLCode = function(s) {
s = s.replace(new RegExp('<(img|br|hr)([^>]*)><\\/(img|br|hr)>', 'gi'), '<$1$2 />');
// Weird MSIE bug, <p><hr /></p> breaks runtime?
- if (tinyMCE.isMSIE)
+ if (tinyMCE.isIE)
s = s.replace(new RegExp('<p><hr \\/><\\/p>', 'gi'), "<hr>");
+ // Weird tags will make IE error #bug: 1538495
+ if (tinyMCE.isIE)
+ s = s.replace(/<!(\s*)\/>/g, '');
+
// Convert relative anchors to absolute URLs ex: #something to file.htm#something
- if (tinyMCE.getParam('convert_urls'))
- s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#");
+ // Removed: Since local document anchors should never be forced absolute example edit.php?id=something
+ //if (tinyMCE.getParam('convert_urls'))
+ // s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#");
return s;
};
@@ -3826,7 +4046,7 @@ TinyMCE_Engine.prototype.convertSpansToFonts = function(doc) {
var h = doc.body.innerHTML;
h = h.replace(/<span/gi, '<font');
h = h.replace(/<\/span/gi, '</font');
- doc.body.innerHTML = h;
+ tinyMCE.setInnerHTML(doc.body, h);
var s = doc.getElementsByTagName("font");
for (var i=0; i<s.length; i++) {
@@ -3865,7 +4085,7 @@ TinyMCE_Engine.prototype.convertFontsToSpans = function(doc) {
var h = doc.body.innerHTML;
h = h.replace(/<font/gi, '<span');
h = h.replace(/<\/font/gi, '</span');
- doc.body.innerHTML = h;
+ tinyMCE.setInnerHTML(doc.body, h);
var fsClasses = tinyMCE.getParam('font_size_classes');
if (fsClasses != '')
@@ -3921,20 +4141,11 @@ TinyMCE_Engine.prototype.cleanupAnchors = function(doc) {
};
TinyMCE_Engine.prototype.getContent = function(editor_id) {
- var h;
-
if (typeof(editor_id) != "undefined")
- tinyMCE.selectedInstance = tinyMCE.getInstanceById(editor_id);
+ tinyMCE.getInstanceById(editor_id).select();
- if (tinyMCE.selectedInstance) {
- h = tinyMCE._cleanupHTML(this.selectedInstance, this.selectedInstance.getDoc(), tinyMCE.settings, this.selectedInstance.getBody(), false, true);
-
- // When editing always use fonts internaly
- if (tinyMCE.getParam("convert_fonts_to_spans"))
- tinyMCE.convertSpansToFonts(this.selectedInstance.getDoc());
-
- return h;
- }
+ if (tinyMCE.selectedInstance)
+ return tinyMCE.selectedInstance.getHTML();
return null;
};
@@ -3986,8 +4197,8 @@ TinyMCE_Engine.prototype._fixTables = function(d) {
}
};
-TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual, on_save, on_submit) {
- var h, d, t1, t2, t3, t4, t5, c, s;
+TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual, on_save, on_submit, inn) {
+ var h, d, t1, t2, t3, t4, t5, c, s, nb;
if (!tinyMCE.getParam('cleanup'))
return elm.innerHTML;
@@ -4025,25 +4236,28 @@ TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual,
c.sourceIndex = -1;
if (s.cleanup_serializer == "xml")
- h = c.serializeNodeAsXML(elm);
+ h = c.serializeNodeAsXML(elm, inn);
else
- h = c.serializeNodeAsHTML(elm);
+ h = c.serializeNodeAsHTML(elm, inn);
if (d)
t3 = new Date().getTime();
// Post processing
+ nb = tinyMCE.getParam('entity_encoding') == 'numeric' ? '&#160;' : '&nbsp;';
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(/<td>\s*<br \/>\s*<\/td>/g, '<td>' + nb + '</td>');
+ h = h.replace(/<p>\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>');
+ h = h.replace(/<br \/>$/, ''); // Remove last BR for Gecko
+ h = h.replace(/<br \/><\/p>/g, '</p>'); // Remove last BR in P tags for Gecko
+ h = h.replace(/<p>\s*(&nbsp;|&#160;)\s*<br \/>\s*(&nbsp;|&#160;)\s*<\/p>/g, '<p>' + nb + '</p>');
+ h = h.replace(/<p>\s*(&nbsp;|&#160;)\s*<br \/>\s*<\/p>/g, '<p>' + nb + '</p>');
+ h = h.replace(/<p>\s*<br \/>\s*&nbsp;\s*<\/p>/g, '<p>' + nb + '</p>');
h = h.replace(new RegExp('<a>(.*?)<\\/a>', 'g'), '$1');
- h = h.replace(/<p([^>]*)>\s*<\/p>/g, '<p$1>&nbsp;</p>');
+ h = h.replace(/<p([^>]*)>\s*<\/p>/g, '<p$1>' + nb + '</p>');
// Clean body
if (/^\s*(<br \/>|<p>&nbsp;<\/p>|<p>&#160;<\/p>|<p><\/p>)\s*$/.test(h))
@@ -4059,7 +4273,7 @@ TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual,
// 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>');
+ h = h.replace(/<td([^>]*)>\s*<br \/>\s*<\/td>/g, '<td$1>' + nb + '</td>');
}
if (s.force_br_newlines)
@@ -4097,7 +4311,7 @@ TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual,
};
function TinyMCE_Cleanup() {
- this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
+ this.isIE = (navigator.appName == "Microsoft Internet Explorer");
this.rules = tinyMCE.clearArray(new Array());
// Default config
@@ -4118,7 +4332,7 @@ function TinyMCE_Cleanup() {
this.vElements = tinyMCE.clearArray(new Array());
this.vElementsRe = '';
- this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|BUTTON|AREA)$/;
+ this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|AREA)$/;
this.codeElementsRe = /^(SCRIPT|STYLE)$/;
this.serializationId = 0;
this.mceAttribs = {
@@ -4144,6 +4358,7 @@ TinyMCE_Cleanup.prototype = {
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', '<(\\/?)(', ')([^>]*)>');
+ this.serializedNodes = [];
if (s.invalid_elements != '')
this.iveRe = this._arrayToRe(s.invalid_elements.toUpperCase().split(','), 'g', '^(', ')$');
@@ -4186,6 +4401,71 @@ TinyMCE_Cleanup.prototype = {
this.vElementsRe = this._arrayToRe(this.vElements, '');
},
+ isValid : function(n) {
+ this._setupRules(); // Will initialize cleanup rules
+
+ // Clean the name up a bit
+ n = n.replace(/[^a-z0-9]+/gi, '').toUpperCase();
+
+ return !tinyMCE.getParam('cleanup') || this.vElementsRe.test(n);
+ },
+
+ addChildRemoveRuleStr : function(s) {
+ var x, y, p, i, t, tn, ta, cl, r;
+
+ if (!s)
+ return;
+
+ ta = s.split(',');
+ for (x=0; x<ta.length; x++) {
+ s = ta[x];
+
+ // Split tag/children
+ 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 = "^(";
+
+ // Build regex
+ cl = this.split(/\|/, p[1]);
+ for (i=0; i<cl.length; i++) {
+ if (cl[i] == '%istrict')
+ r += tinyMCE.inlineStrict;
+ else if (cl[i] == '%itrans')
+ r += tinyMCE.inlineTransitional;
+ else if (cl[i] == '%istrict_na')
+ r += tinyMCE.inlineStrict.substring(2);
+ else if (cl[i] == '%itrans_na')
+ r += tinyMCE.inlineTransitional.substring(2);
+ else if (cl[i] == '%btrans')
+ r += tinyMCE.blockElms;
+ else if (cl[i] == '%strict')
+ r += tinyMCE.blockStrict;
+ else
+ r += (cl[i].charAt(0) != '#' ? cl[i].toUpperCase() : cl[i]);
+
+ r += (i != cl.length - 1 ? '|' : '');
+ }
+
+ r += ')$';
+//tinyMCE.debug(t + "=" + r);
+ if (this.childRules == null)
+ this.childRules = tinyMCE.clearArray(new Array());
+
+ this.childRules[tn[y]] = new RegExp(r);
+
+ if (p.length > 1)
+ this.childRules[tn[y]].wrapTag = p[2];
+ }
+ }
+ },
+
parseRuleStr : function(s) {
var ta, p, r, a, i, x, px, t, tn, y, av, or = tinyMCE.clearArray(new Array()), dv;
@@ -4233,6 +4513,15 @@ TinyMCE_Cleanup.prototype = {
for (i=0; i<a.length; i++) {
t = a[i];
+ if (t.charAt(0) == '!') {
+ a[i] = t = t.substring(1);
+
+ if (!r.reqAttribsRe)
+ r.reqAttribsRe = '\\s+(' + t;
+ else
+ r.reqAttribsRe += '|' + t;
+ }
+
av = new RegExp('(=|:|<)(.*?)$').exec(t);
t = t.replace(new RegExp('(=|:|<).*?$'), '');
if (av && av.length > 0) {
@@ -4252,7 +4541,7 @@ TinyMCE_Cleanup.prototype = {
if (!r.validAttribValues)
r.validAttribValues = tinyMCE.clearArray(new Array());
- r.validAttribValues[t.toLowerCase()] = this._arrayToRe(this.split('?', av[0].substring(1)), '');
+ r.validAttribValues[t.toLowerCase()] = this._arrayToRe(this.split('?', av[0].substring(1)), 'i');
}
}
@@ -4261,6 +4550,9 @@ TinyMCE_Cleanup.prototype = {
a[i] = t.toLowerCase();
}
+ if (r.reqAttribsRe)
+ r.reqAttribsRe = new RegExp(r.reqAttribsRe + ')=\"', 'g');
+
r.vAttribsRe += ')$';
r.vAttribsRe = this._wildcardToRe(r.vAttribsRe);
r.vAttribsReIsWild = new RegExp('\\*|\\?|\\+', 'g').test(r.vAttribsRe);
@@ -4285,7 +4577,7 @@ TinyMCE_Cleanup.prototype = {
var s, b;
if (!this.xmlDoc) {
- if (this.isMSIE) {
+ if (this.isIE) {
try {this.xmlDoc = new ActiveXObject('MSXML2.DOMDocument');} catch (e) {}
if (!this.xmlDoc)
@@ -4305,7 +4597,7 @@ TinyMCE_Cleanup.prototype = {
this._convertToXML(n, b);
- if (this.isMSIE)
+ if (this.isIE)
return this.xmlDoc.xml;
else
return new XMLSerializer().serializeToString(this.xmlDoc);
@@ -4356,23 +4648,36 @@ TinyMCE_Cleanup.prototype = {
}
},
- serializeNodeAsHTML : function(n) {
- var en, no, h = '', i, l, r, cn, va = false, f = false, at, hc;
+ serializeNodeAsHTML : function(n, inn) {
+ var en, no, h = '', i, l, t, st, r, cn, va = false, f = false, at, hc, cr;
this._setupRules(); // Will initialize cleanup rules
if (this._isDuplicate(n))
return '';
+ // Skip non valid child elements
+ if (n.parentNode && this.childRules != null) {
+ cr = this.childRules[n.parentNode.nodeName];
+
+ if (typeof(cr) != "undefined" && !cr.test(n.nodeName)) {
+ st = true;
+ t = null;
+ }
+ }
+
switch (n.nodeType) {
case 1: // Element
hc = n.hasChildNodes();
+ if (st)
+ break;
+
// MSIE sometimes produces <//tag>
- if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && n.nodeName.indexOf('/') != -1)
+ if ((tinyMCE.isRealIE) && n.nodeName.indexOf('/') != -1)
break;
- if (this.vElementsRe.test(n.nodeName) && (!this.iveRe || !this.iveRe.test(n.nodeName))) {
+ if (this.vElementsRe.test(n.nodeName) && (!this.iveRe || !this.iveRe.test(n.nodeName)) && !inn) {
va = true;
r = this.rules[n.nodeName];
@@ -4392,7 +4697,7 @@ TinyMCE_Cleanup.prototype = {
if (r.removeEmpty && !hc)
return "";
- h += '<' + en;
+ t = '<' + en;
if (r.vAttribsReIsWild) {
// Serialize wildcard attributes
@@ -4400,12 +4705,12 @@ TinyMCE_Cleanup.prototype = {
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);
+ t += 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]);
+ t += this._serializeAttribute(n, r, r.vAttribs[i]);
}
// Serialize mce_ atts
@@ -4414,28 +4719,39 @@ TinyMCE_Cleanup.prototype = {
for (no in at) {
if (at[no])
- h += this._serializeAttribute(n, r, at[no]);
+ t += this._serializeAttribute(n, r, at[no]);
}
}
+ // Check for required attribs
+ if (r.reqAttribsRe && !t.match(r.reqAttribsRe))
+ t = null;
+
// Close these
- if (this.closeElementsRe.test(n.nodeName))
- return h + ' />';
+ if (t != null && this.closeElementsRe.test(n.nodeName))
+ return t + ' />';
- h += '>';
+ if (t != null)
+ h += t + '>';
- if (this.isMSIE && this.codeElementsRe.test(n.nodeName))
+ if (this.isIE && this.codeElementsRe.test(n.nodeName))
h += n.innerHTML;
}
break;
case 3: // Text
+ if (st)
+ break;
+
if (n.parentNode && this.codeElementsRe.test(n.parentNode.nodeName))
- return this.isMSIE ? '' : n.nodeValue;
+ return this.isIE ? '' : n.nodeValue;
return this.xmlEncode(n.nodeValue);
case 8: // Comment
+ if (st)
+ break;
+
return "<!--" + this._trimComment(n.nodeValue) + "-->";
}
@@ -4451,7 +4767,7 @@ TinyMCE_Cleanup.prototype = {
h += this.fillStr;
// End element
- if (va)
+ if (t != null && va)
h += '</' + en + '>';
return h;
@@ -4488,8 +4804,12 @@ TinyMCE_Cleanup.prototype = {
if (av.length != 0 && av == "{$uid}")
av = "uid_" + (this.idCount++);
- if (av.length != 0)
- return " " + an + "=" + '"' + this.xmlEncode(av) + '"';
+ if (av.length != 0) {
+ if (an.indexOf('on') != 0)
+ av = this.xmlEncode(av);
+
+ return " " + an + "=" + '"' + av + '"';
+ }
return "";
},
@@ -4497,6 +4817,12 @@ TinyMCE_Cleanup.prototype = {
formatHTML : function(h) {
var s = this.settings, p = '', i = 0, li = 0, o = '', l;
+ // Replace BR in pre elements to \n
+ h = h.replace(/<pre([^>]*)>(.*?)<\/pre>/gi, function (a, b, c) {
+ c = c.replace(/<br\s*\/>/gi, '\n');
+ return '<pre' + b + '>' + c + '</pre>';
+ });
+
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
@@ -4527,7 +4853,7 @@ TinyMCE_Cleanup.prototype = {
},
xmlEncode : function(s) {
- var i, l, e, o = '', c;
+ var cl = this;
this._setupEntities(); // Will intialize lookup table
@@ -4536,29 +4862,16 @@ TinyMCE_Cleanup.prototype = {
return tinyMCE.xmlEncode(s);
case "named":
- for (i=0, l=s.length; i<l; i++) {
- c = s.charCodeAt(i);
- e = this.entities[c];
+ return s.replace(new RegExp('[\u007F-\uFFFF<>&"\']', 'g'), function (c, b) {
+ b = cl.entities[c.charCodeAt(0)];
- if (e && e != '')
- o += '&' + e + ';';
- else
- o += String.fromCharCode(c);
- }
-
- return o;
+ return b ? '&' + b + ';' : c;
+ });
case "numeric":
- for (i=0, l=s.length; i<l; i++) {
- c = s.charCodeAt(i);
-
- if (c > 127 || c == 60 || c == 62 || c == 38 || c == 39 || c == 34)
- o += '&#' + c + ";";
- else
- o += String.fromCharCode(c);
- }
-
- return o;
+ return s.replace(new RegExp('[\u007F-\uFFFF<>&"\']', 'g'), function (c, b) {
+ return b ? '&#' + c.charCodeAt(0) + ';' : c;
+ });
}
return s;
@@ -4596,16 +4909,16 @@ TinyMCE_Cleanup.prototype = {
if (n == "class" && !v)
v = e.className;
- if (this.isMSIE && n == "http-equiv")
+ if (this.isIE && n == "http-equiv")
v = e.httpEquiv;
- if (this.isMSIE && e.nodeName == "FORM" && n == "enctype" && v == "application/x-www-form-urlencoded")
+ if (this.isIE && e.nodeName == "FORM" && n == "enctype" && v == "application/x-www-form-urlencoded")
v = "";
- if (this.isMSIE && e.nodeName == "INPUT" && n == "size" && v == "20")
+ if (this.isIE && e.nodeName == "INPUT" && n == "size" && v == "20")
v = "";
- if (this.isMSIE && e.nodeName == "INPUT" && n == "maxlength" && v == "2147483647")
+ if (this.isIE && e.nodeName == "INPUT" && n == "maxlength" && v == "2147483647")
v = "";
if (n == "style" && !tinyMCE.isOpera)
@@ -4679,6 +4992,7 @@ TinyMCE_Cleanup.prototype = {
if (!this.rulesDone) {
this.addRuleStr(s.valid_elements);
this.addRuleStr(s.extended_valid_elements);
+ this.addChildRemoveRuleStr(s.valid_child_elements);
this.rulesDone = true;
}
@@ -4690,7 +5004,7 @@ TinyMCE_Cleanup.prototype = {
if (!this.settings.fix_content_duplication)
return false;
- if (tinyMCE.isMSIE && !tinyMCE.isOpera && n.nodeType == 1) {
+ if (tinyMCE.isRealIE && n.nodeType == 1) {
// Mark elements
if (n.mce_serialized == this.serializationId)
return true;
@@ -4708,10 +5022,44 @@ TinyMCE_Cleanup.prototype = {
return false;
}
-};
+
+ };
/* file:jscripts/tiny_mce/classes/TinyMCE_DOMUtils.class.js */
+TinyMCE_Engine.prototype.createTagHTML = function(tn, a, h) {
+ var o = '', f = tinyMCE.xmlEncode;
+
+ o = '<' + tn;
+
+ if (a) {
+ for (n in a) {
+ if (typeof(a[n]) != 'function' && a[n] != null)
+ o += ' ' + f(n) + '="' + f('' + a[n]) + '"';
+ }
+ }
+
+ o += !h ? ' />' : '>' + h + '</' + tn + '>';
+
+ return o;
+};
+
+TinyMCE_Engine.prototype.createTag = function(d, tn, a, h) {
+ var o = d.createElement(tn);
+
+ if (a) {
+ for (n in a) {
+ if (typeof(a[n]) != 'function' && a[n] != null)
+ tinyMCE.setAttrib(o, n, a[n]);
+ }
+ }
+
+ if (h)
+ o.innerHTML = h;
+
+ return o;
+};
+
TinyMCE_Engine.prototype.getElementByAttributeValue = function(n, e, a, v) {
return (n = this.getElementsByAttributeValue(n, e, a, v)).length == 0 ? null : n[0];
};
@@ -4731,13 +5079,10 @@ TinyMCE_Engine.prototype.isBlockElement = function(n) {
return n != null && n.nodeType == 1 && this.blockRegExp.test(n.nodeName);
};
-TinyMCE_Engine.prototype.getParentBlockElement = function(n) {
- while (n) {
- if (this.isBlockElement(n))
- return n;
-
- n = n.parentNode;
- }
+TinyMCE_Engine.prototype.getParentBlockElement = function(n, r) {
+ return this.getParentNode(n, function(n) {
+ return tinyMCE.isBlockElement(n);
+ }, r);
return null;
};
@@ -4752,7 +5097,16 @@ TinyMCE_Engine.prototype.insertAfter = function(n, r){
TinyMCE_Engine.prototype.setInnerHTML = function(e, h) {
var i, nl, n;
- if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ // Convert all strong/em to b/i in Gecko
+ if (tinyMCE.isGecko) {
+ h = h.replace(/<strong/gi, '<b');
+ h = h.replace(/<em(\/?)/gi, '<i');
+ h = h.replace(/<em /gi, '<i');
+ h = h.replace(/<\/strong>/gi, '</b>');
+ h = h.replace(/<\/em>/gi, '</i>');
+ }
+
+ if (tinyMCE.isRealIE) {
// 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, '>');
@@ -4782,23 +5136,28 @@ TinyMCE_Engine.prototype.setInnerHTML = function(e, h) {
};
TinyMCE_Engine.prototype.getOuterHTML = function(e) {
- if (tinyMCE.isMSIE)
+ if (tinyMCE.isIE)
return e.outerHTML;
var d = e.ownerDocument.createElement("body");
- d.appendChild(e);
+ d.appendChild(e.cloneNode(true));
return d.innerHTML;
};
-TinyMCE_Engine.prototype.setOuterHTML = function(e, h) {
- if (tinyMCE.isMSIE) {
+TinyMCE_Engine.prototype.setOuterHTML = function(e, h, d) {
+ var d = typeof(d) == "undefined" ? e.ownerDocument : d, i, nl, t;
+
+ if (tinyMCE.isIE && e.nodeType == 1)
e.outerHTML = h;
- return;
- }
+ else {
+ t = d.createElement("body");
+ t.innerHTML = h;
- var d = e.ownerDocument.createElement("body");
- d.innerHTML = h;
- e.parentNode.replaceChild(d.firstChild, e);
+ for (i=0, nl=t.childNodes; i<nl.length; i++)
+ e.parentNode.insertBefore(nl[i].cloneNode(true), e);
+
+ e.parentNode.removeChild(e);
+ }
};
TinyMCE_Engine.prototype._getElementById = function(id, d) {
@@ -4825,56 +5184,28 @@ TinyMCE_Engine.prototype._getElementById = function(id, d) {
};
TinyMCE_Engine.prototype.getNodeTree = function(n, na, t, nn) {
- var i;
-
- if (typeof(t) == "undefined" || n.nodeType == t && (typeof(nn) == "undefined" || n.nodeName == nn))
- na[na.length] = n;
-
- if (n.hasChildNodes()) {
- for (i=0; i<n.childNodes.length; i++)
- tinyMCE.getNodeTree(n.childNodes[i], na, t, nn);
- }
-
- return na;
+ return this.selectNodes(n, function(n) {
+ return (!t || n.nodeType == t) && (!nn || n.nodeName == nn);
+ }, na ? na : new Array());
};
-TinyMCE_Engine.prototype.getParentElement = function(node, names, attrib_name, attrib_value) {
- if (typeof(names) == "undefined") {
- if (node.nodeType == 1)
- return node;
-
- // Find parent node that is a element
- while ((node = node.parentNode) != null && node.nodeType != 1) ;
+TinyMCE_Engine.prototype.getParentElement = function(n, na, f, r) {
+ var re = na ? new RegExp('^(' + na.toUpperCase().replace(/,/g, '|') + ')$') : 0, v;
- return node;
- }
+ // Compatiblity with old scripts where f param was a attribute string
+ if (f && typeof(f) == 'string')
+ return this.getParentElement(n, na, function(no) {return tinyMCE.getAttrib(no, f) != '';});
- if (node == null)
- return null;
-
- var namesAr = names.toUpperCase().split(',');
-
- 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);
-
- return null;
+ return this.getParentNode(n, function(n) {
+ return ((n.nodeType == 1 && !re) || (re && re.test(n.nodeName))) && (!f || f(n));
+ }, r);
};
-TinyMCE_Engine.prototype.getParentNode = function(n, f) {
+TinyMCE_Engine.prototype.getParentNode = function(n, f, r) {
while (n) {
+ if (n == r)
+ return null;
+
if (f(n))
return n;
@@ -4884,15 +5215,17 @@ TinyMCE_Engine.prototype.getParentNode = function(n, f) {
return null;
};
-TinyMCE_Engine.prototype.getAttrib = function(elm, name, default_value) {
- if (typeof(default_value) == "undefined")
- default_value = "";
+TinyMCE_Engine.prototype.getAttrib = function(elm, name, dv) {
+ var v;
+
+ if (typeof(dv) == "undefined")
+ dv = "";
// Not a element
if (!elm || elm.nodeType != 1)
- return default_value;
+ return dv;
- var v = elm.getAttribute(name);
+ v = elm.getAttribute(name);
// Try className for class attrib
if (name == "class" && !v)
@@ -4906,47 +5239,46 @@ TinyMCE_Engine.prototype.getAttrib = function(elm, name, default_value) {
if (tinyMCE.isGecko && name == "href" && elm.href != null && elm.href != "")
v = elm.href;
- if (name == "http-equiv" && tinyMCE.isMSIE)
+ if (name == "http-equiv" && tinyMCE.isIE)
v = elm.httpEquiv;
if (name == "style" && !tinyMCE.isOpera)
v = elm.style.cssText;
- return (v && v != "") ? v : default_value;
+ return (v && v != "") ? v : dv;
};
-TinyMCE_Engine.prototype.setAttrib = function(element, name, value, fix_value) {
- if (typeof(value) == "number" && value != null)
- value = "" + value;
+TinyMCE_Engine.prototype.setAttrib = function(el, name, va, fix) {
+ if (typeof(va) == "number" && va != null)
+ va = "" + va;
- if (fix_value) {
- if (value == null)
- value = "";
+ if (fix) {
+ if (va == null)
+ va = "";
- var re = new RegExp('[^0-9%]', 'g');
- value = value.replace(re, '');
+ va = va.replace(/[^0-9%]/g, '');
}
if (name == "style")
- element.style.cssText = value;
+ el.style.cssText = va;
if (name == "class")
- element.className = value;
+ el.className = va;
- if (value != null && value != "" && value != -1)
- element.setAttribute(name, value);
+ if (va != null && va != "" && va != -1)
+ el.setAttribute(name, va);
else
- element.removeAttribute(name);
+ el.removeAttribute(name);
};
-TinyMCE_Engine.prototype.setStyleAttrib = function(elm, name, value) {
- eval('elm.style.' + name + '=value;');
+TinyMCE_Engine.prototype.setStyleAttrib = function(e, n, v) {
+ e.style[n] = v;
- // 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);
+ // Style attrib deleted in IE
+ if (tinyMCE.isIE && v == null || v == '') {
+ v = tinyMCE.serializeStyle(tinyMCE.parseStyle(e.style.cssText));
+ e.style.cssText = v;
+ e.setAttribute("style", v);
}
};
@@ -4967,16 +5299,16 @@ TinyMCE_Engine.prototype.switchClass = function(ei, c) {
}
};
-TinyMCE_Engine.prototype.getAbsPosition = function(n) {
- var p = {absLeft : 0, absTop : 0};
+TinyMCE_Engine.prototype.getAbsPosition = function(n, cn) {
+ var l = 0, t = 0;
- while (n) {
- p.absLeft += n.offsetLeft;
- p.absTop += n.offsetTop;
+ while (n && n != cn) {
+ l += n.offsetLeft;
+ t += n.offsetTop;
n = n.offsetParent;
}
- return p;
+ return {absLeft : l, absTop : t};
};
TinyMCE_Engine.prototype.prevNode = function(e, n) {
@@ -5005,6 +5337,16 @@ TinyMCE_Engine.prototype.nextNode = function(e, n) {
return null;
};
+TinyMCE_Engine.prototype.selectElements = function(n, na, f) {
+ var i, a = [], nl, x;
+
+ for (x=0, na = na.split(','); x<na.length; x++)
+ for (i=0, nl = n.getElementsByTagName(na[x]); i<nl.length; i++)
+ (!f || f(nl[i])) && a.push(nl[i]);
+
+ return a;
+};
+
TinyMCE_Engine.prototype.selectNodes = function(n, f, a) {
var i;
@@ -5024,19 +5366,16 @@ TinyMCE_Engine.prototype.selectNodes = function(n, f, a) {
TinyMCE_Engine.prototype.addCSSClass = function(e, c, b) {
var o = this.removeCSSClass(e, c);
-
return e.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
};
TinyMCE_Engine.prototype.removeCSSClass = function(e, c) {
- var a = this.explode(' ', e.className), i;
-
- for (i=0; i<a.length; i++) {
- if (a[i] == c)
- a[i] = '';
- }
+ c = e.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
+ return e.className = c != ' ' ? c : '';
+};
- return e.className = a.join(' ');
+TinyMCE_Engine.prototype.hasCSSClass = function(n, c) {
+ return new RegExp('\\b' + c + '\\b', 'g').test(n.className);
};
TinyMCE_Engine.prototype.renameElement = function(e, n, d) {
@@ -5061,6 +5400,17 @@ TinyMCE_Engine.prototype.renameElement = function(e, n, d) {
}
};
+TinyMCE_Engine.prototype.getViewPort = function(w) {
+ var d = w.document, m = d.compatMode == 'CSS1Compat', b = d.body, de = d.documentElement;
+
+ return {
+ left : w.pageXOffset || (m ? de.scrollLeft : b.scrollLeft),
+ top : w.pageYOffset || (m ? de.scrollTop : b.scrollTop),
+ width : w.innerWidth || (m ? de.clientWidth : b.clientWidth),
+ height : w.innerHeight || (m ? de.clientHeight : b.clientHeight)
+ };
+};
+
/* file:jscripts/tiny_mce/classes/TinyMCE_URL.class.js */
TinyMCE_Engine.prototype.parseURL = function(url_str) {
@@ -5228,10 +5578,10 @@ TinyMCE_Engine.prototype.convertAbsoluteURLToRelativeURL = function(base_url, ur
};
TinyMCE_Engine.prototype.convertRelativeToAbsoluteURL = function(base_url, relative_url) {
- var baseURL = this.parseURL(base_url);
+ var baseURL = this.parseURL(base_url), baseURLParts, relURLParts;
var relURL = this.parseURL(relative_url);
- if (relative_url == "" || relative_url.charAt(0) == '/' || relative_url.indexOf('://') != -1 || relative_url.indexOf('mailto:') != -1 || relative_url.indexOf('javascript:') != -1)
+ if (relative_url == "" || relative_url.indexOf('://') != -1 || /^(mailto:|javascript:|#|\/)/.test(relative_url))
return relative_url;
// Split parts
@@ -5306,7 +5656,7 @@ TinyMCE_Engine.prototype.convertURL = function(url, node, on_save) {
return url;
// Fix relative/Mozilla
- if (!tinyMCE.isMSIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/')
+ if (!tinyMCE.isIE && !on_save && url.indexOf("://") == -1 && url.charAt(0) != '/')
return tinyMCE.settings['base_href'] + url;
// Handle relative URLs
@@ -5353,12 +5703,14 @@ TinyMCE_Engine.prototype.convertURL = function(url, node, on_save) {
};
TinyMCE_Engine.prototype.convertAllRelativeURLs = function(body) {
+ var i, elms, src, href, mhref, msrc;
+
// 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');
+ elms = body.getElementsByTagName("img");
+ for (i=0; i<elms.length; i++) {
+ src = tinyMCE.getAttrib(elms[i], 'src');
- var msrc = tinyMCE.getAttrib(elms[i], 'mce_src');
+ msrc = tinyMCE.getAttrib(elms[i], 'mce_src');
if (msrc != "")
src = msrc;
@@ -5369,11 +5721,11 @@ TinyMCE_Engine.prototype.convertAllRelativeURLs = function(body) {
}
// 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');
+ elms = body.getElementsByTagName("a");
+ for (i=0; i<elms.length; i++) {
+ href = tinyMCE.getAttrib(elms[i], 'href');
- var mhref = tinyMCE.getAttrib(elms[i], 'mce_href');
+ mhref = tinyMCE.getAttrib(elms[i], 'mce_href');
if (mhref != "")
href = mhref;
@@ -5387,26 +5739,40 @@ TinyMCE_Engine.prototype.convertAllRelativeURLs = function(body) {
/* file:jscripts/tiny_mce/classes/TinyMCE_Array.class.js */
TinyMCE_Engine.prototype.clearArray = function(a) {
- for (var k in a)
- a[k] = null;
+ var n;
+
+ for (n in a)
+ a[n] = null;
return a;
};
+TinyMCE_Engine.prototype.explode = function(d, s) {
+ var ar = s.split(d), oar = new Array(), i;
+
+ for (i = 0; i<ar.length; i++) {
+ if (ar[i] != "")
+ oar[oar.length] = ar[i];
+ }
+
+ return oar;
+};
+
/* file:jscripts/tiny_mce/classes/TinyMCE_Event.class.js */
TinyMCE_Engine.prototype._setEventsEnabled = function(node, state) {
- var events = new Array('onfocus','onblur','onclick','ondblclick',
+ var evs, x, y, elms, i, event;
+ var events = ['onfocus','onblur','onclick','ondblclick',
'onmousedown','onmouseup','onmouseover','onmousemove',
- 'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup');
+ 'onmouseout','onkeypress','onkeydown','onkeydown','onkeyup'];
- 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 = "";
+ evs = tinyMCE.settings['event_elements'].split(',');
+ for (y=0; y<evs.length; y++){
+ elms = node.getElementsByTagName(evs[y]);
+ for (i=0; i<elms.length; i++) {
+ event = "";
- for (var x=0; x<events.length; x++) {
+ for (x=0; x<events.length; x++) {
if ((event = tinyMCE.getAttrib(elms[i], events[x])) != '') {
event = tinyMCE.cleanupEventStr("" + event);
@@ -5453,7 +5819,7 @@ TinyMCE_Engine.prototype._eventPatch = function(editor_id) {
if (!tinyMCE.isInstance(inst))
continue;
- tinyMCE.selectedInstance = inst;
+ inst.select();
win = inst.getWin();
if (win && win.event) {
@@ -5471,38 +5837,64 @@ TinyMCE_Engine.prototype._eventPatch = function(editor_id) {
}
};
+TinyMCE_Engine.prototype.findEvent = function(e) {
+ var n, inst;
+
+ if (e)
+ return e;
+
+ for (n in tinyMCE.instances) {
+ inst = tinyMCE.instances[n];
+
+ if (tinyMCE.isInstance(inst) && inst.getWin().event)
+ return inst.getWin().event;
+ }
+
+ return null;
+};
+
TinyMCE_Engine.prototype.unloadHandler = function() {
tinyMCE.triggerSave(true, true);
};
TinyMCE_Engine.prototype.addEventHandlers = function(inst) {
- var doc = inst.getDoc();
+ this.setEventHandlers(inst, 1);
+};
+
+TinyMCE_Engine.prototype.setEventHandlers = function(inst, s) {
+ var doc = inst.getDoc(), ie, ot, i, f = s ? tinyMCE.addEvent : tinyMCE.removeEvent;
+
+ ie = ['keypress', 'keyup', 'keydown', 'click', 'mouseup', 'mousedown', 'controlselect', 'dblclick'];
+ ot = ['keypress', 'keyup', 'keydown', 'click', 'mouseup', 'mousedown', 'focus', 'blur', 'dragdrop'];
inst.switchSettings();
- 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, "mousedown", TinyMCE_Engine.prototype._eventPatch);
- tinyMCE.addEvent(doc, "click", TinyMCE_Engine.prototype._eventPatch);
+ if (tinyMCE.isIE) {
+ for (i=0; i<ie.length; i++)
+ f(doc, ie[i], 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);
+ for (i=0; i<ot.length; i++)
+ f(doc, ot[i], tinyMCE.handleEvent);
eval('try { doc.designMode = "On"; } catch(e) {}'); // Force designmode
}
};
TinyMCE_Engine.prototype.onMouseMove = function() {
- var inst;
+ var inst, lh;
+
+ // Fix for IE7 bug where it's not restoring hover on anchors correctly
+ if (tinyMCE.lastHover) {
+ lh = tinyMCE.lastHover;
+
+ // Call out on menus and refresh class on normal buttons
+ if (lh.className.indexOf('mceMenu') != -1)
+ tinyMCE._menuButtonEvent('out', lh);
+ else
+ lh.className = lh.className;
+
+ tinyMCE.lastHover = null;
+ }
if (!tinyMCE.hasMouseMoved) {
inst = tinyMCE.selectedInstance;
@@ -5519,20 +5911,52 @@ TinyMCE_Engine.prototype.onMouseMove = function() {
};
TinyMCE_Engine.prototype.cancelEvent = function(e) {
- if (tinyMCE.isMSIE) {
+ if (!e)
+ return false;
+
+ if (tinyMCE.isIE) {
e.returnValue = false;
e.cancelBubble = true;
- } else
+ } else {
e.preventDefault();
+ e.stopPropagation && e.stopPropagation();
+ }
+
+ return false;
};
TinyMCE_Engine.prototype.addEvent = function(o, n, h) {
+ // Add cleanup for all non unload events
+ if (n != 'unload') {
+ function clean() {
+ var ex;
+
+ try {
+ tinyMCE.removeEvent(o, n, h);
+ tinyMCE.removeEvent(window, 'unload', clean);
+ o = n = h = null;
+ } catch (ex) {
+ // IE may produce access denied exception on unload
+ }
+ }
+
+ // Add memory cleaner
+ tinyMCE.addEvent(window, 'unload', clean);
+ }
+
if (o.attachEvent)
o.attachEvent("on" + n, h);
else
o.addEventListener(n, h, false);
};
+TinyMCE_Engine.prototype.removeEvent = function(o, n, h) {
+ if (o.detachEvent)
+ o.detachEvent("on" + n, h);
+ else
+ o.removeEventListener(n, h, false);
+};
+
TinyMCE_Engine.prototype.addSelectAccessibility = function(e, s, w) {
// Add event handlers
if (!s._isAccessible) {
@@ -5547,8 +5971,8 @@ TinyMCE_Engine.prototype.addSelectAccessibility = function(e, s, w) {
TinyMCE_Engine.prototype.accessibleEventHandler = function(e) {
var win = this._win;
- e = tinyMCE.isMSIE ? win.event : e;
- var elm = tinyMCE.isMSIE ? e.srcElement : e.target;
+ e = tinyMCE.isIE ? win.event : e;
+ var elm = tinyMCE.isIE ? e.srcElement : e.target;
// Unpiggyback onchange on blur
if (e.type == "blur") {
@@ -5582,7 +6006,7 @@ TinyMCE_Engine.prototype.accessibleEventHandler = function(e) {
TinyMCE_Engine.prototype._resetIframeHeight = function() {
var ife;
- if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ if (tinyMCE.isRealIE) {
ife = tinyMCE.selectedInstance.iframeElement;
/* if (ife._oldWidth) {
@@ -5608,17 +6032,17 @@ TinyMCE_Selection.prototype = {
var inst = this.instance;
var e, r = this.getRng(), h;
- if (tinyMCE.isSafari) {
- // Not realy perfect!!
- return r.toString();
- }
+ if (!r)
+ return null;
e = document.createElement("body");
- if (tinyMCE.isGecko)
+ if (r.cloneContents)
e.appendChild(r.cloneContents());
- else
+ else if (typeof(r.item) != 'undefined' || typeof(r.htmlText) != 'undefined')
e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText;
+ else
+ e.innerHTML = r.toString(); // Failed, use text for now
h = tinyMCE._cleanupHTML(inst, inst.contentDocument, inst.settings, e, e, false, true, false);
@@ -5633,7 +6057,7 @@ TinyMCE_Selection.prototype = {
var inst = this.instance;
var d, r, s, t;
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isIE) {
d = inst.getDoc();
if (d.selection.type == "Text") {
@@ -5654,29 +6078,23 @@ TinyMCE_Selection.prototype = {
},
getBookmark : function(simple) {
+ var inst = this.instance;
var rng = this.getRng();
- var doc = this.instance.getDoc();
- var sp, le, s, e, nl, i, si, ei;
- var trng, sx, sy, xx = -999999999;
-
- // Skip Opera for now
- if (tinyMCE.isOpera)
- return null;
+ var doc = inst.getDoc(), b = inst.getBody();
+ var sp, le, s, e, nl, i, si, ei, w;
+ var trng, sx, sy, xx = -999999999, vp = inst.getViewPort();
- sx = doc.body.scrollLeft + doc.documentElement.scrollLeft;
- sy = doc.body.scrollTop + doc.documentElement.scrollTop;
+ sx = vp.left;
+ sy = vp.top;
- if (tinyMCE.isSafari || tinyMCE.isGecko)
+ if (tinyMCE.isSafari || tinyMCE.isOpera || simple)
return {rng : rng, scrollX : sx, scrollY : sy};
- if (tinyMCE.isMSIE) {
- if (simple)
- return {rng : rng};
-
+ if (tinyMCE.isIE) {
if (rng.item) {
e = rng.item(0);
- nl = doc.getElementsByTagName(e.nodeName);
+ nl = b.getElementsByTagName(e.nodeName);
for (i=0; i<nl.length; i++) {
if (e == nl[i]) {
sp = i;
@@ -5691,6 +6109,11 @@ TinyMCE_Selection.prototype = {
scrollY : sy
};
} else {
+ trng = doc.body.createTextRange();
+ trng.moveToElementText(inst.getBody());
+ trng.collapse(true);
+ bp = Math.abs(trng.move('character', xx));
+
trng = rng.duplicate();
trng.collapse(true);
sp = Math.abs(trng.move('character', xx));
@@ -5700,7 +6123,7 @@ TinyMCE_Selection.prototype = {
le = Math.abs(trng.move('character', xx)) - sp;
return {
- start : sp,
+ start : sp - bp,
length : le,
scrollX : sx,
scrollY : sy
@@ -5709,51 +6132,64 @@ TinyMCE_Selection.prototype = {
}
if (tinyMCE.isGecko) {
- s = tinyMCE.getParentElement(rng.startContainer);
- for (si=0; si<s.childNodes.length && s.childNodes[si] != rng.startContainer; si++) ;
+ s = this.getSel();
+ e = this.getFocusElement();
- nl = doc.getElementsByTagName(s.nodeName);
- for (i=0; i<nl.length; i++) {
- if (s == nl[i]) {
+ if (!s)
+ return null;
+
+ if (e && e.nodeName == 'IMG') {
+ /*nl = b.getElementsByTagName('IMG');
+ for (i=0; i<nl.length; i++) {
+ if (e == nl[i]) {
sp = i;
break;
}
+ }*/
+
+ return {
+ start : -1,
+ end : -1,
+ index : sp,
+ scrollX : sx,
+ scrollY : sy
+ };
}
- e = tinyMCE.getParentElement(rng.endContainer);
- for (ei=0; ei<e.childNodes.length && e.childNodes[ei] != rng.endContainer; ei++) ;
+ // Caret or selection
+ if (s.anchorNode == s.focusNode && s.anchorOffset == s.focusOffset) {
+ e = this._getPosText(b, s.anchorNode, s.focusNode);
- nl = doc.getElementsByTagName(e.nodeName);
- for (i=0; i<nl.length; i++) {
- if (e == nl[i]) {
- le = i;
- break;
- }
- }
+ if (!e)
+ return {scrollX : sx, scrollY : sy};
- //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 {
+ start : e.start + s.anchorOffset,
+ end : e.end + s.focusOffset,
+ scrollX : sx,
+ scrollY : sy
+ };
+ } else {
+ e = this._getPosText(b, rng.startContainer, rng.endContainer);
+
+ if (!e)
+ return {scrollX : sx, scrollY : sy};
+
+ return {
+ start : e.start + rng.startOffset,
+ end : e.end + rng.endOffset,
+ scrollX : sx,
+ scrollY : sy
+ };
+ }
}
return null;
},
moveToBookmark : function(bookmark) {
- var rng, nl, i;
var inst = this.instance;
+ var rng, nl, i, ex, b = inst.getBody(), sd;
var doc = inst.getDoc();
var win = inst.getWin();
var sel = this.getSel();
@@ -5762,22 +6198,27 @@ TinyMCE_Selection.prototype = {
return false;
if (tinyMCE.isSafari) {
- sel.setBaseAndExtent(bookmark.startContainer, bookmark.startOffset, bookmark.endContainer, bookmark.endOffset);
+ sel.setBaseAndExtent(bookmark.rng.startContainer, bookmark.rng.startOffset, bookmark.rng.endContainer, bookmark.rng.endOffset);
return true;
}
- if (tinyMCE.isMSIE) {
+ if (tinyMCE.isRealIE) {
if (bookmark.rng) {
- bookmark.rng.select();
+ try {
+ bookmark.rng.select();
+ } catch (ex) {
+ // Ignore
+ }
+
return true;
}
win.focus();
if (bookmark.tag) {
- rng = inst.getBody().createControlRange();
+ rng = b.createControlRange();
- nl = doc.getElementsByTagName(bookmark.tag);
+ nl = b.getElementsByTagName(bookmark.tag);
if (nl.length > bookmark.index) {
try {
@@ -5787,11 +6228,20 @@ TinyMCE_Selection.prototype = {
}
}
} else {
- rng = inst.getSel().createRange();
- rng.moveToElementText(inst.getBody());
- rng.collapse(true);
- rng.moveStart('character', bookmark.start);
- rng.moveEnd('character', bookmark.length);
+ // Try/catch needed since this operation breaks when TinyMCE is placed in hidden divs/tabs
+ try {
+ // Incorrect bookmark
+ if (bookmark.start < 0)
+ return true;
+
+ rng = inst.getSel().createRange();
+ rng.moveToElementText(inst.getBody());
+ rng.collapse(true);
+ rng.moveStart('character', bookmark.start);
+ rng.moveEnd('character', bookmark.length);
+ } catch (ex) {
+ return true;
+ }
}
rng.select();
@@ -5800,36 +6250,83 @@ TinyMCE_Selection.prototype = {
return true;
}
- if (tinyMCE.isGecko && bookmark.rng) {
- sel.removeAllRanges();
- sel.addRange(bookmark.rng);
+ if (tinyMCE.isGecko || tinyMCE.isOpera) {
+ if (bookmark.rng) {
+ sel.removeAllRanges();
+ sel.addRange(bookmark.rng);
+ }
+
+ if (bookmark.start != -1 && bookmark.end != -1) {
+ try {
+ sd = this._getTextPos(b, bookmark.start, bookmark.end);
+ rng = doc.createRange();
+ rng.setStart(sd.startNode, sd.startOffset);
+ rng.setEnd(sd.endNode, sd.endOffset);
+ sel.removeAllRanges();
+ sel.addRange(rng);
+ win.focus();
+ } catch (ex) {
+ // Ignore
+ }
+ }
+
+ /*
+ if (typeof(bookmark.index) != 'undefined') {
+ tinyMCE.selectElements(b, 'IMG', function (n) {
+ if (bookmark.index-- == 0) {
+ // Select image in Gecko here
+ }
+
+ return false;
+ });
+ }
+ */
+
win.scrollTo(bookmark.scrollX, bookmark.scrollY);
return true;
}
- if (tinyMCE.isGecko) {
- // try {
- rng = doc.createRange();
+ return false;
+ },
- nl = doc.getElementsByTagName(bookmark.startTag);
- if (nl.length > bookmark.start)
- rng.setStart(nl[bookmark.start].childNodes[bookmark.startIndex], bookmark.startOffset);
+ _getPosText : function(r, sn, en) {
+ var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
- nl = doc.getElementsByTagName(bookmark.endTag);
- if (nl.length > bookmark.end)
- rng.setEnd(nl[bookmark.end].childNodes[bookmark.endIndex], bookmark.endOffset);
+ while ((n = w.nextNode()) != null) {
+ if (n == sn)
+ d.start = p;
- sel.removeAllRanges();
- sel.addRange(rng);
- /* } catch {
- // Ignore
- }*/
+ if (n == en) {
+ d.end = p;
+ return d;
+ }
- win.scrollTo(bookmark.scrollX, bookmark.scrollY);
- return true;
+ p += n.nodeValue ? n.nodeValue.length : 0;
}
- return false;
+ return null;
+ },
+
+ _getTextPos : function(r, sp, ep) {
+ var w = document.createTreeWalker(r, NodeFilter.SHOW_TEXT, null, false), n, p = 0, d = {};
+
+ while ((n = w.nextNode()) != null) {
+ p += n.nodeValue ? n.nodeValue.length : 0;
+
+ if (p >= sp && !d.startNode) {
+ d.startNode = n;
+ d.startOffset = sp - (p - n.nodeValue.length);
+ }
+
+ if (p >= ep) {
+ d.endNode = n;
+ d.endOffset = ep - (p - n.nodeValue.length);
+
+ return d;
+ }
+ }
+
+ return null;
},
selectNode : function(node, collapse, select_text_node, to_start) {
@@ -5847,8 +6344,11 @@ TinyMCE_Selection.prototype = {
if (typeof(to_start) == "undefined")
to_start = true;
- if (tinyMCE.isMSIE) {
- rng = inst.getBody().createTextRange();
+ if (inst.settings.auto_resize)
+ inst.resizeToContent();
+
+ if (tinyMCE.isRealIE) {
+ rng = inst.getDoc().body.createTextRange();
try {
rng.moveToElementText(node);
@@ -5915,69 +6415,79 @@ TinyMCE_Selection.prototype = {
},
scrollToNode : function(node) {
- var inst = this.instance;
- var pos, doc, scrollX, scrollY, height;
-
- // 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;
+ var inst = this.instance, w = inst.getWin(), vp = inst.getViewPort(), pos = tinyMCE.getAbsPosition(node), cvp, p, cwin;
// 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);
+ if (pos.absLeft < vp.left || pos.absLeft > vp.left + vp.width || pos.absTop < vp.top || pos.absTop > vp.top + (vp.height-25))
+ w.scrollTo(pos.absLeft, pos.absTop - vp.height + 25);
+
+ // Scroll container window
+ if (inst.settings.auto_resize) {
+ cwin = inst.getContainerWin();
+ cvp = tinyMCE.getViewPort(cwin);
+ p = this.getAbsPosition(node);
+
+ if (p.absLeft < cvp.left || p.absLeft > cvp.left + cvp.width || p.absTop < cvp.top || p.absTop > cvp.top + cvp.height)
+ cwin.scrollTo(p.absLeft, p.absTop - cvp.height + 25);
+ }
+ },
+
+ getAbsPosition : function(n) {
+ var pos = tinyMCE.getAbsPosition(n), ipos = tinyMCE.getAbsPosition(this.instance.iframeElement);
+
+ return {
+ absLeft : ipos.absLeft + pos.absLeft,
+ absTop : ipos.absTop + pos.absTop
+ };
},
getSel : function() {
var inst = this.instance;
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
+ if (tinyMCE.isRealIE)
return inst.getDoc().selection;
return inst.contentWindow.getSelection();
},
getRng : function() {
- var inst = this.instance;
- var sel = this.getSel();
+ var s = this.getSel();
- if (sel == null)
+ if (s == null)
return null;
- if (tinyMCE.isMSIE && !tinyMCE.isOpera)
- return sel.createRange();
+ if (tinyMCE.isRealIE)
+ return s.createRange();
- if (tinyMCE.isSafari && !sel.getRangeAt)
+ if (tinyMCE.isSafari && !s.getRangeAt)
return '' + window.getSelection();
- return sel.getRangeAt(0);
+ return s.getRangeAt(0);
},
getFocusElement : function() {
- var inst = this.instance;
+ var inst = this.instance, doc, rng, sel, elm;
- if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
- var doc = inst.getDoc();
- var rng = doc.selection.createRange();
+ if (tinyMCE.isRealIE) {
+ doc = inst.getDoc();
+ rng = doc.selection.createRange();
// if (rng.collapse)
// rng.collapse(true);
- var elm = rng.item ? rng.item(0) : rng.parentElement();
+ elm = rng.item ? rng.item(0) : rng.parentElement();
} else {
- if (inst.isHidden())
+ if (!tinyMCE.isSafari && inst.isHidden())
return inst.getBody();
- var sel = this.getSel();
- var rng = this.getRng();
+ sel = this.getSel();
+ rng = this.getRng();
if (!sel || !rng)
return null;
- var elm = rng.commonAncestorContainer;
- //var elm = (sel && sel.anchorNode) ? sel.anchorNode : null;
+ elm = rng.commonAncestorContainer;
+ //elm = (sel && sel.anchorNode) ? sel.anchorNode : null;
// Handle selection a image or other control like element such as anchors
if (!rng.collapsed) {
@@ -5999,7 +6509,8 @@ TinyMCE_Selection.prototype = {
return elm;
}
-};
+
+ };
/* file:jscripts/tiny_mce/classes/TinyMCE_UndoRedo.class.js */
@@ -6013,39 +6524,40 @@ function TinyMCE_UndoRedo(inst) {
TinyMCE_UndoRedo.prototype = {
add : function(l) {
- var b;
+ var b, customUndoLevels, newHTML, inst = this.instance, i, ul, ur;
if (l) {
this.undoLevels[this.undoLevels.length] = l;
return true;
}
- var inst = this.instance;
-
if (this.typingUndoIndex != -1) {
this.undoIndex = this.typingUndoIndex;
- // tinyMCE.debug("Override: " + this.undoIndex);
+
+ if (tinyMCE.typingUndoIndex != -1)
+ tinyMCE.undoIndex = tinyMCE.typingUndoIndex;
}
- var newHTML = tinyMCE.trim(inst.getBody().innerHTML);
+ newHTML = tinyMCE.trim(inst.getBody().innerHTML);
if (this.undoLevels[this.undoIndex] && newHTML != this.undoLevels[this.undoIndex].content) {
- //tinyMCE.debug(newHTML, this.undoLevels[this.undoIndex]);
+ //tinyMCE.debug(newHTML, this.undoLevels[this.undoIndex].content);
tinyMCE.dispatchCallback(inst, 'onchange_callback', 'onChange', inst);
// Time to compress
- var customUndoLevels = tinyMCE.settings['custom_undo_redo_levels'];
+ 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]);
+ for (i=0; i<this.undoLevels.length-1; i++)
this.undoLevels[i] = this.undoLevels[i+1];
- }
this.undoLevels.length--;
this.undoIndex--;
+
+ // Todo: Implement global undo/redo logic here
}
b = inst.undoBookmark;
+
if (!b)
b = inst.selection.getBookmark();
@@ -6055,12 +6567,24 @@ TinyMCE_UndoRedo.prototype = {
bookmark : b
};
+ // Remove all above from global undo/redo
+ ul = tinyMCE.undoLevels;
+ for (i=tinyMCE.undoIndex + 1; i<ul.length; i++) {
+ ur = ul[i].undoRedo;
+
+ if (ur.undoIndex == ur.undoLevels.length -1)
+ ur.undoIndex--;
+
+ ur.undoLevels.length--;
+ }
+
+ // Add global undo level
+ tinyMCE.undoLevels[tinyMCE.undoIndex++] = inst;
+ tinyMCE.undoLevels.length = tinyMCE.undoIndex;
+
this.undoLevels.length = this.undoIndex + 1;
- //tinyMCE.debug("level added" + this.undoIndex);
return true;
-
- // tinyMCE.debug(this.undoIndex + "," + (this.undoLevels.length-1));
}
return false;
@@ -6072,13 +6596,13 @@ TinyMCE_UndoRedo.prototype = {
// 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);
}
-
- // tinyMCE.debug("Undo - undo levels:" + this.undoLevels.length + ", undo index: " + this.undoIndex);
},
redo : function() {
@@ -6088,23 +6612,28 @@ TinyMCE_UndoRedo.prototype = {
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);
}
tinyMCE.triggerNodeChange();
}
-};
+
+ };
/* file:jscripts/tiny_mce/classes/TinyMCE_ForceParagraphs.class.js */
var TinyMCE_ForceParagraphs = {
_insertPara : function(inst, e) {
+ var doc = inst.getDoc(), sel = inst.getSel(), body = inst.getBody(), win = inst.contentWindow, rng = sel.getRangeAt(0);
+ var rootElm = doc.documentElement, blockName = "P", startNode, endNode, startBlock, endBlock;
+ var rngBefore, rngAfter, direct, startNode, startOffset, endNode, endOffset, b = tinyMCE.isOpera ? inst.selection.getBookmark() : null;
+ var paraBefore, paraAfter, startChop, endChop, contents;
+
function isEmpty(para) {
function isEmptyHTML(html) {
return html.replace(new RegExp('[ \t\r\n]+', 'g'), '').toLowerCase() == "";
@@ -6133,43 +6662,33 @@ var TinyMCE_ForceParagraphs = {
return true;
}
- 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 = doc.createRange();
rngBefore.setStart(sel.anchorNode, sel.anchorOffset);
rngBefore.collapse(true);
// Setup after range
- var rngAfter = doc.createRange();
+ 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;
+ direct = rngBefore.compareBoundaryPoints(rngBefore.START_TO_END, rngAfter) < 0;
+ startNode = direct ? sel.anchorNode : sel.focusNode;
+ startOffset = direct ? sel.anchorOffset : sel.focusOffset;
+ endNode = direct ? sel.focusNode : sel.anchorNode;
+ 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);
+ startBlock = inst.getParentBlockElement(startNode);
+ endBlock = inst.getParentBlockElement(endNode);
// If absolute force paragraph generation within
if (startBlock && new RegExp('absolute|relative|static', 'gi').test(startBlock.style.position))
@@ -6188,7 +6707,7 @@ var TinyMCE_ForceParagraphs = {
}
// Within a list use normal behaviour
- if (tinyMCE.getParentElement(startBlock, "OL,UL") != null)
+ if (tinyMCE.getParentElement(startBlock, "OL,UL", null, body) != null)
return false;
// Within a table create new paragraphs
@@ -6196,16 +6715,16 @@ var TinyMCE_ForceParagraphs = {
startBlock = endBlock = null;
// 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);
+ paraBefore = (startBlock != null && startBlock.nodeName == blockName) ? startBlock.cloneNode(false) : doc.createElement(blockName);
+ paraAfter = (endBlock != null && endBlock.nodeName == blockName) ? endBlock.cloneNode(false) : doc.createElement(blockName);
// Is header, then force paragraph under
if (/^(H[1-6])$/.test(blockName))
paraAfter = doc.createElement("p");
// Setup chop nodes
- var startChop = startNode;
- var endChop = endNode;
+ startChop = startNode;
+ endChop = endNode;
// Get startChop node
node = startChop;
@@ -6236,7 +6755,9 @@ var TinyMCE_ForceParagraphs = {
if (startBlock == null) {
// Delete selection
rng.deleteContents();
- sel.removeAllRanges();
+
+ if (!tinyMCE.isSafari)
+ sel.removeAllRanges();
if (startChop != rootElm && endChop != rootElm) {
// Insert paragraph before
@@ -6260,7 +6781,7 @@ var TinyMCE_ForceParagraphs = {
if (endChop.nodeName != "#text" && endChop.nodeName != "BODY")
rngBefore.setEndAfter(endChop);
- var contents = rng.cloneContents();
+ contents = rng.cloneContents();
if (contents.firstChild && (contents.firstChild.nodeName == blockName || contents.firstChild.nodeName == "BODY"))
paraAfter.innerHTML = contents.firstChild.innerHTML;
else
@@ -6280,17 +6801,25 @@ var TinyMCE_ForceParagraphs = {
rngBefore.deleteContents();
// Insert new paragraphs
- paraAfter.normalize();
- rngBefore.insertNode(paraAfter);
- paraBefore.normalize();
- rngBefore.insertNode(paraBefore);
+ if (tinyMCE.isOpera) {
+ paraBefore.normalize();
+ rngBefore.insertNode(paraBefore);
+ paraAfter.normalize();
+ rngBefore.insertNode(paraAfter);
+ } else {
+ paraAfter.normalize();
+ rngBefore.insertNode(paraAfter);
+ paraBefore.normalize();
+ rngBefore.insertNode(paraBefore);
+ }
- // tinyMCE.debug("1: ", paraBefore.innerHTML, paraAfter.innerHTML);
+ //tinyMCE.debug("1: ", paraBefore.innerHTML, paraAfter.innerHTML);
} else {
body.innerHTML = "<" + blockName + ">&nbsp;</" + blockName + "><" + blockName + ">&nbsp;</" + blockName + ">";
paraAfter = body.childNodes[1];
}
+ inst.selection.moveToBookmark(b);
inst.selection.selectNode(paraAfter, true, true);
return true;
@@ -6308,7 +6837,7 @@ var TinyMCE_ForceParagraphs = {
// Place secound part within new paragraph
rngAfter.setEndAfter(endChop);
rngAfter.setStart(endNode, endOffset);
- var contents = rngAfter.cloneContents();
+ contents = rngAfter.cloneContents();
if (contents.firstChild && contents.firstChild.nodeName == blockName) {
/* var nodes = contents.firstChild.childNodes;
@@ -6331,7 +6860,7 @@ var TinyMCE_ForceParagraphs = {
paraAfter.innerHTML = "&nbsp;";
// Create a range around everything
- var rng = doc.createRange();
+ rng = doc.createRange();
if (!startChop.previousSibling && startChop.parentNode.nodeName.toUpperCase() == blockName) {
rng.setStartBefore(startChop.parentNode);
@@ -6349,14 +6878,22 @@ var TinyMCE_ForceParagraphs = {
// Delete all contents and insert new paragraphs
rng.deleteContents();
- rng.insertNode(paraAfter);
- rng.insertNode(paraBefore);
+
+ if (tinyMCE.isOpera) {
+ rng.insertNode(paraBefore);
+ rng.insertNode(paraAfter);
+ } else {
+ rng.insertNode(paraAfter);
+ rng.insertNode(paraBefore);
+ }
+
//tinyMCE.debug("2", paraBefore.innerHTML, paraAfter.innerHTML);
// Normalize
paraAfter.normalize();
paraBefore.normalize();
+ inst.selection.moveToBookmark(b);
inst.selection.selectNode(paraAfter, true, true);
return true;
@@ -6365,21 +6902,26 @@ var TinyMCE_ForceParagraphs = {
_handleBackSpace : function(inst) {
var r = inst.getRng(), sn = r.startContainer, nv, s = false;
- if (sn && sn.nextSibling && sn.nextSibling.nodeName == "BR") {
+ // Added body check for bug #1527787
+ if (sn && sn.nextSibling && sn.nextSibling.nodeName == "BR" && sn.parentNode.nodeName != "BODY") {
nv = sn.nodeValue;
- // Handle if a backspace is pressed after a space character #bug 1466054
- if (nv != null && nv.length >= r.startOffset && nv.charAt(r.startOffset - 1) == ' ')
- s = true;
+ // Handle if a backspace is pressed after a space character #bug 1466054 removed since fix for #1527787
+ /*if (nv != null && nv.length >= r.startOffset && nv.charAt(r.startOffset - 1) == ' ')
+ s = true;*/
// Only remove BRs if we are at the end of line #bug 1464152
if (nv != null && r.startOffset == nv.length)
sn.nextSibling.parentNode.removeChild(sn.nextSibling);
}
+ if (inst.settings.auto_resize)
+ inst.resizeToContent();
+
return s;
}
-};
+
+ };
/* file:jscripts/tiny_mce/classes/TinyMCE_Layer.class.js */
@@ -6515,14 +7057,20 @@ TinyMCE_Layer.prototype = {
if (!this.blockerElement && this.blockMode) {
d = this.doc;
- b = d.createElement("iframe");
+ b = d.getElementById(this.id + "_blocker");
- b.style.cssText = 'display: none; position: absolute; left: 0; top: 0';
- b.src = 'javascript:false;';
- b.frameBorder = '0';
- b.scrolling = 'no';
+ if (!b) {
+ b = d.createElement("iframe");
+
+ b.setAttribute('id', this.id + "_blocker");
+ 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);
+ }
- d.body.appendChild(b);
this.blockerElement = b;
}
@@ -6541,7 +7089,7 @@ TinyMCE_Layer.prototype = {
return p;
},
- create : function(n, c, p) {
+ create : function(n, c, p, h) {
var d = this.doc, e = d.createElement(n);
e.setAttribute('id', this.id);
@@ -6552,18 +7100,26 @@ TinyMCE_Layer.prototype = {
if (!p)
p = d.body;
+ if (h)
+ e.innerHTML = h;
+
p.appendChild(e);
return this.element = e;
},
+ exists : function() {
+ return this.doc.getElementById(this.id) != null;
+ },
+
parseInt : function(s) {
if (s == null || s == '')
return 0;
return parseInt(s);
}
-};
+
+ };
/* file:jscripts/tiny_mce/classes/TinyMCE_Menu.class.js */
@@ -6582,7 +7138,6 @@ function TinyMCE_Menu() {
this.needsUpdate = true;
};
-// Extends the TinyMCE_Layer class
TinyMCE_Menu.prototype = tinyMCE.extend(TinyMCE_Layer.prototype, {
init : function(s) {
var n;
@@ -6653,7 +7208,7 @@ TinyMCE_Menu.prototype = tinyMCE.extend(TinyMCE_Layer.prototype, {
break;
default:
- h += '<tr><td><a href="javascript:void(0);" onmousedown="' + tinyMCE.xmlEncode(m[i].js) + ';return false;"><span' + c +'>' + t + '</span></a>';
+ h += '<tr><td><a href="#" onclick="return tinyMCE.cancelEvent(event);" onmousedown="return tinyMCE.cancelEvent(event);" onmouseup="' + tinyMCE.xmlEncode(m[i].js) + ';return tinyMCE.cancelEvent(event);"><span' + c +'>' + t + '</span></a>';
}
h += '</td></tr>';
@@ -6690,30 +7245,40 @@ TinyMCE_Menu.prototype = tinyMCE.extend(TinyMCE_Layer.prototype, {
tinyMCE.lastMenu = this;
}
-});
-/* file:jscripts/tiny_mce/classes/TinyMCE_Debug.class.js */
+ });
-TinyMCE_Engine.prototype.debug = function() {
- var m = "", e, a, i;
+/* file:jscripts/tiny_mce/classes/TinyMCE_Compatibility.class.js */
- 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>';
+if (!Function.prototype.call) {
+ Function.prototype.call = function() {
+ var a = arguments, s = a[0], i, as = '', r, o;
- document.body.appendChild(d);
- e = document.getElementById("tinymce_debug");
- }
+ for (i=1; i<a.length; i++)
+ as += (i > 1 ? ',' : '') + 'a[' + i + ']';
+
+ o = s._fu;
+ s._fu = this;
+ r = eval('s._fu(' + as + ')');
+ s._fu = o;
- a = this.debug.arguments;
- for (i=0; i<a.length; i++) {
+ return r;
+ };
+};
+
+/* file:jscripts/tiny_mce/classes/TinyMCE_Debug.class.js */
+
+TinyMCE_Engine.prototype.debug = function() {
+ var m = "", a, i, l = tinyMCE.log.length;
+
+ for (i=0, a = this.debug.arguments; i<a.length; i++) {
m += a[i];
+
if (i<a.length-1)
m += ', ';
}
- e.value += m + "\n";
+ if (l < 1000)
+ tinyMCE.log[l] = "[debug] " + m;
};
+
diff --git a/wp-includes/js/tinymce/tiny_mce_popup.js b/wp-includes/js/tinymce/tiny_mce_popup.js
index cbcdf3e..c4db092 100644
--- a/wp-includes/js/tinymce/tiny_mce_popup.js
+++ b/wp-includes/js/tinymce/tiny_mce_popup.js
@@ -3,274 +3,286 @@
// Some global instances, this will be filled later
var tinyMCE = null, tinyMCELang = null;
-
function TinyMCE_Popup() {
};
+TinyMCE_Popup.prototype = {
+ findWin : function(w) {
+ var c;
-TinyMCE_Popup.prototype.init = function() {
- var win = window.opener ? window.opener : window.dialogArguments;
- var inst;
+ // Check parents
+ c = w;
+ while (c && (c = c.parent) != null) {
+ if (typeof(c.tinyMCE) != "undefined")
+ return c;
+ }
- if (!win) {
- // Try parent
- win = parent.parent;
+ // Check openers
+ c = w;
+ while (c && (c = c.opener) != null) {
+ if (typeof(c.tinyMCE) != "undefined")
+ return c;
+ }
// Try top
- if (typeof(win.tinyMCE) == "undefined")
- win = top;
- }
-
- window.opener = win;
- this.windowOpener = win;
- this.onLoadEval = "";
+ if (typeof(top.tinyMCE) != "undefined")
+ return top;
- // Setup parent references
- tinyMCE = win.tinyMCE;
- tinyMCELang = win.tinyMCELang;
+ return null;
+ },
- if (!tinyMCE) {
- alert("tinyMCE object reference not found from popup.");
- return;
- }
+ init : function() {
+ var win = window.opener ? window.opener : window.dialogArguments, c;
+ var inst;
- inst = tinyMCE.selectedInstance;
- this.isWindow = tinyMCE.getWindowArg('mce_inside_iframe', false) == false;
- this.storeSelection = (tinyMCE.isMSIE && !tinyMCE.isOpera) && !this.isWindow && tinyMCE.getWindowArg('mce_store_selection', true);
+ if (!win)
+ win = this.findWin(window);
- if (this.isWindow)
- window.focus();
+ if (!win) {
+ alert("tinyMCE object reference not found from popup.");
+ return;
+ }
- // Store selection
- if (this.storeSelection)
- inst.selectionBookmark = inst.selection.getBookmark(true);
+ window.opener = win;
+ this.windowOpener = win;
+ this.onLoadEval = "";
- // Setup dir
- if (tinyMCELang['lang_dir'])
- document.dir = tinyMCELang['lang_dir'];
+ // Setup parent references
+ tinyMCE = win.tinyMCE;
+ tinyMCELang = win.tinyMCELang;
- // Setup title
- var re = new RegExp('{|\\\$|}', 'g');
- var title = document.title.replace(re, "");
- if (typeof tinyMCELang[title] != "undefined") {
- var divElm = document.createElement("div");
- divElm.innerHTML = tinyMCELang[title];
- document.title = divElm.innerHTML;
+ inst = tinyMCE.selectedInstance;
+ this.isWindow = tinyMCE.getWindowArg('mce_inside_iframe', false) == false;
+ this.storeSelection = (tinyMCE.isRealIE) && !this.isWindow && tinyMCE.getWindowArg('mce_store_selection', true);
- if (tinyMCE.setWindowTitle != null)
- tinyMCE.setWindowTitle(window, divElm.innerHTML);
- }
+ if (this.isWindow)
+ window.focus();
- // Output Popup CSS class
- document.write('<link href="' + tinyMCE.getParam("popups_css") + '" rel="stylesheet" type="text/css">');
+ // Store selection
+ if (this.storeSelection)
+ inst.selectionBookmark = inst.selection.getBookmark(true);
- tinyMCE.addEvent(window, "load", this.onLoad);
-};
+ // Setup dir
+ if (tinyMCELang['lang_dir'])
+ document.dir = tinyMCELang['lang_dir'];
+ // Setup title
+ var re = new RegExp('{|\\\$|}', 'g');
+ var title = document.title.replace(re, "");
+ if (typeof tinyMCELang[title] != "undefined") {
+ var divElm = document.createElement("div");
+ divElm.innerHTML = tinyMCELang[title];
+ document.title = divElm.innerHTML;
-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 ) {
- tinyMCE.closeWindow(window);
+ if (tinyMCE.setWindowTitle != null)
+ tinyMCE.setWindowTitle(window, divElm.innerHTML);
}
- }
- if (tinyMCE.getWindowArg('mce_replacevariables', true))
- body.innerHTML = tinyMCE.applyTemplate(body.innerHTML, tinyMCE.windowArgs);
+ // Output Popup CSS class
+ document.write('<link href="' + tinyMCE.getParam("popups_css") + '" rel="stylesheet" type="text/css">');
- 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;
- }
- }
+ if (tinyMCE.getParam("popups_css_add")) {
+ c = tinyMCE.getParam("popups_css_add");
- if (body.style.display == 'none')
- body.style.display = 'block';
+ // Is relative
+ if (c.indexOf('://') == -1 && c.charAt(0) != '/')
+ c = tinyMCE.documentBasePath + "/" + c;
- // Execute real onload (Opera fix)
- if (tinyMCEPopup.onLoadEval != "")
- eval(tinyMCEPopup.onLoadEval);
-};
+ document.write('<link href="' + c + '" rel="stylesheet" type="text/css">');
+ }
+ tinyMCE.addEvent(window, "load", this.onLoad);
+ },
-TinyMCE_Popup.prototype.executeOnLoad = function(str) {
- if (tinyMCE.isOpera)
- this.onLoadEval = str;
- else
- eval(str);
-};
+ onLoad : function() {
+ var dir, i, elms, body = document.body;
+ if (tinyMCE.getWindowArg('mce_replacevariables', true))
+ body.innerHTML = tinyMCE.applyTemplate(body.innerHTML, tinyMCE.windowArgs);
-TinyMCE_Popup.prototype.resizeToInnerSize = function() {
- // Netscape 7.1 workaround
- if (this.isWindow && tinyMCE.isNS71) {
- window.resizeBy(0, 10);
- return;
- }
-
- if (this.isWindow) {
- var doc = document;
- var body = doc.body;
- var oldMargin, wrapper, iframe, nodes, dx, dy;
+ 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;
+ }
+ }
if (body.style.display == 'none')
body.style.display = 'block';
- // Remove margin
- oldMargin = body.style.margin;
- body.style.margin = '0';
-
- // Create wrapper
- wrapper = doc.createElement("div");
- wrapper.id = 'mcBodyWrapper';
- wrapper.style.display = 'none';
- wrapper.style.margin = '0';
-
- // Wrap body elements
- nodes = doc.body.childNodes;
- for (var i=nodes.length-1; i>=0; i--) {
- if (wrapper.hasChildNodes())
- wrapper.insertBefore(nodes[i].cloneNode(true), wrapper.firstChild);
- else
- wrapper.appendChild(nodes[i].cloneNode(true));
-
- nodes[i].parentNode.removeChild(nodes[i]);
+ // Execute real onload (Opera fix)
+ if (tinyMCEPopup.onLoadEval != "")
+ eval(tinyMCEPopup.onLoadEval);
+ },
+
+ executeOnLoad : function(str) {
+ if (tinyMCE.isOpera)
+ this.onLoadEval = str;
+ else
+ eval(str);
+ },
+
+ resizeToInnerSize : function() {
+ // Netscape 7.1 workaround
+ if (this.isWindow && tinyMCE.isNS71) {
+ window.resizeBy(0, 10);
+ return;
}
- // Add wrapper
- doc.body.appendChild(wrapper);
-
- // Create iframe
- iframe = document.createElement("iframe");
- iframe.id = "mcWinIframe";
- iframe.src = document.location.href.toLowerCase().indexOf('https') == -1 ? "about:blank" : tinyMCE.settings['default_document'];
- iframe.width = "100%";
- iframe.height = "100%";
- iframe.style.margin = '0';
-
- // Add iframe
- doc.body.appendChild(iframe);
-
- // Measure iframe
- iframe = document.getElementById('mcWinIframe');
- dx = tinyMCE.getWindowArg('mce_width') - iframe.clientWidth;
- dy = tinyMCE.getWindowArg('mce_height') - iframe.clientHeight;
-
- // Resize window
- // tinyMCE.debug(tinyMCE.getWindowArg('mce_width') + "," + tinyMCE.getWindowArg('mce_height') + " - " + dx + "," + dy);
- window.resizeBy(dx, dy);
-
- // Hide iframe and show wrapper
- body.style.margin = oldMargin;
- iframe.style.display = 'none';
- wrapper.style.display = 'block';
- }
-};
-
-
-TinyMCE_Popup.prototype.resizeToContent = function() {
- var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
- var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
-
- if (isOpera)
- return;
-
- if (isMSIE) {
- try { window.resizeTo(10, 10); } catch (e) {}
-
- var elm = document.body;
- var width = elm.offsetWidth;
- var height = elm.offsetHeight;
- var dx = (elm.scrollWidth - width) + 4;
- var dy = elm.scrollHeight - height;
-
- try { window.resizeBy(dx, dy); } catch (e) {}
- } else {
- window.scrollBy(1000, 1000);
- if (window.scrollX > 0 || window.scrollY > 0) {
- window.resizeBy(window.innerWidth * 2, window.innerHeight * 2);
- window.sizeToContent();
- window.scrollTo(0, 0);
- var x = parseInt(screen.width / 2.0) - (window.outerWidth / 2.0);
- var y = parseInt(screen.height / 2.0) - (window.outerHeight / 2.0);
- window.moveTo(x, y);
+ if (this.isWindow) {
+ var doc = document;
+ var body = doc.body;
+ var oldMargin, wrapper, iframe, nodes, dx, dy;
+
+ if (body.style.display == 'none')
+ body.style.display = 'block';
+
+ // Remove margin
+ oldMargin = body.style.margin;
+ body.style.margin = '0';
+
+ // Create wrapper
+ wrapper = doc.createElement("div");
+ wrapper.id = 'mcBodyWrapper';
+ wrapper.style.display = 'none';
+ wrapper.style.margin = '0';
+
+ // Wrap body elements
+ nodes = doc.body.childNodes;
+ for (var i=nodes.length-1; i>=0; i--) {
+ if (wrapper.hasChildNodes())
+ wrapper.insertBefore(nodes[i].cloneNode(true), wrapper.firstChild);
+ else
+ wrapper.appendChild(nodes[i].cloneNode(true));
+
+ nodes[i].parentNode.removeChild(nodes[i]);
+ }
+
+ // Add wrapper
+ doc.body.appendChild(wrapper);
+
+ // Create iframe
+ iframe = document.createElement("iframe");
+ iframe.id = "mcWinIframe";
+ iframe.src = document.location.href.toLowerCase().indexOf('https') == -1 ? "about:blank" : tinyMCE.settings['default_document'];
+ iframe.width = "100%";
+ iframe.height = "100%";
+ iframe.style.margin = '0';
+
+ // Add iframe
+ doc.body.appendChild(iframe);
+
+ // Measure iframe
+ iframe = document.getElementById('mcWinIframe');
+ dx = tinyMCE.getWindowArg('mce_width') - iframe.clientWidth;
+ dy = tinyMCE.getWindowArg('mce_height') - iframe.clientHeight;
+
+ // Resize window
+ // tinyMCE.debug(tinyMCE.getWindowArg('mce_width') + "," + tinyMCE.getWindowArg('mce_height') + " - " + dx + "," + dy);
+ window.resizeBy(dx, dy);
+
+ // Hide iframe and show wrapper
+ body.style.margin = oldMargin;
+ iframe.style.display = 'none';
+ wrapper.style.display = 'block';
}
- }
-};
-
-
-TinyMCE_Popup.prototype.getWindowArg = function(name, default_value) {
- return tinyMCE.getWindowArg(name, default_value);
-};
-
+ },
+
+ resizeToContent : function() {
+ var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
+ var isOpera = (navigator.userAgent.indexOf("Opera") != -1);
+
+ if (isOpera)
+ return;
+
+ if (isMSIE) {
+ try { window.resizeTo(10, 10); } catch (e) {}
+
+ var elm = document.body;
+ var width = elm.offsetWidth;
+ var height = elm.offsetHeight;
+ var dx = (elm.scrollWidth - width) + 4;
+ var dy = elm.scrollHeight - height;
+
+ try { window.resizeBy(dx, dy); } catch (e) {}
+ } else {
+ window.scrollBy(1000, 1000);
+ if (window.scrollX > 0 || window.scrollY > 0) {
+ window.resizeBy(window.innerWidth * 2, window.innerHeight * 2);
+ window.sizeToContent();
+ window.scrollTo(0, 0);
+ var x = parseInt(screen.width / 2.0) - (window.outerWidth / 2.0);
+ var y = parseInt(screen.height / 2.0) - (window.outerHeight / 2.0);
+ window.moveTo(x, y);
+ }
+ }
+ },
-TinyMCE_Popup.prototype.restoreSelection = function() {
- if (this.storeSelection) {
- var inst = tinyMCE.selectedInstance;
+ getWindowArg : function(name, default_value) {
+ return tinyMCE.getWindowArg(name, default_value);
+ },
- inst.getWin().focus();
+ restoreSelection : function() {
+ if (this.storeSelection) {
+ var inst = tinyMCE.selectedInstance;
- if (inst.selectionBookmark)
- inst.selection.moveToBookmark(inst.selectionBookmark);
- }
-};
+ inst.getWin().focus();
+ 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.selectionBookmark = inst.selection.getBookmark(true);
-};
+ execCommand : function(command, user_interface, value) {
+ var inst = tinyMCE.selectedInstance;
+ this.restoreSelection();
+ inst.execCommand(command, user_interface, value);
-TinyMCE_Popup.prototype.close = function() {
- tinyMCE.closeWindow(window);
-};
+ // Store selection
+ if (this.storeSelection)
+ inst.selectionBookmark = inst.selection.getBookmark(true);
+ },
+ close : function() {
+ tinyMCE.closeWindow(window);
+ },
-TinyMCE_Popup.prototype.pickColor = function(e, element_id) {
- tinyMCE.selectedInstance.execCommand('mceColorPicker', true, {
- element_id : element_id,
- document : document,
- window : window,
- store_selection : false
- });
-};
+ pickColor : function(e, element_id) {
+ tinyMCE.selectedInstance.execCommand('mceColorPicker', true, {
+ element_id : element_id,
+ document : document,
+ window : window,
+ store_selection : false
+ });
+ },
+ openBrowser : function(element_id, type, option) {
+ var cb = tinyMCE.getParam(option, tinyMCE.getParam("file_browser_callback"));
+ var url = document.getElementById(element_id).value;
-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;
+ tinyMCE.setWindowArg("window", window);
+ tinyMCE.setWindowArg("document", document);
- tinyMCE.setWindowArg("window", window);
- tinyMCE.setWindowArg("document", document);
+ // Call to external callback
+ if (eval('typeof(tinyMCEPopup.windowOpener.' + cb + ')') == "undefined")
+ alert("Callback function: " + cb + " could not be found.");
+ else
+ eval("tinyMCEPopup.windowOpener." + cb + "(element_id, url, type, window);");
+ },
- // Call to external callback
- if (eval('typeof(tinyMCEPopup.windowOpener.' + cb + ')') == "undefined")
- alert("Callback function: " + cb + " could not be found.");
- else
- eval("tinyMCEPopup.windowOpener." + cb + "(element_id, url, type, window);");
-};
+ importClass : function(c) {
+ window[c] = function() {};
-TinyMCE_Popup.prototype.importClass = function(c) {
- window[c] = function() {};
+ for (var n in window.opener[c].prototype)
+ window[c].prototype[n] = window.opener[c].prototype[n];
- for (var n in window.opener[c].prototype)
- window[c].prototype[n] = window.opener[c].prototype[n];
+ window[c].constructor = window.opener[c].constructor;
+ }
- window[c].constructor = window.opener[c].constructor;
-};
+ };
// Setup global instance
var tinyMCEPopup = new TinyMCE_Popup();
diff --git a/wp-includes/js/tinymce/utils/form_utils.js b/wp-includes/js/tinymce/utils/form_utils.js
index 0481815..c502943 100644
--- a/wp-includes/js/tinymce/utils/form_utils.js
+++ b/wp-includes/js/tinymce/utils/form_utils.js
@@ -1,7 +1,5 @@
/**
- * $RCSfile: form_utils.js,v $
- * $Revision: 1.10 $
- * $Date: 2006/03/22 12:21:24 $
+ * $Id: form_utils.js 43 2006-08-08 16:10:07Z spocke $
*
* Various form utilitiy functions.
*
@@ -9,18 +7,20 @@
* @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
*/
+var themeBaseURL = tinyMCE.baseURL + '/themes/' + tinyMCE.getParam("theme");
+
function getColorPickerHTML(id, target_form_element) {
- var html = "";
+ var h = "";
- 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/' + 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>';
+ h += '<a id="' + id + '_link" href="javascript:void(0);" onkeydown="pickColor(event,\'' + target_form_element +'\');" onmousedown="pickColor(event,\'' + target_form_element +'\');return false;">';
+ h += '<img id="' + id + '" src="' + themeBaseURL + '/images/color.gif"';
+ h += ' onmouseover="this.className=\'mceButtonOver\'"';
+ h += ' onmouseout="this.className=\'mceButtonNormal\'"';
+ h += ' onmousedown="this.className=\'mceButtonDown\'"';
+ h += ' width="20" height="16" border="0" title="' + tinyMCE.getLang('lang_browse') + '"';
+ h += ' class="mceButtonNormal" alt="' + tinyMCE.getLang('lang_browse') + '" /></a>';
- return html;
+ return h;
}
function pickColor(e, target_form_element) {
@@ -57,7 +57,7 @@ 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/' + tinyMCE.getParam("theme") + '/images/browse.gif"';
+ html += '<img id="' + id + '" src="' + themeBaseURL + '/images/browse.gif"';
html += ' onmouseover="this.className=\'mceButtonOver\';"';
html += ' onmouseout="this.className=\'mceButtonNormal\';"';
html += ' onmousedown="this.className=\'mceButtonDown\';"';
@@ -92,9 +92,10 @@ function selectByValue(form_obj, field_name, value, add_custom, ignore_case) {
}
if (!found && add_custom && value != '') {
- var option = new Option('Value: ' + value, value);
+ var option = new Option(value, value);
option.selected = true;
sel.options[sel.options.length] = option;
+ sel.selectedIndex = sel.options.length - 1;
}
return found;
diff --git a/wp-includes/js/tinymce/utils/mclayer.js b/wp-includes/js/tinymce/utils/mclayer.js
index 0a7837b..deac8b7 100644
--- a/wp-includes/js/tinymce/utils/mclayer.js
+++ b/wp-includes/js/tinymce/utils/mclayer.js
@@ -1,7 +1,5 @@
/**
- * $RCSfile: mclayer.js,v $
- * $Revision: 1.2 $
- * $Date: 2006/02/06 20:11:09 $
+ * $Id: mclayer.js 18 2006-06-29 14:11:23Z spocke $
*
* Moxiecode floating layer script.
*
@@ -209,4 +207,4 @@ MCLayer.prototype = {
return parseInt(s);
}
-} \ No newline at end of file
+}
diff --git a/wp-includes/js/tinymce/utils/mctabs.js b/wp-includes/js/tinymce/utils/mctabs.js
index c159360..354186e 100644
--- a/wp-includes/js/tinymce/utils/mctabs.js
+++ b/wp-includes/js/tinymce/utils/mctabs.js
@@ -1,7 +1,5 @@
/**
- * $RCSfile: mctabs.js,v $
- * $Revision: 1.2 $
- * $Date: 2006/02/06 20:11:09 $
+ * $Id: mctabs.js 18 2006-06-29 14:11:23Z spocke $
*
* Moxiecode DHTML Tabs script.
*
diff --git a/wp-includes/js/tinymce/utils/validate.js b/wp-includes/js/tinymce/utils/validate.js
index 747b62b..f329b13 100644
--- a/wp-includes/js/tinymce/utils/validate.js
+++ b/wp-includes/js/tinymce/utils/validate.js
@@ -1,7 +1,5 @@
/**
- * $RCSfile: validate.js,v $
- * $Revision: 1.3 $
- * $Date: 2006/02/06 20:11:09 $
+ * $Id: validate.js 65 2006-08-24 15:54:55Z spocke $
*
* Various form validation methods.
*
@@ -9,42 +7,213 @@
* @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
*/
-function testRegExp(form_name, element_name, re) {
- return new RegExp(re).test(document.forms[form_name].elements[element_name].value);
-}
+/**
+ // String validation:
+
+ if (!Validator.isEmail('myemail'))
+ alert('Invalid email.');
+
+ // Form validation:
+
+ var f = document.forms['myform'];
+
+ if (!Validator.isEmail(f.myemail))
+ alert('Invalid email.');
+*/
+
+var Validator = {
+ isEmail : function(s) {
+ return this.test(s, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
+ },
+
+ isAbsUrl : function(s) {
+ return this.test(s, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+\\/?.*$');
+ },
+
+ isSize : function(s) {
+ return this.test(s, '^[0-9]+(px|%)?$');
+ },
+
+ isId : function(s) {
+ return this.test(s, '^[A-Za-z_]([A-Za-z0-9_])*$');
+ },
+
+ isEmpty : function(s) {
+ var nl, i;
+
+ if (s.nodeName == 'SELECT' && s.selectedIndex < 1)
+ return true;
+
+ if (s.type == 'checkbox' && !s.checked)
+ return true;
+
+ if (s.type == 'radio') {
+ for (i=0, nl = s.form.elements; i<nl.length; i++) {
+ if (nl[i].type == "radio" && nl[i].name == s.name && nl[i].checked)
+ return false;
+ }
+
+ return true;
+ }
+
+ return new RegExp('^\\s*$').test(s.nodeType == 1 ? s.value : s);
+ },
+
+ isNumber : function(s, d) {
+ return !isNaN(s.nodeType == 1 ? s.value : s) && (!d || !this.test(s, '^-?[0-9]*\\.[0-9]*$'));
+ },
+
+ test : function(s, p) {
+ s = s.nodeType == 1 ? s.value : s;
+
+ return s == '' || new RegExp(p).test(s);
+ }
+};
+
+var AutoValidator = {
+ settings : {
+ id_cls : 'id',
+ int_cls : 'int',
+ url_cls : 'url',
+ number_cls : 'number',
+ email_cls : 'email',
+ size_cls : 'size',
+ required_cls : 'required',
+ invalid_cls : 'invalid',
+ min_cls : 'min',
+ max_cls : 'max'
+ },
+
+ init : function(s) {
+ var n;
+
+ for (n in s)
+ this.settings[n] = s[n];
+ },
+
+ validate : function(f) {
+ var i, nl, s = this.settings, c = 0;
+
+ nl = this.tags(f, 'label');
+ for (i=0; i<nl.length; i++)
+ this.removeClass(nl[i], s.invalid_cls);
+
+ c += this.validateElms(f, 'input');
+ c += this.validateElms(f, 'select');
+ c += this.validateElms(f, 'textarea');
+
+ return c == 3;
+ },
+
+ invalidate : function(n) {
+ this.mark(n.form, n);
+ },
+
+ reset : function(e) {
+ var t = new Array('label', 'input', 'select', 'textarea');
+ var i, j, nl, s = this.settings;
+
+ if (e == null)
+ return;
+
+ for (i=0; i<t.length; i++) {
+ nl = this.tags(e.form ? e.form : e, t[i]);
+ for (j=0; j<nl.length; j++)
+ this.removeClass(nl[j], s.invalid_cls);
+ }
+ },
+
+ validateElms : function(f, e) {
+ var nl, i, n, s = this.settings, st = true, va = Validator, v;
+
+ nl = this.tags(f, e);
+ for (i=0; i<nl.length; i++) {
+ n = nl[i];
+
+ this.removeClass(n, s.invalid_cls);
+
+ if (this.hasClass(n, s.required_cls) && va.isEmpty(n))
+ st = this.mark(f, n);
+
+ if (this.hasClass(n, s.number_cls) && !va.isNumber(n))
+ st = this.mark(f, n);
+
+ if (this.hasClass(n, s.int_cls) && !va.isNumber(n, true))
+ st = this.mark(f, n);
+
+ if (this.hasClass(n, s.url_cls) && !va.isAbsUrl(n))
+ st = this.mark(f, n);
+
+ if (this.hasClass(n, s.email_cls) && !va.isEmail(n))
+ st = this.mark(f, n);
+
+ if (this.hasClass(n, s.size_cls) && !va.isSize(n))
+ st = this.mark(f, n);
+
+ if (this.hasClass(n, s.id_cls) && !va.isId(n))
+ st = this.mark(f, n);
+
+ if (this.hasClass(n, s.min_cls, true)) {
+ v = this.getNum(n, s.min_cls);
+
+ if (isNaN(v) || parseInt(n.value) < parseInt(v))
+ st = this.mark(f, n);
+ }
+
+ if (this.hasClass(n, s.max_cls, true)) {
+ v = this.getNum(n, s.max_cls);
+
+ if (isNaN(v) || parseInt(n.value) > parseInt(v))
+ st = this.mark(f, n);
+ }
+ }
+
+ return st;
+ },
+
+ hasClass : function(n, c, d) {
+ return new RegExp('\\b' + c + (d ? '[0-9]+' : '') + '\\b', 'g').test(n.className);
+ },
+
+ getNum : function(n, c) {
+ c = n.className.match(new RegExp('\\b' + c + '([0-9]+)\\b', 'g'))[0];
+ c = c.replace(/[^0-9]/g, '');
+
+ return c;
+ },
-function validateString(form_name, element_name) {
- return (document.forms[form_name].elements[element_name].value.length > 0);
-}
+ addClass : function(n, c, b) {
+ var o = this.removeClass(n, c);
+ n.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c;
+ },
-function validateSelection(form_name, element_name) {
- return (document.forms[form_name].elements[element_name].selectedIndex > 0);
-}
+ removeClass : function(n, c) {
+ c = n.className.replace(new RegExp("(^|\\s+)" + c + "(\\s+|$)"), ' ');
+ return n.className = c != ' ' ? c : '';
+ },
-function validateCheckBox(form_name, element_name) {
- return document.forms[form_name].elements[element_name].checked;
-}
+ tags : function(f, s) {
+ return f.getElementsByTagName(s);
+ },
-function validateCleanString(form_name, element_name) {
- return testRegExp(form_name, element_name, '^[A-Za-z0-9_]+$');
-}
+ mark : function(f, n) {
+ var s = this.settings;
-function validateEmail(form_name, element_name) {
- return testRegExp(form_name, element_name, '^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$');
-}
+ this.addClass(n, s.invalid_cls);
+ this.markLabels(f, n, s.invalid_cls);
-function validateAbsUrl(form_name, element_name) {
- return testRegExp(form_name, element_name, '^(news|telnet|nttp|file|http|ftp|https)://[-A-Za-z0-9\\.]+$');
-}
+ return false;
+ },
-function validateNumber(form_name, element_name, allow_blank) {
- return (!allow_blank && value == '') ? false : testRegExp(form_name, element_name, '^-?[0-9]*\\.?[0-9]*$');
-}
+ markLabels : function(f, n, ic) {
+ var nl, i;
-function validateSize(form_name, element_name,) {
- return testRegExp(form_name, element_name, '^[0-9]+(px|%)?$');
-}
+ nl = this.tags(f, "label");
+ for (i=0; i<nl.length; i++) {
+ if (nl[i].getAttribute("for") == n.id || nl[i].htmlFor == n.id)
+ this.addClass(nl[i], ic);
+ }
-function validateID(form_name, element_name,) {
- return testRegExp(form_name, element_name, '^[A-Za-z_]([A-Za-z0-9_])*$');
-}
+ return null;
+ }
+};
diff --git a/wp-includes/js/wp-ajax-js.php b/wp-includes/js/wp-ajax-js.php
index e56cba9..0d4cf2b 100644
--- a/wp-includes/js/wp-ajax-js.php
+++ b/wp-includes/js/wp-ajax-js.php
@@ -19,7 +19,7 @@ Object.extend(WPAjax.prototype, {
tempObj.WPError(transport);
}
});
- this.url = url;
+ this.url = url ? url : '<?php bloginfo( 'wpurl' ); ?>/wp-admin/admin-ajax.php';
this.getResponseElement(responseEl);
},
addArg: function(key, value) {
@@ -91,3 +91,6 @@ Ajax.Responders.register( {
window.onbeforeunload = wpBeforeUnload;
}
});
+
+//Pretty func adapted from ALA http://www.alistapart.com/articles/gettingstartedwithajax
+function getNodeValue(tree,el){try { var r = tree.getElementsByTagName(el)[0].firstChild.nodeValue; } catch(err) { var r = null; } return r; }
diff --git a/wp-includes/l10n.php b/wp-includes/l10n.php
index b2b099c..b536b92 100644
--- a/wp-includes/l10n.php
+++ b/wp-includes/l10n.php
@@ -17,7 +17,7 @@ function get_locale() {
return $locale;
}
-// Return a translated string.
+// Return a translated string.
function __($text, $domain = 'default') {
global $l10n;
diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php
index c4002bd..151a986 100644
--- a/wp-includes/link-template.php
+++ b/wp-includes/link-template.php
@@ -63,7 +63,7 @@ function get_permalink($id = 0) {
$authordata = get_userdata($post->post_author);
$author = $authordata->user_nicename;
$date = explode(" ",date('Y m d H i s', $unixtime));
- $rewritereplace =
+ $rewritereplace =
array(
$date[0],
$date[1],
@@ -89,7 +89,23 @@ function post_permalink($post_id = 0, $mode = '') { // $mode legacy
return get_permalink($post_id);
}
+// Respects page_on_front. Use this one.
function get_page_link($id = false) {
+ global $post;
+
+ if ( !$id )
+ $id = $post->ID;
+
+ if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
+ $link = get_option('home');
+ else
+ $link = _get_page_link( $id );
+
+ return apply_filters('page_link', $link, $id);
+}
+
+// Ignores page_on_front. Internal use only.
+function _get_page_link( $id = false ) {
global $post, $wp_rewrite;
if ( !$id )
@@ -105,10 +121,7 @@ function get_page_link($id = false) {
$link = get_option('home') . "/?page_id=$id";
}
- if ( 'page' == get_option('show_on_front') && $id == get_option('page_on_front') )
- $link = get_option('home');
-
- return apply_filters('page_link', $link, $id);
+ return apply_filters( '_get_page_link', $link, $id );
}
function get_attachment_link($id = false) {
@@ -123,7 +136,10 @@ function get_attachment_link($id = false) {
$object = get_post($id);
if ( $wp_rewrite->using_permalinks() && ($object->post_parent > 0) ) {
$parent = get_post($object->post_parent);
- $parentlink = get_permalink($object->post_parent);
+ if ( 'page' == $parent->post_type )
+ $parentlink = _get_page_link( $object->post_parent ); // Ignores page_on_front
+ else
+ $parentlink = get_permalink( $object->post_parent );
if (! strstr($parentlink, '?') )
$link = trim($parentlink, '/') . '/' . $object->post_name . '/';
}
@@ -266,7 +282,7 @@ function get_previous_post($in_same_cat = false, $excluded_categories = '') {
for ( $i = 1; $i < (count($cat_array)); $i++ ) {
$join .= ' OR category_id = ' . intval($cat_array[$i]->cat_ID);
}
- $join .= ')';
+ $join .= ')';
}
$sql_exclude_cats = '';
@@ -299,7 +315,7 @@ function get_next_post($in_same_cat = false, $excluded_categories = '') {
for ( $i = 1; $i < (count($cat_array)); $i++ ) {
$join .= ' OR category_id = ' . intval($cat_array[$i]->cat_ID);
}
- $join .= ')';
+ $join .= ')';
}
$sql_exclude_cats = '';
@@ -334,7 +350,7 @@ function previous_post_link($format='&laquo; %link', $link='%title', $in_same_ca
$format = str_replace('%link', $link, $format);
- echo $format;
+ echo $format;
}
function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat = false, $excluded_categories = '') {
@@ -349,7 +365,7 @@ function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat =
$link = $string . $link . '</a>';
$format = str_replace('%link', $link, $format);
- echo $format;
+ echo $format;
}
function get_pagenum_link($pagenum = 1) {
@@ -357,7 +373,7 @@ function get_pagenum_link($pagenum = 1) {
$qstr = wp_specialchars($_SERVER['REQUEST_URI']);
- $page_querystring = "paged";
+ $page_querystring = "paged";
$page_modstring = "page/";
$page_modregex = "page/?";
$permalink = 0;
@@ -435,9 +451,9 @@ function next_posts($max_page = 0) { // original by cfactor at cooltux.org
}
function next_posts_link($label='Next Page &raquo;', $max_page=0) {
- global $paged, $wpdb;
+ global $paged, $wpdb, $wp_query;
if ( !$max_page ) {
- $max_page = _max_num_pages();
+ $max_page = $wp_query->max_num_pages;
}
if ( !$paged )
$paged = 1;
@@ -471,34 +487,12 @@ function previous_posts_link($label='&laquo; Previous Page') {
}
}
-function _max_num_pages() {
- static $max_num_pages;
- global $wpdb, $wp_query;
-
- if (isset($max_num_pages)) return $max_num_pages;
- $posts_per = get_query_var('posts_per_page');
- if ( empty($posts_per) ) $posts_per = 1;
-
- if ( 'posts' == get_query_var('what_to_show') ) {
- preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
- $fromwhere = $matches[1];
- $numposts = $wpdb->get_var("SELECT COUNT(DISTINCT $wpdb->posts.ID) FROM $fromwhere");
- $max_num_pages = ceil($numposts / $posts_per);
- } else {
- preg_match('#FROM\s(.*)\sORDER BY#siU', $wp_query->request, $matches);
- $fromwhere = preg_replace('/( AND )?post_date >= (\'|\")(.*?)(\'|\")( AND post_date <= (\'\")(.*?)(\'\"))?/siU', '', $matches[1]);
- $num_days = $wpdb->query("SELECT DISTINCT post_date FROM $fromwhere GROUP BY year(post_date), month(post_date), dayofmonth(post_date)");
- $max_num_pages = ceil($num_days / $posts_per);
- }
-
- return $max_num_pages;
-}
-
function posts_nav_link($sep=' &#8212; ', $prelabel='&laquo; Previous Page', $nxtlabel='Next Page &raquo;') {
- if ( !is_single() ) {
- $max_num_pages = _max_num_pages();
+ global $wp_query;
+ if ( !is_singular() ) {
+ $max_num_pages = $wp_query->max_num_pages;
$paged = get_query_var('paged');
-
+
//only have sep if there's both prev and next results
if ($paged < 2 || $paged >= $max_num_pages) {
$sep = '';
diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php
index 18426d6..a4bb24b 100644
--- a/wp-includes/pluggable.php
+++ b/wp-includes/pluggable.php
@@ -46,7 +46,7 @@ function get_currentuserinfo() {
if ( ! empty($current_user) )
return;
- if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) ||
+ if ( empty($_COOKIE[USER_COOKIE]) || empty($_COOKIE[PASS_COOKIE]) ||
!wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true) ) {
wp_set_current_user(0);
return false;
@@ -218,7 +218,7 @@ endif;
if ( !function_exists('auth_redirect') ) :
function auth_redirect() {
// Checks if a user is logged in, if not redirects them to the login page
- if ( (!empty($_COOKIE[USER_COOKIE]) &&
+ if ( (!empty($_COOKIE[USER_COOKIE]) &&
!wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true)) ||
(empty($_COOKIE[USER_COOKIE])) ) {
nocache_headers();
@@ -278,7 +278,8 @@ function wp_redirect($location, $status = 302) {
if ( $is_IIS ) {
header("Refresh: 0;url=$location");
} else {
- status_header($status); // This causes problems on IIS
+ if ( php_sapi_name() != 'cgi-fcgi' )
+ status_header($status); // This causes problems on IIS and some FastCGI setups
header("Location: $location");
}
}
@@ -339,7 +340,7 @@ endif;
if ( ! function_exists('wp_notify_postauthor') ) :
function wp_notify_postauthor($comment_id, $comment_type='') {
global $wpdb;
-
+
$comment = get_comment($comment_id);
$post = get_post($comment->comment_post_ID);
$user = get_userdata( $post->post_author );
@@ -386,11 +387,11 @@ function wp_notify_postauthor($comment_id, $comment_type='') {
$from = "From: \"$blogname\" <$admin_email>";
if ( '' != $comment->comment_author_email )
$reply_to = "Reply-To: $comment->comment_author_email";
- } else {
+ } else {
$from = "From: \"$comment->comment_author\" <$admin_email>";
if ( '' != $comment->comment_author_email )
$reply_to = "Reply-To: \"$comment->comment_author_email\" <$comment->comment_author_email>";
- }
+ }
$message_headers = "MIME-Version: 1.0\n"
. "$from\n"
@@ -434,9 +435,9 @@ function wp_notify_moderator($comment_id) {
$notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n";
$notify_message .= sprintf( __('Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=%s'), $comment->comment_author_IP ) . "\r\n";
$notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n";
- $notify_message .= sprintf( __('To approve this comment, visit: %s'), get_option('siteurl')."/wp-admin/comment.php?action=mac&c=$comment_id" ) . "\r\n";
- $notify_message .= sprintf( __('To delete this comment, visit: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&c=$comment_id" ) . "\r\n";
- $notify_message .= sprintf( __('To mark this comment as spam, visit: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&dt=spam&c=$comment_id" ) . "\r\n";
+ $notify_message .= sprintf( __('Approve it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=mac&c=$comment_id" ) . "\r\n";
+ $notify_message .= sprintf( __('Delete it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&c=$comment_id" ) . "\r\n";
+ $notify_message .= sprintf( __('Spam it: %s'), get_option('siteurl')."/wp-admin/comment.php?action=cdc&dt=spam&c=$comment_id" ) . "\r\n";
$notify_message .= sprintf( __('Currently %s comments are waiting for approval. Please visit the moderation panel:'), $comments_waiting ) . "\r\n";
$notify_message .= get_option('siteurl') . "/wp-admin/moderation.php\r\n";
@@ -447,7 +448,7 @@ function wp_notify_moderator($comment_id) {
$subject = apply_filters('comment_moderation_subject', $subject, $comment_id);
@wp_mail($admin_email, $subject, $notify_message);
-
+
return true;
}
endif;
@@ -497,7 +498,7 @@ function wp_create_nonce($action = -1) {
$uid = $user->id;
$i = ceil(time() / 43200);
-
+
return substr(wp_hash($i . $action . $uid), -12, 10);
}
endif;
diff --git a/wp-includes/post.php b/wp-includes/post.php
index 40606ae..642f664 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -8,25 +8,27 @@ function get_attached_file($attachment_id) {
return get_post_meta($attachment_id, '_wp_attached_file', true);
}
-function &get_children($post = 0, $output = OBJECT) {
+function &get_children($args = '', $output = OBJECT) {
global $post_cache, $wpdb, $blog_id;
- if ( empty($post) ) {
+ if ( empty($args) ) {
if ( isset($GLOBALS['post']) )
- $post_parent = & $GLOBALS['post']->post_parent;
+ $r = array('post_parent' => & $GLOBALS['post']->post_parent);
else
return false;
- } elseif ( is_object($post) ) {
- $post_parent = $post->post_parent;
- } else {
- $post_parent = $post;
- }
-
- $post_parent = (int) $post_parent;
+ } elseif ( is_object($args) )
+ $r = array('post_parent' => $post->post_parent);
+ elseif ( is_numeric($args) )
+ $r = array('post_parent' => $args);
+ elseif ( is_array($args) )
+ $r = &$args;
+ else
+ parse_str($args, $r);
- $query = "SELECT * FROM $wpdb->posts WHERE post_parent = $post_parent";
+ $defaults = array('numberposts' => -1, 'post_type' => '', 'post_status' => '', 'post_parent' => 0);
+ $r = array_merge($defaults, $r);
- $children = $wpdb->get_results($query);
+ $children = get_posts( $r );
if ( $children ) {
foreach ( $children as $key => $child ) {
@@ -158,18 +160,24 @@ function get_posts($args) {
else
parse_str($args, $r);
- $defaults = array('numberposts' => 5, 'offset' => 0, 'category' => '',
- 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' =>'');
+ $defaults = array('numberposts' => 5, 'offset' => 0, 'category' => 0,
+ 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '',
+ 'meta_key' => '', 'meta_value' =>'', 'post_type' => 'post', 'post_status' => 'publish', 'post_parent' => 0);
$r = array_merge($defaults, $r);
extract($r);
+ $numberposts = (int) $numberposts;
+ $offset = (int) $offset;
+ $category = (int) $category;
+ $post_parent = (int) $post_parent;
$inclusions = '';
if ( !empty($include) ) {
- $offset = 0; //ignore offset, category, exclude, meta_key, and meta_value params if using include
- $category = '';
- $exclude = '';
+ $offset = 0; //ignore offset, category, exclude, meta_key, and meta_value, post_parent if using include
+ $category = 0;
+ $exclude = '';
$meta_key = '';
$meta_value = '';
+ $post_parent = 0;
$incposts = preg_split('/[\s,]+/',$include);
$numberposts = count($incposts); // only the number of posts included
if ( count($incposts) ) {
@@ -181,8 +189,8 @@ function get_posts($args) {
}
}
}
- if (!empty($inclusions))
- $inclusions .= ')';
+ if (!empty($inclusions))
+ $inclusions .= ')';
$exclusions = '';
if ( !empty($exclude) ) {
@@ -196,16 +204,30 @@ function get_posts($args) {
}
}
}
- if (!empty($exclusions))
+ if (!empty($exclusions))
$exclusions .= ')';
$query ="SELECT DISTINCT * FROM $wpdb->posts " ;
- $query .= ( empty( $category ) ? "" : ", $wpdb->post2cat " ) ;
- $query .= ( empty( $meta_key ) ? "" : ", $wpdb->postmeta " ) ;
- $query .= " WHERE (post_type = 'post' AND post_status = 'publish') $exclusions $inclusions " ;
- $query .= ( empty( $category ) ? "" : "AND ($wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $category. ") " ) ;
- $query .= ( empty( $meta_key ) | empty($meta_value) ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" ) ;
- $query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . " " . $order . " LIMIT " . $offset . ',' . $numberposts ;
+ $query .= ( empty( $category ) ? "" : ", $wpdb->post2cat " );
+ $query .= ( empty( $meta_key ) ? "" : ", $wpdb->postmeta " );
+ $query .= " WHERE (post_type = 'post' AND post_status = 'publish') $exclusions $inclusions ";
+ $query .= ( empty( $category ) ? "" : "AND ($wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $category. ") " );
+ $query .= ( empty( $meta_key ) | empty($meta_value) ? "" : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )" );
+ $query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . " " . $order . " LIMIT " . $offset . ',' . $numberposts;
+
+ $query = "SELECT DISTINCT * FROM $wpdb->posts ";
+ $query .= empty( $category ) ? '' : ", $wpdb->post2cat ";
+ $query .= empty( $meta_key ) ? '' : ", $wpdb->postmeta ";
+ $query .= " WHERE 1=1 ";
+ $query .= empty( $post_type ) ? '' : "AND post_type = '$post_type' ";
+ $query .= empty( $post_status ) ? '' : "AND post_status = '$post_status' ";
+ $query .= "$exclusions $inclusions " ;
+ $query .= empty( $category ) ? '' : "AND ($wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $category. ") ";
+ $query .= empty( $post_parent ) ? '' : "AND $wpdb->posts.post_parent = '$post_parent' ";
+ $query .= empty( $meta_key ) | empty($meta_value) ? '' : " AND ($wpdb->posts.ID = $wpdb->postmeta.post_id AND $wpdb->postmeta.meta_key = '$meta_key' AND $wpdb->postmeta.meta_value = '$meta_value' )";
+ $query .= " GROUP BY $wpdb->posts.ID ORDER BY " . $orderby . ' ' . $order;
+ if ( 0 < $numberposts )
+ $query .= " LIMIT " . $offset . ',' . $numberposts;
$posts = $wpdb->get_results($query);
@@ -229,7 +251,7 @@ function add_post_meta($post_id, $key, $value, $unique = false) {
}
}
- $post_meta_cache[$blog_id][$post_id][$key][] = $original;
+ $post_meta_cache[$blog_id][$post_id][$key][] = $value;
$value = maybe_serialize($value);
$value = $wpdb->escape($value);
@@ -274,6 +296,14 @@ function get_post_meta($post_id, $key, $single = false) {
$post_id = (int) $post_id;
+ if ( isset($post_meta_cache[$blog_id][$post_id][$key]) ) {
+ if ( $single ) {
+ return maybe_unserialize( $post_meta_cache[$blog_id][$post_id][$key][0] );
+ } else {
+ return maybe_unserialize( $post_meta_cache[$blog_id][$post_id][$key] );
+ }
+ }
+
if ( !isset($post_meta_cache[$blog_id][$post_id]) )
update_postmeta_cache($post_id);
@@ -392,6 +422,8 @@ function wp_delete_post($postid = 0) {
$wp_rewrite->flush_rules();
}
+ do_action('post_deleted', $postid);
+
return $post;
}
@@ -400,9 +432,9 @@ function wp_get_post_categories($post_ID = 0) {
$post_ID = (int) $post_ID;
- $sql = "SELECT category_id
- FROM $wpdb->post2cat
- WHERE post_id = '$post_ID'
+ $sql = "SELECT category_id
+ FROM $wpdb->post2cat
+ WHERE post_id = '$post_ID'
ORDER BY category_id";
$result = $wpdb->get_col($sql);
@@ -435,7 +467,7 @@ function wp_get_single_post($postid = 0, $mode = OBJECT) {
// Set categories
if($mode == OBJECT) {
$post->post_category = wp_get_post_categories($postid);
- }
+ }
else {
$post['post_category'] = wp_get_post_categories($postid);
}
@@ -635,13 +667,13 @@ function wp_insert_post($postarr = array()) {
if ( !defined('WP_IMPORTING') ) {
if ( $post_pingback )
$result = $wpdb->query("
- INSERT INTO $wpdb->postmeta
- (post_id,meta_key,meta_value)
+ INSERT INTO $wpdb->postmeta
+ (post_id,meta_key,meta_value)
VALUES ('$post_ID','_pingme','1')
");
$result = $wpdb->query("
- INSERT INTO $wpdb->postmeta
- (post_id,meta_key,meta_value)
+ INSERT INTO $wpdb->postmeta
+ (post_id,meta_key,meta_value)
VALUES ('$post_ID','_encloseme','1')
");
wp_schedule_single_event(time(), 'do_pings');
@@ -653,7 +685,7 @@ 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);
}
@@ -684,22 +716,22 @@ function wp_update_post($postarr = array()) {
$post = add_magic_quotes($post);
// Passed post category list overwrites existing category list if not empty.
- if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
+ if ( isset($postarr['post_category']) && is_array($postarr['post_category'])
&& 0 != count($postarr['post_category']) )
- $post_cats = $postarr['post_category'];
- else
- $post_cats = $post['post_category'];
+ $post_cats = $postarr['post_category'];
+ else
+ $post_cats = $post['post_category'];
// Drafts shouldn't be assigned a date unless explicitly done so by the user
- if ( 'draft' == $post['post_status'] && empty($postarr['edit_date']) && empty($postarr['post_date']) &&
- ('0000-00-00 00:00:00' == $post['post_date']) )
+ if ( 'draft' == $post['post_status'] && empty($postarr['edit_date']) && empty($postarr['post_date']) &&
+ ('0000-00-00 00:00:00' == $post['post_date']) )
$clear_date = true;
else
$clear_date = false;
- // Merge old and new fields with new fields overwriting old ones.
- $postarr = array_merge($post, $postarr);
- $postarr['post_category'] = $post_cats;
+ // Merge old and new fields with new fields overwriting old ones.
+ $postarr = array_merge($post, $postarr);
+ $postarr['post_category'] = $post_cats;
if ( $clear_date ) {
$postarr['post_date'] = '';
$postarr['post_date_gmt'] = '';
@@ -733,8 +765,8 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
// First the old categories
$old_categories = $wpdb->get_col("
- SELECT category_id
- FROM $wpdb->post2cat
+ SELECT category_id
+ FROM $wpdb->post2cat
WHERE post_id = $post_ID");
if (!$old_categories) {
@@ -749,9 +781,9 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
if ($delete_cats) {
foreach ($delete_cats as $del) {
$wpdb->query("
- DELETE FROM $wpdb->post2cat
- WHERE category_id = $del
- AND post_id = $post_ID
+ DELETE FROM $wpdb->post2cat
+ WHERE category_id = $del
+ AND post_id = $post_ID
");
}
}
@@ -774,7 +806,10 @@ function wp_set_post_categories($post_ID = 0, $post_categories = array()) {
$count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->post2cat, $wpdb->posts WHERE $wpdb->posts.ID=$wpdb->post2cat.post_id AND post_status = 'publish' AND post_type = 'post' AND category_id = '$cat_id'");
$wpdb->query("UPDATE $wpdb->categories SET category_count = '$count' WHERE cat_ID = '$cat_id'");
wp_cache_delete($cat_id, 'category');
+ do_action('edit_category', $cat_id);
}
+
+ do_action('edit_post', $post_ID);
} // wp_set_post_categories()
//
@@ -848,10 +883,10 @@ function trackback_url_list($tb_list, $post_id) {
$trackback_urls = explode(',', $tb_list);
foreach($trackback_urls as $tb_url) {
- $tb_url = trim($tb_url);
- trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
+ $tb_url = trim($tb_url);
+ trackback($tb_url, stripslashes($post_title), $excerpt, $post_id);
+ }
}
- }
}
//
@@ -891,7 +926,7 @@ function &get_page(&$page, $output = OBJECT) {
if ( isset($GLOBALS['page']->ID) && ($page == $GLOBALS['page']->ID) ) {
$_page = & $GLOBALS['page'];
wp_cache_add($_page->ID, $_page, 'pages');
- } elseif ( isset($_page) && $_page == $GLOBALS['post_cache'][$blog_id][$page] ) {
+ } elseif ( !isset($_page) && $_page == $GLOBALS['post_cache'][$blog_id][$page] ) {
return get_post($page, $output);
} elseif ( isset($_page) && $_page == wp_cache_get($page, 'pages') ) {
// Got it.
@@ -928,7 +963,7 @@ function get_page_by_path($page_path, $output = OBJECT) {
$pages = $wpdb->get_results("SELECT ID, post_name, post_parent FROM $wpdb->posts WHERE post_name = '$leaf_path' AND post_type='page'");
- if ( empty($pages) )
+ if ( empty($pages) )
return NULL;
foreach ($pages as $page) {
@@ -1016,6 +1051,11 @@ function &get_pages($args = '') {
$r = array_merge($defaults, $r);
extract($r);
+ $key = md5( serialize( $r ) );
+ if ( $cache = wp_cache_get( 'get_pages', 'page' ) )
+ if ( isset( $cache[ $key ] ) )
+ return apply_filters('get_pages', $cache[ $key ], $r );
+
$inclusions = '';
if ( !empty($include) ) {
$child_of = 0; //ignore child_of, exclude, meta_key, and meta_value params if using include
@@ -1095,9 +1135,17 @@ function &get_pages($args = '') {
if ( $child_of || $hierarchical )
$pages = & get_page_children($child_of, $pages);
+ $cache[ $key ] = $pages;
+ wp_cache_set( 'get_pages', $cache, 'page' );
+
return $pages;
}
+function delete_get_pages_cache() {
+ wp_cache_delete( 'get_pages', 'page' );
+}
+add_action( 'save_post', 'delete_get_pages_cache' );
+
function generate_page_uri_index() {
global $wpdb;
@@ -1196,7 +1244,7 @@ function wp_insert_attachment($object, $file = false, $post_parent = 0) {
if (empty($post_date))
$post_date = current_time('mysql');
- if (empty($post_date_gmt))
+ if (empty($post_date_gmt))
$post_date_gmt = current_time('mysql', 1);
if ( empty($comment_status) ) {
diff --git a/wp-includes/query.php b/wp-includes/query.php
index b2dd69d..6f5fbf0 100644
--- a/wp-includes/query.php
+++ b/wp-includes/query.php
@@ -3,7 +3,7 @@
/*
* The Big Query.
*/
-
+
function get_query_var($var) {
global $wp_query;
@@ -11,8 +11,9 @@ function get_query_var($var) {
}
function &query_posts($query) {
- global $wp_query;
- return $wp_query->query($query);
+ unset($GLOBALS['wp_query']);
+ $GLOBALS['wp_query'] =& new WP_Query();
+ return $GLOBALS['wp_query']->query($query);
}
/*
@@ -223,7 +224,7 @@ function is_404 () {
/*
* The Loop. Post loop control.
*/
-
+
function have_posts() {
global $wp_query;
@@ -265,6 +266,9 @@ class WP_Query {
var $in_the_loop = false;
var $post;
+ var $found_posts = 0;
+ var $max_num_pages = 0;
+
var $is_single = false;
var $is_preview = false;
var $is_page = false;
@@ -412,8 +416,8 @@ class WP_Query {
} elseif ( $qv['p'] ) {
$this->is_single = true;
} elseif (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {
- // If year, month, day, hour, minute, and second are set, a single
- // post is being queried.
+ // If year, month, day, hour, minute, and second are set, a single
+ // post is being queried.
$this->is_single = true;
} elseif ('' != $qv['static'] || '' != $qv['pagename'] || (int) $qv['page_id']) {
$this->is_page = true;
@@ -489,7 +493,7 @@ class WP_Query {
if ('' != $qv['category_name']) {
$this->is_category = true;
}
-
+
if ((empty($qv['author'])) || ($qv['author'] == '0')) {
$this->is_author = false;
} else {
@@ -583,14 +587,13 @@ class WP_Query {
$limits = '';
$join = '';
$search = '';
+ $groupby = '';
if ( !isset($q['post_type']) )
$q['post_type'] = 'post';
$post_type = $q['post_type'];
if ( !isset($q['posts_per_page']) || $q['posts_per_page'] == 0 )
$q['posts_per_page'] = get_option('posts_per_page');
- if ( !isset($q['what_to_show']) )
- $q['what_to_show'] = get_option('what_to_show');
if ( isset($q['showposts']) && $q['showposts'] ) {
$q['showposts'] = (int) $q['showposts'];
$q['posts_per_page'] = $q['showposts'];
@@ -606,7 +609,6 @@ class WP_Query {
}
if ( $this->is_feed ) {
$q['posts_per_page'] = get_option('posts_per_rss');
- $q['what_to_show'] = 'posts';
}
$q['posts_per_page'] = (int) $q['posts_per_page'];
if ( $q['posts_per_page'] < -1 )
@@ -693,6 +695,7 @@ class WP_Query {
$reqpage = 0;
if ( ('page' == get_option('show_on_front') ) && ( $reqpage == get_option('page_for_posts') ) ) {
+ $this->is_singular = false;
$this->is_page = false;
$this->is_home = true;
$this->is_posts_page = true;
@@ -732,6 +735,7 @@ class WP_Query {
if (($q['page_id'] != '') && (intval($q['page_id']) != 0)) {
$q['page_id'] = intval($q['page_id']);
if ( ('page' == get_option('show_on_front') ) && ( $q['page_id'] == get_option('page_for_posts') ) ) {
+ $this->is_singular = false;
$this->is_page = false;
$this->is_home = true;
$this->is_posts_page = true;
@@ -767,7 +771,7 @@ class WP_Query {
// Category stuff
- if ((empty($q['cat'])) || ($q['cat'] == '0') ||
+ if ((empty($q['cat'])) || ($q['cat'] == '0') ||
// Bypass cat checks if fetching specific posts
( $this->is_single || $this->is_page )) {
$whichcat='';
@@ -784,7 +788,7 @@ class WP_Query {
if ( $in )
$in_cats .= "$cat, " . get_category_children($cat, '', ', ');
else
- $out_cats .= "$cat, " . get_category_children($cat, '', ', ');
+ $out_cats .= "$cat, " . get_category_children($cat, '', ', ');
}
$in_cats = substr($in_cats, 0, -2);
$out_cats = substr($out_cats, 0, -2);
@@ -801,12 +805,10 @@ class WP_Query {
$out_cats = " AND ID NOT IN ($out_posts)";
}
$whichcat = $in_cats . $out_cats;
- $distinct = 'DISTINCT';
+ $groupby = "{$wpdb->posts}.ID";
}
// Category stuff for nice URLs
-
- global $cache_categories;
if ('' != $q['category_name']) {
$reqcat = get_category_by_path($q['category_name']);
$q['category_name'] = str_replace('%2F', '/', urlencode(urldecode($q['category_name'])));
@@ -829,14 +831,14 @@ class WP_Query {
$reqcat = 0;
$q['cat'] = $reqcat;
-
+
$tables = ", $wpdb->post2cat, $wpdb->categories";
$join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
$whichcat = " AND category_id IN ({$q['cat']}, ";
$whichcat .= get_category_children($q['cat'], '', ', ');
$whichcat = substr($whichcat, 0, -2);
$whichcat .= ")";
- $distinct = 'DISTINCT';
+ $groupby = "{$wpdb->posts}.ID";
}
// Author/user stuff
@@ -920,7 +922,7 @@ class WP_Query {
if ( is_admin() )
$where .= " OR post_status = 'future' OR post_status = 'draft'";
-
+
if ( is_user_logged_in() ) {
if ( 'post' == $post_type )
$cap = 'edit_private_posts';
@@ -942,40 +944,26 @@ class WP_Query {
$join = apply_filters('posts_join', $join);
// Paging
- if (empty($q['nopaging']) && ! $this->is_single && ! $this->is_page) {
+ if (empty($q['nopaging']) && !$this->is_singular) {
$page = abs(intval($q['paged']));
if (empty($page)) {
$page = 1;
}
- if (($q['what_to_show'] == 'posts')) {
- if ( empty($q['offset']) ) {
- $pgstrt = '';
- $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
- $limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
- } else { // we're ignoring $page and using 'offset'
- $q['offset'] = abs(intval($q['offset']));
- $pgstrt = $q['offset'] . ', ';
- $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
- }
- } elseif ($q['what_to_show'] == 'days') {
- $startrow = $q['posts_per_page'] * (intval($page)-1);
- $start_date = $wpdb->get_var("SELECT max(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $startrow,1");
- $endrow = $startrow + $q['posts_per_page'] - 1;
- $end_date = $wpdb->get_var("SELECT min(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $endrow,1");
-
- if ($page > 1) {
- $where .= " AND post_date >= '$end_date' AND post_date <= '$start_date'";
- } else {
- $where .= " AND post_date >= '$end_date'";
- }
+ if ( empty($q['offset']) ) {
+ $pgstrt = '';
+ $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
+ $limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
+ } else { // we're ignoring $page and using 'offset'
+ $q['offset'] = abs(intval($q['offset']));
+ $pgstrt = $q['offset'] . ', ';
+ $limits = 'LIMIT ' . $pgstrt . $q['posts_per_page'];
}
}
// Apply post-paging filters on where and join. Only plugins that
// manipulate paging queries should use these hooks.
$where = apply_filters('posts_where_paged', $where);
- $groupby = '';
$groupby = apply_filters('posts_groupby', $groupby);
if ( ! empty($groupby) )
$groupby = 'GROUP BY ' . $groupby;
@@ -983,11 +971,17 @@ class WP_Query {
$orderby = apply_filters('posts_orderby', $q['orderby']);
$distinct = apply_filters('posts_distinct', $distinct);
$fields = apply_filters('posts_fields', "$wpdb->posts.*");
- $request = " SELECT $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby ORDER BY $orderby $limits";
+ $found_rows = '';
+ if ( !empty($limits) )
+ $found_rows = 'SQL_CALC_FOUND_ROWS';
+ $request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby ORDER BY $orderby $limits";
$this->request = apply_filters('posts_request', $request);
$this->posts = $wpdb->get_results($this->request);
-
+ if ( !empty($limits) ) {
+ $this->found_posts = $wpdb->get_var('SELECT FOUND_ROWS()');
+ $this->max_num_pages = ceil($this->found_posts / $q['posts_per_page']);
+ }
// Check post status to determine if post should be displayed.
if ( !empty($this->posts) && ($this->is_single || $this->is_page) ) {
$status = get_post_status($this->posts[0]);
@@ -1018,9 +1012,10 @@ class WP_Query {
}
}
+ $this->posts = apply_filters('the_posts', $this->posts);
+
update_post_caches($this->posts);
- $this->posts = apply_filters('the_posts', $this->posts);
$this->post_count = count($this->posts);
if ($this->post_count > 0) {
$this->post = $this->posts[0];
@@ -1030,7 +1025,7 @@ class WP_Query {
}
function next_post() {
-
+
$this->current_post++;
$this->post = $this->posts[$this->current_post];
@@ -1066,7 +1061,7 @@ class WP_Query {
$this->post = $this->posts[0];
}
}
-
+
function &query($query) {
$this->parse_query($query);
return $this->get_posts();
diff --git a/wp-includes/registration.php b/wp-includes/registration.php
index 8ec38a4..39b931c 100644
--- a/wp-includes/registration.php
+++ b/wp-includes/registration.php
@@ -85,9 +85,9 @@ function wp_insert_user($userdata) {
$wpdb->query( $query );
$user_id = $ID;
} else {
- $query = "INSERT INTO $wpdb->users
+ $query = "INSERT INTO $wpdb->users
(user_login, user_pass, user_email, user_url, user_registered, user_nicename, display_name)
- VALUES
+ VALUES
('$user_login', '$user_pass', '$user_email', '$user_url', '$user_registered', '$user_nicename', '$display_name')";
$query = apply_filters('create_user_query', $query);
$wpdb->query( $query );
diff --git a/wp-includes/rewrite.php b/wp-includes/rewrite.php
index 571f0c0..4b35e3b 100644
--- a/wp-includes/rewrite.php
+++ b/wp-includes/rewrite.php
@@ -16,15 +16,15 @@ function add_rewrite_tag($tagname, $regex) {
if (strlen($tagname) < 3 || $tagname{0} != '%' || $tagname{strlen($tagname)-1} != '%') {
return;
}
-
+
$qv = trim($tagname, '%');
-
+
global $wp_rewrite, $wp;
$wp->add_query_var($qv);
$wp_rewrite->add_rewrite_tag($tagname, $regex, $qv . '=');
}
-//Add a new feed type like /atom1/
+//Add a new feed type like /atom1/
function add_feed($feedname, $function) {
global $wp_rewrite;
if (!in_array($feedname, $wp_rewrite->feeds)) { //override the file if it is
@@ -169,7 +169,7 @@ class WP_Rewrite {
var $non_wp_rules; //rules that don't redirect to WP's index.php
var $endpoints;
var $use_verbose_rules = false;
- var $rewritecode =
+ var $rewritecode =
array(
'%year%',
'%monthnum%',
@@ -185,7 +185,7 @@ class WP_Rewrite {
'%search%'
);
- var $rewritereplace =
+ var $rewritereplace =
array(
'([0-9]{4})',
'([0-9]{1,2})',
@@ -201,7 +201,7 @@ class WP_Rewrite {
'(.+)'
);
- var $queryreplace =
+ var $queryreplace =
array (
'year=',
'monthnum=',
@@ -218,7 +218,7 @@ class WP_Rewrite {
);
var $feeds = array ( 'feed', 'rdf', 'rss', 'rss2', 'atom' );
-
+
function using_permalinks() {
if (empty($this->permalink_structure))
return false;
@@ -235,7 +235,7 @@ class WP_Rewrite {
if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) {
return true;
}
-
+
return false;
}
@@ -251,11 +251,11 @@ class WP_Rewrite {
$match_suffix = '';
if (! empty($this->matches)) {
- $match_prefix = '$' . $this->matches . '[';
+ $match_prefix = '$' . $this->matches . '[';
$match_suffix = ']';
- }
+ }
- return "$match_prefix$number$match_suffix";
+ return "$match_prefix$number$match_suffix";
}
function page_rewrite_rules() {
@@ -301,13 +301,13 @@ class WP_Rewrite {
$date_endian= $endian;
break;
}
- }
+ }
if ( empty($date_endian) )
$date_endian = '%year%/%monthnum%/%day%';
// Do not allow the date tags and %post_id% to overlap in the permalink
- // structure. If they do, move the date tags to $front/date/.
+ // structure. If they do, move the date tags to $front/date/.
$front = $this->front;
preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
$tok_index = 1;
@@ -482,11 +482,11 @@ class WP_Rewrite {
//build a regex to match the trackback and page/xx parts of URLs
$trackbackregex = 'trackback/?$';
$pageregex = 'page/?([0-9]{1,})/?$';
-
+
//build up an array of endpoint regexes to append => queries to append
if ($endpoints) {
$ep_query_append = array ();
- foreach ($this->endpoints as $endpoint) {
+ foreach ($this->endpoints as $endpoint) {
//match everything after the endpoint name, but allow for nothing to appear there
$epmatch = $endpoint[1] . '(/(.*))?/?$';
//this will be appended on to the rest of the query for each dir
@@ -511,7 +511,7 @@ class WP_Rewrite {
if (0 < $i) {
$queries[$i] = $queries[$i - 1] . '&';
}
-
+
$query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1);
$queries[$i] .= $query_token;
}
@@ -548,7 +548,7 @@ class WP_Rewrite {
$num_toks = preg_match_all('/%.+?%/', $struct, $toks);
//get the 'tagname=$matches[i]'
$query = $queries[$num_toks - 1];
-
+
//set up $ep_mask_specific which is used to match more specific URL types
switch ($dirs[$j]) {
case '%year%': $ep_mask_specific = EP_YEAR; break;
@@ -580,15 +580,15 @@ class WP_Rewrite {
$rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2);
if ($paged) //...and /page/xx ones
$rewrite = array_merge($rewrite, array($pagematch => $pagequery));
-
+
//if we've got some tags in this dir
if ($num_toks) {
$post = false;
$page = false;
-
- //check to see if this dir is permalink-level: i.e. the structure specifies an
+
+ //check to see if this dir is permalink-level: i.e. the structure specifies an
//individual post. Do this by checking it contains at least one of 1) post name,
- //2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and
+ //2) post ID, 3) page name, 4) timestamp (year, month, day, hour, second and
//minute all present). Set these flags now as we need them for the endpoints.
if (strstr($struct, '%postname%') || strstr($struct, '%post_id%')
|| strstr($struct, '%pagename%')
@@ -597,7 +597,7 @@ class WP_Rewrite {
if ( strstr($struct, '%pagename%') )
$page = true;
}
-
+
//do endpoints
if ($endpoints) {
foreach ($ep_query_append as $regex => $ep) {
@@ -607,7 +607,7 @@ class WP_Rewrite {
}
}
}
-
+
//if we're creating rules for a permalink, do all the endpoints like attachments etc
if ($post) {
$post = true;
@@ -618,7 +618,7 @@ class WP_Rewrite {
$match = rtrim($match, '/');
//get rid of brackets
$submatchbase = str_replace(array('(',')'),'',$match);
-
+
//add a rule for at attachments, which take the form of <permalink>/some-text
$sub1 = $submatchbase . '/([^/]+)/';
$sub1tb = $sub1 . $trackbackregex; //add trackback regex <permalink>/trackback/...
@@ -626,19 +626,19 @@ class WP_Rewrite {
$sub1feed2 = $sub1 . $feedregex2; //and <permalink>/(feed|atom...)
//add an ? as we don't have to match that last slash, and finally a $ so we
//match to the end of the URL
-
+
//add another rule to match attachments in the explicit form:
//<permalink>/attachment/some-text
$sub2 = $submatchbase . '/attachment/([^/]+)/';
$sub2tb = $sub2 . $trackbackregex; //and add trackbacks <permalink>/attachment/trackback
$sub2feed = $sub2 . $feedregex; //feeds, <permalink>/attachment/feed/(atom|...)
$sub2feed2 = $sub2 . $feedregex2; //and feeds again on to this <permalink>/attachment/(feed|atom...)
-
+
//create queries for these extra tag-ons we've just dealt with
$subquery = $index . '?attachment=' . $this->preg_index(1);
$subtbquery = $subquery . '&tb=1';
$subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
-
+
//do endpoints for attachments
if ($endpoint) { foreach ($ep_query_append as $regex => $ep) {
if ($ep[0] & EP_ATTACHMENT) {
@@ -646,11 +646,11 @@ class WP_Rewrite {
$rewrite[$sub2 . $regex] = $subquery . '?' . $ep[1] . $this->preg_index(2);
}
} }
-
+
//now we've finished with endpoints, finish off the $sub1 and $sub2 matches
$sub1 .= '?$';
$sub2 .= '?$';
-
+
//allow URLs like <permalink>/2 for <permalink>/page/2
$match = $match . '(/[0-9]+)?/?$';
$query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1);
@@ -659,7 +659,7 @@ class WP_Rewrite {
$match .= '?$';
$query = $index . '?' . $query;
}
-
+
//create the final array for this dir by joining the $rewrite array (which currently
//only contains rules/queries for trackback, pages etc) to the main regex/query for
//this dir
@@ -669,7 +669,7 @@ class WP_Rewrite {
if ($post) {
//add trackback
$rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite);
-
+
//add regexes/queries for attachments, attachment trackbacks and so on
if ( ! $page ) //require <permalink>/attachment/stuff form for pages because of confusion with subpages
$rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery));
@@ -763,11 +763,11 @@ class WP_Rewrite {
$home_root = parse_url(get_option('home'));
$home_root = trailingslashit($home_root['path']);
-
+
$rules = "<IfModule mod_rewrite.c>\n";
$rules .= "RewriteEngine On\n";
$rules .= "RewriteBase $home_root\n";
-
+
//add in the rules that don't redirect to WP's index.php (and thus shouldn't be handled by WP at all)
foreach ($this->non_wp_rules as $match => $query) {
// Apache 1.3 does not support the reluctant (non-greedy) modifier.
@@ -819,7 +819,7 @@ class WP_Rewrite {
return $rules;
}
-
+
//Add a straight rewrite rule
function add_rule($regex, $redirect) {
//get everything up to the first ?
@@ -831,12 +831,12 @@ class WP_Rewrite {
$this->extra_rules[$regex] = $redirect;
}
}
-
+
//add a rule that doesn't redirect to index.php
function add_external_rule($regex, $redirect) {
$this->non_wp_rules[$regex] = $redirect;
}
-
+
//add an endpoint, like /trackback/, to be inserted after certain URL types (specified in $places)
function add_endpoint($name, $places) {
global $wp;
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index f5585ec..0c33252 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -15,18 +15,13 @@ class WP_Scripts {
$this->add( 'sack', '/wp-includes/js/tw-sack.js', false, '1.6.1' );
$this->add( 'quicktags', '/wp-includes/js/quicktags.js', false, '3517' );
$this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '3517' );
- $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '09212006a' );
+ $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20061113' );
$mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php');
- $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20061006' );
+ $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20061113' );
$this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0');
- $this->add( 'autosave', '/wp-includes/js/autosave.js.php', array('prototype', 'sack'), '4211');
- $this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '4187');
- $this->add( 'listman', '/wp-includes/js/list-manipulation-js.php', array('wp-ajax', 'fat'), '4187');
- $this->add( 'scriptaculous', '/wp-includes/js/scriptaculous/scriptaculous.js', array('prototype'), '1.6.1');
- $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/scriptaculous.js?load=builder,dragdrop', array('prototype'), '1.6.1');
- $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/scriptaculous.js?load=controls', array('prototype'), '1.6.1');
- $this->add( 'cropper', '/wp-content/themes/connections/crop/cropper.js', array('scriptaculous-dragdrop'), '1');
- $this->add( 'colorpicker', '/wp-includes/js/colorpicker.js', false, '1');
+ $this->add( 'autosave', '/wp-includes/js/autosave.js.php', array('prototype', 'sack'), '4508');
+ $this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '4459');
+ $this->add( 'listman', '/wp-includes/js/list-manipulation-js.php', array('wp-ajax', 'fat'), '4459');
if ( is_admin() ) {
$this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' );
$this->add( 'ajaxcat', '/wp-admin/cat-js.php', array('listman'), '3684' );
@@ -35,7 +30,7 @@ class WP_Scripts {
$this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3847' );
$this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '3684' );
$this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' );
- $this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), '4355b' );
+ $this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), '4466b' );
}
}
@@ -80,7 +75,7 @@ class WP_Scripts {
}
}
}
-
+
/**
* Determines dependencies of scripts
@@ -169,7 +164,7 @@ class WP_Scripts {
endswitch;
return false;
}
-
+
}
class _WP_Script {
diff --git a/wp-includes/theme.php b/wp-includes/theme.php
index d8051da..46f7249 100644
--- a/wp-includes/theme.php
+++ b/wp-includes/theme.php
@@ -1,6 +1,6 @@
<?php
/*
- * Theme/template/stylesheet functions.
+ * Theme/template/stylesheet functions.
*/
function get_stylesheet() {
@@ -14,7 +14,7 @@ function get_stylesheet_directory() {
}
function get_stylesheet_directory_uri() {
- $stylesheet = rawurlencode( get_stylesheet() );
+ $stylesheet = get_stylesheet();
$stylesheet_dir_uri = get_theme_root_uri() . "/$stylesheet";
return apply_filters('stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet);
}
@@ -32,7 +32,7 @@ function get_locale_stylesheet_uri() {
$locale = get_locale();
if ( file_exists("$dir/$locale.css") )
$stylesheet_uri = "$stylesheet_dir_uri/$locale.css";
- else if ( !empty($wp_locale->text_direction) && file_exists("$dir/{$wp_locale->text_direction}.css") )
+ elseif ( !empty($wp_locale->text_direction) && file_exists("$dir/{$wp_locale->text_direction}.css") )
$stylesheet_uri = "$stylesheet_dir_uri/{$wp_locale->text_direction}.css";
else
$stylesheet_uri = '';
@@ -88,8 +88,7 @@ function get_theme_data($theme_file) {
}
function get_themes() {
- global $wp_themes;
- global $wp_broken_themes;
+ global $wp_themes, $wp_broken_themes;
if ( isset($wp_themes) )
return $wp_themes;
@@ -99,53 +98,70 @@ function get_themes() {
$theme_root = get_theme_root();
$theme_loc = str_replace(ABSPATH, '', $theme_root);
- // Files in wp-content/themes directory
+ // Files in wp-content/themes directory and one subdir down
$themes_dir = @ dir($theme_root);
- if ( $themes_dir ) {
- while(($theme_dir = $themes_dir->read()) !== false) {
- if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
- if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) {
- continue;
+ if ( !$themes_dir )
+ return false;
+
+ while ( ($theme_dir = $themes_dir->read()) !== false ) {
+ if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
+ if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' )
+ continue;
+ $stylish_dir = @ dir($theme_root . '/' . $theme_dir);
+ $found_stylesheet = false;
+ while ( ($theme_file = $stylish_dir->read()) !== false ) {
+ if ( $theme_file == 'style.css' ) {
+ $theme_files[] = $theme_dir . '/' . $theme_file;
+ $found_stylesheet = true;
+ break;
}
- $stylish_dir = @ dir($theme_root . '/' . $theme_dir);
- $found_stylesheet = false;
- while (($theme_file = $stylish_dir->read()) !== false) {
- if ( $theme_file == 'style.css' ) {
- $theme_files[] = $theme_dir . '/' . $theme_file;
- $found_stylesheet = true;
- break;
+ }
+ if ( !$found_stylesheet ) { // look for themes in that dir
+ $subdir = "$theme_root/$theme_dir";
+ $subdir_name = $theme_dir;
+ $theme_subdir = @dir( $subdir );
+ while ( ($theme_dir = $theme_subdir->read()) !== false ) {
+ if ( is_dir( $subdir . '/' . $theme_dir) && is_readable($subdir . '/' . $theme_dir) ) {
+ if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' )
+ continue;
+ $stylish_dir = @ dir($subdir . '/' . $theme_dir);
+ $found_stylesheet = false;
+ while ( ($theme_file = $stylish_dir->read()) !== false ) {
+ if ( $theme_file == 'style.css' ) {
+ $theme_files[] = $subdir_name . '/' . $theme_dir . '/' . $theme_file;
+ $found_stylesheet = true;
+ break;
+ }
+ }
}
}
- if ( !$found_stylesheet ) {
- $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
- }
+ $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
}
}
}
- if ( !$themes_dir || !$theme_files ) {
+ if ( !$themes_dir || !$theme_files )
return $themes;
- }
sort($theme_files);
- foreach($theme_files as $theme_file) {
- if ( ! is_readable("$theme_root/$theme_file") ) {
+ foreach ( (array) $theme_files as $theme_file ) {
+ if ( !is_readable("$theme_root/$theme_file") ) {
$wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.'));
continue;
}
$theme_data = get_theme_data("$theme_root/$theme_file");
- $name = $theme_data['Name'];
- $title = $theme_data['Title'];
+ $name = $theme_data['Name'];
+ $title = $theme_data['Title'];
$description = wptexturize($theme_data['Description']);
- $version = $theme_data['Version'];
- $author = $theme_data['Author'];
- $template = $theme_data['Template'];
- $stylesheet = dirname($theme_file);
+ $version = $theme_data['Version'];
+ $author = $theme_data['Author'];
+ $template = $theme_data['Template'];
+ $stylesheet = dirname($theme_file);
- foreach (array('png', 'gif', 'jpg', 'jpeg') as $ext) {
+ foreach ( array('png', 'gif', 'jpg', 'jpeg') as $ext ) {
if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) {
$screenshot = "screenshot.$ext";
break;
@@ -158,24 +174,28 @@ function get_themes() {
}
if ( empty($template) ) {
- if ( file_exists(dirname("$theme_root/$theme_file/index.php")) ) {
+ if ( file_exists(dirname("$theme_root/$theme_file/index.php")) )
$template = dirname($theme_file);
- } else {
+ else
continue;
- }
}
$template = trim($template);
if ( !file_exists("$theme_root/$template/index.php") ) {
- $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'));
- continue;
+ $parent_dir = dirname(dirname($theme_file));
+ if ( file_exists("$theme_root/$parent_dir/$template/index.php") ) {
+ $template = "$parent_dir/$template";
+ } else {
+ $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'));
+ continue;
+ }
}
$stylesheet_files = array();
$stylesheet_dir = @ dir("$theme_root/$stylesheet");
if ( $stylesheet_dir ) {
- while(($file = $stylesheet_dir->read()) !== false) {
+ while ( ($file = $stylesheet_dir->read()) !== false ) {
if ( !preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file) )
$stylesheet_files[] = "$theme_loc/$stylesheet/$file";
}
@@ -222,10 +242,10 @@ function get_themes() {
// Resolve theme dependencies.
$theme_names = array_keys($themes);
- foreach ($theme_names as $theme_name) {
+ foreach ( (array) $theme_names as $theme_name ) {
$themes[$theme_name]['Parent Theme'] = '';
if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) {
- foreach ($theme_names as $parent_theme_name) {
+ foreach ( (array) $theme_names as $parent_theme_name ) {
if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) {
$themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
break;
@@ -256,7 +276,7 @@ function get_current_theme() {
$current_theme = 'WordPress Default';
if ( $themes ) {
- foreach ($theme_names as $theme_name) {
+ foreach ( (array) $theme_names as $theme_name ) {
if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
$themes[$theme_name]['Template'] == $current_template ) {
$current_theme = $themes[$theme_name]['Name'];
@@ -300,7 +320,7 @@ function get_category_template() {
$template = '';
if ( file_exists(TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php') )
$template = TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php';
- else if ( file_exists(TEMPLATEPATH . "/category.php") )
+ elseif ( file_exists(TEMPLATEPATH . "/category.php") )
$template = TEMPLATEPATH . "/category.php";
return apply_filters('category_template', $template);
@@ -315,7 +335,7 @@ function get_home_template() {
if ( file_exists(TEMPLATEPATH . "/home.php") )
$template = TEMPLATEPATH . "/home.php";
- else if ( file_exists(TEMPLATEPATH . "/index.php") )
+ elseif ( file_exists(TEMPLATEPATH . "/index.php") )
$template = TEMPLATEPATH . "/index.php";
return apply_filters('home_template', $template);
@@ -330,9 +350,9 @@ function get_page_template() {
if ( 'default' == $template )
$template = '';
- if ( ! empty($template) && file_exists(TEMPLATEPATH . "/$template") )
+ if ( !empty($template) && file_exists(TEMPLATEPATH . "/$template") )
$template = TEMPLATEPATH . "/$template";
- else if ( file_exists(TEMPLATEPATH . "/page.php") )
+ elseif ( file_exists(TEMPLATEPATH . "/page.php") )
$template = TEMPLATEPATH . "/page.php";
else
$template = '';
@@ -374,14 +394,13 @@ function get_comments_popup_template() {
return apply_filters('comments_popup_template', $template);
}
-function load_template($file) {
+function load_template($_template_file) {
global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query,
$wp_rewrite, $wpdb, $wp_version, $wp, $id, $comment;
- if( is_array( $wp_query->query_vars ) )
- extract($wp_query->query_vars);
+ extract($wp_query->query_vars, EXTR_SKIP);
- require_once($file);
+ require_once($_template_file);
}
function locale_stylesheet() {
@@ -396,14 +415,14 @@ function validate_current_theme() {
if ( defined('WP_INSTALLING') )
return true;
- if ((get_template() != 'default') && (!file_exists(get_template_directory() . '/index.php'))) {
+ if ( get_template() != 'default' && !file_exists(get_template_directory() . '/index.php') ) {
update_option('template', 'default');
update_option('stylesheet', 'default');
do_action('switch_theme', 'Default');
return false;
}
- if ((get_stylesheet() != 'default') && (!file_exists(get_template_directory() . '/style.css'))) {
+ if ( get_stylesheet() != 'default' && !file_exists(get_template_directory() . '/style.css') ) {
update_option('template', 'default');
update_option('stylesheet', 'default');
do_action('switch_theme', 'Default');
@@ -413,4 +432,32 @@ function validate_current_theme() {
return true;
}
+function get_theme_mod($name, $default = false) {
+ $theme = get_current_theme();
+
+ $mods = get_option("mods_$theme");
+
+ if ( isset($mods[$name]) )
+ return $mods[$name];
+
+ return sprintf($default, get_template_directory_uri());
+}
+
+function set_theme_mod($name, $value) {
+ $theme = get_current_theme();
+
+ $mods = get_option("mods_$theme");
+
+ $mods[$name] = $value;
+
+ update_option("mods_$theme", $mods);
+ wp_cache_delete("mods_$theme", 'options');
+}
+
+function remove_theme_mods() {
+ $theme = get_current_theme();
+
+ delete_option("mods_$theme");
+}
+
?>
diff --git a/wp-includes/user.php b/wp-includes/user.php
index d5828bb..e1f9770 100644
--- a/wp-includes/user.php
+++ b/wp-includes/user.php
@@ -152,7 +152,7 @@ function setup_userdata($user_id = '') {
if ( '' == $user_id )
$user = wp_get_current_user();
- else
+ else
$user = new WP_User($user_id);
if ( 0 == $user->ID )
diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php
index f543099..e1fe61e 100644
--- a/wp-includes/wp-db.php
+++ b/wp-includes/wp-db.php
@@ -97,7 +97,7 @@ class wpdb {
function print_error($str = '') {
global $EZSQL_ERROR;
if (!$str) $str = mysql_error();
- $EZSQL_ERROR[] =
+ $EZSQL_ERROR[] =
array ('query' => $this->last_query, 'error_str' => $str);
$str = htmlspecialchars($str, ENT_QUOTES);
diff --git a/wp-includes/wpmu-functions.php b/wp-includes/wpmu-functions.php
index ec9746c..e4040c5 100644
--- a/wp-includes/wpmu-functions.php
+++ b/wp-includes/wpmu-functions.php
@@ -1387,4 +1387,19 @@ function get_current_site() {
return $current_site;
}
+function cat_is_ancestor_of($cat1, $cat2) {
+ if ( is_int($cat1) )
+ $cat1 = & get_category($cat1);
+ if ( is_int($cat2) )
+ $cat2 = & get_category($cat2);
+
+ if ( !$cat1->cat_ID || !$cat2->category_parent )
+ return false;
+
+ if ( $cat2->category_parent == $cat1->cat_ID )
+ return true;
+
+ return cat_is_ancestor_of($cat1, get_category($cat2->parent_category));
+}
+
?>