summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wp-admin/admin-functions.php4
-rw-r--r--wp-admin/categories.php6
-rw-r--r--wp-admin/comment.php16
-rw-r--r--wp-admin/edit-page-form.php3
-rw-r--r--wp-admin/import/blogger.php6
-rw-r--r--wp-admin/inline-uploading.php6
-rw-r--r--wp-admin/link.php10
-rw-r--r--wp-admin/moderation.php2
-rw-r--r--wp-admin/options-discussion.php3
-rw-r--r--wp-admin/page.php8
-rw-r--r--wp-admin/plugin-editor.php4
-rw-r--r--wp-admin/plugins.php4
-rw-r--r--wp-admin/post.php8
-rw-r--r--wp-admin/templates.php6
-rw-r--r--wp-admin/theme-editor.php4
-rw-r--r--wp-admin/themes.php68
-rw-r--r--wp-admin/user-edit.php13
-rw-r--r--wp-admin/users.php12
-rw-r--r--wp-content/mu-plugins/misc.php5
-rw-r--r--wp-content/themes/default/functions.php2
-rw-r--r--wp-includes/cron.php7
-rw-r--r--wp-includes/functions.php97
-rw-r--r--wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js30
-rw-r--r--wp-includes/js/tinymce/plugins/autosave/readme.txt1
-rw-r--r--wp-includes/js/tinymce/plugins/directionality/editor_plugin.js161
-rw-r--r--wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin_src.js0
-rw-r--r--wp-includes/js/tinymce/plugins/inlinepopups/readme.txt0
-rw-r--r--wp-includes/js/tinymce/plugins/paste/editor_plugin.js388
-rw-r--r--wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js19
-rw-r--r--wp-includes/js/tinymce/themes/advanced/editor_template.js44
-rw-r--r--wp-includes/js/tinymce/tiny_mce.js510
-rw-r--r--wp-includes/js/tinymce/tiny_mce_config.php5
-rw-r--r--wp-includes/js/tinymce/tiny_mce_popup.js9
-rw-r--r--wp-includes/pluggable.php27
-rw-r--r--wp-includes/rss.php1619
-rw-r--r--wp-includes/script-loader.php6
-rw-r--r--wp-login.php5
-rw-r--r--wp-trackback.php2
-rw-r--r--xmlrpc.php10
39 files changed, 1710 insertions, 1420 deletions
diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php
index 3cae3ae..038eb8c 100644
--- a/wp-admin/admin-functions.php
+++ b/wp-admin/admin-functions.php
@@ -412,8 +412,8 @@ function edit_user($user_id = 0) {
if (isset ($_POST['pass2']))
$pass2 = $_POST['pass2'];
- if (isset ($_POST['role'])) {
- if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users'))
+ if (isset ($_POST['role']) && current_user_can('edit_users')) {
+ if ($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users'))
$user->role = $_POST['role'];
}
diff --git a/wp-admin/categories.php b/wp-admin/categories.php
index 3e33f0c..7c66c6d 100644
--- a/wp-admin/categories.php
+++ b/wp-admin/categories.php
@@ -31,7 +31,7 @@ case 'addcat':
wp_insert_category($_POST);
- header('Location: categories.php?message=1#addcat');
+ wp_redirect('categories.php?message=1#addcat');
break;
case 'delete':
@@ -52,7 +52,7 @@ case 'delete':
wp_delete_category($cat_ID);
- header('Location: categories.php?message=2');
+ wp_redirect('categories.php?message=2');
break;
@@ -74,7 +74,7 @@ case 'editedcat':
wp_update_category($_POST);
- header('Location: categories.php?message=3');
+ wp_redirect('categories.php?message=3');
break;
default:
diff --git a/wp-admin/comment.php b/wp-admin/comment.php
index 9adcba6..52ec008 100644
--- a/wp-admin/comment.php
+++ b/wp-admin/comment.php
@@ -118,9 +118,9 @@ case 'deletecomment':
wp_delete_comment($comment->comment_ID);
if ((wp_get_referer() != '') && (false == $noredir)) {
- header('Location: ' . wp_get_referer());
+ wp_redirect(wp_get_referer());
} else {
- header('Location: '. get_settings('siteurl') .'/wp-admin/edit-comments.php');
+ wp_redirect(get_settings('siteurl') .'/wp-admin/edit-comments.php');
}
exit();
break;
@@ -145,9 +145,9 @@ case 'unapprovecomment':
wp_set_comment_status($comment->comment_ID, "hold");
if ((wp_get_referer() != "") && (false == $noredir)) {
- header('Location: ' . wp_get_referer());
+ wp_redirect(wp_get_referer());
} else {
- header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
+ wp_redirect(get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
}
exit();
break;
@@ -176,9 +176,9 @@ case 'approvecomment':
if ((wp_get_referer() != "") && (false == $noredir)) {
- header('Location: ' . wp_get_referer());
+ wp_redirect(wp_get_referer());
} else {
- header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
+ wp_redirect(get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
}
exit();
break;
@@ -194,9 +194,9 @@ case 'editedcomment':
$referredby = $_POST['referredby'];
if (!empty($referredby)) {
- header('Location: ' . $referredby);
+ wp_redirect($referredby);
} else {
- header ("Location: edit.php?p=$comment_post_ID&c=1#comments");
+ wp_redirect("edit.php?p=$comment_post_ID&c=1#comments");
}
break;
diff --git a/wp-admin/edit-page-form.php b/wp-admin/edit-page-form.php
index 14d5fa8..de6dd62 100644
--- a/wp-admin/edit-page-form.php
+++ b/wp-admin/edit-page-form.php
@@ -184,8 +184,9 @@ list_meta($metadata);
</div>
<?php if ('edit' == $action) :
+ $delete_nonce = wp_create_nonce( 'delete-page_' . $post_ID );
if ( current_user_can('delete_page', $post->ID) ) ?>
- <input name="deletepost" class="delete" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this page') ?>" <?php echo "onclick=\"return confirm('" . sprintf(__("You are about to delete this page \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), js_escape($post->post_title) ) . "')\""; ?> />
+ <input name="deletepost" class="button" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this page') ?>" <?php echo "onclick=\"if ( confirm('" . sprintf(__("You are about to delete this page \'%s\'\\n \'Cancel\' to stop, \'OK\' to delete."), js_escape($post->post_title) ) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}return false;\""; ?> />
<?php endif; ?>
</form>
diff --git a/wp-admin/import/blogger.php b/wp-admin/import/blogger.php
index 8de766c..f79a164 100644
--- a/wp-admin/import/blogger.php
+++ b/wp-admin/import/blogger.php
@@ -30,7 +30,7 @@ class Blogger_Import {
// Deletes saved data and redirect.
function restart() {
delete_option('import-blogger');
- header("Location: admin.php?import=blogger");
+ wp_redirect("admin.php?import=blogger");
die();
}
@@ -218,7 +218,7 @@ class Blogger_Import {
// Redirects to next step
function do_next_step() {
- header("Location: admin.php?import=blogger&noheader=true&blog={$_GET['blog']}");
+ wp_redirect("admin.php?import=blogger&noheader=true&blog={$_GET['blog']}");
die();
}
@@ -278,7 +278,7 @@ class Blogger_Import {
);
}
update_option('import-blogger', $this->import);
- header("Location: admin.php?import=blogger&noheader=true&step=1");
+ wp_redirect("admin.php?import=blogger&noheader=true&step=1");
}
die();
}
diff --git a/wp-admin/inline-uploading.php b/wp-admin/inline-uploading.php
index 601f530..ca9f945 100644
--- a/wp-admin/inline-uploading.php
+++ b/wp-admin/inline-uploading.php
@@ -41,7 +41,7 @@ if ( !current_user_can('edit_post', (int) $attachment) )
wp_delete_attachment($attachment);
-header("Location: " . basename(__FILE__) ."?post=$post&all=$all&action=view&start=$start");
+wp_redirect(basename(__FILE__) ."?post=$post&all=$all&action=view&start=$start");
die;
case 'save':
@@ -105,7 +105,7 @@ if ( preg_match('!^image/!', $attachment['post_mime_type']) ) {
add_post_meta($id, '_wp_attachment_metadata', array());
}
-header("Location: " . basename(__FILE__) . "?post=$post&all=$all&action=view&start=0");
+wp_redirect(basename(__FILE__) . "?post=$post&all=$all&action=view&start=0");
die();
case 'upload':
@@ -144,7 +144,7 @@ if ( '' == $sort )
$attachments = $wpdb->get_results("SELECT ID, post_date, post_title, post_mime_type, guid FROM $wpdb->posts WHERE post_type = 'attachment' $and_type $and_post $and_user ORDER BY $sort LIMIT $start, $double", ARRAY_A);
if ( count($attachments) == 0 ) {
- header("Location: " . basename(__FILE__) ."?post=$post&action=upload" );
+ wp_redirect( basename(__FILE__) ."?post=$post&action=upload" );
die;
} elseif ( count($attachments) > $num ) {
$next = $start + count($attachments) - $num;
diff --git a/wp-admin/link.php b/wp-admin/link.php
index ae61da3..967a02c 100644
--- a/wp-admin/link.php
+++ b/wp-admin/link.php
@@ -37,7 +37,7 @@ switch ($action) {
//for each link id (in $linkcheck[]) change category to selected value
if (count($linkcheck) == 0) {
- header('Location: '.$this_file);
+ wp_redirect($this_file);
exit;
}
@@ -49,7 +49,7 @@ switch ($action) {
$deleted++;
}
- header("Location: $this_file?deleted=$deleted");
+ wp_redirect("$this_file?deleted=$deleted");
break;
case 'move' :
@@ -61,14 +61,14 @@ switch ($action) {
//for each link id (in $linkcheck[]) change category to selected value
if (count($linkcheck) == 0) {
- header('Location: '.$this_file);
+ wp_redirect($this_file);
exit;
}
$all_links = join(',', $linkcheck);
// should now have an array of links we can change
//$q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
- header('Location: '.$this_file);
+ wp_redirect($this_file);
break;
case 'add' :
@@ -76,7 +76,7 @@ switch ($action) {
add_link();
- header('Location: '.wp_get_referer().'?added=true');
+ wp_redirect(wp_get_referer().'?added=true');
break;
case 'save' :
diff --git a/wp-admin/moderation.php b/wp-admin/moderation.php
index 5839e6f..530a99e 100644
--- a/wp-admin/moderation.php
+++ b/wp-admin/moderation.php
@@ -70,7 +70,7 @@ case 'update':
}
$file = basename(__FILE__);
- header("Location: $file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved&spam=$item_spam");
+ wp_redirect("$file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved&spam=$item_spam");
exit();
break;
diff --git a/wp-admin/options-discussion.php b/wp-admin/options-discussion.php
index 247c01f..c96b246 100644
--- a/wp-admin/options-discussion.php
+++ b/wp-admin/options-discussion.php
@@ -87,9 +87,6 @@ if ($action == 'retrospam') {
<p>
<textarea name="blacklist_keys" cols="60" rows="4" id="blacklist_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('blacklist_keys'); ?></textarea>
</p>
-<p><label for="open_proxy_check">
-<input name="open_proxy_check" type="checkbox" id="open_proxy_check" value="1" <?php checked('1', get_settings('open_proxy_check')); ?> />
-<?php _e('Blacklist comments from open and insecure proxies.') ?></label></p>
</fieldset>
<p class="submit">
<input type="hidden" name="action" value="update" />
diff --git a/wp-admin/page.php b/wp-admin/page.php
index 32fb2ae..16e2d9d 100644
--- a/wp-admin/page.php
+++ b/wp-admin/page.php
@@ -52,7 +52,7 @@ case 'post':
if ( isset($_POST['save']) )
$location = "page.php?action=edit&post=$page_ID";
- header("Location: $location");
+ wp_redirect($location);
exit();
break;
@@ -120,7 +120,7 @@ case 'editpost':
} else {
$location = 'page-new.php';
}
- header ('Location: ' . $location); // Send user on their way while we keep working
+ wp_redirect($location); // Send user on their way while we keep working
exit();
break;
@@ -146,12 +146,12 @@ case 'delete':
if (strstr($sendback, 'page.php')) $sendback = get_settings('siteurl') .'/wp-admin/page.php';
elseif (strstr($sendback, 'attachments.php')) $sendback = get_settings('siteurl') .'/wp-admin/attachments.php';
$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
- header ('Location: ' . $sendback);
+ wp_redirect($sendback);
exit();
break;
default:
- header('Location: edit-pages.php');
+ wp_redirect('edit-pages.php');
exit();
break;
} // end switch
diff --git a/wp-admin/plugin-editor.php b/wp-admin/plugin-editor.php
index 56bab5a..4c3c600 100644
--- a/wp-admin/plugin-editor.php
+++ b/wp-admin/plugin-editor.php
@@ -45,9 +45,9 @@ case 'update':
$f = fopen($real_file, 'w+');
fwrite($f, $newcontent);
fclose($f);
- header("Location: plugin-editor.php?file=$file&a=te");
+ wp_redirect("plugin-editor.php?file=$file&a=te");
} else {
- header("Location: plugin-editor.php?file=$file");
+ wp_redirect("plugin-editor.php?file=$file");
}
exit();
diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php
index e289e59..c5bef8b 100644
--- a/wp-admin/plugins.php
+++ b/wp-admin/plugins.php
@@ -19,14 +19,14 @@ if ( isset($_GET['action']) ) {
include(ABSPATH . 'wp-content/plugins/' . trim( $_GET['plugin'] ));
do_action('activate_' . trim( $_GET['plugin'] ));
}
- header('Location: plugins.php?activate=true');
+ wp_redirect('plugins.php?activate=true');
} else if ('deactivate' == $_GET['action']) {
check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
$current = get_settings('active_plugins');
array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
update_option('active_plugins', $current);
do_action('deactivate_' . trim( $_GET['plugin'] ));
- header('Location: plugins.php?deactivate=true');
+ wp_redirect('plugins.php?deactivate=true');
}
exit;
}
diff --git a/wp-admin/post.php b/wp-admin/post.php
index d603913..7f3c2ab 100644
--- a/wp-admin/post.php
+++ b/wp-admin/post.php
@@ -52,7 +52,7 @@ case 'post':
if ( isset($_POST['save']) )
$location = "post.php?action=edit&post=$post_ID";
- header("Location: $location");
+ wp_redirect($location);
exit();
break;
@@ -123,7 +123,7 @@ case 'editpost':
$location = 'post-new.php';
}
- header ('Location: ' . $location); // Send user on their way while we keep working
+ wp_redirect($location); // Send user on their way while we keep working
exit();
break;
@@ -149,12 +149,12 @@ case 'delete':
if (strstr($sendback, 'post.php')) $sendback = get_settings('siteurl') .'/wp-admin/post-new.php';
elseif (strstr($sendback, 'attachments.php')) $sendback = get_settings('siteurl') .'/wp-admin/attachments.php';
$sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
- header ('Location: ' . $sendback);
+ wp_redirect($sendback);
exit();
break;
default:
- header('Location: edit.php');
+ wp_redirect('edit.php');
exit();
break;
} // end switch
diff --git a/wp-admin/templates.php b/wp-admin/templates.php
index c22d56a..ab5f1c1 100644
--- a/wp-admin/templates.php
+++ b/wp-admin/templates.php
@@ -48,12 +48,12 @@ case 'update':
if ( $f ) {
fwrite($f, $newcontent);
fclose($f);
- header("Location: templates.php?file=$file&a=te");
+ wp_redirect("templates.php?file=$file&a=te");
} else {
- header("Location: templates.php?file=$file&a=err");
+ wp_redirect("templates.php?file=$file&a=err");
}
} else {
- header("Location: templates.php?file=$file&a=err");
+ wp_redirect("templates.php?file=$file&a=err");
}
exit();
diff --git a/wp-admin/theme-editor.php b/wp-admin/theme-editor.php
index 10fb8fc..3213cc4 100644
--- a/wp-admin/theme-editor.php
+++ b/wp-admin/theme-editor.php
@@ -59,9 +59,9 @@ case 'update':
$f = fopen($real_file, 'w+');
fwrite($f, $newcontent);
fclose($f);
- header("Location: theme-editor.php?file=$file&theme=$theme&a=te");
+ wp_redirect("theme-editor.php?file=$file&theme=$theme&a=te");
} else {
- header("Location: theme-editor.php?file=$file&theme=$theme");
+ wp_redirect("theme-editor.php?file=$file&theme=$theme");
}
exit();
diff --git a/wp-admin/themes.php b/wp-admin/themes.php
index f57bd1b..bc8ecbe 100644
--- a/wp-admin/themes.php
+++ b/wp-admin/themes.php
@@ -1,35 +1,6 @@
<?php
require_once('admin.php');
-if ( isset($_GET['action']) ) {
- check_admin_referer('switch-theme_' . $_GET['template']);
-
- if ('activate' == $_GET['action']) {
- if ( isset($_GET['template']) )
- update_option('template', $_GET['template']);
-
- if ( isset($_GET['stylesheet']) )
- update_option('stylesheet', $_GET['stylesheet']);
-
- do_action('switch_theme', get_current_theme());
-
- header('Location: themes.php?activated=true');
- exit;
- }
-}
-
-$title = __('Manage Themes');
-$parent_file = 'themes.php';
-require_once('admin-header.php');
-?>
-
-<?php if ( ! validate_current_theme() ) : ?>
-<div id="message1" class="updated fade"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div>
-<?php elseif ( isset($_GET['activated']) ) : ?>
-<div id="message2" class="updated fade"><p><?php printf(__('New theme activated. <a href="%s">View site &raquo;</a>'), get_bloginfo('home') . '/'); ?></p></div>
-<?php endif; ?>
-
-<?php
$themes = get_themes();
$ct = current_theme_info();
$allowed_themes = get_site_option( "allowed_themes" );
@@ -51,8 +22,47 @@ while( list( $key, $val ) = each( $themes ) ) {
}
}
reset( $themes );
+
+if ( isset($_GET['action']) ) {
+ check_admin_referer('switch-theme_' . $_GET['template']);
+
+ if ('activate' == $_GET['action']) {
+ $found = false;
+ while( list( $key, $details ) = each( $themes ) ) {
+ if( $details[ 'Template' ] == $_GET['template'] && $details[ 'Stylesheet' ] == $_GET['stylesheet'] ) {
+ $found = true;
+ break;
+ }
+ }
+ if( $found == true ) {
+ if ( isset($_GET['template']) )
+ update_option('template', $_GET['template']);
+
+ if ( isset($_GET['stylesheet']) )
+ update_option('stylesheet', $_GET['stylesheet']);
+
+ do_action('switch_theme', get_current_theme());
+
+ wp_redirect('themes.php?activated=true');
+ } else {
+ wp_redirect('themes.php');
+ }
+ exit;
+ }
+}
+
+$title = __('Manage Themes');
+$parent_file = 'themes.php';
+require_once('admin-header.php');
?>
+<?php if ( ! validate_current_theme() ) : ?>
+<div id="message1" class="updated fade"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div>
+<?php elseif ( isset($_GET['activated']) ) : ?>
+<div id="message2" class="updated fade"><p><?php printf(__('New theme activated. <a href="%s">View site &raquo;</a>'), get_bloginfo('home') . '/'); ?></p></div>
+<?php endif; ?>
+
+
<div class="wrap">
<h2><?php _e('Current Theme'); ?></h2>
<div id="currenttheme">
diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php
index 6b0f052..26376b7 100644
--- a/wp-admin/user-edit.php
+++ b/wp-admin/user-edit.php
@@ -25,11 +25,9 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
}
$wp_http_referer = remove_query_arg(array('update', 'delete_count'), stripslashes($wp_http_referer));
-$errors = array();
-
// Only allow site admins to edit every user.
-if( is_site_admin() == false )
- if( $user_id != $current_user->ID ) $errors = new WP_Error('head', __('You do not have permission to edit this user.'));
+if ( !is_site_admin() && ($user_id != $current_user->ID) )
+ $errors = new WP_Error('head', __('You do not have permission to edit this user.'));
switch ($action) {
case 'switchposts':
@@ -46,13 +44,14 @@ check_admin_referer('update-user_' . $user_id);
if ( !current_user_can('edit_user', $user_id) )
$errors = new WP_Error('head', __('You do not have permission to edit this user.'));
-else
- if( isset( $errors ) == false ) $errors = edit_user($user_id);
+
+if ( !isset($errors) )
+ $errors = edit_user($user_id);
if( !is_wp_error( $errors ) ) {
$redirect = "user-edit.php?user_id=$user_id&updated=true";
$redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
- header("Location: $redirect");
+ wp_redirect($redirect);
exit;
}
diff --git a/wp-admin/users.php b/wp-admin/users.php
index 2ed85bf..3c75395 100644
--- a/wp-admin/users.php
+++ b/wp-admin/users.php
@@ -124,7 +124,7 @@ case 'promote':
check_admin_referer('bulk-users');
if (empty($_POST['users'])) {
- header('Location: ' . $redirect);
+ wp_redirect($redirect);
}
if ( !current_user_can('edit_users') )
@@ -145,7 +145,7 @@ case 'promote':
$user->set_role($_POST['new_role']);
}
- header('Location: ' . add_query_arg('update', $update, $redirect));
+ wp_redirect(add_query_arg('update', $update, $redirect));
break;
@@ -154,7 +154,7 @@ case 'dodelete':
check_admin_referer('delete-users');
if ( empty($_POST['users']) ) {
- header('Location: ' . $redirect);
+ wp_redirect($redirect);
}
if ( !current_user_can('delete_users') )
@@ -185,7 +185,7 @@ case 'dodelete':
$redirect = add_query_arg('delete_count', $delete_count, $redirect);
- header('Location: ' . add_query_arg('update', $update, $redirect));
+ wp_redirect(add_query_arg('update', $update, $redirect));
break;
@@ -194,7 +194,7 @@ case 'delete':
check_admin_referer('bulk-users');
if ( empty($_POST['users']) )
- header('Location: ' . $redirect);
+ wp_redirect($redirect);
if ( !current_user_can('delete_users') )
$errors = new WP_Error('edit_users', __('You can&#8217;t delete users.'));
@@ -332,7 +332,7 @@ case 'adduser':
else {
$new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_POST['user_login']), true));
$redirect = add_query_arg('usersearch', $new_user_login, $redirect);
- header('Location: ' . add_query_arg('update', $update, $redirect) . '#user-' . $user_id);
+ wp_redirect(add_query_arg('update', $update, $redirect) . '#user-' . $user_id);
die();
}
diff --git a/wp-content/mu-plugins/misc.php b/wp-content/mu-plugins/misc.php
index e02818d..a67c379 100644
--- a/wp-content/mu-plugins/misc.php
+++ b/wp-content/mu-plugins/misc.php
@@ -1,5 +1,10 @@
<?php
+function kill_proxy_check( $option ) {
+ return 0;
+}
+add_filter('option_open_proxy_check', 'kill_proxy_check');
+
function graceful_fail( $message ) {
die('
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
diff --git a/wp-content/themes/default/functions.php b/wp-content/themes/default/functions.php
index 5f825ff..929a7cd 100644
--- a/wp-content/themes/default/functions.php
+++ b/wp-content/themes/default/functions.php
@@ -123,7 +123,7 @@ function kubrick_add_theme_page() {
}
}
//print_r($_REQUEST);
- header("Location: themes.php?page=functions.php&saved=true");
+ wp_redirect("themes.php?page=functions.php&saved=true");
die;
}
add_action('admin_head', 'kubrick_theme_page_head');
diff --git a/wp-includes/cron.php b/wp-includes/cron.php
index bab3bf6..2edb7ab 100644
--- a/wp-includes/cron.php
+++ b/wp-includes/cron.php
@@ -65,7 +65,12 @@ function wp_next_scheduled( $hook ) {
}
function spawn_cron() {
- $keys = array_keys( get_option( 'cron' ) );
+ $crons = get_option( 'cron' );
+
+ if ( !is_array($crons) )
+ return;
+
+ $keys = array_keys( $crons );
if ( array_shift( $keys ) > time() )
return;
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index 63416a9..91d3379 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -809,7 +809,8 @@ function do_feed_atom() {
function do_robots() {
global $current_blog;
- do_action('do_robots');
+ do_action('do_robotstxt');
+
if ( '0' == $current_blog->public ) {
echo "User-agent: *\n";
echo "Disallow: /\n";
@@ -1043,4 +1044,98 @@ function wp_proxy_check($ipnum) {
return false;
}
+function wp_explain_nonce($action) {
+ if ( $action !== -1 && preg_match('/([a-z]+)-([a-z]+)(_(.+))?/', $action, $matches) ) {
+ $verb = $matches[1];
+ $noun = $matches[2];
+
+ $trans = array();
+ $trans['update']['attachment'] = array(__('Are you sure you want to edit this attachment: &quot;%s&quot;?'), 'get_the_title');
+
+ $trans['add']['category'] = array(__('Are you sure you want to add this category?'), false);
+ $trans['delete']['category'] = array(__('Are you sure you want to delete this category: &quot;%s&quot;?'), 'get_catname');
+ $trans['update']['category'] = array(__('Are you sure you want to edit this category: &quot;%s&quot;?'), 'get_catname');
+
+ $trans['delete']['comment'] = array(__('Are you sure you want to delete this comment: &quot;%s&quot;?'), 'use_id');
+ $trans['unapprove']['comment'] = array(__('Are you sure you want to unapprove this comment: &quot;%s&quot;?'), 'use_id');
+ $trans['approve']['comment'] = array(__('Are you sure you want to approve this comment: &quot;%s&quot;?'), 'use_id');
+ $trans['update']['comment'] = array(__('Are you sure you want to edit this comment: &quot;%s&quot;?'), 'use_id');
+ $trans['bulk']['comments'] = array(__('Are you sure you want to bulk modify comments?'), false);
+ $trans['moderate']['comments'] = array(__('Are you sure you want to moderate comments?'), false);
+
+ $trans['add']['bookmark'] = array(__('Are you sure you want to add this bookmark?'), false);
+ $trans['delete']['bookmark'] = array(__('Are you sure you want to delete this bookmark: &quot;%s&quot;?'), 'use_id');
+ $trans['update']['bookmark'] = array(__('Are you sure you want to edit this bookmark: &quot;%s&quot;?'), 'use_id');
+ $trans['bulk']['bookmarks'] = array(__('Are you sure you want to bulk modify bookmarks?'), false);
+
+ $trans['add']['page'] = array(__('Are you sure you want to add this page?'), false);
+ $trans['delete']['page'] = array(__('Are you sure you want to delete this page: &quot;%s&quot;?'), 'get_the_title');
+ $trans['update']['page'] = array(__('Are you sure you want to edit this page: &quot;%s&quot;?'), 'get_the_title');
+
+ $trans['edit']['plugin'] = array(__('Are you sure you want to edit this plugin file: &quot;%s&quot;?'), 'use_id');
+ $trans['activate']['plugin'] = array(__('Are you sure you want to activate this plugin: &quot;%s&quot;?'), 'use_id');
+ $trans['deactivate']['plugin'] = array(__('Are you sure you want to deactivate this plugin: &quot;%s&quot;?'), 'use_id');
+
+ $trans['add']['post'] = array(__('Are you sure you want to add this post?'), false);
+ $trans['delete']['post'] = array(__('Are you sure you want to delete this post: &quot;%s&quot;?'), 'get_the_title');
+ $trans['update']['post'] = array(__('Are you sure you want to edit this post: &quot;%s&quot;?'), 'get_the_title');
+
+ $trans['add']['user'] = array(__('Are you sure you want to add this user?'), false);
+ $trans['delete']['users'] = array(__('Are you sure you want to delete users?'), false);
+ $trans['bulk']['users'] = array(__('Are you sure you want to bulk modify users?'), false);
+ $trans['update']['user'] = array(__('Are you sure you want to edit this user: &quot;%s&quot;?'), 'get_author_name');
+ $trans['update']['profile'] = array(__('Are you sure you want to modify the profile for: &quot;%s&quot;?'), 'get_author_name');
+
+ $trans['update']['options'] = array(__('Are you sure you want to edit your settings?'), false);
+ $trans['update']['permalink'] = array(__('Are you sure you want to change your permalink structure to: %s?'), 'use_id');
+ $trans['edit']['file'] = array(__('Are you sure you want to edit this file: &quot;%s&quot;?'), 'use_id');
+ $trans['edit']['theme'] = array(__('Are you sure you want to edit this theme file: &quot;%s&quot;?'), 'use_id');
+ $trans['switch']['theme'] = array(__('Are you sure you want to switch to this theme: &quot;%s&quot;?'), 'use_id');
+
+ if ( isset($trans[$verb][$noun]) ) {
+ if ( !empty($trans[$verb][$noun][1]) ) {
+ $lookup = $trans[$verb][$noun][1];
+ $object = $matches[4];
+ if ( 'use_id' != $lookup )
+ $object = call_user_func($lookup, $object);
+ return sprintf($trans[$verb][$noun][0], $object);
+ } else {
+ return $trans[$verb][$noun][0];
+ }
+ }
+ }
+
+ return __('Are you sure you want to do this');
+}
+
+function wp_nonce_ays($action) {
+ global $pagenow, $menu, $submenu, $parent_file, $submenu_file;
+
+ $adminurl = get_settings('siteurl') . '/wp-admin';
+ if ( wp_get_referer() )
+ $adminurl = wp_get_referer();
+
+ $title = __('WordPress Confirmation');
+ require_once(ABSPATH . '/wp-admin/admin-header.php');
+ // Remove extra layer of slashes.
+ $_POST = stripslashes_deep($_POST );
+ if ( $_POST ) {
+ $q = http_build_query($_POST);
+ $q = explode( ini_get('arg_separator.output'), $q);
+ $html .= "\t<form method='post' action='$pagenow'>\n";
+ foreach ( (array) $q as $a ) {
+ $v = substr(strstr($a, '='), 1);
+ $k = substr($a, 0, -(strlen($v)+1));
+ $html .= "\t\t<input type='hidden' name='" . wp_specialchars( urldecode($k), 1 ) . "' value='" . wp_specialchars( urldecode($v), 1 ) . "' />\n";
+ }
+ $html .= "\t\t<input type='hidden' name='_wpnonce' value='" . wp_create_nonce($action) . "' />\n";
+ $html .= "\t\t<div id='message' class='confirm fade'>\n\t\t<p>" . wp_explain_nonce($action) . "</p>\n\t\t<p><a href='$adminurl'>" . __('No') . "</a> <input type='submit' value='" . __('Yes') . "' /></p>\n\t\t</div>\n\t</form>\n";
+ } else {
+ $html .= "\t<div id='message' class='confirm fade'>\n\t<p>" . wp_explain_nonce($action) . "</p>\n\t<p><a href='$adminurl'>" . __('No') . "</a> <a href='" . add_query_arg( '_wpnonce', wp_create_nonce($action), $_SERVER['REQUEST_URI'] ) . "'>" . __('Yes') . "</a></p>\n\t</div>\n";
+ }
+ $html .= "</body>\n</html>";
+ echo $html;
+ include_once(ABSPATH . '/wp-admin/admin-footer.php');
+}
+
?>
diff --git a/wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js
deleted file mode 100644
index 102d69b..0000000
--- a/wp-includes/js/tinymce/plugins/autosave/editor_plugin_src.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('autosave', 'en,sv,cs,he,no,hu,de,da,ru,ru_KOI8-R,ru_UTF-8,fi,cy,es,is,pl');
-
-function TinyMCE_autosave_getInfo() {
- return {
- longname : 'Auto save',
- author : 'Moxiecode Systems',
- authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html',
- version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
- };
-};
-
-function TinyMCE_autosave_beforeUnloadHandler() {
- var msg = tinyMCE.getLang("lang_autosave_unload_msg");
-
- var anyDirty = false;
- for (var n in tinyMCE.instances) {
- var inst = tinyMCE.instances[n];
- if (!tinyMCE.isInstance(inst))
- continue;
-
- if (inst.isDirty())
- return msg;
- }
-
- return;
-}
-
-window.onbeforeunload = TinyMCE_autosave_beforeUnloadHandler;
diff --git a/wp-includes/js/tinymce/plugins/autosave/readme.txt b/wp-includes/js/tinymce/plugins/autosave/readme.txt
deleted file mode 100644
index 4fdb78a..0000000
--- a/wp-includes/js/tinymce/plugins/autosave/readme.txt
+++ /dev/null
@@ -1 +0,0 @@
-Check the TinyMCE documentation for details on this plugin.
diff --git a/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js b/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
index c866b53..ad0fa87 100644
--- a/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
@@ -1,83 +1,92 @@
-/* Import plugin specific language pack */
-tinyMCE.importPluginLanguagePack('directionality', 'en,sv,fr_ca,zh_cn,cs,da,he,no,de,hu,ru,ru_KOI8-R,ru_UTF-8,es,cy,is,pl');
-
-function TinyMCE_directionality_getInfo() {
- return {
- longname : 'Directionality',
- author : 'Moxiecode Systems',
- authorurl : 'http://tinymce.moxiecode.com',
- infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html',
- version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
- };
-};
+/**
+ * $RCSfile: editor_plugin_src.js,v $
+ * $Revision: 1.16 $
+ * $Date: 2006/02/10 21:34:28 $
+ *
+ * @author Moxiecode
+ * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
+ */
-function TinyMCE_directionality_getControlHTML(control_name) {
- switch (control_name) {
- case "ltr":
- var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionLTR\');return false;';
- return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" onmousedown="return false;"><img id="{$editor_id}_ltr" src="{$pluginurl}/images/ltr.gif" title="{$lang_directionality_ltr_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>'
- + '<div class="zerosize"><input type="button" accesskey="." onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionLTR\',false);" /></div>';
-
- case "rtl":
- var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionRTL\');return false;';
- return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" onmousedown="return false;"><img id="{$editor_id}_rtl" src="{$pluginurl}/images/rtl.gif" title="{$lang_directionality_rtl_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>'
- + '<div class="zerosize"><input type="button" accesskey="," onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionRTL\',false);" /></div>';
- }
-
- return "";
-}
-
-function TinyMCE_directionality_execCommand(editor_id, element, command, user_interface, value) {
- // Handle commands
- switch (command) {
- case "mceDirectionLTR":
- var inst = tinyMCE.getInstanceById(editor_id);
- var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
-
- if (elm)
- elm.setAttribute("dir", "ltr");
-
- tinyMCE.triggerNodeChange(false);
+/* 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');
+
+var TinyMCE_DirectionalityPlugin = {
+ getInfo : function() {
+ return {
+ longname : 'Directionality',
+ author : 'Moxiecode Systems',
+ authorurl : 'http://tinymce.moxiecode.com',
+ infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html',
+ version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
+ };
+ },
+
+ getControlHTML : function(cn) {
+ switch (cn) {
+ case "ltr":
+ return tinyMCE.getButtonHTML(cn, 'lang_directionality_ltr_desc', '{$pluginurl}/images/ltr.gif', 'mceDirectionLTR');
+
+ case "rtl":
+ return tinyMCE.getButtonHTML(cn, 'lang_directionality_rtl_desc', '{$pluginurl}/images/rtl.gif', 'mceDirectionRTL');
+ }
+
+ return "";
+ },
+
+ execCommand : function(editor_id, element, command, user_interface, value) {
+ // Handle commands
+ switch (command) {
+ case "mceDirectionLTR":
+ var inst = tinyMCE.getInstanceById(editor_id);
+ var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
+
+ if (elm)
+ elm.setAttribute("dir", "ltr");
+
+ tinyMCE.triggerNodeChange(false);
+ return true;
+
+ case "mceDirectionRTL":
+ var inst = tinyMCE.getInstanceById(editor_id);
+ var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
+
+ if (elm)
+ elm.setAttribute("dir", "rtl");
+
+ tinyMCE.triggerNodeChange(false);
+ return true;
+ }
+
+ // Pass to next handler in chain
+ return false;
+ },
+
+ handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
+ function getAttrib(elm, name) {
+ return elm.getAttribute(name) ? elm.getAttribute(name) : "";
+ }
+
+ if (node == null)
+ return;
+
+ var elm = tinyMCE.getParentElement(node, "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
+ if (!elm) {
+ tinyMCE.switchClass(editor_id + '_ltr', 'mceButtonDisabled');
+ tinyMCE.switchClass(editor_id + '_rtl', 'mceButtonDisabled');
return true;
+ }
- case "mceDirectionRTL":
- var inst = tinyMCE.getInstanceById(editor_id);
- var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
-
- if (elm)
- elm.setAttribute("dir", "rtl");
-
- tinyMCE.triggerNodeChange(false);
- return true;
- }
+ tinyMCE.switchClass(editor_id + '_ltr', 'mceButtonNormal');
+ tinyMCE.switchClass(editor_id + '_rtl', 'mceButtonNormal');
- // Pass to next handler in chain
- return false;
-}
+ var dir = getAttrib(elm, "dir");
+ if (dir == "ltr" || dir == "")
+ tinyMCE.switchClass(editor_id + '_ltr', 'mceButtonSelected');
+ else
+ tinyMCE.switchClass(editor_id + '_rtl', 'mceButtonSelected');
-function TinyMCE_directionality_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
- function getAttrib(elm, name) {
- return elm.getAttribute(name) ? elm.getAttribute(name) : "";
+ return true;
}
+};
- tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonNormal', false);
- tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonNormal', false);
-
- if (node == null)
- return;
-
- var elm = tinyMCE.getParentElement(node, "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
- if (!elm) {
- tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonDisabled', true);
- tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonDisabled', true);
- return;
- }
-
- var dir = getAttrib(elm, "dir");
- if (dir == "ltr" || dir == "")
- tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonSelected', false);
- else
- tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonSelected', false);
-
- return true;
-}
+tinyMCE.addPlugin("directionality", TinyMCE_DirectionalityPlugin);
diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin_src.js
deleted file mode 100644
index e69de29..0000000
--- a/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin_src.js
+++ /dev/null
diff --git a/wp-includes/js/tinymce/plugins/inlinepopups/readme.txt b/wp-includes/js/tinymce/plugins/inlinepopups/readme.txt
deleted file mode 100644
index e69de29..0000000
--- a/wp-includes/js/tinymce/plugins/inlinepopups/readme.txt
+++ /dev/null
diff --git a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
index 916e29f..7a7b133 100644
--- a/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
@@ -1,388 +1,2 @@
-/**
- * $RCSfile: editor_plugin_src.js,v $
- * $Revision: 1.36 $
- * $Date: 2006/03/20 12:03:44 $
- *
- * @author Moxiecode
- * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
- */
+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);
-/* Import plugin specific language pack */
-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'; // 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)) {
- 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'; // 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);
- 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 && /^\s$/m.test(np.nodeValue)) {
- np = np.nextSibling;
- continue;
- }
-
- if (search == mdot) {
- if (np.nodeType == 1 && /^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/wordpress/editor_plugin.js b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
index e5067c0..733b4c2 100644
--- a/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
+++ b/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
@@ -379,22 +379,3 @@ tinyMCE.execCommand = function (command, user_interface, value) {
}
return re;
};
-
-tinyMCE.orgFixGeckoBaseHREFBug = tinyMCE.fixGeckoBaseHREFBug;
-tinyMCE.fixGeckoBaseHREFBug = function(m, e, h) {
- if ( tinyMCE.isGecko && m == 1 )
- h = h.replace(new RegExp('<((a|img|select|area|iframe|base|input|script|embed|object|link)\\s([^>]*\\s)?)(src|href)\\s*=', 'gi'), '<$1 x$4=');
- else
- h = tinyMCE.orgFixGeckoBaseHREFBug(m, e, h);
-
- return h;
-};
-
-tinyMCE.orgStoreAwayURLs = tinyMCE.storeAwayURLs;
-tinyMCE.storeAwayURLs = function(s) {
- // Remove all mce_src, mce_href and replace them with new ones
- s = s.replace(new RegExp('mce_(href|src)\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
- s = s.replace(new RegExp('<((a|img|select|area|iframe|base|input|script|embed|object|link)\\s([^>]*\\s)?)(src|href)\\s*=\\s*"([^"]*)"', 'gi'), '<$1 $4="$5" mce_$4="$5"');
-
- return s;
-};
diff --git a/wp-includes/js/tinymce/themes/advanced/editor_template.js b/wp-includes/js/tinymce/themes/advanced/editor_template.js
index 5a3e09c..052914e 100644
--- a/wp-includes/js/tinymce/themes/advanced/editor_template.js
+++ b/wp-includes/js/tinymce/themes/advanced/editor_template.js
@@ -1,7 +1,7 @@
/**
* $RCSfile: editor_template_src.js,v $
- * $Revision: 1.93 $
- * $Date: 2006/03/14 17:33:50 $
+ * $Revision: 1.96 $
+ * $Date: 2006/04/18 13:32:52 $
*
* @author Moxiecode
* @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
@@ -81,7 +81,13 @@ var TinyMCE_AdvancedTheme = {
['h3', '{$lang_theme_h3}'],
['h4', '{$lang_theme_h4}'],
['h5', '{$lang_theme_h5}'],
- ['h6', '{$lang_theme_h6}']
+ ['h6', '{$lang_theme_h6}'],
+ ['div', '{$lang_theme_div}'],
+ ['blockquote', '{$lang_theme_blockquote}'],
+ ['code', '{$lang_theme_code}'],
+ ['dt', '{$lang_theme_dt}'],
+ ['dd', '{$lang_theme_dd}'],
+ ['samp', '{$lang_theme_samp}']
];
html += '<option value="">{$lang_theme_block}</option>';
@@ -90,7 +96,7 @@ var TinyMCE_AdvancedTheme = {
for (var i=0; i<formats.length; i++) {
for (var x=0; x<lookup.length; x++) {
if (formats[i] == lookup[x][0])
- html += '<option value="<' + lookup[x][0] + '>">' + lookup[x][1] + '</option>';
+ html += '<option value="&lt;' + lookup[x][0] + '&gt;">' + lookup[x][1] + '</option>';
}
}
@@ -117,16 +123,16 @@ var TinyMCE_AdvancedTheme = {
return fontHTML;
case "fontsizeselect":
- return '<select id="{$editor_id}_fontSizeSelect" name="{$editor_id}_fontSizeSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontSize\',false,this.options[this.selectedIndex].value);" class="mceSelectList">\
- <option value="0">{$lang_theme_font_size}</option>\
- <option value="1">1 (8 pt)</option>\
- <option value="2">2 (10 pt)</option>\
- <option value="3">3 (12 pt)</option>\
- <option value="4">4 (14 pt)</option>\
- <option value="5">5 (18 pt)</option>\
- <option value="6">6 (24 pt)</option>\
- <option value="7">7 (36 pt)</option>\
- </select>';
+ return '<select id="{$editor_id}_fontSizeSelect" name="{$editor_id}_fontSizeSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontSize\',false,this.options[this.selectedIndex].value);" class="mceSelectList">'+
+ '<option value="0">{$lang_theme_font_size}</option>'+
+ '<option value="1">1 (8 pt)</option>'+
+ '<option value="2">2 (10 pt)</option>'+
+ '<option value="3">3 (12 pt)</option>'+
+ '<option value="4">4 (14 pt)</option>'+
+ '<option value="5">5 (18 pt)</option>'+
+ '<option value="6">6 (24 pt)</option>'+
+ '<option value="7">7 (36 pt)</option>'+
+ '</select>';
case "|":
case "separator":
@@ -458,7 +464,7 @@ var TinyMCE_AdvancedTheme = {
var deltaHeight = 0;
var resizing = tinyMCE.getParam("theme_advanced_resizing", false);
var path = tinyMCE.getParam("theme_advanced_path", true);
- var statusbarHTML = '<div id="{$editor_id}_path" class="mceStatusbarPathText" style="display: ' + (path ? "block" : "none") + '">&nbsp;</div><div id="{$editor_id}_resize" class="mceStatusbarResize" style="display: ' + (resizing ? "block" : "none") + '" onmousedown="tinyMCE.themes.advanced._setResizing(event,\'{$editor_id}\',true);"></div><br style="clear: both" />';
+ var statusbarHTML = '<div id="{$editor_id}_path" class="mceStatusbarPathText" style="display: ' + (path ? "block" : "none") + '">&#160;</div><div id="{$editor_id}_resize" class="mceStatusbarResize" style="display: ' + (resizing ? "block" : "none") + '" onmousedown="tinyMCE.themes.advanced._setResizing(event,\'{$editor_id}\',true);"></div><br style="clear: both" />';
var layoutManager = tinyMCE.getParam("theme_advanced_layout_manager", "SimpleLayout");
// Setup style select options -- MOVED UP FOR EXTERNAL TOOLBAR COMPATABILITY!
@@ -583,11 +589,7 @@ var TinyMCE_AdvancedTheme = {
for (var i = 0; i < containers.length; i++)
{
if (containers[i] == "mceEditor") //Exceptions for mceEditor and ...
- {
- template['html'] += '<tr><td align="center" class="mceEditor_border">\
- <span id="{$editor_id}"></span>\
- </td></tr>';
- }
+ template['html'] += '<tr><td align="center" class="mceEditor_border"><span id="{$editor_id}"></span></td></tr>';
else if (containers[i] == "mceElementpath" || containers[i] == "mceStatusbar") // ... mceElementpath:
{
var pathClass = "mceStatusbar";
@@ -814,7 +816,7 @@ var TinyMCE_AdvancedTheme = {
}
}
- pathElm.innerHTML = '<a href="#" accesskey="x"></a>' + tinyMCE.getLang('lang_theme_path') + ": " + html + '&nbsp;';
+ pathElm.innerHTML = '<a href="#" accesskey="x"></a>' + tinyMCE.getLang('lang_theme_path') + ": " + html + '&#160;';
}
// Reset old states
diff --git a/wp-includes/js/tinymce/tiny_mce.js b/wp-includes/js/tinymce/tiny_mce.js
index 9fbf19f..643aab4 100644
--- a/wp-includes/js/tinymce/tiny_mce.js
+++ b/wp-includes/js/tinymce/tiny_mce.js
@@ -3,13 +3,15 @@
function TinyMCE_Engine() {
this.majorVersion = "2";
- this.minorVersion = "0.5.1";
- this.releaseDate = "2006-03-22";
+ this.minorVersion = "0.6.1";
+ this.releaseDate = "2006-05-04";
this.instances = new Array();
this.switchClassCache = new Array();
this.windowArgs = new Array();
this.loadedFiles = new Array();
+ this.pendingFiles = new Array();
+ this.loadingIndex = 0;
this.configs = new Array();
this.currentConfig = 0;
this.eventHandlers = new Array();
@@ -127,7 +129,7 @@ TinyMCE_Engine.prototype = {
this._def("inline_styles", false);
this._def("convert_newlines_to_brs", false);
this._def("auto_reset_designmode", true);
- this._def("entities", "160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,34,quot,38,amp,60,lt,62,gt,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro", true);
+ this._def("entities", "39,#39,160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,34,quot,38,amp,60,lt,62,gt,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro", true);
this._def("entity_encoding", "named");
this._def("cleanup_callback", "");
this._def("add_unload_trigger", true);
@@ -159,6 +161,13 @@ TinyMCE_Engine.prototype = {
this._def("content_css", '');
this._def("fix_list_elements", false);
this._def("fix_table_elements", false);
+ this._def("strict_loading_mode", document.contentType == 'application/xhtml+xml');
+ this._def("hidden_tab_class", '');
+ this._def("display_tab_class", '');
+
+ // Force strict loading mode to false on non Gecko browsers
+ if (this.isMSIE && !this.isOpera)
+ this.settings.strict_loading_mode = false;
// Browser check IE
if (this.isMSIE && this.settings['browsers'].indexOf('msie') == -1)
@@ -198,9 +207,9 @@ 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|dir|fieldset|form|noscript|noframes|menu|isindex)$", "i");
+ 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.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);
- this.uniqueURL = 'http://tinymce.moxiecode.cp/mce_temp_url'; // Make unique URL non real URL
+ this.uniqueURL = 'javascript:TINYMCE_UNIQUEURL();'; // Make unique URL non real URL
this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>';
this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup');
@@ -287,6 +296,9 @@ TinyMCE_Engine.prototype = {
// Save away this config
settings['index'] = this.configs.length;
this.configs[this.configs.length] = settings;
+
+ // Start loading first one in chain
+ this.loadNextScript();
},
_addUnloadEvents : function() {
@@ -319,6 +331,8 @@ TinyMCE_Engine.prototype = {
// Use the previous plugin object base URL used when loading external plugins
p.baseURL = op ? op.baseURL : tinyMCE.baseURL + "/plugins/" + n;
this.plugins[n] = p;
+
+ this.loadNextScript();
},
setPluginBaseURL : function(n, u) {
@@ -343,6 +357,8 @@ TinyMCE_Engine.prototype = {
addTheme : function(n, t) {
this.themes[n] = t;
+
+ this.loadNextScript();
},
addMenu : function(n, m) {
@@ -354,21 +370,43 @@ TinyMCE_Engine.prototype = {
},
loadScript : function(url) {
- for (var i=0; i<this.loadedFiles.length; i++) {
+ var i;
+
+ for (i=0; i<this.loadedFiles.length; i++) {
if (this.loadedFiles[i] == url)
return;
}
- document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></script>');
+ if (tinyMCE.settings.strict_loading_mode)
+ this.pendingFiles[this.pendingFiles.length] = url;
+ else
+ document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></script>');
this.loadedFiles[this.loadedFiles.length] = url;
},
+ loadNextScript : function() {
+ var d = document, se;
+
+ if (!tinyMCE.settings.strict_loading_mode)
+ return;
+
+ if (this.loadingIndex < this.pendingFiles.length) {
+ se = d.createElementNS('http://www.w3.org/1999/xhtml', 'script');
+ se.setAttribute('language', 'javascript');
+ se.setAttribute('type', 'text/javascript');
+ se.setAttribute('src', this.pendingFiles[this.loadingIndex++]);
+
+ d.getElementsByTagName("head")[0].appendChild(se);
+ } else
+ this.loadingIndex = -1; // Done with loading
+ },
+
loadCSS : function(url) {
var ar = url.replace(/\s+/, '').split(',');
var lflen = 0, csslen = 0;
var skip = false;
- var x = 0, i = 0;
+ var x = 0, i = 0, nl, le;
for (x = 0,csslen = ar.length; x<csslen; x++) {
ignore_css = false;
@@ -383,7 +421,18 @@ TinyMCE_Engine.prototype = {
}
if (!skip) {
- document.write('<link href="' + ar[x] + '" rel="stylesheet" type="text/css" />');
+ if (tinyMCE.settings.strict_loading_mode) {
+ nl = document.getElementsByTagName("head");
+
+ le = document.createElement('link');
+ le.setAttribute('href', ar[x]);
+ le.setAttribute('rel', 'stylesheet');
+ le.setAttribute('type', 'text/css');
+
+ nl[0].appendChild(le);
+ } else
+ document.write('<link href="' + ar[x] + '" rel="stylesheet" type="text/css" />');
+
this.loadedFiles[this.loadedFiles.length] = ar[x];
}
}
@@ -658,7 +707,7 @@ TinyMCE_Engine.prototype = {
}
iframe.setAttribute("id", id);
- iframe.setAttribute("className", "mceEditorIframe");
+ iframe.setAttribute("class", "mceEditorIframe");
iframe.setAttribute("border", "0");
iframe.setAttribute("frameBorder", "0");
iframe.setAttribute("marginWidth", "0");
@@ -668,6 +717,7 @@ TinyMCE_Engine.prototype = {
iframe.setAttribute("width", aw);
iframe.setAttribute("height", ah);
iframe.setAttribute("allowtransparency", "true");
+ iframe.className = 'mceEditorIframe';
if (tinyMCE.settings["auto_resize"])
iframe.setAttribute("scrolling", "no");
@@ -679,6 +729,10 @@ TinyMCE_Engine.prototype = {
iframe.style.width = aw;
iframe.style.height = ah;
+ // Ugly hack for Gecko problem in strict mode
+ if (tinyMCE.settings.strict_loading_mode)
+ iframe.style.marginBottom = '-5px';
+
// MSIE 5.0 issue
if (tinyMCE.isMSIE && !tinyMCE.isOpera)
replace_element.outerHTML = iframe.outerHTML;
@@ -697,6 +751,14 @@ TinyMCE_Engine.prototype = {
var head = doc.getElementsByTagName('head').item(0);
var content = inst.startContent;
+ // HTML values get XML encoded in strict mode
+ if (tinyMCE.settings.strict_loading_mode) {
+ content = content.replace(/&lt;/g, '<');
+ content = content.replace(/&gt;/g, '>');
+ content = content.replace(/&quot;/g, '"');
+ content = content.replace(/&amp;/g, '&');
+ }
+
inst.switchSettings();
// Not loaded correctly hit it again, Mozilla bug #997860
@@ -851,6 +913,22 @@ TinyMCE_Engine.prototype = {
inst.startContent = tinyMCE.trim(inst.getBody().innerHTML);
inst.undoRedo.add({ content : inst.startContent });
+ // Cleanup any mess left from storyAwayURLs
+ 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'), "");
+ }
+
+ return false;
+ });
+ }
+
+ // Cleanup any mess left from storyAwayURLs
+ tinyMCE._removeInternal(inst.getBody());
+
tinyMCE.selectedInstance = inst;
tinyMCE.triggerNodeChange(false, true);
},
@@ -868,6 +946,20 @@ TinyMCE_Engine.prototype = {
return s;
},
+ _removeInternal : function(n) {
+ 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'), "");
+ }
+
+ return false;
+ });
+ }
+ },
+
removeTinyMCEFormElements : function(form_obj) {
// Check if form is valid
if (typeof(form_obj) == "undefined" || form_obj == null)
@@ -922,7 +1014,23 @@ TinyMCE_Engine.prototype = {
if (tinyMCE.selectedInstance)
tinyMCE.selectedInstance.setBaseHREF(null);
- window.setTimeout("tinyMCE.selectedInstance.setBaseHREF(tinyMCE.settings['base_href']);", 1);
+ // 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) {
+ var ife = tinyMCE.selectedInstance.iframeElement;
+
+ /*if (ife.style.width.indexOf('%') != -1) {
+ ife._oldWidth = ife.width.height;
+ ife.style.width = ife.clientWidth;
+ }*/
+
+ if (ife.style.height.indexOf('%') != -1) {
+ ife._oldHeight = ife.style.height;
+ ife.style.height = ife.clientHeight;
+ }
+ }
+
+ window.setTimeout("tinyMCE.selectedInstance.setBaseHREF(tinyMCE.settings['base_href']);tinyMCE._resetIframeHeight();", 1);
return;
case "submit":
@@ -1241,6 +1349,12 @@ TinyMCE_Engine.prototype = {
},
onLoad : function() {
+ // 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")
return true;
@@ -1425,6 +1539,8 @@ TinyMCE_Engine.prototype = {
tinyMCELang[(key.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = ar[key];
}
+ this.loadNextScript();
+
// for (var key in ar)
// tinyMCELang[(key.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = "|" + ar[key] + "|";
},
@@ -1671,10 +1787,13 @@ TinyMCE_Engine.prototype = {
return className;
},
- handleVisualAid : function(el, deep, state, inst) {
+ handleVisualAid : function(el, deep, state, inst, skip_dispatch) {
if (!el)
return;
+ if (!skip_dispatch)
+ tinyMCE.dispatchCallback(inst, 'handle_visual_aid_callback', 'handleVisualAid', el, deep, state, inst);
+
var tableElement = null;
switch (el.nodeName) {
@@ -1713,7 +1832,7 @@ TinyMCE_Engine.prototype = {
if (deep && el.hasChildNodes()) {
for (var i=0; i<el.childNodes.length; i++)
- tinyMCE.handleVisualAid(el.childNodes[i], deep, state, inst);
+ tinyMCE.handleVisualAid(el.childNodes[i], deep, state, inst, true);
}
},
@@ -1751,35 +1870,54 @@ TinyMCE_Engine.prototype = {
*/
fixGeckoBaseHREFBug : function(m, e, h) {
- var nl, i;
+ var nl, i, a, n, xsrc, xhref, el;
if (tinyMCE.isGecko) {
if (m == 1) {
- h = h.replace(/\ssrc=/gi, " xsrc=");
- h = h.replace(/\shref=/gi, " xhref=");
+ h = h.replace(/\ssrc=/gi, " mce_tsrc=");
+ h = h.replace(/\shref=/gi, " mce_thref=");
return h;
} else {
- var el = new Array('a','img','select','area','iframe','base','input','script','embed','object','link');
+ el = new Array('a','img','select','area','iframe','base','input','script','embed','object','link');
- for (var a=0; a<el.length; a++) {
- var n = e.getElementsByTagName(el[a]);
+ for (a=0; a<el.length; a++) {
+ n = e.getElementsByTagName(el[a]);
for (i=0; i<n.length; i++) {
- var xsrc = tinyMCE.getAttrib(n[i], "xsrc");
- var xhref = tinyMCE.getAttrib(n[i], "xhref");
+ xsrc = tinyMCE.getAttrib(n[i], "mce_tsrc");
+ xhref = tinyMCE.getAttrib(n[i], "mce_thref");
if (xsrc != "") {
- n[i].src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc);
- n[i].removeAttribute("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 (xhref != "") {
- n[i].href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xhref);
- n[i].removeAttribute("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[i].removeAttribute("mce_thref");
}
}
}
+
+ el = 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=");
+ }
+
+ return false;
+ });
}
}
@@ -1920,14 +2058,14 @@ TinyMCE_Engine.prototype = {
}
if (doc) {
- var styles = tinyMCE.isMSIE ? doc.styleSheets : doc.styleSheets;
+ var styles = doc.styleSheets;
if (styles && styles.length > 0) {
for (var x=0; x<styles.length; x++) {
var csses = null;
// Just ignore any errors
- eval("try {var csses = tinyMCE.isMSIE ? doc.styleSheets(" + x + ").rules : doc.styleSheets[" + x + "].cssRules;} catch(e) {}");
+ eval("try {var csses = tinyMCE.isMSIE ? doc.styleSheets(" + x + ").rules : styles[" + x + "].cssRules;} catch(e) {}");
if (!csses)
return new Array();
@@ -1938,17 +2076,31 @@ TinyMCE_Engine.prototype = {
if (selectorText) {
var rules = selectorText.split(',');
for (var c=0; c<rules.length; c++) {
+ var rule = rules[c];
+
+ // Strip spaces between selectors
+ while (rule.indexOf(' ') == 0)
+ rule = rule.substring(1);
+
// Invalid rule
- if (rules[c].indexOf(' ') != -1 || rules[c].indexOf(':') != -1 || rules[c].indexOf('mceItem') != -1)
+ if (rule.indexOf(' ') != -1 || rule.indexOf(':') != -1 || rule.indexOf('mceItem') != -1)
continue;
- if (rules[c] == "." + tinyMCE.settings['visual_table_class'] || rules[c].indexOf('mceEditable') != -1 || rules[c].indexOf('mceNonEditable') != -1)
+ if (rule.indexOf(tinyMCE.settings['visual_table_class']) != -1 || rule.indexOf('mceEditable') != -1 || rule.indexOf('mceNonEditable') != -1)
continue;
// Is class rule
- if (rules[c].indexOf('.') != -1) {
- //alert(rules[c].substring(rules[c].indexOf('.')));
- output[output.length] = rules[c].substring(rules[c].indexOf('.')+1);
+ if (rule.indexOf('.') != -1) {
+ var cssClass = rule.substring(rule.indexOf('.') + 1);
+ var addClass = true;
+
+ for (var p=0; p<output.length && addClass; p++) {
+ if (output[p] == cssClass)
+ addClass = false;
+ }
+
+ if (addClass)
+ output[output.length] = cssClass;
}
}
}
@@ -2100,6 +2252,17 @@ 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;
}
};
@@ -2520,15 +2683,21 @@ TinyMCE_Control.prototype = {
case "FormatBlock":
if (value == null || value == "") {
- var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address");
+ var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address,blockquote,dt,dl,dd,samp");
if (elm)
this.execCommand("mceRemoveNode", false, elm);
} else {
- if (value == '<div>' && tinyMCE.isGecko)
- value = 'div';
-
- this.getDoc().execCommand("FormatBlock", false, value);
+ 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)) {
+ var b = this.selection.getBookmark();
+ this.getDoc().execCommand("FormatBlock", false, '<p>');
+ tinyMCE.renameElement(tinyMCE.getParentBlockElement(this.getFocusElement()), value);
+ this.selection.moveToBookmark(b);
+ } else
+ this.getDoc().execCommand("FormatBlock", false, value);
}
tinyMCE.triggerNodeChange();
@@ -2829,6 +2998,9 @@ TinyMCE_Control.prototype = {
tinyMCE.setInnerHTML(doc.body, tinyMCE._cleanupHTML(this, doc, tinyMCE.settings, doc.body));
tinyMCE.convertAllRelativeURLs(doc.body);
+ // Cleanup any mess left from storyAwayURLs
+ tinyMCE._removeInternal(this.getBody());
+
// When editing always use fonts internaly
if (tinyMCE.getParam("convert_fonts_to_spans"))
tinyMCE.convertSpansToFonts(doc);
@@ -3273,7 +3445,7 @@ TinyMCE_Control.prototype = {
if (tinyMCE.settings['debug']) {
hc = '<textarea wrap="off" id="' + form_element_name + '" name="' + form_element_name + '" cols="100" rows="15"></textarea>';
} else {
- hc = '<input type="hidden" type="text" id="' + form_element_name + '" name="' + form_element_name + '" />';
+ hc = '<input type="hidden" id="' + form_element_name + '" name="' + form_element_name + '" />';
this.oldTargetElement.style.display = "none";
}
@@ -3318,7 +3490,8 @@ TinyMCE_Control.prototype = {
var tElm = targetDoc.getElementById(this.editorId);
if (!tinyMCE.isMSIE) {
- if (tElm && tElm.nodeName == "SPAN") {
+ // Node case is preserved in XML strict mode
+ if (tElm && (tElm.nodeName == "SPAN" || tElm.nodeName == "span")) {
tElm = tinyMCE._createIFrame(tElm, targetDoc);
dynamicIFrame = true;
}
@@ -3413,7 +3586,27 @@ TinyMCE_Control.prototype = {
},
triggerSave : function(skip_cleanup, skip_callback) {
+ var e, nl = new Array(), i, s;
+
this.switchSettings();
+ s = tinyMCE.settings;
+
+ // Force hidden tabs visible while serializing
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ e = this.iframeElement;
+
+ do {
+ if (e.style && e.style.display == 'none') {
+ e.style.display = 'block';
+ nl[nl.length] = {elm : e, type : 'style'};
+ }
+
+ if (e.style && s.hidden_tab_class.length > 0 && e.className.indexOf(s.hidden_tab_class) != -1) {
+ e.className = s.display_tab_class;
+ nl[nl.length] = {elm : e, type : 'class'};
+ }
+ } while ((e = e.parentNode) != null)
+ }
tinyMCE.settings['preformatted'] = false;
@@ -3456,33 +3649,42 @@ TinyMCE_Control.prototype = {
if (tinyMCE.isSafari && this.formElement)
this.formElement.innerText = htm;
+
+ // Hide them again (tabs in MSIE)
+ for (i=0; i<nl.length; i++) {
+ if (nl[i].type == 'style')
+ nl[i].elm.style.display = 'none';
+ else
+ nl[i].elm.className = s.hidden_tab_class;
+ }
}
};
/* file:jscripts/tiny_mce/classes/TinyMCE_Cleanup.class.js */
TinyMCE_Engine.prototype.cleanupHTMLCode = function(s) {
- s = s.replace(/<p \/>/gi, '<p>&nbsp;</p>');
- s = s.replace(/<p>\s*<\/p>/gi, '<p>&nbsp;</p>');
+ s = s.replace(new RegExp('<p \\/>', 'gi'), '<p>&nbsp;</p>');
+ s = s.replace(new RegExp('<p>\\s*<\\/p>', 'gi'), '<p>&nbsp;</p>');
+
+ // Fix close BR elements
+ s = s.replace(new RegExp('<br>\\s*<\\/br>', 'gi'), '<br />');
// Open closed tags like <b/> to <b></b>
-// tinyMCE.debug("f:" + s);
- s = s.replace(/<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|font|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([a-z]*)([^\\|>]*?)\/>/gi, '<$1$2$3></$1$2>');
-// tinyMCE.debug("e:" + s);
+ s = s.replace(new RegExp('<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|font|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([a-z]*)([^\\\\|>]*)\\/>', 'gi'), '<$1$2$3></$1$2>');
// Remove trailing space <b > to <b>
s = s.replace(new RegExp('\\s+></', 'gi'), '></');
// Close tags <img></img> to <img/>
- s = s.replace(/<(img|br|hr)(.*?)><\/(img|br|hr)>/gi, '<$1$2 />');
+ 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)
- s = s.replace(/<p><hr \/><\/p>/gi, "<hr>");
+ s = s.replace(new RegExp('<p><hr \\/><\\/p>', 'gi'), "<hr>");
// Convert relative anchors to absolute URLs ex: #something to file.htm#something
if (tinyMCE.getParam('convert_urls'))
- s = s.replace(new RegExp('(href=\"?)(\\s*?#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#");
+ s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#");
return s;
};
@@ -3544,6 +3746,9 @@ TinyMCE_Engine.prototype.serializeStyle = function(ar) {
tinyMCE.compressStyle(ar, "border", "", "border");
tinyMCE.compressStyle(ar, "border", "-width", "border-width");
tinyMCE.compressStyle(ar, "border", "-color", "border-color");
+ tinyMCE.compressStyle(ar, "border", "-style", "border-style");
+ tinyMCE.compressStyle(ar, "padding", "", "padding");
+ tinyMCE.compressStyle(ar, "margin", "", "margin");
for (var key in ar) {
var val = ar[key];
@@ -3704,7 +3909,8 @@ TinyMCE_Engine.prototype.convertFontsToSpans = function(doc) {
TinyMCE_Engine.prototype.cleanupAnchors = function(doc) {
var i, cn, x, an = doc.getElementsByTagName("a");
- for (i=0; i<an.length; i++) {
+ // Loops backwards due to bug #1467987
+ for (i=an.length-1; i>=0; i--) {
if (tinyMCE.getAttrib(an[i], "name") != "" && tinyMCE.getAttrib(an[i], "href") == "") {
cn = an[i].childNodes;
@@ -3836,7 +4042,7 @@ TinyMCE_Engine.prototype._cleanupHTML = function(inst, doc, config, elm, visual,
h = h.replace(/<p>\s*(&nbsp;|&#160;)\s*<br \/>\s*(&nbsp;|&#160;)\s*<\/p>/g, '<p>&nbsp;</p>');
h = h.replace(/<p>\s*(&nbsp;|&#160;)\s*<br \/>\s*<\/p>/g, '<p>&nbsp;</p>');
h = h.replace(/<p>\s*<br \/>\s*&nbsp;\s*<\/p>/g, '<p>&nbsp;</p>');
- h = h.replace(/<a>(.*?)<\/a>/g, '$1');
+ h = h.replace(new RegExp('<a>(.*?)<\\/a>', 'g'), '$1');
h = h.replace(/<p([^>]*)>\s*<\/p>/g, '<p$1>&nbsp;</p>');
// Clean body
@@ -3912,7 +4118,7 @@ function TinyMCE_Cleanup() {
this.vElements = tinyMCE.clearArray(new Array());
this.vElementsRe = '';
- this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|BUTTON)$/;
+ this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|BUTTON|AREA)$/;
this.codeElementsRe = /^(SCRIPT|STYLE)$/;
this.serializationId = 0;
this.mceAttribs = {
@@ -4027,8 +4233,8 @@ TinyMCE_Cleanup.prototype = {
for (i=0; i<a.length; i++) {
t = a[i];
- av = /(=|:|<)(.*?)$/.exec(t);
- t = t.replace(/(=|:|<).*?$/, '');
+ av = new RegExp('(=|:|<)(.*?)$').exec(t);
+ t = t.replace(new RegExp('(=|:|<).*?$'), '');
if (av && av.length > 0) {
if (av[0].charAt(0) == ':') {
if (!r.forceAttribs)
@@ -4334,13 +4540,6 @@ TinyMCE_Cleanup.prototype = {
c = s.charCodeAt(i);
e = this.entities[c];
- // &apos; is not working in MSIE
- // More info: http://www.w3.org/TR/xhtml1/#C_16
- if (c == 39) {
- o += "&#39;";
- continue;
- }
-
if (e && e != '')
o += '&' + e + ';';
else
@@ -4378,12 +4577,6 @@ TinyMCE_Cleanup.prototype = {
},
_trimComment : function(s) {
- // Make xsrc, xhref as src and href again
- if (tinyMCE.isGecko) {
- s = s.replace(/\sxsrc=/gi, " src=");
- s = s.replace(/\sxhref=/gi, " href=");
- }
-
// Remove mce_src, mce_href
s = s.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), "");
s = s.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), "");
@@ -4406,6 +4599,15 @@ TinyMCE_Cleanup.prototype = {
if (this.isMSIE && n == "http-equiv")
v = e.httpEquiv;
+ if (this.isMSIE && e.nodeName == "FORM" && n == "enctype" && v == "application/x-www-form-urlencoded")
+ v = "";
+
+ if (this.isMSIE && e.nodeName == "INPUT" && n == "size" && v == "20")
+ v = "";
+
+ if (this.isMSIE && e.nodeName == "INPUT" && n == "maxlength" && v == "2147483647")
+ v = "";
+
if (n == "style" && !tinyMCE.isOpera)
v = e.style.cssText;
@@ -4557,7 +4759,8 @@ TinyMCE_Engine.prototype.setInnerHTML = function(e, h) {
// Since MSIE auto generated emtpy P tags some times we must tell it to keep the real ones
h = h.replace(/<p([^>]*)>\u00A0?<\/p>/gi, '<p$1 mce_keep="true">&nbsp;</p>'); // Keep empty paragraphs
- h = h.replace(/<p([^>]*)>&nbsp;<\/p>/gi, '<p$1 mce_keep="true">&nbsp;</p>'); // Keep empty paragraphs
+ h = h.replace(/<p([^>]*)>\s*&nbsp;\s*<\/p>/gi, '<p$1 mce_keep="true">&nbsp;</p>'); // Keep empty paragraphs
+ h = h.replace(/<p([^>]*)>\s+<\/p>/gi, '<p$1 mce_keep="true">&nbsp;</p>'); // Keep empty paragraphs
// Remove first comment
e.innerHTML = tinyMCE.uniqueTag + h;
@@ -4670,6 +4873,17 @@ TinyMCE_Engine.prototype.getParentElement = function(node, names, attrib_name, a
return null;
};
+TinyMCE_Engine.prototype.getParentNode = function(n, f) {
+ while (n) {
+ if (f(n))
+ return n;
+
+ n = n.parentNode;
+ }
+
+ return null;
+};
+
TinyMCE_Engine.prototype.getAttrib = function(elm, name, default_value) {
if (typeof(default_value) == "undefined")
default_value = "";
@@ -4791,6 +5005,62 @@ TinyMCE_Engine.prototype.nextNode = function(e, n) {
return null;
};
+TinyMCE_Engine.prototype.selectNodes = function(n, f, a) {
+ var i;
+
+ if (!a)
+ a = new Array();
+
+ if (f(n))
+ a[a.length] = n;
+
+ if (n.hasChildNodes()) {
+ for (i=0; i<n.childNodes.length; i++)
+ tinyMCE.selectNodes(n.childNodes[i], f, a);
+ }
+
+ return 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] = '';
+ }
+
+ return e.className = a.join(' ');
+};
+
+TinyMCE_Engine.prototype.renameElement = function(e, n, d) {
+ var ne, i, ar;
+
+ d = typeof(d) == "undefined" ? tinyMCE.selectedInstance.getDoc() : d;
+
+ if (e) {
+ ne = d.createElement(n);
+
+ ar = e.attributes;
+ for (i=ar.length-1; i>-1; i--) {
+ if (ar[i].specified && ar[i].nodeValue)
+ ne.setAttribute(ar[i].nodeName.toLowerCase(), ar[i].nodeValue);
+ }
+
+ ar = e.childNodes;
+ for (i=0; i<ar.length; i++)
+ ne.appendChild(ar[i].cloneNode(true));
+
+ e.parentNode.replaceChild(ne, e);
+ }
+};
+
/* file:jscripts/tiny_mce/classes/TinyMCE_URL.class.js */
TinyMCE_Engine.prototype.parseURL = function(url_str) {
@@ -4950,9 +5220,9 @@ TinyMCE_Engine.prototype.convertAbsoluteURLToRelativeURL = function(base_url, ur
if (fileName == targetURL.path && targetURL.anchor != "")
targetURL.path = "";
- // If empty and not local anchor force slash
+ // If empty and not local anchor force filename or slash
if (targetURL.path == "" && !targetURL.anchor)
- targetURL.path = "/";
+ targetURL.path = fileName != "" ? fileName : "/";
return this.serializeURL(targetURL);
};
@@ -5215,6 +5485,7 @@ TinyMCE_Engine.prototype.addEventHandlers = function(inst) {
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);
} else {
tinyMCE.addEvent(doc, "keypress", tinyMCE.handleEvent);
@@ -5308,6 +5579,24 @@ TinyMCE_Engine.prototype.accessibleEventHandler = function(e) {
return true;
};
+TinyMCE_Engine.prototype._resetIframeHeight = function() {
+ var ife;
+
+ if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
+ ife = tinyMCE.selectedInstance.iframeElement;
+
+/* if (ife._oldWidth) {
+ ife.style.width = ife._oldWidth;
+ ife.width = ife._oldWidth;
+ }*/
+
+ if (ife._oldHeight) {
+ ife.style.height = ife._oldHeight;
+ ife.height = ife._oldHeight;
+ }
+ }
+};
+
/* file:jscripts/tiny_mce/classes/TinyMCE_Selection.class.js */
function TinyMCE_Selection(inst) {
@@ -5328,8 +5617,8 @@ TinyMCE_Selection.prototype = {
if (tinyMCE.isGecko)
e.appendChild(r.cloneContents());
- else
- e.innerHTML = r.htmlText;
+ else
+ e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText;
h = tinyMCE._cleanupHTML(inst, inst.contentDocument, inst.settings, e, e, false, true, false);
@@ -5490,8 +5779,13 @@ TinyMCE_Selection.prototype = {
nl = doc.getElementsByTagName(bookmark.tag);
- if (nl.length > bookmark.index)
- rng.addElement(nl[bookmark.index]);
+ if (nl.length > bookmark.index) {
+ try {
+ rng.addElement(nl[bookmark.index]);
+ } catch (ex) {
+ // Might be thrown if the node no longer exists
+ }
+ }
} else {
rng = inst.getSel().createRange();
rng.moveToElementText(inst.getBody());
@@ -5877,6 +6171,13 @@ var TinyMCE_ForceParagraphs = {
var startBlock = tinyMCE.getParentBlockElement(startNode);
var endBlock = tinyMCE.getParentBlockElement(endNode);
+ // If absolute force paragraph generation within
+ if (startBlock && new RegExp('absolute|relative|static', 'gi').test(startBlock.style.position))
+ startBlock = null;
+
+ if (endBlock && new RegExp('absolute|relative|static', 'gi').test(endBlock.style.position))
+ endBlock = null;
+
// Use current block name
if (startBlock != null) {
blockName = startBlock.nodeName;
@@ -6062,13 +6363,21 @@ var TinyMCE_ForceParagraphs = {
},
_handleBackSpace : function(inst) {
- var r = inst.getRng();
- var sn = r.startContainer;
+ var r = inst.getRng(), sn = r.startContainer, nv, s = false;
- if (sn && sn.nextSibling && sn.nextSibling.nodeName == "BR")
- sn.nextSibling.parentNode.removeChild(sn.nextSibling);
+ if (sn && sn.nextSibling && sn.nextSibling.nodeName == "BR") {
+ nv = sn.nodeValue;
- return false;
+ // 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;
+
+ // 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);
+ }
+
+ return s;
}
};
@@ -6080,6 +6389,7 @@ function TinyMCE_Layer(id, bm) {
this.events = false;
this.element = null;
this.blockMode = typeof(bm) != 'undefined' ? bm : true;
+ this.doc = document;
};
TinyMCE_Layer.prototype = {
@@ -6144,8 +6454,11 @@ TinyMCE_Layer.prototype = {
resizeTo : function(w, h) {
var e = this.getElement();
- e.style.width = w + "px";
- e.style.height = h + "px";
+ if (w != null)
+ e.style.width = w + "px";
+
+ if (h != null)
+ e.style.height = h + "px";
this.updateBlocker();
},
@@ -6166,7 +6479,7 @@ TinyMCE_Layer.prototype = {
getElement : function() {
if (!this.element)
- this.element = document.getElementById(this.id);
+ this.element = this.doc.getElementById(this.id);
return this.element;
},
@@ -6201,7 +6514,7 @@ TinyMCE_Layer.prototype = {
var d, b;
if (!this.blockerElement && this.blockMode) {
- d = document;
+ d = this.doc;
b = d.createElement("iframe");
b.style.cssText = 'display: none; position: absolute; left: 0; top: 0';
@@ -6229,7 +6542,7 @@ TinyMCE_Layer.prototype = {
},
create : function(n, c, p) {
- var d = document, e = d.createElement(n);
+ var d = this.doc, e = d.createElement(n);
e.setAttribute('id', this.id);
@@ -6243,37 +6556,6 @@ TinyMCE_Layer.prototype = {
return this.element = e;
},
-/*
- addCSSClass : function(e, c) {
- this.removeCSSClass(e, c);
- var a = this.explode(' ', e.className);
- a[a.length] = c;
- e.className = a.join(' ');
- },
-
- removeCSSClass : function(e, c) {
- var a = this.explode(' ', e.className), i;
-
- for (i=0; i<a.length; i++) {
- if (a[i] == c)
- a[i] = '';
- }
-
- e.className = a.join(' ');
- },
-
- explode : function(d, s) {
- var ar = s.split(d);
- var oar = new Array();
-
- for (var i = 0; i<ar.length; i++) {
- if (ar[i] != "")
- oar[oar.length] = ar[i];
- }
-
- return oar;
- },
-*/
parseInt : function(s) {
if (s == null || s == '')
@@ -6397,7 +6679,7 @@ TinyMCE_Menu.prototype = tinyMCE.extend(TinyMCE_Layer.prototype, {
if (tinyMCE.lastMenu && tinyMCE.lastMenu != this)
tinyMCE.lastMenu.hide();
- this.parent.show.call(this);
+ TinyMCE_Layer.prototype.show.call(this);
if (!tinyMCE.isOpera) {
// Accessibility stuff
diff --git a/wp-includes/js/tinymce/tiny_mce_config.php b/wp-includes/js/tinymce/tiny_mce_config.php
index 651165a..283ffb8 100644
--- a/wp-includes/js/tinymce/tiny_mce_config.php
+++ b/wp-includes/js/tinymce/tiny_mce_config.php
@@ -43,6 +43,10 @@
$mce_popups_css = get_option('siteurl') . '/wp-includes/js/tinymce/plugins/wordpress/popups.css';
$mce_css = get_option('siteurl') . '/wp-includes/js/tinymce/plugins/wordpress/wordpress.css';
$mce_css = apply_filters('mce_css', $mce_css);
+ if ( $_SERVER['HTTPS'] ) {
+ $mce_css = str_replace('http://', 'https://', $mce_css);
+ $mce_popups_css = str_replace('http://', 'https://', $mce_popups_css);
+ }
?>
initArray = {
@@ -69,6 +73,7 @@ initArray = {
convert_newlines_to_brs : false,
remove_linebreaks : false,
fix_list_elements : true,
+ entities : "38,amp,60,lt,62,gt",
content_css : "<?php echo $mce_css; ?>",
valid_elements : "<?php echo $valid_elements; ?>",
save_callback : 'TinyMCE_wordpressPlugin.saveCallback',
diff --git a/wp-includes/js/tinymce/tiny_mce_popup.js b/wp-includes/js/tinymce/tiny_mce_popup.js
index c5864e6..cbcdf3e 100644
--- a/wp-includes/js/tinymce/tiny_mce_popup.js
+++ b/wp-includes/js/tinymce/tiny_mce_popup.js
@@ -263,6 +263,15 @@ TinyMCE_Popup.prototype.openBrowser = function(element_id, type, option) {
eval("tinyMCEPopup.windowOpener." + cb + "(element_id, url, type, window);");
};
+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];
+
+ window[c].constructor = window.opener[c].constructor;
+};
+
// Setup global instance
var tinyMCEPopup = new TinyMCE_Popup();
diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php
index 8724cd9..9c2440f 100644
--- a/wp-includes/pluggable.php
+++ b/wp-includes/pluggable.php
@@ -227,7 +227,7 @@ function auth_redirect() {
(empty($_COOKIE[USER_COOKIE])) ) {
nocache_headers();
- header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
+ wp_redirect(get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
exit();
}
}
@@ -235,34 +235,11 @@ endif;
if ( !function_exists('check_admin_referer') ) :
function check_admin_referer($action = -1) {
- global $pagenow, $menu, $submenu, $parent_file, $submenu_file;;
$adminurl = strtolower(get_settings('siteurl')).'/wp-admin';
$referer = strtolower(wp_get_referer());
if ( !wp_verify_nonce($_REQUEST['_wpnonce'], $action) &&
!(-1 == $action && strstr($referer, $adminurl)) ) {
- if ( $referer )
- $adminurl = $referer;
- $title = __('WordPress Confirmation');
- require_once(ABSPATH . '/wp-admin/admin-header.php');
- // Remove extra layer of slashes.
- $_POST = stripslashes_deep($_POST );
- if ( $_POST ) {
- $q = http_build_query($_POST);
- $q = explode( ini_get('arg_separator.output'), $q);
- $html .= "\t<form method='post' action='$pagenow'>\n";
- foreach ( (array) $q as $a ) {
- $v = substr(strstr($a, '='), 1);
- $k = substr($a, 0, -(strlen($v)+1));
- $html .= "\t\t<input type='hidden' name='" . wp_specialchars( urldecode($k), 1 ) . "' value='" . wp_specialchars( urldecode($v), 1 ) . "' />\n";
- }
- $html .= "\t\t<input type='hidden' name='_wpnonce' value='" . wp_create_nonce($action) . "' />\n";
- $html .= "\t\t<div id='message' class='confirm fade'>\n\t\t<p>" . __('Are you sure you want to do this?') . "</p>\n\t\t<p><a href='$adminurl'>" . __('No') . "</a> <input type='submit' value='" . __('Yes') . "' /></p>\n\t\t</div>\n\t</form>\n";
- } else {
- $html .= "\t<div id='message' class='confirm fade'>\n\t<p>" . __('Are you sure you want to do this?') . "</p>\n\t<p><a href='$adminurl'>" . __('No') . "</a> <a href='" . add_query_arg( '_wpnonce', wp_create_nonce($action), $_SERVER['REQUEST_URI'] ) . "'>" . __('Yes') . "</a></p>\n\t</div>\n";
- }
- $html .= "</body>\n</html>";
- echo $html;
- include_once(ABSPATH . '/wp-admin/admin-footer.php');
+ wp_nonce_ays($action);
die();
}
do_action('check_admin_referer', $action);
diff --git a/wp-includes/rss.php b/wp-includes/rss.php
index 2f99d3f..e0c1d84 100644
--- a/wp-includes/rss.php
+++ b/wp-includes/rss.php
@@ -1,793 +1,1159 @@
<?php
-/*
- * Project: MagpieRSS: a simple RSS integration tool
- * File: A compiled file for RSS syndication
- * Author: Kellan Elliott-McCrea <kellan@protest.net>
- * Version: 0.51
- * License: GPL
+
+/* Much of the code in this file was taken from MagpieRSS
+ * by Kellan Elliott-McCrea <kellan@protest.net> which is
+ * released under the GPL license.
+ *
+ * The lastest version of MagpieRSS can be obtained from:
+ * http://magpierss.sourceforge.net
*/
-define('RSS', 'RSS');
-define('ATOM', 'Atom');
-define('MAGPIE_USER_AGENT', 'WordPress/' . $wp_version);
+function fetch_rss($url) {
+ $url = apply_filters('fetch_rss_url', $url);
-class MagpieRSS {
- var $parser;
- var $current_item = array(); // item currently being parsed
- var $items = array(); // collection of parsed items
- var $channel = array(); // hash of channel fields
- var $textinput = array();
- var $image = array();
- var $feed_type;
- var $feed_version;
+ $feeder = new WP_Feeder();
- // parser variables
- var $stack = array(); // parser stack
- var $inchannel = false;
- var $initem = false;
- var $incontent = false; // if in Atom <content mode="xml"> field
- var $intextinput = false;
- var $inimage = false;
- var $current_field = '';
- var $current_namespace = false;
+ $feed = $feeder->get($url);
- //var $ERROR = "";
+ $magpie = $feed->to_magpie();
- var $_CONTENT_CONSTRUCTS = array('content', 'summary', 'info', 'title', 'tagline', 'copyright');
+ return $magpie;
+}
- function MagpieRSS ($source) {
+class WP_Feeder {
+ var $url, $http_client, $last_fetch, $wp_object_cache, $cache;
+ var $redirects = 0;
+ var $max_redirects = 3;
+ var $cache_redirects = true;
+
+ function WP_Feeder () {
+ global $wp_object_cache;
+
+ if ( $wp_object_cache->cache_enabled ) {
+ $this->wp_object_cache = true;
+ } else {
+ $this->wp_object_cache = false;
+ $this->cache = new RSSCache();
+ }
+ }
- # if PHP xml isn't compiled in, die
- #
- if ( !function_exists('xml_parser_create') )
- trigger_error( "Failed to load PHP's XML Extension. http://www.php.net/manual/en/ref.xml.php" );
+ function get ($url) {
+ $cached = false;
- $parser = @xml_parser_create();
+ $feed = $this->cache_get($url);
- if ( !is_resource($parser) )
- trigger_error( "Failed to create an instance of PHP's XML parser. http://www.php.net/manual/en/ref.xml.php");
+ if ( is_object($feed) ) {
+ $cached = true;
+ } else {
+ unset($feed);
+ $this->fetch($url);
- $this->parser = $parser;
-
- # pass in parser, and a reference to this object
- # setup handlers
- #
- xml_set_object( $this->parser, $this );
- xml_set_element_handler($this->parser,
- 'feed_start_element', 'feed_end_element' );
+ $feed = new WP_Feed($this->http_client);
+ }
- xml_set_character_data_handler( $this->parser, 'feed_cdata' );
+ // Handle redirects
+ if ( $feed->status >= 300 && $feed->status < 400 && $this->redirects < $this->max_redirects ) {
+ ++$this->redirects;
- $status = xml_parse( $this->parser, $source );
+ if ( $this->cache_redirects && !$cached )
+ $this->cache_set($url, $feed);
- if (! $status ) {
- $errorcode = xml_get_error_code( $this->parser );
- if ( $errorcode != XML_ERROR_NONE ) {
- $xml_error = xml_error_string( $errorcode );
- $error_line = xml_get_current_line_number($this->parser);
- $error_col = xml_get_current_column_number($this->parser);
- $errormsg = "$xml_error at line $error_line, column $error_col";
-
- $this->error( $errormsg );
- }
+ return $this->get($feed->redirect_location);
}
- xml_parser_free( $this->parser );
+ if ( !$cached )
+ $this->cache_set($url, $feed);
- $this->normalize();
+ return $feed;
}
- function feed_start_element($p, $element, &$attrs) {
- $el = $element = strtolower($element);
- $attrs = array_change_key_case($attrs, CASE_LOWER);
+ function fetch ($url) {
+ $this->last_fetch = $url;
+ $parts = parse_url($url);
+ $url = ($parts['path'] ? $parts['path'] : '/') . ($parts['query'] ? '?'.$parts['query'] : '');
+ $this->http_client = new HttpClient('', 80);
+ $this->http_client->handle_redirects = false;
+ $this->http_client->host = $parts['host'];
+ $this->http_client->port = $parts['port'] ? $parts['port'] : 80;
+ $this->http_client->user_agent = 'WordPress ' . $GLOBALS['wp_version'] . ' Feed Client';
+ $this->http_client->get($url);
+ }
+
+ function cache_get ($url) {
+ if ( $this->wp_object_cache )
+ return unserialize(wp_cache_get($url, 'rss'));
- // check for a namespace, and split if found
- $ns = false;
- if ( strpos( $element, ':' ) ) {
- list($ns, $el) = split( ':', $element, 2);
- }
- if ( $ns and $ns != 'rdf' ) {
- $this->current_namespace = $ns;
- }
+ return $this->cache->get($url);
+ }
+
+ function cache_set ($url, $object) {
+ if ( $this->wp_object_cache )
+ return wp_cache_set($url, serialize($object), 'rss', 3600);
+
+ return $this->cache->set($url, $object);
+ }
+}
- # if feed type isn't set, then this is first element of feed
- # identify feed from root element
- #
- if (!isset($this->feed_type) ) {
- if ( $el == 'rdf' ) {
- $this->feed_type = RSS;
- $this->feed_version = '1.0';
- }
- elseif ( $el == 'rss' ) {
- $this->feed_type = RSS;
- $this->feed_version = $attrs['version'];
- }
- elseif ( $el == 'feed' ) {
- $this->feed_type = ATOM;
- $this->feed_version = $attrs['version'];
- $this->inchannel = true;
- }
- return;
- }
+class RSSCache {
+ var $BASE_CACHE = 'wp-content/cache'; // where the cache files are stored
+ var $MAX_AGE = 43200; // when are files stale, default twelve hours
+ var $ERROR = ''; // accumulate error messages
- if ( $el == 'channel' )
- {
- $this->inchannel = true;
+ function RSSCache ($base='', $age='') {
+ if ( $base ) {
+ $this->BASE_CACHE = $base;
}
- elseif ($el == 'item' or $el == 'entry' )
- {
- $this->initem = true;
- if ( isset($attrs['rdf:about']) ) {
- $this->current_item['about'] = $attrs['rdf:about'];
- }
+ if ( $age ) {
+ $this->MAX_AGE = $age;
}
- // if we're in the default namespace of an RSS feed,
- // record textinput or image fields
- elseif (
- $this->feed_type == RSS and
- $this->current_namespace == '' and
- $el == 'textinput' )
- {
- $this->intextinput = true;
- }
+ }
- elseif (
- $this->feed_type == RSS and
- $this->current_namespace == '' and
- $el == 'image' )
- {
- $this->inimage = true;
- }
+ function set ($url, $rss) {
+ global $wpdb;
+ $cache_option = 'rss_' . $this->file_name( $url );
+ $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
- # handle atom content constructs
- elseif ( $this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
- {
- // avoid clashing w/ RSS mod_content
- if ($el == 'content' ) {
- $el = 'atom_content';
- }
+ if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$cache_option'") )
+ add_option($cache_option, '', '', 'no');
+ if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$cache_timestamp'") )
+ add_option($cache_timestamp, '', '', 'no');
+
+ update_option($cache_option, $rss);
+ update_option($cache_timestamp, time() );
- $this->incontent = $el;
+ return $cache_option;
+ }
+ function get ($url) {
+ $this->ERROR = "";
+ $cache_option = 'rss_' . $this->file_name( $url );
+ if ( ! get_option( $cache_option ) ) {
+ $this->debug(
+ "Cache doesn't contain: $url (cache option: $cache_option)"
+ );
+ return 0;
}
- // if inside an Atom content construct (e.g. content or summary) field treat tags as text
- elseif ($this->feed_type == ATOM and $this->incontent )
- {
- // if tags are inlined, then flatten
- $attrs_str = join(' ',
- array_map('map_attrs',
- array_keys($attrs),
- array_values($attrs) ) );
+ $rss = get_option( $cache_option );
- $this->append_content( "<$element $attrs_str>" );
+ return $rss;
+ }
- array_unshift( $this->stack, $el );
- }
+ function check_cache ( $url ) {
+ $this->ERROR = "";
+ $cache_option = $this->file_name( $url );
+ $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
- // Atom support many links per containging element.
- // Magpie treats link elements of type rel='alternate'
- // as being equivalent to RSS's simple link element.
- //
- elseif ($this->feed_type == ATOM and $el == 'link' )
- {
- if ( isset($attrs['rel']) and $attrs['rel'] == 'alternate' )
- {
- $link_el = 'link';
+ if ( $mtime = get_option($cache_timestamp) ) {
+ // find how long ago the file was added to the cache
+ // and whether that is longer then MAX_AGE
+ $age = time() - $mtime;
+ if ( $this->MAX_AGE > $age ) {
+ // object exists and is current
+ return 'HIT';
}
else {
- $link_el = 'link_' . $attrs['rel'];
+ // object exists but is old
+ return 'STALE';
}
-
- $this->append($link_el, $attrs['href']);
}
- // set stack[0] to current element
else {
- array_unshift($this->stack, $el);
+ // object does not exist
+ return 'MISS';
}
}
+ function serialize ( $rss ) {
+ return serialize( $rss );
+ }
+ function unserialize ( $data ) {
+ return unserialize( $data );
+ }
- function feed_cdata ($p, $text) {
+ function file_name ($url) {
+ return md5( $url );
+ }
- if ($this->feed_type == ATOM and $this->incontent)
- {
- $this->append_content( $text );
+ function error ($errormsg, $lvl=E_USER_WARNING) {
+ // append PHP's error message if track_errors enabled
+ if ( isset($php_errormsg) ) {
+ $errormsg .= " ($php_errormsg)";
+ }
+ $this->ERROR = $errormsg;
+ if ( MAGPIE_DEBUG ) {
+ trigger_error( $errormsg, $lvl);
}
else {
- $current_el = join('_', array_reverse($this->stack));
- $this->append($current_el, $text);
+ error_log( $errormsg, 0);
+ }
+ }
+ function debug ($debugmsg, $lvl=E_USER_NOTICE) {
+ if ( MAGPIE_DEBUG ) {
+ $this->error("MagpieRSS [debug] $debugmsg", $lvl);
}
}
+}
- function feed_end_element ($p, $el) {
- $el = strtolower($el);
+class WP_Feed {
+ var $status;
+ var $raw_xml;
+ var $last_updated;
+ var $tree;
+ var $items;
+ var $children;
- if ( $el == 'item' or $el == 'entry' )
- {
- $this->items[] = $this->current_item;
- $this->current_item = array();
- $this->initem = false;
- }
- elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'textinput' )
- {
- $this->intextinput = false;
- }
- elseif ($this->feed_type == RSS and $this->current_namespace == '' and $el == 'image' )
- {
- $this->inimage = false;
+ var $parser;
+ var $feed_type;
+ var $feed_version;
+ var $stack = array();
+
+ function WP_Feed ($source)
+ {
+ # if PHP xml isn't compiled in, die
+ #
+ if (!function_exists('xml_parser_create')) {
+ $this->error( "Failed to load PHP's XML Extension. " .
+ "http://www.php.net/manual/en/ref.xml.php",
+ E_USER_ERROR );
}
- elseif ($this->feed_type == ATOM and in_array($el, $this->_CONTENT_CONSTRUCTS) )
- {
- $this->incontent = false;
+
+ // Handle overloaded arg (string or HttpClient object)
+ if ( is_object($source) ) {
+ if ( $source->status >= 200 && $source->status < 300) {
+ $this->etag = $source->headers['etag'];
+ $this->last_modified = $source->headers['last-modified'];
+ $source = $source->content;
+ } else {
+ $this->scour();
+ $this->status = $source->status;
+ $this->redirect_location = $source->headers->location;
+ $this->bathe();
+ return;
+ }
}
- elseif ($el == 'channel' or $el == 'feed' )
- {
- $this->inchannel = false;
+
+ list($parser, $source) = $this->create_parser($source, 'UTF-8', null, true);
+
+ if (!is_resource($parser)) {
+ $this->error( "Failed to create an instance of PHP's XML parser. " .
+ "http://www.php.net/manual/en/ref.xml.php",
+ E_USER_ERROR );
}
- elseif ($this->feed_type == ATOM and $this->incontent ) {
- // balance tags properly
- // note: i don't think this is actually neccessary
- if ( $this->stack[0] == $el )
- {
- $this->append_content("</$el>");
- }
- else {
- $this->append_content("<$el />");
+
+ $this->parser = $parser;
+
+ # pass in parser, and a reference to this object
+ # setup handlers
+ #
+ xml_set_object($this->parser, $this);
+ xml_set_element_handler($this->parser, 'start_element', 'end_element');
+ xml_set_character_data_handler( $this->parser, 'cdata');
+
+ $status = xml_parse( $this->parser, $source );
+
+ if (! $status ) {
+ $errorcode = xml_get_error_code( $this->parser );
+ if ( $errorcode != XML_ERROR_NONE ) {
+ $xml_error = xml_error_string( $errorcode );
+ $error_line = xml_get_current_line_number($this->parser);
+ $error_col = xml_get_current_column_number($this->parser);
+ $errormsg = "$xml_error at line $error_line, column $error_col";
+
+ $this->error( $errormsg );
}
+ }
- array_shift( $this->stack );
+ // SUPER SLOPPY FEED DISCOVERY!! TO-DO: AXE THIS CRAP!!
+ if ( !is_object($this->feed) || !method_exists($this->feed, 'to_xml') ) {
+ if ( preg_match_all('/<link [^>]*href=([^ >]+)[^>]+>/i', $source, $matches) ) {
+ $types = array('rss', 'atom');
+ foreach ( $types as $type )
+ foreach ( $matches[0] as $key => $link )
+ if ( preg_match('/rel=.alternate./', $link) && preg_match("/type=[^ >]*{$type}[^ >]*/", $link) )
+ break 2;
+ $this->scour();
+ $this->redirect_location = 'http://xml.wordpress.com/get/' . trim($matches[1][$key], '\'"');
+ $this->status = 301;
+ return;
+ } else {
+ $this->scour();
+ $this->status = 404;
+ return;
+ }
+ } else {
+ $this->status = 200;
}
- else {
- array_shift( $this->stack );
+
+ xml_parser_free( $this->parser );
+ unset($this->parser);
+
+ $this->bathe();
+ }
+
+ function to_xml() {
+ if ( is_object($this->feed) && method_exists($this->feed, 'to_xml') )
+ return $this->feed->to_xml();
+
+ return false;
+ }
+
+ // Called internally by xml_parse(). We create an object and call its start_element method.
+ function start_element($p, $element, &$attrs) {
+ $el = $element;// = strtolower($element);
+ // $attrs = array_change_key_case($attrs, CASE_LOWER);
+
+ // If there is an extended class for this element, use it.
+ $class = 'element';
+
+ $maybe_class = $test_class = strtolower(str_replace(':', '_', $el));
+ if ( class_exists($maybe_class) ) {
+ for ($classes[] = $test_class; $test_class = get_parent_class ($test_class); $classes[] = $test_class);
+ if ( in_array($class, $classes) )
+ $class = $maybe_class;
}
- $this->current_namespace = false;
+ // Instantiate an object for this element.
+ $object = new $class();
+
+ // Tell the element to start itself.
+ $object->start_element($p, $element, $attrs, $this);
+ }
+
+ function cdata ($p, $data) {
+ $this->stack[0]->cdata($p, $data, $this);
+ }
+
+ function end_element ($p, $el) {
+ $this->stack[0]->end_element($p, $el, $this);
}
- function concat (&$str1, $str2="") {
- if (!isset($str1) ) {
- $str1="";
+ function create_parser($source, $out_enc, $in_enc, $detect) {
+ if ( substr(phpversion(),0,1) == 5) {
+ $parser = $this->php5_create_parser($in_enc, $detect);
+ }
+ else {
+ list($parser, $source) = $this->php4_create_parser($source, $in_enc, $detect);
}
- $str1 .= $str2;
+ if ($out_enc) {
+ $this->encoding = $out_enc;
+ xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, $out_enc);
+ xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
+ }
+
+ return array($parser, $source);
}
- function append_content($text) {
- if ( $this->initem ) {
- $this->concat( $this->current_item[ $this->incontent ], $text );
+ function php5_create_parser($in_enc, $detect) {
+ // by default php5 does a fine job of detecting input encodings
+ if(!$detect && $in_enc) {
+ return xml_parser_create($in_enc);
}
- elseif ( $this->inchannel ) {
- $this->concat( $this->channel[ $this->incontent ], $text );
+ else {
+ return xml_parser_create('');
}
}
- // smart append - field and namespace aware
- function append($el, $text) {
- if (!$el) {
- return;
+ /**
+ * Instaniate an XML parser under PHP4
+ *
+ * Unfortunately PHP4's support for character encodings
+ * and especially XML and character encodings sucks. As
+ * long as the documents you parse only contain characters
+ * from the ISO-8859-1 character set (a superset of ASCII,
+ * and a subset of UTF-8) you're fine. However once you
+ * step out of that comfy little world things get mad, bad,
+ * and dangerous to know.
+ *
+ * The following code is based on SJM's work with FoF
+ * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
+ *
+ */
+ function php4_create_parser($source, $in_enc, $detect) {
+ if ( !$detect ) {
+ return array(xml_parser_create($in_enc), $source);
}
- if ( $this->current_namespace )
- {
- if ( $this->initem ) {
- $this->concat(
- $this->current_item[ $this->current_namespace ][ $el ], $text);
- }
- elseif ($this->inchannel) {
- $this->concat(
- $this->channel[ $this->current_namespace][ $el ], $text );
- }
- elseif ($this->intextinput) {
- $this->concat(
- $this->textinput[ $this->current_namespace][ $el ], $text );
+
+ if (!$in_enc) {
+ if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) {
+ $in_enc = strtoupper($m[1]);
+ $this->source_encoding = $in_enc;
}
- elseif ($this->inimage) {
- $this->concat(
- $this->image[ $this->current_namespace ][ $el ], $text );
+ else {
+ $in_enc = 'UTF-8';
}
}
- else {
- if ( $this->initem ) {
- $this->concat(
- $this->current_item[ $el ], $text);
- }
- elseif ($this->intextinput) {
- $this->concat(
- $this->textinput[ $el ], $text );
- }
- elseif ($this->inimage) {
- $this->concat(
- $this->image[ $el ], $text );
- }
- elseif ($this->inchannel) {
- $this->concat(
- $this->channel[ $el ], $text );
- }
+ if ($this->known_encoding($in_enc)) {
+ return array(xml_parser_create($in_enc), $source);
}
- }
- function normalize () {
- // if atom populate rss fields
- if ( $this->is_atom() ) {
- $this->channel['descripton'] = $this->channel['tagline'];
- for ( $i = 0; $i < count($this->items); $i++) {
- $item = $this->items[$i];
- if ( isset($item['summary']) )
- $item['description'] = $item['summary'];
- if ( isset($item['atom_content']))
- $item['content']['encoded'] = $item['atom_content'];
+ // the dectected encoding is not one of the simple encodings PHP knows
+
+ // attempt to use the iconv extension to
+ // cast the XML to a known encoding
+ // @see http://php.net/iconv
- $this->items[$i] = $item;
+ if (function_exists('iconv')) {
+ $encoded_source = iconv($in_enc,'UTF-8', $source);
+ if ($encoded_source) {
+ return array(xml_parser_create('UTF-8'), $encoded_source);
}
}
- elseif ( $this->is_rss() ) {
- $this->channel['tagline'] = $this->channel['description'];
- for ( $i = 0; $i < count($this->items); $i++) {
- $item = $this->items[$i];
- if ( isset($item['description']))
- $item['summary'] = $item['description'];
- if ( isset($item['content']['encoded'] ) )
- $item['atom_content'] = $item['content']['encoded'];
- $this->items[$i] = $item;
+ // iconv didn't work, try mb_convert_encoding
+ // @see http://php.net/mbstring
+ if(function_exists('mb_convert_encoding')) {
+ $encoded_source = mb_convert_encoding($source, 'UTF-8', $in_enc );
+ if ($encoded_source) {
+ return array(xml_parser_create('UTF-8'), $encoded_source);
}
}
- }
- function is_rss () {
- if ( $this->feed_type == RSS ) {
- return $this->feed_version;
- }
- else {
- return false;
- }
+ // else
+ $this->error("Feed is in an unsupported character encoding. ($in_enc) " .
+ "You may see strange artifacts, and mangled characters.",
+ E_USER_NOTICE);
+
+ return array(xml_parser_create(), $source);
}
- function is_atom() {
- if ( $this->feed_type == ATOM ) {
- return $this->feed_version;
+ function known_encoding($enc) {
+ $enc = strtoupper($enc);
+ if ( in_array($enc, array('UTF-8', 'US-ASCII', 'ISO-8859-1')) ) {
+ return $enc;
}
else {
return false;
}
}
- function map_attrs($k, $v) {
- return "$k=\"$v\"";
- }
-
- function error( $errormsg, $lvl = E_USER_WARNING ) {
+ function error ($errormsg, $lvl=E_USER_WARNING) {
// append PHP's error message if track_errors enabled
if ( isset($php_errormsg) ) {
$errormsg .= " ($php_errormsg)";
}
if ( MAGPIE_DEBUG ) {
- trigger_error( $errormsg, $lvl);
- } else {
- error_log( $errormsg, 0);
- }
- }
-
-}
-
-function map_attrs($k, $v) {
- return "$k=\"$v\"";
-}
-
-require_once( dirname(__FILE__) . '/class-snoopy.php');
-
-function fetch_rss ($url) {
- // initialize constants
- init();
-
- if ( !isset($url) ) {
- // error("fetch_rss called without a url");
- return false;
- }
-
- // if cache is disabled
- if ( !MAGPIE_CACHE_ON ) {
- // fetch file, and parse it
- $resp = _fetch_remote_file( $url );
- if ( is_success( $resp->status ) ) {
- return _response_to_rss( $resp );
+ // trigger_error( $errormsg, $lvl);
}
else {
- // error("Failed to fetch $url and cache is off");
- return false;
+ error_log( $errormsg, 0);
}
- }
- // else cache is ON
- else {
- // Flow
- // 1. check cache
- // 2. if there is a hit, make sure its fresh
- // 3. if cached obj fails freshness check, fetch remote
- // 4. if remote fails, return stale object, or error
-
- $cache = new RSSCache( MAGPIE_CACHE_DIR, MAGPIE_CACHE_AGE );
- if (MAGPIE_DEBUG and $cache->ERROR) {
- debug($cache->ERROR, E_USER_WARNING);
+ $notices = E_USER_NOTICE|E_NOTICE;
+ if ( $lvl&$notices ) {
+ $this->WARNING = $errormsg;
+ } else {
+ $this->ERROR = $errormsg;
}
+ }
+ // Remove empty and |^_.*| object vars
+ function bathe() {
+ foreach ( get_object_vars($this) as $key => $data )
+ if ( empty($this->$key) || substr($key, 0, 1) == '_' )
+ unset($this->$key);
+ }
- $cache_status = 0; // response of check_cache
- $request_headers = array(); // HTTP headers to send with fetch
- $rss = 0; // parsed RSS object
- $errormsg = 0; // errors, if any
-
- if (!$cache->ERROR) {
- // return cache HIT, MISS, or STALE
- $cache_status = $cache->check_cache( $url );
- }
-
- // if object cached, and cache is fresh, return cached obj
- if ( $cache_status == 'HIT' ) {
- $rss = $cache->get( $url );
- if ( isset($rss) and $rss ) {
- $rss->from_cache = 1;
- if ( MAGPIE_DEBUG > 1) {
- debug("MagpieRSS: Cache HIT", E_USER_NOTICE);
- }
- return $rss;
+ // Remove ALL object vars
+ function scour() {
+ foreach ( get_object_vars($this) as $key => $data )
+ unset($this->$key);
+ }
+
+ function to_magpie() {
+ $magpie = new stdClass();
+
+ foreach ( $this as $var => $value ) {
+ if ( $var == 'feed' ) {
+ continue;
+ } else {
+ $magpie->$var = $this->$var;
}
}
- // else attempt a conditional get
-
- // setup headers
- if ( $cache_status == 'STALE' ) {
- $rss = $cache->get( $url );
- if ( $rss->etag and $rss->last_modified ) {
- $request_headers['If-None-Match'] = $rss->etag;
- $request_headers['If-Last-Modified'] = $rss->last_modified;
- }
- }
+ $magpie->items = array();
- $resp = _fetch_remote_file( $url, $request_headers );
+ if ( is_object($this->feed) && method_exists($this->feed, 'to_magpie') ) {
+ $feed = $this->feed->to_magpie();
- if (isset($resp) and $resp) {
- if ($resp->status == '304' ) {
- // we have the most current copy
- if ( MAGPIE_DEBUG > 1) {
- debug("Got 304 for $url");
- }
- // reset cache on 304 (at minutillo insistent prodding)
- $cache->set($url, $rss);
- return $rss;
- }
- elseif ( is_success( $resp->status ) ) {
- $rss = _response_to_rss( $resp );
- if ( $rss ) {
- if (MAGPIE_DEBUG > 1) {
- debug("Fetch successful");
- }
- // add object to cache
- $cache->set( $url, $rss );
- return $rss;
- }
- }
- else {
- $errormsg = "Failed to fetch $url. ";
- if ( $resp->error ) {
- # compensate for Snoopy's annoying habbit to tacking
- # on '\n'
- $http_error = substr($resp->error, 0, -2);
- $errormsg .= "(HTTP Error: $http_error)";
- }
- else {
- $errormsg .= "(HTTP Response: " . $resp->response_code .')';
+ if ( is_array($feed) ) {
+ foreach ( $this->feed->to_magpie() as $var => $val ) {
+ if ( $var == 'items' )
+ $magpie->items = $val;
+ else
+ $magpie->channel["$var"] = $val;
}
}
}
- else {
- $errormsg = "Unable to retrieve RSS file for unknown reasons.";
- }
- // else fetch failed
-
- // attempt to return cached object
- if ($rss) {
- if ( MAGPIE_DEBUG ) {
- debug("Returning STALE object for $url");
- }
- return $rss;
- }
+ return $magpie;
+ }
+}
- // else we totally failed
- // error( $errormsg );
- return false;
+class element {
+ function element() {
+ }
- } // end if ( !MAGPIE_CACHE_ON ) {
-} // end fetch_rss()
+ function start_element($p, $el, $attr, &$mag) {
+ $this->name = $el;
+ $this->attributes = $attr;
-function _fetch_remote_file ($url, $headers = "" ) {
- // Snoopy is an HTTP client in PHP
- $client = new Snoopy();
- $client->agent = MAGPIE_USER_AGENT;
- $client->read_timeout = MAGPIE_FETCH_TIME_OUT;
- $client->use_gzip = MAGPIE_USE_GZIP;
- if (is_array($headers) ) {
- $client->rawheaders = $headers;
+ array_unshift($mag->stack, $this);
+ }
+ function cdata($p, $data, &$mag) {
+ if ( empty($this->children) )
+ $this->appendText($data);
}
- @$client->fetch($url);
- return $client;
+ function end_element($p, $el, &$mag) {
+ array_shift($mag->stack);
-}
+ $this->bathe();
-function _response_to_rss ($resp) {
- $rss = new MagpieRSS( $resp->results );
-
- // if RSS parsed successfully
- if ( $rss and !$rss->ERROR) {
+ if ( is_object($mag->stack[0]) )
+ $mag->stack[0]->appendChild($this);
+ }
- // find Etag, and Last-Modified
- foreach($resp->headers as $h) {
- // 2003-03-02 - Nicola Asuni (www.tecnick.com) - fixed bug "Undefined offset: 1"
- if (strpos($h, ": ")) {
- list($field, $val) = explode(": ", $h, 2);
- }
- else {
- $field = $h;
- $val = "";
- }
+ function wrap_cdata() {
+ if ( strpos($this->innerText, '<') ) {
+ $spacer = (substr($this->innerText, -1) == ']') ? ' ' : '';
+ $this->innerText = str_replace(']]>', ']]&gt;', $this->innerText);
+ $this->innerText = '<![CDATA[' . $this->innerText . $spacer . ']]>';
+ }
+ }
- if ( $field == 'ETag' ) {
- $rss->etag = $val;
- }
+ function appendText($text) {
+ $this->innerText .= $text;
+ }
- if ( $field == 'Last-Modified' ) {
- $rss->last_modified = $val;
- }
- }
+ function appendChild($object) {
+ $this->children[] = & $object;
+ }
- return $rss;
- } // else construct error message
- else {
- $errormsg = "Failed to parse RSS file.";
+ // Add self to array
+ function to_array(&$array) {
+ $self = get_object_vars($this);
- if ($rss) {
- $errormsg .= " (" . $rss->ERROR . ")";
- }
- // error($errormsg);
+ unset($self['children']);
- return false;
- } // end if ($rss and !$rss->error)
-}
+ foreach ( $this->children as $child )
+ $child->to_array($self);
-/*=======================================================================*\
- Function: init
- Purpose: setup constants with default values
- check for user overrides
-\*=======================================================================*/
-function init () {
- if ( defined('MAGPIE_INITALIZED') ) {
- return;
- }
- else {
- define('MAGPIE_INITALIZED', 1);
+ $array[$this->name] = $self;
}
- if ( !defined('MAGPIE_CACHE_ON') ) {
- define('MAGPIE_CACHE_ON', 1);
+ // Return self as XML
+ function to_xml($indent = "\t", $generation = 0) {
+ $self = "<$this->name";
+ $self .= $this->attributes ? ' '.string_attributes($this->attributes) : '';
+ if ( empty($this->innerText) && empty($this->children) )
+ $self .= " />\n";
+ else {
+ $self .= ">";
+ if ( $this->children ) {
+ $self .= "\n";
+ foreach ( $this->children as $child )
+ $self .= $child->to_xml($indent, $generation + 1);
+ $self .= $indent ? $this->indent('', $indent, $generation) : '';
+ } else {
+ $self .= $this->innerText;
+ }
+ $self .= "</$this->name>\n";
+ }
+ return $indent ? $this->indent($self, $indent, $generation) : $self;
}
- if ( !defined('MAGPIE_CACHE_DIR') ) {
- define('MAGPIE_CACHE_DIR', './cache');
+ function indent($string, $indent, $generation) {
+ for ( $i = ''; strlen($i) < $generation; $i .= $indent ) ;
+ return $i . $string;
}
- if ( !defined('MAGPIE_CACHE_AGE') ) {
- define('MAGPIE_CACHE_AGE', 60*60); // one hour
+ /**
+ * Gets the innerText of the first matching element in the vars
+ * @param string Provide any number of strings to try
+ * @return mixed
+ */
+ function getChildText() {
+ foreach ( func_get_args() as $name )
+ foreach ( $this->children as $element )
+ if ( $element->name == $name )
+ return $element->innerText;
+ return false;
}
- if ( !defined('MAGPIE_CACHE_FRESH_ONLY') ) {
- define('MAGPIE_CACHE_FRESH_ONLY', 0);
+ /**
+ * Gets a ref to the first matching element
+ * @param string Provide any number of strings to try
+ * @return object
+ */
+ function &getChildElement() {
+ foreach ( func_get_args() as $name )
+ foreach ( $this->children as $key => $element )
+ if ( $element->name == $name )
+ return $this->children[$key];
+ return false;
}
- if ( !defined('MAGPIE_DEBUG') ) {
- define('MAGPIE_DEBUG', 0);
+ function getAttribute($name) {
+ if ( is_array($this->attributes) )
+ foreach ( $this->attributes as $attr => $value )
+ if ( $attr == $name )
+ return $value;
+ return null;
}
- if ( !defined('MAGPIE_USER_AGENT') ) {
- $ua = 'WordPress/' . $wp_version;
+ function bathe() {
+ foreach ( get_object_vars($this) as $var => $value )
+ if ( empty($this->$var) )
+ unset($this->$var);
+ }
- if ( MAGPIE_CACHE_ON ) {
- $ua = $ua . ')';
- }
- else {
- $ua = $ua . '; No cache)';
- }
+ function to_magpie() {
+ if ( strlen(trim($this->innerText)) > 0 )
+ return $this->innerText;
- define('MAGPIE_USER_AGENT', $ua);
- }
+ if ( is_array($this->attributes) )
+ $e = $this->attributes;
- if ( !defined('MAGPIE_FETCH_TIME_OUT') ) {
- define('MAGPIE_FETCH_TIME_OUT', 2); // 2 second timeout
- }
+ if ( is_array($this->children) && count($this->children) > 0 )
+ foreach ( $this->children as $k => $c )
+ $e[$k] = $this->children[$k]->to_magpie();
- // use gzip encoding to fetch rss files if supported?
- if ( !defined('MAGPIE_USE_GZIP') ) {
- define('MAGPIE_USE_GZIP', true);
+ return $e;
}
}
-function is_info ($sc) {
- return $sc >= 100 && $sc < 200;
-}
-
-function is_success ($sc) {
- return $sc >= 200 && $sc < 300;
-}
+// Base Atom class
+class feed extends element {
+ function end_element($p, $el, &$mag) {
+ $mag->feed = $this;
+ $mag->is_feed = true;
+ $mag->last_modified = $this->last_modified();
+ $mag->stack = array();
+ }
+ function last_modified() {
+ $time = parse_w3cdtf($this->getChildText('modified'));
+ return gmdate('D, d M Y H:i:s T', $time);
+ }
+ function to_magpie() {
+ foreach ( $this->children as $k => $c ) {
+ if ( $this->children[$k]->name == 'entry' )
+ $magpie['items'][] = $this->children[$k]->to_magpie();
+ else
+ $magpie[$this->children[$k]->name] = $this->children[$k]->innerText;
+ }
-function is_redirect ($sc) {
- return $sc >= 300 && $sc < 400;
+ return $magpie;
+ }
}
-function is_error ($sc) {
- return $sc >= 400 && $sc < 600;
+// RSS base class
+class rss extends feed {
+ function last_modified() {
+ $channel =& $this->getChildElement('channel');
+ $date = $channel->getChildText('pubDate', 'lastBuildDate');
+ return gmdate('D, d M Y H:i:s T', strtotime($date));
+ }
+ function to_magpie() {
+ return $this->children[0]->to_magpie();
+ }
}
+class rdf_rdf extends feed {
+ function to_magpie() {
+ $magpie = array();
+ foreach ( $this->children as $k => $child ) {
+ if ( $this->children[$k]->name == 'item' )
+ $magpie['items'][] = $this->children[$k]->to_magpie();
+ elseif ( method_exists($this->children[$k], 'to_magpie') )
+ $magpie[$this->children[$k]->name] = $this->children[$k]->to_magpie();
+ else
+ $magpie[$this->children[$k]->name] = $this->children[$k]->innerText;
+ }
+ if ( is_array($magpie['channel']) )
+ $magpie = array_merge($magpie['channel'], $magpie);
-function is_client_error ($sc) {
- return $sc >= 400 && $sc < 500;
+ return $magpie;
+ }
}
+class channel extends element {
+ function to_magpie() {
+ foreach ( $this->children as $k => $c ) {
+ if ( $this->children[$k]->name == 'item' )
+ $magpie['items'][] = $this->children[$k]->to_magpie();
+ else
+ $magpie[$this->children[$k]->name] = $this->children[$k]->innerText;
+ }
-function is_server_error ($sc) {
- return $sc >= 500 && $sc < 600;
+ return $magpie;
+ }
}
-class RSSCache {
- var $BASE_CACHE = 'wp-content/cache'; // where the cache files are stored
- var $MAX_AGE = 43200; // when are files stale, default twelve hours
- var $ERROR = ''; // accumulate error messages
-
- function RSSCache ($base='', $age='') {
- if ( $base ) {
- $this->BASE_CACHE = $base;
- }
- if ( $age ) {
- $this->MAX_AGE = $age;
+// Atom article class
+class entry extends element {
+ function to_magpie() {
+ foreach ( $this->children as $k => $v ) {
+ if ( is_object($this->children[$k]) )
+ $value = $this->children[$k]->to_magpie();
+ else
+ $value = $this->children[$k]->innerText;
+
+ $name = $this->children[$k]->name;
+
+ $norms = array(
+ 'dc:subject' => 'categories',
+ 'summary' => 'description',
+ );
+ $name = str_replace(array_keys($norms), array_values($norms), $name);
+
+ switch ( $name ) {
+ // The ones that needs to be dereferenced
+ case 'author':
+ $magpie[$name] = $value[0];
+ break;
+
+ // The ones that can be multiple
+ case 'categories':
+ $magpie[$name][] = $value;
+ break;
+
+ default:
+ $magpie[$name] = $value;
+ }
}
-
+ return $magpie;
}
-/*=======================================================================*\
- Function: set
- Purpose: add an item to the cache, keyed on url
- Input: url from wich the rss file was fetched
- Output: true on sucess
-\*=======================================================================*/
- function set ($url, $rss) {
- global $wpdb;
- $cache_option = 'rss_' . $this->file_name( $url );
- $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
+ function to_array(&$array) {
+ $self = get_object_vars($this);
- if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$cache_option'") )
- add_option($cache_option, '', '', 'no');
- if ( !$wpdb->get_var("SELECT option_name FROM $wpdb->options WHERE option_name = '$cache_timestamp'") )
- add_option($cache_timestamp, '', '', 'no');
+ unset($self['children']);
- update_option($cache_option, $rss);
- update_option($cache_timestamp, time() );
+ foreach ( $this->children as $child )
+ $child->to_array($self);
- return $cache_option;
+ $array['items'][] = $self;
}
+}
-/*=======================================================================*\
- Function: get
- Purpose: fetch an item from the cache
- Input: url from wich the rss file was fetched
- Output: cached object on HIT, false on MISS
-\*=======================================================================*/
- function get ($url) {
- $this->ERROR = "";
- $cache_option = 'rss_' . $this->file_name( $url );
-
- if ( ! get_option( $cache_option ) ) {
- $this->debug(
- "Cache doesn't contain: $url (cache option: $cache_option)"
- );
- return 0;
+// RSS article class
+class item extends entry {
+ function to_magpie() {
+ foreach ( $this->children as $k => $v ) {
+ if ( is_object($this->children[$k]) )
+ $value = $this->children[$k]->to_magpie();
+ else
+ $value = $this->children[$k]->innerText;
+
+ $name = $this->children[$k]->name;
+
+ $norms = array(
+ 'category' => 'categories',
+ 'content:encoded' => 'content',
+ 'dc:creator' => 'author',
+ 'wfw:commentRss' => 'comments',
+ 'wfw:commentRSS' => 'comments',
+ 'pubDate' => 'pubdate',
+ );
+ $name = str_replace(array_keys($norms), array_values($norms), $name);
+
+ switch ( $name ) {
+ // The ones that needs to be dereferenced
+ case 'taxo:topics':
+ $magpie[$name] = $value[0];
+ break;
+
+ // The ones that can be multiple
+ case 'categories':
+ $magpie[$name][] = $value;
+ break;
+
+ default:
+ $magpie[$name] = $value;
+ }
}
+ return $magpie;
+ }
+}
- $rss = get_option( $cache_option );
+class category extends element {
+ function to_array(&$array) {
+ $self = get_object_vars($this);
- return $rss;
- }
+ unset($self['children']);
-/*=======================================================================*\
- Function: check_cache
- Purpose: check a url for membership in the cache
- and whether the object is older then MAX_AGE (ie. STALE)
- Input: url from wich the rss file was fetched
- Output: cached object on HIT, false on MISS
-\*=======================================================================*/
- function check_cache ( $url ) {
- $this->ERROR = "";
- $cache_option = $this->file_name( $url );
- $cache_timestamp = 'rss_' . $this->file_name( $url ) . '_ts';
+ foreach ( $this->children as $child )
+ $child->to_array($self);
- if ( $mtime = get_option($cache_timestamp) ) {
- // find how long ago the file was added to the cache
- // and whether that is longer then MAX_AGE
- $age = time() - $mtime;
- if ( $this->MAX_AGE > $age ) {
- // object exists and is current
- return 'HIT';
- }
- else {
- // object exists but is old
- return 'STALE';
- }
- }
- else {
- // object does not exist
- return 'MISS';
- }
+ $array['categories'][] = $self;
}
+}
-/*=======================================================================*\
- Function: serialize
-\*=======================================================================*/
- function serialize ( $rss ) {
- return serialize( $rss );
- }
+class link extends element {
+ function end_element($p, $el, &$mag) {
+ if ( $href = $this->getAttribute('href') )
+ $this->innerText = $href;
-/*=======================================================================*\
- Function: unserialize
-\*=======================================================================*/
- function unserialize ( $data ) {
- return unserialize( $data );
+ parent::end_element($p, $el, $mag);
}
+}
-/*=======================================================================*\
- Function: file_name
- Purpose: map url to location in cache
- Input: url from wich the rss file was fetched
- Output: a file name
-\*=======================================================================*/
- function file_name ($url) {
- return md5( $url );
- }
-/*=======================================================================*\
- Function: error
- Purpose: register error
-\*=======================================================================*/
- function error ($errormsg, $lvl=E_USER_WARNING) {
- // append PHP's error message if track_errors enabled
- if ( isset($php_errormsg) ) {
- $errormsg .= " ($php_errormsg)";
- }
- $this->ERROR = $errormsg;
- if ( MAGPIE_DEBUG ) {
- trigger_error( $errormsg, $lvl);
- }
- else {
- error_log( $errormsg, 0);
- }
- }
- function debug ($debugmsg, $lvl=E_USER_NOTICE) {
- if ( MAGPIE_DEBUG ) {
- $this->error("MagpieRSS [debug] $debugmsg", $lvl);
- }
- }
+/* Version 0.9, 6th April 2003 - Simon Willison ( http://simon.incutio.com/ )
+ Manual: http://scripts.incutio.com/httpclient/
+*/
+
+if ( !class_exists('HttpClient') ) :
+class HttpClient {
+ // Request vars
+ var $host;
+ var $port;
+ var $path;
+ var $method;
+ var $postdata = '';
+ var $cookies = array();
+ var $referer;
+ var $accept = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,image/jpeg,image/gif,*/*';
+ var $accept_encoding = 'gzip';
+ var $accept_language = 'en-us';
+ var $user_agent = 'Incutio HttpClient v0.9';
+ // Options
+ var $timeout = 20;
+ var $use_gzip = true;
+ var $no_cache = false;
+ var $persist_cookies = true; // If true, received cookies are placed in the $this->cookies array ready for the next request
+ // Note: This currently ignores the cookie path (and time) completely. Time is not important,
+ // but path could possibly lead to security problems.
+ var $persist_referers = true; // For each request, sends path of last request as referer
+ var $debug = false;
+ var $handle_redirects = true; // Auaomtically redirect if Location or URI header is found
+ var $max_redirects = 5;
+ var $headers_only = false; // If true, stops receiving once headers have been read.
+ // Basic authorization variables
+ var $username;
+ var $password;
+ // Response vars
+ var $status;
+ var $headers = array();
+ var $content = '';
+ var $errormsg;
+ // Tracker variables
+ var $redirect_count = 0;
+ var $cookie_host = '';
+ function HttpClient($host, $port=80) {
+ $this->host = $host;
+ $this->port = $port;
+ }
+ function get($path, $data = false) {
+ $this->path = $path;
+ $this->method = 'GET';
+ if ($data) {
+ $this->path .= '?'.$this->buildQueryString($data);
+ }
+ return $this->doRequest();
+ }
+ function post($path, $data) {
+ $this->path = $path;
+ $this->method = 'POST';
+ $this->postdata = $this->buildQueryString($data);
+ return $this->doRequest();
+ }
+ function buildQueryString($data) {
+ $querystring = '';
+ if (is_array($data)) {
+ // Change data in to postable data
+ foreach ($data as $key => $val) {
+ if (is_array($val)) {
+ foreach ($val as $val2) {
+ $querystring .= urlencode($key).'='.urlencode($val2).'&';
+ }
+ } else {
+ $querystring .= urlencode($key).'='.urlencode($val).'&';
+ }
+ }
+ $querystring = substr($querystring, 0, -1); // Eliminate unnecessary &
+ } else {
+ $querystring = $data;
+ }
+ return $querystring;
+ }
+ function doRequest() {
+ // Performs the actual HTTP request, returning true or false depending on outcome
+ if (!$fp = @fsockopen($this->host, $this->port, $errno, $errstr, $this->timeout)) {
+ // Set error message
+ switch($errno) {
+ case -3:
+ $this->errormsg = 'Socket creation failed (-3)';
+ case -4:
+ $this->errormsg = 'DNS lookup failure (-4)';
+ case -5:
+ $this->errormsg = 'Connection refused or timed out (-5)';
+ default:
+ $this->errormsg = 'Connection failed ('.$errno.')';
+ $this->errormsg .= ' '.$errstr;
+ $this->debug($this->errormsg);
+ }
+ return false;
+ }
+ socket_set_timeout($fp, $this->timeout);
+ $request = $this->buildRequest();
+ $this->debug('Request', $request);
+ fwrite($fp, $request);
+ // Reset all the variables that should not persist between requests
+ $this->headers = array();
+ $this->content = '';
+ $this->errormsg = '';
+ // Set a couple of flags
+ $inHeaders = true;
+ // Now start reading back the response
+ $line = fgets($fp, 4096);
+ // Deal with first line of returned data
+ if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) {
+ $this->errormsg = "Status code line invalid: ".htmlentities($line);
+ $this->debug($this->errormsg);
+ return false;
+ }
+ $http_version = $m[1]; // not used
+ $this->status = $m[2];
+ $status_string = $m[3]; // not used
+ $this->debug(trim($line));
+ while (!feof($fp)) {
+ $line = fgets($fp, 4096);
+ if ($inHeaders) {
+ if (trim($line) == '') {
+ $inHeaders = false;
+ $this->debug('Received Headers', $this->headers);
+ if ($this->headers_only) {
+ break; // Skip the rest of the input
+ }
+ continue;
+ }
+ if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) {
+ // Skip to the next header
+ continue;
+ }
+ $key = strtolower(trim($m[1]));
+ $val = trim($m[2]);
+ // Deal with the possibility of multiple headers of same name
+ if (isset($this->headers[$key])) {
+ if (is_array($this->headers[$key])) {
+ $this->headers[$key][] = $val;
+ } else {
+ $this->headers[$key] = array($this->headers[$key], $val);
+ }
+ } else {
+ $this->headers[$key] = $val;
+ }
+ continue;
+ }
+ // We're not in the headers, so append the line to the contents
+ $this->content .= $line;
+ }
+ fclose($fp);
+ // If data is compressed, uncompress it
+ if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] == 'gzip') {
+ $this->debug('Content is gzip encoded, unzipping it');
+ $this->content = substr($this->content, 10); // See http://www.php.net/manual/en/function.gzencode.php
+ $this->content = gzinflate($this->content);
+ }
+ // If $persist_cookies, deal with any cookies
+ if ($this->persist_cookies && isset($this->headers['set-cookie']) && $this->host == $this->cookie_host) {
+ $cookies = $this->headers['set-cookie'];
+ if (!is_array($cookies)) {
+ $cookies = array($cookies);
+ }
+ foreach ($cookies as $cookie) {
+ if (preg_match('/([^=]+)=([^;]+);/', $cookie, $m)) {
+ $this->cookies[$m[1]] = $m[2];
+ }
+ }
+ // Record domain of cookies for security reasons
+ $this->cookie_host = $this->host;
+ }
+ // If $persist_referers, set the referer ready for the next request
+ if ($this->persist_referers) {
+ $this->debug('Persisting referer: '.$this->getRequestURL());
+ $this->referer = $this->getRequestURL();
+ }
+ // Finally, if handle_redirects and a redirect is sent, do that
+ if ($this->handle_redirects) {
+ if (++$this->redirect_count >= $this->max_redirects) {
+ $this->errormsg = 'Number of redirects exceeded maximum ('.$this->max_redirects.')';
+ $this->debug($this->errormsg);
+ $this->redirect_count = 0;
+ return false;
+ }
+ $location = isset($this->headers['location']) ? $this->headers['location'] : '';
+ $uri = isset($this->headers['uri']) ? $this->headers['uri'] : '';
+ if ($location || $uri) {
+ $url = parse_url($location.$uri);
+ // This will FAIL if redirect is to a different site
+ return $this->get($url['path']);
+ }
+ }
+ return true;
+ }
+ function buildRequest() {
+ $headers = array();
+ $headers[] = "{$this->method} {$this->path} HTTP/1.0"; // Using 1.1 leads to all manner of problems, such as "chunked" encoding
+ $headers[] = "Host: {$this->host}";
+ $headers[] = "User-Agent: {$this->user_agent}";
+ $headers[] = "Accept: {$this->accept}";
+ if ($this->use_gzip) {
+ $headers[] = "Accept-encoding: {$this->accept_encoding}";
+ }
+ $headers[] = "Accept-language: {$this->accept_language}";
+ if ($this->referer) {
+ $headers[] = "Referer: {$this->referer}";
+ }
+ if ($this->no_cache) {
+ $headers[] = "Pragma: no-cache";
+ $headers[] = "Cache-control: no-cache";
+ }
+ // Cookies
+ if ($this->cookies) {
+ $cookie = 'Cookie: ';
+ foreach ($this->cookies as $key => $value) {
+ $cookie .= "$key=$value; ";
+ }
+ $headers[] = $cookie;
+ }
+ // Basic authentication
+ if ($this->username && $this->password) {
+ $headers[] = 'Authorization: BASIC '.base64_encode($this->username.':'.$this->password);
+ }
+ // If this is a POST, set the content type and length
+ if ($this->postdata) {
+ $headers[] = 'Content-Type: application/x-www-form-urlencoded';
+ $headers[] = 'Content-Length: '.strlen($this->postdata);
+ }
+ $request = implode("\r\n", $headers)."\r\n\r\n".$this->postdata;
+ return $request;
+ }
+ function getStatus() {
+ return $this->status;
+ }
+ function getContent() {
+ return $this->content;
+ }
+ function getHeaders() {
+ return $this->headers;
+ }
+ function getHeader($header) {
+ $header = strtolower($header);
+ if (isset($this->headers[$header])) {
+ return $this->headers[$header];
+ } else {
+ return false;
+ }
+ }
+ function getError() {
+ return $this->errormsg;
+ }
+ function getCookies() {
+ return $this->cookies;
+ }
+ function getRequestURL() {
+ $url = 'http://'.$this->host;
+ if ($this->port != 80) {
+ $url .= ':'.$this->port;
+ }
+ $url .= $this->path;
+ return $url;
+ }
+ // Setter methods
+ function setUserAgent($string) {
+ $this->user_agent = $string;
+ }
+ function setAuthorization($username, $password) {
+ $this->username = $username;
+ $this->password = $password;
+ }
+ function setCookies($array) {
+ $this->cookies = $array;
+ }
+ // Option setting methods
+ function useGzip($boolean) {
+ $this->use_gzip = $boolean;
+ }
+ function setPersistCookies($boolean) {
+ $this->persist_cookies = $boolean;
+ }
+ function setPersistReferers($boolean) {
+ $this->persist_referers = $boolean;
+ }
+ function setHandleRedirects($boolean) {
+ $this->handle_redirects = $boolean;
+ }
+ function setMaxRedirects($num) {
+ $this->max_redirects = $num;
+ }
+ function setHeadersOnly($boolean) {
+ $this->headers_only = $boolean;
+ }
+ function setDebug($boolean) {
+ $this->debug = $boolean;
+ }
+ // "Quick" static methods
+ function quickGet($url) {
+ $bits = parse_url($url);
+ $host = $bits['host'];
+ $port = isset($bits['port']) ? $bits['port'] : 80;
+ $path = isset($bits['path']) ? $bits['path'] : '/';
+ if (isset($bits['query'])) {
+ $path .= '?'.$bits['query'];
+ }
+ $client = new HttpClient($host, $port);
+ if (!$client->get($path)) {
+ return false;
+ } else {
+ return $client->getContent();
+ }
+ }
+ function quickPost($url, $data) {
+ $bits = parse_url($url);
+ $host = $bits['host'];
+ $port = isset($bits['port']) ? $bits['port'] : 80;
+ $path = isset($bits['path']) ? $bits['path'] : '/';
+ $client = new HttpClient($host, $port);
+ if (!$client->post($path, $data)) {
+ return false;
+ } else {
+ return $client->getContent();
+ }
+ }
+ function debug($msg, $object = false) {
+ if ($this->debug) {
+ print '<div style="border: 1px solid red; padding: 0.5em; margin: 0.5em;"><strong>HttpClient Debug:</strong> '.$msg;
+ if ($object) {
+ ob_start();
+ print_r($object);
+ $content = htmlentities(ob_get_contents());
+ ob_end_clean();
+ print '<pre>'.$content.'</pre>';
+ }
+ print '</div>';
+ }
+ }
}
+endif;
-function parse_w3cdtf ( $date_str ) {
+function string_attributes($attrs) {
+ return join(' ', array_map(create_function('$k,$v', 'return "$k=\"".htmlspecialchars($v)."\"";'), array_keys($attrs), array_values($attrs) ) );
+}
+if ( !function_exists('parse_w3cdtf') ) :
+function parse_w3cdtf ( $date_str ) {
# regex to match wc3dtf
$pat = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(:(\d{2}))?(?:([-+])(\d{2}):?(\d{2})|(Z))?/";
if ( preg_match( $pat, $date_str, $match ) ) {
- list( $year, $month, $day, $hours, $minutes, $seconds) =
- array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[6]);
+ list( $year, $month, $day, $hours, $minutes, $seconds) =
+ array( $match[1], $match[2], $match[3], $match[4], $match[5], $match[7]);
# calc epoch for current date assuming GMT
$epoch = gmmktime( $hours, $minutes, $seconds, $month, $day, $year);
@@ -798,7 +1164,7 @@ function parse_w3cdtf ( $date_str ) {
}
else {
list( $tz_mod, $tz_hour, $tz_min ) =
- array( $match[8], $match[9], $match[10]);
+ array( $match[8], $match[9], $match[10]);
# zero out the variables
if ( ! $tz_hour ) { $tz_hour = 0; }
@@ -820,42 +1186,7 @@ function parse_w3cdtf ( $date_str ) {
else {
return -1;
}
- }
-function wp_rss ($url, $num) {
- //ini_set("display_errors", false); uncomment to suppress php errors thrown if the feed is not returned.
- $num_items = $num;
- $rss = fetch_rss($url);
- if ( $rss ) {
- echo "<ul>";
- $rss->items = array_slice($rss->items, 0, $num_items);
- foreach ($rss->items as $item ) {
- echo "<li>\n";
- echo "<a href='$item[link]' title='$item[description]'>";
- echo htmlentities($item['title']);
- echo "</a><br />\n";
- echo "</li>\n";
- }
- echo "</ul>";
- }
- else {
- echo "an error has occured the feed is probably down, try again later.";
- }
}
+endif;
-function get_rss ($uri, $num = 5) { // Like get posts, but for RSS
- $rss = fetch_rss($url);
- if ( $rss ) {
- $rss->items = array_slice($rss->items, 0, $num_items);
- foreach ($rss->items as $item ) {
- echo "<li>\n";
- echo "<a href='$item[link]' title='$item[description]'>";
- echo htmlentities($item['title']);
- echo "</a><br />\n";
- echo "</li>\n";
- }
- return $posts;
- } else {
- return false;
- }
-}
?>
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index f7be9e0..71bd56c 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -15,8 +15,8 @@ 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, '04162006' );
- $this->add( 'wp_tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('tiny_mce'), '04162006' );
+ $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '06262006a' );
+ $this->add( 'wp_tiny_mce', '/wp-includes/js/tinymce/tiny_mce_config.php', array('tiny_mce'), '06262006a' );
if ( is_admin() ) {
$this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' );
$this->add( 'listman', '/wp-admin/list-manipulation-js.php', array('sack', 'fat'), '3850' ); // Make changeset # the correct one
@@ -62,7 +62,7 @@ class WP_Scripts {
if ( !in_array($handle, $this->printed) && isset($this->scripts[$handle]) ) {
$ver = $this->scripts[$handle]->ver ? $this->scripts[$handle]->ver : $wp_db_version;
if ( isset($this->args[$handle]) )
- $ver .= '&' . $this->args[$handle];
+ $ver .= '&amp;' . $this->args[$handle];
$src = 0 === strpos($this->scripts[$handle]->src, 'http://') ? $this->scripts[$handle]->src : get_settings( 'siteurl' ) . $this->scripts[$handle]->src;
echo "<script type='text/javascript' src='$src?ver=$ver'></script>\n";
$this->printed[] = $handle;
diff --git a/wp-login.php b/wp-login.php
index 86c5912..87c765f 100644
--- a/wp-login.php
+++ b/wp-login.php
@@ -30,7 +30,7 @@ case 'logout':
$redirect_to = 'wp-login.php';
if ( isset($_REQUEST['redirect_to']) )
- $redirect_to = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $_REQUEST['redirect_to']);
+ $redirect_to = $_REQUEST['redirect_to'];
wp_redirect($redirect_to);
exit();
@@ -173,7 +173,6 @@ default:
$redirect_to = 'wp-admin/';
else
$redirect_to = $_REQUEST['redirect_to'];
- $redirect_to = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $redirect_to);
if( $_POST ) {
$user_login = $_POST['log'];
@@ -242,7 +241,7 @@ if ( $error ) {
<?php _e('Remember me'); ?></label></p>
<p class="submit">
<input type="submit" name="submit" id="submit" value="<?php _e('Login'); ?> &raquo;" tabindex="4" />
- <input type="hidden" name="redirect_to" value="<?php echo $redirect_to; ?>" />
+ <input type="hidden" name="redirect_to" value="<?php echo wp_specialchars($redirect_to); ?>" />
</p>
</form>
<ul>
diff --git a/wp-trackback.php b/wp-trackback.php
index 00eabeb..cf93844 100644
--- a/wp-trackback.php
+++ b/wp-trackback.php
@@ -55,7 +55,7 @@ if ( !intval( $tb_id ) )
if (empty($title) && empty($tb_url) && empty($blog_name)) {
// If it doesn't look like a trackback at all...
- header('Location: ' . get_permalink($tb_id));
+ wp_redirect(get_permalink($tb_id));
exit;
}
diff --git a/xmlrpc.php b/xmlrpc.php
index 0b7e1a4..8127c2c 100644
--- a/xmlrpc.php
+++ b/xmlrpc.php
@@ -1228,16 +1228,16 @@ class wp_xmlrpc_server extends IXR_Server {
$pagelinkedfrom = $wpdb->escape( $pagelinkedfrom );
$original_title = $title;
- $comment_post_ID = $post_ID;
- $comment_author = $title;
+ $comment_post_ID = (int) $post_ID;
+ $comment_author = $this->escape($title);
$comment_author_url = $pagelinkedfrom;
- $comment_content = $context;
+ $comment_content = $this->escape($context);
$comment_type = 'pingback';
$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_content', 'comment_type');
- wp_new_comment($commentdata);
- do_action('pingback_post', $wpdb->insert_id);
+ $comment_ID = wp_new_comment($commentdata);
+ do_action('pingback_post', $comment_ID);
return "Pingback from $pagelinkedfrom to $pagelinkedto registered. Keep the web talking! :-)";
}