Make WordPress Core

Changes in trunk [3503:4431]


Ignore:
Location:
trunk
Files:
116 added
23 deleted
155 edited

Legend:

Unmodified
Added
Removed
  • trunk/readme.html

    r3503 r4431  
    22<html xmlns="http://www.w3.org/1999/xhtml">
    33<head>
    4 <title>WordPress &rsaquo; ReadMe</title>
    5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    6 <style type="text/css" media="screen">
    7     <!--
    8     html {
    9         background: #eee;
    10     }
    11     body {
    12         background: #fff;
    13         color: #000;
    14         font-family: Georgia, "Times New Roman", Times, serif;
    15         margin-left: 25%;
    16         margin-right: 25%;
    17         padding: .2em 2em;
    18     }
    19    
    20     h1 {
    21         color: #006;
    22         font-size: 18px;
    23         font-weight: lighter;
    24     }
    25    
    26     h2 {
    27         font-size: 16px;
    28     }
    29    
    30     p, li, dt {
    31         line-height: 140%;
    32         padding-bottom: 2px;
    33     }
    34 
    35     ul, ol {
    36         padding: 5px 5px 5px 20px;
    37     }
    38     -->
    39     </style>
     4    <title>WordPress &rsaquo; ReadMe</title>
     5    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     6    <link rel="stylesheet" href="wp-admin/install.css" type="text/css" />
    407</head>
    418<body>
    42 <h1 style="text-align: center"><img alt="WordPress" src="http://wordpress.org/images/wordpress.gif" /> <br />
    43     Version 2.0</h1>
    44 <p style="text-align: center"> Semantic Personal Publishing Platform </p>
     9<h1 id="logo" style="text-align: center">
     10    <img alt="WordPress" src="wp-admin/images/wordpress-logo.png" />
     11    <br /> Version 2.1-ALPHA
     12</h1>
     13<p style="text-align: center">Semantic Personal Publishing Platform</p>
     14
    4515<h1>First Things First</h1>
    4616<p>Welcome. WordPress is a very special project to me. Every developer and contributor adds something unique to the mix, and together we create something beautiful that I'm proud to be a part of. Thousands of hours have gone into WordPress, and we're dedicated to making it better every day. Thank you for making it part of your world.</p>
    4717<p style="text-align: right;">&#8212; Matt Mullenweg </p>
    4818
    49 <h1 id="installation">Installation: Famous 5-minute install</h1>
     19<h1>Installation: Famous 5-minute install</h1>
    5020<ol>
    5121    <li>Unzip the package in an empty directory</li>
     
    6939<h2>Template Changes</h2>
    7040<p>If you have customized your templates you will probably have to make some changes to them. If you're converting your 1.2 or earlier templates, <a href="http://codex.wordpress.org/Upgrade_1.2_to_1.5">we've created a special guide for you</a>. </p>
     41
    7142<h1>Online Resources</h1>
    7243<p>If you have any questions that aren't addressed in this document, please take advantage of WordPress' numerous online resources:</p>
    7344<dl>
    7445    <dt><a href="http://codex.wordpress.org/">The WordPress Codex </a></dt>
    75     <dd>The Codex is the encyclopedia of all things WordPress. It is the most comprehensive source of information for WordPress available. </dd>
     46        <dd>The Codex is the encyclopedia of all things WordPress. It is the most comprehensive source of information for WordPress available. </dd>
    7647    <dt><a href="http://wordpress.org/development/">The Development Blog</a></dt>
    77     <dd>This is where you'll find the latest updates and news related to WordPress. Bookmark and check often. </dd>
     48        <dd>This is where you'll find the latest updates and news related to WordPress. Bookmark and check often. </dd>
    7849    <dt><a href="http://planet.wordpress.org/">WordPress Planet </a></dt>
    79     <dd>The WordPress Planet is a news aggregator that brings together posts from WordPress blogs around the web. </dd>
     50        <dd>The WordPress Planet is a news aggregator that brings together posts from WordPress blogs around the web. </dd>
    8051    <dt><a href="http://wordpress.org/support/">WordPress Support Forums</a></dt>
    81     <dd>If you've looked everywhere and still can't find an answer, the support forums are very active and have a large community ready to help. To help them help you be sure to use a descriptive thread title and describe your question in as much detail as possible. </dd>
     52        <dd>If you've looked everywhere and still can't find an answer, the support forums are very active and have a large community ready to help. To help them help you be sure to use a descriptive thread title and describe your question in as much detail as possible. </dd>
    8253    <dt><a href="http://codex.wordpress.org/IRC">WordPress IRC Channel</a></dt>
    83     <dd>Finally, there is an online chat channel that is used for discussion amoung people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. (irc.freenode.net #wordpresss) </dd>
     54        <dd>Finally, there is an online chat channel that is used for discussion amoung people who use WordPress and occasionally support topics. The above wiki page should point you in the right direction. (irc.freenode.net #wordpresss) </dd>
    8455</dl>
    8556
    86 <h1 id="requirements">System Recommendations</h1>
     57<h1>System Recommendations</h1>
    8758<ul>
    8859    <li>PHP version <strong>4.1</strong> or higher</li>
     
    9566<p>WordPress can <a href="http://codex.wordpress.org/Importing_from_other_blogging_software">import from a number of systems</a>. First you need to get WordPress installed and working as described above.</p>
    9667
    97 <h1 id="templates">XML-RPC Interface</h1>
     68<h1>XML-RPC Interface</h1>
    9869<p>You can now post to your WordPress blog with tools like <a href="http://ecto.kung-foo.tv/">Ecto</a>, <a href="http://blogbuddy.sourceforge.net">BlogBuddy</a>, <a href="http://bloggar.com/">Bloggar</a>, <a href="http://www.ubique.ch/wapblogger/">WapBlogger</a> (post from your Wap cellphone!), <a href="http://radio.userland.com">Radio Userland</a> (which means you can use Radio's email-to-blog feature), <a href="http://www.zempt.com/">Zempt</a>, <a href="http://www.newzcrawler.com/">NewzCrawler</a>, and other tools that support the Blogging APIs! :) You can read more about <a href="http://codex.wordpress.org/XML-RPC_Support">XML-RPC support on the Codex</a>.</p>
    9970
    10071<h1>Post via Email</h1>
    101 <p>You can post from an email client! To set this up go to your &quot;Writing&quot; options screen and fill in the connection details for your secret POP3 account. Then you need to set up <code>wp-mail.php</code> to execute periodically to check the mailbox for new posts. You can do it with Cron-jobs, or if your host doesn't support it you can look into the various website-monitoring services, and make them check your <code>wp-mail.php</code> URL. </p>
    102 <p> Posting is easy: Any email sent to the address you specify will be posted, with the subject as the title. It is best to keep the address dicrete. The script will <i>delete</i> emails that are successfully posted. </p>
    103 <h1 id="roles">User Roles </h1>
     72<p>You can post from an email client! To set this up go to your &quot;Writing&quot; options screen and fill in the connection details for your secret POP3 account. Then you need to set up <code>wp-mail.php</code> to execute periodically to check the mailbox for new posts. You can do it with Cron-jobs, or if your host doesn't support it you can look into the various website-monitoring services, and make them check your <code>wp-mail.php</code> URL.</p>
     73<p>Posting is easy: Any email sent to the address you specify will be posted, with the subject as the title. It is best to keep the address dicrete. The script will <i>delete</i> emails that are successfully posted.</p>
    10474
     75<h1>User Roles</h1>
    10576<p>We've eliminated user levels in order to make way for the much more flexible roles system introduced in 2.0. You can <a href="http://codex.wordpress.org/Roles_and_Capabilities">read more about Roles and Capabilities on the Codex</a>.</p>
    10677
  • trunk/wp-admin/admin-db.php

    r3503 r4431  
    44    global $wpdb;
    55    $user_id = (int) $user_id;
    6     $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author = $user_id ORDER BY ID DESC";
     6    $query = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author = $user_id ORDER BY ID DESC";
    77    $query = apply_filters('get_users_drafts', $query);
    88    return $wpdb->get_results( $query );
     
    1515
    1616    $editable = get_editable_user_ids( $user_id );
    17    
     17
    1818    if( !$editable ) {
    1919        $other_drafts = '';
    2020    } else {
    2121        $editable = join(',', $editable);
    22         $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'draft' AND post_author IN ($editable) AND post_author != '$user_id' ");
     22        $other_drafts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft' AND post_author IN ($editable) AND post_author != '$user_id' ");
    2323    }
    2424
     
    3535    } else {
    3636        $editable = join(',', $editable);
    37         $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable)" );
     37        $authors = $wpdb->get_results( "SELECT * FROM $wpdb->users WHERE ID IN ($editable) ORDER BY display_name" );
    3838    }
    3939
     
    4343function get_editable_user_ids( $user_id, $exclude_zeros = true ) {
    4444    global $wpdb;
    45    
     45
    4646    $user = new WP_User( $user_id );
    47    
     47
    4848    if ( ! $user->has_cap('edit_others_posts') ) {
    4949        if ( $user->has_cap('edit_posts') || $exclude_zeros == false )
     
    5858    if ( $exclude_zeros )
    5959        $query .= " AND meta_value != '0'";
    60        
     60
    6161    return $wpdb->get_col( $query );
    6262}
     
    8484
    8585    extract($catarr);
     86
     87    if( trim( $cat_name ) == '' )
     88        return 0;
    8689
    8790    $cat_ID = (int) $cat_ID;
     
    9396        $update = false;
    9497
    95     $cat_name = wp_specialchars($cat_name);
    96 
     98    $cat_name = apply_filters('pre_category_name', $cat_name);
     99   
    97100    if (empty ($category_nicename))
    98101        $category_nicename = sanitize_title($cat_name);
    99102    else
    100103        $category_nicename = sanitize_title($category_nicename);
     104    $category_nicename = apply_filters('pre_category_nicename', $category_nicename);
    101105
    102106    if (empty ($category_description))
    103107        $category_description = '';
    104 
    105     if (empty ($category_parent))
     108    $category_description = apply_filters('pre_category_description', $category_description);
     109
     110    $category_parent = (int) $category_parent;
     111    if ( empty($category_parent) || !get_category( $category_parent ) || $category_parent == $cat_ID )
    106112        $category_parent = 0;
    107113
     114    if ( isset($posts_private) )
     115        $posts_private = (int) $posts_private;
     116    else
     117        $posts_private = 0;
     118
     119    if ( isset($links_private) )
     120        $links_private = (int) $links_private;
     121    else
     122        $links_private = 0;
     123
    108124    if (!$update) {
    109         $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent')");
     125        $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent, links_private, posts_private) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$category_parent', '$links_private', '$posts_private')");
    110126        $cat_ID = $wpdb->insert_id;
    111127    } else {
    112         $wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent' WHERE cat_ID = '$cat_ID'");
    113     }
    114    
     128        $wpdb->query ("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$category_parent', links_private = '$links_private', posts_private = '$posts_private' WHERE cat_ID = '$cat_ID'");
     129    }
     130
    115131    if ( $category_nicename == '' ) {
    116132        $category_nicename = sanitize_title($cat_name, $cat_ID );
     
    154170
    155171    // Don't delete the default cat.
    156     if (1 == $cat_ID)
     172    if ( $cat_ID == get_option('default_category') )
     173        return 0;
     174
     175    if ( $cat_ID == get_option('default_link_category') )
    157176        return 0;
    158177
     
    162181
    163182    // Delete the category.
    164     $wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'");
     183    if ( !$wpdb->query("DELETE FROM $wpdb->categories WHERE cat_ID = '$cat_ID'") )
     184        return 0;
    165185
    166186    // Update children to point to new parent.
    167187    $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'");
    168188
    169     // TODO: Only set categories to general if they're not in another category already
    170     $wpdb->query("UPDATE $wpdb->post2cat SET category_id='1' WHERE category_id='$cat_ID'");
    171 
     189    // Only set posts and links to the default category if they're not in another category already.
     190    $default_cat = get_option('default_category');
     191    $posts = $wpdb->get_col("SELECT post_id FROM $wpdb->post2cat WHERE category_id='$cat_ID'");
     192    if ( is_array($posts) ) foreach ($posts as $post_id) {
     193        $cats = wp_get_post_categories($post_id);
     194        if ( 1 == count($cats) )
     195            $cats = array($default_cat);
     196        else
     197            $cats = array_diff($cats, array($cat_ID));
     198        wp_set_post_categories($post_id, $cats);
     199    }
     200
     201    $default_link_cat = get_option('default_link_category');
     202    $links = $wpdb->get_col("SELECT link_id FROM $wpdb->link2cat WHERE category_id='$cat_ID'");
     203    if ( is_array($links) ) foreach ($links as $link_id) {
     204        $cats = wp_get_link_cats($link_id);
     205        if ( 1 == count($cats) )
     206            $cats = array($default_link_cat);
     207        else
     208            $cats = array_diff($cats, array($cat_ID));
     209        wp_set_link_cats($link_id, $cats);
     210    }
     211   
    172212    wp_cache_delete($cat_ID, 'category');
    173213    wp_cache_delete('all_category_ids', 'category');
     
    194234
    195235    if ($post_id)
    196         wp_set_post_cats('', $post_id, $cat_ids);
     236        wp_set_post_categories($post_id, $cat_ids);
    197237
    198238    return $cat_ids;
     
    230270
    231271    // FINALLY, delete user
     272    do_action('delete_user', $id);
     273
    232274    $wpdb->query("DELETE FROM $wpdb->users WHERE ID = $id");
    233275    $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$id'");
     
    236278    wp_cache_delete($user->user_login, 'userlogins');
    237279
    238     do_action('delete_user', $id);
    239 
    240280    return true;
    241281}
    242282
    243 function get_link($link_id, $output = OBJECT) {
    244     global $wpdb;
     283function wp_revoke_user($id) {
     284    $id = (int) $id;
    245285   
    246     $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = '$link_id'");
    247 
    248     if ( $output == OBJECT ) {
    249         return $link;
    250     } elseif ( $output == ARRAY_A ) {
    251         return get_object_vars($link);
    252     } elseif ( $output == ARRAY_N ) {
    253         return array_values(get_object_vars($link));
    254     } else {
    255         return $link;
    256     }
     286    $user = new WP_User($id);
     287    $user->remove_all_caps();   
    257288}
    258289
    259290function wp_insert_link($linkdata) {
    260291    global $wpdb, $current_user;
    261    
     292
    262293    extract($linkdata);
    263294
    264295    $update = false;
     296
    265297    if ( !empty($link_id) )
    266298        $update = true;
    267299
     300    if( trim( $link_name ) == '' )
     301        return 0;
     302    $link_name = apply_filters('pre_link_name', $link_name);
     303
     304    if( trim( $link_url ) == '' )
     305        return 0;
     306    $link_url = apply_filters('pre_link_url', $link_url);
     307
    268308    if ( empty($link_rating) )
    269         $link_rating = 0;   
     309        $link_rating = 0;
     310    else
     311        $link_rating = (int) $link_rating;
     312
     313    if ( empty($link_image) )
     314        $link_image = '';
     315    $link_image = apply_filters('pre_link_image', $link_image);
    270316
    271317    if ( empty($link_target) )
    272         $link_target = ''; 
     318        $link_target = '';
     319    $link_target = apply_filters('pre_link_target', $link_target);
    273320
    274321    if ( empty($link_visible) )
    275322        $link_visible = 'Y';
    276        
     323    $link_visibile = preg_replace('/[^YNyn]/', '', $link_visible);
     324
    277325    if ( empty($link_owner) )
    278326        $link_owner = $current_user->id;
     327    else
     328        $link_owner = (int) $link_owner;
    279329
    280330    if ( empty($link_notes) )
    281331        $link_notes = '';
     332    $link_notes = apply_filters('pre_link_notes', $link_notes);
     333
     334    if ( empty($link_description) )
     335        $link_description = '';
     336    $link_description = apply_filters('pre_link_description', $link_description);
     337
     338    if ( empty($link_rss) )
     339        $link_rss = '';
     340    $link_rss = apply_filters('pre_link_rss', $link_rss);
     341
     342    if ( empty($link_rel) )
     343        $link_rel = '';
     344    $link_rel = apply_filters('pre_link_rel', $link_rel);
     345
     346    // Make sure we set a valid category
     347    if (0 == count($link_category) || !is_array($link_category)) {
     348        $link_category = array(get_option('default_link_category'));
     349    }
    282350
    283351    if ( $update ) {
    284352        $wpdb->query("UPDATE $wpdb->links SET link_url='$link_url',
    285353            link_name='$link_name', link_image='$link_image',
    286             link_target='$link_target', link_category='$link_category',
     354            link_target='$link_target',
    287355            link_visible='$link_visible', link_description='$link_description',
    288356            link_rating='$link_rating', link_rel='$link_rel',
     
    290358            WHERE link_id='$link_id'");
    291359    } else {
    292         $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_category, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_category', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
     360        $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_image, link_target, link_description, link_visible, link_owner, link_rating, link_rel, link_notes, link_rss) VALUES('$link_url','$link_name', '$link_image', '$link_target', '$link_description', '$link_visible', '$link_owner', '$link_rating', '$link_rel', '$link_notes', '$link_rss')");
    293361        $link_id = $wpdb->insert_id;
    294362    }
    295    
     363
     364    wp_set_link_cats($link_id, $link_category);
     365
    296366    if ( $update )
    297367        do_action('edit_link', $link_id);
     
    306376
    307377    $link_id = (int) $linkdata['link_id'];
    308    
     378
    309379    $link = get_link($link_id, ARRAY_A);
    310    
     380
    311381    // Escape data pulled from DB.
    312382    $link = add_magic_quotes($link);
    313    
     383
     384    // Passed link category list overwrites existing category list if not empty.
     385    if ( isset($linkdata['link_category']) && is_array($linkdata['link_category'])
     386             && 0 != count($linkdata['link_category']) )
     387        $link_cats = $linkdata['link_category'];
     388    else
     389        $link_cats = $link['link_category'];
     390
    314391    // Merge old and new fields with new fields overwriting old ones.
    315392    $linkdata = array_merge($link, $linkdata);
     393    $linkdata['link_category'] = $link_cats;
    316394
    317395    return wp_insert_link($linkdata);
     
    322400
    323401    do_action('delete_link', $link_id);
    324     return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'");
    325 }
     402   
     403    $categories = wp_get_link_cats($link_id);
     404    if( is_array( $categories ) ) {
     405        foreach ( $categories as $category ) {
     406            $wpdb->query("UPDATE $wpdb->categories SET link_count = link_count - 1 WHERE cat_ID = '$category'");
     407            wp_cache_delete($category, 'category');
     408        }
     409    }
     410
     411    $wpdb->query("DELETE FROM $wpdb->link2cat WHERE link_id = '$link_id'");
     412    return $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$link_id'");
     413}
     414
     415function wp_get_link_cats($link_ID = 0) {
     416    global $wpdb;
     417
     418    $sql = "SELECT category_id
     419        FROM $wpdb->link2cat
     420        WHERE link_id = $link_ID
     421        ORDER BY category_id";
     422
     423    $result = $wpdb->get_col($sql);
     424
     425    if ( !$result )
     426        $result = array();
     427
     428    return array_unique($result);
     429}
     430
     431function wp_set_link_cats($link_ID = 0, $link_categories = array()) {
     432    global $wpdb;
     433    // If $link_categories isn't already an array, make it one:
     434    if (!is_array($link_categories) || 0 == count($link_categories))
     435        $link_categories = array(get_option('default_link_category'));
     436
     437    $link_categories = array_unique($link_categories);
     438
     439    // First the old categories
     440    $old_categories = $wpdb->get_col("
     441        SELECT category_id
     442        FROM $wpdb->link2cat
     443        WHERE link_id = $link_ID");
     444
     445    if (!$old_categories) {
     446        $old_categories = array();
     447    } else {
     448        $old_categories = array_unique($old_categories);
     449    }
     450
     451    // Delete any?
     452    $delete_cats = array_diff($old_categories,$link_categories);
     453
     454    if ($delete_cats) {
     455        foreach ($delete_cats as $del) {
     456            $wpdb->query("
     457                DELETE FROM $wpdb->link2cat
     458                WHERE category_id = $del
     459                    AND link_id = $link_ID
     460                ");
     461        }
     462    }
     463
     464    // Add any?
     465    $add_cats = array_diff($link_categories, $old_categories);
     466
     467    if ($add_cats) {
     468        foreach ($add_cats as $new_cat) {
     469            $wpdb->query("
     470                INSERT INTO $wpdb->link2cat (link_id, category_id)
     471                VALUES ($link_ID, $new_cat)");
     472        }
     473    }
     474   
     475    // Update category counts.
     476    $all_affected_cats = array_unique(array_merge($link_categories, $old_categories));
     477    foreach ( $all_affected_cats as $cat_id ) {
     478        $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
     479        $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
     480        wp_cache_delete($cat_id, 'category');
     481    }
     482}   // wp_set_link_cats()
    326483
    327484function post_exists($title, $content = '', $post_date = '') {
  • trunk/wp-admin/admin-footer.php

    r3503 r4431  
    11
    2 <div id="footer"><p><a href="http://wordpress.org/" id="wordpress-logo"><img src="images/wordpress-logo.png" alt="WordPress" /></a></p>
    3 <p>
    4 <a href="http://codex.wordpress.org/"><?php _e('Documentation'); ?></a> &#8212; <a href="http://wordpress.org/support/"><?php _e('Support Forums'); ?></a> <br />
    5 <?php bloginfo('version'); ?> &#8212; <?php printf(__('%s seconds'), number_format(timer_stop(), 2)); ?>
    6 </p>
    7 
     2<div id="footer">
     3<p class="logo"><a href="http://wordpress.org/" id="wordpress-logo"><img src="images/wordpress-logo.png" alt="WordPress" /></a></p>
     4<p class="docs"><?php _e('<a href="http://codex.wordpress.org/">Documentation</a>'); ?> &#8212; <?php _e('<a href="http://wordpress.org/support/">Support Forums</a>'); ?><br />
     5<?php bloginfo('version'); ?> &#8212; <?php printf(__('%s seconds'), timer_stop(0, 2)); ?></p>
    86</div>
    97<?php do_action('admin_footer', ''); ?>
    108<script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script>
    11 
    12 <?php
    13 if ( (substr(php_sapi_name(), 0, 3) == 'cgi') && spawn_pinger() ) {
    14     echo '<iframe id="pingcheck" src="' . get_settings('siteurl') .'/wp-admin/execute-pings.php?time=' . time() . '" style="border:none;width:1px;height:1px;"></iframe>';
    15 }
    16 ?>
    17 
    189</body>
    1910</html>
  • trunk/wp-admin/admin-functions.php

    r3503 r4431  
    11<?php
    22
     3function write_post() {
     4    $result = wp_write_post();
     5    if( is_wp_error($result) )
     6        wp_die( $result->get_error_message() );
     7    else
     8        return $result;
     9}
     10
    311// Creates a new post from the "Write Post" form using $_POST information.
    4 function write_post() {
     12function wp_write_post() {
    513    global $user_ID;
    614
    7     if (!current_user_can('edit_posts'))
    8         die(__('You are not allowed to create posts or drafts on this blog.'));
     15    if ( 'page' == $_POST['post_type'] ) {
     16        if ( !current_user_can('edit_pages') )
     17            return new WP_Error('edit_pages', __('You are not allowed to create pages on this blog.'));
     18    } else {
     19        if ( !current_user_can('edit_posts') )
     20            return new WP_Error('edit_posts', __('You are not allowed to create posts or drafts on this blog.'));
     21    }
    922
    1023    // Rename.
     
    1629    if (!empty ($_POST['post_author_override'])) {
    1730        $_POST['post_author'] = (int) $_POST['post_author_override'];
    18     } else
     31    } else {
    1932        if (!empty ($_POST['post_author'])) {
    2033            $_POST['post_author'] = (int) $_POST['post_author'];
     
    2336        }
    2437
    25     if (($_POST['post_author'] != $_POST['user_ID']) && !current_user_can('edit_others_posts'))
    26         die(__('You cannot post as this user.'));
     38    }
     39
     40    if ($_POST['post_author'] != $_POST['user_ID']) {
     41        if ( 'page' == $_POST['post_type'] ) {
     42            if ( !current_user_can('edit_others_pages') )
     43                return new WP_Error('edit_others_pages', __('You cannot create pages as this user.'));
     44        } else {
     45            if ( !current_user_can('edit_others_posts') )
     46                return new WP_Error('edit_others_posts', __('You cannot post as this user.'));
     47
     48        }
     49    }
    2750
    2851    // What to do based on which button they pressed
     
    3558    if ('' != $_POST['advanced'])
    3659        $_POST['post_status'] = 'draft';
    37     if ('' != $_POST['savepage'])
    38         $_POST['post_status'] = 'static';
    39 
    40     if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
     60
     61    if ( 'page' == $_POST['post_type'] ) {
     62        if ('publish' == $_POST['post_status'] && !current_user_can('publish_pages'))
     63            $_POST['post_status'] = 'draft';
     64    } else {
     65        if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
     66            $_POST['post_status'] = 'draft';
     67    }
     68
     69    if (!isset ($_POST['comment_status']))
     70        $_POST['comment_status'] = 'closed';
     71
     72    if (!isset ($_POST['ping_status']))
     73        $_POST['ping_status'] = 'closed';
     74
     75    if (!empty ($_POST['edit_date'])) {
     76        $aa = $_POST['aa'];
     77        $mm = $_POST['mm'];
     78        $jj = $_POST['jj'];
     79        $hh = $_POST['hh'];
     80        $mn = $_POST['mn'];
     81        $ss = $_POST['ss'];
     82        $jj = ($jj > 31) ? 31 : $jj;
     83        $hh = ($hh > 23) ? $hh -24 : $hh;
     84        $mn = ($mn > 59) ? $mn -60 : $mn;
     85        $ss = ($ss > 59) ? $ss -60 : $ss;
     86        $_POST['post_date'] = sprintf("%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss);
     87        $_POST['post_date_gmt'] = get_gmt_from_date($_POST['post_date']);
     88    }
     89
     90    // Create the post.
     91    $post_ID = wp_insert_post($_POST);
     92    add_meta($post_ID);
     93
     94    // Reunite any orphaned attachments with their parent
     95    if ( $_POST['temp_ID'] )
     96        relocate_children($_POST['temp_ID'], $post_ID);
     97
     98    // Now that we have an ID we can fix any attachment anchor hrefs
     99    fix_attachment_links($post_ID);
     100
     101    return $post_ID;
     102}
     103
     104// Move child posts to a new parent
     105function relocate_children($old_ID, $new_ID) {
     106    global $wpdb;
     107    $old_ID = (int) $old_ID;
     108    $new_ID = (int) $new_ID;
     109    return $wpdb->query("UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID");
     110}
     111
     112// Replace hrefs of attachment anchors with up-to-date permalinks.
     113function fix_attachment_links($post_ID) {
     114    global $wp_rewrite;
     115
     116    $post = & get_post($post_ID, ARRAY_A);
     117
     118    $search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie";
     119
     120    // See if we have any rel="attachment" links
     121    if ( 0 == preg_match_all($search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER) )
     122        return;
     123
     124    $i = 0;
     125    $search = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i";
     126    foreach ( $anchor_matches[0] as $anchor ) {
     127        if ( 0 == preg_match($search, $anchor, $id_matches) )
     128            continue;
     129
     130        $id = $id_matches[3];
     131
     132        // While we have the attachment ID, let's adopt any orphans.
     133        $attachment = & get_post($id, ARRAY_A);
     134        if ( ! empty($attachment) && ! is_object(get_post($attachment['post_parent'])) ) {
     135            $attachment['post_parent'] = $post_ID;
     136            // Escape data pulled from DB.
     137            $attachment = add_magic_quotes($attachment);
     138            wp_update_post($attachment);
     139        }
     140
     141        $post_search[$i] = $anchor;
     142        $post_replace[$i] = preg_replace("#href=(\"|')[^'\"]*\\1#e", "stripslashes('href=\\1').get_attachment_link($id).stripslashes('\\1')", $anchor);
     143        ++$i;
     144    }
     145
     146    $post['post_content'] = str_replace($post_search, $post_replace, $post['post_content']);
     147
     148    // Escape data pulled from DB.
     149    $post = add_magic_quotes($post);
     150
     151    return wp_update_post($post);
     152}
     153
     154// Update an existing post with values provided in $_POST.
     155function edit_post() {
     156    global $user_ID;
     157
     158    $post_ID = (int) $_POST['post_ID'];
     159
     160    if ( 'page' == $_POST['post_type'] ) {
     161        if ( !current_user_can('edit_page', $post_ID) )
     162            wp_die(__('You are not allowed to edit this page.'));
     163    } else {
     164        if ( !current_user_can('edit_post', $post_ID) )
     165            wp_die(__('You are not allowed to edit this post.'));
     166    }
     167
     168    // Rename.
     169    $_POST['ID'] = (int) $_POST['post_ID'];
     170    $_POST['post_content'] = $_POST['content'];
     171    $_POST['post_excerpt'] = $_POST['excerpt'];
     172    $_POST['post_parent'] = $_POST['parent_id'];
     173    $_POST['to_ping'] = $_POST['trackback_url'];
     174
     175    if (!empty ($_POST['post_author_override'])) {
     176        $_POST['post_author'] = (int) $_POST['post_author_override'];
     177    } else
     178        if (!empty ($_POST['post_author'])) {
     179            $_POST['post_author'] = (int) $_POST['post_author'];
     180        } else {
     181            $_POST['post_author'] = (int) $_POST['user_ID'];
     182        }
     183
     184    if ($_POST['post_author'] != $_POST['user_ID']) {
     185        if ( 'page' == $_POST['post_type'] ) {
     186            if ( !current_user_can('edit_others_pages') )
     187                wp_die(__('You cannot edit pages as this user.'));
     188        } else {
     189            if ( !current_user_can('edit_others_posts') )
     190                wp_die(__('You cannot edit posts as this user.'));
     191
     192        }
     193    }
     194
     195    // What to do based on which button they pressed
     196    if ('' != $_POST['saveasdraft'])
    41197        $_POST['post_status'] = 'draft';
    42 
    43     if ('static' == $_POST['post_status'] && !current_user_can('edit_pages'))
    44         die(__('This user cannot edit pages.'));
     198    if ('' != $_POST['saveasprivate'])
     199        $_POST['post_status'] = 'private';
     200    if ('' != $_POST['publish'])
     201        $_POST['post_status'] = 'publish';
     202    if ('' != $_POST['advanced'])
     203        $_POST['post_status'] = 'draft';
     204
     205    if ( 'page' == $_POST['post_type'] ) {
     206        if ('publish' == $_POST['post_status'] && !current_user_can('edit_published_pages'))
     207            $_POST['post_status'] = 'draft';
     208    } else {
     209        if ('publish' == $_POST['post_status'] && !current_user_can('edit_published_posts'))
     210            $_POST['post_status'] = 'draft';
     211    }
     212
     213    if (!isset ($_POST['comment_status']))
     214        $_POST['comment_status'] = 'closed';
     215
     216    if (!isset ($_POST['ping_status']))
     217        $_POST['ping_status'] = 'closed';
    45218
    46219    if (!empty ($_POST['edit_date'])) {
     
    59232    }
    60233
    61     // Create the post.
    62     $post_ID = wp_insert_post($_POST);
    63     add_meta($post_ID);
    64 
    65     // Reunite any orphaned attachments with their parent
    66     if ( $_POST['temp_ID'] )
    67         relocate_children($_POST['temp_ID'], $post_ID);
    68 
    69     // Now that we have an ID we can fix any attachment anchor hrefs
    70     fix_attachment_links($post_ID);
    71 
    72     return $post_ID;
    73 }
    74 
    75 // Move child posts to a new parent
    76 function relocate_children($old_ID, $new_ID) {
    77     global $wpdb;
    78     $old_ID = (int) $old_ID;
    79     $new_ID = (int) $new_ID;
    80     return $wpdb->query("UPDATE $wpdb->posts SET post_parent = $new_ID WHERE post_parent = $old_ID");
    81 }
    82 
    83 // Replace hrefs of attachment anchors with up-to-date permalinks.
    84 function fix_attachment_links($post_ID) {
    85     global $wp_rewrite;
    86 
    87     $post = & get_post($post_ID);
    88 
    89     $search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie";
    90 
    91     // See if we have any rel="attachment" links
    92     if ( 0 == preg_match_all($search, $post->post_content, $anchor_matches, PREG_PATTERN_ORDER) )
    93         return;
    94 
    95     $i = 0;
    96     $search = "# id=(\"|')p(\d+)\\1#i";
    97     foreach ( $anchor_matches[0] as $anchor ) {
    98         if ( 0 == preg_match($search, $anchor, $id_matches) )
    99             continue;
    100 
    101         $id = $id_matches[2];
    102 
    103         // While we have the attachment ID, let's adopt any orphans.
    104         $attachment = & get_post($id);
    105         if ( ! is_object(get_post($attachment->post_parent)) ) {
    106             $attachment->post_parent = $post_ID;
    107             wp_update_post($attachment);
    108         }
    109 
    110         $post_search[$i] = $anchor;
    111         $post_replace[$i] = preg_replace("#href=(\"|')[^'\"]*\\1#e", "stripslashes('href=\\1').get_attachment_link($id).stripslashes('\\1')", $anchor);
    112         ++$i;
    113     }
    114 
    115     $post->post_content = str_replace($post_search, $post_replace, $post->post_content);
    116 
    117     return wp_update_post($post);
    118 }
    119 
    120 // Update an existing post with values provided in $_POST.
    121 function edit_post() {
    122     global $user_ID;
    123 
    124     $post_ID = (int) $_POST['post_ID'];
    125 
    126     if (!current_user_can('edit_post', $post_ID))
    127         die(__('You are not allowed to edit this post.'));
    128 
    129     // Rename.
    130     $_POST['ID'] = (int) $_POST['post_ID'];
    131     $_POST['post_content'] = $_POST['content'];
    132     $_POST['post_excerpt'] = $_POST['excerpt'];
    133     $_POST['post_parent'] = $_POST['parent_id'];
    134     $_POST['to_ping'] = $_POST['trackback_url'];
    135 
    136     if (!empty ($_POST['post_author_override'])) {
    137         $_POST['post_author'] = (int) $_POST['post_author_override'];
    138     } else
    139         if (!empty ($_POST['post_author'])) {
    140             $_POST['post_author'] = (int) $_POST['post_author'];
    141         } else {
    142             $_POST['post_author'] = (int) $_POST['user_ID'];
    143         }
    144 
    145     if (($_POST['post_author'] != $_POST['user_ID']) && !current_user_can('edit_others_posts'))
    146         die(__('You cannot post as this user.'));
    147 
    148     // What to do based on which button they pressed
    149     if ('' != $_POST['saveasdraft'])
    150         $_POST['post_status'] = 'draft';
    151     if ('' != $_POST['saveasprivate'])
    152         $_POST['post_status'] = 'private';
    153     if ('' != $_POST['publish'])
    154         $_POST['post_status'] = 'publish';
    155     if ('' != $_POST['advanced'])
    156         $_POST['post_status'] = 'draft';
    157     if ('' != $_POST['savepage'])
    158         $_POST['post_status'] = 'static';
    159 
    160     if ('publish' == $_POST['post_status'] && !current_user_can('publish_posts'))
    161         $_POST['post_status'] = 'draft';
    162 
    163     if ('static' == $_POST['post_status'] && !current_user_can('edit_pages'))
    164         die(__('This user cannot edit pages.'));
    165 
    166     if (!isset ($_POST['comment_status']))
    167         $_POST['comment_status'] = 'closed';
    168 
    169     if (!isset ($_POST['ping_status']))
    170         $_POST['ping_status'] = 'closed';
    171 
    172     if (!empty ($_POST['edit_date'])) {
    173         $aa = $_POST['aa'];
    174         $mm = $_POST['mm'];
    175         $jj = $_POST['jj'];
    176         $hh = $_POST['hh'];
    177         $mn = $_POST['mn'];
    178         $ss = $_POST['ss'];
    179         $jj = ($jj > 31) ? 31 : $jj;
    180         $hh = ($hh > 23) ? $hh -24 : $hh;
    181         $mn = ($mn > 59) ? $mn -60 : $mn;
    182         $ss = ($ss > 59) ? $ss -60 : $ss;
    183         $_POST['post_date'] = "$aa-$mm-$jj $hh:$mn:$ss";
    184         $_POST['post_date_gmt'] = get_gmt_from_date("$aa-$mm-$jj $hh:$mn:$ss");
    185     }
    186 
    187234    // Meta Stuff
    188235    if ($_POST['meta']) {
     
    190237            update_meta($key, $value['key'], $value['value']);
    191238    }
    192    
     239
    193240    if ($_POST['deletemeta']) {
    194241        foreach ($_POST['deletemeta'] as $key => $value)
     
    213260
    214261    if (!current_user_can('edit_post', $comment_post_ID))
    215         die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.'));
     262        wp_die(__('You are not allowed to edit comments on this post, so you cannot edit this comment.'));
    216263
    217264    $_POST['comment_author'] = $_POST['newcomment_author'];
     
    241288// Get an existing post and format it for editing.
    242289function get_post_to_edit($id) {
    243     global $richedit;
    244     $richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false;
    245290
    246291    $post = get_post($id);
    247292
    248     $post->post_content = format_to_edit($post->post_content, $richedit);
     293    $post->post_content = format_to_edit($post->post_content, user_can_richedit());
    249294    $post->post_content = apply_filters('content_edit_pre', $post->post_content);
    250295
     
    255300    $post->post_title = apply_filters('title_edit_pre', $post->post_title);
    256301
    257     if ($post->post_status == 'static')
     302    $post->post_password = format_to_edit($post->post_password);
     303
     304    if ($post->post_type == 'page')
    258305        $post->page_template = get_post_meta($id, '_wp_page_template', true);
    259306
     
    287334
    288335    $post->post_status = 'draft';
    289     $post->comment_status = get_settings('default_comment_status');
    290     $post->ping_status = get_settings('default_ping_status');
    291     $post->post_pingback = get_settings('default_pingback_flag');
    292     $post->post_category = get_settings('default_category');
     336    $post->comment_status = get_option('default_comment_status');
     337    $post->ping_status = get_option('default_ping_status');
     338    $post->post_pingback = get_option('default_pingback_flag');
     339    $post->post_category = get_option('default_category');
    293340    $post->post_content = apply_filters('default_content', $post_content);
    294341    $post->post_title = apply_filters('default_title', $post_title);
     
    302349
    303350function get_comment_to_edit($id) {
    304     global $richedit;
    305     $richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false;
    306 
    307351    $comment = get_comment($id);
    308352
    309     $comment->comment_content = format_to_edit($comment->comment_content, $richedit);
     353    $comment->comment_content = format_to_edit($comment->comment_content, user_can_richedit());
    310354    $comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content);
    311355
     
    323367}
    324368
     369function wp_dropdown_roles( $default = false ) {
     370    global $wp_roles;
     371    $r = '';
     372    foreach($wp_roles->role_names as $role => $name)
     373        if ( $default == $role ) // Make default first in list
     374            $p = "\n\t<option selected='selected' value='$role'>$name</option>";
     375        else
     376            $r .= "\n\t<option value='$role'>$name</option>";
     377    echo $p . $r;
     378}
     379
     380
     381function get_user_to_edit($user_id) {
     382    $user = new WP_User($user_id);
     383    $user->user_login = wp_specialchars($user->user_login, 1);
     384    $user->user_email = wp_specialchars($user->user_email, 1);
     385    $user->user_url = wp_specialchars($user->user_url, 1);
     386    $user->first_name = wp_specialchars($user->first_name, 1);
     387    $user->last_name = wp_specialchars($user->last_name, 1);
     388    $user->display_name = wp_specialchars($user->display_name, 1);
     389    $user->nickname = wp_specialchars($user->nickname, 1);
     390    $user->aim = wp_specialchars($user->aim, 1);
     391    $user->yim = wp_specialchars($user->yim, 1);
     392    $user->jabber = wp_specialchars($user->jabber, 1);
     393    $user->description = wp_specialchars($user->description);
     394
     395    return $user;
     396}
     397
    325398// Creates a new user from the "Users" form using $_POST information.
    326399
    327400function add_user() {
    328     return edit_user();
     401    if ( func_num_args() ) { // The hackiest hack that ever did hack
     402        global $current_user, $wp_roles;
     403        $user_id = func_get_arg(0);
     404
     405        if (isset ($_POST['role'])) {
     406            if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users')) {
     407                $user = new WP_User($user_id);
     408                $user->set_role($_POST['role']);
     409            }
     410        }
     411    } else {
     412        add_action('user_register', 'add_user'); // See above
     413        return edit_user();
     414    }
    329415}
    330416
    331417function edit_user($user_id = 0) {
    332418    global $current_user, $wp_roles, $wpdb;
    333 
    334419    if ($user_id != 0) {
    335420        $update = true;
     
    351436        $pass2 = $_POST['pass2'];
    352437
    353     if (isset ($_POST['role'])) {
     438    if (isset ($_POST['role']) && current_user_can('edit_users')) {
    354439        if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users'))
    355440            $user->role = $_POST['role'];
     
    371456        $user->display_name = wp_specialchars(trim($_POST['display_name']));
    372457    if (isset ($_POST['description']))
    373         $user->description = wp_specialchars(trim($_POST['description']));
     458        $user->description = trim($_POST['description']);
    374459    if (isset ($_POST['jabber']))
    375460        $user->jabber = wp_specialchars(trim($_POST['jabber']));
     
    379464        $user->yim = wp_specialchars(trim($_POST['yim']));
    380465
    381     $errors = array ();
     466    $errors = new WP_Error();
    382467
    383468    /* checking that username has been typed */
    384469    if ($user->user_login == '')
    385         $errors['user_login'] = __('<strong>ERROR</strong>: Please enter a username.');
     470        $errors->add('user_login', __('<strong>ERROR</strong>: Please enter a username.'));
    386471
    387472    /* checking the password has been typed twice */
    388     do_action('check_passwords', array ($user->user_login, & $pass1, & $pass2));
     473    do_action_ref_array('check_passwords', array ($user->user_login, & $pass1, & $pass2));
    389474
    390475    if (!$update) {
    391476        if ($pass1 == '' || $pass2 == '')
    392             $errors['pass'] = __('<strong>ERROR</strong>: Please enter your password twice.');
     477            $errors->add('pass', __('<strong>ERROR</strong>: Please enter your password twice.'));
    393478    } else {
    394479        if ((empty ($pass1) && !empty ($pass2)) || (empty ($pass2) && !empty ($pass1)))
    395             $errors['pass'] = __("<strong>ERROR</strong>: you typed your new password only once.");
     480            $errors->add('pass', __("<strong>ERROR</strong>: you typed your new password only once."));
    396481    }
    397482
    398483    /* Check for "\" in password */
    399484    if( strpos( " ".$pass1, "\\" ) )
    400         $errors['pass'] = __('<strong>ERROR</strong>: Passwords may not contain the character "\\".');
     485        $errors->add('pass', __('<strong>ERROR</strong>: Passwords may not contain the character "\\".'));
    401486
    402487    /* checking the password has been typed twice the same */
    403488    if ($pass1 != $pass2)
    404         $errors['pass'] = __('<strong>ERROR</strong>: Please type the same password in the two password fields.');
     489        $errors->add('pass', __('<strong>ERROR</strong>: Please type the same password in the two password fields.'));
    405490
    406491    if (!empty ($pass1))
     
    408493
    409494    if ( !validate_username($user->user_login) )
    410         $errors['user_login'] = __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.');
     495        $errors->add('user_login', __('<strong>ERROR</strong>: This username is invalid.  Please enter a valid username.'));
    411496
    412497    if (!$update && username_exists($user->user_login))
    413         $errors['user_login'] = __('<strong>ERROR</strong>: This username is already registered, please choose another one.');
     498        $errors->add('user_login', __('<strong>ERROR</strong>: This username is already registered, please choose another one.'));
    414499
    415500    /* checking e-mail address */
    416501    if (empty ($user->user_email)) {
    417         $errors['user_email'] = __("<strong>ERROR</strong>: please type an e-mail address");
     502        $errors->add('user_email', __("<strong>ERROR</strong>: please type an e-mail address"));
    418503    } else
    419504        if (!is_email($user->user_email)) {
    420             $errors['user_email'] = __("<strong>ERROR</strong>: the email address isn't correct");
    421         }
    422 
    423     if (count($errors) != 0)
     505            $errors->add('user_email', __("<strong>ERROR</strong>: the email address isn't correct"));
     506        }
     507
     508    if ( $errors->get_error_codes() )
    424509        return $errors;
    425510
     
    430515        wp_new_user_notification($user_id);
    431516    }
    432 
    433     return $errors;
     517    return $user_id;
    434518}
    435519
     
    437521function get_link_to_edit($link_id) {
    438522    $link = get_link($link_id);
    439    
     523
    440524    $link->link_url = wp_specialchars($link->link_url, 1);
    441525    $link->link_name = wp_specialchars($link->link_name, 1);
    442     $link->link_description = wp_specialchars($link->link_description);
     526    $link->link_image = wp_specialchars($link->link_image, 1);
     527    $link->link_description = wp_specialchars($link->link_description, 1);
    443528    $link->link_notes = wp_specialchars($link->link_notes);
    444     $link->link_rss = wp_specialchars($link->link_rss);
    445    
     529    $link->link_rss = wp_specialchars($link->link_rss, 1);
     530    $link->link_rel = wp_specialchars($link->link_rel, 1);
     531    $link->post_category = $link->link_category;
     532
    446533    return $link;
    447534}
     
    452539    else
    453540        $link->link_url = '';
    454    
     541
    455542    if ( isset($_GET['name']) )
    456543        $link->link_name = wp_specialchars($_GET['name'], 1);
    457544    else
    458545        $link->link_name = '';
    459        
     546
     547    $link->link_visible = 'Y';
     548
    460549    return $link;
    461550}
    462551
    463552function add_link() {
    464     return edit_link(); 
     553    return edit_link();
    465554}
    466555
    467556function edit_link($link_id = '') {
    468557    if (!current_user_can('manage_links'))
    469         die(__("Cheatin' uh ?"));
     558        wp_die(__("Cheatin' uh ?"));
    470559
    471560    $_POST['link_url'] = wp_specialchars($_POST['link_url']);
     
    474563    $_POST['link_image'] = wp_specialchars($_POST['link_image']);
    475564    $_POST['link_rss'] = wp_specialchars($_POST['link_rss']);
    476     $auto_toggle = get_autotoggle($_POST['link_category']);
    477    
    478     // if we are in an auto toggle category and this one is visible then we
    479     // need to make the others invisible before we add this new one.
    480     // FIXME Add category toggle func.
    481     //if (($auto_toggle == 'Y') && ($link_visible == 'Y')) {
    482     //  $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category");
    483     //}
     565    $_POST['link_category'] = $_POST['post_category'];
    484566
    485567    if ( !empty($link_id) ) {
     
    513595function return_categories_list($parent = 0) {
    514596    global $wpdb;
    515     return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC LIMIT 100");
     597    return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY category_count DESC");
    516598}
    517599
     
    521603
    522604function get_nested_categories($default = 0, $parent = 0) {
    523     global $post_ID, $mode, $wpdb;
     605    global $post_ID, $link_id, $mode, $wpdb;
    524606
    525607    if ($post_ID) {
     
    534616            $checked_categories[] = $default;
    535617        }
    536 
     618    } else if ($link_id) {
     619        $checked_categories = $wpdb->get_col("
     620             SELECT category_id
     621             FROM $wpdb->categories, $wpdb->link2cat
     622             WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'
     623             ");
     624
     625        if (count($checked_categories) == 0) {
     626            // No selected categories, strange
     627            $checked_categories[] = $default;
     628        }   
    537629    } else {
    538630        $checked_categories[] = $default;
     
    550642        }
    551643    }
    552    
     644
    553645    usort($result, 'sort_cats');
    554646
     
    558650function write_nested_categories($categories) {
    559651    foreach ($categories as $category) {
    560         echo '<label for="category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label>\n";
    561 
    562         if (isset ($category['children'])) {
    563             echo "\n<span class='cat-nest'>\n";
     652        echo '<li id="category-', $category['cat_ID'], '"><label for="in-category-', $category['cat_ID'], '" class="selectit"><input value="', $category['cat_ID'], '" type="checkbox" name="post_category[]" id="in-category-', $category['cat_ID'], '"', ($category['checked'] ? ' checked="checked"' : ""), '/> ', wp_specialchars($category['cat_name']), "</label></li>\n";
     653
     654        if ( $category['children'] ) {
     655            echo "<ul>\n";
    564656            write_nested_categories($category['children']);
    565             echo "</span>\n";
     657            echo "</ul>\n";
    566658        }
    567659    }
     
    572664}
    573665
     666function return_link_categories_list($parent = 0) {
     667    global $wpdb;
     668    return $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories WHERE category_parent = $parent ORDER BY link_count DESC");
     669}
     670
     671function get_nested_link_categories( $default = 0, $parent = 0 ) {
     672    global $post_ID, $link_id, $mode, $wpdb;
     673
     674    if ($link_id) {
     675        $checked_categories = $wpdb->get_col("
     676             SELECT category_id
     677             FROM $wpdb->categories, $wpdb->link2cat
     678             WHERE $wpdb->link2cat.category_id = cat_ID AND $wpdb->link2cat.link_id = '$link_id'
     679             ");
     680
     681        if (count($checked_categories) == 0) {
     682            // No selected categories, strange
     683            $checked_categories[] = $default;
     684        }   
     685    } else {
     686        $checked_categories[] = $default;
     687    }
     688
     689    $cats = return_link_categories_list($parent);
     690    $result = array ();
     691
     692    if (is_array($cats)) {
     693        foreach ($cats as $cat) {
     694            $result[$cat]['children'] = get_nested_link_categories($default, $cat);
     695            $result[$cat]['cat_ID'] = $cat;
     696            $result[$cat]['checked'] = in_array($cat, $checked_categories);
     697            $result[$cat]['cat_name'] = get_the_category_by_ID($cat);
     698        }
     699    }
     700
     701    usort($result, 'sort_cats');
     702
     703    return $result;
     704}
     705
     706function dropdown_link_categories($default = 0) {
     707    write_nested_categories(get_nested_link_categories($default));
     708}
     709
    574710// Dandy new recursive multiple category stuff.
    575711function cat_rows($parent = 0, $level = 0, $categories = 0) {
    576     global $wpdb, $class;
    577 
    578712    if (!$categories)
    579         $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
     713        $categories = get_categories('hide_empty=0');
    580714
    581715    if ($categories) {
    582716        foreach ($categories as $category) {
    583717            if ($category->category_parent == $parent) {
    584                 $category->cat_name = wp_specialchars($category->cat_name);
    585                 $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
    586                 $pad = str_repeat('&#8212; ', $level);
    587                 if ( current_user_can('manage_categories') ) {
    588                     $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>";
    589                     $default_cat_id = get_option('default_category');
    590                    
    591                     if ($category->cat_ID != $default_cat_id)
    592                         $edit .= "<td><a href='categories.php?action=delete&amp;cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category &quot;%s&quot;.  All of its posts will go to the default category.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars($category->cat_name, 1))."' );\" class='delete'>".__('Delete')."</a>";
    593                     else
    594                         $edit .= "<td style='text-align:center'>".__("Default");
    595                 }
    596                 else
    597                     $edit = '';
    598 
    599                 $class = ('alternate' == $class) ? '' : 'alternate';
    600                 echo "<tr id='cat-$category->cat_ID' class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td>
    601                                 <td>$category->category_description</td>
    602                                 <td>$count</td>
    603                                 <td>$edit</td>
    604                                 </tr>";
     718                echo "\t" . _cat_row( $category, $level );
    605719                cat_rows($category->cat_ID, $level +1, $categories);
    606720            }
     
    611725}
    612726
    613 function page_rows($parent = 0, $level = 0, $pages = 0) {
     727function _cat_row( $category, $level, $name_override = false ) {
     728    global $class;
     729
     730    $pad = str_repeat('&#8212; ', $level);
     731    if ( current_user_can('manage_categories') ) {
     732        $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>";
     733        $default_cat_id = get_option('default_category');
     734        $default_link_cat_id = get_option('default_link_category');
     735
     736        if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) )
     737            $edit .= "<td><a href='" . wp_nonce_url("categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . sprintf(__("You are about to delete the category &quot;%s&quot;.\\nAll of its posts will go into the default category of &quot;%s&quot;\\nAll of its bookmarks will go into the default category of &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), js_escape($category->cat_name), js_escape(get_catname($default_cat_id)), js_escape(get_catname($default_link_cat_id))) . "' );\" class='delete'>".__('Delete')."</a>";
     738        else
     739            $edit .= "<td style='text-align:center'>".__("Default");
     740    } else
     741        $edit = '';
     742
     743    $class = ( ( defined('DOING_AJAX') && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
     744
     745    $category->category_count = number_format( $category->category_count );
     746    $category->link_count = number_format( $category->link_count );
     747    return "<tr id='cat-$category->cat_ID'$class>
     748        <th scope='row' style='text-align: center'>$category->cat_ID</th>
     749        <td>" . ( $name_override ? $name_override : $pad . ' ' . $category->cat_name ) . "</td>
     750        <td>$category->category_description</td>
     751        <td align='center'>$category->category_count</td>
     752        <td align='center'>$category->link_count</td>
     753        <td>$edit</td>\n\t</tr>\n";
     754}
     755
     756function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) {
    614757    global $wpdb, $class, $post;
     758
    615759    if (!$pages)
    616         $pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static' ORDER BY menu_order");
    617 
    618     if ($pages) {
    619         foreach ($pages as $post) {
    620             start_wp();
    621             if ($post->post_parent == $parent) {
    622                 $post->post_title = wp_specialchars($post->post_title);
    623                 $pad = str_repeat('&#8212; ', $level);
    624                 $id = $post->ID;
    625                 $class = ('alternate' == $class) ? '' : 'alternate';
     760        $pages = get_pages('sort_column=menu_order');
     761
     762    if (! $pages)
     763        return false;
     764
     765    foreach ($pages as $post) {
     766        setup_postdata($post);
     767        if ( $hierarchy && ($post->post_parent != $parent) )
     768            continue;
     769
     770        $post->post_title = wp_specialchars($post->post_title);
     771        $pad = str_repeat('&#8212; ', $level);
     772        $id = $post->ID;
     773        $class = ('alternate' == $class) ? '' : 'alternate';
    626774?>
    627775  <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
    628     <th scope="row"><?php echo $post->ID; ?></th>
     776    <th scope="row" style="text-align: center"><?php echo $post->ID; ?></th>
    629777    <td>
    630       <?php echo $pad; ?><?php the_title() ?>
     778      <?php echo $pad; ?><?php the_title() ?>
     779      <?php if ('private' == $post->post_status) _e(' - <strong>Private</strong>'); ?>
    631780    </td>
    632781    <td><?php the_author() ?></td>
    633782    <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td>
    634783    <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
    635     <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
    636     <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td>
     784    <td><?php if ( current_user_can('edit_page', $id) ) { echo "<a href='page.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
     785    <td><?php if ( current_user_can('delete_page', $id) ) { echo "<a href='" . wp_nonce_url("page.php?action=delete&amp;post=$id", 'delete-page_' . $id) .  "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), js_escape(get_the_title()) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
    637786  </tr>
    638787
    639788<?php
    640 
    641                 page_rows($id, $level +1, $pages);
    642             }
    643         }
    644     } else {
    645         return false;
    646     }
     789        if ( $hierarchy) page_rows($id, $level + 1, $pages);
     790    }
     791}
     792
     793function user_row( $user_object, $style = '' ) {
     794    if ( !(is_object($user_object) && is_a($user_object, 'WP_User')) )
     795        $user_object = new WP_User( (int) $user_object );
     796    $email = $user_object->user_email;
     797    $url = $user_object->user_url;
     798    $short_url = str_replace('http://', '', $url);
     799    $short_url = str_replace('www.', '', $short_url);
     800    if ('/' == substr($short_url, -1))
     801        $short_url = substr($short_url, 0, -1);
     802    if (strlen($short_url) > 35)
     803        $short_url =  substr($short_url, 0, 32).'...';
     804    $numposts = get_usernumposts($user_object->ID);
     805    $r = "<tr id='user-$user_object->ID'$style>
     806        <td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td>
     807        <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td>
     808        <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td>
     809        <td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td>
     810        <td><a href='$url' title='website: $url'>$short_url</a></td>";
     811    $r .= "\n\t\t<td align='center'>";
     812    if ($numposts > 0) {
     813        $r .= "<a href='edit.php?author=$user_object->ID' title='" . __('View posts by this author') . "' class='edit'>";
     814        $r .= sprintf(__('View %1$s %2$s'), $numposts, __ngettext('post', 'posts', $numposts));
     815    }
     816    $r .= "</td>\n\t\t<td>";
     817    $edit_link = add_query_arg('wp_http_referer', wp_specialchars(urlencode(stripslashes($_SERVER['REQUEST_URI']))), "user-edit.php?user_id=$user_object->ID");
     818    if ( current_user_can('edit_user', $user_object->ID) )
     819        $r .= "<a href='$edit_link' class='edit'>".__('Edit')."</a>";
     820    $r .= "</td>\n\t</tr>";
     821    return $r;
    647822}
    648823
    649824function wp_dropdown_cats($currentcat = 0, $currentparent = 0, $parent = 0, $level = 0, $categories = 0) {
    650     global $wpdb, $bgcolor;
    651     if (!$categories) {
    652         $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
    653     }
     825    global $wpdb;
     826    if (!$categories)
     827        $categories = get_categories('hide_empty=0');
     828
    654829    if ($categories) {
    655830        foreach ($categories as $category) {
    656831            if ($currentcat != $category->cat_ID && $parent == $category->category_parent) {
    657                 $count = $wpdb->get_var("SELECT COUNT(post_id) FROM $wpdb->post2cat WHERE category_id = $category->cat_ID");
    658832                $pad = str_repeat('&#8211; ', $level);
    659833                $category->cat_name = wp_specialchars($category->cat_name);
     
    668842        return false;
    669843    }
    670 }
    671 
    672 function link_category_dropdown($fieldname, $selected = 0) {
    673     global $wpdb;
    674    
    675     $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
    676     echo "\n<select name='$fieldname' size='1'>\n";
    677     foreach ($results as $row) {
    678         echo "\n\t<option value='$row->cat_id'";
    679         if ($row->cat_id == $selected)
    680             echo " selected='selected'";
    681         echo ">$row->cat_id : " . wp_specialchars($row->cat_name);
    682         if ($row->auto_toggle == 'Y')
    683             echo ' (auto toggle)';
    684         echo "</option>";
    685     }
    686     echo "\n</select>\n";
    687844}
    688845
     
    777934        return $error;
    778935    } else {
     936        apply_filters( 'wp_create_thumbnail', $thumbpath );
    779937        return $thumbpath;
    780938    }
     
    796954    global $post_ID;
    797955    // Exit if no meta
    798     if (!$meta)
     956    if (!$meta) {
     957        echo '<tbody id="the-list"><tr style="display: none;"><td>&nbsp;</td></tr></tbody>'; //TBODY needed for list-manipulation JS
    799958        return;
     959    }
    800960    $count = 0;
    801961?>
    802 <table id='meta-list' cellpadding="3">
     962    <thead>
    803963    <tr>
    804964        <th><?php _e('Key') ?></th>
     
    806966        <th colspan='2'><?php _e('Action') ?></th>
    807967    </tr>
     968    </thead>
    808969<?php
    809 
    810 
     970    $r ="\n\t<tbody id='the-list'>";
    811971    foreach ($meta as $entry) {
    812972        ++ $count;
     
    817977        if ('_' == $entry['meta_key'] { 0 })
    818978            $style .= ' hidden';
    819         echo "
    820             <tr class='$style'>
    821                 <td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>
    822                 <td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>
    823                 <td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br />
    824                 <input name='deletemeta[{$entry['meta_id']}]' type='submit' class='deletemeta' tabindex='6' value='".__('Delete')."' /></td>
    825             </tr>
    826         ";
    827     }
    828     echo "
    829         </table>
    830     ";
     979
     980        if ( is_serialized($entry['meta_value']) ) {
     981            if ( is_serialized_string($entry['meta_value']) ) {
     982                // this is a serialized string, so we should display it
     983                $entry['meta_value'] = maybe_unserialize($entry['meta_value']);
     984            } else {
     985                // this is a serialized array/object so we should NOT display it
     986                --$count;
     987                continue;
     988            }
     989        }
     990
     991        $key_js = js_escape($entry['meta_key']);
     992        $entry['meta_key'] = wp_specialchars( $entry['meta_key'], true );
     993        $entry['meta_value'] = wp_specialchars( $entry['meta_value'], true );
     994        $r .= "\n\t<tr id='meta-{$entry['meta_id']}' class='$style'>";
     995        $r .= "\n\t\t<td valign='top'><input name='meta[{$entry['meta_id']}][key]' tabindex='6' type='text' size='20' value='{$entry['meta_key']}' /></td>";
     996        $r .= "\n\t\t<td><textarea name='meta[{$entry['meta_id']}][value]' tabindex='6' rows='2' cols='30'>{$entry['meta_value']}</textarea></td>";
     997        $r .= "\n\t\t<td align='center'><input name='updatemeta' type='submit' class='updatemeta' tabindex='6' value='".__('Update')."' /><br />";
     998        $r .= "\n\t\t<input name='deletemeta[{$entry['meta_id']}]' type='submit' onclick=\"return deleteSomething( 'meta', {$entry['meta_id']}, '";
     999        $r .= sprintf(__("You are about to delete the &quot;%s&quot; custom field on this post.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), $key_js);
     1000        $r .= "' );\" class='deletemeta' tabindex='6' value='".__('Delete')."' /></td>";
     1001        $r .= "\n\t</tr>";
     1002    }
     1003    echo $r;
     1004    echo "\n\t</tbody>";
    8311005}
    8321006
     
    8461020function meta_form() {
    8471021    global $wpdb;
     1022    $limit = (int) apply_filters('postmeta_form_limit', 30);
    8481023    $keys = $wpdb->get_col("
    849             SELECT meta_key
    850             FROM $wpdb->postmeta
    851             GROUP BY meta_key
    852             ORDER BY meta_id DESC
    853             LIMIT 10");
     1024        SELECT meta_key
     1025        FROM $wpdb->postmeta
     1026        GROUP BY meta_key
     1027        ORDER BY meta_id DESC
     1028        LIMIT $limit");
     1029    natcasesort($keys);
    8541030?>
    8551031<h3><?php _e('Add a new custom field:') ?></h3>
    856 <table cellspacing="3" cellpadding="3">
     1032<table id="newmeta" cellspacing="3" cellpadding="3">
    8571033    <tr>
    8581034<th colspan="2"><?php _e('Key') ?></th>
     
    8611037    <tr valign="top">
    8621038        <td align="right" width="18%">
    863 <?php if ($keys) : ?>
     1039<?php if ( $keys ) : ?>
    8641040<select id="metakeyselect" name="metakeyselect" tabindex="7">
    8651041<option value="#NONE#"><?php _e('- Select -'); ?></option>
    8661042<?php
    8671043
    868     foreach ($keys as $key) {
     1044    foreach ( $keys as $key ) {
     1045        $key = wp_specialchars($key, 1);
    8691046        echo "\n\t<option value='$key'>$key</option>";
    8701047    }
     
    8781055
    8791056</table>
    880 <p class="submit"><input type="submit" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field &raquo;') ?>" /></p>
     1057<p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field &raquo;') ?>" /></p>
    8811058<?php
    8821059
     
    8851062function add_meta($post_ID) {
    8861063    global $wpdb;
     1064    $post_ID = (int) $post_ID;
    8871065
    8881066    $metakeyselect = $wpdb->escape(stripslashes(trim($_POST['metakeyselect'])));
    8891067    $metakeyinput = $wpdb->escape(stripslashes(trim($_POST['metakeyinput'])));
    890     $metavalue = $wpdb->escape(stripslashes(trim($_POST['metavalue'])));
     1068    $metavalue = maybe_serialize(stripslashes((trim($_POST['metavalue']))));
     1069    $metavalue = $wpdb->escape($metavalue);
    8911070
    8921071    if ( ('0' === $metavalue || !empty ($metavalue)) && ((('#NONE#' != $metakeyselect) && !empty ($metakeyselect)) || !empty ($metakeyinput)) ) {
     
    8941073        // input for the key have data, the input takes precedence:
    8951074
    896         if ('#NONE#' != $metakeyselect)
     1075        if ('#NONE#' != $metakeyselect)
    8971076            $metakey = $metakeyselect;
    8981077
     
    9051084                        VALUES ('$post_ID','$metakey','$metavalue')
    9061085                    ");
    907     }
     1086        return $wpdb->insert_id;
     1087    }
     1088    return false;
    9081089} // add_meta
    9091090
    9101091function delete_meta($mid) {
    9111092    global $wpdb;
    912 
    913     $result = $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");
     1093    $mid = (int) $mid;
     1094
     1095    return $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_id = '$mid'");
    9141096}
    9151097
    9161098function update_meta($mid, $mkey, $mvalue) {
    9171099    global $wpdb;
    918 
     1100    $mvalue = maybe_serialize(stripslashes($mvalue));
     1101    $mvalue = $wpdb->escape($mvalue);
     1102    $mid = (int) $mid;
    9191103    return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'");
    9201104}
    9211105
     1106function get_post_meta_by_id($mid) {
     1107    global $wpdb;
     1108    $mid = (int) $mid;
     1109
     1110    $meta = $wpdb->get_row("SELECT * FROM $wpdb->postmeta WHERE meta_id = '$mid'");
     1111    if ( is_serialized_string($meta->meta_value) )
     1112        $meta->meta_value = maybe_unserialize($meta->meta_value);
     1113    return $meta;
     1114}
     1115
    9221116function touch_time($edit = 1, $for_post = 1) {
    923     global $month, $post, $comment;
     1117    global $wp_locale, $post, $comment;
    9241118
    9251119    if ( $for_post )
     
    9281122    echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__('Edit timestamp').'</label></legend>';
    9291123
    930     $time_adj = time() + (get_settings('gmt_offset') * 3600);
     1124    $time_adj = time() + (get_option('gmt_offset') * 3600);
    9311125    $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
    9321126    $jj = ($edit) ? mysql2date('d', $post_date) : gmdate('d', $time_adj);
     
    9371131    $ss = ($edit) ? mysql2date('s', $post_date) : gmdate('s', $time_adj);
    9381132
    939     echo "<select name=\"mm\">\n";
     1133    echo "<select name=\"mm\" onchange=\"edit_date.checked=true\">\n";
    9401134    for ($i = 1; $i < 13; $i = $i +1) {
    9411135        echo "\t\t\t<option value=\"$i\"";
    9421136        if ($i == $mm)
    943             echo " selected='selected'";
    944         if ($i < 10) {
    945             $ii = "0".$i;
    946         } else {
    947             $ii = "$i";
    948         }
    949         echo ">".$month["$ii"]."</option>\n";
     1137            echo ' selected="selected"';
     1138        echo '>' . $wp_locale->get_month($i) . "</option>\n";
    9501139    }
    9511140?>
    9521141</select>
    953 <input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" />
    954 <input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" /> @
    955 <input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" /> :
    956 <input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" />
    957 <input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />
     1142<input type="text" id="jj" name="jj" value="<?php echo $jj; ?>" size="2" maxlength="2" onchange="edit_date.checked=true"/>
     1143<input type="text" id="aa" name="aa" value="<?php echo $aa ?>" size="4" maxlength="5" onchange="edit_date.checked=true" /> @
     1144<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" onchange="edit_date.checked=true" /> :
     1145<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
     1146<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
    9581147<?php
    9591148    if ( $edit ) {
    9601149        _e('Existing timestamp');
    961         echo ": {$month[$mm]} $jj, $aa @ $hh:$mn";
     1150        //echo ': ' . $wp_locale->get_month($mm) . "$jj, $aa @ $hh:$mn";
     1151        echo sprintf(__(': %1$s %2$s, %3$s @ %4$s:%5$s'), $wp_locale->get_month($mm), $jj, $aa, $hh, $mn);
    9621152    }
    9631153?>
     
    9841174        if ($markerdata) {
    9851175            $state = true;
    986             foreach ($markerdata as $markerline) {
     1176            foreach ($markerdata as $n => $markerline) {
    9871177                if (strstr($markerline, "# BEGIN {$marker}"))
    9881178                    $state = false;
    989                 if ($state)
    990                     fwrite($f, "{$markerline}\n");
     1179                if ($state) {
     1180                    if ( $n + 1 < count($markerdata) )
     1181                        fwrite($f, "{$markerline}\n");
     1182                    else
     1183                        fwrite($f, "{$markerline}");
     1184                }
    9911185                if (strstr($markerline, "# END {$marker}")) {
    9921186                    fwrite($f, "# BEGIN {$marker}\n");
     
    10711265}
    10721266
    1073 function the_quicktags() {
    1074     // Browser detection sucks, but until Safari supports the JS needed for this to work people just assume it's a bug in WP
    1075     if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Safari'))
    1076         echo '
    1077         <div id="quicktags">
    1078             <script src="../wp-includes/js/quicktags.js" type="text/javascript"></script>
    1079             <script type="text/javascript">if ( typeof tinyMCE == "undefined" || tinyMCE.configs.length < 1 ) edToolbar();</script>
    1080         </div>
    1081 ';
    1082     else echo '
    1083 <script type="text/javascript">
    1084 function edInsertContent(myField, myValue) {
    1085     //IE support
    1086     if (document.selection) {
    1087         myField.focus();
    1088         sel = document.selection.createRange();
    1089         sel.text = myValue;
    1090         myField.focus();
    1091     }
    1092     //MOZILLA/NETSCAPE support
    1093     else if (myField.selectionStart || myField.selectionStart == "0") {
    1094         var startPos = myField.selectionStart;
    1095         var endPos = myField.selectionEnd;
    1096         myField.value = myField.value.substring(0, startPos)
    1097                       + myValue
    1098                       + myField.value.substring(endPos, myField.value.length);
    1099         myField.focus();
    1100         myField.selectionStart = startPos + myValue.length;
    1101         myField.selectionEnd = startPos + myValue.length;
    1102     } else {
    1103         myField.value += myValue;
    1104         myField.focus();
    1105     }
    1106 }
    1107 </script>
    1108 ';
    1109 }
    1110 
    1111 function validate_current_theme() {
    1112     $theme_loc = 'wp-content/themes';
    1113     $theme_root = ABSPATH.$theme_loc;
    1114 
    1115     $template = get_settings('template');
    1116     $stylesheet = get_settings('stylesheet');
    1117 
    1118     if (($template != 'default') && (!file_exists("$theme_root/$template/index.php"))) {
    1119         update_option('template', 'default');
    1120         update_option('stylesheet', 'default');
    1121         do_action('switch_theme', 'Default');
    1122         return false;
    1123     }
    1124 
    1125     if (($stylesheet != 'default') && (!file_exists("$theme_root/$stylesheet/style.css"))) {
    1126         update_option('template', 'default');
    1127         update_option('stylesheet', 'default');
    1128         do_action('switch_theme', 'Default');
    1129         return false;
    1130     }
    1131 
    1132     return true;
    1133 }
    1134 
    11351267function get_broken_themes() {
    11361268    global $wp_broken_themes;
     
    11771309function parent_dropdown($default = 0, $parent = 0, $level = 0) {
    11781310    global $wpdb, $post_ID;
    1179     $items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_status = 'static' ORDER BY menu_order");
     1311    $items = $wpdb->get_results("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = $parent AND post_type = 'page' ORDER BY menu_order");
    11801312
    11811313    if ($items) {
     
    12051337    global $menu;
    12061338    global $submenu;
     1339    global $_wp_menu_nopriv;
     1340    global $_wp_submenu_nopriv;
     1341    global $plugin_page;
    12071342
    12081343    $parent = get_admin_page_parent();
    1209 
    1210     foreach ($menu as $menu_array) {
    1211         //echo "parent array: " . $menu_array[2];
    1212         if ($menu_array[2] == $parent) {
    1213             if (!current_user_can($menu_array[1])) {
     1344    /*echo "pa: $parent pn: $pagenow pp: $plugin_page<br/>";
     1345    echo "<pre>";
     1346    print_r($_wp_menu_nopriv);
     1347    print_r($_wp_submenu_nopriv);
     1348    echo "</pre>";*/
     1349    if ( isset($_wp_submenu_nopriv[$parent][$pagenow]) )
     1350        return false;
     1351
     1352    if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$parent][$plugin_page]) )
     1353        return false;
     1354   
     1355    if ( empty($parent) ) {
     1356        if ( isset($_wp_menu_nopriv[$pagenow]) )
     1357            return false;
     1358        if ( isset($_wp_submenu_nopriv[$pagenow][$pagenow]) )
     1359            return false;
     1360        if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$pagenow][$plugin_page]) )
     1361            return false;
     1362        foreach (array_keys($_wp_submenu_nopriv) as $key) {
     1363            if ( isset($_wp_submenu_nopriv[$key][$pagenow]) )
    12141364                return false;
    1215             } else {
    1216                 break;
    1217             }
    1218         }
     1365            if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$key][$plugin_page]) )
     1366            return false;   
     1367        }
     1368        return true;
    12191369    }
    12201370
     
    12221372        foreach ($submenu[$parent] as $submenu_array) {
    12231373            if ($submenu_array[2] == $pagenow) {
    1224                 if (!current_user_can($submenu_array[1])) {
     1374                if (current_user_can($submenu_array[1]))
     1375                    return true;
     1376                else
    12251377                    return false;
    1226                 } else {
    1227                     return true;
    1228                 }
    12291378            }
    12301379        }
    12311380    }
    12321381
     1382    foreach ($menu as $menu_array) {
     1383        if ($menu_array[2] == $parent) {
     1384            if (current_user_can($menu_array[1]))
     1385                return true;
     1386            else
     1387                return false;
     1388        }
     1389    }
     1390   
    12331391    return true;
    12341392}
     
    12871445    global $pagenow;
    12881446    global $plugin_page;
    1289 
    1290     if (isset ($parent_file) && !empty ($parent_file)) {
     1447    global $_wp_real_parent_file;
     1448    global $_wp_menu_nopriv;
     1449    global $_wp_submenu_nopriv;
     1450
     1451    if ( !empty ($parent_file) ) {
     1452        if ( isset($_wp_real_parent_file[$parent_file]) )
     1453            $parent_file = $_wp_real_parent_file[$parent_file];
     1454
    12911455        return $parent_file;
    12921456    }
     
    12961460            if ($parent_menu[2] == $plugin_page) {
    12971461                $parent_file = $plugin_page;
    1298                 return $plugin_page;
     1462                if ( isset($_wp_real_parent_file[$parent_file]) )
     1463                    $parent_file = $_wp_real_parent_file[$parent_file];
     1464                return $parent_file;
    12991465            }
    13001466        }
     1467        if ( isset($_wp_menu_nopriv[$plugin_page]) ) {
     1468            $parent_file = $plugin_page;
     1469            if ( isset($_wp_real_parent_file[$parent_file]) )
     1470                    $parent_file = $_wp_real_parent_file[$parent_file];
     1471            return $parent_file;
     1472        }           
     1473    }
     1474
     1475    if ( isset($plugin_page) && isset($_wp_submenu_nopriv[$pagenow][$plugin_page]) ) {
     1476        $parent_file = $pagenow;
     1477        if ( isset($_wp_real_parent_file[$parent_file]) )
     1478            $parent_file = $_wp_real_parent_file[$parent_file];
     1479        return $parent_file;       
    13011480    }
    13021481
    13031482    foreach (array_keys($submenu) as $parent) {
    13041483        foreach ($submenu[$parent] as $submenu_array) {
     1484            if ( isset($_wp_real_parent_file[$parent]) )
     1485                $parent = $_wp_real_parent_file[$parent];
    13051486            if ($submenu_array[2] == $pagenow) {
    13061487                $parent_file = $parent;
     
    13371518    global $submenu;
    13381519    global $menu;
     1520    global $_wp_real_parent_file;
     1521    global $_wp_submenu_nopriv;
     1522    global $_wp_menu_nopriv;
     1523
     1524    $file = plugin_basename($file);
    13391525
    13401526    $parent = plugin_basename($parent);
    1341     $file = plugin_basename($file);
     1527    if ( isset($_wp_real_parent_file[$parent]) )
     1528        $parent = $_wp_real_parent_file[$parent];
     1529
     1530    if ( !current_user_can($access_level) ) {
     1531        $_wp_submenu_nopriv[$parent][$file] = true;
     1532        return false;
     1533    }
    13421534
    13431535    // If the parent doesn't already have a submenu, add a link to the parent
     
    13451537    // parent file someone is trying to link back to the parent manually.  In
    13461538    // this case, don't automatically add a link back to avoid duplication.
    1347     if (!isset ($submenu[$parent]) && $file != $parent) {
     1539    if (!isset ($submenu[$parent]) && $file != $parent  ) {
    13481540        foreach ($menu as $parent_menu) {
    1349             if ($parent_menu[2] == $parent) {
     1541            if ( $parent_menu[2] == $parent && current_user_can($parent_menu[1]) ) {
    13501542                $submenu[$parent][] = $parent_menu;
    13511543            }
     
    13971589    switch ($code) {
    13981590        case 1 :
    1399             die(__('Sorry, can&#8217;t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'));
     1591            wp_die(__('Sorry, can&#8217;t edit files with ".." in the name. If you are trying to edit a file in your WordPress home directory, you can just type the name of the file in.'));
    14001592
    14011593        case 2 :
    1402             die(__('Sorry, can&#8217;t call files with their real path.'));
     1594            wp_die(__('Sorry, can&#8217;t call files with their real path.'));
    14031595
    14041596        case 3 :
    1405             die(__('Sorry, that file cannot be edited.'));
     1597            wp_die(__('Sorry, that file cannot be edited.'));
    14061598    }
    14071599}
    14081600
    14091601function get_home_path() {
    1410     $home = get_settings('home');
    1411     if ($home != '' && $home != get_settings('siteurl')) {
     1602    $home = get_option('home');
     1603    if ($home != '' && $home != get_option('siteurl')) {
    14121604        $home_path = parse_url($home);
    14131605        $home_path = $home_path['path'];
     
    14411633        return $wp_file_descriptions[basename($file)];
    14421634    }
    1443     elseif (file_exists(ABSPATH.$file)) {
    1444         $template_data = implode('', file(ABSPATH.$file));
     1635    elseif ( file_exists( ABSPATH . $file ) && is_file( ABSPATH . $file ) ) {
     1636        $template_data = implode('', file( ABSPATH . $file ));
    14451637        if (preg_match("|Template Name:(.*)|i", $template_data, $name))
    14461638            return $name[1];
     
    14731665    preg_match("|Author URI:(.*)|i", $plugin_data, $author_uri);
    14741666    if (preg_match("|Version:(.*)|i", $plugin_data, $version))
    1475         $version = $version[1];
     1667        $version = trim($version[1]);
    14761668    else
    14771669        $version = '';
    14781670
    1479     $description = wptexturize($description[1]);
     1671    $description = wptexturize(trim($description[1]));
    14801672
    14811673    $name = $plugin_name[1];
     
    14831675    $plugin = $name;
    14841676    if ('' != $plugin_uri[1] && '' != $name) {
    1485         $plugin = '<a href="'.$plugin_uri[1].'" title="'.__('Visit plugin homepage').'">'.$plugin.'</a>';
     1677        $plugin = '<a href="' . trim($plugin_uri[1]) . '" title="'.__('Visit plugin homepage').'">'.$plugin.'</a>';
    14861678    }
    14871679
    14881680    if ('' == $author_uri[1]) {
    1489         $author = $author_name[1];
    1490     } else {
    1491         $author = '<a href="'.$author_uri[1].'" title="'.__('Visit author homepage').'">'.$author_name[1].'</a>';
     1681        $author = trim($author_name[1]);
     1682    } else {
     1683        $author = '<a href="' . trim($author_uri[1]) . '" title="'.__('Visit author homepage').'">' . trim($author_name[1]) . '</a>';
    14921684    }
    14931685
     
    15031695
    15041696    $wp_plugins = array ();
    1505     $plugin_loc = 'wp-content/plugins';
    1506     $plugin_root = ABSPATH.$plugin_loc;
     1697    $plugin_root = ABSPATH . PLUGINDIR;
    15071698
    15081699    // Files in wp-content/plugins directory
     
    15291720    }
    15301721
    1531     if (!$plugins_dir || !$plugin_files) {
     1722    if ( !$plugins_dir || !$plugin_files )
    15321723        return $wp_plugins;
    1533     }
    1534 
    1535     sort($plugin_files);
    1536 
    1537     foreach ($plugin_files as $plugin_file) {
    1538         if ( !is_readable("$plugin_root/$plugin_file"))
     1724
     1725    foreach ( $plugin_files as $plugin_file ) {
     1726        if ( !is_readable("$plugin_root/$plugin_file") )
    15391727            continue;
    15401728
    15411729        $plugin_data = get_plugin_data("$plugin_root/$plugin_file");
    15421730
    1543         if (empty ($plugin_data['Name'])) {
     1731        if ( empty ($plugin_data['Name']) )
    15441732            continue;
    1545         }
    15461733
    15471734        $wp_plugins[plugin_basename($plugin_file)] = $plugin_data;
    15481735    }
     1736
     1737    uasort($wp_plugins, create_function('$a, $b', 'return strnatcasecmp($a["Name"], $b["Name"]);'));
    15491738
    15501739    return $wp_plugins;
     
    16551844        __("Failed to write file to disk."));
    16561845
    1657     // Accepted MIME types are set here as PCRE. Override with $override['mimes'].
    1658     $mimes = apply_filters('upload_mimes', array (
    1659         'jpg|jpeg|jpe' => 'image/jpeg',
    1660         'gif' => 'image/gif',
    1661         'png' => 'image/png',
    1662         'bmp' => 'image/bmp',
    1663         'tif|tiff' => 'image/tiff',
    1664         'ico' => 'image/x-icon',
    1665         'asf|asx|wax|wmv|wmx' => 'video/asf',
    1666         'avi' => 'video/avi',
    1667         'mov|qt' => 'video/quicktime',
    1668         'mpeg|mpg|mpe' => 'video/mpeg',
    1669         'txt|c|cc|h' => 'text/plain',
    1670         'rtx' => 'text/richtext',
    1671         'css' => 'text/css',
    1672         'htm|html' => 'text/html',
    1673         'mp3|mp4' => 'audio/mpeg',
    1674         'ra|ram' => 'audio/x-realaudio',
    1675         'wav' => 'audio/wav',
    1676         'ogg' => 'audio/ogg',
    1677         'mid|midi' => 'audio/midi',
    1678         'wma' => 'audio/wma',
    1679         'rtf' => 'application/rtf',
    1680         'js' => 'application/javascript',
    1681         'pdf' => 'application/pdf',
    1682         'doc' => 'application/msword',
    1683         'pot|pps|ppt' => 'application/vnd.ms-powerpoint',
    1684         'wri' => 'application/vnd.ms-write',
    1685         'xla|xls|xlt|xlw' => 'application/vnd.ms-excel',
    1686         'mdb' => 'application/vnd.ms-access',
    1687         'mpp' => 'application/vnd.ms-project',
    1688         'swf' => 'application/x-shockwave-flash',
    1689         'class' => 'application/java',
    1690         'tar' => 'application/x-tar',
    1691         'zip' => 'application/zip',
    1692         'gz|gzip' => 'application/x-gzip',
    1693         'exe' => 'application/x-msdownload'
    1694     ));
    1695 
    16961846    // All tests are on by default. Most can be turned off by $override[{test_name}] = false;
    16971847    $test_form = true;
     
    17211871        return $upload_error_handler($file, __('Specified file failed upload test.'));
    17221872
    1723     // A correct MIME type will pass this test.
     1873    // A correct MIME type will pass this test. Override $mimes or use the upload_mimes filter.
    17241874    if ( $test_type ) {
    1725         $type = false;
    1726         $ext = false;
    1727         foreach ($mimes as $ext_preg => $mime_match) {
    1728             $ext_preg = '![^.]\.(' . $ext_preg . ')$!i';
    1729             if ( preg_match($ext_preg, $file['name'], $ext_matches) ) {
    1730                 $type = $mime_match;
    1731                 $ext = $ext_matches[1];
    1732             }
    1733         }
     1875        $wp_filetype = wp_check_filetype($file['name'], $mimes);
     1876
     1877        extract($wp_filetype);
    17341878
    17351879        if ( !$type || !$ext )
     
    17581902                $filename = str_replace("$number$ext", ++$number . $ext, $filename);
    17591903        }
     1904        $filename = str_replace($ext, '', $filename);
     1905        $filename = sanitize_title_with_dashes($filename) . $ext;
    17601906    }
    17611907
     
    17631909    $new_file = $uploads['path'] . "/$filename";
    17641910    if ( false === @ move_uploaded_file($file['tmp_name'], $new_file) )
    1765         die(printf(__('The uploaded file could not be moved to %s.'), $file['path']));
     1911        wp_die(printf(__('The uploaded file could not be moved to %s.'), $uploads['path']));
    17661912
    17671913    // Set correct file permissions
     
    17721918    // Compute the URL
    17731919    $url = $uploads['url'] . "/$filename";
    1774 
    1775     return array('file' => $new_file, 'url' => $url, 'type' => $type);
     1920   
     1921    $return = apply_filters( 'wp_handle_upload', array('file' => $new_file, 'url' => $url, 'type' => $type) );
     1922
     1923    return $return;
    17761924}
    17771925
     
    17901938
    17911939function wp_import_upload_form($action) {
     1940    $size = strtolower( ini_get('upload_max_filesize') );
     1941    $bytes = 0;
     1942    if ( strstr( $size, 'k' ) )
     1943        $bytes = $size * 1024;
     1944    if ( strstr( $size, 'm' ) )
     1945        $bytes = $size * 1024 * 1024;
     1946    if ( strstr( $size, 'g' ) )
     1947        $bytes = $size * 1024 * 1024 * 1024;
    17921948?>
    1793 <script type="text/javascript">
    1794 function cancelUpload() {
    1795 o = document.getElementById('uploadForm');
    1796 o.method = 'GET';
    1797 o.action.value = 'view';
    1798 o.submit();
    1799 }
    1800 </script>
    1801 <form enctype="multipart/form-data" id="uploadForm" method="POST" action="<?php echo $action ?>">
    1802 <label for="upload"><?php _e('File:'); ?></label><input type="file" id="upload" name="import" />
     1949<form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo $action ?>">
     1950<p>
     1951<label for="upload"><?php _e('Choose a file from your computer:'); ?></label> (<?php printf( __('Maximum size: %s'), $size ); ?>)
     1952<input type="file" id="upload" name="import" size="25" />
    18031953<input type="hidden" name="action" value="save" />
    1804 <div id="buttons">
    1805 <input type="submit" value="<?php _e('Import'); ?>" />
    1806 <input type="button" value="<?php _e('Cancel'); ?>" onclick="cancelUpload()" />
    1807 </div>
     1954<input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" />
     1955</p>
     1956<p class="submit">
     1957<input type="submit" value="<?php _e('Upload file and import'); ?> &raquo;" />
     1958</p>
    18081959</form>
    1809 <?php   
     1960<?php
    18101961}
    18111962
     
    18181969
    18191970    $url = $file['url'];
    1820     $file = $file['file'];
     1971    $file = addslashes( $file['file'] );
    18211972    $filename = basename($file);
    18221973
     
    18351986}
    18361987
    1837 function user_can_richedit() {
    1838     if ( 'true' != get_user_option('rich_editing') )
    1839         return false;
    1840 
    1841     if ( preg_match('!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT']) )
    1842         return false;
    1843 
    1844     return true; // Best guess
    1845 }
    1846 
    18471988function the_attachment_links($id = false) {
    18481989    $id = (int) $id;
    18491990    $post = & get_post($id);
    18501991
    1851     if ( $post->post_status != 'attachment' )
     1992    if ( $post->post_type != 'attachment' )
    18521993        return false;
    18531994
    18541995    $icon = get_attachment_icon($post->ID);
    1855 
     1996    $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true );
     1997    $thumb = isset($attachment_data['thumb']);
    18561998?>
    1857 <p><?php _e('Text linked to file') ?><br />
    1858 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo basename($post->guid) ?></a></textarea></p>
    1859 <p><?php _e('Text linked to subpost') ?><br />
    1860 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $post->post_title ?></a></textarea></p>
     1999<form id="the-attachment-links">
     2000<table>
     2001    <col />
     2002    <col class="widefat" />
     2003    <tr>
     2004        <th scope="row"><?php _e('URL') ?></th>
     2005        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><?php echo $post->guid ?></textarea></td>
     2006    </tr>
    18612007<?php if ( $icon ) : ?>
    1862 <p><?php _e('Thumbnail linked to file') ?><br />
    1863 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo $icon ?></a></textarea></p>
    1864 <p><?php _e('Thumbnail linked to subpost') ?><br />
    1865 <textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment" id="<?php echo $post->ID ?>"><?php echo $icon ?></a></textarea></p>
     2008    <tr>
     2009        <th scope="row"><?php $thumb ? _e('Thumbnail linked to file') : _e('Image linked to file'); ?></th>
     2010        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid; ?>"><?php echo $icon ?></a></textarea></td>
     2011    </tr>
     2012    <tr>
     2013        <th scope="row"><?php $thumb ? _e('Thumbnail linked to page') : _e('Image linked to file'); ?></th>
     2014        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment wp-att-<?php echo $post->ID; ?>"><?php echo $icon ?></a></textarea></td>
     2015    </tr>
     2016<?php else : ?>
     2017    <tr>
     2018        <th scope="row"><?php _e('Link to file') ?></th>
     2019        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo $post->guid ?>" class="attachmentlink"><?php echo basename($post->guid);  ?></a></textarea></td>
     2020    </tr>
     2021    <tr>
     2022        <th scope="row"><?php _e('Link to page') ?></th>
     2023        <td><textarea rows="1" cols="40" type="text" class="attachmentlinks" readonly="readonly"><a href="<?php echo get_attachment_link($post->ID) ?>" rel="attachment wp-att-<?php echo $post->ID ?>"><?php the_title(); ?></a></textarea></td>
     2024    </tr>
    18662025<?php endif; ?>
     2026</table>
     2027</form>
    18672028<?php
    18682029}
     
    18772038}
    18782039
     2040function wp_reset_vars($vars) {
     2041    for ($i=0; $i<count($vars); $i += 1) {
     2042        $var = $vars[$i];
     2043        global $$var;
     2044
     2045        if (!isset($$var)) {
     2046            if (empty($_POST["$var"])) {
     2047                if (empty($_GET["$var"]))
     2048                    $$var = '';
     2049                else
     2050                    $$var = $_GET["$var"];
     2051            } else {
     2052                $$var = $_POST["$var"];
     2053            }
     2054        }
     2055    }
     2056}
     2057
     2058// If siteurl or home changed, reset cookies and flush rewrite rules.
     2059function update_home_siteurl($old_value, $value) {
     2060    global $wp_rewrite, $user_login, $user_pass_md5;
     2061
     2062    if ( defined("WP_INSTALLING") )
     2063        return;
     2064
     2065    // If home changed, write rewrite rules to new location.
     2066    $wp_rewrite->flush_rules();
     2067    // Clear cookies for old paths.
     2068    wp_clearcookie();
     2069    // Set cookies for new paths.
     2070    wp_setcookie($user_login, $user_pass_md5, true, get_option('home'), get_option('siteurl'));
     2071}
     2072
     2073add_action('update_option_home', 'update_home_siteurl', 10, 2);
     2074add_action('update_option_siteurl', 'update_home_siteurl', 10, 2);
     2075
     2076function wp_crop_image($src_file, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false) {
     2077    if ( ctype_digit($src_file) ) // Handle int as attachment ID
     2078        $src_file = get_attached_file($src_file);
     2079
     2080    $src = wp_load_image($src_file);
     2081
     2082    if ( !is_resource($src) )
     2083        return $src;
     2084
     2085    $dst = imagecreatetruecolor($dst_w, $dst_h);
     2086
     2087    if ( $src_abs ) {
     2088        $src_w -= $src_x;
     2089        $src_h -= $src_y;
     2090    }
     2091
     2092    imageantialias($dst, true);
     2093    imagecopyresampled($dst, $src, 0, 0, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h);
     2094
     2095    if ( !$dst_file )
     2096        $dst_file = str_replace(basename($src_file), 'cropped-'.basename($src_file), $src_file);
     2097
     2098    $dst_file = preg_replace('/\\.[^\\.]+$/', '.jpg', $dst_file);
     2099
     2100    if ( imagejpeg($dst, $dst_file) )
     2101        return $dst_file;
     2102    else
     2103        return false;
     2104}
     2105
     2106function wp_load_image($file) {
     2107    if ( ctype_digit($file) )
     2108        $file = get_attached_file($file);
     2109
     2110    if ( !file_exists($file) )
     2111        return "File '$file' doesn't exist?";
     2112
     2113    $contents = file_get_contents($file);
     2114
     2115    $image = imagecreatefromstring($contents);
     2116
     2117    if ( !is_resource($image) )
     2118        return "File '$file' is not image?";
     2119
     2120    return $image;
     2121}
     2122
    18792123?>
  • trunk/wp-admin/admin-header.php

    r3503 r4431  
    1 <?php 
     1<?php
    22@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    33if (!isset($_GET["page"])) require_once('admin.php');
    44if ( $editing ) {
    5     $dbx_js = true;
    6     $cat_js = true;
     5    wp_enqueue_script( array("dbx-admin-key?pagenow=$pagenow",'admin-custom-fields') );
     6    if ( current_user_can('manage_categories') )
     7        wp_enqueue_script( 'ajaxcat' );
     8    if ( user_can_richedit() )
     9        wp_enqueue_script( 'wp_tiny_mce' );
    710}
    8 if ( $list_js || $cat_js )
    9     $sack_js = true;
     11
     12get_admin_page_title();
     13
    1014?>
    11 <?php get_admin_page_title(); ?>
    1215<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    13 <html xmlns="http://www.w3.org/1999/xhtml">
     16<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    1417<head>
    15 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
     18<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
    1619<title><?php bloginfo('name') ?> &rsaquo; <?php echo $title; ?> &#8212; WordPress</title>
    17 <link rel="stylesheet" href="<?php echo get_settings('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" />
     20<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/wp-admin.css?version=<?php bloginfo('version'); ?>" type="text/css" />
     21<?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
     22<link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />
     23<?php endif; ?>
    1824<script type="text/javascript">
    1925//<![CDATA[
     
    2127//]]>
    2228</script>
    23 <script type="text/javascript" src="../wp-includes/js/fat.js"></script>
    24 <?php if ( $xfn_js ) { ?>
    25 <script type="text/javascript" src="xfn.js"></script>
    26 <?php } ?>
    27 <?php if ( $sack_js ) { ?>
    28 <script type="text/javascript" src="../wp-includes/js/tw-sack.js"></script>
    29 <?php } ?>
    30 <?php if ( $list_js ) { ?>
    31 <script type="text/javascript" src="list-manipulation.js"></script>
    32 <?php } ?>
    33 <?php if ( $dbx_js ) { ?>
    34 <script type="text/javascript" src="../wp-includes/js/dbx.js"></script>
    35 <script type="text/javascript">
    36 //<![CDATA[
    37 addLoadEvent( function() {
    38 <?php switch ( $pagenow ) : case 'post.php' : ?>
    39 var manager = new dbxManager('postmeta');
    40 <?php break; case 'page-new.php' : ?>
    41 var manager = new dbxManager('pagemeta');
    42 <?php break; endswitch; ?>
    43 });
    44 //]]>
    45 </script>
    46 <script type="text/javascript" src="../wp-includes/js/dbx-key.js"></script>
    47 <?php } ?>
    48 <?php if ( $editing && user_can_richedit() ) { ?>
    49 <script type="text/javascript" src="../wp-includes/js/tinymce/tiny_mce_gzip.php?ver=20051211"></script>
    50 <?php } ?>
    51 <?php if ( $cat_js ) { ?>
    52 <script type="text/javascript" src="cat-js.php"></script>
    53 <?php } ?>
    5429<?php if ( ($parent_file != 'link-manager.php') && ($parent_file != 'options-general.php') ) : ?>
    5530<style type="text/css">* html { overflow-x: hidden; }</style>
    56 <?php endif; ?>
    57 <?php do_action('admin_head'); ?>
     31<?php endif;
     32if ( isset($page_hook) )
     33    do_action('admin_print_scripts-' . $page_hook);
     34else if ( isset($plugin_page) )
     35    do_action('admin_print_scripts-' . $plugin_page);
     36do_action('admin_print_scripts');
     37
     38if ( isset($page_hook) )
     39    do_action('admin_head-' . $page_hook);
     40else if ( isset($plugin_page) )
     41    do_action('admin_head-' . $plugin_page);
     42do_action('admin_head');
     43?>
    5844</head>
    5945<body>
    6046<div id="wphead">
    61 <h1><?php echo wptexturize(get_settings(('blogname'))); ?> <span>(<a href="<?php echo get_settings('home') . '/'; ?>"><?php _e('View site') ?> &raquo;</a>)</span></h1>
     47<h1><?php echo wptexturize(get_option(('blogname'))); ?> <span>(<a href="<?php echo get_option('home') . '/'; ?>"><?php _e('View site &raquo;') ?></a>)</span></h1>
    6248</div>
    63 <div id="user_info"><p><?php printf(__('Howdy, <strong>%s</strong>.'), $user_identity) ?> [<a href="<?php echo get_settings('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php _e('Sign Out'); ?></a>, <a href="profile.php"><?php _e('My Account'); ?></a>] </p></div>
     49<div id="user_info"><p><?php printf(__('Howdy, <strong>%s</strong>.'), $user_identity) ?> [<a href="<?php echo get_option('siteurl'); ?>/wp-login.php?action=logout" title="<?php _e('Log out of this account') ?>"><?php _e('Sign Out'); ?></a>, <a href="profile.php"><?php _e('My Profile'); ?></a>] </p></div>
    6450
    6551<?php
  • trunk/wp-admin/admin.php

    r3503 r4431  
    66
    77if ( get_option('db_version') != $wp_db_version )
    8     die (sprintf(__("Your database is out-of-date.  Please <a href='%s'>upgrade</a>."), get_option('siteurl') . '/wp-admin/upgrade.php'));
     8    wp_die(sprintf(__("Your database is out-of-date.  Please <a href='%s'>upgrade</a>."), get_option('siteurl') . '/wp-admin/upgrade.php'));
    99   
    1010require_once(ABSPATH . 'wp-admin/admin-functions.php');
    1111require_once(ABSPATH . 'wp-admin/admin-db.php');
    12 require_once(ABSPATH . WPINC . '/registration-functions.php');
     12require_once(ABSPATH . WPINC . '/registration.php');
    1313
    1414auth_redirect();
     
    1818update_category_cache();
    1919
    20 get_currentuserinfo();
     20wp_get_current_user();
    2121
    22 $posts_per_page = get_settings('posts_per_page');
    23 $what_to_show = get_settings('what_to_show');
    24 $date_format = get_settings('date_format');
    25 $time_format = get_settings('time_format');
     22$posts_per_page = get_option('posts_per_page');
     23$what_to_show = get_option('what_to_show');
     24$date_format = get_option('date_format');
     25$time_format = get_option('time_format');
    2626
    27 $wpvarstoreset = array('profile','redirect','redirect_url','a','popuptitle','popupurl','text', 'trackback', 'pingback');
    28 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    29     $wpvar = $wpvarstoreset[$i];
    30     if (!isset($$wpvar)) {
    31         if (empty($_POST["$wpvar"])) {
    32             if (empty($_GET["$wpvar"])) {
    33                 $$wpvar = '';
    34             } else {
    35                 $$wpvar = $_GET["$wpvar"];
    36             }
    37         } else {
    38             $$wpvar = $_POST["$wpvar"];
    39         }
    40     }
     27wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'popuptitle', 'popupurl', 'text', 'trackback', 'pingback'));
     28
     29wp_enqueue_script( 'fat' );
     30
     31$editing = false;
     32
     33if (isset($_GET['page'])) {
     34    $plugin_page = stripslashes($_GET['page']);
     35    $plugin_page = plugin_basename($plugin_page);
    4136}
    42 
    43 $xfn_js = $sack_js = $list_js = $cat_js = $dbx_js = $editing = false;
    4437
    4538require(ABSPATH . '/wp-admin/menu.php');
    4639
    4740// Handle plugin admin pages.
    48 if (isset($_GET['page'])) {
    49     $plugin_page = stripslashes($_GET['page']);
    50     $plugin_page = plugin_basename($plugin_page);
     41if (isset($plugin_page)) {
    5142    $page_hook = get_plugin_page_hook($plugin_page, $pagenow);
    5243
    5344    if ( $page_hook ) {
     45        do_action('load-' . $page_hook);
    5446        if (! isset($_GET['noheader']))
    5547            require_once(ABSPATH . '/wp-admin/admin-header.php');
    56        
     48
    5749        do_action($page_hook);
    5850    } else {
    5951        if ( validate_file($plugin_page) ) {
    60             die(__('Invalid plugin page'));
     52            wp_die(__('Invalid plugin page'));
    6153        }
    62        
    63         if (! file_exists(ABSPATH . "wp-content/plugins/$plugin_page"))
    64             die(sprintf(__('Cannot load %s.'), $plugin_page));
     54
     55        if (! file_exists(ABSPATH . PLUGINDIR . "/$plugin_page"))
     56            wp_die(sprintf(__('Cannot load %s.'), htmlentities($plugin_page)));
     57
     58        do_action('load-' . $plugin_page);
    6559
    6660        if (! isset($_GET['noheader']))
    6761            require_once(ABSPATH . '/wp-admin/admin-header.php');
    68        
    69         include(ABSPATH . "wp-content/plugins/$plugin_page");
     62
     63        include(ABSPATH . PLUGINDIR . "/$plugin_page");
    7064    }
    71    
     65
    7266    include(ABSPATH . 'wp-admin/admin-footer.php');
    7367
    7468    exit();
    7569} else if (isset($_GET['import'])) {
    76    
     70
    7771    $importer = $_GET['import'];
    7872
     73    if ( ! current_user_can('import') )
     74        wp_die(__('You are not allowed to import.'));
     75
    7976    if ( validate_file($importer) ) {
    80         die(__('Invalid importer.'));
     77        wp_die(__('Invalid importer.'));
    8178    }
    82        
     79
    8380    if (! file_exists(ABSPATH . "wp-admin/import/$importer.php"))
    84         die(__('Cannot load importer.'));
    85    
     81        wp_die(__('Cannot load importer.'));
     82
    8683    include(ABSPATH . "wp-admin/import/$importer.php");
    8784
    88     $parent_file = 'import.php';
     85    $parent_file = 'edit.php';
     86    $submenu_file = 'import.php';
    8987    $title = __('Import');
    90    
     88
    9189    if (! isset($_GET['noheader']))
    9290        require_once(ABSPATH . 'wp-admin/admin-header.php');
     
    9896
    9997    call_user_func($wp_importers[$importer][2]);
    100            
     98
    10199    include(ABSPATH . 'wp-admin/admin-footer.php');
    102100
    103101    exit();
     102} else {
     103    do_action("load-$pagenow");
    104104}
    105105
  • trunk/wp-admin/bookmarklet.php

    r3503 r4431  
    44
    55if ( ! current_user_can('edit_posts') )
    6     die ("Cheatin' uh?");
     6    wp_die(__('Cheatin&#8217; uh?'));
    77
    88if ('b' == $a):
     
    2626$popuptitle = wp_specialchars(stripslashes($popuptitle));
    2727$text       = wp_specialchars(stripslashes(urldecode($text)));
    28    
     28
    2929$popuptitle = funky_javascript_fix($popuptitle);
    3030$text       = funky_javascript_fix($text);
    31    
     31
    3232$post_title = wp_specialchars($_REQUEST['post_title']);
    3333if (!empty($post_title))
     
    3535else
    3636    $post->post_title = $popuptitle;
    37    
     37
    3838 
    3939$content  = wp_specialchars($_REQUEST['content']);
     
    5151<head>
    5252<title><?php bloginfo('name') ?> &rsaquo; Bookmarklet &#8212; WordPress</title>
    53 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
     53<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
    5454<link rel="stylesheet" href="wp-admin.css" type="text/css" />
    5555
  • trunk/wp-admin/cat-js.php

    r3503 r4431  
    11<?php
    2 require_once('admin.php');
    3 header('Content-type: text/javascript; charset=' . get_settings('blog_charset'), true);
     2require_once('../wp-config.php');
     3cache_javascript_headers();
    44?>
    5 var ajaxCat = new sack();
    6 var newcat;
    7  
     5addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.topAdder=1;catList.alt=0;catList.showLink=0;});
     6addLoadEvent(newCatAddIn);
    87function newCatAddIn() {
    9     if ( !document.getElementById('jaxcat') ) return false;
    10     var ajaxcat = document.createElement('span');
    11     ajaxcat.id = 'ajaxcat';
    12 
    13     newcat = document.createElement('input');
    14     newcat.type = 'text';
    15     newcat.name = 'newcat';
    16     newcat.id = 'newcat';
    17     newcat.size = '16';
    18     newcat.setAttribute('autocomplete', 'off');
    19     newcat.onkeypress = ajaxNewCatKeyPress;
    20 
    21     var newcatSub = document.createElement('input');
    22     newcatSub.type = 'button';
    23     newcatSub.name = 'Button';
    24     newcatSub.id = 'catadd';
    25     newcatSub.value = '<?php echo addslashes(__('Add')); ?>';
    26     newcatSub.onclick = ajaxNewCat;
    27 
    28     ajaxcat.appendChild(newcat);
    29     ajaxcat.appendChild(newcatSub);
    30     document.getElementById('jaxcat').appendChild(ajaxcat);
    31 
    32     howto = document.createElement('span');
    33     howto.innerHTML = '<?php echo addslashes(__('Separate multiple categories with commas.')); ?>';
    34     howto.id = 'howto';
    35     ajaxcat.appendChild(howto);
     8    var jaxcat = $('jaxcat');
     9    if ( !jaxcat )
     10        return false;
     11    jaxcat.update('<span id="ajaxcat"><input type="text" name="newcat" id="newcat" size="16" autocomplete="off"/><input type="button" name="Button" id="catadd" value="<?php _e('Add'); ?>"/><span id="howto"><?php _e('Separate multiple categories with commas.'); ?></span></span>');
     12    $('newcat').onkeypress = function(e) { return killSubmit("catList.ajaxAdder('category','jaxcat');", e); };
     13    $('catadd').onclick = function() { catList.ajaxAdder('category', 'jaxcat'); };
    3614}
    37 
    38 addLoadEvent(newCatAddIn);
    39 
    40 function getResponseElement() {
    41     var p = document.getElementById('ajaxcatresponse');
    42     if (!p) {
    43         p = document.createElement('span');
    44         document.getElementById('jaxcat').appendChild(p);
    45         p.id = 'ajaxcatresponse';
    46     }
    47     return p;
    48 }
    49 
    50 function newCatLoading() {
    51     var p = getResponseElement();
    52     p.innerHTML = '<?php echo addslashes(__('Sending Data...')); ?>';
    53 }
    54 
    55 function newCatLoaded() {
    56     var p = getResponseElement();
    57     p.innerHTML = '<?php echo addslashes(__('Data Sent...')); ?>';
    58 }
    59 
    60 function newCatInteractive() {
    61     var p = getResponseElement();
    62     p.innerHTML = '<?php echo addslashes(__('Processing Request...')); ?>';
    63 }
    64 
    65 function newCatCompletion() {
    66     var p = getResponseElement();
    67     var id    = 0;
    68     var ids   = new Array();
    69     var names = new Array();
    70    
    71     ids   = myPload( ajaxCat.response );
    72     names = myPload( newcat.value );
    73     for ( i = 0; i < ids.length; i++ ) {
    74         id = ids[i].replace(/[\n\r]+/g, "");
    75         if ( id == '-1' ) {
    76             p.innerHTML = "<?php echo addslashes(__("You don't have permission to do that.")); ?>";
    77             return;
    78         }
    79         if ( id == '0' ) {
    80             p.innerHTML = "<?php echo addslashes(__('That category name is invalid.  Try something else.')); ?>";
    81             return;
    82         }
    83        
    84         var exists = document.getElementById('category-' + id);
    85        
    86         if (exists) {
    87             var moveIt = exists.parentNode;
    88             var container = moveIt.parentNode;
    89             container.removeChild(moveIt);
    90             container.insertBefore(moveIt, container.firstChild);
    91             moveIt.id = 'new-category-' + id;
    92             exists.checked = 'checked';
    93             var nowClass = moveIt.className;
    94             moveIt.className = nowClass + ' fade';
    95             Fat.fade_all();
    96             moveIt.className = nowClass;
    97         } else {
    98             var catDiv = document.getElementById('categorychecklist');
    99             var newLabel = document.createElement('label');
    100             newLabel.setAttribute('for', 'category-' + id);
    101             newLabel.id = 'new-category-' + id;
    102             newLabel.className = 'selectit fade';
    103    
    104             var newCheck = document.createElement('input');
    105             newCheck.type = 'checkbox';
    106             newCheck.value = id;
    107             newCheck.name = 'post_category[]';
    108             newCheck.id = 'category-' + id;
    109             newLabel.appendChild(newCheck);
    110    
    111             var newLabelText = document.createTextNode(' ' + names[i]);
    112             newLabel.appendChild(newLabelText);
    113    
    114             catDiv.insertBefore(newLabel, catDiv.firstChild);
    115             newCheck.checked = 'checked';
    116    
    117             Fat.fade_all();
    118             newLabel.className = 'selectit';
    119         }
    120         newcat.value = '';
    121     }
    122     p.parentNode.removeChild(p);
    123 //  var id = parseInt(ajaxCat.response, 10);
    124 }
    125 
    126 function ajaxNewCatKeyPress(e) {
    127     if (!e) {
    128         if (window.event) {
    129             e = window.event;
    130         } else {
    131             return;
    132         }
    133     }
    134     if (e.keyCode == 13) {
    135         ajaxNewCat();
    136         e.returnValue = false;
    137         e.cancelBubble = true;
    138         return false;
    139     }
    140 }
    141 
    142 function ajaxNewCat() {
    143     var newcat = document.getElementById('newcat');
    144     var split_cats = new Array(1);
    145     var catString = '';
    146 
    147     catString = 'ajaxnewcat=' + encodeURIComponent(newcat.value);
    148     ajaxCat.requestFile = 'edit-form-ajax-cat.php';
    149     ajaxCat.method = 'GET';
    150     ajaxCat.onLoading = newCatLoading;
    151     ajaxCat.onLoaded = newCatLoaded;
    152     ajaxCat.onInteractive = newCatInteractive;
    153     ajaxCat.onCompletion = newCatCompletion;
    154     ajaxCat.runAJAX(catString);
    155 }
    156 
    157 function myPload( str ) {
    158     var fixedExplode = new Array();
    159     var comma = new String(',');
    160     var count = 0;
    161     var currentElement = '';
    162 
    163     for( x=0; x < str.length; x++) {
    164         andy = str.charAt(x);
    165         if ( comma.indexOf(andy) != -1 ) {
    166             currentElement = currentElement.replace(new RegExp('^\\s*(.*?)\\s*$', ''), '$1'); // trim
    167             fixedExplode[count] = currentElement;
    168             currentElement = "";
    169             count++;
    170         } else {
    171             currentElement += andy;
    172         }
    173     }
    174 
    175     if ( currentElement != "" )
    176         fixedExplode[count] = currentElement;
    177     return fixedExplode;
    178 }
  • trunk/wp-admin/categories.php

    r3503 r4431  
    44$title = __('Categories');
    55$parent_file = 'edit.php';
    6 $list_js = true;
    76
    8 $wpvarstoreset = array('action','cat');
    9 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    10     $wpvar = $wpvarstoreset[$i];
    11     if (!isset($$wpvar)) {
    12         if (empty($_POST["$wpvar"])) {
    13             if (empty($_GET["$wpvar"])) {
    14                 $$wpvar = '';
    15             } else {
    16                 $$wpvar = $_GET["$wpvar"];
    17             }
    18         } else {
    19             $$wpvar = $_POST["$wpvar"];
    20         }
    21     }
    22 }
     7wp_reset_vars(array('action', 'cat'));
    238
    249switch($action) {
     
    2611case 'addcat':
    2712
     13    check_admin_referer('add-category');
     14
    2815    if ( !current_user_can('manage_categories') )
    29         die (__('Cheatin&#8217; uh?'));
    30    
    31     wp_insert_category($_POST);
     16        wp_die(__('Cheatin&#8217; uh?'));
    3217
    33     header('Location: categories.php?message=1#addcat');
     18    if( wp_insert_category($_POST ) ) {
     19        wp_redirect('categories.php?message=1#addcat');
     20    } else {
     21        wp_redirect('categories.php?message=4#addcat');
     22    }
    3423break;
    3524
    3625case 'delete':
    37 
    38     check_admin_referer();
     26    $cat_ID = (int) $_GET['cat_ID'];
     27    check_admin_referer('delete-category_' .  $cat_ID);
    3928
    4029    if ( !current_user_can('manage_categories') )
    41         die (__('Cheatin&#8217; uh?'));
     30        wp_die(__('Cheatin&#8217; uh?'));
    4231
    43     $cat_ID = (int) $_GET['cat_ID'];
    4432    $cat_name = get_catname($cat_ID);
    4533
    46     if ( 1 == $cat_ID )
    47         die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
     34    // Don't delete the default cats.
     35    if ( $cat_ID == get_option('default_category') )
     36        wp_die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
     37
     38    if ( $cat_ID == get_option('default_link_category') )
     39        wp_die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one for bookmarks"), $cat_name));
    4840
    4941    wp_delete_category($cat_ID);
    5042
    51     header('Location: categories.php?message=2');
     43    wp_redirect('categories.php?message=2');
    5244
    5345break;
     
    5850    $cat_ID = (int) $_GET['cat_ID'];
    5951    $category = get_category_to_edit($cat_ID);
    60     ?>
    61 
    62 <div class="wrap">
    63  <h2><?php _e('Edit Category') ?></h2>
    64  <form name="editcat" action="categories.php" method="post">
    65       <table class="editform" width="100%" cellspacing="2" cellpadding="5">
    66         <tr>
    67           <th width="33%" scope="row"><?php _e('Category name:') ?></th>
    68           <td width="67%"><input name="cat_name" type="text" value="<?php echo wp_specialchars($category->cat_name); ?>" size="40" /> <input type="hidden" name="action" value="editedcat" />
    69 <input type="hidden" name="cat_ID" value="<?php echo $category->cat_ID ?>" /></td>
    70         </tr>
    71         <tr>
    72             <th scope="row"><?php _e('Category slug:') ?></th>
    73             <td><input name="category_nicename" type="text" value="<?php echo wp_specialchars($category->category_nicename); ?>" size="40" /></td>
    74         </tr>
    75         <tr>
    76             <th scope="row"><?php _e('Category parent:') ?></th>
    77             <td>       
    78             <select name='category_parent'>
    79       <option value='0' <?php if (!$category->category_parent) echo " selected='selected'"; ?>><?php _e('None') ?></option>
    80       <?php wp_dropdown_cats($category->cat_ID, $category->category_parent); ?>
    81       </select></td>
    82         </tr>
    83         <tr>
    84             <th scope="row"><?php _e('Description:') ?></th>
    85             <td><textarea name="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->category_description, 1); ?></textarea></td>
    86         </tr>
    87         </table>
    88       <p class="submit"><input type="submit" name="submit" value="<?php _e('Edit category') ?> &raquo;" /></p>
    89  </form>
    90  <p><a href="categories.php"><?php _e('&laquo; Return to category list'); ?></a></p>
    91 </div>
    92     <?php
     52    include('edit-category-form.php');
    9353
    9454break;
    9555
    9656case 'editedcat':
     57    $cat_ID = (int) $_POST['cat_ID'];
     58    check_admin_referer('update-category_' . $cat_ID);
     59
    9760    if ( !current_user_can('manage_categories') )
    98         die (__('Cheatin&#8217; uh?'));
    99    
     61        wp_die(__('Cheatin&#8217; uh?'));
     62
    10063    wp_update_category($_POST);
    10164
    102     header('Location: categories.php?message=3');
     65    wp_redirect('categories.php?message=3');
    10366break;
    10467
    10568default:
    10669
     70wp_enqueue_script( 'admin-categories' );
    10771require_once ('admin-header.php');
    10872
     
    11074$messages[2] = __('Category deleted.');
    11175$messages[3] = __('Category updated.');
     76$messages[4] = __('Category not added.');
    11277?>
    11378
     
    12287    <h2><?php _e('Categories') ?> </h2>
    12388<?php endif; ?>
    124 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
     89<table class="widefat">
     90    <thead>
    12591    <tr>
    126         <th scope="col"><?php _e('ID') ?></th>
     92        <th scope="col" style="text-align: center"><?php _e('ID') ?></th>
    12793        <th scope="col"><?php _e('Name') ?></th>
    12894        <th scope="col"><?php _e('Description') ?></th>
    129         <th scope="col"><?php _e('# Posts') ?></th>
    130         <th colspan="2"><?php _e('Action') ?></th>
     95        <th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th>
     96        <th scope="col" width="90" style="text-align: center"><?php _e('Bookmarks') ?></th>
     97        <th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
    13198    </tr>
     99    </thead>
     100    <tbody id="the-list">
    132101<?php
    133102cat_rows();
    134103?>
     104    </tbody>
    135105</table>
    136 
    137 <div id="ajax-response"></div>
    138106
    139107</div>
     
    141109<?php if ( current_user_can('manage_categories') ) : ?>
    142110<div class="wrap">
    143 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete posts from that category, it will just set them back to the default category <strong>%s</strong>.'), get_catname(get_option('default_category'))) ?></p>
     111<p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and bookmarks in that category.  Instead, posts in the deleted category are set to the category <strong>%s</strong> and bookmarks are set to <strong>%s</strong>.'), get_catname(get_option('default_category')), get_catname(get_option('default_link_category'))) ?></p>
    144112</div>
    145113
    146 <div class="wrap">
    147     <h2><?php _e('Add New Category') ?></h2>
    148     <form name="addcat" id="addcat" action="categories.php" method="post">
    149        
    150         <p><?php _e('Name:') ?><br />
    151         <input type="text" name="cat_name" value="" /></p>
    152         <p><?php _e('Category parent:') ?><br />
    153         <select name='category_parent' class='postform'>
    154         <option value='0'><?php _e('None') ?></option>
    155         <?php wp_dropdown_cats(0); ?>
    156         </select></p>
    157         <p><?php _e('Description: (optional)') ?> <br />
    158         <textarea name="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p>
    159         <p class="submit"><input type="hidden" name="action" value="addcat" /><input type="submit" name="submit" value="<?php _e('Add Category &raquo;') ?>" /></p>
    160     </form>
    161 </div>
     114<?php include('edit-category-form.php'); ?>
    162115<?php endif; ?>
    163116
     
    167120
    168121include('admin-footer.php');
     122
    169123?>
  • trunk/wp-admin/edit-comments.php

    r3503 r4431  
    44$title = __('Edit Comments');
    55$parent_file = 'edit.php';
    6 $list_js = true;
     6wp_enqueue_script( 'admin-comments' );
    77
    88require_once('admin-header.php');
     
    2424    }
    2525}
     26
     27function getNumChecked(form)
     28{
     29    var num = 0;
     30    for (i = 0, n = form.elements.length; i < n; i++) {
     31        if(form.elements[i].type == "checkbox") {
     32            if(form.elements[i].checked == true)
     33                num++;
     34        }
     35    }
     36    return num;
     37}
    2638//-->
    2739</script>
    2840<div class="wrap">
    2941<h2><?php _e('Comments'); ?></h2>
    30 <form name="searchform" action="" method="get">
     42<form name="searchform" action="" method="get" id="editcomments">
    3143  <fieldset>
    3244  <legend><?php _e('Show Comments That Contain...') ?></legend>
     
    3446  <input type="submit" name="submit" value="<?php _e('Search') ?>"  /> 
    3547  <input type="hidden" name="mode" value="<?php echo $mode; ?>" />
    36   <?php _e('(Searches within comment text, e-mail, URI, and IP address.)') ?>
     48  <?php _e('(Searches within comment text, e-mail, URL, and IP address.)') ?>
    3749  </fieldset>
    3850</form>
     
    4052<?php
    4153if ( !empty( $_POST['delete_comments'] ) ) :
     54    check_admin_referer('bulk-comments');
     55
    4256    $i = 0;
    4357    foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each
    4458        $comment = (int) $comment;
    4559        $post_id = $wpdb->get_var("SELECT comment_post_ID FROM $wpdb->comments WHERE comment_ID = $comment");
    46         $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
    47         if ( current_user_can('edit_post', $post_id) ) :
    48             wp_set_comment_status($comment, "delete");
     60        // $authordata = get_userdata( $wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $post_id") );
     61        if ( current_user_can('edit_post', $post_id) ) {
     62            if ( !empty( $_POST['spam_button'] ) )
     63                wp_set_comment_status($comment, 'spam');
     64            else
     65                wp_set_comment_status($comment, 'delete');
    4966            ++$i;
    50         endif;
     67        }
    5168    endforeach;
    52     echo "<div class='wrap'><p>" . sprintf(__('%s comments deleted.'), $i) . "</p></div>";
     69    echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
     70    if ( !empty( $_POST['spam_button'] ) )
     71        printf(__('%s comments marked as spam.'), $i);
     72    else
     73        printf(__('%s comments deleted.'), $i);
     74    echo '</p></div>';
    5375endif;
    5476
     
    78100            $start = '';
    79101
    80         echo "<ol id='the-list' class='commentlist' $start>";
     102        echo "<ol id='the-comment-list' class='commentlist' $start>";
    81103        $i = 0;
    82104        foreach ($comments as $comment) {
     
    89111                $class .= ' alternate';
    90112            echo "<li id='comment-$comment->comment_ID' class='$class'>";
    91 ?>     
    92         <p><strong><?php _e('Name:') ?></strong> <?php comment_author() ?> <?php if ($comment->comment_author_email) { ?>| <strong><?php _e('E-mail:') ?></strong> <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url ) { ?> | <strong><?php _e('URI:') ?></strong> <?php comment_author_url_link() ?> <?php } ?>| <strong><?php _e('IP:') ?></strong> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
    93        
    94         <?php comment_text() ?>
    95 
    96         <p><?php _e('Posted'); echo ' '; comment_date('M j, g:i A'); 
    97             if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    98                 echo " | <a href=\"post.php?action=editcomment&amp;comment=".$comment->comment_ID."\">" . __('Edit Comment') . "</a>";
    99                 echo " | <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars( $comment->comment_author, 1 ))  . "' );\">" . __('Delete Comment') . "</a> &#8212; ";
    100             } // end if any comments to show
    101             // Get post title
    102             if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    103                 $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = $comment->comment_post_ID");
    104                 $post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
    105                 ?> <a href="post.php?action=edit&amp;post=<?php echo $comment->comment_post_ID; ?>"><?php printf(__('Edit Post &#8220;%s&#8221;'), stripslashes($post_title)); ?></a>
    106                 <?php } ?>
    107              | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a></p>
     113?>
     114<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
     115
     116<?php comment_text() ?>
     117
     118<p><?php comment_date('M j, g:i A');  ?> &#8212; [
     119<?php
     120if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
     121    echo " <a href='comment.php?action=editcomment&amp;comment=".$comment->comment_ID."'>" .  __('Edit') . '</a>';
     122    echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $comment->comment_post_ID . '&amp;comment=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
     123    if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
     124        echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $comment->comment_post_ID . '&amp;comment=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
     125        echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $comment->comment_post_ID . '&amp;comment=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
     126    }
     127    echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;delete_type=spam&amp;p=" . $comment->comment_post_ID . "&amp;comment=" . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to mark as spam."), js_escape( $comment->comment_author))  . "', theCommentList );\">" . __('Spam') . "</a> ";
     128}
     129$post = get_post($comment->comment_post_ID);
     130$post_title = wp_specialchars( $post->post_title, 'double' );
     131$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
     132?>
     133 | <a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ]</p>
    108134        </li>
    109135
    110 <?php } // end foreach ?>
     136<?php } // end foreach($comment) ?>
    111137</ol>
    112138
     
    114140
    115141<?php
    116     } else {
     142    } else { //no comments to show
    117143
    118144        ?>
    119145        <p>
    120146        <strong><?php _e('No comments found.') ?></strong></p>
    121        
     147
    122148        <?php
    123149    } // end if ($comments)
     
    125151
    126152    if ($comments) {
    127         echo '<form name="deletecomments" id="deletecomments" action="" method="post">
    128         <table width="100%" cellpadding="3" cellspacing="3">
     153        echo '<form name="deletecomments" id="deletecomments" action="" method="post"> ';
     154        wp_nonce_field('bulk-comments');
     155        echo '<table class="widefat">
     156<thead>
    129157  <tr>
    130     <th scope="col">*</th>
     158    <th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById(\'deletecomments\'));" /></th>
    131159    <th scope="col">' .  __('Name') . '</th>
    132160    <th scope="col">' .  __('E-mail') . '</th>
    133161    <th scope="col">' . __('IP') . '</th>
    134162    <th scope="col">' . __('Comment Excerpt') . '</th>
    135     <th scope="col" colspan="3">' .  __('Actions') . '</th>
    136   </tr>';
     163    <th scope="col" colspan="3" style="text-align: center">' .  __('Actions') . '</th>
     164  </tr>
     165</thead>';
    137166        foreach ($comments as $comment) {
    138167        $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
     168        $comment_status = wp_get_comment_status($comment->comment_ID);
    139169        $class = ('alternate' == $class) ? '' : 'alternate';
    140 ?>
    141   <tr class='<?php echo $class; ?>'>
     170        $class .= ('unapproved' == $comment_status) ? ' unapproved' : '';
     171?>
     172  <tr id="comment-<?php echo $comment->comment_ID; ?>" class='<?php echo $class; ?>'>
    142173    <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { ?><input type="checkbox" name="delete_comments[]" value="<?php echo $comment->comment_ID; ?>" /><?php } ?></td>
    143174    <td><?php comment_author_link() ?></td>
     
    145176    <td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td>
    146177    <td><?php comment_excerpt(); ?></td>
    147     <td><a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a></td>
     178    <td>
     179        <?php if ('unapproved' == $comment_status) { ?>
     180            (Unapproved)
     181        <?php } else { ?>
     182            <a href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php comment_ID() ?>" class="edit"><?php _e('View') ?></a>
     183        <?php } ?>
     184    </td>
    148185    <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    149     echo "<a href='post.php?action=editcomment&amp;comment=$comment->comment_ID' class='edit'>" .  __('Edit') . "</a>"; } ?></td>
     186    echo "<a href='comment.php?action=editcomment&amp;comment=$comment->comment_ID' class='edit'>" .  __('Edit') . "</a>"; } ?></td>
    150187    <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
    151             echo "<a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n  \'Cancel\' to stop, \'OK\' to delete."), $comment->comment_author) . "')\"    class='delete'>" . __('Delete') . "</a>"; } ?></td>
     188        echo "<a href=\"comment.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape( $comment->comment_author ))  . "', theCommentList );\" class='delete'>" . __('Delete') . "</a> ";
     189        } ?></td>
    152190  </tr>
    153191        <?php
    154192        } // end foreach
    155193    ?></table>
    156     <p><a href="javascript:;" onclick="checkAll(document.getElementById('deletecomments')); return false; "><?php _e('Invert Checkbox Selection') ?></a></p>
    157             <p class="submit"><input type="submit" name="Submit" value="<?php _e('Delete Checked Comments') ?> &raquo;" onclick="return confirm('<?php _e("You are about to delete these comments permanently \\n  \'Cancel\' to stop, \'OK\' to delete.") ?>')" /> </p>
     194<p class="submit"><input type="submit" name="delete_button" class="delete" value="<?php _e('Delete Checked Comments &raquo;') ?>" onclick="var numchecked = getNumChecked(document.getElementById('deletecomments')); if(numchecked < 1) { alert('<?php _e("Please select some comments to delete"); ?>'); return false } return confirm('<?php printf(__("You are about to delete %s comments permanently \\n  \'Cancel\' to stop, \'OK\' to delete."), "' + numchecked + '"); ?>')" />
     195            <input type="submit" name="spam_button" value="<?php _e('Mark Checked Comments as Spam &raquo;') ?>" onclick="return confirm('<?php _e("You are about to mark these comments as spam \\n  \'Cancel\' to stop, \'OK\' to mark as spam.") ?>')" /></p>
    158196  </form>
     197<div id="ajax-response"></div>
    159198<?php
    160199    } else {
  • trunk/wp-admin/edit-form-advanced.php

    r3503 r4431  
    1515
    1616<div class="wrap">
    17 <h2 id="write-post"><?php _e('Write Post'); ?><?php if ( 0 != $post_ID ) : ?>
    18  <small class="quickjump"><a href="#preview-post"><?php _e('preview &darr;'); ?></a></small><?php endif; ?></h2>
    1917<?php
    2018
     
    2220    $form_action = 'post';
    2321    $temp_ID = -1 * time();
    24     $form_extra = "<input type='hidden' name='temp_ID' value='$temp_ID' />";
     22    $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
     23    wp_nonce_field('add-post');
    2524} else {
    2625    $form_action = 'editpost';
    27     $form_extra = "<input type='hidden' name='post_ID' value='$post_ID' />";
     26    $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
     27    wp_nonce_field('update-post_' .  $post_ID);
    2828}
    2929
     
    3838    $already_pinged = explode("\n", trim($post->pinged));
    3939    foreach ($already_pinged as $pinged_url) {
    40         $pings .= "\n\t<li>$pinged_url</li>";
     40        $pings .= "\n\t<li>" . wp_specialchars($pinged_url) . "</li>";
    4141    }
    4242    $pings .= '</ul>';
     
    5050
    5151<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
    52 <input type="hidden" name="action" value="<?php echo $form_action ?>" />
     52<input type="hidden" id="hiddenaction" name="action" value="<?php echo $form_action ?>" />
     53<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
    5354<input type="hidden" name="post_author" value="<?php echo $post->post_author ?>" />
     55<input type="hidden" id="post_type" name="post_type" value="post" />
    5456
    5557<?php echo $form_extra ?>
     
    6769<div id="moremeta">
    6870<div id="grabit" class="dbx-group">
     71
     72<fieldset id="categorydiv" class="dbx-box">
     73<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
     74<div class="dbx-content">
     75<p id="jaxcat"></p>
     76<ul id="categorychecklist"><?php dropdown_categories(); ?></ul></div>
     77</fieldset>
    6978
    7079<fieldset id="commentstatusdiv" class="dbx-box">
     
    8089
    8190<fieldset id="passworddiv" class="dbx-box">
    82 <h3 class="dbx-handle"><?php _e('Password-Protect Post') ?></h3>
     91<h3 class="dbx-handle"><?php _e('Post Password') ?></h3>
    8392<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password ?>" /></div>
    8493</fieldset>
    8594
    8695<fieldset id="slugdiv" class="dbx-box">
    87 <h3 class="dbx-handle"><?php _e('Post slug') ?></h3>
     96<h3 class="dbx-handle"><?php _e('Post Slug') ?></h3>
    8897<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo $post->post_name ?>" /></div>
    8998</fieldset>
    9099
    91 <fieldset id="categorydiv" class="dbx-box">
    92 <h3 class="dbx-handle"><?php _e('Categories') ?></h3>
    93 <div class="dbx-content">
    94 <p id="jaxcat"></p>
    95 <div id="categorychecklist"><?php dropdown_categories(get_settings('default_category')); ?></div></div>
    96 </fieldset>
    97 
    98 <fieldset class="dbx-box">
     100<fieldset id="poststatusdiv" class="dbx-box">
    99101<h3 class="dbx-handle"><?php _e('Post Status') ?></h3>
    100102<div class="dbx-content"><?php if ( current_user_can('publish_posts') ) : ?>
    101 <label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); ?> /> <?php _e('Published') ?></label>
     103<label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label>
    102104<?php endif; ?>
    103105      <label for="post_status_draft" class="selectit"><input id="post_status_draft" name="post_status" type="radio" value="draft" <?php checked($post->post_status, 'draft'); ?> /> <?php _e('Draft') ?></label>
     
    106108
    107109<?php if ( current_user_can('edit_posts') ) : ?>
    108 <fieldset class="dbx-box">
     110<fieldset id="posttimestampdiv" class="dbx-box">
    109111<h3 class="dbx-handle"><?php _e('Post Timestamp'); ?>:</h3>
    110112<div class="dbx-content"><?php touch_time(($action == 'edit')); ?></div>
     
    112114<?php endif; ?>
    113115
    114 <?php if ( $authors = get_editable_authors( $current_user->id ) ) : // TODO: ROLE SYSTEM ?>
     116<?php
     117$authors = get_editable_authors( $current_user->id ); // TODO: ROLE SYSTEM
     118if ( $authors && count( $authors ) > 1 ) :
     119?>
    115120<fieldset id="authordiv" class="dbx-box">
    116 <h3 class="dbx-handle"><?php _e('Post author'); ?>:</h3>
     121<h3 class="dbx-handle"><?php _e('Post Author'); ?>:</h3>
    117122<div class="dbx-content">
    118123<select name="post_author_override" id="post_author_override">
     
    143148<legend><?php _e('Post') ?></legend>
    144149
    145 <?php
    146  $rows = get_settings('default_post_edit_rows');
    147  if (($rows < 3) || ($rows > 100)) {
    148      $rows = 12;
    149  }
    150 ?>
    151 <?php the_quicktags(); ?>
    152 
    153 <div><textarea <?php if ( user_can_richedit() ) echo 'title="true" '; ?>rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="2" id="content"><?php echo user_can_richedit() ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div>
    154 </fieldset>
    155 
    156 <script type="text/javascript">
    157 <!--
    158 edCanvas = document.getElementById('content');
    159 <?php if ( user_can_richedit() ) : ?>
    160 // This code is meant to allow tabbing from Title to Post (TinyMCE).
    161 if ( tinyMCE.isMSIE )
    162     document.getElementById('title').onkeydown = function (e)
    163         {
    164             e = e ? e : window.event;
    165             if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
    166                 var i = tinyMCE.selectedInstance;
    167                 if(typeof i ==  'undefined')
    168                     return true;
    169                                 tinyMCE.execCommand("mceStartTyping");
    170                 this.blur();
    171                 i.contentWindow.focus();
    172                 e.returnValue = false;
    173                 return false;
    174             }
    175         }
    176 else
    177     document.getElementById('title').onkeypress = function (e)
    178         {
    179             e = e ? e : window.event;
    180             if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
    181                 var i = tinyMCE.selectedInstance;
    182                 if(typeof i ==  'undefined')
    183                     return true;
    184                                 tinyMCE.execCommand("mceStartTyping");
    185                 this.blur();
    186                 i.contentWindow.focus();
    187                 e.returnValue = false;
    188                 return false;
    189             }
    190         }
    191 <?php endif; ?>
    192 //-->
    193 </script>
     150    <?php the_editor($post->post_content); ?>
     151</fieldset>
    194152
    195153<?php echo $form_pingback ?>
     
    197155
    198156
    199 <p class="submit"><?php echo $saveasdraft; ?> <input type="submit" name="submit" value="<?php _e('Save') ?>" style="font-weight: bold;" tabindex="4" />
     157<p class="submit">
     158<span id="autosave"></span>
     159<?php echo $saveasdraft; ?>
     160<input type="submit" name="submit" value="<?php _e('Save') ?>" style="font-weight: bold;" tabindex="4" />
    200161<?php
    201162if ('publish' != $post->post_status || 0 == $post_ID) {
     
    210171if ( !empty($_REQUEST['popupurl']) )
    211172    echo wp_specialchars($_REQUEST['popupurl']);
    212 else if ( url_to_postid($_SERVER['HTTP_REFERER']) == $post_ID )
     173else if ( url_to_postid(wp_get_referer()) == $post_ID )
    213174    echo 'redo';
    214175else
    215     echo wp_specialchars($_SERVER['HTTP_REFERER']);
     176    echo wp_specialchars(wp_get_referer());
    216177?>" /></p>
    217178
     
    221182if (current_user_can('upload_files')) {
    222183    $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
    223     $uploading_iframe_src = "inline-uploading.php?action=view&amp;post=$uploading_iframe_ID";
     184    $uploading_iframe_src = wp_nonce_url("upload.php?style=inline&amp;tab=upload&amp;post_id=$uploading_iframe_ID", 'inlineuploading');
    224185    $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
    225186    if ( false != $uploading_iframe_src )
    226         echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
     187        echo '<iframe id="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
    227188}
    228189?>
     
    230191<div id="advancedstuff" class="dbx-group" >
    231192
     193<div class="dbx-box-wrapper">
    232194<fieldset id="postexcerpt" class="dbx-box">
     195<div class="dbx-handle-wrapper">
    233196<h3 class="dbx-handle"><?php _e('Optional Excerpt') ?></h3>
     197</div>
     198<div class="dbx-content-wrapper">
    234199<div class="dbx-content"><textarea rows="1" cols="40" name="excerpt" tabindex="6" id="excerpt"><?php echo $post->post_excerpt ?></textarea></div>
    235 </fieldset>
    236 
    237 <fieldset class="dbx-box">
     200</div>
     201</fieldset>
     202</div>
     203
     204<div class="dbx-box-wrapper">
     205<fieldset id="trackbacksdiv" class="dbx-box">
     206<div class="dbx-handle-wrapper">
    238207<h3 class="dbx-handle"><?php _e('Trackbacks') ?></h3>
     208</div>
     209<div class="dbx-content-wrapper">
    239210<div class="dbx-content"><?php _e('Send trackbacks to'); ?>: <?php echo $form_trackback; ?> (<?php _e('Separate multiple URIs with spaces'); ?>)
    240211<?php
     
    243214?>
    244215</div>
    245 </fieldset>
    246 
     216</div>
     217</fieldset>
     218</div>
     219
     220<div class="dbx-box-wrapper">
    247221<fieldset id="postcustom" class="dbx-box">
     222<div class="dbx-handle-wrapper">
    248223<h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3>
     224</div>
     225<div class="dbx-content-wrapper">
    249226<div id="postcustomstuff" class="dbx-content">
    250 <?php
    251 if($metadata = has_meta($post_ID)) {
    252 ?>
    253 <?php
    254     list_meta($metadata);
    255 ?>
    256 <?php
    257 }
     227<table cellpadding="3">
     228<?php
     229$metadata = has_meta($post_ID);
     230list_meta($metadata);
     231?>
     232
     233</table>
     234<?php
    258235    meta_form();
    259236?>
    260 </div>
    261 </fieldset>
     237<div id="ajax-response"></div>
     238</div>
     239</div>
     240</fieldset>
     241</div>
    262242
    263243<?php do_action('dbx_post_advanced'); ?>
     
    265245</div>
    266246
    267 <?php if ('edit' == $action) : ?>
    268 <input name="deletepost" class="button" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this post') ?>" <?php echo "onclick=\"return confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n  \'Cancel\' to stop, \'OK\' to delete."), addslashes($post->post_title) ) . "')\""; ?> />
     247<?php if ('edit' == $action) : $delete_nonce = wp_create_nonce( 'delete-post_' . $post_ID ); ?>
     248<input name="deletepost" class="button delete" type="submit" id="deletepost" tabindex="10" value="<?php _e('Delete this post') ?>" <?php echo "onclick=\"if ( confirm('" . sprintf(__("You are about to delete this post \'%s\'\\n  \'Cancel\' to stop, \'OK\' to delete."), js_escape($post->post_title) ) . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true;}return false;\""; ?> />
    269249<?php endif; ?>
    270250
  • trunk/wp-admin/edit-form-comment.php

    r3503 r4431  
    66?>
    77
    8 <form name="post" action="post.php" method="post" id="post">
     8<form name="post" action="comment.php" method="post" id="post">
     9<?php wp_nonce_field('update-comment_' . $comment->comment_ID) ?>
    910<div class="wrap">
    1011<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
     
    1819</script>
    1920<fieldset id="namediv">
    20     <legend><?php _e('Name:') ?></legend>
     21    <legend><label for="name"><?php _e('Name:') ?></label></legend>
    2122    <div>
    22       <input type="text" name="newcomment_author" size="22" value="<?php echo $comment->comment_author ?>" tabindex="1" id="name" />
     23      <input type="text" name="newcomment_author" size="25" value="<?php echo $comment->comment_author ?>" tabindex="1" id="name" />
    2324    </div>
    2425</fieldset>
    2526<fieldset id="emaildiv">
    26         <legend><?php _e('E-mail:') ?></legend>
     27        <legend><label for="email"><?php _e('E-mail:') ?></label></legend>
    2728        <div>
    28           <input type="text" name="newcomment_author_email" size="30" value="<?php echo $comment->comment_author_email ?>" tabindex="2" id="email" />
     29          <input type="text" name="newcomment_author_email" size="20" value="<?php echo $comment->comment_author_email ?>" tabindex="2" id="email" />
    2930    </div>
    3031</fieldset>
    3132<fieldset id="uridiv">
    32         <legend><?php _e('URI:') ?></legend>
     33        <legend><label for="URL"><?php _e('URL:') ?></label></legend>
    3334        <div>
    3435          <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url ?>" tabindex="3" id="URL" />
     
    3839<fieldset style="clear: both;">
    3940        <legend><?php _e('Comment') ?></legend>
    40 <?php the_quicktags(); ?>
    41 
    42 <?php
    43  $rows = get_settings('default_post_edit_rows');
    44  if (($rows < 3) || ($rows > 100)) {
    45      $rows = 10;
    46  }
    47 ?>
    48 <div><textarea title="true" rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content" style="width: 99%"><?php echo user_can_richedit() ? wp_richedit_pre($comment->comment_content) : $comment->comment_content; ?></textarea></div>
     41    <?php the_editor($comment->comment_content, 'content', 'newcomment_author_url'); ?>
    4942</fieldset>
    5043
    51 <script type="text/javascript">
    52 <!--
    53 edCanvas = document.getElementById('content');
    54 <?php if ( user_can_richedit() ) : ?>
    55 // This code is meant to allow tabbing from Author URL to Post (TinyMCE).
    56 if ( tinyMCE.isMSIE )
    57     document.getElementById('newcomment_author_url').onkeydown = function (e)
    58         {
    59             e = e ? e : window.event;
    60             if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
    61                 var i = tinyMCE.selectedInstance;
    62                 if(typeof i ==  'undefined')
    63                     return true;
    64                                 tinyMCE.execCommand("mceStartTyping");
    65                 this.blur();
    66                 i.contentWindow.focus();
    67                 e.returnValue = false;
    68                 return false;
    69             }
    70         }
    71 else
    72     document.getElementById('newcomment_author_url').onkeypress = function (e)
    73         {
    74             e = e ? e : window.event;
    75             if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
    76                 var i = tinyMCE.selectedInstance;
    77                 if(typeof i ==  'undefined')
    78                     return true;
    79                                 tinyMCE.execCommand("mceStartTyping");
    80                 this.blur();
    81                 i.contentWindow.focus();
    82                 e.returnValue = false;
    83                 return false;
    84             }
    85         }
    86 <?php endif; ?>
    87 //-->
    88 </script>
    89 
    9044<p class="submit"><input type="submit" name="editcomment" id="editcomment" value="<?php echo $submitbutton_text ?>" style="font-weight: bold;" tabindex="6" />
    91   <input name="referredby" type="hidden" id="referredby" value="<?php echo $_SERVER['HTTP_REFERER']; ?>" />
     45  <input name="referredby" type="hidden" id="referredby" value="<?php echo wp_get_referer(); ?>" />
    9246</p>
    9347
     
    10761<?php if ( current_user_can('edit_posts') ) : ?>
    10862    <tr>
    109         <th scope="row"><?php _e('Edit time'); ?>:</th>
    110         <td><?php touch_time(('editcomment' == $action), 0); ?></td>
     63        <th scope="row" valign="top"><?php _e('Edit time'); ?>:</th>
     64        <td><?php touch_time(('editcomment' == $action), 0); ?> </td>
    11165    </tr>
    11266<?php endif; ?>
    11367
    11468    <tr>
    115         <th scope="row"><?php _e('Delete'); ?>:</th>
    116         <td><p><a class="delete" href="post.php?action=confirmdeletecomment&amp;noredir=true&amp;comment=<?php echo $comment->comment_ID; ?>&amp;p=<?php echo $comment->comment_post_ID; ?>"><?php _e('Delete comment') ?></a></p></td>
     69        <th scope="row" valign="top"><?php _e('Delete'); $delete_nonce = wp_create_nonce( 'delete-comment_' . $comment->comment_ID ); ?>:</th>
     70        <td><input name="deletecomment" class="button delete" type="submit" id="deletecomment" tabindex="10" value="<?php _e('Delete this comment') ?>" <?php echo "onclick=\"if ( confirm('" . __("You are about to delete this comment \\n  \'Cancel\' to stop, \'OK\' to delete.") . "') ) { document.forms.post._wpnonce.value = '$delete_nonce'; return true; } return false;\""; ?> />
     71        <input type="hidden" name="comment" value="<?php echo $comment->comment_ID ?>" />
     72        <input type="hidden" name="p" value="<?php echo $comment->comment_post_ID ?>" />
     73        <input type="hidden" name="noredir" value="1" />
     74    </td>
    11775    </tr>
    11876</table>
  • trunk/wp-admin/edit-form.php

    r3503 r4431  
    3535<?php the_quicktags(); ?>
    3636<?php
    37  $rows = get_settings('default_post_edit_rows');
     37 $rows = get_option('default_post_edit_rows');
    3838 if (($rows < 3) || ($rows > 100)) {
    3939     $rows = 10;
     
    5252<input type="hidden" name="post_pingback" value="<?php echo get_option('default_pingback_flag') ?>" id="post_pingback" />
    5353
    54 <p><label for="trackback"> <?php printf(__('<a href="%s" title="Help on trackbacks"><strong>TrackBack</strong> a <abbr title="Universal Resource Identifier">URI</abbr></a>:</label> (Separate multiple <abbr title="Universal Resource Identifier">URI</abbr>s with spaces.)<br />'), 'http://wordpress.org/docs/reference/post/#trackback') ?>
     54<p><label for="trackback"> <?php printf(__('<a href="%s" title="Help on trackbacks"><strong>TrackBack</strong> a <abbr title="Universal Resource Locator">URL</abbr></a>:</label> (Separate multiple <abbr title="Universal Resource Locator">URL</abbr>s with spaces.)<br />'), 'http://wordpress.org/docs/reference/post/#trackback') ?>
    5555    <input type="text" name="trackback_url" style="width: 360px" id="trackback" tabindex="7" /></p>
    5656
     
    6565      echo '<input name="advanced" type="submit" id="advancededit" tabindex="7" value="' .  __('Advanced Editing &raquo;') . '" />';
    6666  } ?>
    67   <input name="referredby" type="hidden" id="referredby" value="<?php if (isset($_SERVER['HTTP_REFERER'])) echo urlencode($_SERVER['HTTP_REFERER']); ?>" />
     67  <input name="referredby" type="hidden" id="referredby" value="<?php if ( wp_get_referer() ) echo urlencode(wp_get_referer()); ?>" />
    6868</p>
    6969
  • trunk/wp-admin/edit-link-form.php

    r3503 r4431  
    11<?php
    22if ( ! empty($link_id) ) {
    3     $editing = true;
    4     $heading = __('Edit a link:');
     3    $heading = __('Edit Link');
    54    $submit_text = __('Save Changes &raquo;');
    6     $form = '<form action="" method="post" name="editlink" id="editlink">';
     5    $form = '<form name="editlink" id="editlink" method="post" action="link.php">';
     6    $nonce_action = 'update-bookmark_' . $link_id;
    77} else {
    8     $editing = false;
    9     $heading = __('<strong>Add</strong> a link:');
     8    $heading = __('Add Link');
    109    $submit_text = __('Add Link &raquo;');
    11     $form = '<form name="addlink" method="post" action="link-manager.php">';
     10    $form = '<form name="addlink" id="addlink" method="post" action="link.php">';
     11    $nonce_action = 'add-bookmark';
    1212}
    1313
     
    2929    }
    3030}
    31 
    3231?>
    3332
    3433<div class="wrap">
    35   <?php echo $form ?>
    36   <h2><?php echo $heading ?></h2>
    37 <fieldset class="options">
    38     <legend><?php _e('Basics') ?></legend>
    39         <table class="editform" width="100%" cellspacing="2" cellpadding="5">
    40          <tr>
    41            <th width="33%" scope="row"><?php _e('URI:') ?></th>
    42            <td width="67%"><input type="text" name="link_url" value="<?php echo $link->link_url; ?>" style="width: 95%;" /></td>
    43          </tr>
    44          <tr>
    45            <th scope="row"><?php _e('Link Name:') ?></th>
    46            <td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
    47          </tr>
    48          <tr>
    49             <th scope="row"><?php _e('Short description:') ?></th>
    50             <td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
    51             </tr>
    52         <tr>
    53            <th scope="row"><?php _e('Category:') ?></th>
    54            <td><?php link_category_dropdown('link_category', $link->link_category); ?></td>
    55          </tr>
     34<h2><?php echo $heading ?></h2>
     35<?php echo $form ?>
     36<?php wp_nonce_field($nonce_action); ?>
     37
     38<div id="poststuff">
     39<div id="moremeta">
     40<div id="grabit" class="dbx-group">
     41
     42<fieldset id="categorydiv" class="dbx-box">
     43<h3 class="dbx-handle"><?php _e('Categories') ?></h3>
     44<div class="dbx-content">
     45<p id="jaxcat"></p>
     46<ul id="categorychecklist"><?php dropdown_link_categories(get_option('default_link_category')); ?></ul>
     47</div>
     48</fieldset>
     49
     50<fieldset class="dbx-box">
     51<h3 class="dbx-handle"><?php _e('Target') ?></h3>
     52<div class="dbx-content">
     53<label for="link_target_blank" class="selectit">
     54<input id="link_target_blank" type="radio" name="link_target" value="_blank" <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
     55<code>_blank</code></label>
     56<label for="link_target_top" class="selectit">
     57<input id="link_target_top" type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
     58<code>_top</code></label>
     59<label for="link_target_none" class="selectit">
     60<input id="link_target_none" type="radio" name="link_target" value="" <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
     61<?php _e('none') ?></label>
     62</div>
     63</fieldset>
     64
     65<fieldset class="dbx-box">
     66<h3 class="dbx-handle"><?php _e('Visible') ?></h3>
     67<div class="dbx-content">
     68<label for="link_visible_yes" class="selectit">
     69<input id="link_visible_yes" type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
     70<?php _e('Yes') ?></label>
     71<label for="link_visible_no" class="selectit">
     72<input id="link_visible_no" type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" />
     73<?php _e('No') ?></label>
     74</div>
     75</fieldset>
     76
     77</div>
     78</div>
     79
     80<table class="editform" width="100%" cellspacing="2" cellpadding="5">
     81<tr>
     82<th scope="row" valign="top"><label for="link_name"><?php _e('Name:') ?></label></th>
     83<td><input type="text" name="link_name" value="<?php echo $link->link_name; ?>" style="width: 95%" /></td>
     84</tr>
     85<tr>
     86<th width="20%" scope="row" valign="top"><label for="link_url"><?php _e('Address:') ?></label></th>
     87<td width="80%"><input type="text" name="link_url" value="<?php echo $link->link_url; if ( empty( $link->link_url ) ) echo 'http://'; ?>" style="width: 95%" /></td>
     88</tr>
     89<tr>
     90<th scope="row" valign="top"><label for="link_description"><?php _e('Description:') ?></label></th>
     91<td><input type="text" name="link_description" value="<?php echo $link->link_description; ?>" style="width: 95%" /></td>
     92</tr>
    5693</table>
    57 </fieldset>
    58        <p class="submit">
    59        <input type="submit" name="submit" value="<?php echo $submit_text ?>" />
    60        </p>
    61     <fieldset class="options">
    62         <legend><?php _e('Link Relationship (XFN)') ?></legend>
    63         <table class="editform" width="100%" cellspacing="2" cellpadding="5">
    64             <tr>
    65                 <th width="33%" scope="row"><?php _e('rel:') ?></th>
    66                 <td width="67%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td>
    67             </tr>
    68             <tr>
    69                 <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th>
    70                 <td>
    71                     <table cellpadding="3" cellspacing="5">
    72               <tr>
    73               <th scope="row"> <?php _e('identity') ?> </th>
    74               <td>
    75                 <label for="me">
    76                 <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
    77           <?php _e('another web address of mine') ?></label>
    78               </td>
    79             </tr>
    80             <tr>
    81               <th scope="row"> <?php _e('friendship') ?> </th>
    82               <td>
    83                 <label for="contact">
    84                 <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
    85                 <label for="acquaintance">
    86                 <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> />  <?php _e('acquaintance') ?></label>
    87                 <label id="friend">
    88                 <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
    89                 <label for="friendship">
    90                 <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label>
    91               </td>
    92             </tr>
    93             <tr>
    94               <th scope="row"> <?php _e('physical') ?> </th>
    95               <td>
    96                 <label for="met">
    97                 <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
    98           <?php _e('met') ?></label>
    99               </td>
    100             </tr>
    101             <tr>
    102               <th scope="row"> <?php _e('professional') ?> </th>
    103               <td>
    104                 <label for="co-worker">
    105                 <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
    106           <?php _e('co-worker') ?></label>
    107                 <label for="colleague">
    108                 <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
    109           <?php _e('colleague') ?></label>
    110               </td>
    111             </tr>
    112             <tr>
    113               <th scope="row"> <?php _e('geographical') ?> </th>
    114               <td>
    115                 <label for="co-resident">
    116                 <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
    117           <?php _e('co-resident') ?></label>
    118                 <label for="neighbor">
    119                 <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
    120           <?php _e('neighbor') ?></label>
    121                 <label for="geographical">
    122                 <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
    123           <?php _e('none') ?></label>
    124               </td>
    125             </tr>
    126             <tr>
    127               <th scope="row"> <?php _e('family') ?> </th>
    128               <td>
    129                 <label for="child">
    130                 <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?>  />
    131           <?php _e('child') ?></label>
    132                 <label for="kin">
    133                 <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?>  />
    134           <?php _e('kin') ?></label>
    135                 <label for="parent">
    136                 <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
    137           <?php _e('parent') ?></label>
    138                 <label for="sibling">
    139                 <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
    140           <?php _e('sibling') ?></label>
    141                 <label for="spouse">
    142                 <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
    143           <?php _e('spouse') ?></label>
    144                 <label for="family">
    145                 <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
    146           <?php _e('none') ?></label>
    147               </td>
    148             </tr>
    149             <tr>
    150               <th scope="row"> <?php _e('romantic') ?> </th>
    151               <td>
    152                 <label for="muse">
    153                 <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
    154          <?php _e('muse') ?></label>
    155                 <label for="crush">
    156                 <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
    157          <?php _e('crush') ?></label>
    158                 <label for="date">
    159                 <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
    160          <?php _e('date') ?></label>
    161                 <label for="romantic">
    162                 <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
    163          <?php _e('sweetheart') ?></label>
    164               </td>
    165             </tr>
    166         </table>
    167           </td>
    168             </tr>
     94
     95<p class="submit">
     96<input type="submit" name="submit" value="<?php echo $submit_text ?>" />
     97</p>
     98
     99<div id="advancedstuff" class="dbx-group" >
     100
     101<fieldset id="xfn" class="dbx-box">
     102<h3 class="dbx-handle"><?php _e('Link Relationship (XFN)') ?></h3>
     103<div class="dbx-content">
     104<table class="editform" width="100%" cellspacing="2" cellpadding="5">
     105    <tr>
     106        <th width="20%" scope="row"><?php _e('rel:') ?></th>
     107        <td width="80%"><input type="text" name="link_rel" id="link_rel" size="50" value="<?php echo $link->link_rel; ?>" /></td>
     108    </tr>
     109    <tr>
     110        <th scope="row"><?php _e('<a href="http://gmpg.org/xfn/">XFN</a> Creator:') ?></th>
     111        <td>
     112            <table cellpadding="3" cellspacing="5">
     113                <tr>
     114                    <th scope="row"> <?php _e('identity') ?> </th>
     115                    <td>
     116                        <label for="me">
     117                        <input type="checkbox" name="identity" value="me" id="me" <?php xfn_check('identity', 'me'); ?> />
     118                        <?php _e('another web address of mine') ?></label>
     119                    </td>
     120                </tr>
     121                <tr>
     122                    <th scope="row"> <?php _e('friendship') ?> </th>
     123                    <td>
     124                        <label for="contact">
     125                        <input class="valinp" type="radio" name="friendship" value="contact" id="contact" <?php xfn_check('friendship', 'contact', 'radio'); ?> /> <?php _e('contact') ?></label>
     126                        <label for="acquaintance">
     127                        <input class="valinp" type="radio" name="friendship" value="acquaintance" id="acquaintance" <?php xfn_check('friendship', 'acquaintance', 'radio'); ?> />  <?php _e('acquaintance') ?></label>
     128                        <label for="friend">
     129                        <input class="valinp" type="radio" name="friendship" value="friend" id="friend" <?php xfn_check('friendship', 'friend', 'radio'); ?> /> <?php _e('friend') ?></label>
     130                        <label for="friendship">
     131                        <input name="friendship" type="radio" class="valinp" value="" id="friendship" <?php xfn_check('friendship', '', 'radio'); ?> /> <?php _e('none') ?></label>
     132                    </td>
     133                </tr>
     134                <tr>
     135                    <th scope="row"> <?php _e('physical') ?> </th>
     136                    <td>
     137                        <label for="met">
     138                        <input class="valinp" type="checkbox" name="physical" value="met" id="met" <?php xfn_check('physical', 'met'); ?> />
     139                        <?php _e('met') ?></label>
     140                    </td>
     141                </tr>
     142                <tr>
     143                    <th scope="row"> <?php _e('professional') ?> </th>
     144                    <td>
     145                        <label for="co-worker">
     146                        <input class="valinp" type="checkbox" name="professional" value="co-worker" id="co-worker" <?php xfn_check('professional', 'co-worker'); ?> />
     147                        <?php _e('co-worker') ?></label>
     148                        <label for="colleague">
     149                        <input class="valinp" type="checkbox" name="professional" value="colleague" id="colleague" <?php xfn_check('professional', 'colleague'); ?> />
     150                        <?php _e('colleague') ?></label>
     151                    </td>
     152                </tr>
     153                <tr>
     154                    <th scope="row"> <?php _e('geographical') ?> </th>
     155                    <td>
     156                        <label for="co-resident">
     157                        <input class="valinp" type="radio" name="geographical" value="co-resident" id="co-resident" <?php xfn_check('geographical', 'co-resident', 'radio'); ?> />
     158                        <?php _e('co-resident') ?></label>
     159                        <label for="neighbor">
     160                        <input class="valinp" type="radio" name="geographical" value="neighbor" id="neighbor" <?php xfn_check('geographical', 'neighbor', 'radio'); ?> />
     161                        <?php _e('neighbor') ?></label>
     162                        <label for="geographical">
     163                        <input class="valinp" type="radio" name="geographical" value="" id="geographical" <?php xfn_check('geographical', '', 'radio'); ?> />
     164                        <?php _e('none') ?></label>
     165                    </td>
     166                </tr>
     167                <tr>
     168                    <th scope="row"> <?php _e('family') ?> </th>
     169                    <td>
     170                        <label for="child">
     171                        <input class="valinp" type="radio" name="family" value="child" id="child" <?php xfn_check('family', 'child', 'radio'); ?>  />
     172                        <?php _e('child') ?></label>
     173                        <label for="kin">
     174                        <input class="valinp" type="radio" name="family" value="kin" id="kin" <?php xfn_check('family', 'kin', 'radio'); ?>  />
     175                        <?php _e('kin') ?></label>
     176                        <label for="parent">
     177                        <input class="valinp" type="radio" name="family" value="parent" id="parent" <?php xfn_check('family', 'parent', 'radio'); ?> />
     178                        <?php _e('parent') ?></label>
     179                        <label for="sibling">
     180                        <input class="valinp" type="radio" name="family" value="sibling" id="sibling" <?php xfn_check('family', 'sibling', 'radio'); ?> />
     181                        <?php _e('sibling') ?></label>
     182                        <label for="spouse">
     183                        <input class="valinp" type="radio" name="family" value="spouse" id="spouse" <?php xfn_check('family', 'spouse', 'radio'); ?> />
     184                        <?php _e('spouse') ?></label>
     185                        <label for="family">
     186                        <input class="valinp" type="radio" name="family" value="" id="family" <?php xfn_check('family', '', 'radio'); ?> />
     187                        <?php _e('none') ?></label>
     188                    </td>
     189                </tr>
     190                <tr>
     191                    <th scope="row"> <?php _e('romantic') ?> </th>
     192                    <td>
     193                        <label for="muse">
     194                        <input class="valinp" type="checkbox" name="romantic" value="muse" id="muse" <?php xfn_check('romantic', 'muse'); ?> />
     195                        <?php _e('muse') ?></label>
     196                        <label for="crush">
     197                        <input class="valinp" type="checkbox" name="romantic" value="crush" id="crush" <?php xfn_check('romantic', 'crush'); ?> />
     198                        <?php _e('crush') ?></label>
     199                        <label for="date">
     200                        <input class="valinp" type="checkbox" name="romantic" value="date" id="date" <?php xfn_check('romantic', 'date'); ?> />
     201                        <?php _e('date') ?></label>
     202                        <label for="romantic">
     203                        <input class="valinp" type="checkbox" name="romantic" value="sweetheart" id="romantic" <?php xfn_check('romantic', 'sweetheart'); ?> />
     204                        <?php _e('sweetheart') ?></label>
     205                    </td>
     206                </tr>
     207            </table>
     208        </td>
     209    </tr>
    169210</table>
    170 </fieldset>
    171        <p class="submit">
    172        <input type="submit" name="submit" value="<?php echo $submit_text ?>" />
    173        </p>
    174 <fieldset class="options">
    175         <legend><?php _e('Advanced') ?></legend>
    176         <table class="editform" width="100%" cellspacing="2" cellpadding="5">
    177          <tr>
    178            <th width="33%" scope="row"><?php _e('Image URI:') ?></th>
    179            <td width="67%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
    180          </tr>
    181 <tr>
    182            <th scope="row"><?php _e('RSS URI:') ?> </th>
    183            <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
    184          </tr>
    185          <tr>
    186            <th scope="row"><?php _e('Notes:') ?></th>
    187            <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td>
    188          </tr>
    189          <tr>
    190            <th scope="row"><?php _e('Rating:') ?></th>
    191            <td><select name="link_rating" size="1">
    192 <?php
    193     for ($r = 0; $r < 10; $r++) {
    194       echo('            <option value="'.$r.'" ');
    195       if ($link->link_rating == $r)
    196         echo 'selected="selected"';
    197       echo('>'.$r.'</option>');
    198     }
    199 ?>
    200            </select>
    201          &nbsp;<?php _e('(Leave at 0 for no rating.)') ?> </td>
    202          </tr>
    203          <tr>
    204            <th scope="row"><?php _e('Target') ?></th>
    205            <td><label>
    206           <input type="radio" name="link_target" value="_blank"   <?php echo(($link->link_target == '_blank') ? 'checked="checked"' : ''); ?> />
    207           <code>_blank</code></label><br />
    208 <label>
    209 <input type="radio" name="link_target" value="_top" <?php echo(($link->link_target == '_top') ? 'checked="checked"' : ''); ?> />
    210 <code>_top</code></label><br />
    211 <label>
    212 <input type="radio" name="link_target" value=""     <?php echo(($link->link_target == '') ? 'checked="checked"' : ''); ?> />
    213 <?php _e('none') ?></label><br />
    214 <?php _e('(Note that the <code>target</code> attribute is illegal in XHTML 1.1 and 1.0 Strict.)') ?></td>
    215          </tr>
    216          <tr>
    217            <th scope="row"><?php _e('Visible:') ?></th>
    218            <td><label>
    219              <input type="radio" name="link_visible" <?php if ($link->link_visible == 'Y') echo "checked='checked'"; ?> value="Y" />
    220 <?php _e('Yes') ?></label><br /><label>
    221 <input type="radio" name="link_visible" <?php if ($link->link_visible == 'N') echo "checked='checked'"; ?> value="N" />
    222 <?php _e('No') ?></label></td>
    223          </tr>
     211</div>
     212</fieldset>
     213
     214<fieldset id="advanced" class="dbx-box">
     215<h3 class="dbx-handle"><?php _e('Advanced') ?></h3>
     216<div class="dbx-content">
     217<table class="editform" width="100%" cellspacing="2" cellpadding="5">
     218    <tr>
     219        <th width="20%" scope="row"><?php _e('Image Address:') ?></th>
     220        <td width="80%"><input type="text" name="link_image" size="50" value="<?php echo $link->link_image; ?>" style="width: 95%" /></td>
     221    </tr>
     222    <tr>
     223        <th scope="row"><?php _e('RSS Address:') ?> </th>
     224        <td><input name="link_rss" type="text" id="rss_uri" value="<?php echo $link->link_rss; ?>" size="50" style="width: 95%" /></td>
     225    </tr>
     226    <tr>
     227        <th scope="row"><?php _e('Notes:') ?></th>
     228        <td><textarea name="link_notes" cols="50" rows="10" style="width: 95%"><?php echo $link->link_notes; ?></textarea></td>
     229    </tr>
     230    <tr>
     231        <th scope="row"><?php _e('Rating:') ?></th>
     232        <td><select name="link_rating" size="1">
     233        <?php
     234            for ($r = 0; $r < 10; $r++) {
     235                echo('            <option value="'.$r.'" ');
     236                if ($link->link_rating == $r)
     237                    echo 'selected="selected"';
     238                echo('>'.$r.'</option>');
     239            }
     240        ?></select>&nbsp;<?php _e('(Leave at 0 for no rating.)') ?>
     241        </td>
     242    </tr>
    224243</table>
    225244</fieldset>
    226 <p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p>
    227 <?php if ( $editing ) : ?>
    228           <input type="hidden" name="action" value="editlink" />
    229           <input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
    230           <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
    231           <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
     245</div>
     246
     247<?php if ( $link_id ) : ?>
     248<input type="hidden" name="action" value="save" />
     249<input type="hidden" name="link_id" value="<?php echo (int) $link_id; ?>" />
     250<input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
     251<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
    232252<?php else: ?>
    233         <input type="hidden" name="action" value="Add" />
     253<input type="hidden" name="action" value="add" />
    234254<?php endif; ?>
    235 </form>
    236 </div>
     255</div>
     256</form>
     257</div>
  • trunk/wp-admin/edit-page-form.php

    r3503 r4431  
    11
    22<div class="wrap">
    3 <h2 id="write-post"><?php _e('Write Page'); ?><?php if ( 0 != $post_ID ) : ?>
    4 <small class="quickjump"><a href="#preview-post"><?php _e('preview &darr;'); ?></a></small><?php endif; ?></h2>
     3<h2 id="write-post"><?php _e('Write Page'); ?></h2>
    54<?php
    65if (0 == $post_ID) {
    76    $form_action = 'post';
     7    $nonce_action = 'add-page';
    88    $temp_ID = -1 * time();
    9     $form_extra = "<input type='hidden' name='temp_ID' value='$temp_ID' />";
     9    $form_extra = "<input type='hidden' id='post_ID' name='temp_ID' value='$temp_ID' />";
    1010} else {
    1111    $form_action = 'editpost';
    12     $form_extra = "<input type='hidden' name='post_ID' value='$post_ID' />";
     12    $nonce_action = 'update-page_' . $post_ID;
     13    $form_extra = "<input type='hidden' id='post_ID' name='post_ID' value='$post_ID' />";
    1314}
    1415
    15 $sendto = $_SERVER['HTTP_REFERER'];
     16$sendto = wp_get_referer();
    1617
    1718if ( 0 != $post_ID && $sendto == get_permalink($post_ID) )
     
    2122?>
    2223
    23 <form name="post" action="post.php" method="post" id="post">
     24<form name="post" action="page.php" method="post" id="post">
    2425
    2526<?php
     27wp_nonce_field($nonce_action);
     28
    2629if (isset($mode) && 'bookmarklet' == $mode) {
    2730    echo '<input type="hidden" name="mode" value="bookmarklet" />';
     
    2932?>
    3033<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
    31 <input type="hidden" name="action" value='<?php echo $form_action ?>' />
     34<input type="hidden" id="hiddenaction" name="action" value='<?php echo $form_action ?>' />
     35<input type="hidden" id="originalaction" name="originalaction" value="<?php echo $form_action ?>" />
    3236<?php echo $form_extra ?>
    33 <input type="hidden" name="post_status" value="static" />
     37<input type="hidden" id="post_type" name="post_type" value="page" />
    3438
    3539<script type="text/javascript">
    36 <!--
     40// <![CDATA[
    3741function focusit() { // focus on first input field
    3842    document.post.title.focus();
    3943}
    4044addLoadEvent(focusit);
    41 //-->
     45// ]]>
    4246</script>
    4347<div id="poststuff">
     
    5660</fieldset>
    5761
     62<fieldset class="dbx-box">
     63<h3 class="dbx-handle"><?php _e('Page Status') ?></h3>
     64<div class="dbx-content"><?php if ( current_user_can('publish_pages') ) : ?>
     65<label for="post_status_publish" class="selectit"><input id="post_status_publish" name="post_status" type="radio" value="publish" <?php checked($post->post_status, 'publish'); checked($post->post_status, 'future'); ?> /> <?php _e('Published') ?></label>
     66<?php endif; ?>
     67      <label for="post_status_draft" class="selectit"><input id="post_status_draft" name="post_status" type="radio" value="draft" <?php checked($post->post_status, 'draft'); ?> /> <?php _e('Draft') ?></label>
     68      <label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="radio" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php _e('Private') ?></label></div>
     69</fieldset>
     70
    5871<fieldset id="passworddiv" class="dbx-box">
    59 <h3 class="dbx-handle"><?php _e('Password-Protect Post') ?></h3>
     72<h3 class="dbx-handle"><?php _e('Page Password') ?></h3>
    6073<div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password ?>" /></div>
    6174</fieldset>
     
    7184
    7285<?php if ( 0 != count( get_page_templates() ) ) { ?>
    73 <fieldset id="pageparent" class="dbx-box">
     86<fieldset id="pagetemplate" class="dbx-box">
    7487<h3 class="dbx-handle"><?php _e('Page Template:') ?></h3>
    7588<div class="dbx-content"><p><select name="page_template">
     
    8295
    8396<fieldset id="slugdiv" class="dbx-box">
    84 <h3 class="dbx-handle"><?php _e('Post slug') ?></h3>
     97<h3 class="dbx-handle"><?php _e('Page Slug') ?></h3>
    8598<div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo $post->post_name ?>" /></div>
    8699</fieldset>
     
    88101<?php if ( $authors = get_editable_authors( $current_user->id ) ) : // TODO: ROLE SYSTEM ?>
    89102<fieldset id="authordiv" class="dbx-box">
    90 <h3 class="dbx-handle"><?php _e('Post author'); ?>:</h3>
     103<h3 class="dbx-handle"><?php _e('Page Author'); ?>:</h3>
    91104<div class="dbx-content">
    92105<select name="post_author_override" id="post_author_override">
     
    122135<fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>">
    123136    <legend><?php _e('Page Content') ?></legend>
    124 <?php
    125  $rows = get_settings('default_post_edit_rows');
    126  if (($rows < 3) || ($rows > 100)) {
    127      $rows = 10;
    128  }
    129 ?>
    130 <?php the_quicktags(); ?>
    131 
    132 <div><textarea title="true" rows="<?php echo $rows; ?>" cols="40" name="content" tabindex="4" id="content"><?php echo user_can_richedit() ? wp_richedit_pre($post->post_content) : $post->post_content; ?></textarea></div>
     137    <?php the_editor($post->post_content); ?>
    133138</fieldset>
    134139
    135 <script type="text/javascript">
    136 <!--
    137 edCanvas = document.getElementById('content');
    138 <?php if ( user_can_richedit() ) : ?>
    139 // This code is meant to allow tabbing from Title to Post (TinyMCE).
    140 if ( tinyMCE.isMSIE )
    141     document.getElementById('title').onkeydown = function (e)
    142         {
    143             e = e ? e : window.event;
    144             if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
    145                 var i = tinyMCE.selectedInstance;
    146                 if(typeof i ==  'undefined')
    147                     return true;
    148                                 tinyMCE.execCommand("mceStartTyping");
    149                 this.blur();
    150                 i.contentWindow.focus();
    151                 e.returnValue = false;
    152                 return false;
    153             }
    154         }
    155 else
    156     document.getElementById('title').onkeypress = function (e)
    157         {
    158             e = e ? e : window.event;
    159             if (e.keyCode == 9 && !e.shiftKey && !e.controlKey && !e.altKey) {
    160                 var i = tinyMCE.selectedInstance;
    161                 if(typeof i ==  'undefined')
    162                     return true;
    163                                 tinyMCE.execCommand("mceStartTyping");
    164                 this.blur();
    165                 i.contentWindow.focus();
    166                 e.returnValue = false;
    167                 return false;
    168             }
    169         }
    170 <?php endif; ?>
    171 //-->
    172 </script>
    173 
    174140<p class="submit">
    175 <?php if ( $post_ID ) : ?>
    176 <input name="save" type="submit" id="save" tabindex="5" value=" <?php _e('Save and Continue Editing'); ?> "/>
    177 <input name="savepage" type="submit" id="savepage" tabindex="6" value="<?php $post_ID ? _e('Save') : _e('Create New Page') ?> &raquo;" />
    178 <?php else : ?>
    179 <input name="savepage" type="submit" id="savepage" tabindex="6" value="<?php _e('Create New Page') ?> &raquo;" />
    180 <?php endif; ?>
     141<span id="autosave"></span>
     142<input name="save" type="submit" id="save" tabindex="3" value="<?php _e('Save and Continue Editing'); ?>" />
     143<input type="submit" name="submit" value="<?php _e('Save') ?>" style="font-weight: bold;" tabindex="4" />
     144<?php
     145if ('publish' != $post->post_status || 0 == $post_ID):
     146?>
     147<?php if ( current_user_can('publish_pages') ) : ?>
     148    <input name="publish" type="submit" id="publish" tabindex="5" accesskey="p" value="<?php _e('Publish') ?>" />
     149<?php endif; endif;?>
    181150<input name="referredby" type="hidden" id="referredby" value="<?php echo $sendto; ?>" />
    182151</p>
     
    187156if (current_user_can('upload_files')) {
    188157    $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID);
    189     $uploading_iframe_src = "inline-uploading.php?action=view&amp;post=$uploading_iframe_ID";
     158    $uploading_iframe_src = wp_nonce_url("upload.php?style=inline&amp;tab=upload&amp;post_id=$uploading_iframe_ID", 'inlineuploading');
    190159    $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src);
    191160    if ( false != $uploading_iframe_src )
    192         echo '<iframe id="uploading" border="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
     161        echo '<iframe id="uploading" frameborder="0" src="' . $uploading_iframe_src . '">' . __('This feature requires iframe support.') . '</iframe>';
    193162}
    194163?>
     
    199168<h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3>
    200169<div id="postcustomstuff" class="dbx-content">
     170<table cellpadding="3">
    201171<?php
    202 if($metadata = has_meta($post_ID)) {
     172$metadata = has_meta($post_ID);
     173list_meta($metadata);
    203174?>
     175
     176</table>
    204177<?php
    205     list_meta($metadata);
    206 ?>
    207 <?php
    208 }
    209178    meta_form();
    210179?>
    211180</div>
     181<div id="ajax-response"></div>
    212182</fieldset>
    213183
     
    216186</div>
    217187
    218 <?php if ('edit' == $action) : ?>
    219         <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."), $wpdb->escape($post->post_title) ) . "')\""; ?> />
     188<?php if ('edit' == $action) :
     189    $delete_nonce = wp_create_nonce( 'delete-page_' . $post_ID );
     190    if ( current_user_can('delete_page', $post->ID) ) ?>
     191        <input name="deletepost" class="button delete" 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;\""; ?> />
    220192<?php endif; ?>
     193</div>
     194
    221195</form>
    222196
    223197</div>
    224 
    225 </div>
  • trunk/wp-admin/edit-pages.php

    r3503 r4431  
    33$title = __('Pages');
    44$parent_file = 'edit.php';
    5 $list_js = true;
     5wp_enqueue_script( 'listman' );
    66require_once('admin-header.php');
    77?>
     
    99<div class="wrap">
    1010<h2><?php _e('Page Management'); ?></h2>
    11 <p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page'); ?> &raquo;</a></p>
     11<p><?php _e('Pages are like posts except they live outside of the normal blog chronology and can be hierarchical. You can use pages to organize and manage any amount of content.'); ?> <a href="page-new.php"><?php _e('Create a new page &raquo;'); ?></a></p>
    1212
    1313<form name="searchform" action="" method="get">
     
    2020
    2121<?php
     22wp('post_type=page&orderby=menu_order&what_to_show=posts&posts_per_page=-1&posts_per_archive_page=-1');
    2223
    23 $show_post_type = 'page';
    24 
    25 if ( isset($_GET['s']) )
    26     wp();
     24if ( $_GET['s'] )
     25    $all = false;
    2726else
    28     $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static'");
     27    $all = true;
    2928
    3029if ($posts) {
    3130?>
    32 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
    33   <tr>
    34     <th scope="col"><?php _e('ID') ?></th>
    35     <th scope="col"><?php _e('Title') ?></th>
     31<table class="widefat">
     32  <thead>
     33  <tr>
     34    <th scope="col" style="text-align: center"><?php _e('ID') ?></th>
     35    <th scope="col"><?php _e('Title') ?></th>
    3636    <th scope="col"><?php _e('Owner') ?></th>
    3737    <th scope="col"><?php _e('Updated') ?></th>
    38     <th scope="col"></th>
    39     <th scope="col"></th>
    40     <th scope="col"></th>
    41   </tr>
     38    <th scope="col" colspan="3" style="text-align: center"><?php _e('Action'); ?></th>
     39  </tr>
     40  </thead>
     41  <tbody id="the-list">
    4242<?php
    43 if ( isset($_GET['s']) ) {
    44 foreach ( $posts as $post ) :
    45     $class = ('alternate' != $class) ? 'alternate' : ''; ?>
    46   <tr id='page-<?php echo $id; ?>' class='<?php echo $class; ?>'>
    47     <th scope="row"><?php echo $post->ID; ?></th>
    48     <td>
    49       <?php echo $pad; ?><?php the_title() ?>
    50     </td>
    51     <td><?php the_author() ?></td>
    52     <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td>
    53     <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td>
    54     <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=edit&amp;post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>
    55     <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the &quot;%s&quot; page.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td>
    56   </tr>
    57 <?php
    58 endforeach;
    59 } else {
    60     page_rows();
    61 }
     43page_rows(0, 0, $posts, $all);
    6244?>
    63 </table>
     45  </tbody>
     46</table>
    6447
    6548<div id="ajax-response"></div>
     
    7356?>
    7457
    75 <h3><a href="page-new.php"><?php _e('Create New Page'); ?> &raquo;</a></h3>
     58<h3><a href="page-new.php"><?php _e('Create New Page &raquo;'); ?></a></h3>
    7659
    7760</div>
  • trunk/wp-admin/edit.php

    r3503 r4431  
    44$title = __('Posts');
    55$parent_file = 'edit.php';
    6 $list_js = true;
     6wp_enqueue_script( 1 == $_GET['c'] ? 'admin-comments' : 'listman' );
    77require_once('admin-header.php');
    88
     
    5656<h2>
    5757<?php
    58 $what_to_show = 'posts';
    59 $posts_per_page = 15;
    60 $posts_per_archive_page = -1;
    61 
    62 wp();
     58
     59wp('what_to_show=posts&posts_per_page=15&posts_per_archive_page=-1');
    6360
    6461if ( is_month() ) {
     
    7774</h2>
    7875
    79 <form name="searchform" action="" method="get" style="float: left; width: 16em; margin-right: 3em;">
     76<form name="searchform" id="searchform" action="" method="get">
    8077  <fieldset>
    8178  <legend><?php _e('Search Posts&hellip;') ?></legend>
    8279  <input type="text" name="s" value="<?php if (isset($s)) echo wp_specialchars($s, 1); ?>" size="17" />
    83   <input type="submit" name="submit" value="<?php _e('Search') ?>" />
     80  <input type="submit" name="submit" value="<?php _e('Search') ?>" class="button" />
    8481  </fieldset>
    8582</form>
    8683
    87 <?php $arc_result = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_date != '0000-00-00 00:00:00' ORDER BY post_date DESC");
     84<?php $arc_result = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS yyear, MONTH(post_date) AS mmonth FROM $wpdb->posts WHERE post_type = 'post' ORDER BY post_date DESC");
    8885
    8986if ( count($arc_result) ) { ?>
    9087
    91 <form name="viewarc" action="" method="get" style="float: left; width: 20em; margin-bottom: 1em;">
     88<form name="viewarc" id="viewarc" action="" method="get">
    9289    <fieldset>
    9390    <legend><?php _e('Browse Month&hellip;') ?></legend>
    9491    <select name='m'>
    9592    <?php
    96         foreach ($arc_result as $arc_row) {         
    97             $arc_year  = $arc_row->yyear;
    98             $arc_month = $arc_row->mmonth;
    99            
    100             if( isset($_GET['m']) && $arc_year . zeroise($arc_month, 2) == (int) $_GET['m'] )
     93        foreach ($arc_result as $arc_row) {
     94            if ( $arc_row->yyear == 0 )
     95                continue;
     96            $arc_row->mmonth = zeroise($arc_row->mmonth, 2);
     97
     98            if( isset($_GET['m']) && $arc_row->yyear . $arc_row->mmonth == (int) $_GET['m'] )
    10199                $default = 'selected="selected"';
    102100            else
    103101                $default = null;
    104            
    105             echo "<option $default value=\"" . $arc_year.zeroise($arc_month, 2) . '">';
    106             echo $month[zeroise($arc_month, 2)] . " $arc_year";
     102
     103            echo "<option $default value='$arc_row->yyear$arc_row->mmonth'>";
     104            echo $wp_locale->get_month($arc_row->mmonth) . " $arc_row->yyear";
    107105            echo "</option>\n";
    108106        }
    109107    ?>
    110108    </select>
    111         <input type="submit" name="submit" value="<?php _e('Show Month') ?>" />
     109        <input type="submit" name="submit" value="<?php _e('Show Month') ?>" class="button" />
    112110    </fieldset>
    113111</form>
     
    115113<?php } ?>
    116114
     115<form name="viewcat" id="viewcat" action="" method="get">
     116    <fieldset>
     117    <legend><?php _e('Browse Category&hellip;') ?></legend>
     118    <?php wp_dropdown_categories('show_option_all='.__('All').'&hide_empty=1&hierarchical=1&show_count=1&selected='.$cat);?>
     119    <input type="submit" name="submit" value="<?php _e('Show Category') ?>" class="button" />
     120    </fieldset>
     121</form>
     122
     123<?php do_action('restrict_manage_posts'); ?>
     124
    117125<br style="clear:both;" />
    118126
    119127<?php
    120 
    121128// define the columns to display, the syntax is 'internal name' => 'display name'
    122129$posts_columns = array(
     
    137144?>
    138145
    139 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
     146<table class="widefat">
     147    <thead>
    140148    <tr>
    141149
     
    145153
    146154    </tr>
     155    </thead>
     156    <tbody id="the-list">
    147157<?php
    148158if ($posts) {
    149159$bgcolor = '';
    150160foreach ($posts as $post) { start_wp();
     161add_filter('the_title','wp_specialchars');
    151162$class = ('alternate' == $class) ? '' : 'alternate';
    152163?>
     
    158169
    159170    switch($column_name) {
    160    
     171
    161172    case 'id':
    162173        ?>
    163         <th scope="row"><?php echo $id ?></th>
     174        <th scope="row" style="text-align: center"><?php echo $id ?></th>
    164175        <?php
    165176        break;
     
    185196    case 'comments':
    186197        ?>
    187         <td><a href="edit.php?p=<?php echo $id ?>&amp;c=1">
     198        <td style="text-align: center"><a href="edit.php?p=<?php echo $id ?>&amp;c=1">
    188199      <?php comments_number(__('0'), __('1'), __('%')) ?>
    189200      </a></td>
     
    211222    case 'control_delete':
    212223        ?>
    213         <td><?php if ( current_user_can('edit_post',$post->ID) ) { echo "<a href='post.php?action=delete&amp;post=$id' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . sprintf(__("You are about to delete this post &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), wp_specialchars(get_the_title('', ''), 1) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
     224        <td><?php if ( current_user_can('delete_post',$post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post=$id", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . sprintf(__("You are about to delete this post &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), js_escape(get_the_title()) ) . "' );\">" . __('Delete') . "</a>"; } ?></td>
    214225        <?php
    215226        break;
     
    233244<?php
    234245} // end if ($posts)
    235 ?>
     246?>
     247    </tbody>
    236248</table>
    237249
     
    249261    if ($comments) {
    250262    ?>
    251 <h3><?php _e('Comments') ?></h3>
    252 <ol id="comments">
    253 <?php
     263<h3 id="comments"><?php _e('Comments') ?></h3>
     264<ol id="the-comment-list" class="commentlist">
     265<?php
     266$i = 0;
    254267foreach ($comments as $comment) {
    255 $comment_status = wp_get_comment_status($comment->comment_ID);
    256 ?>
    257 
    258 <li <?php if ("unapproved" == $comment_status) echo "class='unapproved'"; ?> >
    259   <?php comment_date('Y-n-j') ?>
    260   @
    261   <?php comment_time('g:m:s a') ?>
    262   <?php
    263             if ( current_user_can('edit_post', $post->ID) ) {
    264                 echo "[ <a href=\"post.php?action=editcomment&amp;comment=".$comment->comment_ID."\">" .  __('Edit') . "</a>";
    265                 echo " - <a href=\"post.php?action=deletecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n  \'OK\' to delete, \'Cancel\' to stop."), $comment->comment_author) . "')\">" . __('Delete') . "</a> ";
    266                 if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
    267                     if ('approved' == wp_get_comment_status($comment->comment_ID)) {
    268                         echo " - <a href=\"post.php?action=unapprovecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\">" . __('Unapprove') . "</a> ";
    269                     } else {
    270                         echo " - <a href=\"post.php?action=approvecomment&amp;p=".$post->ID."&amp;comment=".$comment->comment_ID."\">" . __('Approve') . "</a> ";
    271                     }
    272                 }
    273                 echo "]";
    274             } // end if any comments to show
    275             ?>
    276   <br />
    277   <strong>
    278   <?php comment_author() ?>
    279   (
    280   <?php comment_author_email_link() ?>
    281   /
    282   <?php comment_author_url_link() ?>
    283   )</strong> (IP:
    284   <?php comment_author_IP() ?>
    285   )
    286   <?php comment_text() ?>
    287 
    288 </li>
    289 <!-- /comment -->
     268
     269        ++$i; $class = '';
     270        $authordata = get_userdata($wpdb->get_var("SELECT post_author FROM $wpdb->posts WHERE ID = $comment->comment_post_ID"));
     271            $comment_status = wp_get_comment_status($comment->comment_ID);
     272            if ('unapproved' == $comment_status)
     273                $class .= ' unapproved';
     274            if ($i % 2)
     275                $class .= ' alternate';
     276            echo "<li id='comment-$comment->comment_ID' class='$class'>";
     277?>
     278<p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
     279
     280<?php comment_text() ?>
     281
     282<p><?php comment_date('M j, g:i A');  ?> &#8212; [
     283<?php
     284if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
     285    echo " <a href='comment.php?action=editcomment&amp;comment=".$comment->comment_ID."\'>" .  __('Edit') . '</a>';
     286    echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . '" onclick="return deleteSomething( \'comment\', ' . $comment->comment_ID . ', \'' . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($comment->comment_author)) . "', theCommentList );\">" . __('Delete') . '</a> ';
     287    if ( ('none' != $comment_status) && ( current_user_can('moderate_comments') ) ) {
     288        echo '<span class="unapprove"> | <a href="' . wp_nonce_url('comment.php?action=unapprovecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'unapprove-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Unapprove') . '</a> </span>';
     289        echo '<span class="approve"> | <a href="' . wp_nonce_url('comment.php?action=approvecomment&amp;p=' . $post->ID . '&amp;comment=' . $comment->comment_ID, 'approve-comment_' . $comment->comment_ID) . '" onclick="return dimSomething( \'comment\', ' . $comment->comment_ID . ', \'unapproved\', theCommentList );">' . __('Approve') . '</a> </span>';
     290    }
     291    echo " | <a href=\"" . wp_nonce_url("comment.php?action=deletecomment&amp;delete_type=spam&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID, 'delete-comment_' . $comment->comment_ID) . "\" onclick=\"return deleteSomething( 'comment-as-spam', $comment->comment_ID, '" . sprintf(__("You are about to mark as spam this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to mark as spam."), js_escape( $comment->comment_author))  . "', theCommentList );\">" . __('Spam') . "</a> ]";
     292} // end if any comments to show
     293?>
     294</p>
     295        </li>
     296
    290297<?php //end of the loop, don't delete
    291298        } // end foreach
  • trunk/wp-admin/import.php

    r3503 r4431  
    22require_once ('admin.php');
    33$title = __('Import');
    4 $parent_file = 'import.php';
     4$parent_file = 'edit.php';
    55require_once ('admin-header.php');
    66?>
     
    3131} else {
    3232?>
    33 <table width="100%" cellpadding="3" cellspacing="3">
     33<table class="widefat">
    3434
    3535<?php
     
    3737    foreach ($importers as $id => $data) {
    3838        $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate';
    39         $action = "<a href='admin.php?import=$id' title='{$data[1]}'>{$data[0]}</a>";
     39        $action = "<a href='admin.php?import=$id' title='".wptexturize(strip_tags($data[1]))."'>{$data[0]}</a>";
    4040
    4141        if ($style != '')
     
    4343        echo "
    4444            <tr $style>
    45                 <td class=\"togl\">$action</td>
    46                 <td class=\"desc\">{$data[1]}</td>
     45                <td class='import-system'>$action</td>
     46                <td class='desc'>{$data[1]}</td>
    4747            </tr>";
    4848    }
  • trunk/wp-admin/import/blogger.php

    r3503 r4431  
    2626    function restart() {
    2727        delete_option('import-blogger');
    28         header("Location: admin.php?import=blogger");
     28        wp_redirect("admin.php?import=blogger");
    2929        die();
    3030    }
     
    136136        if ($header) curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    137137        $response = curl_exec ($ch);
    138    
     138
    139139        if ($parse) {
    140140            $response = $this->parse_response($response);
     
    142142            return $response;
    143143        }
    144    
     144
    145145        return $response;
    146146    }
     
    211211        update_option('import-blogger', $this->import);
    212212    }
    213    
     213
    214214    // Redirects to next step
    215215    function do_next_step() {
    216         header("Location: admin.php?import=blogger&noheader=true&blog={$_GET['blog']}");
     216        wp_redirect("admin.php?import=blogger&noheader=true&blog={$_GET['blog']}");
    217217        die();
    218218    }
     
    225225                $this->login_form(__('The script will log into your Blogger account, change some settings so it can read your blog, and restore the original settings when it\'s done. Here\'s what you do:').'</p><ol><li>'.__('Back up your Blogger template.').'</li><li>'.__('Back up any other Blogger settings you might need later.').'</li><li>'.__('Log out of Blogger').'</li><li>'.__('Log in <em>here</em> with your Blogger username and password.').'</li><li>'.__('On the next screen, click one of your Blogger blogs.').'</li><li>'.__('Do not close this window or navigate away until the process is complete.').'</li></ol>');
    226226            }
    227        
    228             // Try logging in. If we get an array of cookies back, we at least connected.       
     227
     228            // Try logging in. If we get an array of cookies back, we at least connected.
    229229            $this->import['cookies'] = $this->login_blogger($_POST['user'], $_POST['pass']);
    230230            if ( !is_array( $this->import['cookies'] ) ) {
    231231                $this->login_form(__('Login failed. Please enter your credentials again.'));
    232232            }
    233            
     233
    234234            // Save the password so we can log the browser in when it's time to publish.
    235235            $this->import['pass'] = $_POST['pass'];
     
    242242            preg_match_all('#posts\.g\?blogID=(\d+)">([^<]+)</a>#U', $response['body'], $blogsary);
    243243            if ( ! count( $blogsary[1] < 1 ) )
    244                 die(__('No blogs found for this user.'));
     244                wp_die(__('No blogs found for this user.'));
    245245            $this->import['blogs'] = array();
    246246            $template = '<MainPage><br /><br /><br /><p>'.__('Are you looking for %title%? It is temporarily out of service. Please try again in a few minutes. Meanwhile, discover <a href="http://wordpress.org/">a better blogging tool</a>.').'</p><BloggerArchives><a class="archive" href="<$BlogArchiveURL$>"><$BlogArchiveName$></a><br /></BloggerArchives></MainPage><ArchivePage><Blogger><wordpresspost><$BlogItemDateTime$>|W|P|<$BlogItemAuthorNickname$>|W|P|<$BlogItemBody$>|W|P|<$BlogItemNumber$>|W|P|<$BlogItemTitle$>|W|P|<$BlogItemAuthorEmail$><BlogItemCommentsEnabled><BlogItemComments><wordpresscomment><$BlogCommentDateTime$>|W|P|<$BlogCommentAuthor$>|W|P|<$BlogCommentBody$></BlogItemComments></BlogItemCommentsEnabled></Blogger></ArchivePage>';
     
    274274            }
    275275            update_option('import-blogger', $this->import);
    276             header("Location: admin.php?import=blogger&noheader=true&step=1");
     276            wp_redirect("admin.php?import=blogger&noheader=true&step=1");
    277277        }
    278278        die();
     
    307307                            $response = $this->get_blogger("http://www.blogger.com/blog-publishing.g?blogID={$_GET['blog']}&publishMode=0", $headers);
    308308                            if ( $response['code'] >= 400 )
    309                                 die('<h2>'.__('Failed attempt to change publish mode from FTP to BlogSpot.').'</h2><pre>' . addslashes(print_r($headers, 1)) . addslashes(print_r($response, 1)) . '</pre>');
     309                                wp_die('<h2>'.__('Failed attempt to change publish mode from FTP to BlogSpot.').'</h2><pre>' . addslashes(print_r($headers, 1)) . addslashes(print_r($response, 1)) . '</pre>');
    310310                            $this->import['blogs'][$_GET['blog']]['url'] = 'http://' . $optary['modify']['subdomain'] . '.blogspot.com/';
    311311                            sleep(2);
     
    322322                    $response = $this->post_blogger($posturl, $headers, $paramary);
    323323                    if ( $response['code'] >= 400 || strstr($response['body'], 'There are errors on this form') )
    324                         die('<p>'.__('Error on form submission. Retry or reset the importer.').'</p>' . addslashes(print_r($response, 1)));
     324                        wp_die('<p>'.__('Error on form submission. Retry or reset the importer.').'</p>' . addslashes(print_r($response, 1)));
    325325                }
    326326                $output .= "<del><p>$blog_opt</p></del>\n";
     
    342342                $form.= $body;
    343343                $form.= "</div><script type='text/javascript'>forms=document.getElementsByTagName('form');for(i=0;i<forms.length;i++){if(forms[i].action.search('{$blog_opt}')){forms[i].submit();break;}}</script>";
    344                 $output.= '<p>'.sprintf('<strong>%s</strong> in progress, please wait...', $blog_opt)."</p>\n";
     344                $output.= '<p>'.sprintf(__('<strong>%s</strong> in progress, please wait...'), $blog_opt)."</p>\n";
    345345            } else {
    346346                $output.= "<p>$blog_opt</p>\n";
     
    365365        $bloghtml = $this->get_blogger($this->import['blogs'][$_GET['blog']]['url']);
    366366        if (! strstr($bloghtml['body'], '<a class="archive"') )
    367             die(__('Your Blogger blog did not take the new template or did not respond.'));
     367            wp_die(__('Your Blogger blog did not take the new template or did not respond.'));
    368368        preg_match_all('#<a class="archive" href="([^"]*)"#', $bloghtml['body'], $archives);
    369369        foreach ($archives[1] as $archive) {
     
    396396                $archive = $this->get_blogger($url);
    397397                if ( $archive['code'] > 200 )
    398                     continue;   
     398                    continue;
    399399                $posts = explode('<wordpresspost>', $archive['body']);
    400400                for ($i = 1; $i < count($posts); $i = $i + 1) {
     
    410410                    $post_author_name = $wpdb->escape(trim($postinfo[1]));
    411411                    $post_author_email = $postinfo[5] ? $postinfo[5] : 'user@wordpress.org';
    412    
     412
    413413                    if ( $this->lump_authors ) {
    414414                        // Ignore Blogger authors. Use the current user_ID for all posts imported.
     
    421421                            $user_password = substr(md5(uniqid(microtime())), 0, 6);
    422422                            $result = wp_create_user( $user_login, $user_password, $user_email );
    423                             $status.= sprintf('Registered user <strong>%s</strong>.', $user_login);
     423                            $status.= sprintf(__('Registered user <strong>%s</strong>.'), $user_login);
    424424                            $this->import['blogs'][$_GET['blog']]['newusers'][] = $user_login;
    425425                        }
     
    436436                    $postminute = zeroise($post_date_His[1], 2);
    437437                    $postsecond = zeroise($post_date_His[2], 2);
    438    
     438
    439439                    if (($post_date[2] == 'PM') && ($posthour != '12'))
    440440                        $posthour = $posthour + 12;
    441441                    else if (($post_date[2] == 'AM') && ($posthour == '12'))
    442442                        $posthour = '00';
    443    
     443
    444444                    $post_date = "$postyear-$postmonth-$postday $posthour:$postminute:$postsecond";
    445    
     445
    446446                    $post_content = addslashes($post_content);
    447447                    $post_content = str_replace(array('<br>','<BR>','<br/>','<BR/>','<br />','<BR />'), "\n", $post_content); // the XHTML touch... ;)
    448    
     448
    449449                    $post_title = addslashes($post_title);
    450            
     450
    451451                    $post_status = 'publish';
    452    
     452
    453453                    if ( $ID = post_exists($post_title, '', $post_date) ) {
    454454                        $post_array[$i]['ID'] = $ID;
     
    510510                }
    511511                $status = sprintf(__('%s post(s) parsed, %s skipped...'), $postcount,  $skippedpostcount).' '.
    512                     sprintf(__('%s comment(s) parsed, %s skipped...'), $commentcoun, $skippedcommentcount).' '.
     512                    sprintf(__('%s comment(s) parsed, %s skipped...'), $commentcount, $skippedcommentcount).' '.
    513513                    ' <strong>'.__('Done').'</strong>';
    514514                $import = $this->import;
     
    547547                        sleep(2);
    548548                        if ( $response['code'] >= 400 )
    549                             die('<h1>Error restoring publishMode.</h1><p>Please tell the devs.</p>' . addslashes(print_r($response, 1)) );
     549                            wp_die('<h1>'.__('Error restoring publishMode').'</h1><p>'.__('Please tell the devs.').'</p>' . addslashes(print_r($response, 1)) );
    550550                    }
    551551                }
     
    598598            $this->restart();
    599599        }
    600        
     600
    601601        if ( isset($_GET['noheader']) ) {
    602             $this->import = get_settings('import-blogger');
     602            header('Content-Type: text/html; charset=utf-8');
     603
     604            $this->import = get_option('import-blogger');
    603605
    604606            if ( false === $this->import ) {
     
    614616            }
    615617//echo "Step $step.";
    616 //die('<pre>'.print_r($this->import,1).'</pre');
     618//wp_die('<pre>'.print_r($this->import,1).'</pre');
    617619            switch ($step) {
    618620                case 0 :
     
    648650            }
    649651            die;
    650            
     652
    651653        } else {
    652654            $this->greet();
     
    661663$blogger_import = new Blogger_Import();
    662664
    663 register_importer('blogger', 'Blogger', __('Import posts and comments from a Blogger account'), array ($blogger_import, 'start'));
     665register_importer('blogger', __('Blogger and Blog*Spot'), __('Import <strong>posts and comments</strong> from your Blogger account'), array ($blogger_import, 'start'));
    664666
    665667?>
  • trunk/wp-admin/import/dotclear.php

    • Property svn:eol-style set to native
    r3503 r4431  
    11<?php
     2/*
     3 * Dotclear import plugin
     4 * by Thomas Quinot - http://thomas.quinot.org/
     5 */
     6
    27/**
    38    Add These Functions to make our lives easier
     
    813    {
    914    global $wpdb;
    10    
     15
    1116    $cat_id -= 0;   // force numeric
    1217    $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
    13    
     18
    1419    return $name;
    1520    }
     
    128133    {
    129134        echo '<div class="wrap">';
    130         echo '<h2>'.__('Import Dotclear').'</h2>';
     135        echo '<h2>'.__('Import DotClear').'</h2>';
    131136        echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>';
    132137    }
     
    136141        echo '</div>';
    137142    }
    138    
     143
    139144    function greet()
    140145    {
    141         echo '<p>'.__('Howdy! This importer allows you to extract posts from a Dotclear database into your blog.  Mileage may vary.').'</p>';
    142         echo '<p>'.__('Your Dotclear Configuration settings are as follows:').'</p>';
     146        echo '<div class="narrow"><p>'.__('Howdy! This importer allows you to extract posts from a DotClear database into your blog.  Mileage may vary.').'</p>';
     147        echo '<p>'.__('Your DotClear Configuration settings are as follows:').'</p>';
    143148        echo '<form action="admin.php?import=dotclear&amp;step=1" method="post">';
    144149        $this->db_form();
    145         echo '<input type="submit" name="submit" value="'.__('Import Categories').'" />';
    146         echo '</form>';
     150        echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Categories').' &raquo;" /></p>';
     151        echo '</form></div>';
    147152    }
    148153
     
    153158        $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
    154159        set_magic_quotes_runtime(0);
    155         $prefix = get_option('tpre');
    156        
     160        $dbprefix = get_option('dcdbprefix');
     161
    157162        // Get Categories
    158         return $dcdb->get_results('SELECT * FROM dc_categorie', ARRAY_A);
    159     }
    160    
     163        return $dcdb->get_results('SELECT * FROM '.$dbprefix.'categorie', ARRAY_A);
     164    }
     165
    161166    function get_dc_users()
    162167    {
     
    165170        $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
    166171        set_magic_quotes_runtime(0);
    167         $prefix = get_option('tpre');
    168        
     172        $dbprefix = get_option('dcdbprefix');
     173
    169174        // Get Users
    170        
    171         return $dcdb->get_results('SELECT * FROM dc_user', ARRAY_A);
    172     }
    173    
     175
     176        return $dcdb->get_results('SELECT * FROM '.$dbprefix.'user', ARRAY_A);
     177    }
     178
    174179    function get_dc_posts()
    175180    {
     
    177182        $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
    178183        set_magic_quotes_runtime(0);
    179         $prefix = get_option('tpre');
    180        
     184        $dbprefix = get_option('dcdbprefix');
     185
    181186        // Get Posts
    182         return $dcdb->get_results('SELECT dc_post.*, dc_categorie.cat_libelle_url AS post_cat_name
    183                         FROM dc_post INNER JOIN dc_categorie
    184                           ON dc_post.cat_id = dc_categorie.cat_id', ARRAY_A);
    185     }
    186    
     187        return $dcdb->get_results('SELECT '.$dbprefix.'post.*, '.$dbprefix.'categorie.cat_libelle_url AS post_cat_name
     188                        FROM '.$dbprefix.'post INNER JOIN '.$dbprefix.'categorie
     189                          ON '.$dbprefix.'post.cat_id = '.$dbprefix.'categorie.cat_id', ARRAY_A);
     190    }
     191
    187192    function get_dc_comments()
    188193    {
     
    191196        $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
    192197        set_magic_quotes_runtime(0);
    193         $prefix = get_option('tpre');
    194        
     198        $dbprefix = get_option('dcdbprefix');
     199
    195200        // Get Comments
    196         return $dcdb->get_results('SELECT * FROM dc_comment', ARRAY_A);
    197     }
    198    
     201        return $dcdb->get_results('SELECT * FROM '.$dbprefix.'comment', ARRAY_A);
     202    }
     203
    199204    function get_dc_links()
    200205    {
     
    202207        $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost'));
    203208        set_magic_quotes_runtime(0);
    204         $prefix = get_option('tpre');
    205 
    206         return $dcdb->get_results('SELECT * FROM dc_link ORDER BY position', ARRAY_A);
    207     }
    208    
     209        $dbprefix = get_option('dcdbprefix');
     210
     211        return $dcdb->get_results('SELECT * FROM '.$dbprefix.'link ORDER BY position', ARRAY_A);
     212    }
     213
    209214    function cat2wp($categories='')
    210215    {
     
    221226                $count++;
    222227                extract($category);
    223                
     228
    224229                // Make Nice Variables
    225230                $name = $wpdb->escape($cat_libelle_url);
     
    237242                $dccat2wpcat[$id] = $ret_id;
    238243            }
    239            
     244
    240245            // Store category translation for future use
    241246            add_option('dccat2wpcat',$dccat2wpcat);
     
    246251        return false;
    247252    }
    248    
     253
    249254    function users2wp($users='')
    250255    {
     
    253258        $count = 0;
    254259        $dcid2wpid = array();
    255        
     260
    256261        // Midnight Mojo
    257262        if(is_array($users))
     
    262267                $count++;
    263268                extract($user);
    264                
     269
    265270                // Make Nice Variables
    266271                $name = $wpdb->escape(csc ($name));
    267272                $RealName = $wpdb->escape(csc ($user_pseudo));
    268                
     273
    269274                if($uinfo = get_userdatabylogin($name))
    270275                {
    271                    
     276
    272277                    $ret_id = wp_insert_user(array(
    273278                                'ID'        => $uinfo->ID,
     
    290295                }
    291296                $dcid2wpid[$user_id] = $ret_id;
    292                
     297
    293298                // Set Dotclear-to-WordPress permissions translation
    294                
     299
    295300                // Update Usermeta Data
    296301                $user = new WP_User($ret_id);
     
    303308                else if(2  <= $wp_perms) { $user->set_role('contributor'); }
    304309                else                     { $user->set_role('subscriber'); }
    305                
     310
    306311                update_usermeta( $ret_id, 'wp_user_level', $wp_perms);
    307312                update_usermeta( $ret_id, 'rich_editing', 'false');
     
    309314                update_usermeta( $ret_id, 'last_name', csc ($user_nom));
    310315            }// End foreach($users as $user)
    311            
     316
    312317            // Store id translation array for future use
    313318            add_option('dcid2wpid',$dcid2wpid);
    314            
    315            
     319
     320
    316321            echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>';
    317322            return true;
    318323        }// End if(is_array($users)
    319        
     324
    320325        echo __('No Users to Import!');
    321326        return false;
    322        
     327
    323328    }// End function user2wp()
    324    
     329
    325330    function posts2wp($posts='')
    326331    {
     
    339344                $count++;
    340345                extract($post);
    341                
     346
    342347                // Set Dotclear-to-WordPress status translation
    343348                $stattrans = array(0 => 'draft', 1 => 'publish');
    344349                $comment_status_map = array (0 => 'closed', 1 => 'open');
    345                
     350
    346351                //Can we do this more efficiently?
    347352                $uinfo = ( get_userdatabylogin( $user_id ) ) ? get_userdatabylogin( $user_id ) : 1;
     
    350355                $Title = $wpdb->escape(csc ($post_titre));
    351356                $post_content = textconv ($post_content);
     357                $post_excerpt = "";
    352358                if ($post_chapo != "") {
    353359                    $post_excerpt = textconv ($post_chapo);
     
    357363                $post_content = $wpdb->escape ($post_content);
    358364                $post_status = $stattrans[$post_pub];
    359                
     365
    360366                // Import Post data into WordPress
    361                
     367
    362368                if($pinfo = post_exists($Title,$post_content))
    363369                {
     
    398404                }
    399405                $dcposts2wpposts[$post_id] = $ret_id;
    400                
     406
    401407                // Make Post-to-Category associations
    402408                $cats = array();
    403409                if($cat1 = get_catbynicename($post_cat_name)) { $cats[1] = $cat1; }
    404410
    405                 if(!empty($cats)) { wp_set_post_cats('', $ret_id, $cats); }
     411                if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); }
    406412            }
    407413        }
    408414        // Store ID translation for later use
    409415        add_option('dcposts2wpposts',$dcposts2wpposts);
    410        
     416
    411417        echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>';
    412         return true;   
    413     }
    414    
     418        return true;
     419    }
     420
    415421    function comments2wp($comments='')
    416422    {
     
    420426        $dccm2wpcm = array();
    421427        $postarr = get_option('dcposts2wpposts');
    422        
     428
    423429        // Magic Mojo
    424430        if(is_array($comments))
     
    429435                $count++;
    430436                extract($comment);
    431                
     437
    432438                // WordPressify Data
    433439                $comment_ID = ltrim($comment_id, '0');
     
    438444                $web = "http://".$wpdb->escape($comment_site);
    439445                $message = $wpdb->escape(textconv ($comment_content));
    440                
     446
    441447                if($cinfo = comment_exists($name, $comment_dt))
    442448                {
     
    473479            }
    474480            // Store Comment ID translation for future use
    475             add_option('dccm2wpcm', $dccm2wpcm);           
    476            
     481            add_option('dccm2wpcm', $dccm2wpcm);
     482
    477483            // Associate newly formed categories with posts
    478484            get_comment_count($ret_id);
    479            
    480            
     485
     486
    481487            echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>';
    482488            return true;
     
    485491        return false;
    486492    }
    487    
     493
    488494    function links2wp($links='')
    489495    {
     
    491497        global $wpdb;
    492498        $count = 0;
    493        
     499
    494500        // Deal with the links
    495501        if(is_array($links))
     
    500506                $count++;
    501507                extract($link);
    502                
     508
    503509                if ($title != "") {
    504510                    if ($cinfo = link_cat_exists (csc ($title))) {
     
    512518                    $linkname = $wpdb->escape(csc ($label));
    513519                    $description = $wpdb->escape(csc ($title));
    514                
     520
    515521                    if($linfo = link_exists($linkname)) {
    516522                        $ret_id = wp_insert_link(array(
     
    541547        return false;
    542548    }
    543        
     549
    544550    function import_categories()
    545     {   
    546         // Category Import 
     551    {
     552        // Category Import
    547553        $cats = $this->get_dc_cats();
    548554        $this->cat2wp($cats);
    549555        add_option('dc_cats', $cats);
    550        
    551        
    552            
     556
     557
     558
    553559        echo '<form action="admin.php?import=dotclear&amp;step=2" method="post">';
    554560        printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
     
    556562
    557563    }
    558    
     564
    559565    function import_users()
    560566    {
     
    562568        $users = $this->get_dc_users();
    563569        $this->users2wp($users);
    564        
     570
    565571        echo '<form action="admin.php?import=dotclear&amp;step=3" method="post">';
    566572        printf('<input type="submit" name="submit" value="%s" />', __('Import Posts'));
    567573        echo '</form>';
    568574    }
    569    
     575
    570576    function import_posts()
    571577    {
     
    573579        $posts = $this->get_dc_posts();
    574580        $this->posts2wp($posts);
    575        
     581
    576582        echo '<form action="admin.php?import=dotclear&amp;step=4" method="post">';
    577583        printf('<input type="submit" name="submit" value="%s" />', __('Import Comments'));
    578584        echo '</form>';
    579585    }
    580    
     586
    581587    function import_comments()
    582588    {
     
    584590        $comments = $this->get_dc_comments();
    585591        $this->comments2wp($comments);
    586        
     592
    587593        echo '<form action="admin.php?import=dotclear&amp;step=5" method="post">';
    588594        printf('<input type="submit" name="submit" value="%s" />', __('Import Links'));
    589595        echo '</form>';
    590596    }
    591    
     597
    592598    function import_links()
    593599    {
     
    596602        $this->links2wp($links);
    597603        add_option('dc_links', $links);
    598        
     604
    599605        echo '<form action="admin.php?import=dotclear&amp;step=6" method="post">';
    600606        printf('<input type="submit" name="submit" value="%s" />', __('Finish'));
    601607        echo '</form>';
    602608    }
    603    
     609
    604610    function cleanup_dcimport()
    605611    {
    606         delete_option('tpre');
     612        delete_option('dcdbprefix');
    607613        delete_option('dc_cats');
    608614        delete_option('dcid2wpid');
     
    618624        $this->tips();
    619625    }
    620    
     626
    621627    function tips()
    622628    {
    623         echo '<p>'.__('Welcome to WordPress.  We hope (and expect!) that you will find this platform incredibly rewarding!  As a new WordPress user coming from Dotclear, there are some things that we would like to point out.  Hopefully, they will help your transition go as smoothly as possible.').'</p>';
     629        echo '<p>'.__('Welcome to WordPress.  We hope (and expect!) that you will find this platform incredibly rewarding!  As a new WordPress user coming from DotClear, there are some things that we would like to point out.  Hopefully, they will help your transition go as smoothly as possible.').'</p>';
    624630        echo '<h3>'.__('Users').'</h3>';
    625         echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password.  Forget it.  You didn\'t have that login in Dotclear, why should you have it here?  Instead we have taken care to import all of your users into our system.  Unfortunately there is one downside.  Because both WordPress and Dotclear uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users.  <strong>Every user has the same username, but their passwords are reset to password123.</strong>  So <a href="%1$s">Login</a> and change it.'), '/wp-login.php').'</p>';
     631        echo '<p>'.sprintf(__('You have already setup WordPress and have been assigned an administrative login and password.  Forget it.  You didn\'t have that login in DotClear, why should you have it here?  Instead we have taken care to import all of your users into our system.  Unfortunately there is one downside.  Because both WordPress and DotClear uses a strong encryption hash with passwords, it is impossible to decrypt it and we are forced to assign temporary passwords to all your users.  <strong>Every user has the same username, but their passwords are reset to password123.</strong>  So <a href="%1$s">Login</a> and change it.'), '/wp-login.php').'</p>';
    626632        echo '<h3>'.__('Preserving Authors').'</h3>';
    627633        echo '<p>'.__('Secondly, we have attempted to preserve post authors.  If you are the only author or contributor to your blog, then you are safe.  In most cases, we are successful in this preservation endeavor.  However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.').'</p>';
    628634        echo '<h3>'.__('Textile').'</h3>';
    629         echo '<p>'.__('Also, since you\'re coming from Dotclear, you probably have been using Textile to format your comments and posts.  If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/2004/04/19/wordpress-plugin-textile-20/">Textile for WordPress</a>.  Trust me... You\'ll want it.').'</p>';
     635        echo '<p>'.__('Also, since you\'re coming from DotClear, you probably have been using Textile to format your comments and posts.  If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>.  Trust me... You\'ll want it.').'</p>';
    630636        echo '<h3>'.__('WordPress Resources').'</h3>';
    631637        echo '<p>'.__('Finally, there are numerous WordPress resources around the internet.  Some of them are:').'</p>';
    632638        echo '<ul>';
    633639        echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>';
    634         echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums').'</li>';
     640        echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums</a>').'</li>';
    635641        echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>';
    636642        echo '</ul>';
    637         echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>';
    638     }
    639    
     643        echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '../wp-login.php').'</p>';
     644    }
     645
    640646    function db_form()
    641647    {
    642         echo '<ul>';
    643         printf('<li><label for="dbuser">%s</label> <input type="text" name="dbuser" /></li>', __('Dotclear Database User:'));
    644         printf('<li><label for="dbpass">%s</label> <input type="password" name="dbpass" /></li>', __('Dotclear Database Password:'));
    645         printf('<li><label for="dbname">%s</label> <input type="text" name="dbname" /></li>', __('Dotclear Database Name:'));
    646         printf('<li><label for="dbhost">%s</label> <input type="text" name="dbhost" value="localhost" /></li>', __('Dotclear Database Host:'));
    647         /* printf('<li><label for="dbprefix">%s</label> <input type="text" name="dbprefix" /></li>', __('Dotclear Table prefix (if any):')); */
    648         printf('<li><label for="dccharset">%s</label> <input type="text" name="dccharset" value="ISO-8859-15"/></li>', __('Originating character set:'));
    649         echo '</ul>';
    650     }
    651    
     648        echo '<table class="editform">';
     649        printf('<tr><th><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('Dotclear Database User:'));
     650        printf('<tr><th><label for="dbpass">%s</label></th><td><input type="password" name="dbpass" id="dbpass" /></td></tr>', __('DotClear Database Password:'));
     651        printf('<tr><th><label for="dbname">%s</label></th><td><input type="text" name="dbname" id="dbname" /></td></tr>', __('Dotclear Database Name:'));
     652        printf('<tr><th><label for="dbhost">%s</label></th><td><input type="text" name="dbhost" nameid="dbhost" value="localhost" /></td></tr>', __('DotClear Database Host:'));
     653        printf('<tr><th><label for="dbprefix">%s</label></th><td><input type="text" name="dbprefix" id="dbprefix" value="dc_"/></td></tr>', __('DotClear Table prefix:'));
     654        printf('<tr><th><label for="dccharset">%s</label></th><td><input type="text" name="dccharset" id="dccharset" value="ISO-8859-15"/></td></tr>', __('Originating character set:'));
     655        echo '</table>';
     656    }
     657
    652658    function dispatch()
    653659    {
     
    658664            $step = (int) $_GET['step'];
    659665        $this->header();
    660        
     666
    661667        if ( $step > 0 )
    662668        {
     
    664670            {
    665671                if(get_option('dcuser'))
    666                     delete_option('dcuser');   
     672                    delete_option('dcuser');
    667673                add_option('dcuser',$_POST['dbuser']);
    668674            }
     
    670676            {
    671677                if(get_option('dcpass'))
    672                     delete_option('dcpass');   
     678                    delete_option('dcpass');
    673679                add_option('dcpass',$_POST['dbpass']);
    674680            }
    675            
     681
    676682            if($_POST['dbname'])
    677683            {
    678684                if(get_option('dcname'))
    679                     delete_option('dcname');   
     685                    delete_option('dcname');
    680686                add_option('dcname',$_POST['dbname']);
    681687            }
     
    691697                    delete_option('dccharset');
    692698                add_option('dccharset',$_POST['dccharset']);
    693             }           
     699            }
    694700            if($_POST['dbprefix'])
    695701            {
    696                 if(get_option('tpre'))
    697                     delete_option('tpre');
    698                 add_option('tpre',$_POST['dbprefix']);
    699             }           
     702                if(get_option('dcdbprefix'))
     703                    delete_option('dcdbprefix');
     704                add_option('dcdbprefix',$_POST['dbprefix']);
     705            }
    700706
    701707
     
    727733                break;
    728734        }
    729        
     735
    730736        $this->footer();
    731737    }
     
    733739    function Dotclear_Import()
    734740    {
    735         // Nothing. 
     741        // Nothing.
    736742    }
    737743}
    738744
    739745$dc_import = new Dotclear_Import();
    740 register_importer('dotclear', 'Dotclear', __('Import posts from a Dotclear Blog'), array ($dc_import, 'dispatch'));
     746register_importer('dotclear', __('DotClear'), __('Import posts from a DotClear Blog'), array ($dc_import, 'dispatch'));
    741747?>
  • trunk/wp-admin/import/greymatter.php

    r3503 r4431  
     1<?php
     2
     3class GM_Import {
     4
     5    var $gmnames = array ();
     6
     7    function header() {
     8        echo '<div class="wrap">';
     9        echo '<h2>'.__('Import Greymatter').'</h2>';
     10    }
     11
     12    function footer() {
     13        echo '</div>';
     14    }
     15
     16    function greet() {
     17        $this->header();
     18?>
     19<p><?php _e('This is a basic GreyMatter to WordPress import script.') ?></p>
     20<p><?php _e('What it does:') ?></p>
     21<ul>
     22<li><?php _e('Parses gm-authors.cgi to import (new) authors. Everyone is imported at level 1.') ?></li>
     23<li><?php _e('Parses the entries cgi files to import posts, comments, and karma on posts (although karma is not used on WordPress yet).<br />If authors are found not to be in gm-authors.cgi, imports them at level 0.') ?></li>
     24<li><?php _e("Detects duplicate entries or comments. If you don't import everything the first time, or this import should fail in the middle, duplicate entries will not be made when you try again.") ?></li>
     25</ul>
     26<p><?php _e('What it does not:') ?></p>
     27<ul>
     28<li><?php _e('Parse gm-counter.cgi, gm-banlist.cgi, gm-cplog.cgi (you can make a CP log hack if you really feel like it, but I question the need of a CP log).') ?></li>
     29<li><?php _e('Import gm-templates.') ?></li>
     30<li><?php _e("Doesn't keep entries on top.")?></li>
     31</ul>
     32<p>&nbsp;</p>
     33
     34<form name="stepOne" method="get">
     35<input type="hidden" name="import" value="greymatter" />
     36<input type="hidden" name="step" value="1" />
     37<h3><?php _e('Second step: GreyMatter details:') ?></h3>
     38<p><table cellpadding="0">
     39<tr>
     40<td><?php _e('Path to GM files:') ?></td>
     41<td><input type="text" style="width:300px" name="gmpath" value="/home/my/site/cgi-bin/greymatter/" /></td>
     42</tr>
     43<tr>
     44<td><?php _e('Path to GM entries:') ?></td>
     45<td><input type="text" style="width:300px" name="archivespath" value="/home/my/site/cgi-bin/greymatter/archives/" /></td>
     46</tr>
     47<tr>
     48<td colspan="2"><br /><?php _e("This importer will search for files 00000001.cgi to 000-whatever.cgi,<br />so you need to enter the number of the last GM post here.<br />(if you don't know that number, just log into your FTP and look it out<br />in the entries' folder)") ?></td>
     49</tr>
     50<tr>
     51<td><?php _e("Last entry's number:") ?></td>
     52<td><input type="text" name="lastentry" value="00000001" /></td>
     53</tr>
     54</table>
     55</p>
     56<p><?php _e("When you're ready, click OK to start importing: ") ?><input type="submit" name="submit" value="<?php _e('OK') ?>" class="search" /></p>
     57</form>
     58<p>&nbsp</p>
     59<?php
     60        $this->footer();
     61    }
     62
     63
     64
     65    function gm2autobr($string) { // transforms GM's |*| into b2's <br />\n
     66        $string = str_replace("|*|","<br />\n",$string);
     67        return($string);
     68    }
     69   
     70    function import() {
     71        global $wpdb;
     72   
     73        $wpvarstoreset = array('gmpath', 'archivespath', 'lastentry');
     74        for ($i=0; $i<count($wpvarstoreset); $i += 1) {
     75            $wpvar = $wpvarstoreset[$i];
     76            if (!isset($$wpvar)) {
     77                if (empty($_POST["$wpvar"])) {
     78                    if (empty($_GET["$wpvar"])) {
     79                        $$wpvar = '';
     80                    } else {
     81                        $$wpvar = $_GET["$wpvar"];
     82                    }
     83                } else {
     84                    $$wpvar = $_POST["$wpvar"];
     85                }
     86            }
     87        }
     88
     89        if (!chdir($archivespath))
     90            wp_die(sprintf(__("Wrong path, %s\ndoesn't exist\non the server"), $archivespath));
     91
     92        if (!chdir($gmpath))
     93            wp_die(sprintf(__("Wrong path, %s\ndoesn't exist\non the server"), $gmpath));
     94           
     95        $this->header();
     96?>
     97<p><?php _e('The importer is running...') ?></p>
     98<ul>
     99<li><?php _e('importing users...') ?><ul><?php
     100
     101    chdir($gmpath);
     102    $userbase = file("gm-authors.cgi");
     103
     104    foreach($userbase as $user) {
     105        $userdata=explode("|", $user);
     106
     107        $user_ip="127.0.0.1";
     108        $user_domain="localhost";
     109        $user_browser="server";
     110
     111        $s=$userdata[4];
     112        $user_joindate=substr($s,6,4)."-".substr($s,0,2)."-".substr($s,3,2)." 00:00:00";
     113
     114        $user_login=$wpdb->escape($userdata[0]);
     115        $pass1=$wpdb->escape($userdata[1]);
     116        $user_nickname=$wpdb->escape($userdata[0]);
     117        $user_email=$wpdb->escape($userdata[2]);
     118        $user_url=$wpdb->escape($userdata[3]);
     119        $user_joindate=$wpdb->escape($user_joindate);
     120
     121        $user_id = username_exists($user_login);
     122        if ($user_id) {
     123            printf('<li>'.__('user %s').'<strong>'.__('Already exists').'</strong></li>', "<em>$user_login</em>");
     124            $this->gmnames[$userdata[0]] = $user_id;
     125            continue;
     126        }
     127
     128        $user_info = array("user_login"=>"$user_login", "user_pass"=>"$pass1", "user_nickname"=>"$user_nickname", "user_email"=>"$user_email", "user_url"=>"$user_url", "user_ip"=>"$user_ip", "user_domain"=>"$user_domain", "user_browser"=>"$user_browser", "dateYMDhour"=>"$user_joindate", "user_level"=>"1", "user_idmode"=>"nickname");
     129        $user_id = wp_insert_user($user_info);
     130        $this->gmnames[$userdata[0]] = $user_id;
     131       
     132        printf('<li>'.__('user %s...').' <strong>'.__('Done').'</strong></li>', "<em>$user_login</em>");
     133    }
     134
     135?></ul><strong><?php _e('Done') ?></strong></li>
     136<li><?php _e('importing posts, comments, and karma...') ?><br /><ul><?php
     137
     138    chdir($archivespath);
     139   
     140    for($i = 0; $i <= $lastentry; $i = $i + 1) {
     141       
     142        $entryfile = "";
     143       
     144        if ($i<10000000) {
     145            $entryfile .= "0";
     146            if ($i<1000000) {
     147                $entryfile .= "0";
     148                if ($i<100000) {
     149                    $entryfile .= "0";
     150                    if ($i<10000) {
     151                        $entryfile .= "0";
     152                        if ($i<1000) {
     153                            $entryfile .= "0";
     154                            if ($i<100) {
     155                                $entryfile .= "0";
     156                                if ($i<10) {
     157                                    $entryfile .= "0";
     158        }}}}}}}
     159
     160        $entryfile .= "$i";
     161
     162        if (is_file($entryfile.".cgi")) {
     163
     164            $entry=file($entryfile.".cgi");
     165            $postinfo=explode("|",$entry[0]);
     166            $postmaincontent=$this->gm2autobr($entry[2]);
     167            $postmorecontent=$this->gm2autobr($entry[3]);
     168
     169            $post_author=trim($wpdb->escape($postinfo[1]));
     170
     171            $post_title=$this->gm2autobr($postinfo[2]);
     172            printf('<li>'.__('entry # %s : %s : by %s'), $entryfile, $post_title, $postinfo[1]);
     173            $post_title=$wpdb->escape($post_title);
     174
     175            $postyear=$postinfo[6];
     176            $postmonth=zeroise($postinfo[4],2);
     177            $postday=zeroise($postinfo[5],2);
     178            $posthour=zeroise($postinfo[7],2);
     179            $postminute=zeroise($postinfo[8],2);
     180            $postsecond=zeroise($postinfo[9],2);
     181
     182            if (($postinfo[10]=="PM") && ($posthour!="12"))
     183                $posthour=$posthour+12;
     184
     185            $post_date="$postyear-$postmonth-$postday $posthour:$postminute:$postsecond";
     186
     187            $post_content=$postmaincontent;
     188            if (strlen($postmorecontent)>3)
     189                $post_content .= "<!--more--><br /><br />".$postmorecontent;
     190            $post_content=$wpdb->escape($post_content);
     191
     192            $post_karma=$postinfo[12];
     193
     194            $post_status = 'publish'; //in greymatter, there are no drafts
     195            $comment_status = 'open';
     196            $ping_status = 'closed';
     197           
     198            if ($post_ID = post_exists($post_title, '', $post_date)) {
     199                echo ' ';
     200                _e('(already exists)');
     201            } else {
     202                //just so that if a post already exists, new users are not created by checkauthor
     203                // we'll check the author is registered, or if it's a deleted author
     204                $user_id = username_exists($post_author);
     205                if (!$user_id) {    // if deleted from GM, we register the author as a level 0 user
     206                    $user_ip="127.0.0.1";
     207                    $user_domain="localhost";
     208                    $user_browser="server";
     209                    $user_joindate="1979-06-06 00:41:00";
     210                    $user_login=$wpdb->escape($post_author);
     211                    $pass1=$wpdb->escape("password");
     212                    $user_nickname=$wpdb->escape($post_author);
     213                    $user_email=$wpdb->escape("user@deleted.com");
     214                    $user_url=$wpdb->escape("");
     215                    $user_joindate=$wpdb->escape($user_joindate);
     216                   
     217                    $user_info = array("user_login"=>$user_login, "user_pass"=>$pass1, "user_nickname"=>$user_nickname, "user_email"=>$user_email, "user_url"=>$user_url, "user_ip"=>$user_ip, "user_domain"=>$user_domain, "user_browser"=>$user_browser, "dateYMDhour"=>$user_joindate, "user_level"=>0, "user_idmode"=>"nickname");
     218                    $user_id = wp_insert_user($user_info);
     219                    $this->gmnames[$postinfo[1]] = $user_id;
     220                   
     221                    echo ': ';
     222                    printf(__('registered deleted user %s at level 0 '), "<em>$user_login</em>");
     223                }
     224           
     225                if (array_key_exists($postinfo[1], $this->gmnames)) {
     226                    $post_author = $this->gmnames[$postinfo[1]];
     227                } else {
     228                    $post_author = $user_id;
     229                }
     230           
     231                $postdata = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_modified', 'post_modified_gmt');
     232                $post_ID = wp_insert_post($postdata);
     233            }
     234
     235            $c=count($entry);
     236            if ($c>4) {
     237                $numAddedComments = 0;
     238                $numComments = 0;
     239                for ($j=4;$j<$c;$j++) {
     240                    $entry[$j]=$this->gm2autobr($entry[$j]);
     241                    $commentinfo=explode("|",$entry[$j]);
     242                    $comment_post_ID=$post_ID;
     243                    $comment_author=$wpdb->escape($commentinfo[0]);
     244                    $comment_author_email=$wpdb->escape($commentinfo[2]);
     245                    $comment_author_url=$wpdb->escape($commentinfo[3]);
     246                    $comment_author_IP=$wpdb->escape($commentinfo[1]);
     247
     248                    $commentyear=$commentinfo[7];
     249                    $commentmonth=zeroise($commentinfo[5],2);
     250                    $commentday=zeroise($commentinfo[6],2);
     251                    $commenthour=zeroise($commentinfo[8],2);
     252                    $commentminute=zeroise($commentinfo[9],2);
     253                    $commentsecond=zeroise($commentinfo[10],2);
     254                    if (($commentinfo[11]=="PM") && ($commenthour!="12"))
     255                        $commenthour=$commenthour+12;
     256                    $comment_date="$commentyear-$commentmonth-$commentday $commenthour:$commentminute:$commentsecond";
     257
     258                    $comment_content=$wpdb->escape($commentinfo[12]);
     259
     260                    if (!comment_exists($comment_author, $comment_date)) {
     261                        $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_content', 'comment_approved');
     262                        $commentdata = wp_filter_comment($commentdata);
     263                        wp_insert_comment($commentdata);
     264                        $numAddedComments++;
     265                    }
     266                    $numComments++;
     267                }
     268                if ($numAddedComments > 0) {
     269                    echo ': ';
     270                    printf(__('imported %d comment(s)'), $numAddedComments);
     271                }
     272                $preExisting = $numComments - numAddedComments;
     273                if ($preExisting > 0) {
     274                    echo ' ';
     275                    printf(__('ignored %d pre-existing comments'), $preExisting);
     276                }
     277            }
     278            echo '... <strong>'.__('Done').'</strong></li>';
     279        }
     280    }
     281    ?>
     282</ul><strong><?php _e('Done') ?></strong></li></ul>
     283<p>&nbsp;</p>
     284<p><?php _e('Completed Greymatter import!') ?></p>
     285<?php
     286    $this->footer();
     287    }
     288
     289    function dispatch() {
     290        if (empty ($_GET['step']))
     291            $step = 0;
     292        else
     293            $step = (int) $_GET['step'];
     294
     295        switch ($step) {
     296            case 0 :
     297                $this->greet();
     298                break;
     299            case 1:
     300                $this->import();
     301                break;
     302        }
     303    }
     304
     305    function GM_Import() {
     306        // Nothing.
     307    }
     308}
     309
     310$gm_import = new GM_Import();
     311
     312register_importer('greymatter', __('Greymatter'), __('Import posts and comments from your Greymatter blog'), array ($gm_import, 'dispatch'));
     313?>
  • trunk/wp-admin/import/livejournal.php

    r3503 r4431  
    1919        return strtr($string, $trans_tbl);
    2020    }
    21    
     21
    2222    function greet() {
     23        echo '<div class="narrow">';
    2324        echo '<p>'.__('Howdy! This importer allows you to extract posts from LiveJournal XML export file into your blog.  Pick a LiveJournal file to upload and click Import.').'</p>';
    2425        wp_import_upload_form("admin.php?import=livejournal&amp;step=1");
     26        echo '</div>';
    2527    }
    2628
    2729    function import_posts() {
    2830        global $wpdb, $current_user;
    29        
     31
    3032        set_magic_quotes_runtime(0);
    3133        $importdata = file($this->file); // Read the file into an array
     
    3638        $posts = $posts[1];
    3739        unset($importdata);
    38         echo '<ol>';       
     40        echo '<ol>';
    3941        foreach ($posts as $post) {
    40             flush();
    4142            preg_match('|<subject>(.*?)</subject>|is', $post, $post_title);
    4243            $post_title = $wpdb->escape(trim($post_title[1]));
     
    7980            preg_match_all('|<comment>(.*?)</comment>|is', $post, $comments);
    8081            $comments = $comments[1];
    81            
     82
    8283            if ( $comments ) {
    8384                $comment_post_ID = $post_id;
     
    119120            }
    120121            echo '</li>';
    121             flush();
    122             ob_flush();
    123122        }
    124123        echo '</ol>';
     
    135134        $this->import_posts();
    136135        wp_import_cleanup($file['id']);
    137        
     136
    138137        echo '<h3>';
    139138        printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
     
    148147
    149148        $this->header();
    150        
     149
    151150        switch ($step) {
    152151            case 0 :
     
    157156                break;
    158157        }
    159        
     158
    160159        $this->footer();
    161160    }
    162161
    163162    function LJ_Import() {
    164         // Nothing. 
     163        // Nothing.
    165164    }
    166165}
     
    168167$livejournal_import = new LJ_Import();
    169168
    170 register_importer('livejournal', 'LiveJournal', __('Import posts from LiveJournal'), array ($livejournal_import, 'dispatch'));
     169register_importer('livejournal', __('LiveJournal'), __('Import posts from LiveJournal'), array ($livejournal_import, 'dispatch'));
    171170?>
  • trunk/wp-admin/import/mt.php

    r3503 r4431  
    1212    function header() {
    1313        echo '<div class="wrap">';
    14         echo '<h2>'.__('Import Movable Type').'</h2>';
     14        echo '<h2>'.__('Import Movable Type and TypePad').'</h2>';
    1515    }
    1616
     
    2222        $this->header();
    2323?>
     24<div class="narrow">
    2425<p><?php _e('Howdy! We&#8217;re about to begin the process to import all of your Movable Type entries into WordPress. To begin, select a file to upload and click Import.'); ?></p>
    2526<?php wp_import_upload_form( add_query_arg('step', 1) ); ?>
    2627    <p><?php _e('The importer is smart enough not to import duplicates, so you can run this multiple times without worry if&#8212;for whatever reason&#8212;it doesn\'t finish. If you get an <strong>out of memory</strong> error try splitting up the import file into pieces.'); ?> </p>
     28</div>
    2729<?php
    2830        $this->footer();
     
    3335        $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY ID");
    3436?><select name="userselect[<?php echo $n; ?>]">
    35     <option value="#NONE#">- Select -</option>
     37    <option value="#NONE#"><?php _e('- Select -') ?></option>
    3638    <?php
    3739
     
    135137    function mt_authors_form() {
    136138?>
     139<div class="wrap">
     140<h2><?php _e('Assign Authors'); ?></h2>
    137141<p><?php _e('To make it easier for you to edit and save the imported posts and drafts, you may want to change the name of the author of the posts. For example, you may want to import all the entries as <code>admin</code>s entries.'); ?></p>
    138142<p><?php _e('Below, you can see the names of the authors of the MovableType posts in <i>italics</i>. For each of these names, you can either pick an author in your WordPress installation from the menu, or enter a name for the author in the textbox.'); ?></p>
     
    147151        foreach ($authors as $author) {
    148152            ++ $j;
    149             echo '<li><i>'.$author.'</i><br />'.'<input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30">';
     153            echo '<li>'.__('Current author:').' <strong>'.$author.'</strong><br />'.sprintf(__('Create user %1$s or map to existing'), ' <input type="text" value="'.$author.'" name="'.'user[]'.'" maxlength="30"> <br />');
    150154            $this->users_form($j);
    151155            echo '</li>';
    152156        }
    153157
    154         echo '<input type="submit" value="Submit">'.'<br/>';
     158        echo '<input type="submit" value="'.__('Submit').'">'.'<br/>';
    155159        echo '</form>';
    156         echo '</ol>';
    157 
    158         flush();
     160        echo '</ol></div>';
     161
    159162    }
    160163
     
    162165        $file = wp_import_handle_upload();
    163166        if ( isset($file['error']) ) {
    164             echo $file['error'];
     167            $this->header();
     168            echo '<p>'.__('Sorry, there has been an error').'.</p>';
     169            echo '<p><strong>' . $file['error'] . '</strong></p>';
     170            $this->footer();
    165171            return;
    166172        }
     
    175181        global $wpdb;
    176182        $i = -1;
    177         echo "<ol>";
     183        echo "<div class='wrap'><ol>";
    178184        foreach ($this->posts as $post) {
    179185            if ('' != trim($post)) {
     
    194200                // We want the excerpt
    195201                preg_match("|-----\nEXCERPT:(.*)|s", $post, $excerpt);
    196                 $excerpt = $wpdb->escape(trim($excerpt[1]));
     202                $post_excerpt = $wpdb->escape(trim($excerpt[1]));
    197203                $post = preg_replace("|(-----\nEXCERPT:.*)|s", '', $post);
    198204
     
    331337                }
    332338                if ( $num_comments )
    333                     printf(__('(%s comments)'), $num_comments);
     339                    printf(' '.__('(%s comments)'), $num_comments);
    334340
    335341                // Finally the pings
     
    379385                }
    380386                if ( $num_pings )
    381                     printf(__('(%s pings)'), $num_pings);
    382                
     387                    printf(' '.__('(%s pings)'), $num_pings);
     388
    383389                echo "</li>";
    384390            }
    385             flush();
    386391        }
    387392
     
    390395        wp_import_cleanup($this->id);
    391396
    392         echo '<h3>'.sprintf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')).'</h3>';
     397        echo '<h3>'.sprintf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')).'</h3></div>';
    393398    }
    394399
    395400    function import() {
    396401        $this->id = (int) $_GET['id'];
     402       
    397403        $this->file = get_attached_file($this->id);
    398404        $this->get_authors_from_post();
     
    421427
    422428    function MT_Import() {
    423         // Nothing. 
     429        // Nothing.
    424430    }
    425431}
     
    427433$mt_import = new MT_Import();
    428434
    429 register_importer('mt', 'Movable Type', __('Import posts and comments from your Movable Type blog'), array ($mt_import, 'dispatch'));
     435register_importer('mt', __('Movable Type and TypePad'), __('Imports <strong>posts and comments</strong> from your Movable Type or TypePad blog'), array ($mt_import, 'dispatch'));
    430436?>
  • trunk/wp-admin/import/rss.php

    r3503 r4431  
    2020        return strtr($string, $trans_tbl);
    2121    }
    22    
     22
    2323    function greet() {
     24        echo '<div class="narrow">';
    2425        echo '<p>'.__('Howdy! This importer allows you to extract posts from any RSS 2.0 file into your blog. This is useful if you want to import your posts from a system that is not handled by a custom import tool. Pick an RSS file to upload and click Import.').'</p>';
    2526        wp_import_upload_form("admin.php?import=rss&amp;step=1");
     27        echo '</div>';
    2628    }
    2729
    2830    function get_posts() {
    2931        global $wpdb;
    30        
     32
    3133        set_magic_quotes_runtime(0);
    3234        $datalines = file($this->file); // Read the file into an array
     
    3941        foreach ($this->posts as $post) {
    4042            preg_match('|<title>(.*?)</title>|is', $post, $post_title);
    41             $post_title = $wpdb->escape(trim($post_title[1]));
     43            $post_title = str_replace(array('<![CDATA[', ']]>'), '', $wpdb->escape( trim($post_title[1]) ));
    4244
    43             preg_match('|<pubdate>(.*?)</pubdate>|is', $post, $post_date);
     45            preg_match('|<pubdate>(.*?)</pubdate>|is', $post, $post_date_gmt);
    4446
    45             if ($post_date) {
    46                 $post_date = strtotime($post_date[1]);
     47            if ($post_date_gmt) {
     48                $post_date_gmt = strtotime($post_date_gmt[1]);
    4749            } else {
    4850                // if we don't already have something from pubDate
    49                 preg_match('|<dc:date>(.*?)</dc:date>|is', $post, $post_date);
    50                 $post_date = preg_replace('|([-+])([0-9]+):([0-9]+)$|', '\1\2\3', $post_date[1]);
    51                 $post_date = str_replace('T', ' ', $post_date);
    52                 $post_date = strtotime($post_date);
     51                preg_match('|<dc:date>(.*?)</dc:date>|is', $post, $post_date_gmt);
     52                $post_date_gmt = preg_replace('|([-+])([0-9]+):([0-9]+)$|', '\1\2\3', $post_date_gmt[1]);
     53                $post_date_gmt = str_replace('T', ' ', $post_date_gmt);
     54                $post_date_gmt = strtotime($post_date_gmt);
    5355            }
    5456
    55             $post_date = gmdate('Y-m-d H:i:s', $post_date);
     57            $post_date_gmt = gmdate('Y-m-d H:i:s', $post_date_gmt);
     58            $post_date = get_date_from_gmt( $post_date_gmt );
    5659
    5760            preg_match_all('|<category>(.*?)</category>|is', $post, $categories);
     
    9194            $post_author = 1;
    9295            $post_status = 'publish';
    93             $this->posts[$index] = compact('post_author', 'post_date', 'post_content', 'post_title', 'post_status', 'guid', 'categories');
     96            $this->posts[$index] = compact('post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 'post_status', 'guid', 'categories');
    9497            $index++;
    9598        }
     
    135138        $this->import_posts();
    136139        wp_import_cleanup($file['id']);
    137        
     140
    138141        echo '<h3>';
    139142        printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home'));
     
    148151
    149152        $this->header();
    150        
     153
    151154        switch ($step) {
    152155            case 0 :
     
    157160                break;
    158161        }
    159        
     162
    160163        $this->footer();
    161164    }
    162165
    163166    function RSS_Import() {
    164         // Nothing. 
     167        // Nothing.
    165168    }
    166169}
     
    168171$rss_import = new RSS_Import();
    169172
    170 register_importer('rss', 'RSS', __('Import posts from an RSS feed'), array ($rss_import, 'dispatch'));
     173register_importer('rss', __('RSS'), __('Import posts from an RSS feed'), array ($rss_import, 'dispatch'));
    171174?>
  • trunk/wp-admin/import/textpattern.php

    r3503 r4431  
    88    {
    99    global $wpdb;
    10    
     10
    1111    $cat_id -= 0;   // force numeric
    1212    $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"');
    13    
     13
    1414    return $name;
    1515    }
     
    5050        echo '</div>';
    5151    }
    52    
    53     function greet()
    54     {
     52
     53    function greet() {
     54        echo '<div class="narrow">';
    5555        echo '<p>'.__('Howdy! This importer allows you to extract posts from any Textpattern 4.0.2+ into your blog. This has not been tested on previous versions of Textpattern.  Mileage may vary.').'</p>';
    5656        echo '<p>'.__('Your Textpattern Configuration settings are as follows:').'</p>';
    5757        echo '<form action="admin.php?import=textpattern&amp;step=1" method="post">';
    5858        $this->db_form();
    59         echo '<input type="submit" name="submit" value="'.__('Import Categories').'" />';
     59        echo '<p class="submit"><input type="submit" name="submit" value="'.__('Import Categories').' &raquo;" /></p>';
    6060        echo '</form>';
     61        echo '</div>';
    6162    }
    6263
     
    6869        set_magic_quotes_runtime(0);
    6970        $prefix = get_option('tpre');
    70        
     71
    7172        // Get Categories
    7273        return $txpdb->get_results('SELECT
     
    7879                                     ARRAY_A);
    7980    }
    80    
     81
    8182    function get_txp_users()
    8283    {
     
    8687        set_magic_quotes_runtime(0);
    8788        $prefix = get_option('tpre');
    88        
     89
    8990        // Get Users
    90        
     91
    9192        return $txpdb->get_results('SELECT
    9293                                        user_id,
     
    9798                                    FROM '.$prefix.'txp_users', ARRAY_A);
    9899    }
    99    
     100
    100101    function get_txp_posts()
    101102    {
     
    104105        set_magic_quotes_runtime(0);
    105106        $prefix = get_option('tpre');
    106        
     107
    107108        // Get Posts
    108109        return $txpdb->get_results('SELECT
     
    123124                                    ', ARRAY_A);
    124125    }
    125    
     126
    126127    function get_txp_comments()
    127128    {
     
    131132        set_magic_quotes_runtime(0);
    132133        $prefix = get_option('tpre');
    133        
     134
    134135        // Get Comments
    135136        return $txpdb->get_results('SELECT * FROM '.$prefix.'txp_discuss', ARRAY_A);
    136137    }
    137    
     138
    138139        function get_txp_links()
    139140    {
     
    142143        set_magic_quotes_runtime(0);
    143144        $prefix = get_option('tpre');
    144        
     145
    145146        return $txpdb->get_results('SELECT
    146147                                        id,
     
    153154                                      ARRAY_A);                       
    154155    }
    155    
     156
    156157    function cat2wp($categories='')
    157158    {
     
    168169                $count++;
    169170                extract($category);
    170                
    171                
     171
     172
    172173                // Make Nice Variables
    173174                $name = $wpdb->escape($name);
    174175                $title = $wpdb->escape($title);
    175                
     176
    176177                if($cinfo = category_exists($name))
    177178                {
     
    184185                $txpcat2wpcat[$id] = $ret_id;
    185186            }
    186            
     187
    187188            // Store category translation for future use
    188189            add_option('txpcat2wpcat',$txpcat2wpcat);
     
    193194        return false;
    194195    }
    195    
     196
    196197    function users2wp($users='')
    197198    {
     
    200201        $count = 0;
    201202        $txpid2wpid = array();
    202        
     203
    203204        // Midnight Mojo
    204205        if(is_array($users))
     
    209210                $count++;
    210211                extract($user);
    211                
     212
    212213                // Make Nice Variables
    213214                $name = $wpdb->escape($name);
    214215                $RealName = $wpdb->escape($RealName);
    215                
     216
    216217                if($uinfo = get_userdatabylogin($name))
    217218                {
    218                    
     219
    219220                    $ret_id = wp_insert_user(array(
    220221                                'ID'            => $uinfo->ID,
     
    237238                }
    238239                $txpid2wpid[$user_id] = $ret_id;
    239                
     240
    240241                // Set Textpattern-to-WordPress permissions translation
    241242                $transperms = array(1 => '10', 2 => '9', 3 => '5', 4 => '4', 5 => '3', 6 => '2', 7 => '0');
    242                
     243
    243244                // Update Usermeta Data
    244245                $user = new WP_User($ret_id);
     
    250251                if('2'  == $transperms[$privs]) { $user->set_role('contributor'); }
    251252                if('0'  == $transperms[$privs]) { $user->set_role('subscriber'); }
    252                
     253
    253254                update_usermeta( $ret_id, 'wp_user_level', $transperms[$privs] );
    254255                update_usermeta( $ret_id, 'rich_editing', 'false');
    255256            }// End foreach($users as $user)
    256            
     257
    257258            // Store id translation array for future use
    258259            add_option('txpid2wpid',$txpid2wpid);
    259            
    260            
     260
     261
    261262            echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>';
    262263            return true;
    263264        }// End if(is_array($users)
    264        
     265
    265266        echo __('No Users to Import!');
    266267        return false;
    267        
     268
    268269    }// End function user2wp()
    269    
     270
    270271    function posts2wp($posts='')
    271272    {
     
    284285                $count++;
    285286                extract($post);
    286                
     287
    287288                // Set Textpattern-to-WordPress status translation
    288289                $stattrans = array(1 => 'draft', 2 => 'private', 3 => 'draft', 4 => 'publish', 5 => 'publish');
    289                
     290
    290291                //Can we do this more efficiently?
    291292                $uinfo = ( get_userdatabylogin( $AuthorID ) ) ? get_userdatabylogin( $AuthorID ) : 1;
     
    296297                $Excerpt = $wpdb->escape($Excerpt);
    297298                $post_status = $stattrans[$Status];
    298                
     299
    299300                // Import Post data into WordPress
    300                
     301
    301302                if($pinfo = post_exists($Title,$Body))
    302303                {
     
    333334                }
    334335                $txpposts2wpposts[$ID] = $ret_id;
    335                
     336
    336337                // Make Post-to-Category associations
    337338                $cats = array();
     
    339340                if($cat2 = get_catbynicename($Category2)) { $cats[2] = $cat2; }
    340341
    341                 if(!empty($cats)) { wp_set_post_cats('', $ret_id, $cats); }
     342                if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); }
    342343            }
    343344        }
    344345        // Store ID translation for later use
    345346        add_option('txpposts2wpposts',$txpposts2wpposts);
    346        
     347
    347348        echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>';
    348         return true;   
    349     }
    350    
     349        return true;
     350    }
     351
    351352    function comments2wp($comments='')
    352353    {
     
    356357        $txpcm2wpcm = array();
    357358        $postarr = get_option('txpposts2wpposts');
    358        
     359
    359360        // Magic Mojo
    360361        if(is_array($comments))
     
    365366                $count++;
    366367                extract($comment);
    367                
     368
    368369                // WordPressify Data
    369370                $comment_ID = ltrim($discussid, '0');
     
    374375                $web = $wpdb->escape($web);
    375376                $message = $wpdb->escape($message);
    376                
     377
    377378                if($cinfo = comment_exists($name, $posted))
    378379                {
     
    406407            }
    407408            // Store Comment ID translation for future use
    408             add_option('txpcm2wpcm', $txpcm2wpcm);         
    409            
     409            add_option('txpcm2wpcm', $txpcm2wpcm);
     410
    410411            // Associate newly formed categories with posts
    411412            get_comment_count($ret_id);
    412            
    413            
     413
     414
    414415            echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>';
    415416            return true;
     
    418419        return false;
    419420    }
    420    
     421
    421422    function links2wp($links='')
    422423    {
     
    424425        global $wpdb;
    425426        $count = 0;
    426        
     427
    427428        // Deal with the links
    428429        if(is_array($links))
     
    433434                $count++;
    434435                extract($link);
    435                
     436
    436437                // Make nice vars
    437438                $category = $wpdb->escape($category);
    438439                $linkname = $wpdb->escape($linkname);
    439440                $description = $wpdb->escape($description);
    440                
     441
    441442                if($linfo = link_exists($linkname))
    442443                {
     
    471472        return false;
    472473    }
    473        
     474
    474475    function import_categories()
    475     {   
    476         // Category Import 
     476    {
     477        // Category Import
    477478        $cats = $this->get_txp_cats();
    478479        $this->cat2wp($cats);
    479480        add_option('txp_cats', $cats);
    480        
    481        
    482            
     481
     482
     483
    483484        echo '<form action="admin.php?import=textpattern&amp;step=2" method="post">';
    484485        printf('<input type="submit" name="submit" value="%s" />', __('Import Users'));
     
    486487
    487488    }
    488    
     489
    489490    function import_users()
    490491    {
     
    492493        $users = $this->get_txp_users();
    493494        $this->users2wp($users);
    494        
     495
    495496        echo '<form action="admin.php?import=textpattern&amp;step=3" method="post">';
    496497        printf('<input type="submit" name="submit" value="%s" />', __('Import Posts'));
    497498        echo '</form>';
    498499    }
    499    
     500
    500501    function import_posts()
    501502    {
     
    503504        $posts = $this->get_txp_posts();
    504505        $this->posts2wp($posts);
    505        
     506
    506507        echo '<form action="admin.php?import=textpattern&amp;step=4" method="post">';
    507508        printf('<input type="submit" name="submit" value="%s" />', __('Import Comments'));
    508509        echo '</form>';
    509510    }
    510    
     511
    511512    function import_comments()
    512513    {
     
    514515        $comments = $this->get_txp_comments();
    515516        $this->comments2wp($comments);
    516        
     517
    517518        echo '<form action="admin.php?import=textpattern&amp;step=5" method="post">';
    518519        printf('<input type="submit" name="submit" value="%s" />', __('Import Links'));
    519520        echo '</form>';
    520521    }
    521    
     522
    522523    function import_links()
    523524    {
     
    526527        $this->links2wp($links);
    527528        add_option('txp_links', $links);
    528        
     529
    529530        echo '<form action="admin.php?import=textpattern&amp;step=6" method="post">';
    530531        printf('<input type="submit" name="submit" value="%s" />', __('Finish'));
    531532        echo '</form>';
    532533    }
    533    
     534
    534535    function cleanup_txpimport()
    535536    {
     
    547548        $this->tips();
    548549    }
    549    
     550
    550551    function tips()
    551552    {
     
    556557        echo '<p>'.__('Secondly, we have attempted to preserve post authors.  If you are the only author or contributor to your blog, then you are safe.  In most cases, we are successful in this preservation endeavor.  However, if we cannot ascertain the name of the writer due to discrepancies between database tables, we assign it to you, the administrative user.').'</p>';
    557558        echo '<h3>'.__('Textile').'</h3>';
    558         echo '<p>'.__('Also, since you\'re coming from Textpattern, you probably have been using Textile to format your comments and posts.  If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/2004/04/19/wordpress-plugin-textile-20/">Textile for WordPress</a>.  Trust me... You\'ll want it.').'</p>';
     559        echo '<p>'.__('Also, since you\'re coming from Textpattern, you probably have been using Textile to format your comments and posts.  If this is the case, we recommend downloading and installing <a href="http://www.huddledmasses.org/category/development/wordpress/textile/">Textile for WordPress</a>.  Trust me... You\'ll want it.').'</p>';
    559560        echo '<h3>'.__('WordPress Resources').'</h3>';
    560561        echo '<p>'.__('Finally, there are numerous WordPress resources around the internet.  Some of them are:').'</p>';
    561562        echo '<ul>';
    562563        echo '<li>'.__('<a href="http://www.wordpress.org">The official WordPress site</a>').'</li>';
    563         echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums').'</li>';
     564        echo '<li>'.__('<a href="http://wordpress.org/support/">The WordPress support forums</a>').'</li>';
    564565        echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>';
    565566        echo '</ul>';
    566567        echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>';
    567568    }
    568    
     569
    569570    function db_form()
    570571    {
    571         echo '<ul>';
    572         printf('<li><label for="dbuser">%s</label> <input type="text" name="dbuser" /></li>', __('Textpattern Database User:'));
    573         printf('<li><label for="dbpass">%s</label> <input type="password" name="dbpass" /></li>', __('Textpattern Database Password:'));
    574         printf('<li><label for="dbname">%s</label> <input type="text" name="dbname" /></li>', __('Textpattern Database Name:'));
    575         printf('<li><label for="dbhost">%s</label> <input type="text" name="dbhost" value="localhost" /></li>', __('Textpattern Database Host:'));
    576         printf('<li><label for="dbprefix">%s</label> <input type="text" name="dbprefix" /></li>', __('Textpattern Table prefix (if any):'));
    577         echo '</ul>';
    578     }
    579    
     572        echo '<table class="editform">';
     573        printf('<tr><th scope="row"><label for="dbuser">%s</label></th><td><input type="text" name="dbuser" id="dbuser" /></td></tr>', __('Textpattern Database User:'));
     574        printf('<tr><th scope="row"><label for="dbpass">%s</label></th><td><input type="password" name="dbpass" id="dbpass" /></td></tr>', __('Textpattern Database Password:'));
     575        printf('<tr><th scope="row"><label for="dbname">%s</label></th><td><input type="text" id="dbname" name="dbname" /></td></tr>', __('Textpattern Database Name:'));
     576        printf('<tr><th scope="row"><label for="dbhost">%s</label></th><td><input type="text" id="dbhost" name="dbhost" value="localhost" /></td></tr>', __('Textpattern Database Host:'));
     577        printf('<tr><th scope="row"><label for="dbprefix">%s</label></th><td><input type="text" name="dbprefix" id="dbprefix"  /></td></tr>', __('Textpattern Table prefix (if any):'));
     578        echo '</table>';
     579    }
     580
    580581    function dispatch()
    581582    {
     
    586587            $step = (int) $_GET['step'];
    587588        $this->header();
    588        
     589
    589590        if ( $step > 0 )
    590591        {
     
    592593            {
    593594                if(get_option('txpuser'))
    594                     delete_option('txpuser');   
     595                    delete_option('txpuser');
    595596                add_option('txpuser',$_POST['dbuser']);
    596597            }
     
    598599            {
    599600                if(get_option('txppass'))
    600                     delete_option('txppass');   
     601                    delete_option('txppass');
    601602                add_option('txppass',$_POST['dbpass']);
    602603            }
    603            
     604
    604605            if($_POST['dbname'])
    605606            {
    606607                if(get_option('txpname'))
    607                     delete_option('txpname');   
     608                    delete_option('txpname');
    608609                add_option('txpname',$_POST['dbname']);
    609610            }
     
    619620                    delete_option('tpre');
    620621                add_option('tpre',$_POST['dbprefix']);
    621             }           
     622            }
    622623
    623624
     
    649650                break;
    650651        }
    651        
     652
    652653        $this->footer();
    653654    }
     
    655656    function Textpattern_Import()
    656657    {
    657         // Nothing. 
     658        // Nothing.
    658659    }
    659660}
    660661
    661662$txp_import = new Textpattern_Import();
    662 register_importer('textpattern', 'Textpattern', __('Import posts from a Textpattern Blog'), array ($txp_import, 'dispatch'));
     663register_importer('textpattern', __('Textpattern'), __('Import posts from a Textpattern Blog'), array ($txp_import, 'dispatch'));
    663664?>
  • trunk/wp-admin/index.php

    r3503 r4431  
    22require_once('admin.php');
    33$title = __('Dashboard');
     4$parent_file = 'index.php';
    45require_once('admin-header.php');
    5 require_once (ABSPATH . WPINC . '/rss-functions.php');
     6require_once (ABSPATH . WPINC . '/rss.php');
    67
    78$today = current_time('mysql', 1);
     
    1011<div class="wrap">
    1112
    12 <h2><?php _e('Dashboard'); ?></h2>
     13<h2><?php _e('Welcome to WordPress'); ?></h2>
    1314
    1415<div id="zeitgeist">
     
    2021?>
    2122<div id="incominglinks">
    22 <h3><?php _e('Incoming Links'); ?> <cite><a href="http://www.technorati.com/search/<?php echo trailingslashit(get_option('home')); ?>?partner=wordpress"><?php _e('More'); ?> &raquo;</a></cite></h3>
     23<h3><?php _e('Incoming Links'); ?> <cite><a href="http://www.technorati.com/search/<?php echo trailingslashit(get_option('home')); ?>?partner=wordpress"><?php _e('More &raquo;'); ?></a></cite></h3>
    2324<ul>
    2425<?php
     
    2627foreach ($rss->items as $item ) {
    2728?>
    28     <li><a href="<?php echo wp_filter_kses($item['link']); ?>"><?php echo wp_specialchars($item['title']); ?></a></li>
     29    <li><a href="<?php echo wp_filter_kses($item['link']); ?>"><?php echo wptexturize(wp_specialchars($item['title'])); ?></a></li>
    2930<?php } ?>
    3031</ul>
     
    4445<p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format($numcomments) ); ?> &raquo;</a></strong></p>
    4546<?php endif; ?>
    46 </div>
    4747
    4848<ul>
     
    5757?>
    5858</ul>
    59 
     59</div>
    6060<?php endif; ?>
    6161
    6262<?php
    63 if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) :
     63if ( $recentposts = $wpdb->get_results("SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' AND post_date_gmt < '$today' ORDER BY post_date DESC LIMIT 5") ) :
    6464?>
    6565<div>
     
    8080
    8181<?php
    82 if ( $scheduled = $wpdb->get_results("SELECT ID, post_title, post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_date_gmt > '$today' ORDER BY post_date ASC") ) :
     82if ( $scheduled = $wpdb->get_results("SELECT ID, post_title, post_date_gmt FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'future' ORDER BY post_date ASC") ) :
    8383?>
    8484<div>
     
    9999<h3><?php _e('Blog Stats'); ?></h3>
    100100<?php
    101 $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_status = 'publish'");
     101$numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'");
    102102if (0 < $numposts) $numposts = number_format($numposts);
    103103
     
    114114</div>
    115115
    116 <h3><?php _e('Welcome to WordPress'); ?></h3>
    117 
    118116<p><?php _e('Use these links to get started:'); ?></p>
    119117
    120118<ul>
    121 <li><a href="post.php"><?php _e('Write a post'); ?></a></li>
    122 <li><a href="profile.php"><?php _e('Update your profile or change your password'); ?></a></li>
    123 <li><a href="link-add.php"><?php _e('Add a link to your blogroll'); ?></a></li>
    124 <li><a href="themes.php"><?php _e('Change your site&#8217;s look or theme'); ?></a></li>
     119<?php if ( current_user_can('edit_posts') ) : ?>
     120    <li><a href="post-new.php"><?php _e('Write a post'); ?></a></li>
     121<?php endif; ?>
     122    <li><a href="profile.php"><?php _e('Update your profile or change your password'); ?></a></li>
     123<?php if ( current_user_can('manage_links') ) : ?>
     124    <li><a href="link-add.php"><?php _e('Add a bookmark to your blogroll'); ?></a></li>
     125<?php endif; ?>
     126<?php if ( current_user_can('switch_themes') ) : ?>
     127    <li><a href="themes.php"><?php _e('Change your site&#8217;s look or theme'); ?></a></li>
     128<?php endif; ?>
    125129</ul>
    126 
    127 <p><?php _e("Below is the latest news from the official WordPress development blog, click on a title to read the full entry. If you need help with WordPress please see our <a href='http://codex.wordpress.org/'>great documentation</a> or if that doesn't help visit the <a href='http://wordpress.org/support/'>support forums</a>."); ?></p>
     130<p><?php _e("Need help with WordPress? Please see our <a href='http://codex.wordpress.org/'>documentation</a> or visit the <a href='http://wordpress.org/support/'>support forums</a>."); ?></p>
    128131<?php
    129132$rss = @fetch_rss('http://wordpress.org/development/feed/');
    130133if ( isset($rss->items) && 0 != count($rss->items) ) {
    131134?>
     135<div id="devnews">
    132136<h3><?php _e('WordPress Development Blog'); ?></h3>
    133137<?php
     
    141145}
    142146?>
    143 
     147</div>
    144148
    145149<?php
     
    148152?>
    149153<div id="planetnews">
    150 <h3><?php _e('Other WordPress News'); ?> <a href="http://planet.wordpress.org/"><?php _e('more'); ?> &raquo;</a></h3>
     154<h3><?php _e('Other WordPress News'); ?></h3>
    151155<ul>
    152156<?php
    153157$rss->items = array_slice($rss->items, 0, 20);
    154158foreach ($rss->items as $item ) {
     159$title = wp_specialchars($item['title']);
     160$author = preg_replace( '|(.+?):.+|s', '$1', $item['title'] );
     161$post = preg_replace( '|.+?:(.+)|s', '$1', $item['title'] );
    155162?>
    156 <li><a href='<?php echo wp_filter_kses($item['link']); ?>'><?php echo wp_specialchars($item['title']); ?></a></li>
     163<li><a href='<?php echo wp_filter_kses($item['link']); ?>'><span class="post"><?php echo $post; ?></span><span class="hidden"> - </span><cite><?php echo $author; ?></cite></a></li>
    157164<?php
    158165    }
    159166?>
    160167</ul>
     168<p class="readmore"><a href="http://planet.wordpress.org/"><?php _e('Read more'); ?> &raquo;</a></p>
    161169</div>
    162170<?php
  • trunk/wp-admin/install.php

    r3503 r4431  
    11<?php
    22define('WP_INSTALLING', true);
    3 if (!file_exists('../wp-config.php'))
    4     die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://wordpress.org/docs/faq/#wp-config'>We got it</a>. You can <a href='setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.");
     3if (!file_exists('../wp-config.php')) {
     4  require_once('../wp-includes/functions.php');
     5  wp_die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Installing_WordPress#Step_3:_Set_up_wp-config.php'>We got it</a>. You can <a href='setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.", "WordPress &rsaquo; Error");
     6}
    57
    68require_once('../wp-config.php');
    79require_once('./upgrade-functions.php');
    8 
    9 $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
    10 $guessurl = str_replace('/wp-admin/install.php?step=2', '', $schema . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) );
    1110
    1211if (isset($_GET['step']))
     
    1716?>
    1817<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    19 <html xmlns="http://www.w3.org/1999/xhtml">
     18<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    2019<head>
     20    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    2121    <title><?php _e('WordPress &rsaquo; Installation'); ?></title>
    22     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    23     <style media="screen" type="text/css">
    24     <!--
    25     html {
    26         background: #eee;
    27     }
    28     body {
    29         background: #fff;
    30         color: #000;
    31         font-family: Georgia, "Times New Roman", Times, serif;
    32         margin-left: 20%;
    33         margin-right: 20%;
    34         padding: .2em 2em;
    35     }
    36    
    37     h1 {
    38         color: #006;
    39         font-size: 18px;
    40         font-weight: lighter;
    41     }
    42    
    43     h2 {
    44         font-size: 16px;
    45     }
    46    
    47     p, li, dt {
    48         line-height: 140%;
    49         padding-bottom: 2px;
    50     }
    51 
    52     ul, ol {
    53         padding: 5px 5px 5px 20px;
    54     }
    55     #logo {
    56         margin-bottom: 2em;
    57     }
    58     .step a, .step input {
    59         font-size: 2em;
    60     }
    61     td input {
    62         font-size: 1.5em;
    63     }
    64     .step, th {
    65         text-align: right;
    66     }
    67     #footer {
    68         text-align: center;
    69         border-top: 1px solid #ccc;
    70         padding-top: 1em;
    71         font-style: italic;
    72     }
    73     -->
    74     </style>
     22    <link rel="stylesheet" href="install.css?version=<?php bloginfo('version'); ?>" type="text/css" />
     23    <?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
     24    <link rel="stylesheet" href="install-rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />
     25    <?php endif; ?>
    7526</head>
    7627<body>
     
    7829<?php
    7930// Let's check to make sure WP isn't already installed.
    80 $wpdb->hide_errors();
    81 $installed = $wpdb->get_results("SELECT * FROM $wpdb->users");
    82 if ($installed) die('<h1>'.__('Already Installed').'</h1><p>'.__('You appear to have already installed WordPress. To reinstall please clear your old database tables first.').'</p></body></html>');
    83 $wpdb->show_errors();
     31if ( is_blog_installed() ) die('<h1>'.__('Already Installed').'</h1><p>'.__('You appear to have already installed WordPress. To reinstall please clear your old database tables first.').'</p></body></html>');
    8432
    8533switch($step) {
    86 
    8734    case 0:
    8835?>
    8936<p><?php printf(__('Welcome to WordPress installation. We&#8217;re now going to go through a few steps to get you up and running with the latest in personal publishing platforms. You may want to peruse the <a href="%s">ReadMe documentation</a> at your leisure.'), '../readme.html'); ?></p>
    90     <h2 class="step"><a href="install.php?step=1"><?php _e('First Step &raquo;'); ?></a></h2>
     37<h2 class="step"><a href="install.php?step=1"><?php _e('First Step &raquo;'); ?></a></h2>
    9138<?php
    92     break;
    93 
     39        break;
    9440    case 1:
    95 
    9641?>
    9742<h1><?php _e('First Step'); ?></h1>
     
    9944
    10045<form id="setup" method="post" action="install.php?step=2">
    101 <table width="100%">
    102 <tr>
    103 <th width="33%"><?php _e('Weblog title:'); ?></th>
    104 <td><input name="weblog_title" type="text" id="weblog_title" size="25" /></td>
    105 </tr>
    106 <tr>
    107 <th><?php _e('Your e-mail:'); ?></th>
    108     <td><input name="admin_email" type="text" id="admin_email" size="25" /></td>
    109 </tr>
    110 </table>
    111 <p><em><?php _e('Double-check that email address before continuing.'); ?></em></p>
    112 <h2 class="step">
    113 <input type="submit" name="Submit" value="<?php _e('Continue to Second Step &raquo;'); ?>" />
    114 </h2>
     46    <table width="100%">
     47        <tr>
     48            <th width="33%"><?php _e('Weblog title:'); ?></th>
     49            <td><input name="weblog_title" type="text" id="weblog_title" size="25" /></td>
     50        </tr>
     51        <tr>
     52            <th><?php _e('Your e-mail:'); ?></th>
     53            <td><input name="admin_email" type="text" id="admin_email" size="25" /></td>
     54        </tr>
     55        <tr>
     56            <th scope="row"  valign="top"> <?php __('Privacy:'); ?></th>
     57            <td><label><input type="checkbox" name="blog_public" value="1" checked="checked" /> <?php _e('I would like my blog to appear in search engines like Google and Technorati.'); ?></label></td>
     58        </tr>
     59    </table>
     60    <p><em><?php _e('Double-check that email address before continuing.'); ?></em></p>
     61    <h2 class="step"><input type="submit" name="Submit" value="<?php _e('Continue to Second Step &raquo;'); ?>" /></h2>
    11562</form>
    11663
    11764<?php
    118     break;
     65        break;
    11966    case 2:
     67        // Fill in the data we gathered
     68        $weblog_title = stripslashes($_POST['weblog_title']);
     69        $admin_email = stripslashes($_POST['admin_email']);
     70        $public = (int) $_POST['blog_public'];
     71        // check e-mail address
     72        if (empty($admin_email)) {
     73            die(__("<strong>ERROR</strong>: please type your e-mail address"));
     74        } else if (!is_email($admin_email)) {
     75            die(__("<strong>ERROR</strong>: the e-mail address isn't correct"));
     76        }
    12077
    121 // Fill in the data we gathered
    122 $weblog_title = stripslashes($_POST['weblog_title']);
    123 $admin_email = stripslashes($_POST['admin_email']);
    124 // check e-mail address
    125 if (empty($admin_email)) {
    126     die (__("<strong>ERROR</strong>: please type your e-mail address"));
    127 } else if (!is_email($admin_email)) {
    128     die (__("<strong>ERROR</strong>: the e-mail address isn't correct"));
    129 }
    130    
    13178?>
    13279<h1><?php _e('Second Step'); ?></h1>
     
    13582
    13683<?php
    137 flush();
    138 
    139 // Set everything up
    140 wp_cache_flush();
    141 make_db_current_silent();
    142 populate_options();
    143 populate_roles();
    144 
    145 update_option('blogname', $weblog_title);
    146 update_option('admin_email', $admin_email);
    147 
    148 // Now drop in some default links
    149 $wpdb->query("INSERT INTO $wpdb->linkcategories (cat_id, cat_name) VALUES (1, '".$wpdb->escape(__('Blogroll'))."')");
    150 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://blogs.linux.ie/xeer/', 'Donncha', 1, 'http://blogs.linux.ie/xeer/feed/', '');");
    151 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 1, 'http://zengun.org/weblog/feed/', '');");
    152 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 1, 'http://boren.nu/feed/', '');");
    153 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 1, 'http://xml.photomatt.net/feed/', '');");
    154 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 1, 'http://zed1.com/journalized/feed/', '');");
    155 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 1, 'http://www.alexking.org/blog/wp-rss2.php', '');");
    156 $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 1, 'http://dougal.gunters.org/feed/', '');");
    157 
    158 // Default category
    159 $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')");
    160 
    161 // First post
    162 $now = date('Y-m-d H:i:s');
    163 $now_gmt = gmdate('Y-m-d H:i:s');
    164 $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, comment_count, to_ping, pinged, post_content_filtered) VALUES ('1', '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(__('hello-world'))."', '$now', '$now_gmt', '1', '', '', '')");
    165 
    166 $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
    167 
    168 // Default comment
    169 $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.<br />To delete a comment, just log in, and view the posts\' comments, there you will have the option to edit or delete them.'))."')");
    170 
    171 // First Page
    172 
    173 $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, to_ping, pinged, post_content_filtered) VALUES ('1', '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'static', '', '', '')");
    174 $wp_rewrite->flush_rules();
    175 
    176 // Set up admin user
    177 $random_password = substr(md5(uniqid(microtime())), 0, 6);
    178 $display_name_array = explode('@', $admin_email);
    179 $display_name = $display_name_array[0];
    180 $wpdb->query("INSERT INTO $wpdb->users (ID, user_login, user_pass, user_email, user_registered, display_name, user_nicename) VALUES ( '1', 'admin', MD5('$random_password'), '$admin_email', NOW(), '$display_name', 'admin')");
    181 $wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$table_prefix}user_level', '10');");
    182 $admin_caps = serialize(array('administrator' => true));
    183 $wpdb->query("INSERT INTO $wpdb->usermeta (user_id, meta_key, meta_value) VALUES ({$wpdb->insert_id}, '{$table_prefix}capabilities', '{$admin_caps}');");
    184 
    185 $message_headers = 'From: ' . $weblog_title . ' <wordpress@' . $_SERVER['SERVER_NAME'] . '>';
    186 $message = sprintf(__("Your new WordPress blog has been successfully set up at:
    187 
    188 %1\$s
    189 
    190 You can log in to the administrator account with the following information:
    191 
    192 Username: admin
    193 Password: %2\$s
    194 
    195 We hope you enjoy your new weblog. Thanks!
    196 
    197 --The WordPress Team
    198 http://wordpress.org/
    199 "), $guessurl, $random_password);
    200 
    201 @wp_mail($admin_email, __('New WordPress Blog'), $message, $message_headers);
    202 
    203 wp_cache_flush();
     84    $result = wp_install($weblog_title, __('admin'), $admin_email, $public);
     85    extract($result);
    20486?>
    20587
    20688<p><em><?php _e('Finished!'); ?></em></p>
    20789
    208 <p><?php printf(__('Now you can <a href="%1$s">log in</a> with the <strong>username</strong> "<code>admin</code>" and <strong>password</strong> "<code>%2$s</code>".'), '../wp-login.php', $random_password); ?></p>
    209 <p><?php _e('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you. If you lose it, you will have to delete the tables from the database yourself, and re-install WordPress. So to review:'); ?>
    210 </p>
     90<p><?php printf(__('Now you can <a href="%1$s">log in</a> with the <strong>username</strong> "<code>admin</code>" and <strong>password</strong> "<code>%2$s</code>".'), '../wp-login.php', $password); ?></p>
     91<p><?php _e('<strong><em>Note that password</em></strong> carefully! It is a <em>random</em> password that was generated just for you. If you lose it, you will have to delete the tables from the database yourself, and re-install WordPress. So to review:'); ?></p>
     92
    21193<dl>
    212 <dt><?php _e('Username'); ?></dt>
    213 <dd><code>admin</code></dd>
    214 <dt><?php _e('Password'); ?></dt>
    215 <dd><code><?php echo $random_password; ?></code></dd>
     94    <dt><?php _e('Username'); ?></dt>
     95        <dd><code><?php _e('admin') ?></code></dd>
     96    <dt><?php _e('Password'); ?></dt>
     97        <dd><code><?php echo $password; ?></code></dd>
    21698    <dt><?php _e('Login address'); ?></dt>
    217 <dd><a href="../wp-login.php">wp-login.php</a></dd>
     99        <dd><a href="../wp-login.php">wp-login.php</a></dd>
    218100</dl>
    219101<p><?php _e('Were you expecting more steps? Sorry to disappoint. All done! :)'); ?></p>
     102
    220103<?php
    221     break;
     104        break;
    222105}
    223106?>
     107
    224108<p id="footer"><?php _e('<a href="http://wordpress.org/">WordPress</a>, personal publishing platform.'); ?></p>
    225109</body>
  • trunk/wp-admin/link-add.php

    r3503 r4431  
    22require_once('admin.php');
    33
    4 $title = __('Add Link');
     4$title = __('Add Bookmark');
    55$this_file = 'link-manager.php';
    66$parent_file = 'link-manager.php';
    77
    88
    9 $wpvarstoreset = array('action', 'cat_id', 'linkurl', 'name', 'image',
     9wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image',
    1010                       'description', 'visible', 'target', 'category', 'link_id',
    1111                       'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
    12                        'notes', 'linkcheck[]');
    13 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    14     $wpvar = $wpvarstoreset[$i];
    15     if (!isset($$wpvar)) {
    16         if (empty($_POST["$wpvar"])) {
    17             if (empty($_GET["$wpvar"])) {
    18                 $$wpvar = '';
    19             } else {
    20                 $$wpvar = $_GET["$wpvar"];
    21             }
    22         } else {
    23             $$wpvar = $_POST["$wpvar"];
    24         }
    25     }
    26 }
     12                       'notes', 'linkcheck[]'));
    2713
    28 $xfn_js = true;
     14wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') );
     15if ( current_user_can( 'manage_categories' ) )
     16    wp_enqueue_script( 'ajaxcat' );
    2917require('admin-header.php');
    3018?>
     
    3927?>
    4028
    41 <div class="wrap">
    42 <?php printf(__('<p>You can drag <a href="%s" title="Link add bookmarklet">Link This</a> to your toolbar and when you click it a window will pop up that will allow you to add whatever site you&#8217;re on to your links! Right now this only works on Mozilla or Netscape, but we&#8217;re working on it.</p>'), "javascript:void(linkmanpopup=window.open('" . get_settings('siteurl') . "/wp-admin/link-add.php?action=popup&amp;linkurl='+escape(location.href)+'&amp;name='+escape(document.title),'LinkManager','scrollbars=yes,width=750,height=550,left=15,top=15,status=yes,resizable=yes'));linkmanpopup.focus();window.focus();linkmanpopup.focus();") ?>
     29<div id="wp-link-bookmarklet"  class="wrap">
     30<h3><?php _e('Add Link Bookmarklet'); ?></h3>
     31<p><?php _e('Right click on the following link and choose "Bookmark This Link..." to create an add link shortcut. Right now this only works on Mozilla or Netscape, but we’re working on it.'); ?></p>
     32<?php printf(__('<p><a href="%s" title="Link add bookmarklet">Link This</a></p>'), "javascript:void(linkmanpopup=window.open('" . get_option('siteurl') . "/wp-admin/link-add.php?action=popup&amp;linkurl='+escape(location.href)+'&amp;name='+escape(document.title),'LinkManager','scrollbars=yes,width=750,height=550,left=15,top=15,status=yes,resizable=yes'));linkmanpopup.focus();window.focus();linkmanpopup.focus();") ?>
    4333</div>
    4434
  • trunk/wp-admin/link-import.php

    r3503 r4431  
    1717        include_once('admin-header.php');
    1818        if ( !current_user_can('manage_links') )
    19             die (__("Cheatin&#8217; uh?"));
     19            wp_die(__('Cheatin&#8217; uh?'));
    2020
    2121        $opmltype = 'blogrolling'; // default.
     
    2525<h2><?php _e('Import your blogroll from another system') ?> </h2>
    2626<form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll">
     27<?php wp_nonce_field('import-bookmarks') ?>
    2728
    28 <p><?php _e('If a program or website you use allows you to export your links or subscriptions as OPML you may import them here.'); ?>
     29<p><?php _e('If a program or website you use allows you to export your bookmarks or subscriptions as OPML you may import them here.'); ?>
    2930<div style="width: 70%; margin: auto; height: 8em;">
    3031<input type="hidden" name="step" value="1" />
     
    4344</div>
    4445
    45 <p style="clear: both; margin-top: 1em;"><?php _e('Now select a category you want to put these links in.') ?><br />
     46<p style="clear: both; margin-top: 1em;"><?php _e('Now select a category you want to put these bookmarks in.') ?><br />
    4647<?php _e('Category:') ?> <select name="cat_id">
    4748<?php
    48 $categories = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
     49$categories = get_categories('hide_empty=0');
    4950foreach ($categories as $category) {
    5051?>
    51 <option value="<?php echo $category->cat_id; ?>"><?php echo $category->cat_id.': '.$category->cat_name; ?></option>
     52<option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars($category->cat_name); ?></option>
    5253<?php
    5354} // end foreach
     
    5556</select></p>
    5657
    57 <p class="submit"><input type="submit" name="submit" value="<?php _e('Import OPML File') ?> &raquo;" /></p>
     58<p class="submit"><input type="submit" name="submit" value="<?php _e('Import OPML File &raquo;') ?>" /></p>
    5859</form>
    5960
     
    6465
    6566    case 1: {
     67        check_admin_referer('import-bookmarks');
     68
    6669                include_once('admin-header.php');
    6770                if ( !current_user_can('manage_links') )
    68                     die (__("Cheatin' uh ?"));
     71                    wp_die(__('Cheatin&#8217; uh?'));
    6972?>
    7073<div class="wrap">
     
    8790
    8891                    if ( isset($file['error']) )
    89                         die($file['error']);
     92                        wp_die($file['error']);
    9093
    9194                    $url = $file['url'];
     
    104107                        if ('http' == substr($titles[$i], 0, 4))
    105108                            $titles[$i] = '';
    106                         // FIXME:  Use wp_insert_link().
    107                         $query = "INSERT INTO $wpdb->links (link_url, link_name, link_target, link_category, link_description, link_owner, link_rss)
    108                                 VALUES('{$urls[$i]}', '".$wpdb->escape($names[$i])."', '', $cat_id, '".$wpdb->escape($descriptions[$i])."', $user_ID, '{$feeds[$i]}')\n";
    109                         $result = $wpdb->query($query);
     109                        $link = array( 'link_url' => $urls[$i], 'link_name' => $wpdb->escape($names[$i]), 'link_category' => array($cat_id), 'link_description' => $wpdb->escape($descriptions[$i]), 'link_owner' => $user_ID, 'link_rss' => $feeds[$i]);                       
     110                        wp_insert_link($link);
    110111                        echo sprintf('<p>'.__('Inserted <strong>%s</strong>').'</p>', $names[$i]);
    111112                    }
    112113?>
    113      <p><?php printf(__('Inserted %1$d links into category %2$s. All done! Go <a href="%3$s">manage those links</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p>
     114     <p><?php printf(__('Inserted %1$d bookmarks into category %2$s. All done! Go <a href="%3$s">manage those bookmarks</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p>
    114115<?php
    115116                } // end if got url
  • trunk/wp-admin/link-manager.php

    r3503 r4431  
    11<?php
     2
     3
    24// Links
    35// Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com
    46
    5 require_once('admin.php');
     7require_once ('admin.php');
    68
    7 $title = __('Manage Links');
     9$title = __('Manage Bookmarks');
    810$this_file = $parent_file = 'link-manager.php';
    9 $list_js = true;
     11wp_enqueue_script( 'listman' );
    1012
    11 $wpvarstoreset = array('action','cat_id', 'linkurl', 'name', 'image',
    12                        'description', 'visible', 'target', 'category', 'link_id',
    13                        'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel',
    14                        'notes', 'linkcheck[]');
     13wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 'description', 'visible', 'target', 'category', 'link_id', 'submit', 'order_by', 'links_show_cat_id', 'rating', 'rel', 'notes', 'linkcheck[]'));
    1514
    16 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    17     $wpvar = $wpvarstoreset[$i];
    18     if (!isset($$wpvar)) {
    19         if (empty($_POST["$wpvar"])) {
    20             if (empty($_GET["$wpvar"])) {
    21                 $$wpvar = '';
    22             } else {
    23                 $$wpvar = $_GET["$wpvar"];
    24             }
    25         } else {
    26             $$wpvar = $_POST["$wpvar"];
    27         }
    28     }
     15if (empty ($cat_id))
     16    $cat_id = 'all';
     17
     18if (empty ($order_by))
     19    $order_by = 'order_name';
     20
     21$title = __('Manage Bookmarks');
     22include_once ("./admin-header.php");
     23
     24if (!current_user_can('manage_links'))
     25    wp_die(__("You do not have sufficient permissions to edit the bookmarks for this blog."));
     26
     27switch ($order_by) {
     28    case 'order_id' :
     29        $sqlorderby = 'id';
     30        break;
     31    case 'order_url' :
     32        $sqlorderby = 'url';
     33        break;
     34    case 'order_desc' :
     35        $sqlorderby = 'description';
     36        break;
     37    case 'order_owner' :
     38        $sqlorderby = 'owner';
     39        break;
     40    case 'order_rating' :
     41        $sqlorderby = 'rating';
     42        break;
     43    case 'order_name' :
     44    default :
     45        $sqlorderby = 'name';
     46        break;
    2947}
    30 
    31 $links_show_cat_id = $_COOKIE['links_show_cat_id_' . COOKIEHASH];
    32 $links_show_order = $_COOKIE['links_show_order_' . COOKIEHASH];
    33 
    34 if ('' != $_POST['assign']) $action = 'assign';
    35 if ('' != $_POST['visibility']) $action = 'visibility';
    36 if ('' != $_POST['move']) $action = 'move';
    37 if ('' != $_POST['linkcheck']) $linkcheck = $_POST[linkcheck];
    38 
    39 switch ($action) {
    40   case 'assign':
    41   {
    42     check_admin_referer();
    43 
    44     // check the current user's level first.
    45     if ( !current_user_can('manage_links') )
    46       die (__("Cheatin' uh ?"));
    47 
    48     //for each link id (in $linkcheck[]): if the current user level >= the
    49     //userlevel of the owner of the link then we can proceed.
    50 
    51     if (count($linkcheck) == 0) {
    52         header('Location: ' . $this_file);
    53         exit;
    54     }
    55     $all_links = join(',', $linkcheck);
    56     $results = $wpdb->get_results("SELECT link_id, link_owner FROM $wpdb->links LEFT JOIN $wpdb->users ON link_owner = ID WHERE link_id in ($all_links)");
    57     foreach ($results as $row) {
    58        $ids_to_change[] = $row->link_id;
    59     }
    60 
    61     // should now have an array of links we can change
    62     $all_links = join(',', $ids_to_change);
    63     $q = $wpdb->query("update $wpdb->links SET link_owner='$newowner' WHERE link_id IN ($all_links)");
    64 
    65     header('Location: ' . $this_file);
    66     break;
    67   }
    68   case 'visibility':
    69   {
    70     check_admin_referer();
    71 
    72     // check the current user's level first.
    73     if ( !current_user_can('manage_links') )
    74       die (__("Cheatin' uh ?"));
    75 
    76     //for each link id (in $linkcheck[]): toggle the visibility
    77     if (count($linkcheck) == 0) {
    78         header('Location: ' . $this_file);
    79         exit;
    80     }
    81     $all_links = join(',', $linkcheck);
    82     $results = $wpdb->get_results("SELECT link_id, link_visible FROM $wpdb->links WHERE link_id in ($all_links)");
    83     foreach ($results as $row) {
    84         if ($row->link_visible == 'Y') { // ok to proceed
    85             $ids_to_turnoff[] = $row->link_id;
    86         } else {
    87             $ids_to_turnon[] = $row->link_id;
    88         }
    89     }
    90 
    91     // should now have two arrays of links to change
    92     if (count($ids_to_turnoff)) {
    93         $all_linksoff = join(',', $ids_to_turnoff);
    94         $q = $wpdb->query("update $wpdb->links SET link_visible='N' WHERE link_id IN ($all_linksoff)");
    95     }
    96 
    97     if (count($ids_to_turnon)) {
    98         $all_linkson = join(',', $ids_to_turnon);
    99         $q = $wpdb->query("update $wpdb->links SET link_visible='Y' WHERE link_id IN ($all_linkson)");
    100     }
    101 
    102     header('Location: ' . $this_file);
    103     break;
    104   }
    105   case 'move':
    106   {
    107     check_admin_referer();
    108 
    109     // check the current user's level first.
    110     if ( !current_user_can('manage_links') )
    111       die (__("Cheatin' uh ?"));
    112 
    113     //for each link id (in $linkcheck[]) change category to selected value
    114     if (count($linkcheck) == 0) {
    115         header('Location: ' . $this_file);
    116         exit;
    117     }
    118     $all_links = join(',', $linkcheck);
    119     // should now have an array of links we can change
    120     $q = $wpdb->query("update $wpdb->links SET link_category='$category' WHERE link_id IN ($all_links)");
    121 
    122     header('Location: ' . $this_file);
    123     break;
    124   }
    125 
    126   case 'Add':
    127   {
    128     check_admin_referer();
    129 
    130     add_link();
    131    
    132     header('Location: ' . $_SERVER['HTTP_REFERER'] . '?added=true');
    133     break;
    134   } // end Add
    135 
    136   case 'editlink':
    137   {
    138  
    139     check_admin_referer();
    140    
    141     if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
    142         $cat_id = $links_show_cat_id;
    143 
    144     if (!isset($cat_id) || ($cat_id == '')) {
    145         if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
    146             $cat_id = 'All';
    147     }
    148     $links_show_cat_id = $cat_id;
    149 
    150     $link_id = (int) $_POST['link_id'];
    151     edit_link($link_id);
    152    
    153     setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
    154     wp_redirect($this_file);
    155     break;
    156   } // end Save
    157 
    158   case 'Delete':
    159   {
    160     check_admin_referer();
    161 
    162     if ( !current_user_can('manage_links') )
    163       die (__("Cheatin' uh ?"));
    164 
    165     $link_id = (int) $_GET['link_id'];
    166 
    167     wp_delete_link($link_id);
    168    
    169     if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
    170         $cat_id = $links_show_cat_id;
    171 
    172     if (!isset($cat_id) || ($cat_id == '')) {
    173         if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
    174         $cat_id = 'All';
    175     }
    176     $links_show_cat_id = $cat_id;
    177     setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
    178     wp_redirect($this_file);
    179     break;
    180   } // end Delete
    181 
    182   case 'linkedit': {
    183     $xfn_js = true;
    184     include_once ('admin-header.php');
    185     if ( !current_user_can('manage_links') )
    186         die(__('You do not have sufficient permissions to edit the links for this blog.'));
    187    
    188     $link_id = (int) $_GET['link_id'];
    189    
    190     if ( !$link = get_link_to_edit($link_id) )
    191         die( __('Link not found.') );
    192    
    193     include('edit-link-form.php');
    194     break;
    195   } // end linkedit
    196   case __("Show"):
    197   {
    198     if (!isset($cat_id) || ($cat_id == '')) {
    199         if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
    200         $cat_id = 'All';
    201     }
    202     $links_show_cat_id = $cat_id;
    203     if (!isset($order_by) || ($order_by == '')) {
    204         if (!isset($links_show_order) || ($links_show_order == ''))
    205         $order_by = 'order_name';
    206     }
    207     $links_show_order = $order_by;
    208     //break; fall through
    209   } // end Show
    210   case "popup":
    211   {
    212     $link_url = stripslashes($_GET["linkurl"]);
    213     $link_name = stripslashes($_GET["name"]);
    214     //break; fall through
    215   }
    216   default:
    217   {
    218     if (isset($links_show_cat_id) && ($links_show_cat_id != ''))
    219         $cat_id = $links_show_cat_id;
    220 
    221     if (!isset($cat_id) || ($cat_id == '')) {
    222         if (!isset($links_show_cat_id) || ($links_show_cat_id == ''))
    223         $cat_id = 'All';
    224     }
    225     $links_show_cat_id = $cat_id;
    226     if (isset($links_show_order) && ($links_show_order != ''))
    227         $order_by = $links_show_order;
    228 
    229     if (!isset($order_by) || ($order_by == ''))
    230         $order_by = 'order_name';
    231     $links_show_order = $order_by;
    232 
    233     setcookie('links_show_cat_id_' . COOKIEHASH, $links_show_cat_id, time()+600);
    234     setcookie('links_show_order_' . COOKIEHASH, $links_show_order, time()+600);
    235     include_once ("./admin-header.php");
    236     if ( !current_user_can('manage_links') )
    237       die(__("You do not have sufficient permissions to edit the links for this blog."));
    238 
    239     switch ($order_by)
    240     {
    241         case 'order_id':     $sqlorderby = 'id';          break;
    242         case 'order_url':    $sqlorderby = 'url';         break;
    243         case 'order_desc':   $sqlorderby = 'description'; break;
    244         case 'order_owner':  $sqlorderby = 'owner';       break;
    245         case 'order_rating': $sqlorderby = 'rating';      break;
    246         case 'order_name':
    247         default:             $sqlorderby = 'name';        break;
    248     }
    249 
    250   if ($action != "popup") {
    25148?>
    25249<script type="text/javascript">
     
    26663</script>
    26764
    268 <div class="wrap">
    269     <form name="cats" method="post" action="">
    270     <table width="75%" cellpadding="3" cellspacing="3">
    271       <tr>
    272         <td>
    273         <?php _e('<strong>Show</strong> links in category:'); ?><br />
    274         </td>
    275         <td>
    276           <?php _e('<strong>Order</strong> by:');?>
    277         </td>
    278         <td>&nbsp;</td>
    279       </tr>
    280       <tr>
    281         <td>
    28265<?php
    283     $results = $wpdb->get_results("SELECT cat_id, cat_name, auto_toggle FROM $wpdb->linkcategories ORDER BY cat_id");
    284     echo "        <select name=\"cat_id\">\n";
    285     echo "          <option value=\"All\"";
    286     if ($cat_id == 'All')
    287       echo " selected='selected'";
    288     echo "> " . __('All') . "</option>\n";
    289     foreach ($results as $row) {
    290       echo "          <option value=\"".$row->cat_id."\"";
    291       if ($row->cat_id == $cat_id)
    292         echo " selected='selected'";
    293         echo ">".$row->cat_id.": ".wp_specialchars($row->cat_name);
    294         if ($row->auto_toggle == 'Y')
    295             echo ' '.__('(auto toggle)');
    296         echo "</option>\n";
    297     }
    298     echo "        </select>\n";
     66if ( isset($_GET['deleted']) ) {
     67    echo '<div style="background-color: rgb(207, 235, 247);" id="message" class="updated fade"><p>';
     68    $deleted = (int) $_GET['deleted'];
     69    printf(__('%s bookmarks deleted.'), $deleted);
     70    echo '</p></div>';
     71}
    29972?>
    300         </td>
    301         <td>
    302           <select name="order_by">
    303             <option value="order_id"     <?php if ($order_by == 'order_id')     echo " selected='selected'";?>><?php _e('Link ID') ?></option>
    304             <option value="order_name"   <?php if ($order_by == 'order_name')   echo " selected='selected'";?>><?php _e('Name') ?></option>
    305             <option value="order_url"    <?php if ($order_by == 'order_url')    echo " selected='selected'";?>><?php _e('URI') ?></option>
    306             <option value="order_desc"   <?php if ($order_by == 'order_desc')   echo " selected='selected'";?>><?php _e('Description') ?></option>
    307             <option value="order_owner"  <?php if ($order_by == 'order_owner')  echo " selected='selected'";?>><?php _e('Owner') ?></option>
    308             <option value="order_rating" <?php if ($order_by == 'order_rating') echo " selected='selected'";?>><?php _e('Rating') ?></option>
    309           </select>
    310         </td>
    311         <td>
    312           <input type="submit" name="action" value="<?php _e('Show') ?>" />
    313         </td>
    314       </tr>
    315     </table>
    316     </form>
    31773
    318 </div>
    319 
    320 <form name="links" id="links" method="post" action="">
    32174<div class="wrap">
    32275
    323     <input type="hidden" name="link_id" value="" />
    324     <input type="hidden" name="action" value="" />
    325     <input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
    326     <input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
    327   <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
    328     <tr>
    329       <th width="15%"><?php _e('Name') ?></th>
    330       <th><?php _e('URI') ?></th>
    331       <th><?php _e('Category') ?></th>
    332       <th><?php _e('rel') ?></th>
    333       <th><?php _e('Image') ?></th>
    334       <th><?php _e('Visible') ?></th>
    335       <th colspan="2"><?php _e('Action') ?></th>
    336       <th>&nbsp;</th>
    337   </tr>
     76<h2><?php _e('Blogroll Management'); ?></h2>
     77<p><?php _e('Here you add links to sites that you visit often and share them on your blog. When you have a list of links in your sidebar to other blogs, it&#8217;s called a &#8220;blogroll.&#8221;'); ?></p>
     78<form id="cats" method="get" action="">
     79<p><?php
     80$categories = get_categories("hide_empty=1&type=link");
     81$select_cat = "<select name=\"cat_id\">\n";
     82$select_cat .= '<option value="all"'  . (($cat_id == 'all') ? " selected='selected'" : '') . '>' . __('All') . "</option>\n";
     83foreach ((array) $categories as $cat)
     84    $select_cat .= '<option value="' . $cat->cat_ID . '"' . (($cat->cat_ID == $cat_id) ? " selected='selected'" : '') . '>' . wp_specialchars($cat->cat_name) . "</option>\n";
     85$select_cat .= "</select>\n";
     86
     87$select_order = "<select name=\"order_by\">\n";
     88$select_order .= '<option value="order_id"' . (($order_by == 'order_id') ? " selected='selected'" : '') . '>' .  __('Bookmark ID') . "</option>\n";
     89$select_order .= '<option value="order_name"' . (($order_by == 'order_name') ? " selected='selected'" : '') . '>' .  __('Name') . "</option>\n";
     90$select_order .= '<option value="order_url"' . (($order_by == 'order_url') ? " selected='selected'" : '') . '>' .  __('Address') . "</option>\n";
     91$select_order .= "</select>\n";
     92
     93printf(__('Currently showing %1$s links ordered by %2$s'), $select_cat, $select_order);
     94?>
     95<input type="submit" name="action" value="<?php _e('Update &raquo;') ?>" /></p>
     96</form>
     97
     98<form id="links" method="post" action="link.php">
     99<?php wp_nonce_field('bulk-bookmarks') ?>
     100<input type="hidden" name="link_id" value="" />
     101<input type="hidden" name="action" value="" />
     102<input type="hidden" name="order_by" value="<?php echo wp_specialchars($order_by, 1); ?>" />
     103<input type="hidden" name="cat_id" value="<?php echo (int) $cat_id ?>" />
     104<table class="widefat">
     105    <thead>
     106    <tr>
     107        <th width="15%"><?php _e('Name') ?></th>
     108        <th><?php _e('URL') ?></th>
     109        <th><?php _e('Categories') ?></th>
     110        <th style="text-align: center"><?php _e('rel') ?></th>
     111        <th style="text-align: center"><?php _e('Visible') ?></th>
     112        <th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
     113        <th style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('links'));" /></th>
     114    </tr>
     115    </thead>
     116    <tbody id="the-list">
    338117<?php
    339     $sql = "SELECT link_url, link_name, link_image, link_description, link_visible,
    340             link_category AS cat_id, cat_name AS category, $wpdb->users.user_login, link_id,
    341             link_rating, link_rel
    342             FROM $wpdb->links
    343             LEFT JOIN $wpdb->linkcategories ON $wpdb->links.link_category = $wpdb->linkcategories.cat_id
    344             LEFT JOIN $wpdb->users ON $wpdb->users.ID = $wpdb->links.link_owner ";
     118if ( 'all' == $cat_id )
     119    $cat_id = '';
     120$links = get_bookmarks("category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0");
     121if ($links)
     122    foreach ($links as $link) {
     123        $link->link_name = wp_specialchars($link->link_name);
     124        $link->link_description = wp_specialchars($link->link_description);
     125        $link->link_url = wp_specialchars($link->link_url);
     126        $link->link_category = wp_get_link_cats($link->link_id);
     127        $short_url = str_replace('http://', '', $link->link_url);
     128        $short_url = str_replace('www.', '', $short_url);
     129        if ('/' == substr($short_url, -1))
     130            $short_url = substr($short_url, 0, -1);
     131        if (strlen($short_url) > 35)
     132            $short_url = substr($short_url, 0, 32).'...';
    345133
    346     if (isset($cat_id) && ($cat_id != 'All')) {
    347       $sql .= " WHERE link_category = $cat_id ";
    348     }
    349     $sql .= ' ORDER BY link_' . $sqlorderby;
     134        $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
     135        ++ $i;
     136        $style = ($i % 2) ? '' : ' class="alternate"';
     137?>
     138    <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>>
     139        <td><strong><?php echo $link->link_name; ?></strong><br />
     140        <?php
    350141
    351     // echo "$sql";
    352     $links = $wpdb->get_results($sql);
    353     if ($links) {
    354         foreach ($links as $link) {
    355             $link->link_name = wp_specialchars($link->link_name);
    356             $link->link_category = wp_specialchars($link->link_category);
    357             $link->link_description = wp_specialchars($link->link_description);
    358             $link->link_url = wp_specialchars($link->link_url);
    359             $short_url = str_replace('http://', '', $link->link_url);
    360             $short_url = str_replace('www.', '', $short_url);
    361             if ('/' == substr($short_url, -1))
    362                 $short_url = substr($short_url, 0, -1);
    363             if (strlen($short_url) > 35)
    364                 $short_url =  substr($short_url, 0, 32).'...';
    365142
    366             $image = ($link->link_image != null) ? __('Yes') : __('No');
    367             $visible = ($link->link_visible == 'Y') ? __('Yes') : __('No');
    368             ++$i;
    369             $style = ($i % 2) ? '' : ' class="alternate"';
     143        echo $link->link_description . "</td>";
     144        echo "<td><a href=\"$link->link_url\" title=\"".sprintf(__('Visit %s'), $link->link_name)."\">$short_url</a></td>";
     145        ?>
     146        <td>
     147        <?php
     148
     149        $cat_names = array();
     150        foreach ($link->link_category as $category) {
     151            $cat_name = get_the_category_by_ID($category);
     152            $cat_name = wp_specialchars($cat_name);
     153            if ( $cat_id != $category )
     154                $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>";
     155            $cat_names[] = $cat_name;
     156        }
     157        echo implode(', ', $cat_names);
     158        ?>
     159        </td>
     160        <td><?php echo $link->link_rel; ?></td>
     161        <td align='center'><?php echo $visible; ?></td>
     162<?php
     163
     164        echo '<td><a href="link.php?link_id='.$link->link_id.'&amp;action=edit" class="edit">'.__('Edit').'</a></td>';
     165        echo '<td><a href="' . wp_nonce_url('link.php?link_id='.$link->link_id.'&amp;action=delete', 'delete-bookmark_' . $link->link_id ) . '"'." onclick=\"return deleteSomething( 'link', $link->link_id , '".sprintf(__("You are about to delete the &quot;%s&quot; bookmark to %s.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($link->link_name), js_escape($link->link_url)).'\' );" class="delete">'.__('Delete').'</a></td>';
     166        echo '<td align="center"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></td>';
     167        echo "\n    </tr>\n";
     168    }
    370169?>
    371     <tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>>
    372         <td><strong><?php echo $link->link_name; ?></strong><br />
    373 <?php           
    374         echo sprintf(__('Description: %s'), $link->link_description) . "</td>";
    375         echo "<td><a href=\"$link->link_url\" title=\"" . sprintf(__('Visit %s'), $link->link_name) . "\">$short_url</a></td>";
    376         echo <<<LINKS
    377         <td>$link->category</td>
    378         <td>$link->link_rel</td>
    379         <td align='center'>$image</td>
    380         <td align='center'>$visible</td>
    381 LINKS;
    382             $show_buttons = 1; // default
    383 
    384             if ($show_buttons) {
    385         echo '<td><a href="link-manager.php?link_id=' . $link->link_id . '&amp;action=linkedit" class="edit">' . __('Edit') . '</a></td>';
    386         echo '<td><a href="link-manager.php?link_id=' . $link->link_id . '&amp;action=Delete"' .  " onclick=\"return deleteSomething( 'link', $link->link_id , '" . sprintf(__("You are about to delete the &quot;%s&quot; link to %s.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($link->link_name,1), wp_specialchars($link->link_url)) . '\' );" class="delete">' . __('Delete') . '</a></td>';
    387         echo '<td><input type="checkbox" name="linkcheck[]" value="' . $link->link_id . '" /></td>';
    388             } else {
    389               echo "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>\n";
    390             }
    391         echo "\n    </tr>\n";
    392         }
    393     }
    394 ?>
     170    </tbody>
    395171</table>
    396172
    397173<div id="ajax-response"></div>
    398174
     175<p class="submit"><input type="submit" class="button" name="deletebookmarks" id="deletebookmarks" value="<?php _e('Delete Checked Bookmarks') ?> &raquo;" onclick="return confirm('<?php _e("You are about to delete these bookmarks permanently \\n  \'Cancel\' to stop, \'OK\' to delete.") ?>')" /></p>
     176</form>
    399177</div>
    400178
    401 <div class="wrap">
    402   <table width="100%" cellpadding="3" cellspacing="3">
    403     <tr><th colspan="4"><?php _e('Manage Multiple Links:') ?></th></tr>
    404     <tr><td colspan="4"><?php _e('Use the checkboxes on the right to select multiple links and choose an action below:') ?></td></tr>
    405     <tr>
    406         <td>
    407           <?php _e('Assign ownership to:'); ?>
    408 <?php
    409     $results = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY ID");
    410     echo "          <select name=\"newowner\" size=\"1\">\n";
    411     foreach ($results as $row) {
    412       echo "            <option value=\"".$row->ID."\"";
    413       echo ">".$row->user_login;
    414       echo "</option>\n";
    415     }
    416     echo "          </select>\n";
    417 ?>
    418         <input name="assign" type="submit" id="assign" value="<?php _e('Go') ?>" />
    419         </td>
    420         <td>
    421           <input name="visibility" type="submit" id="visibility" value="<?php _e('Toggle Visibility') ?>" />
    422         </td>
    423         <td>
    424           <?php _e('Move to category:'); link_category_dropdown('category'); ?> <input name="move" type="submit" id="move" value="<?php _e('Go') ?>" />
    425         </td>
    426         <td align="right">
    427           <a href="#" onclick="checkAll(document.getElementById('links')); return false; "><?php _e('Toggle Checkboxes') ?></a>
    428         </td>
    429     </tr>
    430 </table>
    431 
    432 <?php
    433   } // end if !popup
    434 ?>
    435 </div>
    436 </form>
    437 
    438 
    439 <?php
    440     break;
    441   } // end default
    442 } // end case
    443 ?>
    444 
    445179<?php include('admin-footer.php'); ?>
  • trunk/wp-admin/menu-header.php

    r3503 r4431  
    1212    if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"';
    1313   
    14     if ( current_user_can($item[1]) ) {
    15         if ( file_exists(ABSPATH . "wp-content/plugins/{$item[2]}") )
    16             echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";         
     14    if ( !empty($submenu[$item[2]]) || current_user_can($item[1]) ) {
     15        if ( file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") )
     16            echo "\n\t<li><a href='" . get_option('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
    1717        else
    18             echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
     18            echo "\n\t<li><a href='" . get_option('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
    1919    }
    2020}
     
    4141$menu_hook = get_plugin_page_hook($item[2], $parent_file);
    4242
    43 if (file_exists(ABSPATH . "wp-content/plugins/{$item[2]}") || ! empty($menu_hook)) {
     43if (file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || ! empty($menu_hook)) {
    4444    if ( 'admin.php' == $pagenow )
    45         echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
     45        echo "\n\t<li><a href='" . get_option('siteurl') . "/wp-admin/admin.php?page={$item[2]}'$class>{$item[0]}</a></li>";
    4646    else
    47         echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$parent_file}?page={$item[2]}'$class>{$item[0]}</a></li>";
     47        echo "\n\t<li><a href='" . get_option('siteurl') . "/wp-admin/{$parent_file}?page={$item[2]}'$class>{$item[0]}</a></li>";
    4848 } else {
    49     echo "\n\t<li><a href='" . get_settings('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
     49    echo "\n\t<li><a href='" . get_option('siteurl') . "/wp-admin/{$item[2]}'$class>{$item[0]}</a></li>";
    5050 }
    5151endforeach;
     
    5353
    5454</ul>
    55 <?php endif; ?>
     55<?php
     56else :
     57?>
     58<div id="minisub"></div>
     59<?php
     60
     61endif;
     62
     63do_action('admin_notices');
     64
     65?>
  • trunk/wp-admin/menu.php

    r3503 r4431  
    66// The URL of the item's file
    77$menu[0] = array(__('Dashboard'), 'read', 'index.php');
    8 $menu[5] = array(__('Write'), 'edit_posts', 'post.php');
    9 $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php');
    10 $menu[20] = array(__('Links'), 'manage_links', 'link-manager.php');
     8
     9if ( strstr($_SERVER['REQUEST_URI'], 'edit-pages.php') )
     10    $menu[5] = array(__('Write'), 'edit_pages', 'page-new.php');
     11else
     12    $menu[5] = array(__('Write'), 'edit_posts', 'post-new.php');
     13if ( strstr($_SERVER['REQUEST_URI'], 'page-new.php') )
     14    $menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php');
     15else
     16    $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php');
     17
     18$menu[20] = array(__('Blogroll'), 'manage_links', 'link-manager.php');
    1119$menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php');
    1220$menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
    1321if ( current_user_can('edit_users') )
    14     $menu[35] = array(__('Users'), 'read', 'profile.php');
     22    $menu[35] = array(__('Users'), 'edit_users', 'users.php');
    1523else
    1624    $menu[35] = array(__('Profile'), 'read', 'profile.php');
    1725$menu[40] = array(__('Options'), 'manage_options', 'options-general.php');
    18 $menu[45] = array(__('Import'), 'import', 'import.php');
    1926
    20 $submenu['post.php'][5] = array(__('Write Post'), 'edit_posts', 'post.php');
    21 $submenu['post.php'][10] = array(__('Write Page'), 'edit_pages', 'page-new.php');
     27
     28$submenu['post-new.php'][5] = array(__('Write Post'), 'edit_posts', 'post-new.php');
     29$submenu['post-new.php'][10] = array(__('Write Page'), 'edit_pages', 'page-new.php');
    2230
    2331$submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php');
    2432$submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php');
     33$submenu['edit.php'][12] = array(__('Uploads'), 'upload_files', 'upload.php');
    2534$submenu['edit.php'][15] = array(__('Categories'), 'manage_categories', 'categories.php');
    2635$submenu['edit.php'][20] = array(__('Comments'), 'edit_posts', 'edit-comments.php');
    2736$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
    28 $submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), $awaiting_mod), 'edit_posts', 'moderation.php');
     37$submenu['edit.php'][25] = array(sprintf(__("Awaiting Moderation (%s)"), "<span id='awaitmod'>$awaiting_mod</span>"), 'edit_posts', 'moderation.php');
    2938$submenu['edit.php'][30] = array(__('Files'), 'edit_files', 'templates.php');
     39$submenu['edit.php'][35] = array(__('Import'), 'import', 'import.php');
     40$submenu['edit.php'][40] = array(__('Export'), 'import', 'export.php');
    3041
    31 $submenu['link-manager.php'][5] = array(__('Manage Links'), 'manage_links', 'link-manager.php');
     42$submenu['link-manager.php'][5] = array(__('Manage Blogroll'), 'manage_links', 'link-manager.php');
    3243$submenu['link-manager.php'][10] = array(__('Add Link'), 'manage_links', 'link-add.php');
    33 $submenu['link-manager.php'][15] = array(__('Link Categories'), 'manage_links', 'link-categories.php');
    3444$submenu['link-manager.php'][20] = array(__('Import Links'), 'manage_links', 'link-import.php');
    3545
    36 $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
    37 $submenu['profile.php'][10] = array(__('Authors &amp; Users'), 'edit_users', 'users.php');
     46if ( current_user_can('edit_users') ) {
     47    $_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php.
     48    $submenu['users.php'][5] = array(__('Authors &amp; Users'), 'edit_users', 'users.php');
     49    $submenu['users.php'][10] = array(__('Your Profile'), 'read', 'profile.php');
     50} else {
     51    $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php');
     52}
    3853
    3954$submenu['options-general.php'][10] = array(__('General'), 'manage_options', 'options-general.php');
     
    4156$submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php');
    4257$submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php');
    43 $submenu['options-general.php'][30] = array(__('Permalinks'), 'manage_options', 'options-permalink.php');
    44 $submenu['options-general.php'][35] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php');
     58$submenu['options-general.php'][30] = array(__('Privacy'), 'manage_options', 'options-privacy.php');
     59$submenu['options-general.php'][35] = array(__('Permalinks'), 'manage_options', 'options-permalink.php');
     60$submenu['options-general.php'][40] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php');
    4561
    4662$submenu['plugins.php'][5] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
     
    5571}
    5672
     73$_wp_submenu_nopriv = array();
     74$_wp_menu_nopriv = array();
     75// Loop over submenus and remove pages for which the user does not have privs.
     76foreach ($submenu as $parent => $sub) {
     77    foreach ($sub as $index => $data) {
     78        if ( ! current_user_can($data[1]) ) {
     79            unset($submenu[$parent][$index]);
     80            $_wp_submenu_nopriv[$parent][$data[2]] = true;
     81        }
     82    }
     83   
     84    if ( empty($submenu[$parent]) )
     85        unset($submenu[$parent]);
     86}
     87
     88// Loop over the top-level menu.
     89// Menus for which the original parent is not acessible due to lack of privs will have the next
     90// submenu in line be assigned as the new menu parent.
     91foreach ( $menu as $id => $data ) {
     92    if ( empty($submenu[$data[2]]) )
     93        continue;
     94    $subs = $submenu[$data[2]];
     95    $first_sub = array_shift($subs);
     96    $old_parent = $data[2];
     97    $new_parent = $first_sub[2];
     98    // If the first submenu is not the same as the assigned parent,
     99    // make the first submenu the new parent.
     100    if ( $new_parent != $old_parent ) {
     101        $_wp_real_parent_file[$old_parent] = $new_parent;
     102        $menu[$id][2] = $new_parent;
     103       
     104        foreach ($submenu[$old_parent] as $index => $data) {
     105            $submenu[$new_parent][$index] = $submenu[$old_parent][$index];
     106            unset($submenu[$old_parent][$index]);
     107        }
     108        unset($submenu[$old_parent]);
     109        $_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent];
     110    }
     111}
     112
    57113do_action('admin_menu', '');
    58 ksort($menu); // make it all pretty
     114
     115// Remove menus that have no accessible submenus and require privs that the user does not have.
     116// Run re-parent loop again.
     117foreach ( $menu as $id => $data ) {
     118    // If submenu is empty...
     119    if ( empty($submenu[$data[2]]) ) {
     120        // And user doesn't have privs, remove menu.
     121        if ( ! current_user_can($data[1]) ) {
     122            $_wp_menu_nopriv[$data[2]] = true;
     123            unset($menu[$id]);
     124        }
     125    }
     126}
     127
     128unset($id);
     129
     130uksort($menu, "strnatcasecmp"); // make it all pretty
    59131
    60132if (! user_can_access_admin_page()) {
    61     die( __('You do not have sufficient permissions to access this page.') );
     133    wp_die( __('You do not have sufficient permissions to access this page.') );
    62134}
    63135
  • trunk/wp-admin/moderation.php

    r3503 r4431  
    44$title = __('Moderate comments');
    55$parent_file = 'edit.php';
    6 $list_js = true;
    7 
    8 $wpvarstoreset = array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky');
    9 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    10     $wpvar = $wpvarstoreset[$i];
    11     if (!isset($$wpvar)) {
    12         if (empty($_POST["$wpvar"])) {
    13             if (empty($_GET["$wpvar"])) {
    14                 $$wpvar = '';
    15             } else {
    16                 $$wpvar = $_GET["$wpvar"];
    17             }
    18         } else {
    19             $$wpvar = $_POST["$wpvar"];
    20         }
    21     }
    22 }
     6wp_enqueue_script( 'admin-comments' );
     7
     8wp_reset_vars(array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky'));
    239
    2410$comment = array();
     
    3319case 'update':
    3420
    35     if ( ! current_user_can('moderate_comments') )
    36     die('<p>'.__('Your level is not high enough to moderate comments.').'</p>');
     21    check_admin_referer('moderate-comments');
     22
     23    if ( !current_user_can('moderate_comments') )
     24        wp_die(__('Your level is not high enough to moderate comments.'));
    3725
    3826    $item_ignored = 0;
     
    6048            case 'approve':
    6149                wp_set_comment_status($key, 'approve');
    62                 if ( get_settings('comments_notify') == true ) {
     50                if ( get_option('comments_notify') == true ) {
    6351                    wp_notify_postauthor($key);
    6452                }
     
    6957
    7058    $file = basename(__FILE__);
    71     header("Location: $file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved&spam=$item_spam");
     59    wp_redirect("$file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved&spam=$item_spam");
    7260    exit();
    7361
     
    116104
    117105?>
    118    
     106
    119107<div class="wrap">
    120108
     
    131119    <h2><?php _e('Moderation Queue') ?></h2>
    132120    <form name="approval" action="moderation.php" method="post">
     121    <?php wp_nonce_field('moderate-comments') ?>
    133122    <input type="hidden" name="action" value="update" />
    134     <ol id="the-list" class="commentlist">
     123    <ol id="the-comment-list" class="commentlist">
    135124<?php
    136125$i = 0;
    137126    foreach($comments as $comment) {
    138127    ++$i;
    139     $comment_date = mysql2date(get_settings("date_format") . " @ " . get_settings("time_format"), $comment->comment_date);
     128    $comment_date = mysql2date(get_option("date_format") . " @ " . get_option("time_format"), $comment->comment_date);
    140129    $post_title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID='$comment->comment_post_ID'");
    141     if ($i % 2) $class = 'class="alternate"';
    142     else $class = '';
    143     echo "\n\t<li id='comment-$comment->comment_ID' $class>";
     130    if ($i % 2) $class = 'js-unapproved alternate';
     131    else $class = 'js-unapproved';
     132    echo "\n\t<li id='comment-$comment->comment_ID' class='$class'>";
    144133    ?>
    145     <p><strong><?php _e('Name:') ?></strong> <?php comment_author_link() ?> <?php if ($comment->comment_author_email) { ?>| <strong><?php _e('E-mail:') ?></strong> <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <strong><?php _e('URI:') ?></strong> <?php comment_author_url_link() ?> <?php } ?>| <strong><?php _e('IP:') ?></strong> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a> | <strong><?php _e('Date:') ?></strong> <?php comment_date(); ?></p>
     134    <p><strong><?php comment_author() ?></strong> <?php if ($comment->comment_author_email) { ?>| <?php comment_author_email_link() ?> <?php } if ($comment->comment_author_url && 'http://' != $comment->comment_author_url) { ?> | <?php comment_author_url_link() ?> <?php } ?>| <?php _e('IP:') ?> <a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></p>
    146135<?php comment_text() ?>
    147 <p><?php
    148 echo '<a href="post.php?action=editcomment&amp;comment='.$comment->comment_ID.'">' . __('Edit') . '</a> | ';?>
    149 <a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php _e('View Post') ?></a> |
    150 <?php
    151 echo " <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), wp_specialchars($comment->comment_author, 1)) . "' );\">" . __('Delete just this comment') . "</a> | "; ?>  <?php _e('Bulk action:') ?>
    152     <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-approve" value="approve" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-approve"><?php _e('Approve') ?></label>
    153     <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-spam" value="spam" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-spam"><?php _e('Spam') ?></label>
    154     <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-delete" value="delete" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-delete"><?php _e('Delete') ?></label>
    155     <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-nothing" value="later" checked="checked" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-nothing"><?php _e('Defer until later') ?></label>
     136<p><?php comment_date('M j, g:i A'); ?> &#8212; [ <?php
     137echo '<a href="comment.php?action=editcomment&amp;comment='.$comment->comment_ID.'">' . __('Edit') . '</a> | ';
     138echo " <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by &quot;%s&quot;.\\n&quot;Cancel&quot; to stop, &quot;OK&quot; to delete."), js_escape($comment->comment_author)) . "', theCommentList );\">" . __('Delete ') . "</a> | "; ?>
     139<?php
     140$post = get_post($comment->comment_post_ID);
     141$post_title = wp_specialchars( $post->post_title, 'double' );
     142$post_title = ('' == $post_title) ? "# $comment->comment_post_ID" : $post_title;
     143?>
     144<a href="<?php echo get_permalink($comment->comment_post_ID); ?>" title="<?php echo $post_title; ?>"><?php _e('View Post') ?></a> ] &#8212;
     145 <?php _e('Bulk action:') ?>
     146    <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-approve" value="approve" /> <label for="comment-<?php echo $comment->comment_ID; ?>-approve"><?php _e('Approve') ?></label> &nbsp;
     147    <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-spam" value="spam" /> <label for="comment-<?php echo $comment->comment_ID; ?>-spam"><?php _e('Spam') ?></label> &nbsp;
     148    <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-delete" value="delete" /> <label for="comment-<?php echo $comment->comment_ID; ?>-delete"><?php _e('Delete') ?></label> &nbsp;
     149    <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment-<?php echo $comment->comment_ID; ?>-nothing" value="later" checked="checked" /> <label for="comment-<?php echo $comment->comment_ID; ?>-nothing"><?php _e('Defer until later') ?></label>
    156150    </p>
    157151
     
    164158<div id="ajax-response"></div>
    165159
    166     <p class="submit"><input type="submit" name="submit" value="<?php _e('Moderate Comments &raquo;') ?>" /></p>
     160    <p class="submit"><input type="submit" name="submit" value="<?php _e('Bulk Moderate Comments &raquo;') ?>" /></p>
    167161<script type="text/javascript">
    168162// <![CDATA[
     
    220214
    221215
    222 include('admin-footer.php') ?>
     216include('admin-footer.php');
     217
     218?>
  • trunk/wp-admin/options-discussion.php

    r3503 r4431  
    66
    77include('admin-header.php');
    8 
    9 if ($action == 'retrospam') {
    10     if ( $_GET['move'] == 'true' ) {
    11         retrospam_mgr::move_spam( $_GET[ids] );
    12     }
    13     $retrospaminator = new retrospam_mgr();
    14     $result = $retrospaminator->find_spam();
    15     echo $retrospaminator->display_edit_form( $result );
    16     include('./admin-footer.php');
    17     exit;
    18 }
    198?>
    209
     
    2211<h2><?php _e('Discussion Options') ?></h2>
    2312<form method="post" action="options.php">
     13<?php wp_nonce_field('update-options') ?>
     14<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" /></p>
    2415<fieldset class="options">
    2516<legend><?php _e('Usual settings for an article:<br /><small><em>(These settings may be overridden for individual articles.)</em></small>') ?></legend>
     
    2718<li>
    2819<label for="default_pingback_flag">
    29 <input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php checked('1', get_settings('default_pingback_flag')); ?> />
     20<input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php checked('1', get_option('default_pingback_flag')); ?> />
    3021<?php _e('Attempt to notify any Weblogs linked to from the article (slows down posting.)') ?></label>
    3122</li>
    3223<li>
    3324<label for="default_ping_status">
    34 <input name="default_ping_status" type="checkbox" id="default_ping_status" value="open" <?php checked('open', get_settings('default_ping_status')); ?> />
     25<input name="default_ping_status" type="checkbox" id="default_ping_status" value="open" <?php checked('open', get_option('default_ping_status')); ?> />
    3526<?php _e('Allow link notifications from other Weblogs (pingbacks and trackbacks.)') ?></label>
    3627</li>
    3728<li>
    3829<label for="default_comment_status">
    39 <input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_settings('default_comment_status')); ?> />
     30<input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> />
    4031<?php _e('Allow people to post comments on the article') ?></label>
    4132</li>
     
    4738<li>
    4839<label for="comments_notify">
    49 <input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_settings('comments_notify')); ?> />
     40<input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_option('comments_notify')); ?> />
    5041<?php _e('Anyone posts a comment') ?> </label>
    5142</li>
    5243<li>
    5344<label for="moderation_notify">
    54 <input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked('1', get_settings('moderation_notify')); ?> />
     45<input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked('1', get_option('moderation_notify')); ?> />
    5546<?php _e('A comment is held for moderation') ?> </label>
    5647</li>
     
    6253<li>
    6354<label for="comment_moderation">
    64 <input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_settings('comment_moderation')); ?> />
    65 <?php _e('An administrator must approve the comment (regardless of any matches below)') ?> </label>
     55<input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked('1', get_option('comment_moderation')); ?> />
     56<?php _e('An administrator must always approve the comment') ?> </label>
    6657</li>
    67 <li><label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_settings('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail') ?></label></li>
    68 <li><label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_settings('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment') ?></label></li>
     58<li><label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_option('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail') ?></label></li>
     59<li><label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked('1', get_option('comment_whitelist')); ?> /> <?php _e('Comment author must have a previously approved comment') ?></label></li>
    6960</ul>
    7061</fieldset>
    7162<fieldset class="options">
    7263<legend><?php _e('Comment Moderation') ?></legend>
    73 <p><?php printf(__('Hold a comment in the queue if it contains more than %s links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="text" id="comment_max_links" size="3" value="' . get_settings('comment_max_links'). '" />' ) ?></p>
     64<p><?php printf(__('Hold a comment in the queue if it contains %s or more links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="text" id="comment_max_links" size="3" value="' . get_option('comment_max_links'). '" />' ) ?></p>
    7465
    75 <p><?php _e('When a comment contains any of these words in its content, name, URI, e-mail, or IP, hold it in the moderation queue: (Separate multiple words with new lines.) <a href="http://codex.wordpress.org/Spam_Words">Common spam words</a>.') ?></p>
     66<p><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be held in the <a href="moderation.php">moderation queue</a>. One word or IP per line. It will match inside words, so "press" will match "WordPress".') ?></p>
    7667<p>
    7768<textarea name="moderation_keys" cols="60" rows="4" id="moderation_keys" style="width: 98%; font-size: 12px;" class="code"><?php form_option('moderation_keys'); ?></textarea>
    78 </p>
    79 <p>
    80 <a id="retrospambutton" href="options-discussion.php?action=retrospam"><?php _e('Check past comments against moderation list'); ?></a>
    8169</p>
    8270</fieldset>
    8371<fieldset class="options">
    8472<legend><?php _e('Comment Blacklist') ?></legend>
    85 <p><?php _e('This is a list of words that you want completely blacklisted from your blog. Be very careful what you add here, because if a comment matches something here it will be completely nuked and there will be no notification. Remember that partial words can match, so if there is any chance something here might match it would be better to put it in the moderation box above.') ?></p>
     73<p><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be deleted. One word or IP per line. It will match inside words, so "press" will match "WordPress".') ?></p>
    8674<p>
    8775<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>
    8876</p>
    89 <p><label for="open_proxy_check">
    90 <input name="open_proxy_check" type="checkbox" id="open_proxy_check" value="1" <?php checked('1', get_settings('open_proxy_check')); ?> />
    91 <?php _e('Blacklist comments from open and insecure proxies.') ?></label></p>
    9277</fieldset>
    9378<p class="submit">
    9479<input type="hidden" name="action" value="update" />
    95 <input type="hidden" name="page_options" value="default_pingback_flag,default_ping_status,default_comment_status,comments_notify,moderation_notify,comment_moderation,require_name_email,comment_whitelist,comment_max_links,moderation_keys,blacklist_keys,open_proxy_check" />
    96 <input type="submit" name="Submit" value="<?php _e('Update Options') ?>" />
    97 </p> 
    98 </form> 
     80<input type="hidden" name="page_options" value="default_pingback_flag,default_ping_status,default_comment_status,comments_notify,moderation_notify,comment_moderation,require_name_email,comment_whitelist,comment_max_links,moderation_keys,blacklist_keys" />
     81<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
     82</p>
     83</form>
    9984</div>
     85
    10086<?php include('./admin-footer.php'); ?>
  • trunk/wp-admin/options-general.php

    r3503 r4431  
    1111<h2><?php _e('General Options') ?></h2>
    1212<form method="post" action="options.php">
     13<?php wp_nonce_field('update-options') ?>
     14<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" /></p>
    1315<table class="optiontable">
    1416<tr valign="top">
     
    2325</tr>
    2426<tr valign="top">
    25 <th scope="row"><?php _e('WordPress address (URI):') ?></th>
     27<th scope="row"><?php _e('WordPress address (URL):') ?></th>
    2628<td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>" size="40" class="code" /></td>
    2729</tr>
    2830<tr valign="top">
    29 <th scope="row"><?php _e('Blog address (URI):') ?></th>
     31<th scope="row"><?php _e('Blog address (URL):') ?></th>
    3032<td><input name="home" type="text" id="home" value="<?php form_option('home'); ?>" size="40" class="code" /><br /><?php _e('If you want your blog homepage <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">to be different than the directory</a> you installed WordPress in, enter that address here.'); ?></td>
    3133</tr>
     
    3941<th scope="row"><?php _e('Membership:') ?></th>
    4042<td> <label for="users_can_register">
    41 <input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked('1', get_settings('users_can_register')); ?> />
     43<input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked('1', get_option('users_can_register')); ?> />
    4244<?php _e('Anyone can register') ?></label><br />
    4345<label for="comment_registration">
    44 <input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_settings('comment_registration')); ?> />
     46<input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_option('comment_registration')); ?> />
    4547<?php _e('Users must be registered and logged in to comment') ?>
    4648</label>
     
    5052<th scope="row"><?php _e('New User Default Role:') ?></th>
    5153<td><label for="default_role">
    52 <select name="default_role" id="default_role"><?php
    53 foreach($wp_roles->role_names as $role => $name) {
    54     $selected = (get_settings('default_role') == $role) ? 'selected="selected"' : '';
    55     echo "<option {$selected} value=\"{$role}\">{$name}</option>";
    56 }
    57 ?></select></label>
     54<select name="default_role" id="default_role"><?php wp_dropdown_roles( get_option('default_role') ); ?></select></label>
    5855</td>
    5956</tr>
     
    6966<th scope="row"><?php _e('Times in the weblog should differ by:') ?> </th>
    7067<td><input name="gmt_offset" type="text" id="gmt_offset" size="2" value="<?php form_option('gmt_offset'); ?>" />
    71 <?php _e('hours') ?> </td>
     68<?php _e('hours') ?> (<?php _e('Your timezone offset, for example <code>-6</code> for Central Time.'); ?>)</td>
    7269</tr>
    7370<tr>
    7471<th scope="row"><?php _e('Default date format:') ?></th>
    7572<td><input name="date_format" type="text" id="date_format" size="30" value="<?php form_option('date_format'); ?>" /><br />
    76 <?php _e('Output:') ?> <strong><?php echo mysql2date(get_settings('date_format'), current_time('mysql')); ?></strong></td>
     73<?php _e('Output:') ?> <strong><?php echo mysql2date(get_option('date_format'), current_time('mysql')); ?></strong></td>
    7774</tr>
    7875<tr>
    7976<th scope="row"><?php _e('Default time format:') ?></th>
    8077<td><input name="time_format" type="text" id="time_format" size="30" value="<?php form_option('time_format'); ?>" /><br />
    81 <?php _e('Output:') ?> <strong><?php echo gmdate(get_settings('time_format'), current_time('timestamp')); ?></strong></td>
     78<?php _e('Output:') ?> <strong><?php echo gmdate(get_option('time_format'), current_time('timestamp')); ?></strong></td>
    8279</tr>
    8380<tr>
    8481<th scope="row">&nbsp;</th>
    85 <td><?php _e('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Save option to update sample output.') ?> </td>
     82<td><?php _e('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click "Update options" to update sample output.') ?> </td>
    8683</tr>
    8784<tr>
     
    9087<?php
    9188for ($day_index = 0; $day_index <= 6; $day_index++) :
    92 if ($day_index == get_settings('start_of_week')) $selected = " selected='selected'";
    93 else $selected = '';
    94 echo "\n\t<option value='$day_index' $selected>$weekday[$day_index]</option>";
     89    $selected = (get_option('start_of_week') == $day_index) ? 'selected="selected"' : '';
     90    echo "\n\t<option value='$day_index' $selected>" . $wp_locale->get_weekday($day_index) . '</option>';
    9591endfor;
    9692?>
     
    10096</fieldset>
    10197
    102 <p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
     98<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
    10399<input type="hidden" name="action" value="update" />
    104100<input type="hidden" name="page_options" value="blogname,blogdescription,siteurl,admin_email,users_can_register,gmt_offset,date_format,time_format,home,start_of_week,comment_registration,default_role" />
  • trunk/wp-admin/options-head.php

    r3503 r4431  
    1 <?php
    2 
    3 $wpvarstoreset = array('action','standalone', 'option_group_id');
    4 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    5     $wpvar = $wpvarstoreset[$i];
    6     if (!isset($$wpvar)) {
    7         if (empty($_POST["$wpvar"])) {
    8             if (empty($_GET["$wpvar"])) {
    9                 $$wpvar = '';
    10             } else {
    11                 $$wpvar = $_GET["$wpvar"];
    12             }
    13         } else {
    14             $$wpvar = $_POST["$wpvar"];
    15         }
    16     }
    17 }
    18 ?>
     1<?php wp_reset_vars(array('action', 'standalone', 'option_group_id')); ?>
    192
    203<br clear="all" />
  • trunk/wp-admin/options-misc.php

    r3503 r4431  
    1212<h2><?php _e('Miscellaneous Options') ?></h2>
    1313<form method="post" action="options.php">
    14 
     14<?php wp_nonce_field('update-options') ?>
     15<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" /></p>
    1516<fieldset class="options">
    1617<legend><?php _e('Uploading'); ?></legend>
     
    1819<tr valign="top">
    1920<th scope="row"><?php _e('Store uploads in this folder'); ?>:</th>
    20 <td><input name="upload_path" type="text" id="upload_path" class="code" value="<?php echo str_replace(ABSPATH, '', get_settings('upload_path')); ?>" size="40" />
     21<td><input name="upload_path" type="text" id="upload_path" class="code" value="<?php echo wp_specialchars(str_replace(ABSPATH, '', get_option('upload_path')), 1); ?>" size="40" />
    2122<br />
    2223<?php _e('Default is <code>wp-content/uploads</code>'); ?>
     
    2728<td>
    2829<label for="uploads_use_yearmonth_folders">
    29 <input name="uploads_use_yearmonth_folders" type="checkbox" id="uploads_use_yearmonth_folders" value="1" <?php checked('1', get_settings('uploads_use_yearmonth_folders')); ?> />
     30<input name="uploads_use_yearmonth_folders" type="checkbox" id="uploads_use_yearmonth_folders" value="1" <?php checked('1', get_option('uploads_use_yearmonth_folders')); ?> />
    3031<?php _e('Organize my uploads into month- and year-based folders'); ?>
    3132</label>
     
    3536</fieldset>
    3637
    37 <p><input name="use_linksupdate" type="checkbox" id="use_linksupdate" value="1" <?php checked('1', get_settings('use_linksupdate')); ?> />
    38 <label for="use_linksupdate"><?php _e('Track Links&#8217; Update Times') ?></label></p>
     38<p><input name="use_linksupdate" type="checkbox" id="use_linksupdate" value="1" <?php checked('1', get_option('use_linksupdate')); ?> />
     39<label for="use_linksupdate"><?php _e('Track Bookmarks&#8217; Update Times') ?></label></p>
    3940<p>
    40 <label><input type="checkbox" name="hack_file" value="1" <?php checked('1', get_settings('hack_file')); ?> /> <?php _e('Use legacy <code>my-hacks.php</code> file support') ?></label>
     41<label><input type="checkbox" name="hack_file" value="1" <?php checked('1', get_option('hack_file')); ?> /> <?php _e('Use legacy <code>my-hacks.php</code> file support') ?></label>
    4142</p>
    4243
     
    4445<input type="hidden" name="action" value="update" />
    4546<input type="hidden" name="page_options" value="hack_file,use_linksupdate,uploads_use_yearmonth_folders,upload_path" />
    46 <input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
     47<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
    4748</p>
    4849</form>
  • trunk/wp-admin/options-permalink.php

    r3503 r4431  
    4242var aInputs = document.getElementsByTagName('input');
    4343
    44 for (var i = 0; i < aInputs.length; i++) {     
     44for (var i = 0; i < aInputs.length; i++) {
    4545aInputs[i].onclick = aInputs[i].onkeyup = upit;
    4646}
     
    5858$home_path = get_home_path();
    5959
    60 if ( isset($_POST) ) {
     60if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
     61    check_admin_referer('update-permalink');
     62
    6163    if ( isset($_POST['permalink_structure']) ) {
    6264        $permalink_structure = $_POST['permalink_structure'];
     
    6567        $wp_rewrite->set_permalink_structure($permalink_structure);
    6668    }
    67    
     69
    6870    if ( isset($_POST['category_base']) ) {
    6971        $category_base = $_POST['category_base'];
     
    7375    }
    7476}
    75    
    76 $permalink_structure = get_settings('permalink_structure');
    77 $category_base = get_settings('category_base');
     77
     78$permalink_structure = get_option('permalink_structure');
     79$category_base = get_option('category_base');
    7880
    7981if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') )
     
    101103<div class="wrap">
    102104  <h2><?php _e('Customize Permalink Structure') ?></h2>
    103   <p><?php _e('By default WordPress uses web URIs which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URI structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="http://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p>
     105<form name="form" action="options-permalink.php" method="post">
     106<?php wp_nonce_field('update-permalink') ?>
     107<p class="submit"><input type="submit" name="submit" value="<?php _e('Update Permalink Structure &raquo;') ?>" /></p>
     108  <p><?php _e('By default WordPress uses web <abbr title="Universal Resource Locator">URL</abbr>s which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="http://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p>
    104109
    105110<?php
     
    115120    );
    116121?>
    117 <form name="form" action="options-permalink.php" method="post">
    118122<h3><?php _e('Common options:'); ?></h3>
    119123<p>
    120124    <label>
    121125<input name="selection" type="radio" value="" class="tog" <?php checked('', $permalink_structure); ?> />
    122 <?php _e('Default'); ?><br /> <span> &raquo; <code><?php echo get_settings('home'); ?>/?p=123</code></span>
     126<?php _e('Default'); ?><br /> <span> &raquo; <code><?php echo get_option('home'); ?>/?p=123</code></span>
    123127   </label>
    124128</p>
     
    126130    <label>
    127131<input name="selection" type="radio" value="<?php echo $structures[1]; ?>" class="tog" <?php checked($structures[1], $permalink_structure); ?> />
    128 <?php _e('Date and name based'); ?><br /> <span> &raquo; <code><?php echo get_settings('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></span>
     132<?php _e('Date and name based'); ?><br /> <span> &raquo; <code><?php echo get_option('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></span>
    129133   </label>
    130134</p>
     
    132136    <label>
    133137<input name="selection" type="radio" value="<?php echo $structures[2]; ?>" class="tog" <?php checked($structures[2], $permalink_structure); ?> />
    134 <?php _e('Numeric'); ?><br /> <span> &raquo; <code><?php echo get_settings('home') . $prefix  ; ?>/archives/123</code></span>
     138<?php _e('Numeric'); ?><br /> <span> &raquo; <code><?php echo get_option('home') . $prefix  ; ?>/archives/123</code></span>
    135139   </label>
    136140</p>
     
    142146<?php } ?>
    143147 />
    144 <?php _e('Custom, specify below'); ?>   
     148<?php _e('Custom, specify below'); ?>
    145149</label>
    146150<br />
    147151</p>
    148 <p id="customstructure"><?php _e('Custom structure'); ?>: <input name="permalink_structure" id="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo $permalink_structure; ?>" size="50" /></p>
     152<p id="customstructure"><?php _e('Custom structure'); ?>: <input name="permalink_structure" id="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo wp_specialchars($permalink_structure, 1); ?>" size="50" /></p>
    149153
    150154<h3><?php _e('Optional'); ?></h3>
    151155<?php if ($is_apache) : ?>
    152     <p><?php _e('If you like, you may enter a custom prefix for your category URIs here. For example, <code>/taxonomy/tags</code> would make your category links like <code>http://example.org/taxonomy/tags/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
     156    <p><?php _e('If you like, you may enter a custom prefix for your category <abbr title="Universal Resource Locator">URL</abbr>s here. For example, <code>/taxonomy/tags</code> would make your category links like <code>http://example.org/taxonomy/tags/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
    153157<?php else : ?>
    154     <p><?php _e('If you like, you may enter a custom prefix for your category URIs here. For example, <code>/index.php/taxonomy/tags</code> would make your category links like <code>http://example.org/index.php/taxonomy/tags/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
     158    <p><?php _e('If you like, you may enter a custom prefix for your category <abbr title="Universal Resource Locator">URL</abbr>s here. For example, <code>/index.php/taxonomy/tags</code> would make your category links like <code>http://example.org/index.php/taxonomy/tags/uncategorized/</code>. If you leave this blank the default will be used.') ?></p>
    155159<?php endif; ?>
    156160    <p>
    157   <?php _e('Category base'); ?>: <input name="category_base" type="text" class="code"  value="<?php echo $category_base; ?>" size="30" />
     161  <?php _e('Category base'); ?>: <input name="category_base" type="text" class="code"  value="<?php echo wp_specialchars($category_base, 1); ?>" size="30" />
    158162     </p>
    159163    <p class="submit">
     
    164168  <p><?php _e('If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Make_a_Directory_Writable">writable</a>, we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p>
    165169<form action="options-permalink.php" method="post">
     170<?php wp_nonce_field('update-permalink') ?>
    166171   <p>
    167172<textarea rows="5" style="width: 98%;" name="rules"><?php echo $wp_rewrite->mod_rewrite_rules(); ?>
  • trunk/wp-admin/options-reading.php

    r3503 r4431  
    1010<div class="wrap">
    1111<h2><?php _e('Reading Options') ?></h2>
    12 <form name="form1" method="post" action="options.php">
     12<form name="form1" method="post" action="options.php">
     13<?php wp_nonce_field('update-options') ?>
     14<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" /></p>
     15<?php if ( get_pages() ): ?>
     16<fieldset class="options">
     17<legend><?php _e('Front Page') ?></legend>
     18<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
     19<tr valign="top">
     20<th width="33%" scope="row"><?php _e('Front page displays:')?></th>
     21<td>
     22    <p><label>
     23        <input name="show_on_front" type="radio" value="posts" class="tog" <?php checked('posts', get_option('show_on_front')); ?> />
     24        <?php _e('Your latest posts'); ?>
     25    </label>
     26    </p>
     27    <p><label>
     28        <input name="show_on_front" type="radio" value="page" class="tog" <?php checked('page', get_option('show_on_front')); ?> />
     29        <?php printf(__('A <a href="%s">static page</a> (select below)'), 'edit-pages.php'); ?>
     30    </label>
     31    </p>
     32<ul>
     33    <li><?php printf(__('Front page: %s'), wp_dropdown_pages("name=page_on_front&echo=0&show_option_none=".__('- Select -')."&selected=" . get_option('page_on_front'))); ?></li>
     34    <li><?php printf(__('Posts page: %s'), wp_dropdown_pages("name=page_for_posts&echo=0&show_option_none=".__('- Select -')."&selected=" . get_option('page_for_posts'))); ?></li>
     35</ul>
     36<?php if ( 'page' == get_option('show_on_front') && get_option('page_for_posts') == get_option('page_on_front') ) : ?>
     37<div id="front-page-warning" class="updated fade-ff0000">
     38    <p>
     39        <?php _e('<strong>Warning:</strong> these pages should not be the same!'); ?>
     40    </p>
     41</div>
     42<?php endif; ?>
     43</fieldset>
     44</td>
     45</tr>
     46</table>
     47</fieldset>
     48<?php endif; ?>
     49
    1350<fieldset class="options">
    1451<legend><?php _e('Blog Pages') ?></legend>
    15 <table width="100%" cellspacing="2" cellpadding="5" class="editform">
     52<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
    1653<tr valign="top">
    1754<th width="33%" scope="row"><?php _e('Show at most:') ?></th>
     
    1956<input name="posts_per_page" type="text" id="posts_per_page" value="<?php form_option('posts_per_page'); ?>" size="3" />
    2057<select name="what_to_show" id="what_to_show" >
    21 <option value="days" <?php selected('days', get_settings('what_to_show')); ?>><?php _e('days') ?></option>
    22 <option value="posts" <?php selected('posts', get_settings('what_to_show')); ?>><?php _e('posts') ?></option>
     58<option value="days" <?php selected('days', get_option('what_to_show')); ?>><?php _e('days') ?></option>
     59<option value="posts" <?php selected('posts', get_option('what_to_show')); ?>><?php _e('posts') ?></option>
    2360</select>
    2461</td>
     
    2966<fieldset class="options">
    3067<legend><?php _e('Syndication Feeds') ?></legend>
    31 <table width="100%" cellspacing="2" cellpadding="5" class="editform">
     68<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
    3269<tr valign="top">
    3370<th width="33%" scope="row"><?php _e('Show the most recent:') ?></th>
     
    3774<th scope="row"><?php _e('For each article, show:') ?> </th>
    3875<td>
    39 <label><input name="rss_use_excerpt"  type="radio" value="0" <?php checked(0, get_settings('rss_use_excerpt')); ?>  /> <?php _e('Full text') ?></label><br />
    40 <label><input name="rss_use_excerpt" type="radio" value="1" <?php checked(1, get_settings('rss_use_excerpt')); ?> /> <?php _e('Summary') ?></label>
     76<p><label><input name="rss_use_excerpt"  type="radio" value="0" <?php checked(0, get_option('rss_use_excerpt')); ?> /> <?php _e('Full text') ?></label><br />
     77<label><input name="rss_use_excerpt" type="radio" value="1" <?php checked(1, get_option('rss_use_excerpt')); ?> /> <?php _e('Summary') ?></label></p>
     78<p><?php _e('Note: If you use the <code>&lt;--more--&gt;</code> feature, it will cut off posts in RSS feeds.'); ?></p>
    4179</td>
    4280</tr>
    4381</table>
    4482</fieldset>
    45 <table width="100%" cellspacing="2" cellpadding="5" class="editform">
     83<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
    4684<tr valign="top">
    4785<th width="33%" scope="row"><?php _e('Encoding for pages and feeds:') ?></th>
     
    5189</table>
    5290<p>
    53 <label><input type="checkbox" name="gzipcompression" value="1" <?php checked('1', get_settings('gzipcompression')); ?> />
     91<label><input type="checkbox" name="gzipcompression" value="1" <?php checked('1', get_option('gzipcompression')); ?> />
    5492<?php _e('WordPress should compress articles (gzip) if browsers ask for them') ?></label>
    5593</p>
    5694<p class="submit">
    5795<input type="hidden" name="action" value="update" />
    58 <input type="hidden" name="page_options" value="posts_per_page,what_to_show,posts_per_rss,rss_use_excerpt,blog_charset,gzipcompression" />
    59 <input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
     96<input type="hidden" name="page_options" value="posts_per_page,what_to_show,posts_per_rss,rss_use_excerpt,blog_charset,gzipcompression,show_on_front,page_on_front,page_for_posts" />
     97<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
    6098</p>
    6199</form>
  • trunk/wp-admin/options-writing.php

    r3503 r4431  
    1111<h2><?php _e('Writing Options') ?></h2>
    1212<form method="post" action="options.php">
    13 <table width="100%" cellspacing="2" cellpadding="5" class="editform">
     13<?php wp_nonce_field('update-options') ?>
     14<p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" /></p>
     15<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
    1416<tr valign="top">
    1517<th width="33%" scope="row"> <?php _e('Size of the post box:') ?></th>
     
    2123<td>
    2224<label for="rich_editing">
    23 <input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', get_settings('rich_editing')); ?> />
     25<input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', get_option('rich_editing')); ?> />
    2426<?php _e('Users should use the visual rich editor by default') ?></label><br />
    2527<label for="use_smilies">
    26 <input name="use_smilies" type="checkbox" id="use_smilies" value="1" <?php checked('1', get_settings('use_smilies')); ?> />
     28<input name="use_smilies" type="checkbox" id="use_smilies" value="1" <?php checked('1', get_option('use_smilies')); ?> />
    2729<?php _e('Convert emoticons like <code>:-)</code> and <code>:-P</code> to graphics on display') ?></label><br />
    28 <label for="use_balanceTags"><input name="use_balanceTags" type="checkbox" id="use_balanceTags" value="1" <?php checked('1', get_settings('use_balanceTags')); ?> /> <?php _e('WordPress should correct invalidly nested XHTML automatically') ?></label>
     30<label for="use_balanceTags"><input name="use_balanceTags" type="checkbox" id="use_balanceTags" value="1" <?php checked('1', get_option('use_balanceTags')); ?> /> <?php _e('WordPress should correct invalidly nested XHTML automatically') ?></label>
    2931</td>
    3032</tr>
     
    3537$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");
    3638foreach ($categories as $category) :
    37 if ($category->cat_ID == get_settings('default_category')) $selected = " selected='selected'";
     39if ($category->cat_ID == get_option('default_category')) $selected = " selected='selected'";
     40else $selected = '';
     41echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
     42endforeach;
     43?>
     44</select></td>
     45</tr>
     46<tr valign="top">
     47<th scope="row"><?php _e('Default bookmark category:') ?></th>
     48<td><select name="default_link_category" id="default_link_category">
     49<?php
     50foreach ($categories as $category) :
     51if ($category->cat_ID == get_option('default_link_category')) $selected = " selected='selected'";
    3852else $selected = '';
    3953echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
     
    4559
    4660<fieldset class="options">
    47 <legend><?php _e('Writing by e-mail') ?></legend>
     61<legend><?php _e('Post via e-mail') ?></legend>
    4862<p><?php printf(__('To post to WordPress by e-mail you must set up a secret e-mail account with POP3 access. Any mail received at this address will be posted, so it&#8217;s a good idea to keep this address very secret. Here are three random strings you could use: <code>%s</code>, <code>%s</code>, <code>%s</code>.'), substr(md5(uniqid(microtime())),0,5), substr(md5(uniqid(microtime())),0,5), substr(md5(uniqid(microtime())),0,5)) ?></p>
    4963
    50 <table width="100%" cellspacing="2" cellpadding="5" class="editform">
     64<table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform">
    5165<tr valign="top">
    5266<th scope="row"><?php _e('Mail server:') ?></th>
     
    6781</tr>
    6882<tr valign="top">
    69 <th scope="row"><?php _e('Default post by mail category:') ?></th>
     83<th scope="row"><?php _e('Default mail category:') ?></th>
    7084<td><select name="default_email_category" id="default_email_category">
    7185<?php
    7286//Alreay have $categories from default_category
    7387foreach ($categories as $category) :
    74 if ($category->cat_ID == get_settings('default_email_category')) $selected = " selected='selected'";
     88if ($category->cat_ID == get_option('default_email_category')) $selected = " selected='selected'";
    7589else $selected = '';
    7690echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>";
     
    8498<fieldset class="options">
    8599<legend><?php _e('Update Services') ?></legend>
    86 <p><?php _e('When you publish a new post, WordPress automatically notifies the following site update services. For more about this, see <a href="http://codex.wordpress.org/Update_Services">Update Services</a> on the Codex. Separate multiple service URIs with line breaks.') ?></p>
     100
     101<?php if ( get_option('blog_public') ) : ?>
     102
     103<p><?php _e('When you publish a new post, WordPress automatically notifies the following site update services. For more about this, see <a href="http://codex.wordpress.org/Update_Services">Update Services</a> on the Codex. Separate multiple service <abbr title="Universal Resource Locator">URL</abbr>s with line breaks.') ?></p>
    87104
    88105<textarea name="ping_sites" id="ping_sites" style="width: 98%;" rows="3" cols="50"><?php form_option('ping_sites'); ?></textarea>
     106
     107<?php else : ?>
     108
     109    <p><?php printf(__('WordPress is not notifying any <a href="http://codex.wordpress.org/Update_Services">Update Services</a> because of your blog\'s <a href="%s">privacy settings</a>'), 'options-privacy.php'); ?>
     110
     111<?php endif; ?>
     112
    89113</fieldset>
    90114
    91115<p class="submit">
    92116<input type="hidden" name="action" value="update" />
    93 <input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,rich_editing,ping_sites,mailserver_url,mailserver_port,mailserver_login,mailserver_pass,default_category,default_email_category,use_balanceTags" />
    94 <input type="submit" name="Submit" value="<?php _e('Update Options') ?> &raquo;" />
     117<input type="hidden" name="page_options" value="default_post_edit_rows,use_smilies,rich_editing,ping_sites,mailserver_url,mailserver_port,mailserver_login,mailserver_pass,default_category,default_email_category,use_balanceTags,default_link_category" />
     118<input type="submit" name="Submit" value="<?php _e('Update Options &raquo;') ?>" />
    95119</p>
    96120</form>
  • trunk/wp-admin/options.php

    r3503 r4431  
    66$parent_file = 'options-general.php';
    77
    8 $wpvarstoreset = array('action');
    9 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    10     $wpvar = $wpvarstoreset[$i];
    11     if (!isset($$wpvar)) {
    12         if (empty($_POST["$wpvar"])) {
    13             if (empty($_GET["$wpvar"])) {
    14                 $$wpvar = '';
    15             } else {
    16                 $$wpvar = $_GET["$wpvar"];
    17             }
    18         } else {
    19             $$wpvar = $_POST["$wpvar"];
    20         }
    21     }
    22 }
     8wp_reset_vars(array('action'));
    239
    2410if ( !current_user_can('manage_options') )
    25     die ( __('Cheatin&#8217; uh?') );
     11    wp_die(__('Cheatin&#8217; uh?'));
     12
     13function sanitize_option($option, $value) { // Remember to call stripslashes!
     14
     15    switch ($option) {
     16        case 'admin_email':
     17            $value = stripslashes($value);
     18            $value = sanitize_email($value);
     19            break;
     20
     21        case 'default_post_edit_rows':
     22        case 'mailserver_port':
     23        case 'comment_max_links':
     24            $value = stripslashes($value);
     25            $value = abs((int) $value);
     26            break;
     27
     28        case 'posts_per_page':
     29        case 'posts_per_rss':
     30            $value = stripslashes($value);
     31            $value = (int) $value;
     32            if ( empty($value) ) $value = 1;
     33            if ( $value < -1 ) $value = abs($value);
     34            break;
     35
     36        case 'default_ping_status':
     37        case 'default_comment_status':
     38            $value = stripslashes($value);
     39            // Options that if not there have 0 value but need to be something like "closed"
     40            if ( $value == '0' || $value == '')
     41                $value = 'closed';
     42            break;
     43
     44        case 'blogdescription':
     45        case 'blogname':
     46            if (current_user_can('unfiltered_html') == false)
     47                $value = wp_filter_post_kses( $value ); // calls stripslashes then addslashes
     48            $value = stripslashes($value);
     49            break;
     50
     51        case 'blog_charset':
     52            $value = preg_replace('/[^a-zA-Z0-9_-]/', '', $value); // strips slashes
     53            break;
     54
     55        case 'date_format':
     56        case 'time_format':
     57        case 'mailserver_url':
     58        case 'mailserver_login':
     59        case 'mailserver_pass':
     60        case 'ping_sites':
     61        case 'upload_path':
     62            $value = strip_tags($value);
     63            $value = wp_filter_kses($value); // calls stripslashes then addslashes
     64            $value = stripslashes($value);
     65            break;
     66
     67        case 'gmt_offset':
     68            $value = preg_replace('/[^0-9:.-]/', '', $value); // strips slashes
     69            break;
     70
     71        case 'siteurl':
     72        case 'home':
     73            $value = stripslashes($value);
     74            $value = clean_url($value);
     75            break;
     76        default :
     77            $value = stripslashes($value);
     78            break;
     79    }
     80
     81    return $value; 
     82}
    2683
    2784switch($action) {
     
    2986case 'update':
    3087    $any_changed = 0;
    31    
    32     check_admin_referer();
    3388
    34     if (!$_POST['page_options']) {
    35         foreach ($_POST as $key => $value) {
    36             $options[] = $key;
     89    check_admin_referer('update-options');
     90
     91    if ( !$_POST['page_options'] ) {
     92        foreach ( (array) $_POST as $key => $value) {
     93            if ( !in_array($key, array('_wpnonce', '_wp_http_referer')) )
     94                $options[] = $key;
    3795        }
    3896    } else {
     
    4098    }
    4199
    42     // Save for later.
    43     $old_siteurl = get_settings('siteurl');
    44     $old_home = get_settings('home');
    45 
    46     // HACK
    47     // Options that if not there have 0 value but need to be something like "closed"
    48     $nonbools = array('default_ping_status', 'default_comment_status');
    49100    if ($options) {
    50101        foreach ($options as $option) {
    51102            $option = trim($option);
    52             $value = trim(stripslashes($_POST[$option]));
    53                 if( in_array($option, $nonbools) && ( $value == '0' || $value == '') )
    54                 $value = 'closed';
    55            
    56             if( $option == 'blogdescription' || $option == 'blogname' )
    57                 if (current_user_can('unfiltered_html') == false)
    58                     $value = wp_filter_post_kses( $value );
    59            
    60             if (update_option($option, $value) ) {
    61                 $any_changed++;
    62             }
     103            $value = trim($_POST[$option]);
     104            $value = sanitize_option($option, $value); // This does stripslashes on those that need it
     105            update_option($option, $value);
    63106        }
    64107    }
    65108   
    66     if ($any_changed) {
    67             // If siteurl or home changed, reset cookies.
    68             if ( get_settings('siteurl') != $old_siteurl || get_settings('home') != $old_home ) {
    69                 // If home changed, write rewrite rules to new location.
    70                 $wp_rewrite->flush_rules();
    71                 // Get currently logged in user and password.
    72                 get_currentuserinfo();
    73                 // Clear cookies for old paths.
    74                 wp_clearcookie();
    75                 // Set cookies for new paths.
    76                 wp_setcookie($user_login, $user_pass_md5, true, get_settings('home'), get_settings('siteurl'));
    77             }
    78 
    79             //$message = sprintf(__('%d setting(s) saved... '), $any_changed);
    80     }
    81    
    82     $referred = remove_query_arg('updated' , $_SERVER['HTTP_REFERER']);
    83     $goback = add_query_arg('updated', 'true', $_SERVER['HTTP_REFERER']);
     109    $referred = remove_query_arg('updated' , wp_get_referer());
     110    $goback = add_query_arg('updated', 'true', wp_get_referer());
    84111    $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback);
    85112    wp_redirect($goback);
     
    90117
    91118<div class="wrap">
    92   <h2><?php _e('All options'); ?></h2>
    93   <form name="form" action="options.php" method="post">
     119  <h2><?php _e('All Options'); ?></h2>
     120  <form name="form" action="options.php" method="post" id="all-options">
     121  <?php wp_nonce_field('update-options') ?>
    94122  <input type="hidden" name="action" value="update" />
     123    <p class="submit"><input type="submit" name="Update" value="<?php _e('Update Options &raquo;') ?>" /></p>
    95124  <table width="98%">
    96125<?php
    97126$options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name");
    98127
    99 foreach ($options as $option) :
    100     $value = wp_specialchars($option->option_value);
     128foreach ( (array) $options as $option) :
     129    $disabled = '';
     130    if ( is_serialized($option->option_value) ) {
     131        if ( is_serialized_string($option->option_value) ) {
     132            // this is a serialized string, so we should display it
     133            $value = wp_specialchars(maybe_unserialize($option->option_value), 'single');
     134            $options_to_update[] = $option->option_name;
     135            $class = 'all-options';
     136        } else {
     137            $value = 'SERIALIZED DATA';
     138            $disabled = ' disabled="disabled"';
     139            $class = 'all-options disabled';
     140        }
     141    } else {
     142        $value = wp_specialchars($option->option_value, 'single');
     143        $options_to_update[] = $option->option_name;
     144        $class = 'all-options';
     145    }
    101146    echo "
    102147<tr>
    103148    <th scope='row'><label for='$option->option_name'>$option->option_name</label></th>
    104     <td><input type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . $value . "' /></td>
     149<td>";
     150
     151    if (stristr($value, "\n")) echo "<textarea class='$class' name='$option->option_name' id='$option->option_name' cols='30' rows='5'>$value</textarea>";
     152    else echo "<input class='$class' type='text' name='$option->option_name' id='$option->option_name' size='30' value='" . $value . "'$disabled />";
     153   
     154    echo "</td>
    105155    <td>$option->option_description</td>
    106156</tr>";
     
    108158?>
    109159  </table>
    110 <p class="submit"><input type="submit" name="Update" value="<?php _e('Update Settings &raquo;') ?>" /></p>
     160<?php $options_to_update = implode(',', $options_to_update); ?>
     161<p class="submit"><input type="hidden" name="page_options" value="<?php echo wp_specialchars($options_to_update, true); ?>" /><input type="submit" name="Update" value="<?php _e('Update Options &raquo;') ?>" /></p>
    111162  </form>
    112163</div>
  • trunk/wp-admin/page-new.php

    r3503 r4431  
    22require_once('admin.php');
    33$title = __('New Page');
    4 $parent_file = 'post.php';
     4$parent_file = 'post-new.php';
    55$editing = true;
     6wp_enqueue_script('prototype');
     7wp_enqueue_script('autosave');
    68require_once('admin-header.php');
    79?>
    810
    9 <?php if ( isset($_GET['saved']) ) : ?>
    10 <div id="message" class="updated fade"><p><strong><?php _e('Page saved.') ?> <a href="edit-pages.php"><?php _e('Manage pages'); ?> &raquo;</a></strong></p></div>
     11<?php if ( (isset($_GET['posted']) && $_GET['posted'])  || isset($_GET['saved']) ) : ?>
     12<div id="message" class="updated fade"><p><strong><?php _e('Page saved.') ?></strong> <a href="edit-pages.php"><?php _e('Manage pages'); ?></a> | <a href="<?php echo get_page_link( isset($_GET['posted']) ? $_GET['posted'] : $_GET['saved'] ); ?>"><?php _e('View page') ; ?> &raquo;</a></p></div>
    1113<?php endif; ?>
    1214
     
    1416if ( current_user_can('edit_pages') ) {
    1517    $action = 'post';
    16     get_currentuserinfo();
    17    
    1818    $post = get_default_post_to_edit();
    19     $post->post_status = 'static';
     19    $post->post_type = 'page';
    2020
    2121    include('edit-page-form.php');
  • trunk/wp-admin/plugin-editor.php

    r3503 r4431  
    55$parent_file = 'plugins.php';
    66
    7 $wpvarstoreset = array('action','redirect','profile','error','warning','a','file');
    8 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    9     $wpvar = $wpvarstoreset[$i];
    10     if (!isset($$wpvar)) {
    11         if (empty($_POST["$wpvar"])) {
    12             if (empty($_GET["$wpvar"])) {
    13                 $$wpvar = '';
    14             } else {
    15                 $$wpvar = $_GET["$wpvar"];
    16             }
    17         } else {
    18             $$wpvar = $_POST["$wpvar"];
    19         }
    20     }
    21 }
     7wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file'));
    228
    239$plugins = get_plugins();
     
    2915
    3016$file = validate_file_to_edit($file, $plugin_files);
    31 $real_file = get_real_file_to_edit("wp-content/plugins/$file");
     17$real_file = get_real_file_to_edit( PLUGINDIR . "/$file");
    3218
    3319switch($action) {
     
    3521case 'update':
    3622
     23    check_admin_referer('edit-plugin_' . $file);
     24
    3725    if ( !current_user_can('edit_plugins') )
    38     die('<p>'.__('You have do not have sufficient permissions to edit templates for this blog.').'</p>');
     26        wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
    3927
    4028    $newcontent = stripslashes($_POST['newcontent']);
     
    4331        fwrite($f, $newcontent);
    4432        fclose($f);
    45         header("Location: plugin-editor.php?file=$file&a=te");
     33        wp_redirect("plugin-editor.php?file=$file&a=te");
    4634    } else {
    47         header("Location: plugin-editor.php?file=$file");
     35        wp_redirect("plugin-editor.php?file=$file");
    4836    }
    4937
     
    5341
    5442default:
    55    
     43
     44    if ( !current_user_can('edit_plugins') )
     45        wp_die('<p>'.__('You do not have sufficient permissions to edit plugins for this blog.').'</p>');
     46
    5647    require_once('admin-header.php');
    57     if ( !current_user_can('edit_plugins') )
    58     die('<p>'.__('You have do not have sufficient permissions to edit plugins for this blog.').'</p>');
    5948
    60     update_recently_edited("wp-content/plugins/$file");
    61    
     49    update_recently_edited(PLUGINDIR . "/$file");
     50
    6251    if (!is_file($real_file))
    6352        $error = 1;
    64    
     53
    6554    if (!$error) {
    6655        $f = fopen($real_file, 'r');
     
    9685    <?php   if (!$error) { ?>
    9786  <form name="template" id="template" action="plugin-editor.php" method="post">
     87  <?php wp_nonce_field('edit-plugin_' . $file) ?>
    9888         <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
    9989     <input type="hidden" name="action" value="update" />
     
    10393     <p class="submit">
    10494<?php
    105     echo "<input type='submit' name='submit' value='    " . __('Update File') . " &raquo;' tabindex='2' />";
     95    echo "<input type='submit' name='submit' value='    " . __('Update File &raquo;') . "' tabindex='2' />";
    10696?>
    10797</p>
  • trunk/wp-admin/plugins.php

    r3503 r4431  
    33
    44if ( isset($_GET['action']) ) {
    5     check_admin_referer();
    6    
    75    if ('activate' == $_GET['action']) {
    8         $current = get_settings('active_plugins');
     6        check_admin_referer('activate-plugin_' . $_GET['plugin']);
     7        $current = get_option('active_plugins');
    98        if (!in_array($_GET['plugin'], $current)) {
    109            $current[] = trim( $_GET['plugin'] );
    1110            sort($current);
    1211            update_option('active_plugins', $current);
    13             include(ABSPATH . 'wp-content/plugins/' . trim( $_GET['plugin'] ));
     12            include(ABSPATH . PLUGINDIR . '/' . trim( $_GET['plugin'] ));
    1413            do_action('activate_' . trim( $_GET['plugin'] ));
    1514        }
    16         header('Location: plugins.php?activate=true');
     15        wp_redirect('plugins.php?activate=true');
    1716    } else if ('deactivate' == $_GET['action']) {
    18         $current = get_settings('active_plugins');
     17        check_admin_referer('deactivate-plugin_' . $_GET['plugin']);
     18        $current = get_option('active_plugins');
    1919        array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu!
    2020        update_option('active_plugins', $current);
    2121        do_action('deactivate_' . trim( $_GET['plugin'] ));
    22         header('Location: plugins.php?deactivate=true');
     22        wp_redirect('plugins.php?deactivate=true');
    2323    }
    2424    exit;
     
    3131// If any plugins don't exist, axe 'em
    3232
    33 $check_plugins = get_settings('active_plugins');
     33$check_plugins = get_option('active_plugins');
    3434
    3535// Sanity check.  If the active plugin list is not an array, make it an
     
    3737if ( !is_array($check_plugins) ) {
    3838    $check_plugins = array();
    39     update_option('active_plugins', $check_plugins);   
     39    update_option('active_plugins', $check_plugins);
    4040}
    4141
     
    4343// plugins.
    4444foreach ($check_plugins as $check_plugin) {
    45     if (!file_exists(ABSPATH . 'wp-content/plugins/' . $check_plugin)) {
    46             $current = get_settings('active_plugins');
     45    if (!file_exists(ABSPATH . PLUGINDIR . '/' . $check_plugin)) {
     46            $current = get_option('active_plugins');
    4747            $key = array_search($check_plugin, $current);
    4848            if ( false !== $key && NULL !== $key ) {
     
    6868<?php
    6969
    70 if ( get_settings('active_plugins') )
    71     $current_plugins = get_settings('active_plugins');
     70if ( get_option('active_plugins') )
     71    $current_plugins = get_option('active_plugins');
    7272
    7373$plugins = get_plugins();
     
    7979} else {
    8080?>
    81 <table width="100%" cellpadding="3" cellspacing="3">
     81<table class="widefat plugins">
     82    <thead>
    8283    <tr>
    8384        <th><?php _e('Plugin'); ?></th>
    84         <th><?php _e('Version'); ?></th>
     85        <th style="text-align: center"><?php _e('Version'); ?></th>
    8586        <th><?php _e('Description'); ?></th>
    86         <th><?php _e('Action'); ?></th>
     87        <th style="text-align: center"<?php if ( current_user_can('edit_plugins') ) echo ' colspan="2"'; ?>><?php _e('Action'); ?></th>
    8788    </tr>
     89    </thead>
    8890<?php
    8991    $style = '';
    90 
    91     function sort_plugins($plug1, $plug2) {
    92         return strnatcasecmp($plug1['Name'], $plug2['Name']);
    93     }
    94    
    95     uksort($plugins, 'sort_plugins');
    9692
    9793    foreach($plugins as $plugin_file => $plugin_data) {
     
    9995
    10096        if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) {
    101             $action = "<a href='plugins.php?action=deactivate&amp;plugin=$plugin_file' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>";
     97            $toggle = "<a href='" . wp_nonce_url("plugins.php?action=deactivate&amp;plugin=$plugin_file", 'deactivate-plugin_' . $plugin_file) . "' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>";
    10298            $plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>";
    10399            $style .= $style == 'alternate' ? ' active' : 'active';
    104100        } else {
    105             $action = "<a href='plugins.php?action=activate&amp;plugin=$plugin_file' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";
     101            $toggle = "<a href='" . wp_nonce_url("plugins.php?action=activate&amp;plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";
    106102        }
    107103        $plugin_data['Description'] = wp_kses($plugin_data['Description'], array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()) ); ;
    108         if ($style != '') $style = 'class="' . $style . '"';
     104        if ( $style != '' )
     105            $style = 'class="' . $style . '"';
     106        if ( is_writable(ABSPATH . 'wp-content/plugins/' . $plugin_file) )
     107            $edit = "<a href='plugin-editor.php?file=$plugin_file' title='".__('Open this file in the Plugin Editor')."' class='edit'>".__('Edit')."</a>";
     108        else
     109            $edit = '';
     110
    109111        echo "
    110112    <tr $style>
    111113        <td class='name'>{$plugin_data['Title']}</td>
    112114        <td class='vers'>{$plugin_data['Version']}</td>
    113         <td class='desc'>{$plugin_data['Description']} <cite>".sprintf(__('By %s'), $plugin_data['Author']).".</cite></td>
    114         <td class='togl'>$action</td>
     115        <td class='desc'><p>{$plugin_data['Description']} <cite>".sprintf(__('By %s'), $plugin_data['Author']).".</cite></p></td>
     116        <td class='togl'>$toggle</td>";
     117        if ( current_user_can('edit_plugins') )
     118        echo "
     119        <td>$edit</td>";
     120        echo"
    115121    </tr>";
    116122    }
     
    122128?>
    123129
    124 <p><?php _e('If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the <code>wp-content/plugins</code> directory and it will be automatically deactivated.'); ?></p>
     130<p><?php _e(sprintf('If something goes wrong with a plugin and you can&#8217;t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.', PLUGINDIR)); ?></p>
    125131
    126132<h2><?php _e('Get More Plugins'); ?></h2>
    127 <p><?php _e('You can find additional plugins for your site in the <a href="http://wordpress.org/extend/plugins/">WordPress plugin directory</a>. To install a plugin you generally just need to upload the plugin file into your <code>wp-content/plugins</code> directory. Once a plugin is uploaded, you may activate it here.'); ?></p>
     133<p><?php _e('You can find additional plugins for your site in the <a href="http://wordpress.org/extend/plugins/">WordPress plugin directory</a>.'); ?></p>
     134<p><?php _e(sprintf('To install a plugin you generally just need to upload the plugin file into your <code>%s</code> directory. Once a plugin is uploaded, you may activate it here.', PLUGINDIR)); ?></p>
    128135
    129136</div>
  • trunk/wp-admin/post.php

    r3503 r4431  
    22require_once('admin.php');
    33
    4 $wpvarstoreset = array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder' );
     4$parent_file = 'edit.php';
     5$submenu_file = 'edit.php';
    56
    6 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    7     $wpvar = $wpvarstoreset[$i];
    8     if (!isset($$wpvar)) {
    9         if (empty($_POST["$wpvar"])) {
    10             if (empty($_GET["$wpvar"])) {
    11                 $$wpvar = '';
    12             } else {
    13             $$wpvar = $_GET["$wpvar"];
    14             }
    15         } else {
    16             $$wpvar = $_POST["$wpvar"];
    17         }
    18     }
    19 }
     7wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder'));
    208
    21 if (isset($_POST['deletepost'])) {
    22 $action = "delete";
    23 }
    24 
    25 // Fix submenu highlighting for pages.
    26 if ( isset($_REQUEST['post']) && 'static' == get_post_status($_REQUEST['post']) )
    27     $submenu_file = 'page-new.php';
    28 
    29 $editing = true;
     9if ( isset( $_POST['deletepost'] ) )
     10    $action = 'delete';
    3011
    3112switch($action) {
     13case 'postajaxpost':
    3214case 'post':
    33 
    34     $post_ID = write_post();
     15    $parent_file = 'post-new.php';
     16    $submenu_file = 'post-new.php';
     17    check_admin_referer('add-post');
     18   
     19    $post_ID = 'post' == $action ? write_post() : edit_post();
    3520
    3621    // Redirect.
     
    4429            break;
    4530        default:
    46             $location = 'post.php';
     31            $location = 'post-new.php';
    4732            break;
    4833        }
    4934    } else {
    50         $location = 'post.php?posted=true';
     35        $location = "post-new.php?posted=$post_ID";
    5136    }
    52 
    53     if ( 'static' == $_POST['post_status'] )
    54         $location = "page-new.php?saved=true";
    5537
    5638    if ( isset($_POST['save']) )
    5739        $location = "post.php?action=edit&post=$post_ID";
    5840
    59     header("Location: $location");
     41    wp_redirect($location);
    6042    exit();
    6143    break;
     
    6345case 'edit':
    6446    $title = __('Edit');
    65 
     47    $editing = true;
     48    $post_ID = $p = (int) $_GET['post'];
     49    $post = get_post($post_ID);
     50    if($post->post_status == 'draft') {
     51        wp_enqueue_script('prototype');
     52        wp_enqueue_script('autosave');
     53    }
    6654    require_once('admin-header.php');
    67 
    68     $post_ID = $p = (int) $_GET['post'];
    6955
    7056    if ( !current_user_can('edit_post', $post_ID) )
     
    7258
    7359    $post = get_post_to_edit($post_ID);
    74    
    75     if ($post->post_status == 'static')
    76         include('edit-page-form.php');
    77     else
    78         include('edit-form-advanced.php');
     60
     61    include('edit-form-advanced.php');
    7962
    8063    ?>
    8164    <div id='preview' class='wrap'>
    82     <h2 id="preview-post"><?php _e('Post Preview (updated when post is saved)'); ?> <small class="quickjump"><a href="#write-post"><?php _e('edit &uarr;'); ?></a></small></h2>
    83         <iframe src="<?php echo add_query_arg('preview', 'true', get_permalink($post->ID)); ?>" width="100%" height="600" ></iframe>
     65    <h2 id="preview-post"><?php _e('Post Preview (updated when post is saved)'); ?></h2>
     66        <iframe src="<?php echo wp_specialchars(apply_filters('preview_post_link', add_query_arg('preview', 'true', get_permalink($post->ID)))); ?>" width="100%" height="600" ></iframe>
    8467    </div>
    8568    <?php
     
    8972    $post_id = (int) $_POST['post_ID'];
    9073
     74    check_admin_referer('update-attachment_' . $post_id);
     75
    9176    // Don't let these be changed
    9277    unset($_POST['guid']);
    93     $_POST['post_status'] = 'attachment';
     78    $_POST['post_type'] = 'attachment';
    9479
    9580    // Update the thumbnail filename
     
    10388
    10489case 'editpost':
     90    $post_ID = (int) $_POST['post_ID'];
     91    check_admin_referer('update-post_' . $post_ID);
     92   
    10593    $post_ID = edit_post();
    10694
    107     if ($_POST['save']) {
    108         $location = $_SERVER['HTTP_REFERER'];
    109     } elseif ($_POST['updatemeta']) {
    110         $location = $_SERVER['HTTP_REFERER'] . '&message=2#postcustom';
    111     } elseif ($_POST['deletemeta']) {
    112         $location = $_SERVER['HTTP_REFERER'] . '&message=3#postcustom';
    113     } elseif (isset($_POST['referredby']) && $_POST['referredby'] != $_SERVER['HTTP_REFERER']) {
    114         $location = $_POST['referredby'];
    115         if ( $_POST['referredby'] == 'redo' )
    116             $location = get_permalink( $post_ID );
    117     } elseif ($action == 'editattachment') {
    118         $location = 'attachments.php';
     95    if ( 'post' == $_POST['originalaction'] ) {
     96        if (!empty($_POST['mode'])) {
     97        switch($_POST['mode']) {
     98            case 'bookmarklet':
     99                $location = $_POST['referredby'];
     100                break;
     101            case 'sidebar':
     102                $location = 'sidebar.php?a=b';
     103                break;
     104            default:
     105                $location = 'post-new.php';
     106                break;
     107            }
     108        } else {
     109            $location = "post-new.php?posted=$post_ID";
     110        }
     111
     112        if ( isset($_POST['save']) )
     113            $location = "post.php?action=edit&post=$post_ID";
    119114    } else {
    120         $location = 'post.php';
     115        $referredby = '';
     116        if ( !empty($_POST['referredby']) )
     117            $referredby = preg_replace('|https?://[^/]+|i', '', $_POST['referredby']);
     118        $referer = preg_replace('|https?://[^/]+|i', '', wp_get_referer());
     119   
     120        if ($_POST['save']) {
     121            $location = "post.php?action=edit&post=$post_ID";
     122        } elseif ($_POST['updatemeta']) {
     123            $location = wp_get_referer() . '&message=2#postcustom';
     124        } elseif ($_POST['deletemeta']) {
     125            $location = wp_get_referer() . '&message=3#postcustom';
     126        } elseif (!empty($referredby) && $referredby != $referer) {
     127            $location = $_POST['referredby'];
     128            if ( $_POST['referredby'] == 'redo' )
     129                $location = get_permalink( $post_ID );
     130        } elseif ($action == 'editattachment') {
     131            $location = 'attachments.php';
     132        } else {
     133            $location = 'post-new.php';
     134        }
    121135    }
    122     header ('Location: ' . $location); // Send user on their way while we keep working
     136
     137    wp_redirect($location); // Send user on their way while we keep working
    123138
    124139    exit();
     
    126141
    127142case 'delete':
    128     check_admin_referer();
    129 
    130143    $post_id = (isset($_GET['post']))  ? intval($_GET['post']) : intval($_POST['post_ID']);
     144    check_admin_referer('delete-post_' . $post_id);
    131145
    132146    $post = & get_post($post_id);
    133    
    134     if ( !current_user_can('edit_post', $post_id) )
    135         die( __('You are not allowed to delete this post.') );
    136147
    137     if ( $post->post_status == 'attachment' ) {
     148    if ( !current_user_can('delete_post', $post_id) )
     149        wp_die( __('You are not allowed to delete this post.') );
     150
     151    if ( $post->post_type == 'attachment' ) {
    138152        if ( ! wp_delete_attachment($post_id) )
    139             die( __('Error in deleting...') );
     153            wp_die( __('Error in deleting...') );
    140154    } else {
    141155        if ( !wp_delete_post($post_id) )
    142             die( __('Error in deleting...') );
     156            wp_die( __('Error in deleting...') );
    143157    }
    144158
    145     $sendback = $_SERVER['HTTP_REFERER'];
    146     if (strstr($sendback, 'post.php')) $sendback = get_settings('siteurl') .'/wp-admin/post.php';
    147     elseif (strstr($sendback, 'attachments.php')) $sendback = get_settings('siteurl') .'/wp-admin/attachments.php';
     159    $sendback = wp_get_referer();
     160    if (strstr($sendback, 'post.php')) $sendback = get_option('siteurl') .'/wp-admin/post-new.php';
     161    elseif (strstr($sendback, 'attachments.php')) $sendback = get_option('siteurl') .'/wp-admin/attachments.php';
    148162    $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
    149     header ('Location: ' . $sendback);
    150     break;
    151 
    152 case 'editcomment':
    153     $title = __('Edit Comment');
    154     $parent_file = 'edit.php';
    155     require_once ('admin-header.php');
    156 
    157     get_currentuserinfo();
    158 
    159     $comment = (int) $_GET['comment'];
    160 
    161     if ( ! $comment = get_comment($comment) )
    162         die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'javascript:history.go(-1)'));
    163 
    164     if ( !current_user_can('edit_post', $comment->comment_post_ID) )   
    165         die( __('You are not allowed to edit comments on this post.') );
    166 
    167     $comment = get_comment_to_edit($comment);
    168 
    169     include('edit-form-comment.php');
    170 
    171     break;
    172 
    173 case 'confirmdeletecomment':
    174 
    175     require_once('./admin-header.php');
    176 
    177     $comment = (int) $_GET['comment'];
    178     $p = (int) $_GET['p'];
    179 
    180     if ( ! $comment = get_comment($comment) )
    181         die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
    182 
    183     if ( !current_user_can('edit_post', $comment->comment_post_ID) )   
    184         die( __('You are not allowed to delete comments on this post.') );
    185 
    186     echo "<div class='wrap'>\n";
    187     echo "<p>" . __('<strong>Caution:</strong> You are about to delete the following comment:') . "</p>\n";
    188     echo "<table border='0'>\n";
    189     echo "<tr><td>" . __('Author:') . "</td><td>$comment->comment_author</td></tr>\n";
    190     echo "<tr><td>" . __('E-mail:') . "</td><td>$comment->comment_author_email</td></tr>\n";
    191     echo "<tr><td>". __('URL:') . "</td><td>$comment->comment_author_url</td></tr>\n";
    192     echo "<tr><td>". __('Comment:') . "</td><td>$comment->comment_content</td></tr>\n";
    193     echo "</table>\n";
    194     echo "<p>" . __('Are you sure you want to do that?') . "</p>\n";
    195 
    196     echo "<form action='".get_settings('siteurl')."/wp-admin/post.php' method='get'>\n";
    197     echo "<input type='hidden' name='action' value='deletecomment' />\n";
    198     echo "<input type='hidden' name='p' value='$p' />\n";
    199     echo "<input type='hidden' name='comment' value='{$comment->comment_ID}' />\n";
    200     echo "<input type='hidden' name='noredir' value='1' />\n";
    201     echo "<input type='submit' value='" . __('Yes') . "' />";
    202     echo "&nbsp;&nbsp;";
    203     echo "<input type='button' value='" . __('No') . "' onclick=\"self.location='". get_settings('siteurl') ."/wp-admin/edit.php?p=$p&amp;c=1#comments';\" />\n";
    204     echo "</form>\n";
    205     echo "</div>\n";
    206 
    207     break;
    208 
    209 case 'deletecomment':
    210 
    211     check_admin_referer();
    212 
    213     $comment = (int) $_GET['comment'];
    214     $p = (int) $_GET['p'];
    215     if (isset($_GET['noredir'])) {
    216         $noredir = true;
    217     } else {
    218         $noredir = false;
    219     }
    220 
    221     $postdata = get_post($p) or die(sprintf(__('Oops, no post with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
    222 
    223     if ( ! $comment = get_comment($comment) )
    224              die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'post.php'));
    225 
    226     if ( !current_user_can('edit_post', $comment->comment_post_ID) )   
    227         die( __('You are not allowed to edit comments on this post.') );
    228 
    229     wp_set_comment_status($comment->comment_ID, "delete");
    230     do_action('delete_comment', $comment->comment_ID);
    231 
    232     if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) {
    233         header('Location: ' . $_SERVER['HTTP_REFERER']);
    234     } else {
    235         header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
    236     }
    237 
    238     break;
    239 
    240 case 'unapprovecomment':
    241 
    242     check_admin_referer();
    243 
    244     $comment = (int) $_GET['comment'];
    245     $p = (int) $_GET['p'];
    246     if (isset($_GET['noredir'])) {
    247         $noredir = true;
    248     } else {
    249         $noredir = false;
    250     }
    251 
    252     if ( ! $comment = get_comment($comment) )
    253         die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
    254 
    255     if ( !current_user_can('edit_post', $comment->comment_post_ID) )   
    256         die( __('You are not allowed to edit comments on this post, so you cannot disapprove this comment.') );
    257 
    258     wp_set_comment_status($comment->comment_ID, "hold");
    259 
    260     if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) {
    261         header('Location: ' . $_SERVER['HTTP_REFERER']);
    262     } else {
    263         header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
    264     }
    265 
    266     break;
    267 
    268 case 'mailapprovecomment':
    269 
    270     $comment = (int) $_GET['comment'];
    271 
    272     if ( ! $comment = get_comment($comment) )
    273              die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
    274 
    275     if ( !current_user_can('edit_post', $comment->comment_post_ID) )   
    276         die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
    277 
    278     if ('1' != $comment->comment_approved) {
    279         wp_set_comment_status($comment->comment_ID, 'approve');
    280         if (true == get_option('comments_notify'))
    281             wp_notify_postauthor($comment->comment_ID);
    282     }
    283 
    284     header('Location: ' . get_option('siteurl') . '/wp-admin/moderation.php?approved=1');
    285 
    286     break;
    287 
    288 case 'approvecomment':
    289 
    290     $comment = (int) $_GET['comment'];
    291     $p = (int) $_GET['p'];
    292     if (isset($_GET['noredir'])) {
    293         $noredir = true;
    294     } else {
    295         $noredir = false;
    296     }
    297 
    298     if ( ! $comment = get_comment($comment) )
    299         die(sprintf(__('Oops, no comment with this ID. <a href="%s">Go back</a>!'), 'edit.php'));
    300 
    301     if ( !current_user_can('edit_post', $comment->comment_post_ID) )   
    302         die( __('You are not allowed to edit comments on this post, so you cannot approve this comment.') );
    303 
    304     wp_set_comment_status($comment->comment_ID, "approve");
    305     if (get_settings("comments_notify") == true) {
    306         wp_notify_postauthor($comment->comment_ID);
    307     }
    308 
    309 
    310     if (($_SERVER['HTTP_REFERER'] != "") && (false == $noredir)) {
    311         header('Location: ' . $_SERVER['HTTP_REFERER']);
    312     } else {
    313         header('Location: '. get_settings('siteurl') .'/wp-admin/edit.php?p='.$p.'&c=1#comments');
    314     }
    315 
    316     break;
    317 
    318 case 'editedcomment':
    319 
    320     edit_comment();
    321 
    322     $referredby = $_POST['referredby'];
    323     if (!empty($referredby)) {
    324         header('Location: ' . $referredby);
    325     } else {
    326         header ("Location: edit.php?p=$comment_post_ID&c=1#comments");
    327     }
    328 
     163    wp_redirect($sendback);
     164    exit();
    329165    break;
    330166
    331167default:
    332     $title = __('Create New Post');
    333     require_once ('./admin-header.php');
    334 ?>
    335 <?php if ( isset($_GET['posted']) ) : ?>
    336 <div id="message" class="updated fade"><p><?php printf(__('Post saved. <a href="%s">View site &raquo;</a>'), get_bloginfo('home') . '/'); ?></p></div>
    337 <?php endif; ?>
    338 <?php
    339     if ( current_user_can('edit_posts') ) {
    340         $action = 'post';
    341         get_currentuserinfo();
    342         if ( $drafts = get_users_drafts( $user_ID ) ) {
    343             ?>
    344             <div class="wrap">
    345             <p><strong><?php _e('Your Drafts:') ?></strong>
    346             <?php
    347             $num_drafts = count($drafts);
    348             if ( $num_drafts > 15 ) $num_drafts = 15;
    349             for ( $i = 0; $i < $num_drafts; $i++ ) {
    350                 $draft = $drafts[$i];
    351                 if ( 0 != $i )
    352                     echo ', ';
    353                 $draft->post_title = stripslashes($draft->post_title);
    354                 if ( empty($draft->post_title) )
    355                     $draft->post_title = sprintf(__('Post # %s'), $draft->ID);
    356                 echo "<a href='post.php?action=edit&amp;post=$draft->ID' title='" . __('Edit this draft') . "'>$draft->post_title</a>";
    357             }
    358             ?>
    359             <?php if ( 15 < count($drafts) ) { ?>
    360             , <a href="edit.php"><?php echo sprintf(__('and %s more'), (count($drafts) - 15) ); ?> &raquo;</a>
    361             <?php } ?>
    362             .</p>
    363             </div>
    364             <?php
    365         }
    366 
    367         $post = get_default_post_to_edit();
    368 
    369         include('edit-form-advanced.php');
    370 ?>
    371 <div class="wrap">
    372 <?php echo '<h3>'.__('WordPress bookmarklet').'</h3>
    373 <p>'.__('Right click on the following link and choose "Add to favorites" to create a posting shortcut.').'</p>'; ?>
    374 <p>
    375 
    376 <?php
    377 if ($is_NS4 || $is_gecko) {
    378 ?>
    379 <a href="javascript:if(navigator.userAgent.indexOf('Safari') >= 0){Q=getSelection();}else{Q=document.selection?document.selection.createRange().text:document.getSelection();}location.href='<?php echo get_settings('siteurl') ?>/wp-admin/post.php?text='+encodeURIComponent(Q)+'&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press It - %s'), wp_specialchars(get_settings('blogname'))); ?></a>
    380 <?php
    381 } else if ($is_winIE) {
    382 ?>
    383 <a href="javascript:Q='';if(top.frames.length==0)Q=document.selection.createRange().text;location.href='<?php echo get_settings('siteurl') ?>/wp-admin/post.php?text='+encodeURIComponent(Q)+'&amp;popupurl='+encodeURIComponent(location.href)+'&amp;popuptitle='+encodeURIComponent(document.title);"><?php printf(__('Press it - %s'), get_settings('blogname')); ?></a>
    384 <script type="text/javascript">
    385 <!--
    386 function oneclickbookmarklet(blah) {
    387 window.open ("profile.php?action=IErightclick", "oneclickbookmarklet", "width=500, height=450, location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=120, left=120, screenY=120, top=120");
    388 }
    389 // -->
    390 </script>
    391 <br />
    392 <br />
    393 <?php _e('One-click bookmarklet:') ?><br />
    394 <a href="javascript:oneclickbookmarklet(0);"><?php _e('click here') ?></a>
    395 <?php
    396 } else if ($is_opera) {
    397 ?>
    398 <a href="javascript:location.href='<?php echo get_settings('siteurl'); ?>/wp-admin/post.php?popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_settings('blogname')); ?></a>
    399 <?php
    400 } else if ($is_macIE) {
    401 ?>
    402 <a href="javascript:Q='';location.href='<?php echo get_settings('siteurl'); ?>/wp-admin/bookmarklet.php?text='+escape(document.getSelection())+'&popupurl='+escape(location.href)+'&popuptitle='+escape(document.title);"><?php printf(__('Press it - %s'), get_settings('blogname')); ?></a>
    403 <?php
    404 }
    405 ?>
    406 </p>
    407 </div>
    408 <?php
    409 } else {
    410 ?>
    411 <div class="wrap">
    412 <p><?php printf(__('Since you&#8217;re a newcomer, you&#8217;ll have to wait for an admin to raise your level to 1, in order to be authorized to post.<br />
    413 You can also <a href="mailto:%s?subject=Promotion?">e-mail the admin</a> to ask for a promotion.<br />
    414 When you&#8217;re promoted, just reload this page and you&#8217;ll be able to blog. :)'), get_settings('admin_email')); ?>
    415 </p>
    416 </div>
    417 <?php
    418 }
    419 
     168    wp_redirect('edit.php');
     169    exit();
    420170    break;
    421171} // end switch
    422 /* </Edit> */
    423172include('admin-footer.php');
    424173?>
  • trunk/wp-admin/profile-update.php

    r3503 r4431  
    11<?php
    22
     3$parent_file = 'profile.php';
     4$submenu_file = 'profile.php';
    35require_once('admin.php');
    46
    5 check_admin_referer();
     7check_admin_referer('update-profile_' . $user_ID);
    68
    79if ( !$_POST )
    8     die( __('No post?') );
     10    wp_die( __('No post?') );
    911
    1012$errors = edit_user($user_ID);
    1113
    12 if (count($errors) != 0) {
    13     foreach ($errors as $id => $error) {
    14         echo $error . '<br/>';
    15     }
     14if ( is_wp_error( $errors ) ) {
     15    foreach( $errors->get_error_messages() as $message )
     16        echo "$message<br />";
    1617    exit;
    1718}
    1819
    19 if ( !isset( $_POST['rich_editing'] ) )
    20     $_POST['rich_editing'] = 'false';
    21 update_user_option( $current_user->id, 'rich_editing', $_POST['rich_editing'], true );
     20if ( rich_edit_exists() ) {
     21    if ( !isset( $_POST['rich_editing'] ) )
     22        $_POST['rich_editing'] = 'false';
     23    update_user_option( $current_user->id, 'rich_editing', $_POST['rich_editing'], true );
     24}
    2225
    2326do_action('personal_options_update');
  • trunk/wp-admin/profile.php

    r3503 r4431  
    44$title = __('Profile');
    55
    6 $parent_file = 'profile.php';
     6if ( current_user_can('edit_users') )
     7    $parent_file = 'users.php';
     8else
     9    $parent_file = 'profile.php';
    710include_once('admin-header.php');
    8 $profileuser = new WP_User($user_ID);
     11$profileuser = get_user_to_edit($user_ID);
    912
    1013$bookmarklet_height= 440;
     
    2023<h2><?php _e('Your Profile and Personal Options'); ?></h2>
    2124<form name="profile" id="your-profile" action="profile-update.php" method="post">
     25<?php wp_nonce_field('update-profile_' . $user_ID) ?>
    2226<p>
    2327<input type="hidden" name="from" value="profile" />
    2428<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
    2529</p>
     30
     31<h3><?php _e('Personal Options'); ?></h3>
     32
     33<?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?>
     34<p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', get_user_option('rich_editing')); ?> />
     35<?php _e('Use the visual editor when writing') ?></label></p>
     36<?php endif; ?>
     37
     38<?php do_action('profile_personal_options'); ?>
     39
     40<p class="submit"><input type="submit" value="<?php _e('Update Profile &raquo;') ?>" name="submit" /></p>
    2641
    2742<fieldset>
     
    8297<br clear="all" />
    8398<fieldset>
    84 <legend><?php _e('About yourself'); ?></legend>
    85 <p class="desc"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></p>
     99<legend><?php _e('About Yourself'); ?></legend>
     100<p class="desc"><?php _e('Share a little biographical information. '); ?></p>
    86101<p><textarea name="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea></p>
    87102</fieldset>
     
    107122<br clear="all" />
    108123
    109 <h3><?php _e('Personal Options'); ?></h3>
    110 
    111 <p><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', get_user_option('rich_editing')); ?> />
    112 <?php _e('Use the visual rich editor when writing') ?></label></p>
    113 
    114 <?php do_action('profile_personal_options'); ?>
    115 
    116124  <table width="99%"  border="0" cellspacing="2" cellpadding="3" class="editform">
    117125    <?php
     
    135143    ?>
    136144  </table>
    137 <p class="submit">
    138 <input type="submit" value="<?php _e('Update Profile &raquo;') ?>" name="submit" />
    139 </p>
     145<p class="submit"><input type="submit" value="<?php _e('Update Profile &raquo;') ?>" name="submit" /></p>
    140146</form>
    141147
  • trunk/wp-admin/setup-config.php

    r3503 r4431  
    22define('WP_INSTALLING', true);
    33
    4 if (file_exists('../wp-config.php'))
    5     die("The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.");
    6 
    74if (!file_exists('../wp-config-sample.php'))
    85    die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.');
     6
    97$configFile = file('../wp-config-sample.php');
    108
    119if (!is_writable('../')) die("Sorry, I can't write to the directory. You'll have to either change the permissions on your WordPress directory or create your wp-config.php manually.");
    1210
    13 $step = 0;
    14 if(isset($_GET['step'])) $step = $_GET['step'];
     11
     12if (isset($_GET['step']))
     13    $step = $_GET['step'];
     14else
     15    $step = 0;
    1516header( 'Content-Type: text/html; charset=utf-8' );
    1617?>
     
    2122<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    2223<style media="screen" type="text/css">
    23     <!--
     24    <!--
     25    html {
     26        background: #eee;
     27    }
    2428    body {
     29        background: #fff;
     30        color: #000;
    2531        font-family: Georgia, "Times New Roman", Times, serif;
    26         margin-left: 15%;
    27         margin-right: 15%;
     32        margin-left: 20%;
     33        margin-right: 20%;
     34        padding: .2em 2em;
     35    }
     36
     37    h1 {
     38        color: #006;
     39        font-size: 18px;
     40        font-weight: lighter;
     41    }
     42
     43    h2 {
     44        font-size: 16px;
     45    }
     46
     47    p, li, dt {
     48        line-height: 140%;
     49        padding-bottom: 2px;
     50    }
     51
     52    ul, ol {
     53        padding: 5px 5px 5px 20px;
    2854    }
    2955    #logo {
    30         margin: 0;
    31         padding: 0;
    32         background-image: url(http://wordpress.org/images/logo.png);
    33         background-repeat: no-repeat;
    34         height: 60px;
    35         border-bottom: 4px solid #333;
     56        margin-bottom: 2em;
    3657    }
    37     #logo a {
    38         display: block;
    39         height: 60px;
     58    .step a, .step input {
     59        font-size: 2em;
    4060    }
    41     #logo a span {
    42         display: none;
     61    td input {
     62        font-size: 1.5em;
    4363    }
    44     p, li {
    45         line-height: 140%;
     64    .step, th {
     65        text-align: right;
    4666    }
    47     -->
     67    #footer {
     68        text-align: center;
     69        border-top: 1px solid #ccc;
     70        padding-top: 1em;
     71        font-style: italic;
     72    }
     73    -->
    4874    </style>
    4975</head>
    50 <body> 
    51 <h1 id="logo"><a href="http://wordpress.org/"><span>WordPress</span></a></h1>
     76<body>
     77<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
    5278<?php
     79// Check if wp-config.php has been created
     80if (file_exists('../wp-config.php'))
     81    die("<p>The file 'wp-config.php' already exists. If you need to reset any of the configuration items in this file, please delete it first. You may try <a href='install.php'>installing now</a>.</p></body></html>");
    5382
    5483switch($step) {
    5584    case 0:
    5685?>
     86
    5787<p>Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.</p>
    5888<ol>
    5989  <li>Database name</li>
    6090  <li>Database username</li>
    61   <li>Database password</li> 
     91  <li>Database password</li>
    6292  <li>Database host</li>
    6393  <li>Table prefix (if you want to run more than one WordPress in a single database) </li>
     
    71101    ?>
    72102</p>
    73 <form method="post" action="setup-config.php?step=2"> 
     103<form method="post" action="setup-config.php?step=2">
    74104  <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p>
    75105  <table>
    76106    <tr>
    77107      <th scope="row">Database Name</th>
    78       <td><input name="dbname" type="text" size="45" value="wordpress" /></td>
     108      <td><input name="dbname" type="text" size="25" value="wordpress" /></td>
    79109      <td>The name of the database you want to run WP in. </td>
    80110    </tr>
    81111    <tr>
    82112      <th scope="row">User Name</th>
    83       <td><input name="uname" type="text" size="45" value="username" /></td>
     113      <td><input name="uname" type="text" size="25" value="username" /></td>
    84114      <td>Your MySQL username</td>
    85115    </tr>
    86116    <tr>
    87117      <th scope="row">Password</th>
    88       <td><input name="pwd" type="text" size="45" value="password" /></td>
     118      <td><input name="pwd" type="text" size="25" value="password" /></td>
    89119      <td>...and MySQL password.</td>
    90120    </tr>
    91121    <tr>
    92122      <th scope="row">Database Host</th>
    93       <td><input name="dbhost" type="text" size="45" value="localhost" /></td>
     123      <td><input name="dbhost" type="text" size="25" value="localhost" /></td>
    94124      <td>99% chance you won't need to change this value.</td>
    95125    </tr>
    96126    <tr>
    97127      <th scope="row">Table Prefix</th>
    98       <td><input name="prefix" type="text" id="prefix" value="wp_" size="45" /></td>
     128      <td><input name="prefix" type="text" id="prefix" value="wp_" size="25" /></td>
    99129      <td>If you want to run multiple WordPress installations in a single database, change this.</td>
    100130    </tr>
    101   </table>
    102   <input name="submit" type="submit" value="Submit" />
     131  </table>
     132  <h2 class="step">
     133  <input name="submit" type="submit" value="Submit" />
     134  </h2>
    103135</form>
    104136<?php
    105137    break;
    106    
     138
    107139    case 2:
    108140    $dbname  = trim($_POST['dbname']);
     
    150182<?php
    151183    break;
    152 
    153184}
    154 ?>
     185?>
     186<p id="footer"><a href="http://wordpress.org/">WordPress</a>, personal publishing platform.</p>
    155187</body>
    156188</html>
  • trunk/wp-admin/sidebar.php

    r3503 r4431  
    55
    66if ( ! current_user_can('edit_posts') )
    7     die ("Cheatin' uh ?");
     7    wp_die(__('Cheatin&#8217; uh?'));
    88
    99if ('b' == $_GET['a']) {
     
    4949<body id="sidebar">
    5050<h1 id="wphead"><a href="http://wordpress.org/" rel="external">WordPress</a></h1>
    51 <form name="post" action="post.php" method="POST">
     51<form name="post" action="post.php" method="post">
    5252<div><input type="hidden" name="action" value="post" />
    5353<input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" />
  • trunk/wp-admin/templates.php

    r3503 r4431  
    44$parent_file =  'edit.php';
    55
    6 $wpvarstoreset = array('action','redirect','profile','error','warning','a','file');
    7 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    8     $wpvar = $wpvarstoreset[$i];
    9     if (!isset($$wpvar)) {
    10         if (empty($_POST["$wpvar"])) {
    11             if (empty($_GET["$wpvar"])) {
    12                 $$wpvar = '';
    13             } else {
    14                 $$wpvar = $_GET["$wpvar"];
    15             }
    16         } else {
    17             $$wpvar = $_POST["$wpvar"];
    18         }
    19     }
    20 }
     6wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file'));
    217
    228$recents = get_option('recently_edited');
     
    3723case 'update':
    3824
     25    check_admin_referer('edit-file_' . $file);
     26
    3927    if ( ! current_user_can('edit_files') )
    40     die('<p>'.__('You have do not have sufficient permissions to edit templates for this blog.').'</p>');
     28        wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
    4129
    4230    $newcontent = stripslashes($_POST['newcontent']);
     
    4634            fwrite($f, $newcontent);
    4735            fclose($f);
    48             header("Location: templates.php?file=$file&a=te");
     36            wp_redirect("templates.php?file=$file&a=te");
    4937        } else {
    50             header("Location: templates.php?file=$file&a=err");
     38            wp_redirect("templates.php?file=$file&a=err");
    5139        }
    5240    } else {
    53         header("Location: templates.php?file=$file&a=err");
     41        wp_redirect("templates.php?file=$file&a=err");
    5442    }
    5543
     
    6149
    6250    require_once('./admin-header.php');
    63    
     51
    6452    if ( ! current_user_can('edit_files') )
    65     die('<p>'.__('You have do not have sufficient permissions to edit templates for this blog.').'</p>');
     53        wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
    6654
    6755    if ( strstr( $file, 'wp-config.php' ) )
    68     die('<p>'.__('The config file cannot be edited or viewed through the web interface. Sorry!').'</p>');
     56    wp_die('<p>'.__('The config file cannot be edited or viewed through the web interface. Sorry!').'</p>');
    6957
    7058    update_recently_edited($file);
     
    7260    if (!is_file($real_file))
    7361        $error = true;
    74    
     62
    7563    if (!$error) {
    7664        $f = @ fopen($real_file, 'r');
    7765        if ( $f ) {
    78             $content = fread($f, filesize($real_file));
    79             $content = htmlspecialchars($content);
     66            if ( filesize($real_file ) > 0 ) {
     67                $content = fread($f, filesize($real_file));
     68                $content = htmlspecialchars($content);
     69            } else {
     70                $content = '';
     71            }
    8072        } else {
    8173            $error = true;
     
    8981    <?php else: ?>
    9082 <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div>
    91     <?php endif; ?> 
     83    <?php endif; ?>
    9284<?php endif; ?>
    9385 <div class="wrap">
     
    10799echo '<ol>';
    108100foreach ($recents as $recent) :
    109     echo "<li><a href='templates.php?file=$recent'>" . get_file_description(basename($recent)) . "</a></li>";
     101    echo "<li><a href='templates.php?file=" . wp_specialchars($recent, true) . "'>" . get_file_description(basename($recent)) . "</a></li>";
    110102endforeach;
    111103echo '</ol>';
     
    127119<?php if (!$error) { ?>
    128120  <form name="template" id="template" action="templates.php" method="post">
     121  <?php wp_nonce_field('edit-file_' . $file) ?>
    129122     <div><textarea cols="70" rows="25" name="newcontent" id='newcontent' tabindex="1"><?php echo $content ?></textarea>
    130123     <input type="hidden" name="action" value="update" />
     
    134127     <p class="submit">
    135128<?php
    136     echo "<input type='submit' name='submit' value='    " . __('Update File') . " &raquo;' tabindex='2' />";
     129    echo "<input type='submit' name='submit' value='    " . __('Update File &raquo;') . "' tabindex='2' />";
    137130?>
    138131</p>
  • trunk/wp-admin/theme-editor.php

    r3503 r4431  
    55$parent_file = 'themes.php';
    66
    7 $wpvarstoreset = array('action','redirect','profile','error','warning','a','file', 'theme');
    8 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    9     $wpvar = $wpvarstoreset[$i];
    10     if (!isset($$wpvar)) {
    11         if (empty($_POST["$wpvar"])) {
    12             if (empty($_GET["$wpvar"])) {
    13                 $$wpvar = '';
    14             } else {
    15                 $$wpvar = $_GET["$wpvar"];
    16             }
    17         } else {
    18             $$wpvar = $_POST["$wpvar"];
    19         }
    20     }
    21 }
     7wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'theme'));
    228
    239$themes = get_themes();
     
    3117
    3218if ( ! isset($themes[$theme]) )
    33     die(__('The requested theme does not exist.'));
     19    wp_die(__('The requested theme does not exist.'));
    3420
    3521$allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']);
     
    4834case 'update':
    4935
     36    check_admin_referer('edit-theme_' . $file . $theme);
     37
    5038    if ( !current_user_can('edit_themes') )
    51     die('<p>'.__('You have do not have sufficient permissions to edit templates for this blog.').'</p>');
     39        wp_die('<p>'.__('You do not have sufficient permissions to edit templates for this blog.').'</p>');
    5240
    5341    $newcontent = stripslashes($_POST['newcontent']);
     
    5745        fwrite($f, $newcontent);
    5846        fclose($f);
    59         header("Location: theme-editor.php?file=$file&theme=$theme&a=te");
     47        $location = "theme-editor.php?file=$file&theme=$theme&a=te";
    6048    } else {
    61         header("Location: theme-editor.php?file=$file&theme=$theme");
     49        $location = "theme-editor.php?file=$file&theme=$theme";
    6250    }
    6351
     52    $location = wp_kses_no_null($location);
     53    $strip = array('%0d', '%0a');
     54    $location = str_replace($strip, '', $location);
     55    header("Location: $location");
    6456    exit();
    6557
     
    6759
    6860default:
    69    
     61
     62    if ( !current_user_can('edit_themes') )
     63        wp_die('<p>'.__('You do not have sufficient permissions to edit themes for this blog.').'</p>');
     64
    7065    require_once('admin-header.php');
    71     if ( !current_user_can('edit_themes') )
    72     die('<p>'.__('You have do not have sufficient permissions to edit themes for this blog.').'</p>');
    7366
    7467    update_recently_edited($file);
    75    
     68
    7669    if (!is_file($real_file))
    7770        $error = 1;
    78    
     71
    7972    if (!$error && filesize($real_file) > 0) {
    8073        $f = fopen($real_file, 'r');
     
    10194?>
    10295 </select>
    103  <input type="submit" name="Submit" value="<?php _e('Select') ?> &raquo;" />
     96 <input type="submit" name="Submit" value="<?php _e('Select &raquo;') ?>" class="button" />
    10497 </form>
    10598 </div>
     
    130123    ?>
    131124  <form name="template" id="template" action="theme-editor.php" method="post">
     125  <?php wp_nonce_field('edit-theme_' . $file . $theme) ?>
    132126         <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea>
    133127     <input type="hidden" name="action" value="update" />
     
    138132     <p class="submit">
    139133<?php
    140     echo "<input type='submit' name='submit' value='    " . __('Update File') . " &raquo;' tabindex='2' />";
     134    echo "<input type='submit' name='submit' value='    " . __('Update File &raquo;') . "' tabindex='2' />";
    141135?>
    142136</p>
  • trunk/wp-admin/themes.php

    r3503 r4431  
    33
    44if ( isset($_GET['action']) ) {
    5     check_admin_referer();
    6    
     5    check_admin_referer('switch-theme_' . $_GET['template']);
     6
    77    if ('activate' == $_GET['action']) {
    88        if ( isset($_GET['template']) )
    99            update_option('template', $_GET['template']);
    10        
     10
    1111        if ( isset($_GET['stylesheet']) )
    1212            update_option('stylesheet', $_GET['stylesheet']);
    13        
     13
    1414        do_action('switch_theme', get_current_theme());
    15        
    16         header('Location: themes.php?activated=true');
     15
     16        wp_redirect('themes.php?activated=true');
    1717        exit;
    1818    }
     
    7070    $screenshot = $themes[$theme_name]['Screenshot'];
    7171    $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir'];
    72     $activate_link = "themes.php?action=activate&amp;template=$template&amp;stylesheet=$stylesheet";
     72    $activate_link = wp_nonce_url("themes.php?action=activate&amp;template=$template&amp;stylesheet=$stylesheet", 'switch-theme_' . $template);
    7373?>
    7474<div class="available-theme">
     
    103103<?php
    104104    $theme = '';
    105    
     105
    106106    $theme_names = array_keys($broken_themes);
    107107    natcasesort($theme_names);
  • trunk/wp-admin/update-links.php

    r3503 r4431  
    44
    55if ( !get_option('use_linksupdate') )
    6     die(__('Feature disabled.'));
     6    wp_die(__('Feature disabled.'));
    77
    88$link_uris = $wpdb->get_col("SELECT link_url FROM $wpdb->links");
    99
    1010if ( !$link_uris )
    11     die('No links');
     11    wp_die(__('No links'));
    1212
    1313$link_uris = urlencode( join( $link_uris, "\n" ) );
     
    1717$http_request  = "POST /updated-batch/ HTTP/1.0\r\n";
    1818$http_request .= "Host: api.pingomatic.com\r\n";
    19 $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_settings('blog_charset')."\r\n";
     19$http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_option('blog_charset')."\r\n";
    2020$http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
    2121$http_request .= 'User-Agent: WordPress/' . $wp_version . "\r\n";
     
    2424
    2525$response = '';
    26 if( false !== ( $fs = fsockopen('api.pingomatic.com', 80, $errno, $errstr, 5) ) ) {
     26if ( false !== ( $fs = @fsockopen('api.pingomatic.com', 80, $errno, $errstr, 5) ) ) {
    2727    fwrite($fs, $http_request);
    2828    while ( !feof($fs) )
  • trunk/wp-admin/upgrade-functions.php

    r3503 r4431  
    11<?php
    22
     3if ( file_exists(ABSPATH . 'wp-content/install.php') )
     4    require (ABSPATH . 'wp-content/install.php');
    35require_once(ABSPATH . '/wp-admin/admin-functions.php');
     6require_once(ABSPATH . '/wp-admin/admin-db.php');
    47require_once(ABSPATH . '/wp-admin/upgrade-schema.php');
     8require_once(ABSPATH . WPINC . '/registration.php');
     9
     10if ( !function_exists('wp_install') ) :
     11function wp_install($blog_title, $user_name, $user_email, $public, $meta='') {
     12    global $wp_rewrite;
     13
     14    wp_cache_flush();
     15    make_db_current_silent();
     16    populate_options();
     17    populate_roles();
     18
     19    update_option('blogname', $blog_title);
     20    update_option('admin_email', $user_email);
     21    update_option('blog_public', $public);
     22    $schema = ( isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ) ? 'https://' : 'http://';
     23    $guessurl = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
     24    update_option('siteurl', $guessurl);
     25
     26    // If not a public blog, don't ping.
     27    if ( ! $public )
     28        update_option('default_pingback_flag', 0);
     29
     30    // Create default user.  If the user already exists, the user tables are
     31    // being shared among blogs.  Just set the role in that case.
     32    $user_id = username_exists($user_name);
     33    if ( !$user_id ) {
     34        $random_password = substr(md5(uniqid(microtime())), 0, 6);
     35        $user_id = wp_create_user($user_name, $random_password, $user_email);
     36    } else {
     37        $random_password = __('User already exists.  Password inherited.');
     38    }
     39
     40    $user = new WP_User($user_id);
     41    $user->set_role('administrator');
     42
     43    wp_install_defaults($user_id);
     44
     45    $wp_rewrite->flush_rules();
     46
     47    wp_new_blog_notification($blog_title, $guessurl, $user_id, $random_password);
     48
     49    wp_cache_flush();
     50
     51    return array('url' => $guessurl, 'user_id' => $user_id, 'password' => $random_password);
     52}
     53endif;
     54
     55if ( !function_exists('wp_install_defaults') ) :
     56function wp_install_defaults($user_id) {
     57    global $wpdb;
     58
     59    // Default category
     60    $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_count, category_description) VALUES ('0', '".$wpdb->escape(__('Uncategorized'))."', '".sanitize_title(__('Uncategorized'))."', '1', '')");
     61
     62    // Default link category
     63    $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, link_count, category_description) VALUES ('0', '".$wpdb->escape(__('Blogroll'))."', '".sanitize_title(__('Blogroll'))."', '7', '')");
     64
     65    // Now drop in some default links
     66    $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://inphotos.org/', 'Donncha', 0, 'http://inphotos.org/feed/', '');");
     67    $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (1, 2)" );
     68
     69    $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zengun.org/weblog/', 'Michel', 0, 'http://zengun.org/weblog/feed/', '');");
     70    $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (2, 2)" );
     71
     72    $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://boren.nu/', 'Ryan', 0, 'http://boren.nu/feed/', '');");
     73    $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (3, 2)" );
     74
     75    $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://photomatt.net/', 'Matt', 0, 'http://xml.photomatt.net/feed/', '');");
     76    $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (4, 2)" );
     77
     78    $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://zed1.com/journalized/', 'Mike', 0, 'http://zed1.com/journalized/feed/', '');");
     79    $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (5, 2)" );
     80
     81    $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://www.alexking.org/', 'Alex', 0, 'http://www.alexking.org/blog/wp-rss2.php', '');");
     82    $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (6, 2)" );
     83
     84    $wpdb->query("INSERT INTO $wpdb->links (link_url, link_name, link_category, link_rss, link_notes) VALUES ('http://dougal.gunters.org/', 'Dougal', 0, 'http://dougal.gunters.org/feed/', '');");
     85    $wpdb->query( "INSERT INTO $wpdb->link2cat (`link_id`, `category_id`) VALUES (7, 2)" );
     86
     87    // First post
     88    $now = date('Y-m-d H:i:s');
     89    $now_gmt = gmdate('Y-m-d H:i:s');
     90    $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, comment_count, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'))."', '', '".$wpdb->escape(__('Hello world!'))."', '0', '".$wpdb->escape(__('hello-world'))."', '$now', '$now_gmt', '1', '', '', '')");
     91
     92    $wpdb->query( "INSERT INTO $wpdb->post2cat (`rel_id`, `post_id`, `category_id`) VALUES (1, 1, 1)" );
     93
     94    // Default comment
     95    $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_date, comment_date_gmt, comment_content) VALUES ('1', '".$wpdb->escape(__('Mr WordPress'))."', '', 'http://wordpress.org/', '$now', '$now_gmt', '".$wpdb->escape(__('Hi, this is a comment.<br />To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.'))."')");
     96
     97    // First Page
     98    $wpdb->query("INSERT INTO $wpdb->posts (post_author, post_date, post_date_gmt, post_content, post_excerpt, post_title, post_category, post_name, post_modified, post_modified_gmt, post_status, post_type, to_ping, pinged, post_content_filtered) VALUES ($user_id, '$now', '$now_gmt', '".$wpdb->escape(__('This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress.'))."', '', '".$wpdb->escape(__('About'))."', '0', '".$wpdb->escape(__('about'))."', '$now', '$now_gmt', 'publish', 'page', '', '', '')");
     99}
     100endif;
     101
     102if ( !function_exists('wp_new_blog_notification') ) :
     103function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) {
     104    $user = new WP_User($user_id);
     105    $email = $user->user_email;
     106    $name = $user->user_login;
     107    $message_headers = 'From: "' . $blog_title . '" <wordpress@' . $_SERVER['SERVER_NAME'] . '>';
     108    $message = sprintf(__("Your new WordPress blog has been successfully set up at:
     109
     110%1\$s
     111
     112You can log in to the administrator account with the following information:
     113
     114Username: %2\$s
     115Password: %3\$s
     116
     117We hope you enjoy your new weblog. Thanks!
     118
     119--The WordPress Team
     120http://wordpress.org/
     121"), $blog_url, $name, $password);
     122
     123    @wp_mail($email, __('New WordPress Blog'), $message, $message_headers);
     124}
     125endif;
     126
     127if ( !function_exists('wp_upgrade') ) :
     128function wp_upgrade() {
     129    global $wp_current_db_version, $wp_db_version;
     130
     131    $wp_current_db_version = __get_option('db_version');
     132
     133    // We are up-to-date.  Nothing to do.
     134    if ( $wp_db_version == $wp_current_db_version )
     135        return;
     136
     137    wp_cache_flush();
     138    make_db_current_silent();
     139    upgrade_all();
     140    wp_cache_flush();   
     141}
     142endif;
     143
    5144// Functions to be called in install and upgrade scripts
    6145function upgrade_all() {
     
    21160            $wp_current_db_version = 2541;
    22161    }
    23    
     162
    24163    populate_options();
    25164
     
    30169        upgrade_130();
    31170    }
    32    
     171
    33172    if ( $wp_current_db_version < 3308 )
    34173        upgrade_160();
    35174
     175    if ( $wp_current_db_version < 3845 )
     176        upgrade_210();
     177
    36178    $wp_rewrite->flush_rules();
    37    
     179
    38180    update_option('db_version', $wp_db_version);
    39181}
     
    52194        }
    53195    }
    54    
     196
    55197    $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories");
    56198    foreach ($categories as $category) {
     
    75217        $catwhere = '';
    76218    endif;
    77    
     219
    78220    $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere");
    79221    if ($allposts) :
     
    109251function upgrade_110() {
    110252    global $wpdb;
    111    
     253
    112254    // Set user_nicename.
    113255    $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users");
     
    164306
    165307function upgrade_130() {
    166     global $wpdb, $table_prefix;
     308    global $wpdb;
    167309
    168310    // Remove extraneous backslashes.
     
    217359
    218360    // Obsolete tables
    219     $wpdb->query('DROP TABLE IF EXISTS ' . $table_prefix . 'optionvalues');
    220     $wpdb->query('DROP TABLE IF EXISTS ' . $table_prefix . 'optiontypes');
    221     $wpdb->query('DROP TABLE IF EXISTS ' . $table_prefix . 'optiongroups');
    222     $wpdb->query('DROP TABLE IF EXISTS ' . $table_prefix . 'optiongroup_options');
     361    $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optionvalues');
     362    $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiontypes');
     363    $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroups');
     364    $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'optiongroup_options');
    223365
    224366    // Update comments table to use comment_type
     
    241383
    242384function upgrade_160() {
    243     global $wpdb, $table_prefix, $wp_current_db_version;
     385    global $wpdb, $wp_current_db_version;
    244386
    245387    populate_roles_160();
     
    254396            update_usermeta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) );
    255397        if ( !empty( $user->user_level ) )
    256             update_usermeta( $user->ID, $table_prefix . 'user_level', $user->user_level );
     398            update_usermeta( $user->ID, $wpdb->prefix . 'user_level', $user->user_level );
    257399        if ( !empty( $user->user_icq ) )
    258400            update_usermeta( $user->ID, 'icq', $wpdb->escape($user->user_icq) );
     
    278420            $wpdb->query("UPDATE $wpdb->users SET display_name = '$id' WHERE ID = '$user->ID'");
    279421        endif;
    280        
     422
    281423        // FIXME: RESET_CAPS is temporary code to reset roles and caps if flag is set.
    282         $caps = get_usermeta( $user->ID, $table_prefix . 'capabilities');
     424        $caps = get_usermeta( $user->ID, $wpdb->prefix . 'capabilities');
    283425        if ( empty($caps) || defined('RESET_CAPS') ) {
    284             $level = get_usermeta($user->ID, $table_prefix . 'user_level');
     426            $level = get_usermeta($user->ID, $wpdb->prefix . 'user_level');
    285427            $role = translate_level_to_role($level);
    286             update_usermeta( $user->ID, $table_prefix . 'capabilities', array($role => true) );
    287         }
    288            
     428            update_usermeta( $user->ID, $wpdb->prefix . 'capabilities', array($role => true) );
     429        }
     430
    289431    endforeach;
    290432    $old_user_fields = array( 'user_firstname', 'user_lastname', 'user_icq', 'user_aim', 'user_msn', 'user_yim', 'user_idmode', 'user_ip', 'user_domain', 'user_browser', 'user_description', 'user_nickname', 'user_level' );
     
    293435        $wpdb->query("ALTER TABLE $wpdb->users DROP $old");
    294436    $wpdb->show_errors();
    295    
     437
    296438    if ( 0 == $wpdb->get_var("SELECT SUM(category_count) FROM $wpdb->categories") ) { // Create counts
    297439        $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
     
    319461            post_type = ''
    320462            WHERE ID = $object->ID");
    321            
     463
    322464            $meta = get_post_meta($object->ID, 'imagedata', true);
    323465            if ( ! empty($meta['file']) )
    324466                add_post_meta($object->ID, '_wp_attached_file', $meta['file']);
     467        }
     468    }
     469}
     470
     471function upgrade_210() {
     472    global $wpdb, $wp_current_db_version;
     473
     474    if ( $wp_current_db_version < 3506 ) {
     475        // Update status and type.
     476        $posts = $wpdb->get_results("SELECT ID, post_status FROM $wpdb->posts");
     477
     478        if ( ! empty($posts) ) foreach ($posts as $post) {
     479            $status = $post->post_status;
     480            $type = 'post';
     481
     482            if ( 'static' == $status ) {
     483                $status = 'publish';
     484                $type = 'page';
     485            } else if ( 'attachment' == $status ) {
     486                $status = 'inherit';
     487                $type = 'attachment';
     488            }
     489
     490            $wpdb->query("UPDATE $wpdb->posts SET post_status = '$status', post_type = '$type' WHERE ID = '$post->ID'");
     491        }
     492    }
     493
     494    if ( $wp_current_db_version < 3845 ) {
     495        populate_roles_210();
     496    }
     497
     498    if ( $wp_current_db_version < 3531 ) {
     499        // Give future posts a post_status of future.
     500        $now = gmdate('Y-m-d H:i:59');
     501        $wpdb->query ("UPDATE $wpdb->posts SET post_status = 'future' WHERE post_status = 'publish' AND post_date_gmt > '$now'");
     502       
     503        $posts = $wpdb->get_results("SELECT ID, post_date FROM $wpdb->posts WHERE post_status ='future'");
     504        if ( !empty($posts) )
     505            foreach ( $posts as $post )
     506                wp_schedule_single_event(mysql2date('U', $post->post_date), 'publish_future_post', array($post->ID));
     507    }
     508    if ( $wp_current_db_version < 3570 ) {
     509        // Create categories for link categories if a category with the same
     510        // name doesn't exist.  Create a map of link cat IDs to cat IDs.
     511        $link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories"); 
     512        foreach ( $link_cats as $link_cat) {
     513            if ( $cat_id = category_exists($link_cat->cat_name) ) {
     514                $link_cat_id_map[$link_cat->cat_id] = $cat_id;
     515                $default_link_cat = $cat_id;
     516            } else {
     517                $link_cat_id_map[$link_cat->cat_id] = wp_create_category($link_cat->cat_name);
     518                $default_link_cat = $link_cat_id_map[$link_cat->cat_id];
     519            }
     520        }
     521
     522        // Associate links to cats.
     523        $links = $wpdb->get_results("SELECT link_id, link_category FROM $wpdb->links");
     524        if ( !empty($links) ) foreach ( $links as $link ) {
     525            $link_cat = $link_cat_id_map[$link->link_category];
     526            $cat = $wpdb->get_row("SELECT * FROM $wpdb->link2cat WHERE link_id = '$link->link_id' AND category_id = '$link_cat'");
     527            if (!$cat && 0 != $link->link_category) {
     528                $wpdb->query("INSERT INTO $wpdb->link2cat (link_id, category_id)
     529                    VALUES ('$link->link_id', '$link_cat')");
     530            }           
     531        }
     532       
     533        // Set default to the last category we grabbed during the upgrade loop.
     534        update_option('default_link_category', $default_link_cat);
     535
     536        // Count links per category.
     537        if ( 0 == $wpdb->get_var("SELECT SUM(link_count) FROM $wpdb->categories") ) {
     538            $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
     539            foreach ( $categories as $cat_id ) {
     540                $count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->link2cat, $wpdb->links WHERE $wpdb->links.link_id = $wpdb->link2cat.link_id AND category_id = '$cat_id'");
     541                $wpdb->query("UPDATE $wpdb->categories SET link_count = '$count' WHERE cat_ID = '$cat_id'");
     542            }
    325543        }
    326544    }
     
    447665function dbDelta($queries, $execute = true) {
    448666    global $wpdb;
    449    
     667
    450668    // Seperate individual queries into an array
    451669    if( !is_array($queries) ) {
     
    453671        if('' == $queries[count($queries) - 1]) array_pop($queries);
    454672    }
    455    
     673
    456674    $cqueries = array(); // Creation Queries
    457675    $iqueries = array(); // Insertion Queries
    458676    $for_update = array();
    459    
     677
    460678    // Create a tablename index for an array ($cqueries) of queries
    461679    foreach($queries as $qry) {
     
    476694            // Unrecognized query type
    477695        }
    478     }   
     696    }
    479697
    480698    // Check to see which tables and fields exist
     
    495713
    496714                //echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>";
    497                
     715
    498716                // For every field line specified in the query
    499717                foreach($flds as $fld) {
     
    501719                    preg_match("|^([^ ]*)|", trim($fld), $fvals);
    502720                    $fieldname = $fvals[1];
    503                    
     721
    504722                    // Verify the found field name
    505723                    $validfield = true;
     
    517735                    }
    518736                    $fld = trim($fld);
    519                    
     737
    520738                    // If it's a valid field, add it to the field array
    521739                    if($validfield) {
     
    523741                    }
    524742                }
    525                
     743
    526744                // Fetch the table column structure from the database
    527745                $tablefields = $wpdb->get_results("DESCRIBE {$table};");
    528                                
     746
    529747                // For every field in the table
    530                 foreach($tablefields as $tablefield) {             
     748                foreach($tablefields as $tablefield) {
    531749                    // If the table field exists in the field array...
    532750                    if(array_key_exists(strtolower($tablefield->Field), $cfields)) {
     
    541759                            $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}";
    542760                        }
    543                        
     761
    544762                        // Get the default value from the array
    545763                            //echo "{$cfields[strtolower($tablefield->Field)]}<br>";
     
    568786                    $for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname;
    569787                }
    570                
     788
    571789                // Index stuff goes here
    572790                // Fetch the table index structure from the database
    573791                $tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};");
    574                
     792
    575793                if($tableindices) {
    576794                    // Clear the index array
     
    601819                        $index_columns = '';
    602820                        // For each column in the index
    603                         foreach($index_data['columns'] as $column_data) {                   
     821                        foreach($index_data['columns'] as $column_data) {
    604822                            if($index_columns != '') $index_columns .= ',';
    605823                            // Add the field to the column list string
  • trunk/wp-admin/upgrade-schema.php

    r3503 r4431  
    99  category_parent bigint(20) NOT NULL default '0',
    1010  category_count bigint(20) NOT NULL default '0',
     11  link_count bigint(20) NOT NULL default '0',
     12  posts_private tinyint(1) NOT NULL default '0',
     13  links_private tinyint(1) NOT NULL default '0',
    1114  PRIMARY KEY  (cat_ID),
    1215  KEY category_nicename (category_nicename)
     
    3235  KEY comment_post_ID (comment_post_ID)
    3336);
    34 CREATE TABLE $wpdb->linkcategories (
    35   cat_id bigint(20) NOT NULL auto_increment,
    36   cat_name tinytext NOT NULL,
    37   auto_toggle enum('Y','N') NOT NULL default 'N',
    38   show_images enum('Y','N') NOT NULL default 'Y',
    39   show_description enum('Y','N') NOT NULL default 'N',
    40   show_rating enum('Y','N') NOT NULL default 'Y',
    41   show_updated enum('Y','N') NOT NULL default 'Y',
    42   sort_order varchar(64) NOT NULL default 'rand',
    43   sort_desc enum('Y','N') NOT NULL default 'N',
    44   text_before_link varchar(128) NOT NULL default '<li>',
    45   text_after_link varchar(128) NOT NULL default '<br />',
    46   text_after_all varchar(128) NOT NULL default '</li>',
    47   list_limit int(11) NOT NULL default '-1',
    48   PRIMARY KEY  (cat_id)
     37CREATE TABLE $wpdb->link2cat (
     38  rel_id bigint(20) NOT NULL auto_increment,
     39  link_id bigint(20) NOT NULL default '0',
     40  category_id bigint(20) NOT NULL default '0',
     41  PRIMARY KEY  (rel_id),
     42  KEY link_id (link_id,category_id)
    4943);
    5044CREATE TABLE $wpdb->links (
     
    107101  post_category int(4) NOT NULL default '0',
    108102  post_excerpt text NOT NULL,
    109   post_status enum('publish','draft','private','static','object','attachment') NOT NULL default 'publish',
     103  post_status enum('publish','draft','private','static','object','attachment','inherit','future') NOT NULL default 'publish',
    110104  comment_status enum('open','closed','registered_only') NOT NULL default 'open',
    111105  ping_status enum('open','closed') NOT NULL default 'open',
     
    120114  guid varchar(255) NOT NULL default '',
    121115  menu_order int(11) NOT NULL default '0',
    122   post_type varchar(100) NOT NULL default '',
     116  post_type varchar(20) NOT NULL default 'post',
    123117  post_mime_type varchar(100) NOT NULL default '',
    124118  comment_count bigint(20) NOT NULL default '0',
    125119  PRIMARY KEY  (ID),
    126   KEY post_name (post_name)
     120  KEY post_name (post_name),
     121  KEY type_status_date (post_type,post_status,post_date,ID)
    127122);
    128123CREATE TABLE $wpdb->users (
     
    212207    add_option('blacklist_keys');
    213208    add_option('comment_registration', 0);
    214     add_option('open_proxy_check', 1);
    215209    add_option('rss_language', 'en');
    216210    add_option('html_type', 'text/html');
     
    230224        add_option('upload_path', 'wp-content/uploads');
    231225    }
     226   
     227    // 2.0.3
     228    add_option('secret', md5(uniqid(microtime())));
     229
     230    // 2.1
     231    add_option('blog_public', '1');
     232    add_option('default_link_category', 2);
     233    add_option('show_on_front', 'posts');
    232234
    233235    // Delete unused options
    234     $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog');
     236    $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action');
    235237    foreach ($unusedoptions as $option) :
    236238        delete_option($option);
     
    245247
    246248function populate_roles() {
    247     populate_roles_160();   
     249    populate_roles_160();
     250    populate_roles_210();
    248251}
    249252
     
    257260    add_role('contributor', __('Contributor'));
    258261    add_role('subscriber', __('Subscriber'));
    259    
     262
    260263    // Add caps for Administrator role
    261264    $role = get_role('administrator');
     
    290293    $role->add_cap('level_1');
    291294    $role->add_cap('level_0');
    292    
     295
    293296    // Add caps for Editor role
    294297    $role = get_role('editor');
     
    312315    $role->add_cap('level_1');
    313316    $role->add_cap('level_0');
    314    
     317
    315318    // Add caps for Author role
    316319    $role = get_role('author');
     
    323326    $role->add_cap('level_1');
    324327    $role->add_cap('level_0');
    325    
     328
    326329    // Add caps for Contributor role
    327330    $role = get_role('contributor');
     
    330333    $role->add_cap('level_1');
    331334    $role->add_cap('level_0');
    332    
     335
    333336    // Add caps for Subscriber role
    334337    $role = get_role('subscriber');
     
    337340}
    338341
     342function populate_roles_210() {
     343    $roles = array('administrator', 'editor');
     344    foreach ($roles as $role) {
     345        $role = get_role($role);
     346        if ( empty($role) )
     347            continue;
     348
     349        $role->add_cap('edit_others_pages');
     350        $role->add_cap('edit_published_pages');
     351        $role->add_cap('publish_pages');
     352        $role->add_cap('delete_pages');
     353        $role->add_cap('delete_others_pages');
     354        $role->add_cap('delete_published_pages');
     355        $role->add_cap('delete_posts');
     356        $role->add_cap('delete_others_posts');
     357        $role->add_cap('delete_published_posts');
     358        $role->add_cap('delete_private_posts');
     359        $role->add_cap('edit_private_posts');
     360        $role->add_cap('read_private_posts');
     361        $role->add_cap('delete_private_pages');
     362        $role->add_cap('edit_private_pages');
     363        $role->add_cap('read_private_pages');
     364    }
     365
     366    $role = get_role('administrator');
     367    if ( ! empty($role) ) {
     368        $role->add_cap('delete_users');
     369        $role->add_cap('create_users');
     370    }
     371
     372    $role = get_role('author');
     373    if ( ! empty($role) ) {
     374        $role->add_cap('delete_posts');
     375        $role->add_cap('delete_published_posts');
     376    }
     377
     378    $role = get_role('contributor');
     379    if ( ! empty($role) ) {
     380        $role->add_cap('delete_posts');
     381    }
     382}
     383
    339384?>
  • trunk/wp-admin/upgrade.php

    r3503 r4431  
    11<?php
    22define('WP_INSTALLING', true);
    3 if (!file_exists('../wp-config.php')) die("There doesn't seem to be a wp-config.php file. Double check that you updated wp-config-sample.php with the proper database connection information and renamed it to wp-config.php.");
     3if (!file_exists('../wp-config.php'))
     4    die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://codex.wordpress.org/Installing_WordPress#Step_3:_Set_up_wp-config.php'>We got it</a>. You can <a href='setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.");
     5
    46require('../wp-config.php');
    57timer_start();
    68require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
    79
    8 $step = $_GET['step'];
    9 if (!$step) $step = 0;
    10 header( 'Content-Type: text/html; charset=utf-8' );
     10if (isset($_GET['step']))
     11    $step = $_GET['step'];
     12else
     13    $step = 0;
     14@header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    1115?>
    1216<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    13 <html xmlns="http://www.w3.org/1999/xhtml">
     17<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
    1418<head>
    15     <title>WordPress &rsaquo; Upgrade</title>
    16     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    17     <style media="screen" type="text/css">
    18     <!--
    19     html {
    20         background: #eee;
    21     }
    22     body {
    23         background: #fff;
    24         color: #000;
    25         font-family: Georgia, "Times New Roman", Times, serif;
    26         margin-left: 20%;
    27         margin-right: 20%;
    28         padding: .2em 2em;
    29     }
    30    
    31     h1 {
    32         color: #006;
    33         font-size: 18px;
    34         font-weight: lighter;
    35     }
    36    
    37     h2 {
    38         font-size: 16px;
    39     }
    40    
    41     p, li, dt {
    42         line-height: 140%;
    43         padding-bottom: 2px;
    44     }
    45 
    46     ul, ol {
    47         padding: 5px 5px 5px 20px;
    48     }
    49     #logo {
    50         margin-bottom: 2em;
    51     }
    52 .step a, .step input {
    53     font-size: 2em;
    54 }
    55 .step, th {
    56     text-align: right;
    57 }
    58 #footer {
    59 text-align: center; border-top: 1px solid #ccc; padding-top: 1em; font-style: italic;
    60 }
    61     -->
    62     </style>
     19    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
     20    <title><?php _e('WordPress &rsaquo; Upgrade'); ?></title>
     21    <link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/install.css?version=<?php bloginfo('version'); ?>" type="text/css" />
     22    <?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
     23    <link rel="stylesheet" href="<?php echo get_option('siteurl') ?>/wp-admin/install-rtl.css?version=<?php bloginfo('version'); ?>" type="text/css" />
     24    <?php endif; ?>
    6325</head>
    6426<body>
     
    6628<?php
    6729switch($step) {
    68 
    6930    case 0:
    70     $goback = wp_specialchars($_SERVER['HTTP_REFERER'], 1);
     31        $goback = wp_specialchars(wp_get_referer());
    7132?>
    7233<p><?php _e('This file upgrades you from any previous version of WordPress to the latest. It may take a while though, so be patient.'); ?></p>
    73     <h2 class="step"><a href="upgrade.php?step=1&amp;backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress &raquo;'); ?></a></h2>
     34<h2 class="step"><a href="upgrade.php?step=1&amp;backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress &raquo;'); ?></a></h2>
    7435<?php
    75     break;
    76    
     36        break;
    7737    case 1:
    78     wp_cache_flush();
    79     make_db_current_silent();
    80     upgrade_all();
    81     wp_cache_flush();
     38        wp_upgrade();
    8239
    83     if ( empty( $_GET['backto'] ) )
    84         $backto = __get_option('home');
    85     else
    86         $backto = wp_specialchars( $_GET['backto'] , 1 );
     40        if ( empty( $_GET['backto'] ) )
     41            $backto = __get_option('home');
     42        else
     43            $backto = wp_specialchars( $_GET['backto'] , 1 );
    8744?>
    8845<h2><?php _e('Step 1'); ?></h2>
     
    9855
    9956<?php
    100     break;
     57        break;
    10158}
    10259?>
  • trunk/wp-admin/user-edit.php

    r3503 r4431  
    33
    44$title = __('Edit User');
    5 $parent_file = 'profile.php';   
     5if ( current_user_can('edit_users') )
     6    $parent_file = 'users.php';
     7else
     8    $parent_file = 'profile.php';
    69$submenu_file = 'users.php';
    710
    8 $wpvarstoreset = array('action', 'redirect', 'profile', 'user_id');
    9 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    10     $wpvar = $wpvarstoreset[$i];
    11     if (!isset($$wpvar)) {
    12         if (empty($_POST["$wpvar"])) {
    13             if (empty($_GET["$wpvar"])) {
    14                 $$wpvar = '';
    15             } else {
    16                 $$wpvar = $_GET["$wpvar"];
    17             }
    18         } else {
    19             $$wpvar = $_POST["$wpvar"];
    20         }
    21     }
    22 }
     11wp_reset_vars(array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer'));
     12
     13$wp_http_referer = remove_query_arg(array('update', 'delete_count'), stripslashes($wp_http_referer));
     14
     15$user_id = (int) $user_id;
     16
     17if ( !$user_id )
     18    wp_die(__('Invalid user ID.'));
    2319
    2420switch ($action) {
     
    3329case 'update':
    3430
    35 $errors = array();
    36 
    37 if (!current_user_can('edit_users'))
    38     $errors['head'] = __('You do not have permission to edit this user.');
    39 else
    40     $errors = edit_user($user_id);
    41 
    42 if(count($errors) == 0) {
    43     header("Location: user-edit.php?user_id=$user_id&updated=true");
     31check_admin_referer('update-user_' . $user_id);
     32
     33if ( !current_user_can('edit_user', $user_id) )
     34    wp_die(__('You do not have permission to edit this user.'));
     35
     36$errors = edit_user($user_id);
     37
     38if( !is_wp_error( $errors ) ) {
     39    $redirect = "user-edit.php?user_id=$user_id&updated=true";
     40    $redirect = add_query_arg('wp_http_referer', urlencode($wp_http_referer), $redirect);
     41    wp_redirect($redirect);
    4442    exit;
    4543}
    4644
    4745default:
     46$profileuser = get_user_to_edit($user_id);
     47
     48if ( !current_user_can('edit_user', $user_id) )
     49        wp_die(__('You do not have permission to edit this user.'));
     50
    4851include ('admin-header.php');
    49 
    50 $profileuser = new WP_User($user_id);
    51 
    52 if (!current_user_can('edit_users')) $errors['head'] = __('You do not have permission to edit this user.');
    5352?>
    5453
     
    5655<div id="message" class="updated fade">
    5756    <p><strong><?php _e('User updated.') ?></strong></p>
     57    <?php if ( $wp_http_referer ) : ?>
     58    <p><a href="<?php echo wp_specialchars($wp_http_referer); ?>"><?php _e('&laquo; Back to Authors and Users'); ?></a></p>
     59    <?php endif; ?>
    5860</div>
    5961<?php endif; ?>
    60 <?php if ( count($errors) != 0 ) : ?>
     62<?php if ( is_wp_error( $errors ) ) : ?>
    6163<div class="error">
    6264    <ul>
    6365    <?php
    64     foreach($errors as $error) echo "<li>$error</li>";
     66    foreach( $errors->get_error_messages() as $message )
     67        echo "<li>$message</li>";
    6568    ?>
    6669    </ul>
     
    7275
    7376<form name="profile" id="your-profile" action="user-edit.php" method="post">
     77<?php wp_nonce_field('update-user_' . $user_id) ?>
     78<?php if ( $wp_http_referer ) : ?>
     79    <input type="hidden" name="wp_http_referer" value="<?php echo wp_specialchars($wp_http_referer); ?>" />
     80<?php endif; ?>
    7481<p>
    7582<input type="hidden" name="from" value="profile" />
     
    8794// print_r($profileuser);
    8895echo '<select name="role">';
     96$role_list = '';
     97$user_has_role = false;
    8998foreach($wp_roles->role_names as $role => $name) {
    90     $selected = ($profileuser->has_cap($role)) ? ' selected="selected"' : '';
    91     echo "<option value=\"{$role}\"{$selected}>{$name}</option>";
     99    if ( $profileuser->has_cap($role) ) {
     100        $selected = ' selected="selected"';
     101        $user_has_role = true;
     102    } else {
     103        $selected = '';
     104    }
     105    $role_list .= "<option value=\"{$role}\"{$selected}>{$name}</option>";
    92106}
    93 echo '</select>';
     107if ( $user_has_role )
     108    $role_list .= '<option value="">' . __('&mdash; No role for this blog &mdash;') . '</option>';
     109else
     110    $role_list .= '<option value="" selected="selected">' . __('&mdash; No role for this blog &mdash;') . '</option>';
     111echo $role_list . '</select>';
    94112?></label></p>
    95113
  • trunk/wp-admin/users.php

    r3503 r4431  
    11<?php
    22require_once('admin.php');
    3 require_once( ABSPATH . WPINC . '/registration-functions.php');
     3require_once( ABSPATH . WPINC . '/registration.php');
    44
    55$title = __('Users');
    6 $parent_file = 'profile.php';
    7    
     6if ( current_user_can('edit_users') )
     7    $parent_file = 'users.php';
     8else
     9    $parent_file = 'profile.php';
     10
    811$action = $_REQUEST['action'];
    912$update = '';
    1013
     14if ( empty($_POST) ) {
     15    $referer = '<input type="hidden" name="wp_http_referer" value="'. wp_specialchars(stripslashes($_SERVER['REQUEST_URI'])) . '" />';
     16} elseif ( isset($_POST['wp_http_referer']) ) {
     17    $redirect = remove_query_arg(array('wp_http_referer', 'updated', 'delete_count'), urlencode(stripslashes($_POST['wp_http_referer'])));
     18    $referer = '<input type="hidden" name="wp_http_referer" value="' . wp_specialchars($redirect) . '" />';
     19} else {
     20    $redirect = 'users.php';
     21}
     22
     23
     24// WP_User_Search class
     25// by Mark Jaquith
     26
     27
     28class WP_User_Search {
     29    var $results;
     30    var $search_term;
     31    var $page;
     32    var $raw_page;
     33    var $users_per_page = 50;
     34    var $first_user;
     35    var $last_user;
     36    var $query_limit;
     37    var $query_from_where;
     38    var $total_users_for_query = 0;
     39    var $too_many_total_users = false;
     40    var $search_errors;
     41
     42    function WP_User_Search ($search_term = '', $page = '') { // constructor
     43        $this->search_term = $search_term;
     44        $this->raw_page = ( '' == $page ) ? false : (int) $page;
     45        $this->page = (int) ( '' == $page ) ? 1 : $page;
     46
     47        $this->prepare_query();
     48        $this->query();
     49        $this->prepare_vars_for_template_usage();
     50        $this->do_paging();
     51    }
     52
     53    function prepare_query() {
     54        global $wpdb;
     55        $this->first_user = ($this->page - 1) * $this->users_per_page;
     56        $this->query_limit = 'LIMIT ' . $this->first_user . ',' . $this->users_per_page;
     57        if ( $this->search_term ) {
     58            $searches = array();
     59            $search_sql = 'AND (';
     60            foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col )
     61                $searches[] = $col . " LIKE '%$this->search_term%'";
     62            $search_sql .= implode(' OR ', $searches);
     63            $search_sql .= ')';
     64        }
     65        $this->query_from_where = "FROM $wpdb->users WHERE 1=1 $search_sql";
     66
     67    }
     68
     69    function query() {
     70        global $wpdb;
     71        $this->results = $wpdb->get_col('SELECT ID ' . $this->query_from_where . $this->query_limit);
     72
     73        if ( $this->results )
     74            $this->total_users_for_query = $wpdb->get_var('SELECT COUNT(ID) ' . $this->query_from_where); // no limit
     75        else
     76            $this->search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!'));
     77    }
     78
     79    function prepare_vars_for_template_usage() {
     80        $this->search_term = stripslashes($this->search_term); // done with DB, from now on we want slashes gone
     81    }
     82
     83    function do_paging() {
     84        if ( $this->total_users_for_query > $this->users_per_page ) { // have to page the results
     85            $this->paging_text = paginate_links( array(
     86                'total' => ceil($this->total_users_for_query / $this->users_per_page),
     87                'current' => $this->page,
     88                'prev_text' => '&laquo; Previous Page',
     89                'next_text' => 'Next Page &raquo;',
     90                'base' => 'users.php?%_%',
     91                'format' => 'userspage=%#%',
     92                'add_args' => array( 'usersearch' => urlencode($this->search_term) )
     93            ) );
     94        }
     95    }
     96
     97    function get_results() {
     98        return (array) $this->results;
     99    }
     100
     101    function page_links() {
     102        echo $this->paging_text;
     103    }
     104
     105    function results_are_paged() {
     106        if ( $this->paging_text )
     107            return true;
     108        return false;
     109    }
     110
     111    function is_search() {
     112        if ( $this->search_term )
     113            return true;
     114        return false;
     115    }
     116}
     117
     118
    11119switch ($action) {
    12120
    13121case 'promote':
    14     check_admin_referer();
     122    check_admin_referer('bulk-users');
    15123
    16124    if (empty($_POST['users'])) {
    17         header('Location: users.php');
     125        wp_redirect($redirect);
    18126    }
    19127
    20128    if ( !current_user_can('edit_users') )
    21         die(__('You can&#8217;t edit users.'));
    22 
    23     $userids = $_POST['users'];
     129        wp_die(__('You can&#8217;t edit users.'));
     130
     131    $userids = $_POST['users'];
    24132    $update = 'promote';
    25     foreach($userids as $id) {
     133    foreach($userids as $id) {
     134        if ( ! current_user_can('edit_user', $id) )
     135            wp_die(__('You can&#8217;t edit that user.'));
    26136        // The new role of the current user must also have edit_users caps
    27137        if($id == $current_user->id && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) {
     
    30140        }
    31141
    32         $user = new WP_User($id);
    33         $user->set_role($_POST['new_role']);
    34     }
    35        
    36     header('Location: users.php?update=' . $update);
     142        $user = new WP_User($id);
     143        $user->set_role($_POST['new_role']);
     144    }
     145
     146    wp_redirect(add_query_arg('update', $update, $redirect));
    37147
    38148break;
     
    40150case 'dodelete':
    41151
    42     check_admin_referer();
     152    check_admin_referer('delete-users');
    43153
    44154    if ( empty($_POST['users']) ) {
    45         header('Location: users.php');
    46     }
    47 
    48     if ( !current_user_can('edit_users') )
    49         die(__('You can&#8217;t delete users.'));
     155        wp_redirect($redirect);
     156    }
     157
     158    if ( !current_user_can('delete_users') )
     159        wp_die(__('You can&#8217;t delete users.'));
    50160
    51161    $userids = $_POST['users'];
    52    
    53162    $update = 'del';
    54     foreach ($userids as $id) {
     163    $delete_count = 0;
     164
     165    foreach ( (array) $userids as $id) {
     166        if ( ! current_user_can('delete_user', $id) )
     167            wp_die(__('You can&#8217;t delete that user.'));
     168
    55169        if($id == $current_user->id) {
    56170            $update = 'err_admin_del';
    57171            continue;
    58172        }
    59         switch($_POST['delete_option']) {
     173        switch($_POST['delete_option']) {
    60174        case 'delete':
    61175            wp_delete_user($id);
     
    65179            break;
    66180        }
    67     }
    68 
    69     header('Location: users.php?update=' . $update);
     181        ++$delete_count;
     182    }
     183
     184    $redirect = add_query_arg('delete_count', $delete_count, $redirect);
     185
     186    wp_redirect(add_query_arg('update', $update, $redirect));
    70187
    71188break;
     
    73190case 'delete':
    74191
    75     check_admin_referer();
    76 
    77     if (empty($_POST['users'])) {
    78         header('Location: users.php');
    79     }
    80 
    81     if ( !current_user_can('edit_users') )
    82         $error['edit_users'] = __('You can&#8217;t delete users.');
     192    check_admin_referer('bulk-users');
     193
     194    if ( empty($_POST['users']) )
     195        wp_redirect($redirect);
     196
     197    if ( !current_user_can('delete_users') )
     198        $errors = new WP_Error('edit_users', __('You can&#8217;t delete users.'));
    83199
    84200    $userids = $_POST['users'];
     
    87203?>
    88204<form action="" method="post" name="updateusers" id="updateusers">
     205<?php wp_nonce_field('delete-users') ?>
     206<?php echo $referer; ?>
    89207<div class="wrap">
    90208<h2><?php _e('Delete Users'); ?></h2>
     
    93211<?php
    94212    $go_delete = false;
    95     foreach ($userids as $id) {
    96         $user = new WP_User($id);
    97         if ($id == $current_user->id) {
     213    foreach ( (array) $userids as $id ) {
     214        $user = new WP_User($id);
     215        if ( $id == $current_user->id ) {
    98216            echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n";
    99217        } else {
     
    101219            $go_delete = true;
    102220        }
    103     }
    104     $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login");
    105     $user_dropdown = '<select name="reassign_user">';
    106     foreach ($all_logins as $login) {
    107         if ( $login->ID == $current_user->id || !in_array($login->ID, $userids) ) {
    108             $user_dropdown .= "<option value=\"{$login->ID}\">{$login->user_login}</option>";
    109         }
    110     }
    111     $user_dropdown .= '</select>';
    112     ?>
    113     </ul>
    114 <?php if($go_delete) : ?>
    115     <p><?php _e('What should be done with posts and links owned by this user?'); ?></p>
     221    }
     222    $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login");
     223    $user_dropdown = '<select name="reassign_user">';
     224    foreach ( (array) $all_logins as $login )
     225        if ( $login->ID == $current_user->id || !in_array($login->ID, $userids) )
     226            $user_dropdown .= "<option value=\"{$login->ID}\">{$login->user_login}</option>";
     227    $user_dropdown .= '</select>';
     228    ?>
     229    </ul>
     230<?php if ( $go_delete ) : ?>
     231    <p><?php _e('What should be done with posts and links owned by this user?'); ?></p>
    116232    <ul style="list-style:none;">
    117233        <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" />
     
    132248
    133249case 'adduser':
    134     check_admin_referer();
    135    
    136     $errors = add_user();
    137    
    138     if(count($errors) == 0) {
    139         header('Location: users.php?update=add');
     250    check_admin_referer('add-user');
     251
     252    if ( ! current_user_can('create_users') )
     253        wp_die(__('You can&#8217;t create users.'));
     254
     255    $user_id = add_user();
     256    $update = 'add';
     257    if ( is_wp_error( $user_id ) )
     258        $add_user_errors = $user_id;
     259    else {
     260        $new_user_login = apply_filters('pre_user_login', sanitize_user(stripslashes($_POST['user_login']), true));
     261        $redirect = add_query_arg('usersearch', $new_user_login, $redirect);
     262        wp_redirect(add_query_arg('update', $update, $redirect) . '#user-' . $user_id);
    140263        die();
    141264    }
    142265
    143266default:
    144    
    145     include ('admin-header.php');
    146    
    147     $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users;");
    148    
    149     foreach($userids as $userid) {
     267    wp_enqueue_script('admin-users');
     268
     269    include('admin-header.php');
     270
     271    // Query the users
     272    $wp_user_search = new WP_User_Search($_GET['usersearch'], $_GET['userspage']);
     273
     274    // Make the user objects
     275    foreach ( $wp_user_search->get_results() as $userid ) {
    150276        $tmp_user = new WP_User($userid);
    151277        $roles = $tmp_user->roles;
    152278        $role = array_shift($roles);
    153279        $roleclasses[$role][$tmp_user->user_login] = $tmp_user;
    154     }   
    155    
    156     ?>
    157 
    158     <?php
    159     if (isset($_GET['update'])) :
     280    }
     281
     282    if ( isset($_GET['update']) ) :
    160283        switch($_GET['update']) {
    161284        case 'del':
    162         ?>
    163             <div id="message" class="updated fade"><p><?php _e('User deleted.'); ?></p></div>
     285        case 'del_many':
     286        ?>
     287            <?php $delete_count = (int) $_GET['delete_count']; ?>
     288            <div id="message" class="updated fade"><p><?php printf(__('%1$s %2$s deleted.'), $delete_count, __ngettext('user', 'users', $delete_count) ); ?></p></div>
    164289        <?php
    165290            break;
     
    187312            break;
    188313        }
    189     endif;
    190     if ( isset($errors) ) : ?>
     314    endif; ?>
     315
     316<?php if ( is_wp_error( $errors ) ) : ?>
    191317    <div class="error">
    192318        <ul>
    193319        <?php
    194         foreach($errors as $error) echo "<li>$error</li>";
     320            foreach ( $errors->get_error_messages() as $message )
     321                echo "<li>$message</li>";
    195322        ?>
    196323        </ul>
    197324    </div>
    198     <?php
    199     endif;
    200     ?>
    201    
     325<?php endif; ?>
     326
     327<div class="wrap">
     328
     329    <?php if ( $wp_user_search->is_search() ) : ?>
     330        <h2><?php printf(__('Users Matching "%s" by Role'), wp_specialchars($wp_user_search->search_term)); ?></h2>
     331    <?php else : ?>
     332        <h2><?php _e('User List by Role'); ?></h2>
     333    <?php endif; ?>
     334
     335    <form action="" method="get" name="search" id="search">
     336        <p><input type="text" name="usersearch" id="usersearch" value="<?php echo wp_specialchars($wp_user_search->search_term, 1); ?>" /> <input type="submit" value="<?php _e('Search     users &raquo;'); ?>" class="button" /></p>
     337    </form>
     338
     339    <?php if ( is_wp_error( $wp_user_search->search_errors ) ) : ?>
     340        <div class="error">
     341            <ul>
     342            <?php
     343                foreach ( $wp_user_search->search_errors->get_error_messages() as $message )
     344                    echo "<li>$message</li>";
     345            ?>
     346            </ul>
     347        </div>
     348    <?php endif; ?>
     349
     350
     351<?php if ( $wp_user_search->get_results() ) : ?>
     352
     353    <?php if ( $wp_user_search->is_search() ) : ?>
     354        <p><a href="users.php"><?php _e('&laquo; Back to All Users'); ?></a></p>
     355    <?php endif; ?>
     356
     357    <h3><?php
     358    if ( 0 == $wp_user_search->first_user && $wp_user_search->total_users_for_query <= 50 )
     359        printf(__('%3$s shown below'), $wp_user_search->first_user + 1, min($wp_user_search->first_user + $wp_user_search->users_per_page, $wp_user_search->total_users_for_query), $wp_user_search->total_users_for_query);
     360    else
     361        printf(__('%1$s &#8211; %2$s of %3$s shown below'), $wp_user_search->first_user + 1, min($wp_user_search->first_user + $wp_user_search->users_per_page, $wp_user_search->total_users_for_query), $wp_user_search->total_users_for_query); ?></h3>
     362
     363    <?php if ( $wp_user_search->results_are_paged() ) : ?>
     364        <div class="user-paging-text"><p><?php $wp_user_search->page_links(); ?></p></div>
     365    <?php endif; ?>
     366
    202367<form action="" method="post" name="updateusers" id="updateusers">
    203 <div class="wrap">
    204     <h2><?php _e('User List by Role'); ?></h2>
    205   <table cellpadding="3" cellspacing="3" width="100%">
    206     <?php
    207     foreach($roleclasses as $role => $roleclass) {
    208         ksort($roleclass);
    209         ?>
    210 
    211     <tr>
    212     <th colspan="8" align="left">
    213   <h3><?php echo $wp_roles->role_names[$role]; ?></h3>
    214   </th></tr>
    215 
    216     <tr>
     368<?php wp_nonce_field('bulk-users') ?>
     369<table class="widefat">
     370<?php
     371foreach($roleclasses as $role => $roleclass) {
     372    uksort($roleclass, "strnatcasecmp");
     373?>
     374
     375<tr>
     376<?php if ( !empty($role) ) : ?>
     377    <th colspan="7"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>
     378<?php else : ?>
     379    <th colspan="7"><h3><em><?php _e('No role for this blog'); ?></h3></th>
     380<?php endif; ?>
     381</tr>
     382<tr class="thead">
    217383    <th><?php _e('ID') ?></th>
    218384    <th><?php _e('Username') ?></th>
     
    220386    <th><?php _e('E-mail') ?></th>
    221387    <th><?php _e('Website') ?></th>
    222     <th><?php _e('Posts') ?></th>
    223     <th>&nbsp;</th>
    224     </tr>
    225     <?php
    226     $style = '';
    227     foreach ($roleclass as $user_object) {
    228         $email = $user_object->user_email;
    229         $url = $user_object->user_url;
    230         $short_url = str_replace('http://', '', $url);
    231         $short_url = str_replace('www.', '', $short_url);
    232         if ('/' == substr($short_url, -1))
    233             $short_url = substr($short_url, 0, -1);
    234         if (strlen($short_url) > 35)
    235         $short_url =  substr($short_url, 0, 32).'...';
    236         $style = ('class="alternate"' == $style) ? '' : 'class="alternate"';
    237         $numposts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$user_object->ID' and post_status = 'publish'");
    238         if (0 < $numposts) $numposts = "<a href='edit.php?author=$user_object->ID' title='" . __('View posts') . "'>$numposts</a>";
    239         echo "
    240 <tr $style>
    241     <td><input type='checkbox' name='users[]' id='user_{$user_object->ID}' value='{$user_object->ID}' /> <label for='user_{$user_object->ID}'>{$user_object->ID}</label></td>
    242     <td><label for='user_{$user_object->ID}'><strong>$user_object->user_login</strong></label></td>
    243     <td><label for='user_{$user_object->ID}'>$user_object->first_name $user_object->last_name</label></td>
    244     <td><a href='mailto:$email' title='" . sprintf(__('e-mail: %s'), $email) . "'>$email</a></td>
    245     <td><a href='$url' title='website: $url'>$short_url</a></td>";
    246     echo "<td align='right'>$numposts</td>";
    247     echo '<td>';
    248     if (current_user_can('edit_users'))
    249         echo "<a href='user-edit.php?user_id=$user_object->ID' class='edit'>".__('Edit')."</a>";
    250     echo '</td>';
    251     echo '</tr>';
    252     }
    253    
    254     ?>
    255    
     388    <th colspan="2" style="text-align: center"><?php _e('Actions') ?></th>
     389</tr>
     390</thead>
     391<tbody id="role-<?php echo $role; ?>"><?php
     392$style = '';
     393foreach ( (array) $roleclass as $user_object ) {
     394    $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
     395    echo "\n\t" . user_row($user_object, $style);
     396}
     397?>
     398
     399</tbody>
     400<?php } ?>
     401</table>
     402
     403<?php if ( $wp_user_search->results_are_paged() ) : ?>
     404    <div class="user-paging-text"><p><?php $wp_user_search->page_links(); ?></p></div>
     405<?php endif; ?>
     406
     407    <h3><?php _e('Update Selected'); ?></h3>
     408    <ul style="list-style:none;">
     409        <li><input type="radio" name="action" id="action0" value="delete" /> <label for="action0"><?php _e('Delete checked users.'); ?></label></li>
     410        <li>
     411            <input type="radio" name="action" id="action1" value="promote" /> <label for="action1"><?php _e('Set the Role of checked users to:'); ?></label>
     412            <select name="new_role" onchange="getElementById('action1').checked = 'true'"><?php wp_dropdown_roles(); ?></select>
     413        </li>
     414    </ul>
     415    <p class="submit" style="width: 420px">
     416        <?php echo $referer; ?>
     417        <input type="submit" value="<?php _e('Bulk Update &raquo;'); ?>" />
     418    </p>
     419</form>
     420<?php endif; ?>
     421</div>
    256422
    257423<?php
     424    if ( is_wp_error($add_user_errors) ) {
     425        foreach ( array('user_login' => 'user_login', 'first_name' => 'user_firstname', 'last_name' => 'user_lastname', 'email' => 'user_email', 'url' => 'user_uri', 'role' => 'user_role') as $formpost => $var ) {
     426            $var = 'new_' . $var;
     427            $$var = wp_specialchars(stripslashes($_POST[$formpost]));
     428        }
     429        unset($name);
    258430    }
    259431?>
    260   </table>
    261 
    262 
    263     <h2><?php _e('Update Users'); ?></h2>
    264 <?php
    265 $role_select = '<select name="new_role">';
    266 foreach($wp_roles->role_names as $role => $name) {
    267     $role_select .= "<option value=\"{$role}\">{$name}</option>";
    268 }
    269 $role_select .= '</select>';
    270 ?> 
    271   <ul style="list-style:none;">
    272     <li><input type="radio" name="action" id="action0" value="delete" /> <label for="action0"><?php _e('Delete checked users.'); ?></label></li>
    273     <li><input type="radio" name="action" id="action1" value="promote" /> <?php echo '<label for="action1">'.__('Set the Role of checked users to:')."</label> $role_select"; ?></li>
    274   </ul>
    275     <p class="submit"><input type="submit" value="<?php _e('Update &raquo;'); ?>" /></p>
     432
     433<div class="wrap">
     434<h2 id="add-new-user"><?php _e('Add New User') ?></h2>
     435<div class="narrow">
     436<?php echo '<p>'.sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), get_option('siteurl').'/wp-register.php').'</p>'; ?>
     437<form action="#add-new-user" method="post" name="adduser" id="adduser">
     438<?php wp_nonce_field('add-user') ?>
     439<table class="editform" width="100%" cellspacing="2" cellpadding="5">
     440    <tr>
     441        <th scope="row" width="33%"><?php _e('Username (required)') ?><input name="action" type="hidden" id="action" value="adduser" /></th>
     442        <td width="66%"><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" /></td>
     443    </tr>
     444    <tr>
     445        <th scope="row"><?php _e('First Name') ?> </th>
     446        <td><input name="first_name" type="text" id="first_name" value="<?php echo $new_user_firstname; ?>" /></td>
     447    </tr>
     448    <tr>
     449        <th scope="row"><?php _e('Last Name') ?> </th>
     450        <td><input name="last_name" type="text" id="last_name" value="<?php echo $new_user_lastname; ?>" /></td>
     451    </tr>
     452    <tr>
     453        <th scope="row"><?php _e('E-mail (required)') ?></th>
     454        <td><input name="email" type="text" id="email" value="<?php echo $new_user_email; ?>" /></td>
     455    </tr>
     456    <tr>
     457        <th scope="row"><?php _e('Website') ?></th>
     458        <td><input name="url" type="text" id="url" value="<?php echo $new_user_uri; ?>" /></td>
     459    </tr>
     460
     461<?php if ( apply_filters('show_password_fields', true) ) : ?>
     462    <tr>
     463        <th scope="row"><?php _e('Password (twice)') ?> </th>
     464        <td><input name="pass1" type="password" id="pass1" />
     465        <br />
     466        <input name="pass2" type="password" id="pass2" /></td>
     467    </tr>
     468<?php endif; ?>
     469
     470    <tr>
     471        <th scope="row"><?php _e('Role'); ?></th>
     472        <td><select name="role" id="role">
     473            <?php
     474            if ( !$new_user_role )
     475                $new_user_role = get_option('default_role');
     476            wp_dropdown_roles($new_user_role);
     477            ?>
     478            </select>
     479        </td>
     480    </tr>
     481</table>
     482<p class="submit">
     483    <?php echo $referer; ?>
     484    <input name="adduser" type="submit" id="addusersub" value="<?php _e('Add User &raquo;') ?>" />
     485</p>
    276486</div>
    277487</form>
    278488
    279 <div class="wrap">
    280 <h2><?php _e('Add New User') ?></h2>
    281 <?php echo '<p>'.sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), get_settings('siteurl').'/wp-register.php').'</p>'; ?>
    282 <form action="" method="post" name="adduser" id="adduser">
    283   <table class="editform" width="100%" cellspacing="2" cellpadding="5">
    284     <tr>
    285       <th scope="row" width="33%"><?php _e('Nickname') ?>
    286       <input name="action" type="hidden" id="action" value="adduser" /></th>
    287       <td width="66%"><input name="user_login" type="text" id="user_login" value="<?php echo $new_user_login; ?>" /></td>
    288     </tr>
    289     <tr>
    290       <th scope="row"><?php _e('First Name') ?> </th>
    291       <td><input name="first_name" type="text" id="first_name" value="<?php echo $new_user_firstname; ?>" /></td>
    292     </tr>
    293     <tr>
    294       <th scope="row"><?php _e('Last Name') ?> </th>
    295       <td><input name="last_name" type="text" id="last_name" value="<?php echo $new_user_lastname; ?>" /></td>
    296     </tr>
    297     <tr>
    298       <th scope="row"><?php _e('E-mail') ?></th>
    299       <td><input name="email" type="text" id="email" value="<?php echo $new_user_email; ?>" /></td>
    300     </tr>
    301     <tr>
    302       <th scope="row"><?php _e('Website') ?></th>
    303       <td><input name="url" type="text" id="url" value="<?php echo $new_user_uri; ?>" /></td>
    304     </tr>
     489<?php if ( is_wp_error( $add_user_errors ) ) : ?>
     490    <div class="error">
     491        <?php
     492            foreach ( $add_user_errors->get_error_messages() as $message )
     493                echo "<p>$message</p>";
     494        ?>
     495    </div>
     496<?php endif; ?>
     497<div id="ajax-response"></div>
     498</div>
     499
    305500<?php
    306 $show_password_fields = apply_filters('show_password_fields', true);
    307 if ( $show_password_fields ) :
    308 ?>
    309     <tr>
    310       <th scope="row"><?php _e('Password (twice)') ?> </th>
    311       <td><input name="pass1" type="password" id="pass1" />
    312       <br />
    313       <input name="pass2" type="password" id="pass2" /></td>
    314     </tr>
    315 <?php endif; ?>
    316   </table>
    317   <p class="submit">
    318     <input name="adduser" type="submit" id="adduser" value="<?php _e('Add User') ?> &raquo;" />
    319   </p>
    320   </form>
    321 </div>
    322     <?php
    323 
    324501break;
    325 }
     502
     503} // end of the $action switch
    326504
    327505include('admin-footer.php');
  • trunk/wp-admin/wp-admin.css

    r3503 r4431  
    1919    background: #c00;
    2020    color: #fff;
     21}
     22
     23#devnews h4 {
     24    font-family: Georgia, "Times New Roman", Times, serif;
     25    font-size: 18px;
     26    font-weight: normal;
    2127}
    2228
     
    4147}
    4248
     49#planetnews li .post {
     50    font-family: Georgia, "Times New Roman", Times, serif;
     51    font-size: 18px;
     52    display: block;
     53    height: 60px;
     54    overflow: hidden;
     55}
     56
     57#planetnews .hidden {
     58    display: none;
     59}
     60
     61.readmore {
     62    clear: both;
     63    text-align: right;
     64    margin-right: 5em;
     65}
     66
     67.widefat {
     68    width: 100%;
     69}
     70
     71.widefat td, .widefat th {
     72    padding: 5px 6px;
     73}
     74
     75.widefat th {
     76    text-align: left;
     77}
     78
     79.plugins p {
     80    margin: 4px;
     81    padding: 0;
     82}
     83
     84.plugins .name {
     85    font-size: 16px;
     86}
     87
     88.import-system {
     89    font-size: 16px;
     90}
     91
     92thead, .thead {
     93    background: #dfdfdf
     94}
     95
     96#import-upload-form {
     97    margin: auto;
     98    background: #eee;
     99    padding: 1em;
     100}
     101
    43102a.edit, a.delete, a.edit:hover, a.delete:hover {
    44103    border-bottom: none;
     
    92151}
    93152
    94 fieldset span.cat-nest {
    95     display: block;
    96     margin-left: 10px;
    97 }
    98 
    99153fieldset.options {
    100154    padding: 1em;
     
    102156
    103157fieldset.options legend {
    104     font-size: 16px;
     158    font-size: 1.5em;
     159    font-weight: bold;
     160    font-family: Georgia, "Times New Roman", Times, serif;
    105161}
    106162
     
    111167
    112168h2 {
    113     border-bottom: .5em solid #f0f8ff;
     169    border-bottom: .5em solid #e5f3ff;
    114170    color: #333;
    115     font: normal 30px/5px serif;
     171    font: normal 32px/5px serif;
    116172    margin: 5px 10px;
    117 }
    118 
    119 h2 small.quickjump {
    120     display: block;
    121     text-align: right;
    122 }
    123 
    124 h2 small.quickjump a {
    125     text-decoration: none;
    126     border-bottom: 0;
    127     font-size: 15px;
    128     background: #f0f8ff;
    129     padding: 5px 10px;
    130173}
    131174
     
    148191
    149192p, li, dl, dd, dt {
    150     line-height: 130%;
     193    line-height: 140%;
    151194}
    152195
     
    164207    padding: 0px;
    165208    margin-bottom: 16px;
    166     height: 15em;
     209    height: 17em;
    167210    width: 100%;
    168211/*  overflow-y: hidden;*/
     
    242285
    243286.commentlist li {
    244     border-bottom: 1px solid #369;
    245     padding: .3em 1em;
     287    border-bottom: 1px solid #ccc;
     288    padding: 1em 1em .2em;
     289    margin: 0;
     290}
     291
     292.commentlist p {
     293    padding: 0;
     294    margin: 0 0 .8em;
    246295}
    247296
     
    278327}
    279328
    280 .submit input, .submit input:focus, .button {
     329.submit input, .submit input:focus, .button, .button:focus {
    281330    background: url( images/fade-butt.png );
    282331    border: 3px double #999;
     
    294343}
    295344
     345.button, .button:focus {
     346    padding: 0.15em;
     347}
     348
     349* html .button {
     350    padding: 0;
     351}
     352
    296353.submit, .editform th, #postcustomsubmit {
    297354    text-align: right;
     
    309366    width: 33%;
    310367    text-align: right;
     368    font-size: 1.3em;
     369    font-weight: normal;
    311370}
    312371
     
    327386}
    328387
    329 .updated {
    330     background: #CFEBF7 url(images/notice.gif) no-repeat 1em ;
     388.approve {
     389    display: none;
     390}
     391
     392.unapproved .approve {
     393    display: inline;
     394}
     395
     396.unapproved .unapprove {
     397    display: none;
     398}
     399
     400.updated, .confirm {
     401    background: #CFEBF7 url(images/notice.gif) no-repeat 1em;
    331402    border: 1px solid #2580B2;
    332403    margin: 1em 5% 10px;
     
    346417    clear: both;
    347418    margin: 15px 5%;
    348     padding: .5em 1em;
     419    padding: 1em;
     420}
     421
     422.narrow {
     423    width: 450px;
     424    margin: auto;
     425}
     426
     427.narrow p {
     428    line-height: 150%;
    349429}
    350430
    351431.wrap h2 {
    352     margin: .8em 0 .5em;
     432    margin: .4em 0 .5em;
    353433    clear: both;
    354434}
    355435
    356 table .vers, table .name {
     436* html .wrap h2 {
     437    margin-top: 1em;
     438}
     439
     440table .vers {
    357441    text-align: center;
    358442}
    359443
     444textarea.all-options, input.all-options {
     445    width: 250px;
     446}
     447
     448input.disabled, textarea.disabled {
     449    background: #ccc;
     450}
     451
    360452#adminmenu {
    361     background: #6da6d1;
     453    background: #83B4D8;
    362454    border-top: 3px solid #448abd;
    363455    margin: 0;
    364     padding: .2em .2em .2em 2em;
    365 }
     456    padding: .2em .2em .3em 2em;
     457}
     458
    366459
    367460#adminmenu .current, #submenu .current {
    368461    font-weight: bold;
     462    text-decoration: none;
    369463}
    370464
     
    375469    margin: 0;
    376470    padding: 3px 5px;
    377     text-decoration: none;
    378 }
    379 
    380 #adminmenu a:hover, .current {
     471    border-bottom: none;
     472}
     473
     474#adminmenu a:hover, #adminmenu a.current {
    381475    background: #ddeaf4;
    382476    color: #333;
     
    390484}
    391485
    392 #submenu {
     486#adminmenu a.current {
     487    background: #0d324f;
     488    border-right: 2px solid #4f96c8;
     489    border-top: 1px solid #96c0de;
     490    color: #fff;
     491    padding-bottom: 8px;
     492}
     493
     494#submenu, #minisub {
    393495    background: #0d324f;
    394496    border-bottom: none;
    395497    margin: 0;
    396498    padding: 3px 2em 0 3em;
     499    height: 25px;
     500}
     501
     502#minisub {
     503    height: 6px;
    397504}
    398505
     
    408515    color: #fff;
    409516    font-size: 12px;
    410     padding: .3em .4em .33em;
     517    padding: .3em .4em .4em;
    411518}
    412519
     
    417524
    418525#submenu li {
    419     line-height: 170%;
     526    line-height: 180%;
    420527}
    421528
     
    425532}
    426533
    427 #titlediv, #guiddiv {
    428     margin: 0 8px 0 0;
    429     padding: 0px;
    430 }
    431 
    432 #postdiv {
     534#postdiv, #titlediv, #guiddiv {
    433535    margin: 0 8px 0 0;
    434536    padding: 0px;
     
    445547}
    446548
     549#postdivrich #content {
     550    padding: .7em;
     551    line-height: 140%;
     552}
     553
    447554#titlediv input, #guiddiv input {
    448555    margin: 0px;
    449556    width: 100%;
    450 }
    451 
    452 #quicktags {
    453     margin-left: -1px;
    454557}
    455558
     
    462565}
    463566
    464 #deletepost:hover {
     567input.delete:hover {
    465568    background: #ce0000;
    466569    color: #fff;
     570}
     571
     572#deletebookmarks:hover {
     573    background: #ce0000;
     574    color: #fff;
     575}
     576
     577#postdivrich #quicktags {
     578    background: #f0f0ee;
     579    padding: 0px;
     580    border: 1px solid #ccc;
     581    border-bottom: none;
     582}
     583
     584#postdiv #quicktags {
     585    padding-right: 6px;
     586}
     587
     588#postdivrich #quicktags {
     589    display: none;
     590}
     591
     592#quicktags #ed_toolbar {
     593    padding: 0px 2px;
     594}
     595
     596#ed_toolbar input {
     597    background: #fff url( images/fade-butt.png ) repeat-x 0px -2px;
     598    margin: 3px 2px 2px;
    467599}
    468600
     
    486618#quicktags #ed_code {
    487619    font-family: "Courier New", Courier, mono;
     620    margin-bottom: 3px;
    488621}
    489622
    490623#title {
    491     font-size: 1.5em;
     624    font-size: 1.7em;
     625    padding: 4px;
    492626}
    493627
     
    515649    clear: both;
    516650    text-align: center;
     651    width: 500px;
     652    margin: auto;
     653    height: 100px;
     654}
     655
     656#footer .docs {
     657    padding-top: 19px;
     658    line-height: 160%;
     659}
     660
     661#footer .docs a {
     662    text-decoration: underline;
     663}
     664#footer .logo {
     665    float: left;
     666    margin: 0;
     667    padding: 0;
    517668}
    518669
    519670#login {
    520     background: #fff;
    521     border: 1px solid #a2a2a2;
     671    position: relative;
     672    background: url('images/login-bkg-tile.gif') no-repeat top center;
     673    color: #fff;
    522674    margin: 5em auto;
    523     padding: 1.5em;
    524     width: 25em;
     675    padding: 20px 50px 0;
     676    width: 325px;
    525677}
    526678
    527679#login #login_error {
    528     background: #c00;
    529     border: 1px solid #a40000;
     680    background: #0e3350;
     681    border: 1px solid #2571ab;
     682    color: #ebcd4e;
     683    font-size: 11px;
     684    font-weight: bold;
     685    padding: .6em;
     686    text-align: center;
     687}
     688
     689#login #login_error a {
     690    color: #ebcd4e;
     691    border-color: #ebcd4e;
     692}
     693
     694#login #send {
    530695    color: #fff;
    531     font-size: 16px;
    532     font-weight: bold;
    533     padding: .5em;
     696    text-align: left;
     697    font-weight: normal;
     698    font-size: 1.1em;
     699}
     700
     701#login h1 a {
     702    margin: 0 auto;
     703    height: 88px;
     704    width: 320px;
     705    display: block;
     706    border-bottom: none;
     707}
     708
     709#login .hide {
     710    display: none;
     711}
     712
     713#login .message {
     714    font-size: 10pt;
    534715    text-align: center;
    535716}
    536717
    537 #login h1 {
    538     background: url(images/wordpress-logo.png) no-repeat top left;
    539     margin-top: 0;
    540 }
    541 
    542 #login h1 a {
     718#login .register {
     719    font-size: 20px;
     720}
     721
     722#login input {
     723    padding: 4px;
     724}
     725
     726#login ul {
     727    background: url('images/login-bkg-bottom.gif') no-repeat bottom center;
     728    list-style: none;
     729    margin: 0 -50px;
     730    padding: 10px 50px 25px;;
     731}
     732
     733#login ul:after {
     734    content: ".";
    543735    display: block;
    544     text-indent: -1000px;
    545     height: 66px;
    546     border-bottom: none;
    547 }
    548 
    549 #login input {
    550     padding: 3px;
    551 }
    552 
    553 #login ul {
    554     list-style: none;
    555     margin: 0;
    556     padding: 0;
     736    height: 0;
     737    clear: both;
     738    visibility: hidden;
    557739}
    558740
    559741#login ul li {
    560     display: inline;
    561     margin-left: 1.4em;
     742    float: left;
     743    font-size: 12px;
     744    padding: 5px 0;
    562745    text-align: center;
    563746}
    564747
    565 #login #log, #pwd {
    566     font-size: 1.7em;
    567     width: 80%;
     748#login ul li a {
     749    display: block;
     750    color: #84c4f0;
     751    border: none;
     752    padding: 4px 1px 5px;
     753    width: 160px;
     754}
     755
     756#login ul li a:hover {
     757    background: #0e3350;
     758    border: 1px solid #2571ab;
     759    padding: 3px 0 4px;
     760    color: #fff;
     761}
     762
     763#login .input {
     764    font-size: 1.8em;
     765    margin-top: 3px;
     766    width: 97%;
     767}
     768
     769#login p label {
     770    font-size: 11px;
    568771}
    569772
    570773#login #submit {
    571     font-size: 1.7em;
     774    margin: 0;
     775    font-size: 15px;
     776}
     777.plugins p {
     778}
     779
     780#login .fullwidth {
     781    width: 320px;
     782}
     783
     784#searchform {
     785    float: left;
     786    margin-right: 1em;
     787    width: 18em;
     788}
     789
     790#viewarc {
     791    float: left;
     792    width: 23em;
     793    margin-bottom: 1em;
     794}
     795
     796#viewcat {
     797    float: left;
     798    width: 30em;
     799    margin-bottom: 1em;
    572800}
    573801
     
    614842    float: right;
    615843    width: 170px;
    616 }
    617 
    618 #templateside h3, #postcustom p {
     844    overflow: hidden;
     845}
     846
     847#templateside h3, #postcustom p.submit {
    619848    margin: 0;
    620849}
     
    663892#zeitgeist {
    664893    background: #eee;
    665     border: 1px solid #69c;
     894    border: 1px solid #c5c5c5;
    666895    float: right;
    667896    font-size: 90%;
     
    677906}
    678907
     908* html #zeitgeist h2 {
     909    padding-top: 10px;
     910}
     911
    679912#zeitgeist h2 {
    680913    margin-top: .4em;
     
    712945.alternate.active .name {
    713946    background: #8B8;
     947}
     948
     949#namediv, #emaildiv, #uridiv {
     950    float: left;
     951}
     952
     953#ajax-response {
     954    padding: .5em;
    714955}
    715956
     
    8001041}
    8011042
    802 #categorydiv div div {
     1043#categorydiv ul {
     1044    list-style: none;
     1045    padding: 0;
     1046    margin-left: 10px;
     1047}
     1048
     1049#categorychecklist {
    8031050    height: 12em;
    8041051    overflow: auto;
     1052    margin-top: 8px;
     1053}
     1054
     1055#categorychecklist li {
     1056    margin: 0;
     1057    padding: 0;
    8051058}
    8061059
    8071060#ajaxcat input {
    8081061    border: 1px solid #ccc;
     1062}
     1063
     1064#your-profile #rich_editing {
     1065    border: none;
     1066    background: #fff;
    8091067}
    8101068
     
    8131071    float: left;
    8141072    width: 40%;
    815     padding: .5em 2em;
    816     margin: 1em;
     1073    padding: .5em 2em 1em;
     1074    margin: 1em 1em 1em 0;
    8171075}
    8181076
     
    8491107}
    8501108
     1109#moremeta fieldset.dbx-box-closed {
     1110    background: url(images/box-butt.gif) no-repeat bottom;
     1111    padding-bottom: 9px;
     1112}
     1113
    8511114/* handles */
    8521115
     
    8691132}
    8701133
     1134#advancedstuff h3.dbx-handle {
     1135    margin-left: 7px;
     1136    margin-bottom: -7px;
     1137    padding: 6px 1em 0 3px;
     1138    height: 19px;
     1139    font-size: 12px;
     1140    background: #2685af url(images/box-head-right.gif) no-repeat top right;
     1141}
     1142
     1143#advancedstuff div.dbx-handle-wrapper {
     1144    margin: 0 0 0 -7px;
     1145    background: #fff url(images/box-head-left.gif) no-repeat top left;
     1146}
     1147
     1148#advancedstuff div.dbx-content {
     1149    margin-left: 8px;
     1150    background: url(images/box-bg-right.gif) repeat-y right;
     1151    padding: 10px 10px 15px 0px;
     1152}
     1153
     1154#postexcerpt div.dbx-content {
     1155    margin-right: 0;
     1156    padding-right: 17px;
     1157}
     1158
     1159#advancedstuff div.dbx-content-wrapper {
     1160    margin-left: -7px;
     1161    margin-right: 0;
     1162    background: url(images/box-bg-left.gif) repeat-y left;
     1163}
     1164
     1165#advancedstuff fieldset.dbx-box {
     1166    padding-bottom: 9px;
     1167    margin-left: 6px;
     1168    background: url(images/box-butt-right.gif) no-repeat bottom right;
     1169}
     1170
     1171#advancedstuff div.dbx-box-wrapper {
     1172    background: url(images/box-butt-left.gif) no-repeat bottom left;
     1173}
     1174
     1175#advancedstuff .dbx-box-closed div.dbx-content-wrapper {
     1176    padding-bottom: 2px;
     1177    background: url(images/box-butt-left.gif) no-repeat bottom left;
     1178}
     1179
     1180#advancedstuff .dbx-box {
     1181    background: url(images/box-butt-right.gif) no-repeat bottom right;
     1182}
     1183
     1184
    8711185/* handle cursors */
    8721186.dbx-handle-cursor {
    8731187    cursor: move;
    8741188}
    875    
     1189
    8761190/* toggle images */
    8771191a.dbx-toggle, a.dbx-toggle:visited {
     
    9031217    height: 22px;
    9041218    width: 22px;
     1219    top: 3px;
     1220    right: 5px;
    9051221    background-position: 0 -3px;
    9061222}
     
    9091225    height: 22px;
    9101226    width: 22px;
     1227    top: 3px;
     1228    right: 5px;
    9111229    background-position: 0 -28px;
    9121230}
     
    9241242}
    9251243
    926 #newcat { width: 120px; margin-right: 5px; }
    927 input#catadd {  background: #a4a4a4;
     1244#newcat {
     1245    width: 120px;
     1246    margin-right: 5px;
     1247}
     1248
     1249input #catadd {
     1250    background: #a4a4a4;
    9281251    border-bottom: 1px solid #898989;
    9291252    border-left: 1px solid #bcbcbc;
     
    9381261    margin-bottom: 2px;
    9391262    text-align: center;
    940     width: 37px; }
     1263    width: 37px;
     1264}
     1265
    9411266#howto {
    9421267    font-size: 11px;
     
    9441269    display: block;
    9451270}
     1271
    9461272#jaxcat {
    9471273    margin: 0;
    9481274    padding: 0;
    9491275}
     1276
     1277#ajax-response.alignleft {
     1278    margin-left: 2em;
     1279}
     1280
     1281#postdivrich #edButtons {
     1282    padding-left: 3px;
     1283}
     1284
     1285#postdivrich #content, #postdivrich #content:active {
     1286    border: 1px solid #ccc;
     1287}
     1288
     1289#edButtons input, #edButtons input:active {
     1290    margin: 0px 2px -1px;
     1291}
     1292
     1293#edButtons input.edButtonFore, #edButtons input.edButtonFore:active {
     1294    background: #f0f0ee;
     1295    border-bottom: 1px solid #f0f0ee;
     1296}
     1297
     1298#edButtons input.edButtonBack, #edButtons input.edButtonBack:active {
     1299    background: #fff url( images/fade-butt.png ) repeat-x 0px 15px;
     1300    border-bottom: 1px solid #ccc;
     1301}
     1302
     1303.page-numbers {
     1304    padding: 4px 7px;
     1305    border: 1px solid #fff;
     1306    margin-right: 3px;
     1307}
     1308
     1309a.page-numbers {
     1310    border: 1px solid #ccc;
     1311}
     1312
     1313a.page-numbers:hover {
     1314    border: 1px solid #999;
     1315}
     1316
     1317.page-numbers.current {
     1318    border: 1px solid #999;
     1319    font-weight: bold;
     1320}
  • trunk/wp-admin/xfn.js

    r3503 r4431  
    3939    var aInputs = document.getElementsByTagName('input');
    4040
    41     for (var i = 0; i < aInputs.length; i++) {     
     41    for (var i = 0; i < aInputs.length; i++) {
    4242         aInputs[i].onclick = aInputs[i].onkeyup = upit;
    4343    }
  • trunk/wp-atom.php

    r3503 r4431  
    66}
    77
    8 header('Content-type: application/atom+xml; charset=' . get_settings('blog_charset'), true);
     8header('Content-type: application/atom+xml; charset=' . get_option('blog_charset'), true);
    99$more = 1;
    1010
    1111?>
    12 <?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
     12<?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?>
    1313<feed version="0.3"
    1414  xmlns="http://purl.org/atom/ns#"
     
    3636        <?php the_category_rss('rdf') ?>
    3737        <summary type="text/plain" mode="escaped"><![CDATA[<?php the_excerpt_rss(); ?>]]></summary>
    38 <?php if ( !get_settings('rss_use_excerpt') ) : ?>
     38<?php if ( !get_option('rss_use_excerpt') ) : ?>
    3939        <content type="<?php bloginfo('html_type'); ?>" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>
    4040<?php endif; ?>
     
    4242<?php do_action('atom_entry'); ?>
    4343    </entry>
    44     <?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
     44    <?php $items_count++; if (($items_count == get_option('posts_per_rss')) && empty($m)) { break; } } } ?>
    4545</feed>
  • trunk/wp-blog-header.php

    r3503 r4431  
    55    if ( strstr( $_SERVER['PHP_SELF'], 'wp-admin') ) $path = '';
    66    else $path = 'wp-admin/';
    7     die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://wordpress.org/docs/faq/#wp-config'>We got it</a>. You can <a href='{$path}setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.");
     7
     8  require_once( dirname(__FILE__) . '/wp-includes/functions.php');
     9  wp_die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://wordpress.org/docs/faq/#wp-config'>We got it</a>. You can <a href='{$path}setup-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.", "WordPress &rsaquo; Error");
    810}
    911
  • trunk/wp-comments-post.php

    r3503 r4431  
    1313} elseif ( 'closed' ==  $status->comment_status ) {
    1414    do_action('comment_closed', $comment_post_ID);
    15     die( __('Sorry, comments are closed for this item.') );
     15    wp_die( __('Sorry, comments are closed for this item.') );
    1616} elseif ( 'draft' == $status->post_status ) {
    1717    do_action('comment_on_draft', $comment_post_ID);
     
    2525
    2626// If the user is logged in
    27 get_currentuserinfo();
    28 if ( $user_ID ) :
    29     $comment_author       = $wpdb->escape($user_identity);
    30     $comment_author_email = $wpdb->escape($user_email);
    31     $comment_author_url   = $wpdb->escape($user_url);
     27$user = wp_get_current_user();
     28if ( $user->ID ) :
     29    $comment_author       = $wpdb->escape($user->display_name);
     30    $comment_author_email = $wpdb->escape($user->user_email);
     31    $comment_author_url   = $wpdb->escape($user->user_url);
    3232else :
    3333    if ( get_option('comment_registration') )
    34         die( __('Sorry, you must be logged in to post a comment.') );
     34        wp_die( __('Sorry, you must be logged in to post a comment.') );
    3535endif;
    3636
    3737$comment_type = '';
    3838
    39 if ( get_settings('require_name_email') && !$user_ID ) {
     39if ( get_option('require_name_email') && !$user->ID ) {
    4040    if ( 6 > strlen($comment_author_email) || '' == $comment_author )
    41         die( __('Error: please fill the required fields (name, email).') );
     41        wp_die( __('Error: please fill the required fields (name, email).') );
    4242    elseif ( !is_email($comment_author_email))
    43         die( __('Error: please enter a valid email address.') );
     43        wp_die( __('Error: please enter a valid email address.') );
    4444}
    4545
    4646if ( '' == $comment_content )
    47     die( __('Error: please type a comment.') );
     47    wp_die( __('Error: please type a comment.') );
    4848
    4949$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID');
    5050
    51 wp_new_comment( $commentdata );
     51$comment_id = wp_new_comment( $commentdata );
    5252
    53 if ( !$user_ID ) :
    54     setcookie('comment_author_' . COOKIEHASH, stripslashes($comment_author), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
    55     setcookie('comment_author_email_' . COOKIEHASH, stripslashes($comment_author_email), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
    56     setcookie('comment_author_url_' . COOKIEHASH, stripslashes($comment_author_url), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
     53$comment = get_comment($comment_id);
     54if ( !$user->ID ) :
     55    setcookie('comment_author_' . COOKIEHASH, $comment->comment_author, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
     56    setcookie('comment_author_email_' . COOKIEHASH, $comment->comment_author_email, time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
     57    setcookie('comment_author_url_' . COOKIEHASH, clean_url($comment->comment_author_url), time() + 30000000, COOKIEPATH, COOKIE_DOMAIN);
    5758endif;
    5859
    59 $location = ( empty( $_POST['redirect_to'] ) ) ? get_permalink( $comment_post_ID ) : $_POST['redirect_to'];
     60$location = ( empty($_POST['redirect_to']) ? get_permalink($comment_post_ID) : $_POST['redirect_to'] ) . '#comment-' . $comment_id;
     61$location = apply_filters('comment_post_redirect', $location, $comment);
    6062
    61 wp_redirect( $location );
     63wp_redirect($location);
    6264
    6365?>
  • trunk/wp-commentsrss2.php

    r3503 r4431  
    66}
    77
    8 header('Content-type: text/xml;charset=' . get_settings('blog_charset'), true);
     8header('Content-type: text/xml;charset=' . get_option('blog_charset'), true);
    99
    10 echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>';
     10echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>';
    1111?>
    1212<!-- generator="wordpress/<?php echo $wp_version ?>" -->
     
    3232            comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
    3333            $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
    34             LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '$id'
    35             AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status IN ('publish', 'static', 'object')
     34            LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE comment_post_ID = '" . get_the_ID() . "'
     35            AND $wpdb->comments.comment_approved = '1' AND $wpdb->posts.post_status = 'publish'
    3636            AND post_date_gmt < '" . gmdate("Y-m-d H:i:59") . "'
    37             ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss') );
     37            ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss') );
    3838        } else { // if no post id passed in, we'll just ue the last 10 comments.
    3939            $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email,
    4040            comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID,
    4141            $wpdb->posts.ID, $wpdb->posts.post_password FROM $wpdb->comments
    42             LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status IN ('publish', 'static', 'object')
     42            LEFT JOIN $wpdb->posts ON comment_post_id = id WHERE $wpdb->posts.post_status = 'publish'
    4343            AND $wpdb->comments.comment_approved = '1' AND post_date_gmt < '" . gmdate("Y-m-d H:i:s") . "' 
    44             ORDER BY comment_date_gmt DESC LIMIT " . get_settings('posts_per_rss') );
     44            ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss') );
    4545        }
    4646    // this line is WordPress' motor, do not delete it.
    4747        if ($comments) {
    4848            foreach ($comments as $comment) {
     49                $GLOBALS['comment'] =& $comment;
    4950                // Some plugins may need to know the metadata
    5051                // associated with this comment's post:
     
    5758            $title = apply_filters('the_title_rss', $title);
    5859            printf(__('Comment on %1$s by %2$s'), $title, get_comment_author_rss());
    59         } else {   
    60             printf(__('by: %s'), get_comment_author_rss());         
     60        } else {
     61            printf(__('by: %s'), get_comment_author_rss());
    6162        } ?></title>
    6263        <link><?php comment_link() ?></link>
     
    7879    </item>
    7980<?php
    80             }
     81            } 
    8182        }
    8283    }
  • trunk/wp-config-sample.php

    • Property svn:eol-style changed from CRLF to native
  • trunk/wp-content/plugins/hello.php

    r3503 r4431  
    4242$lyrics = explode("\n", $lyrics);
    4343// And then randomly choose a line
    44 $chosen = wptexturize( $lyrics[ mt_rand(0, count($lyrics) ) ] );
     44$chosen = wptexturize( $lyrics[ mt_rand(0, count($lyrics) - 1) ] );
    4545
    4646// This just echoes the chosen line, we'll position it later
  • trunk/wp-content/themes/classic/comments-popup.php

    r3503 r4431  
    77<html xmlns="http://www.w3.org/1999/xhtml">
    88<head>
    9      <title><?php echo get_settings('blogname'); ?> - <?php echo sprintf(__("Comments on %s"), the_title('','',false)); ?></title>
     9     <title><?php echo get_option('blogname'); ?> - <?php echo sprintf(__("Comments on %s"), the_title('','',false)); ?></title>
    1010
    11     <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
     11    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
    1212    <style type="text/css" media="screen">
    1313        @import url( <?php bloginfo('stylesheet_url'); ?> );
     
    1818<body id="commentspopup">
    1919
    20 <h1 id="header"><a href="" title="<?php echo get_settings('blogname'); ?>"><?php echo get_settings('blogname'); ?></a></h1>
     20<h1 id="header"><a href="" title="<?php echo get_option('blogname'); ?>"><?php echo get_option('blogname'); ?></a></h1>
    2121
    2222<h2 id="comments"><?php _e("Comments"); ?></h2>
    2323
    24 <p><a href="<?php echo get_settings('siteurl'); ?>/wp-commentsrss2.php?p=<?php echo $post->ID; ?>"><?php _e("<abbr title=\"Really Simple Syndication\">RSS</abbr> feed for comments on this post."); ?></a></p>
     24<p><a href="<?php echo get_option('siteurl'); ?>/wp-commentsrss2.php?p=<?php echo $post->ID; ?>"><?php _e("<abbr title=\"Really Simple Syndication\">RSS</abbr> feed for comments on this post."); ?></a></p>
    2525
    2626<?php if ('open' == $post->ping_status) { ?>
    27 <p><?php _e("The <acronym title=\"Uniform Resource Identifier\">URI</acronym> to TrackBack this entry is:"); ?> <em><?php trackback_url() ?></em></p>
     27<p><?php _e("The <abbr title=\"Universal Resource Locator\">URL</abbr> to TrackBack this entry is:"); ?> <em><?php trackback_url() ?></em></p>
    2828<?php } ?>
    2929
    3030<?php
    3131// this line is WordPress' motor, do not delete it.
    32 $comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
    33 $comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
    34 $comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : '';
     32$commenter = wp_get_current_commenter();
     33extract($commenter);
    3534$comments = get_approved_comments($id);
    3635$commentstatus = get_post($id);
     
    5756<p><?php _e("Line and paragraph breaks automatic, e-mail address never displayed, <acronym title=\"Hypertext Markup Language\">HTML</acronym> allowed:"); ?> <code><?php echo allowed_tags(); ?></code></p>
    5857
    59 <form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
     58<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    6059    <p>
    6160      <input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" />
     
    7271    <p>
    7372      <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="28" tabindex="3" />
    74        <label for="url"><?php _e("<acronym title=\"Uniform Resource Identifier\">URI</acronym>"); ?></label>
     73       <label for="url"><?php _e("<abbr title=\"Universal Resource Locator\">URL</abbr>"); ?></label>
    7574    </p>
    7675
     
    104103<script type="text/javascript">
    105104<!--
    106 document.onkeypress = function esc(e) { 
     105document.onkeypress = function esc(e) {
    107106    if(typeof(e) == "undefined") { e=event; }
    108107    if (e.keyCode == 27) { self.close(); }
  • trunk/wp-content/themes/classic/comments.php

    r3503 r4431  
    2828<p><?php comments_rss_link(__('<abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.')); ?>
    2929<?php if ( pings_open() ) : ?>
    30     <a href="<?php trackback_url() ?>" rel="trackback"><?php _e('TrackBack <abbr title="Uniform Resource Identifier">URI</abbr>'); ?></a>
     30    <a href="<?php trackback_url() ?>" rel="trackback"><?php _e('TrackBack <abbr title="Universal Resource Locator">URL</abbr>'); ?></a>
    3131<?php endif; ?>
    3232</p>
  • trunk/wp-content/themes/classic/header.php

    r3503 r4431  
    66
    77    <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
    8    
     8
    99    <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats please -->
    1010
     
    1616    <link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
    1717    <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
    18    
     18
    1919    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
    2020    <?php wp_get_archives('type=monthly&format=link'); ?>
  • trunk/wp-content/themes/classic/index.php

    r3503 r4431  
    66
    77<?php the_date('','<h2>','</h2>'); ?>
    8    
     8
    99<div class="post" id="post-<?php the_ID(); ?>">
    1010     <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    1111    <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> &#8212; <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
    12    
     12
    1313    <div class="storycontent">
    1414        <?php the_content(__('(more...)')); ?>
    1515    </div>
    16    
     16
    1717    <div class="feedback">
    1818            <?php wp_link_pages(); ?>
  • trunk/wp-content/themes/classic/sidebar.php

    r3503 r4431  
    44
    55<ul>
    6     <?php wp_list_pages(); ?>
    7     <?php get_links_list(); ?>
    8  <li id="categories"><?php _e('Categories:'); ?>
    9     <ul>
    10     <?php wp_list_cats(); ?>
    11     </ul>
    12  </li>
     6    <?php wp_list_pages('title_li=' . __('Pages:')); ?>
     7    <?php wp_list_bookmarks('title_after=&title_before='); ?>
     8    <?php wp_list_categories('title_li=' . __('Categories:')); ?>
    139 <li id="search">
    14    <label for="s"><?php _e('Search:'); ?></label>   
    15    <form id="searchform" method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
     10   <label for="s"><?php _e('Search:'); ?></label>
     11   <form id="searchform" method="get" action="<?php bloginfo('home'); ?>">
    1612    <div>
    1713        <input type="text" name="s" id="s" size="15" /><br />
  • trunk/wp-content/themes/default/archive.php

    r3503 r4431  
    66
    77         <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
    8 <?php /* If this is a category archive */ if (is_category()) { ?>               
     8<?php /* If this is a category archive */ if (is_category()) { ?>
    99        <h2 class="pagetitle">Archive for the '<?php echo single_cat_title(); ?>' Category</h2>
    10        
     10
    1111      <?php /* If this is a daily archive */ } elseif (is_day()) { ?>
    1212        <h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2>
    13        
     13
    1414     <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    1515        <h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2>
     
    1717        <?php /* If this is a yearly archive */ } elseif (is_year()) { ?>
    1818        <h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>
    19        
    20       <?php /* If this is a search */ } elseif (is_search()) { ?>
    21         <h2 class="pagetitle">Search Results</h2>
    22        
     19
    2320      <?php /* If this is an author archive */ } elseif (is_author()) { ?>
    2421        <h2 class="pagetitle">Author Archive</h2>
     
    3936                <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    4037                <small><?php the_time('l, F jS, Y') ?></small>
    41                
     38
    4239                <div class="entry">
    4340                    <?php the_content() ?>
    4441                </div>
    45        
     42
    4643                <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
    4744
    4845            </div>
    49    
     46
    5047        <?php endwhile; ?>
    5148
     
    5451            <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    5552        </div>
    56    
     53
    5754    <?php else : ?>
    5855
     
    6158
    6259    <?php endif; ?>
    63        
     60
    6461    </div>
    6562
  • trunk/wp-content/themes/default/archives.php

    r3503 r4431  
    1818<h2>Archives by Subject:</h2>
    1919  <ul>
    20      <?php wp_list_cats(); ?>
     20     <?php wp_list_categories(); ?>
    2121  </ul>
    2222
    23 </div> 
     23</div>
    2424
    2525<?php get_footer(); ?>
  • trunk/wp-content/themes/default/attachment.php

    r3503 r4431  
    22
    33    <div id="content" class="widecolumn">
    4                
     4
    55  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    6    
     6
    77        <div class="navigation">
    88            <div class="alignleft">&nbsp;</div>
     
    1313        <div class="post" id="post-<?php the_ID(); ?>">
    1414            <h2><a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?></a> &raquo; <a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    15             <div class="entrytext">
     15            <div class="entry">
    1616                <p class="<?php echo $classname; ?>"><?php echo $attachment_link; ?><br /><?php echo basename($post->guid); ?></p>
    1717
    1818                <?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>
    19    
    20                 <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
    21    
     19
     20                <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
     21
    2222                <p class="postmetadata alt">
    2323                    <small>
     
    3030                        and is filed under <?php the_category(', ') ?>.
    3131                        You can follow any responses to this entry through the <?php comments_rss_link('RSS 2.0'); ?> feed.
    32                        
     32
    3333                        <?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
    3434                            // Both Comments and Pings are open ?>
    3535                            You can <a href="#respond">leave a response</a>, or <a href="<?php trackback_url(true); ?>" rel="trackback">trackback</a> from your own site.
    36                        
     36
    3737                        <?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
    3838                            // Only Pings are Open ?>
    3939                            Responses are currently closed, but you can <a href="<?php trackback_url(true); ?> " rel="trackback">trackback</a> from your own site.
    40                        
     40
    4141                        <?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
    4242                            // Comments are open, Pings are not ?>
    4343                            You can skip to the end and leave a response. Pinging is currently not allowed.
    44            
     44
    4545                        <?php } elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
    4646                            // Neither Comments, nor Pings are open ?>
    47                             Both comments and pings are currently closed.           
    48                        
     47                            Both comments and pings are currently closed.
     48
    4949                        <?php } edit_post_link('Edit this entry.','',''); ?>
    50                        
     50
    5151                    </small>
    5252                </p>
    53    
     53
    5454            </div>
    5555        </div>
    56        
     56
    5757    <?php comments_template(); ?>
    58    
     58
    5959    <?php endwhile; else: ?>
    60    
     60
    6161        <p>Sorry, no attachments matched your criteria.</p>
    62    
     62
    6363<?php endif; ?>
    64    
     64
    6565    </div>
    6666
  • trunk/wp-content/themes/default/comments-popup.php

    r3503 r4431  
    77<html xmlns="http://www.w3.org/1999/xhtml">
    88<head>
    9      <title><?php echo get_settings('blogname'); ?> - Comments on <?php the_title(); ?></title>
     9     <title><?php echo get_option('blogname'); ?> - Comments on <?php the_title(); ?></title>
    1010
    11     <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_settings('blog_charset'); ?>" />
     11    <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
    1212    <style type="text/css" media="screen">
    1313        @import url( <?php bloginfo('stylesheet_url'); ?> );
     
    1818<body id="commentspopup">
    1919
    20 <h1 id="header"><a href="" title="<?php echo get_settings('blogname'); ?>"><?php echo get_settings('blogname'); ?></a></h1>
     20<h1 id="header"><a href="" title="<?php echo get_option('blogname'); ?>"><?php echo get_option('blogname'); ?></a></h1>
    2121
    2222<h2 id="comments">Comments</h2>
    2323
    24 <p><a href="<?php echo get_settings('siteurl'); ?>/wp-commentsrss2.php?p=<?php echo $post->ID; ?>"><abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.</a></p>
     24<p><a href="<?php echo get_option('siteurl'); ?>/wp-commentsrss2.php?p=<?php echo $post->ID; ?>"><abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.</a></p>
    2525
    2626<?php if ('open' == $post->ping_status) { ?>
    27 <p>The <acronym title="Uniform Resource Identifier">URI</acronym> to TrackBack this entry is: <em><?php trackback_url() ?></em></p>
     27<p>The <abbr title="Universal Resource Locator">URL</abbr> to TrackBack this entry is: <em><?php trackback_url() ?></em></p>
    2828<?php } ?>
    2929
    3030<?php
    3131// this line is WordPress' motor, do not delete it.
    32 $comment_author = (isset($_COOKIE['comment_author_' . COOKIEHASH])) ? trim($_COOKIE['comment_author_'. COOKIEHASH]) : '';
    33 $comment_author_email = (isset($_COOKIE['comment_author_email_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_email_'. COOKIEHASH]) : '';
    34 $comment_author_url = (isset($_COOKIE['comment_author_url_'. COOKIEHASH])) ? trim($_COOKIE['comment_author_url_'. COOKIEHASH]) : '';
     32$commenter = wp_get_current_commenter();
     33extract($commenter);
    3534$comments = get_approved_comments($id);
    3635$post = get_post($id);
     
    5756<p>Line and paragraph breaks automatic, e-mail address never displayed, <acronym title="Hypertext Markup Language">HTML</acronym> allowed: <code><?php echo allowed_tags(); ?></code></p>
    5857
    59 <form action="<?php echo get_settings('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
     58<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
    6059    <p>
    6160      <input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" />
     
    7271    <p>
    7372      <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="28" tabindex="3" />
    74        <label for="url"><acronym title="Uniform Resource Identifier">URI</acronym></label>
     73       <label for="url"><abbr title="Universal Resource Locator">URL</abbr></label>
    7574    </p>
    7675
     
    104103<script type="text/javascript">
    105104<!--
    106 document.onkeypress = function esc(e) { 
     105document.onkeypress = function esc(e) {
    107106    if(typeof(e) == "undefined") { e=event; }
    108107    if (e.keyCode == 27) { self.close(); }
  • trunk/wp-content/themes/default/comments.php

    r3503 r4431  
    66            if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
    77                ?>
    8                
     8
    99                <p class="nocomments">This post is password protected. Enter the password to view comments.<p>
    10                
     10
    1111                <?php
    1212                return;
     
    4040        </li>
    4141
    42     <?php /* Changes every other comment to a different class */   
     42    <?php /* Changes every other comment to a different class */
    4343        if ('alt' == $oddcomment) $oddcomment = '';
    4444        else $oddcomment = 'alt';
     
    5353  <?php if ('open' == $post->comment_status) : ?>
    5454        <!-- If comments are open, but there are no comments. -->
    55        
     55
    5656     <?php else : // comments are closed ?>
    5757        <!-- If comments are closed. -->
    5858        <p class="nocomments">Comments are closed.</p>
    59        
     59
    6060    <?php endif; ?>
    6161<?php endif; ?>
  • trunk/wp-content/themes/default/footer.php

    r3503 r4431  
    22<hr />
    33<div id="footer">
     4<!-- If you'd like to support WordPress, having the "powered by" link someone on your blog is the best way, it's our only promotion or advertising. -->
    45    <p>
    56        <?php bloginfo('name'); ?> is proudly powered by
  • trunk/wp-content/themes/default/functions.php

    r3503 r4431  
    2222
    2323function kubrick_header_image() {
    24     return apply_filters('kubrick_header_image', get_settings('kubrick_header_image'));
     24    return apply_filters('kubrick_header_image', get_option('kubrick_header_image'));
    2525}
    2626
     
    5151
    5252function kubrick_header_color() {
    53     return apply_filters('kubrick_header_color', get_settings('kubrick_header_color'));
     53    return apply_filters('kubrick_header_color', get_option('kubrick_header_color'));
    5454}
    5555
     
    5858    if ( false === $color )
    5959        return 'white';
    60        
     60
    6161    return $color;
    6262}
    6363
    6464function kubrick_header_display() {
    65     return apply_filters('kubrick_header_display', get_settings('kubrick_header_display'));
     65    return apply_filters('kubrick_header_display', get_option('kubrick_header_display'));
    6666}
    6767
     
    9494
    9595                    if ( isset($_REQUEST['toggledisplay']) ) {
    96                         if ( false === get_settings('kubrick_header_display') )
     96                        if ( false === get_option('kubrick_header_display') )
    9797                            update_option('kubrick_header_display', 'none');
    9898                        else
     
    101101                }
    102102            } else {
    103    
     103
    104104                if ( isset($_REQUEST['headerimage']) ) {
    105105                    if ( '' == $_REQUEST['headerimage'] )
     
    108108                        update_option('kubrick_header_image', $_REQUEST['headerimage']);
    109109                }
    110    
     110
    111111                if ( isset($_REQUEST['fontcolor']) ) {
    112112                    if ( '' == $_REQUEST['fontcolor'] )
     
    115115                        update_option('kubrick_header_color', $_REQUEST['fontcolor']);
    116116                }
    117    
     117
    118118                if ( isset($_REQUEST['fontdisplay']) ) {
    119119                    if ( '' == $_REQUEST['fontdisplay'] || 'inline' == $_REQUEST['fontdisplay'] )
     
    124124            }
    125125            //print_r($_REQUEST);
    126             header("Location: themes.php?page=functions.php&saved=true");
     126            wp_redirect("themes.php?page=functions.php&saved=true");
    127127            die;
    128128        }
     
    136136<script type="text/javascript" src="../wp-includes/js/colorpicker.js"></script>
    137137<script type='text/javascript'>
     138// <![CDATA[
    138139    function pickColor(color) {
    139140        ColorPicker_targetInput.value = color;
     
    240241    }
    241242    addLoadEvent(kInit);
     243// ]]>
    242244</script>
    243245<style type='text/css'>
     
    269271        font-size: 1.2em;
    270272        text-align: center;
    271     }   
     273    }
    272274    #kubrick-header #header {
    273275        text-decoration: none;
     
    352354        <br />
    353355        <div id="nonJsForm">
    354             <form method="POST">
     356            <form method="post" action="">
    355357                <div class="zerosize"><input type="submit" name="defaultsubmit" value="Save" /></div>
    356358                <label for="njfontcolor">Font Color:</label><input type="text" name="njfontcolor" id="njfontcolor" value="<?php echo kubrick_header_color(); ?>" /> Any CSS color (<code>red</code> or <code>#FF0000</code> or <code>rgb(255, 0, 0)</code>)<br />
     
    358360                <label for="njlowercolor">Lower Color:</label><input type="text" name="njlowercolor" id="njlowercolor" value="#<?php echo kubrick_lower_color(); ?>" /> HEX only (<code>#FF0000</code> or <code>#F00</code>)<br />
    359361                <input type="hidden" name="hi" id="hi" value="<?php echo kubrick_header_image(); ?>" />
    360                 <label> </label><input type="submit" name="toggledisplay" id="toggledisplay" value="Toggle Text" />
     362                <input type="submit" name="toggledisplay" id="toggledisplay" value="Toggle Text" />
    361363                <input type="submit" name="defaults" value="Use Defaults" />
    362364                <input type="submit" class="defbutton" name="submitform" value="&nbsp;&nbsp;Save&nbsp;&nbsp;" />
     
    372374                <input type="button" name="revert" value="Revert" onclick="kRevert()" />
    373375                <input type="button" value="Advanced" onclick="toggleAdvanced()" />
    374                 <input type="submit" name="submitform" class="defbutton" value="Save" onclick="cp.hidePopup('prettyplease')" />
    375376                <input type="hidden" name="action" value="save" />
    376377                <input type="hidden" name="fontdisplay" id="fontdisplay" value="<?php echo kubrick_header_display(); ?>" />
     
    379380                <input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo kubrick_lower_color(); ?>" />
    380381                <input type="hidden" name="headerimage" id="headerimage" value="<?php echo kubrick_header_image(); ?>" />
     382                <p class="submit"><input type="submit" name="submitform" class="defbutton" value="<?php _e('Update Header &raquo;'); ?>" onclick="cp.hidePopup('prettyplease')" /></p>
    381383            </form>
    382384            <div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div>
    383385            <div id="advanced">
    384                 <form id="jsAdvanced" style="display:none;">
     386                <form id="jsAdvanced" style="display:none;" action="">
    385387                    <label for="advfontcolor">Font Color (CSS): </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="<?php echo kubrick_header_color(); ?>" /><br />
    386388                    <label for="advuppercolor">Upper Color (HEX): </label><input type="text" id="advuppercolor" onchange="advUpdate(this.value, 'uppercolor')" value="#<?php echo kubrick_upper_color(); ?>" /><br />
  • trunk/wp-content/themes/default/header.php

    r3503 r4431  
    1414
    1515<style type="text/css" media="screen">
    16 /*  To accomodate differing install paths of WordPress, images are referred only here,
    17     and not in the wp-layout.css file. If you prefer to use only CSS for colors and what
    18     not, then go right ahead and delete the following lines, and the image files. */
    19        
    20     body { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgcolor.jpg"); }   
    21 <?php /* Checks to see whether it needs a sidebar or not */ if ((! $withcomments) && (! is_single())) { ?>
     16
     17<?php
     18// Checks to see whether it needs a sidebar or not
     19if ( !$withcomments && !is_single() ) {
     20?>
    2221    #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg.jpg") repeat-y top; border: none; }
    2322<?php } else { // No sidebar ?>
    2423    #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; }
    2524<?php } ?>
    26     #header { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickheader.jpg") no-repeat bottom center; }
    27     #footer { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickfooter.jpg") no-repeat bottom; border: none;}
    2825
    29 /*  Because the template is slightly different, size-wise, with images, this needs to be set here
    30     If you don't want to use the template's images, you can also delete the following two lines. */
    31        
    32     #header     { margin: 0 !important; margin: 0 0 0 1px; padding: 1px; height: 198px; width: 758px; }
    33     #headerimg  { margin: 7px 9px 0; height: 192px; width: 740px; }
    34 
    35 /*  To ease the insertion of a personal header image, I have done it in such a way,
    36     that you simply drop in an image called 'personalheader.jpg' into your /images/
    37     directory. Dimensions should be at least 760px x 200px. Anything above that will
    38     get cropped off of the image. */
    39     /*
    40     #headerimg { background: url('<?php bloginfo('stylesheet_directory'); ?>/images/personalheader.jpg') no-repeat top;}
    41     */
    4226</style>
    4327
     
    5034<div id="header">
    5135    <div id="headerimg">
    52         <h1><a href="<?php echo get_settings('home'); ?>/"><?php bloginfo('name'); ?></a></h1>
     36        <h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1>
    5337        <div class="description"><?php bloginfo('description'); ?></div>
    5438    </div>
  • trunk/wp-content/themes/default/index.php

    r3503 r4431  
    44
    55    <?php if (have_posts()) : ?>
    6        
     6
    77        <?php while (have_posts()) : the_post(); ?>
    8                
     8
    99            <div class="post" id="post-<?php the_ID(); ?>">
    1010                <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    1111                <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    12                
     12
    1313                <div class="entry">
    1414                    <?php the_content('Read the rest of this entry &raquo;'); ?>
    1515                </div>
    16        
     16
    1717                <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
    1818            </div>
    19    
     19
    2020        <?php endwhile; ?>
    2121
     
    2424            <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    2525        </div>
    26        
     26
    2727    <?php else : ?>
    2828
  • trunk/wp-content/themes/default/links.php

    r3503 r4431  
    1414</ul>
    1515
    16 </div> 
     16</div>
    1717
    1818<?php get_footer(); ?>
  • trunk/wp-content/themes/default/page.php

    r3503 r4431  
    66        <div class="post" id="post-<?php the_ID(); ?>">
    77        <h2><?php the_title(); ?></h2>
    8             <div class="entrytext">
     8            <div class="entry">
    99                <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    10    
    11                 <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
    12    
     10
     11                <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
     12
    1313            </div>
    1414        </div>
  • trunk/wp-content/themes/default/search.php

    r3503 r4431  
    66
    77        <h2 class="pagetitle">Search Results</h2>
    8        
     8
    99        <div class="navigation">
    1010            <div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
     
    1414
    1515        <?php while (have_posts()) : the_post(); ?>
    16                
     16
    1717            <div class="post">
    1818                <h3 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    1919                <small><?php the_time('l, F jS, Y') ?></small>
    20        
     20
    2121                <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>
    2222            </div>
    23    
     23
    2424        <?php endwhile; ?>
    2525
     
    2828            <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    2929        </div>
    30    
     30
    3131    <?php else : ?>
    3232
     
    3535
    3636    <?php endif; ?>
    37        
     37
    3838    </div>
    3939
  • trunk/wp-content/themes/default/searchform.php

    r3503 r4431  
    11<form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
    2 <div><input type="text" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" />
     2<div><input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
    33<input type="submit" id="searchsubmit" value="Search" />
    44</div>
  • trunk/wp-content/themes/default/sidebar.php

    r3503 r4431  
    11    <div id="sidebar">
    22        <ul>
    3            
     3
    44            <li>
    55                <?php include (TEMPLATEPATH . '/searchform.php'); ?>
     
    1616            <?php /* If this is a category archive */ } elseif (is_category()) { ?>
    1717            <p>You are currently browsing the archives for the <?php single_cat_title(''); ?> category.</p>
    18            
     18
    1919            <?php /* If this is a yearly archive */ } elseif (is_day()) { ?>
    2020            <p>You are currently browsing the <a href="<?php bloginfo('home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives
    2121            for the day <?php the_time('l, F jS, Y'); ?>.</p>
    22            
     22
    2323            <?php /* If this is a monthly archive */ } elseif (is_month()) { ?>
    2424            <p>You are currently browsing the <a href="<?php bloginfo('home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives
     
    2828            <p>You are currently browsing the <a href="<?php bloginfo('home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives
    2929            for the year <?php the_time('Y'); ?>.</p>
    30            
     30
    3131         <?php /* If this is a monthly archive */ } elseif (is_search()) { ?>
    3232            <p>You have searched the <a href="<?php echo bloginfo('home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives
    33             for <strong>'<?php echo wp_specialchars($s); ?>'</strong>. If you are unable to find anything in these search results, you can try one of these links.</p>
     33            for <strong>'<?php the_search_query(); ?>'</strong>. If you are unable to find anything in these search results, you can try one of these links.</p>
    3434
    3535            <?php /* If this is a monthly archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?>
     
    4747            </li>
    4848
    49             <li><h2>Categories</h2>
    50                 <ul>
    51                 <?php wp_list_cats('sort_column=name&optioncount=1&hierarchical=0'); ?>
    52                 </ul>
    53             </li>
     49            <?php wp_list_categories('optioncount=1&hierarchical=0&title_li=<h2>Categories</h2>'); ?>
    5450
    55             <?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?>             
    56                 <?php get_links_list(); ?>
    57                
     51            <?php /* If this is the frontpage */ if ( is_home() || is_page() ) { ?>
     52                <?php wp_list_bookmarks(); ?>
     53
    5854                <li><h2>Meta</h2>
    5955                <ul>
     
    6763                </li>
    6864            <?php } ?>
    69            
     65
    7066        </ul>
    7167    </div>
  • trunk/wp-content/themes/default/single.php

    r3503 r4431  
    22
    33    <div id="content" class="widecolumn">
    4                
     4
    55  <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    6    
     6
    77        <div class="navigation">
    88            <div class="alignleft"><?php previous_post_link('&laquo; %link') ?></div>
    99            <div class="alignright"><?php next_post_link('%link &raquo;') ?></div>
    1010        </div>
    11    
     11
    1212        <div class="post" id="post-<?php the_ID(); ?>">
    1313            <h2><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2>
    14    
    15             <div class="entrytext">
     14
     15            <div class="entry">
    1616                <?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>
    17    
    18                 <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?>
    19    
     17
     18                <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
     19
    2020                <p class="postmetadata alt">
    2121                    <small>
     
    2828                        and is filed under <?php the_category(', ') ?>.
    2929                        You can follow any responses to this entry through the <?php comments_rss_link('RSS 2.0'); ?> feed.
    30                        
     30
    3131                        <?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
    3232                            // Both Comments and Pings are open ?>
    3333                            You can <a href="#respond">leave a response</a>, or <a href="<?php trackback_url(true); ?>" rel="trackback">trackback</a> from your own site.
    34                        
     34
    3535                        <?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) {
    3636                            // Only Pings are Open ?>
    3737                            Responses are currently closed, but you can <a href="<?php trackback_url(true); ?> " rel="trackback">trackback</a> from your own site.
    38                        
     38
    3939                        <?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
    4040                            // Comments are open, Pings are not ?>
    4141                            You can skip to the end and leave a response. Pinging is currently not allowed.
    42            
     42
    4343                        <?php } elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) {
    4444                            // Neither Comments, nor Pings are open ?>
    45                             Both comments and pings are currently closed.           
    46                        
     45                            Both comments and pings are currently closed.
     46
    4747                        <?php } edit_post_link('Edit this entry.','',''); ?>
    48                        
     48
    4949                    </small>
    5050                </p>
    51    
     51
    5252            </div>
    5353        </div>
    54        
     54
    5555    <?php comments_template(); ?>
    56    
     56
    5757    <?php endwhile; else: ?>
    58    
     58
    5959        <p>Sorry, no posts matched your criteria.</p>
    60    
     60
    6161<?php endif; ?>
    62    
     62
    6363    </div>
    6464
  • trunk/wp-content/themes/default/style.css

    r3503 r4431  
    33Theme URI: http://wordpress.org/
    44Description: The default WordPress theme based on the famous <a href="http://binarybonsai.com/kubrick/">Kubrick</a>.
    5 Version: 1.5
     5Version: 1.6
    66Author: Michael Heilemann
    77Author URI: http://binarybonsai.com/
     
    1515    The CSS, XHTML and design is released under GPL:
    1616    http://www.opensource.org/licenses/gpl-license.php
    17    
    18 
    19     *** REGARDING IMAGES ***
    20     All CSS that involves the use of images, can be found in the 'index.php' file.
    21     This is to ease installation inside subdirectories of a server.
    22 
    23     Have fun, and don't be afraid to contact me if you have questions.
     17
    2418*/
    2519
     
    3024    font-size: 62.5%; /* Resets 1em to 10px */
    3125    font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif;
    32     background-color: #d5d6d7;
     26    background: #d5d6d7 url('images/kubrickbgcolor.jpg');
    3327    color: #333;
    3428    text-align: center;
     
    4236
    4337#header {
    44     background-color: #73a0c5;
    45     }
     38    background: #73a0c5 url('images/kubrickheader.jpg') no-repeat bottom center;
     39    }
     40
     41#headerimg  {
     42    margin: 7px 9px 0;
     43    height: 192px;
     44    width: 740px;
     45    }
    4646
    4747#content {
     
    6060    line-height: 1.6em;
    6161    }
    62    
     62
    6363.narrowcolumn .postmetadata {
    6464    text-align: center;
     
    7272
    7373#footer {
    74     background-color: #eee;
     74    background: #eee url('images/kubrickfooter.jpg') no-repeat top;
     75    border: none;
    7576    }
    7677
     
    133134    font: 0.9em 'Lucida Grande', Verdana, Arial, Sans-Serif;
    134135    }
    135    
     136
    136137.commentlist li {
    137138    font-weight: bold;
     
    165166    color: #777;
    166167    }
    167    
     168
    168169code {
    169170    font: 1.1em 'Courier New', Courier, Fixed;
     
    185186    text-decoration: underline;
    186187    }
    187    
     188
    188189#wp-calendar #prev a {
    189190    font-size: 9pt;
     
    209210/* Begin Structure */
    210211body {
    211     margin: 0;
     212    margin: 0 0 20px 0;
    212213    padding: 0;
    213214    }
     
    220221    border: 1px solid #959596;
    221222    }
    222    
     223
    223224#header {
    224     padding: 0;
    225     margin: 0 auto;
    226     height: 200px;
    227     width: 100%;
    228225    background-color: #73a0c5;
     226    margin: 0 0 0 1px;
     227    padding: 0;
     228    height: 200px;
     229    width: 758px;
    229230    }
    230231
     
    247248    width: 450px;
    248249    }
    249    
     250
    250251.post {
    251252    margin: 0 0 40px;
     
    282283
    283284#footer {
    284     padding: 0 0 0 1px;
     285    padding: 0;
    285286    margin: 0 auto;
    286287    width: 760px;
     
    340341    will of course center the image. This is much better than using
    341342    align="center", being much more futureproof (and valid) */
    342    
     343
    343344img.centered {
    344345    display: block;
     
    346347    margin-right: auto;
    347348    }
    348    
     349
    349350img.alignright {
    350351    padding: 4px;
     
    362363    float: right;
    363364    }
    364    
     365
    365366.alignleft {
    366367    float: left
     
    406407    list-style-image: none;
    407408    }
    408    
     409
    409410#sidebar ul, #sidebar ul ol {
    410411    margin: 0;
     
    450451
    451452#sidebar #searchform #s {
    452     width: 115px;
     453    width: 108px;
    453454    padding: 2px;
    454455    }
  • trunk/wp-feed.php

    r3503 r4431  
    66}
    77
    8 // Remove the pad, if present.
    9 $feed = preg_replace('/^_+/', '', $feed);
    10 
    11 if ($feed == '' || $feed == 'feed') {
    12     $feed = 'rss2';
    13 }
    14 
    15 if ( is_single() || ($withcomments == 1) ) {
    16     require(ABSPATH . 'wp-commentsrss2.php');
    17 } else {
    18     switch ($feed) {
    19     case 'atom':
    20         require(ABSPATH . 'wp-atom.php');
    21         break;
    22     case 'rdf':
    23         require(ABSPATH . 'wp-rdf.php');
    24         break;
    25     case 'rss':
    26         require(ABSPATH . 'wp-rss.php');
    27         break;
    28     case 'rss2':
    29         require(ABSPATH . 'wp-rss2.php');
    30         break;
    31     case 'comments-rss2':
    32         require(ABSPATH . 'wp-commentsrss2.php');
    33         break;
    34     }
    35 }
     8do_feed();
    369
    3710?>
  • trunk/wp-includes/cache.php

    r3503 r4431  
    4848}
    4949
    50 define('CACHE_SERIAL_HEADER', "<?php\n//");
    51 define('CACHE_SERIAL_FOOTER', "\n?".">");
     50define('CACHE_SERIAL_HEADER', "<?php\n/*");
     51define('CACHE_SERIAL_FOOTER', "*/\n?".">");
    5252
    5353class WP_Object_Cache {
     
    6565    var $warm_cache_hits = 0;
    6666    var $cache_misses = 0;
     67    var $secret = '';
    6768
    6869    function acquire_lock() {
     
    104105        if ( ! $this->acquire_lock() )
    105106            return false;
    106        
     107
    107108        $this->rm_cache_dir();
    108109        $this->cache = array ();
    109110        $this->dirty_objects = array ();
    110111        $this->non_existant_objects = array ();
    111        
     112
    112113        $this->release_lock();
    113114
     
    143144        }
    144145
    145         $cache_file = $this->cache_dir.$this->get_group_dir($group)."/".md5($id.DB_PASSWORD).'.php';
     146        $cache_file = $this->cache_dir.$this->get_group_dir($group)."/".$this->hash($id).'.php';
    146147        if (!file_exists($cache_file)) {
    147148            $this->non_existant_objects[$group][$id] = true;
     
    159160        }
    160161
    161         $this->cache[$group][$id] = unserialize(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER)));
     162        $this->cache[$group][$id] = unserialize(base64_decode(substr(@ file_get_contents($cache_file), strlen(CACHE_SERIAL_HEADER), -strlen(CACHE_SERIAL_FOOTER))));
    162163        if (false === $this->cache[$group][$id])
    163164            $this->cache[$group][$id] = '';
     
    172173
    173174        return "{$this->blog_id}/$group";
     175    }
     176
     177    function hash($data) {
     178        if ( function_exists('hash_hmac') ) {
     179            return hash_hmac('md5', $data, $this->secret);
     180        } else {
     181            return md5($data . $this->secret);
     182        }
    174183    }
    175184
     
    182191                foreach ($dogs as $catt)
    183192                    $this->cache['category'][$catt->cat_ID] = $catt;
    184 
    185                 foreach ($this->cache['category'] as $catt) {
    186                     $curcat = $catt->cat_ID;
    187                     $fullpath = '/'.$this->cache['category'][$catt->cat_ID]->category_nicename;
    188                     while ($this->cache['category'][$curcat]->category_parent != 0) {
    189                         $curcat = $this->cache['category'][$curcat]->category_parent;
    190                         $fullpath = '/'.$this->cache['category'][$curcat]->category_nicename.$fullpath;
    191                     }
    192                     $this->cache['category'][$catt->cat_ID]->fullpath = $fullpath;
    193                 }
    194193            }
    195194        } else
     
    249248                if ($file == '.' or $file == '..')
    250249                    continue;
    251                    
     250
    252251                if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file))
    253252                    $stack[] = $dir . DIRECTORY_SEPARATOR . $file;
     
    333332            $ids = array_unique($ids);
    334333            foreach ($ids as $id) {
    335                 $cache_file = $group_dir.md5($id.DB_PASSWORD).'.php';
     334                $cache_file = $group_dir.$this->hash($id).'.php';
    336335
    337336                // Remove the cache file if the key is not set.
     
    343342
    344343                $temp_file = tempnam($group_dir, 'tmp');
    345                 $serial = CACHE_SERIAL_HEADER.serialize($this->cache[$group][$id]).CACHE_SERIAL_FOOTER;
     344                $serial = CACHE_SERIAL_HEADER.base64_encode(serialize($this->cache[$group][$id])).CACHE_SERIAL_FOOTER;
    346345                $fd = @fopen($temp_file, 'w');
    347346                if ( false === $fd ) {
     
    355354                        @ unlink($temp_file);
    356355                    else
    357                         $errors++; 
     356                        $errors++;
    358357                }
    359358                @ chmod($cache_file, $file_perms);
     
    364363
    365364        $this->release_lock();
    366        
     365
    367366        if ( $errors )
    368367            return false;
     
    401400            return;
    402401
     402        if ( ! defined('ENABLE_CACHE') )
     403            return;
     404
    403405        // Disable the persistent cache if safe_mode is on.
    404406        if ( ini_get('safe_mode') && ! defined('ENABLE_CACHE') )
     
    422424            $this->expiration_time = CACHE_EXPIRATION_TIME;
    423425
    424         $this->blog_id = md5($blog_id);
     426        if ( defined('WP_SECRET') )
     427            $this->secret = WP_SECRET;
     428        else
     429            $this->secret = DB_PASSWORD . DB_USER . DB_NAME . DB_HOST . ABSPATH;
     430
     431        $this->blog_id = $this->hash($blog_id);
    425432    }
    426433}
  • trunk/wp-includes/capabilities.php

    r3503 r4431  
    77    var $role_names = array();
    88    var $role_key;
     9    var $use_db = true;
    910
    1011    function WP_Roles() {
    11         global $table_prefix;
    12         $this->role_key = $table_prefix . 'user_roles';
    13 
    14         $this->roles = get_option($this->role_key);
     12        $this->_init();
     13    }
     14
     15    function _init () {
     16        global $wpdb;
     17        global $wp_user_roles;
     18        $this->role_key = $wpdb->prefix . 'user_roles';
     19        if ( ! empty($wp_user_roles) ) {
     20            $this->roles = $wp_user_roles;
     21            $this->use_db = false;
     22        } else {
     23            $this->roles = get_option($this->role_key);
     24        }
    1525
    1626        if ( empty($this->roles) )
    1727            return;
    1828
     29        $this->role_objects = array();
     30        $this->role_names =  array();
    1931        foreach ($this->roles as $role => $data) {
    2032            $this->role_objects[$role] = new WP_Role($role, $this->roles[$role]['capabilities']);
     
    3042            'name' => $display_name,
    3143            'capabilities' => $capabilities);
    32         update_option($this->role_key, $this->roles);
     44        if ( $this->use_db )
     45            update_option($this->role_key, $this->roles);
    3346        $this->role_objects[$role] = new WP_Role($role, $capabilities);
    3447        $this->role_names[$role] = $display_name;
    3548        return $this->role_objects[$role];
    3649    }
    37    
     50
    3851    function remove_role($role) {
    3952        if ( ! isset($this->role_objects[$role]) )
    4053            return;
    41        
     54
    4255        unset($this->role_objects[$role]);
    4356        unset($this->role_names[$role]);
    4457        unset($this->roles[$role]);
    4558       
    46         update_option($this->role_key, $this->roles);
     59        if ( $this->use_db )
     60            update_option($this->role_key, $this->roles);
    4761    }
    4862
    4963    function add_cap($role, $cap, $grant = true) {
    5064        $this->roles[$role]['capabilities'][$cap] = $grant;
    51         update_option($this->role_key, $this->roles);
     65        if ( $this->use_db )
     66            update_option($this->role_key, $this->roles);
    5267    }
    5368
    5469    function remove_cap($role, $cap) {
    5570        unset($this->roles[$role]['capabilities'][$cap]);
    56         update_option($this->role_key, $this->roles);
     71        if ( $this->use_db )
     72            update_option($this->role_key, $this->roles);
    5773    }
    5874
     
    7187    {
    7288        return isset($this->role_names[$role]);
    73     }   
     89    }
    7490}
    7591
     
    122138
    123139    function WP_User($id, $name = '') {
    124         global $table_prefix;
     140        global $wpdb;
    125141
    126142        if ( empty($id) && empty($name) )
     
    145161
    146162        $this->id = $this->ID;
    147         $this->cap_key = $table_prefix . 'capabilities';
     163        $this->_init_caps();
     164    }
     165
     166    function _init_caps() {
     167        global $wpdb;
     168        $this->cap_key = $wpdb->prefix . 'capabilities';
    148169        $this->caps = &$this->{$this->cap_key};
    149170        if ( ! is_array($this->caps) )
     
    151172        $this->get_role_caps();
    152173    }
    153    
     174
    154175    function get_role_caps() {
    155176        global $wp_roles;
    156        
     177
    157178        if ( ! isset($wp_roles) )
    158179            $wp_roles = new WP_Roles();
     
    164185        //Build $allcaps from role caps, overlay user's $caps
    165186        $this->allcaps = array();
    166         foreach($this->roles as $role) {
     187        foreach( (array) $this->roles as $role) {
    167188            $role = $wp_roles->get_role($role);
    168189            $this->allcaps = array_merge($this->allcaps, $role->capabilities);
     
    170191        $this->allcaps = array_merge($this->allcaps, $this->caps);
    171192    }
    172    
     193
    173194    function add_role($role) {
    174195        $this->caps[$role] = true;
     
    177198        $this->update_user_level_from_caps();
    178199    }
    179    
     200
    180201    function remove_role($role) {
    181202        if ( empty($this->roles[$role]) || (count($this->roles) <= 1) )
     
    185206        $this->get_role_caps();
    186207    }
    187    
     208
    188209    function set_role($role) {
    189         foreach($this->roles as $oldrole) 
     210        foreach($this->roles as $oldrole)
    190211            unset($this->caps[$oldrole]);
    191         $this->caps[$role] = true;
    192         $this->roles = array($role => true);
     212        if ( !empty($role) ) {
     213            $this->caps[$role] = true;
     214            $this->roles = array($role => true);
     215        } else {
     216            $this->roles = false;
     217        }
    193218        update_usermeta($this->id, $this->cap_key, $this->caps);
    194219        $this->get_role_caps();
     
    204229        }
    205230    }
    206    
     231
    207232    function update_user_level_from_caps() {
    208         global $table_prefix;
     233        global $wpdb;
    209234        $this->user_level = array_reduce(array_keys($this->allcaps),    array(&$this, 'level_reduction'), 0);
    210         update_usermeta($this->id, $table_prefix.'user_level', $this->user_level);
    211     }
    212    
     235        update_usermeta($this->id, $wpdb->prefix.'user_level', $this->user_level);
     236    }
     237
    213238    function add_cap($cap, $grant = true) {
    214239        $this->caps[$cap] = $grant;
     
    221246        update_usermeta($this->id, $this->cap_key, $this->caps);
    222247    }
    223    
     248
     249    function remove_all_caps() {
     250        global $wpdb;
     251        $this->caps = array();
     252        update_usermeta($this->id, $this->cap_key, '');
     253        update_usermeta($this->id, $wpdb->prefix.'user_level', '');
     254        $this->get_role_caps();
     255    }
     256
    224257    //has_cap(capability_or_role_name) or
    225258    //has_cap('edit_post', post_id)
     
    227260        if ( is_numeric($cap) )
    228261            $cap = $this->translate_level_to_cap($cap);
    229        
     262
    230263        $args = array_slice(func_get_args(), 1);
    231264        $args = array_merge(array($cap, $this->id), $args);
     
    254287
    255288    switch ($cap) {
     289    case 'delete_user':
     290        $caps[] = 'delete_users';
     291        break;
     292    case 'edit_user':
     293        $caps[] = 'edit_users';
     294        break;
     295    case 'delete_post':
     296        $author_data = get_userdata($user_id);
     297        //echo "post ID: {$args[0]}<br/>";
     298        $post = get_post($args[0]);
     299        if ( 'page' == $post->post_type ) {
     300            $args = array_merge(array('delete_page', $user_id), $args);
     301            return call_user_func_array('map_meta_cap', $args);
     302        }
     303        $post_author_data = get_userdata($post->post_author);
     304        //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>";
     305        // If the user is the author...
     306        if ($user_id == $post_author_data->ID) {
     307            // If the post is published...
     308            if ($post->post_status == 'publish')
     309                $caps[] = 'delete_published_posts';
     310            else
     311                // If the post is draft...
     312                $caps[] = 'delete_posts';
     313        } else {
     314            // The user is trying to edit someone else's post.
     315            $caps[] = 'delete_others_posts';
     316            // The post is published, extra cap required.
     317            if ($post->post_status == 'publish')
     318                $caps[] = 'delete_published_posts';
     319            else if ($post->post_status == 'private')
     320                $caps[] = 'delete_private_posts';
     321        }
     322        break;
     323    case 'delete_page':
     324        $author_data = get_userdata($user_id);
     325        //echo "post ID: {$args[0]}<br/>";
     326        $page = get_page($args[0]);
     327        $page_author_data = get_userdata($page->post_author);
     328        //echo "current user id : $user_id, page author id: " . $page_author_data->ID . "<br/>";
     329        // If the user is the author...
     330        if ($user_id == $page_author_data->ID) {
     331            // If the page is published...
     332            if ($page->post_status == 'publish')
     333                $caps[] = 'delete_published_pages';
     334            else
     335                // If the page is draft...
     336                $caps[] = 'delete_pages';
     337        } else {
     338            // The user is trying to edit someone else's page.
     339            $caps[] = 'delete_others_pages';
     340            // The page is published, extra cap required.
     341            if ($page->post_status == 'publish')
     342                $caps[] = 'delete_published_pages';
     343            else if ($page->post_status == 'private')
     344                $caps[] = 'delete_private_pages';
     345        }
     346        break;
    256347        // edit_post breaks down to edit_posts, edit_published_posts, or
    257348        // edit_others_posts
     
    260351        //echo "post ID: {$args[0]}<br/>";
    261352        $post = get_post($args[0]);
     353        if ( 'page' == $post->post_type ) {
     354            $args = array_merge(array('edit_page', $user_id), $args);
     355            return call_user_func_array('map_meta_cap', $args);
     356        }
    262357        $post_author_data = get_userdata($post->post_author);
    263358        //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>";
     
    267362            if ($post->post_status == 'publish')
    268363                $caps[] = 'edit_published_posts';
    269             else if ($post->post_status == 'static')
    270                 $caps[] = 'edit_pages';
    271364            else
    272365                // If the post is draft...
    273366                $caps[] = 'edit_posts';
    274367        } else {
    275             if ($post->post_status == 'static') {
    276                 $caps[] = 'edit_pages';
    277                 break;
    278             }
    279 
    280368            // The user is trying to edit someone else's post.
    281369            $caps[] = 'edit_others_posts';
     
    283371            if ($post->post_status == 'publish')
    284372                $caps[] = 'edit_published_posts';
     373            else if ($post->post_status == 'private')
     374                $caps[] = 'edit_private_posts';
     375        }
     376        break;
     377    case 'edit_page':
     378        $author_data = get_userdata($user_id);
     379        //echo "post ID: {$args[0]}<br/>";
     380        $page = get_page($args[0]);
     381        $page_author_data = get_userdata($page->post_author);
     382        //echo "current user id : $user_id, page author id: " . $page_author_data->ID . "<br/>";
     383        // If the user is the author...
     384        if ($user_id == $page_author_data->ID) {
     385            // If the page is published...
     386            if ($page->post_status == 'publish')
     387                $caps[] = 'edit_published_pages';
     388            else
     389                // If the page is draft...
     390                $caps[] = 'edit_pages';
     391        } else {
     392            // The user is trying to edit someone else's page.
     393            $caps[] = 'edit_others_pages';
     394            // The page is published, extra cap required.
     395            if ($page->post_status == 'publish')
     396                $caps[] = 'edit_published_pages';
     397            else if ($page->post_status == 'private')
     398                $caps[] = 'edit_private_pages';
    285399        }
    286400        break;
    287401    case 'read_post':
    288402        $post = get_post($args[0]);
    289        
     403        if ( 'page' == $post->post_type ) {
     404            $args = array_merge(array('read_page', $user_id), $args);
     405            return call_user_func_array('map_meta_cap', $args);
     406        }
     407
    290408        if ( 'private' != $post->post_status ) {
    291409            $caps[] = 'read';
    292             break; 
    293         }
    294            
     410            break;
     411        }
     412
    295413        $author_data = get_userdata($user_id);
    296414        $post_author_data = get_userdata($post->post_author);
     
    300418            $caps[] = 'read_private_posts';
    301419        break;
     420    case 'read_page':
     421        $page = get_page($args[0]);
     422
     423        if ( 'private' != $page->post_status ) {
     424            $caps[] = 'read';
     425            break;
     426        }
     427
     428        $author_data = get_userdata($user_id);
     429        $page_author_data = get_userdata($post->post_author);
     430        if ($user_id == $page_author_data->ID)
     431            $caps[] = 'read';
     432        else
     433            $caps[] = 'read_private_pages';
     434        break;
    302435    default:
    303436        // If no meta caps match, return the original cap.
     
    310443// Capability checking wrapper around the global $current_user object.
    311444function current_user_can($capability) {
    312     global $current_user;
     445    $current_user = wp_get_current_user();
    313446
    314447    $args = array_slice(func_get_args(), 1);
     
    349482}
    350483
    351 //
    352 // These are deprecated.  Use current_user_can().
    353 //
    354 
    355 /* returns true if $user_id can create a new post */
    356 function user_can_create_post($user_id, $blog_id = 1, $category_id = 'None') {
    357     $author_data = get_userdata($user_id);
    358     return ($author_data->user_level > 1);
    359 }
    360 
    361 /* returns true if $user_id can create a new post */
    362 function user_can_create_draft($user_id, $blog_id = 1, $category_id = 'None') {
    363     $author_data = get_userdata($user_id);
    364     return ($author_data->user_level >= 1);
    365 }
    366 
    367 /* returns true if $user_id can edit $post_id */
    368 function user_can_edit_post($user_id, $post_id, $blog_id = 1) {
    369     $author_data = get_userdata($user_id);
    370     $post = get_post($post_id);
    371     $post_author_data = get_userdata($post->post_author);
    372 
    373     if ( (($user_id == $post_author_data->ID) && !($post->post_status == 'publish' &&  $author_data->user_level < 2))
    374          || ($author_data->user_level > $post_author_data->user_level)
    375          || ($author_data->user_level >= 10) ) {
    376         return true;
    377     } else {
    378         return false;
    379     }
    380 }
    381 
    382 /* returns true if $user_id can delete $post_id */
    383 function user_can_delete_post($user_id, $post_id, $blog_id = 1) {
    384     // right now if one can edit, one can delete
    385     return user_can_edit_post($user_id, $post_id, $blog_id);
    386 }
    387 
    388 /* returns true if $user_id can set new posts' dates on $blog_id */
    389 function user_can_set_post_date($user_id, $blog_id = 1, $category_id = 'None') {
    390     $author_data = get_userdata($user_id);
    391     return (($author_data->user_level > 4) && user_can_create_post($user_id, $blog_id, $category_id));
    392 }
    393 
    394 /* returns true if $user_id can edit $post_id's date */
    395 function user_can_edit_post_date($user_id, $post_id, $blog_id = 1) {
    396     $author_data = get_userdata($user_id);
    397     return (($author_data->user_level > 4) && user_can_edit_post($user_id, $post_id, $blog_id));
    398 }
    399 
    400 /* returns true if $user_id can edit $post_id's comments */
    401 function user_can_edit_post_comments($user_id, $post_id, $blog_id = 1) {
    402     // right now if one can edit a post, one can edit comments made on it
    403     return user_can_edit_post($user_id, $post_id, $blog_id);
    404 }
    405 
    406 /* returns true if $user_id can delete $post_id's comments */
    407 function user_can_delete_post_comments($user_id, $post_id, $blog_id = 1) {
    408     // right now if one can edit comments, one can delete comments
    409     return user_can_edit_post_comments($user_id, $post_id, $blog_id);
    410 }
    411 
    412 function user_can_edit_user($user_id, $other_user) {
    413     $user  = get_userdata($user_id);
    414     $other = get_userdata($other_user);
    415     if ( $user->user_level > $other->user_level || $user->user_level > 8 || $user->ID == $other->ID )
    416         return true;
    417     else
    418         return false;
    419 }
    420 
    421484?>
  • trunk/wp-includes/class-snoopy.php

    r3503 r4431  
    4040{
    4141    /**** Public variables ****/
    42    
     42
    4343    /* user definable vars */
    4444
     
    4949    var $proxy_user     =   "";                 // proxy user to use
    5050    var $proxy_pass     =   "";                 // proxy password to use
    51    
     51
    5252    var $agent          =   "Snoopy v1.2.3";    // agent we masquerade as
    5353    var $referer        =   "";                 // referer info to pass
     
    6767                                                // NOTE: this currently does not respect
    6868                                                // dates, domains or paths.
    69    
     69
    7070    var $user           =   "";                 // user for http authentication
    7171    var $pass           =   "";                 // password for http authentication
    72    
     72
    7373    // http accept types
    7474    var $accept         =   "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
    75    
     75
    7676    var $results        =   "";                 // where the content is put
    77        
     77
    7878    var $error          =   "";                 // error messages sent here
    7979    var $response_code  =   "";                 // response code returned from server
    8080    var $headers        =   array();            // headers returned from server sent here
    81     var $maxlength      =   500000;             // max return data length (body)
     81    var $maxlength      =   8192;               // max return data length (body)
    8282    var $read_timeout   =   0;                  // timeout on read operations, in seconds
    8383                                                // supported only since PHP 4 Beta 4
     
    101101                                                // as these functions are not stable
    102102                                                // as of this Snoopy release.
    103    
    104     /**** Private variables ****/   
    105    
     103
     104    /**** Private variables ****/
     105
    106106    var $_maxlinelen    =   4096;               // max line length (headers)
    107    
     107
    108108    var $_httpmethod    =   "GET";              // default http request method
    109109    var $_httpversion   =   "HTTP/1.0";         // default http request version
     
    115115    var $_frameurls     =   array();            // frame src urls
    116116    var $_framedepth    =   0;                  // increments on frame depth
    117    
     117
    118118    var $_isproxy       =   false;              // set if using a proxy server
    119119    var $_fp_timeout    =   30;                 // timeout for socket connection
     
    130130    function fetch($URI)
    131131    {
    132    
     132
    133133        //preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS);
    134134        $URI_PARTS = parse_url($URI);
     
    141141        if (empty($URI_PARTS["path"]))
    142142            $URI_PARTS["path"] = '';
    143                
     143
    144144        switch(strtolower($URI_PARTS["scheme"]))
    145145        {
     
    161161                        $this->_httprequest($path, $fp, $URI, $this->_httpmethod);
    162162                    }
    163                    
     163
    164164                    $this->_disconnect($fp);
    165165
     
    184184                        $frameurls = $this->_frameurls;
    185185                        $this->_frameurls = array();
    186                        
     186
    187187                        while(list(,$frameurl) = each($frameurls))
    188188                        {
     
    195195                                break;
    196196                        }
    197                     }                   
     197                    }
    198198                }
    199199                else
     
    201201                    return false;
    202202                }
    203                 return true;                   
     203                return true;
    204204                break;
    205205            case "https":
     
    255255                            break;
    256256                    }
    257                 }                   
    258                 return true;                   
     257                }
     258                return true;
    259259                break;
    260260            default:
     
    263263                return false;
    264264                break;
    265         }       
     265        }
    266266        return true;
    267267    }
     
    281281    {
    282282        unset($postdata);
    283        
     283
    284284        $postdata = $this->_prepare_post_body($formvars, $formfiles);
    285            
     285
    286286        $URI_PARTS = parse_url($URI);
    287287        if (!empty($URI_PARTS["user"]))
     
    313313                        $this->_httprequest($path, $fp, $URI, $this->_submit_method, $this->_submit_type, $postdata);
    314314                    }
    315                    
     315
    316316                    $this->_disconnect($fp);
    317317
     
    320320                        /* url was redirected, check if we've hit the max depth */
    321321                        if($this->maxredirs > $this->_redirectdepth)
    322                         {                       
     322                        {
    323323                            if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr))
    324                                 $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);                     
    325                            
     324                                $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
     325
    326326                            // only follow redirect if it's on this site, or offsiteok is true
    327327                            if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok)
     
    342342                        $frameurls = $this->_frameurls;
    343343                        $this->_frameurls = array();
    344                        
     344
    345345                        while(list(,$frameurl) = each($frameurls))
    346                         {                                                       
     346                        {
    347347                            if($this->_framedepth < $this->maxframes)
    348348                            {
     
    353353                                break;
    354354                        }
    355                     }                   
    356                    
     355                    }
     356
    357357                }
    358358                else
     
    360360                    return false;
    361361                }
    362                 return true;                   
     362                return true;
    363363                break;
    364364            case "https":
     
    387387                    /* url was redirected, check if we've hit the max depth */
    388388                    if($this->maxredirs > $this->_redirectdepth)
    389                     {                       
     389                    {
    390390                        if(!preg_match("|^".$URI_PARTS["scheme"]."://|", $this->_redirectaddr))
    391                             $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);                     
     391                            $this->_redirectaddr = $this->_expandlinks($this->_redirectaddr,$URI_PARTS["scheme"]."://".$URI_PARTS["host"]);
    392392
    393393                        // only follow redirect if it's on this site, or offsiteok is true
     
    411411
    412412                    while(list(,$frameurl) = each($frameurls))
    413                     {                                                       
     413                    {
    414414                        if($this->_framedepth < $this->maxframes)
    415415                        {
     
    420420                            break;
    421421                    }
    422                 }                   
    423                 return true;                   
     422                }
     423                return true;
    424424                break;
    425                
     425
    426426            default:
    427427                // not a valid protocol
     
    429429                return false;
    430430                break;
    431         }       
     431        }
    432432        return true;
    433433    }
     
    443443    {
    444444        if ($this->fetch($URI))
    445         {           
     445        {
    446446            if($this->lastredirectaddr)
    447447                $URI = $this->lastredirectaddr;
     
    471471    function fetchform($URI)
    472472    {
    473        
     473
    474474        if ($this->fetch($URI))
    475         {           
     475        {
    476476
    477477            if(is_array($this->results))
     
    482482            else
    483483                $this->results = $this->_stripform($this->results);
    484            
     484
    485485            return true;
    486486        }
     
    488488            return false;
    489489    }
    490    
    491    
     490
     491
    492492/*======================================================================*\
    493493    Function:   fetchtext
     
    500500    {
    501501        if($this->fetch($URI))
    502         {           
     502        {
    503503            if(is_array($this->results))
    504504            {
     
    524524    {
    525525        if($this->submit($URI,$formvars, $formfiles))
    526         {           
     526        {
    527527            if($this->lastredirectaddr)
    528528                $URI = $this->lastredirectaddr;
     
    558558    {
    559559        if($this->submit($URI,$formvars, $formfiles))
    560         {           
     560        {
    561561            if($this->lastredirectaddr)
    562562                $URI = $this->lastredirectaddr;
     
    582582    }
    583583
    584    
     584
    585585
    586586/*======================================================================*\
     
    594594    }
    595595
    596    
     596
    597597/*======================================================================*\
    598598    Function:   set_submit_normal
     
    605605    }
    606606
    607    
    608    
     607
     608
    609609
    610610/*======================================================================*\
    611611    Private functions
    612612\*======================================================================*/
    613    
    614    
     613
     614
    615615/*======================================================================*\
    616616    Function:   _striplinks
     
    621621
    622622    function _striplinks($document)
    623     {   
     623    {
    624624        preg_match_all("'<\s*a\s.*?href\s*=\s*          # find <a href=
    625625                        ([\"\'])?                   # find single or double quote
     
    627627                                                    # quote, otherwise match up to next space
    628628                        'isx",$document,$links);
    629                        
     629
    630630
    631631        // catenate the non-empty matches from the conditional subpattern
     
    635635            if(!empty($val))
    636636                $match[] = $val;
    637         }               
    638        
     637        }
     638
    639639        while(list($key,$val) = each($links[3]))
    640640        {
    641641            if(!empty($val))
    642642                $match[] = $val;
    643         }       
    644        
     643        }
     644
    645645        // return the links
    646646        return $match;
     
    655655
    656656    function _stripform($document)
    657     {   
     657    {
    658658        preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements);
    659        
     659
    660660        // catenate the matches
    661661        $match = implode("\r\n",$elements[0]);
    662                
     662
    663663        // return the links
    664664        return $match;
    665665    }
    666666
    667    
    668    
     667
     668
    669669/*======================================================================*\
    670670    Function:   _striptext
     
    676676    function _striptext($document)
    677677    {
    678        
     678
    679679        // I didn't use preg eval (//e) since that is only available in PHP 4.0.
    680680        // so, list your entities one by one here. I included some of the
    681681        // more common ones.
    682                                
     682
    683683        $search = array("'<script[^>]*?>.*?</script>'si",   // strip out javascript
    684684                        "'<[\/\!]*?[^<>]*?>'si",            // strip out html tags
     
    729729                            "ß",
    730730                        );
    731                    
     731
    732732        $text = preg_replace($search,$replace,$document);
    733                                
     733
    734734        return $text;
    735735    }
     
    745745    function _expandlinks($links,$URI)
    746746    {
    747        
     747
    748748        preg_match("/^[^\?]+/",$URI,$match);
    749749
     
    753753        $match_root =
    754754        $match_part["scheme"]."://".$match_part["host"];
    755                
     755
    756756        $search = array(    "|^http://".preg_quote($this->host)."|i",
    757757                            "|^(\/)|i",
     
    760760                            "|/[^\/]+/\.\./|"
    761761                        );
    762                        
     762
    763763        $replace = array(   "",
    764764                            $match_root."/",
     
    766766                            "/",
    767767                            "/"
    768                         );         
    769                
     768                        );
     769
    770770        $expandedLinks = preg_replace($search,$replace,$links);
    771771
     
    780780                $URI        the full URI
    781781                $body       body contents to send if any (POST)
    782     Output:     
    783 \*======================================================================*/
    784    
     782    Output:
     783\*======================================================================*/
     784
    785785    function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="")
    786786    {
     
    788788        if($this->passcookies && $this->_redirectaddr)
    789789            $this->setcookies();
    790            
     790
    791791        $URI_PARTS = parse_url($URI);
    792792        if(empty($url))
    793793            $url = "/";
    794         $headers = $http_method." ".$url." ".$this->_httpversion."\r\n";       
     794        $headers = $http_method." ".$url." ".$this->_httpversion."\r\n";
    795795        if(!empty($this->agent))
    796796            $headers .= "User-Agent: ".$this->agent."\r\n";
     
    806806            $headers .= "Referer: ".$this->referer."\r\n";
    807807        if(!empty($this->cookies))
    808         {           
     808        {
    809809            if(!is_array($this->cookies))
    810810                $this->cookies = (array)$this->cookies;
    811    
     811
    812812            reset($this->cookies);
    813813            if ( count($this->cookies) > 0 ) {
     
    832832            $headers .= "\r\n";
    833833        }
    834         if(!empty($body))   
     834        if(!empty($body))
    835835            $headers .= "Content-length: ".strlen($body)."\r\n";
    836         if(!empty($this->user) || !empty($this->pass)) 
     836        if(!empty($this->user) || !empty($this->pass))
    837837            $headers .= "Authorization: Basic ".base64_encode($this->user.":".$this->pass)."\r\n";
    838        
     838
    839839        //add proxy auth headers
    840         if(!empty($this->proxy_user))   
     840        if(!empty($this->proxy_user))
    841841            $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass)."\r\n";
    842842
    843843
    844844        $headers .= "\r\n";
    845        
     845
    846846        // set the read timeout if needed
    847847        if ($this->read_timeout > 0)
    848848            socket_set_timeout($fp, $this->read_timeout);
    849849        $this->timed_out = false;
    850        
     850
    851851        fwrite($fp,$headers.$body,strlen($headers.$body));
    852        
     852
    853853        $this->_redirectaddr = false;
    854854        unset($this->headers);
    855                        
     855
    856856        while($currentHeader = fgets($fp,$this->_maxlinelen))
    857857        {
     
    861861                return false;
    862862            }
    863                
     863
    864864            if($currentHeader == "\r\n")
    865865                break;
    866                        
     866
    867867            // if a header begins with Location: or URI:, set the redirect
    868868            if(preg_match("/^(Location:|URI:)/i",$currentHeader))
     
    884884                    $this->_redirectaddr = $matches[2];
    885885            }
    886        
     886
    887887            if(preg_match("|^HTTP/|",$currentHeader))
    888888            {
     
    890890                {
    891891                    $this->status= $status[1];
    892                 }               
     892                }
    893893                $this->response_code = $currentHeader;
    894894            }
    895                
     895
    896896            $this->headers[] = $currentHeader;
    897897        }
     
    911911            return false;
    912912        }
    913        
     913
    914914        // check if there is a a redirect meta tag
    915        
     915
    916916        if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
    917917
    918918        {
    919             $this->_redirectaddr = $this->_expandlinks($match[1],$URI); 
     919            $this->_redirectaddr = $this->_expandlinks($match[1],$URI);
    920920        }
    921921
     
    933933        else
    934934            $this->results = $results;
    935        
     935
    936936        return true;
    937937    }
     
    943943                $URI        the full URI
    944944                $body       body contents to send if any (POST)
    945     Output:     
    946 \*======================================================================*/
    947    
     945    Output:
     946\*======================================================================*/
     947
    948948    function _httpsrequest($url,$URI,$http_method,$content_type="",$body="")
    949949    {
     
    951951            $this->setcookies();
    952952
    953         $headers = array();     
    954                    
     953        $headers = array();
     954
    955955        $URI_PARTS = parse_url($URI);
    956956        if(empty($url))
    957957            $url = "/";
    958958        // GET ... header not needed for curl
    959         //$headers[] = $http_method." ".$url." ".$this->_httpversion;       
     959        //$headers[] = $http_method." ".$url." ".$this->_httpversion;
    960960        if(!empty($this->agent))
    961961            $headers[] = "User-Agent: ".$this->agent;
     
    970970            $headers[] = "Referer: ".$this->referer;
    971971        if(!empty($this->cookies))
    972         {           
     972        {
    973973            if(!is_array($this->cookies))
    974974                $this->cookies = (array)$this->cookies;
    975    
     975
    976976            reset($this->cookies);
    977977            if ( count($this->cookies) > 0 ) {
     
    996996                $headers[] = "Content-type: $content_type";
    997997        }
    998         if(!empty($body))   
     998        if(!empty($body))
    999999            $headers[] = "Content-length: ".strlen($body);
    1000         if(!empty($this->user) || !empty($this->pass)) 
     1000        if(!empty($this->user) || !empty($this->pass))
    10011001            $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass);
    1002            
     1002
    10031003        for($curr_header = 0; $curr_header < count($headers); $curr_header++) {
    10041004            $safer_header = strtr( $headers[$curr_header], "\"", " " );
    10051005            $cmdline_params .= " -H \"".$safer_header."\"";
    10061006        }
    1007        
     1007
    10081008        if(!empty($body))
    10091009            $cmdline_params .= " -d \"$body\"";
    1010        
     1010
    10111011        if($this->read_timeout > 0)
    10121012            $cmdline_params .= " -m ".$this->read_timeout;
    1013        
     1013
    10141014        $headerfile = tempnam($temp_dir, "sno");
    10151015
    10161016        $safer_URI = strtr( $URI, "\"", " " ); // strip quotes from the URI to avoid shell access
    10171017        exec(escapeshellcmd($this->curl_path." -D \"$headerfile\"".$cmdline_params." \"".$safer_URI."\""),$results,$return);
    1018        
     1018
    10191019        if($return)
    10201020        {
     
    10221022            return false;
    10231023        }
    1024            
    1025            
     1024
     1025
    10261026        $results = implode("\r\n",$results);
    1027        
     1027
    10281028        $result_headers = file("$headerfile");
    1029                        
     1029
    10301030        $this->_redirectaddr = false;
    10311031        unset($this->headers);
    1032                        
     1032
    10331033        for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++)
    10341034        {
    1035            
     1035
    10361036            // if a header begins with Location: or URI:, set the redirect
    10371037            if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader]))
     
    10531053                    $this->_redirectaddr = $matches[2];
    10541054            }
    1055        
     1055
    10561056            if(preg_match("|^HTTP/|",$result_headers[$currentHeader]))
    10571057                $this->response_code = $result_headers[$currentHeader];
     
    10611061
    10621062        // check if there is a a redirect meta tag
    1063        
     1063
    10641064        if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match))
    10651065        {
    1066             $this->_redirectaddr = $this->_expandlinks($match[1],$URI); 
     1066            $this->_redirectaddr = $this->_expandlinks($match[1],$URI);
    10671067        }
    10681068
     
    10821082
    10831083        unlink("$headerfile");
    1084        
     1084
    10851085        return true;
    10861086    }
     
    10901090    Purpose:    set cookies for a redirection
    10911091\*======================================================================*/
    1092    
     1092
    10931093    function setcookies()
    10941094    {
     
    11001100    }
    11011101
    1102    
     1102
    11031103/*======================================================================*\
    11041104    Function:   _check_timeout
     
    11241124    Input:      $fp file pointer
    11251125\*======================================================================*/
    1126    
     1126
    11271127    function _connect(&$fp)
    11281128    {
     
    11301130            {
    11311131                $this->_isproxy = true;
    1132                
     1132
    11331133                $host = $this->proxy_host;
    11341134                $port = $this->proxy_port;
     
    11391139            $port = $this->port;
    11401140        }
    1141    
     1141
    11421142        $this->status = 0;
    1143        
     1143
    11441144        if($fp = fsockopen(
    11451145                    $host,
     
    11771177    Input:      $fp file pointer
    11781178\*======================================================================*/
    1179    
     1179
    11801180    function _disconnect($fp)
    11811181    {
     
    11831183    }
    11841184
    1185    
     1185
    11861186/*======================================================================*\
    11871187    Function:   _prepare_post_body
     
    11911191    Output:     post body
    11921192\*======================================================================*/
    1193    
     1193
    11941194    function _prepare_post_body($formvars, $formfiles)
    11951195    {
     
    12001200        if (count($formvars) == 0 && count($formfiles) == 0)
    12011201            return;
    1202        
     1202
    12031203        switch ($this->_submit_type) {
    12041204            case "application/x-www-form-urlencoded":
     
    12161216            case "multipart/form-data":
    12171217                $this->_mime_boundary = "Snoopy".md5(uniqid(microtime()));
    1218                
     1218
    12191219                reset($formvars);
    12201220                while(list($key,$val) = each($formvars)) {
     
    12311231                    }
    12321232                }
    1233                
     1233
    12341234                reset($formfiles);
    12351235                while (list($field_name, $file_names) = each($formfiles)) {
     
    12391239
    12401240                        $fp = fopen($file_name, "r");
    1241                         $file_content = fread($fp, filesize($file_name));
     1241                        while (!feof($fp)) {
     1242                            $file_content .= fread($fp, filesize($file_name));
     1243                        }
    12421244                        fclose($fp);
    12431245                        $base_name = basename($file_name);
  • trunk/wp-includes/classes.php

    r3503 r4431  
    11<?php
    22
    3 class WP_Query {
    4     var $query;
    5     var $query_vars;
    6     var $queried_object;
    7     var $queried_object_id;
    8     var $request;
    9 
    10     var $posts;
    11     var $post_count = 0;
    12     var $current_post = -1;
    13     var $in_the_loop = false;
    14     var $post;
    15 
    16     var $is_single = false;
    17     var $is_preview = false;
    18     var $is_page = false;
    19     var $is_archive = false;
    20     var $is_date = false;
    21     var $is_year = false;
    22     var $is_month = false;
    23     var $is_day = false;
    24     var $is_time = false;
    25     var $is_author = false;
    26     var $is_category = false;
    27     var $is_search = false;
    28     var $is_feed = false;
    29     var $is_trackback = false;
    30     var $is_home = false;
    31     var $is_404 = false;
    32     var $is_comments_popup = false;
    33     var $is_admin = false;
    34     var $is_attachment = false;
    35 
    36     function init_query_flags() {
    37         $this->is_single = false;
    38         $this->is_page = false;
    39         $this->is_archive = false;
    40         $this->is_date = false;
    41         $this->is_year = false;
    42         $this->is_month = false;
    43         $this->is_day = false;
    44         $this->is_time = false;
    45         $this->is_author = false;
    46         $this->is_category = false;
    47         $this->is_search = false;
    48         $this->is_feed = false;
    49         $this->is_trackback = false;
    50         $this->is_home = false;
    51         $this->is_404 = false;
    52         $this->is_paged = false;
    53         $this->is_admin = false;
    54         $this->is_attachment = false;
    55     }
    56    
    57     function init () {
    58         unset($this->posts);
    59         unset($this->query);
    60         unset($this->query_vars);
    61         unset($this->queried_object);
    62         unset($this->queried_object_id);
    63         $this->post_count = 0;
    64         $this->current_post = -1;
    65         $this->in_the_loop = false;
    66        
    67         $this->init_query_flags();
    68     }
    69 
    70     // Reparse the query vars.
    71     function parse_query_vars() {
    72         $this->parse_query('');
    73     }
    74 
    75     // Parse a query string and set query type booleans.
    76     function parse_query ($query) {
    77         if ( !empty($query) || !isset($this->query) ) {
    78             $this->init();
    79             parse_str($query, $qv);
    80             $this->query = $query;
    81             $this->query_vars = $qv;
    82         }
    83 
    84         if ('404' == $qv['error']) {
    85             $this->is_404 = true;
    86             if ( !empty($query) ) {
    87                 do_action('parse_query', array(&$this));
    88             }
    89             return;
    90         }
    91 
    92         $qv['m'] =  (int) $qv['m'];
    93         $qv['p'] =  (int) $qv['p'];
    94 
    95         // Compat.  Map subpost to attachment.
    96         if ( '' != $qv['subpost'] )
    97             $qv['attachment'] = $qv['subpost'];
    98         if ( '' != $qv['subpost_id'] )
    99             $qv['attachment_id'] = $qv['subpost_id'];
    100            
    101         if ( ('' != $qv['attachment']) || (int) $qv['attachment_id'] ) {
    102             $this->is_single = true;
    103             $this->is_attachment = true;
    104         } elseif ('' != $qv['name']) {
    105             $this->is_single = true;
    106         } elseif ( $qv['p'] ) {
    107             $this->is_single = true;
    108         } elseif (('' != $qv['hour']) && ('' != $qv['minute']) &&('' != $qv['second']) && ('' != $qv['year']) && ('' != $qv['monthnum']) && ('' != $qv['day'])) {
    109             // If year, month, day, hour, minute, and second are set, a single
    110             // post is being queried.       
    111             $this->is_single = true;
    112         } elseif ('' != $qv['static'] || '' != $qv['pagename'] || '' != $qv['page_id']) {
    113             $this->is_page = true;
    114             $this->is_single = false;
    115         } elseif (!empty($qv['s'])) {
    116             $this->is_search = true;
    117             switch ($qv['show_post_type']) {
    118             case 'page' :
    119                 $this->is_page = true;
    120                 break;
    121             case 'attachment' :
    122                 $this->is_attachment = true;
    123                 break;
    124             }
    125         } else {
    126         // Look for archive queries.  Dates, categories, authors.
    127 
    128             if ( (int) $qv['second']) {
    129                 $this->is_time = true;
    130                 $this->is_date = true;
    131             }
    132 
    133             if ( (int) $qv['minute']) {
    134                 $this->is_time = true;
    135                 $this->is_date = true;
    136             }
    137 
    138             if ( (int) $qv['hour']) {
    139                 $this->is_time = true;
    140                 $this->is_date = true;
    141             }
    142 
    143             if ( (int) $qv['day']) {
    144                 if (! $this->is_date) {
    145                     $this->is_day = true;
    146                     $this->is_date = true;
    147                 }
    148             }
    149 
    150             if ( (int)  $qv['monthnum']) {
    151                 if (! $this->is_date) {
    152                     $this->is_month = true;
    153                     $this->is_date = true;
    154                 }
    155             }
    156 
    157             if ( (int)  $qv['year']) {
    158                 if (! $this->is_date) {
    159                     $this->is_year = true;
    160                     $this->is_date = true;
    161                 }
    162             }
    163 
    164             if ( (int)  $qv['m']) {
    165                 $this->is_date = true;
    166                 if (strlen($qv['m']) > 9) {
    167                     $this->is_time = true;
    168                 } else if (strlen($qv['m']) > 7) {
    169                     $this->is_day = true;
    170                 } else if (strlen($qv['m']) > 5) {
    171                     $this->is_month = true;
    172                 } else {
    173                     $this->is_year = true;
    174                 }
    175             }
    176 
    177             if ('' != $qv['w']) {
    178                 $this->is_date = true;
    179             }
    180 
    181             if (empty($qv['cat']) || ($qv['cat'] == '0')) {
    182                 $this->is_category = false;
    183             } else {
    184                 if (stristr($qv['cat'],'-')) {
    185                     $this->is_category = false;
    186                 } else {
    187                     $this->is_category = true;
    188                 }
    189             }
    190 
    191             if ('' != $qv['category_name']) {
    192                 $this->is_category = true;
    193             }
    194            
    195             if ((empty($qv['author'])) || ($qv['author'] == '0')) {
    196                 $this->is_author = false;
    197             } else {
    198                 $this->is_author = true;
    199             }
    200 
    201             if ('' != $qv['author_name']) {
    202                 $this->is_author = true;
    203             }
    204 
    205             if ( ($this->is_date || $this->is_author || $this->is_category)) {
    206                 $this->is_archive = true;
    207             }
    208 
    209             if ( 'attachment' == $qv['show_post_type'] ) {
    210                 $this->is_attachment = true;
    211             }
    212         }
    213 
    214         if ('' != $qv['feed']) {
    215             $this->is_feed = true;
    216         }
    217 
    218         if ('' != $qv['tb']) {
    219             $this->is_trackback = true;
    220         }
    221 
    222         if ('' != $qv['paged']) {
    223             $this->is_paged = true;
    224         }
    225 
    226         if ('' != $qv['comments_popup']) {
    227             $this->is_comments_popup = true;
    228         }
    229        
    230         //if we're previewing inside the write screen
    231         if ('' != $qv['preview']) {
    232             $this->is_preview = true;
    233         }
    234 
    235         if (strstr($_SERVER['PHP_SELF'], 'wp-admin/')) {
    236             $this->is_admin = true;
    237         }
    238 
    239         if ( ! ($this->is_attachment || $this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_trackback || $this->is_404 || $this->is_admin || $this->is_comments_popup)) {
    240             $this->is_home = true;
    241         }
    242 
    243         if ( !empty($query) ) {
    244             do_action('parse_query', array(&$this));
    245         }
    246     }
    247 
    248     function set_404() {
    249         $this->init_query_flags();
    250         $this->is_404 = true;   
    251     }
    252    
    253     function get($query_var) {
    254         if (isset($this->query_vars[$query_var])) {
    255             return $this->query_vars[$query_var];
    256         }
    257 
    258         return '';
    259     }
    260 
    261     function set($query_var, $value) {
    262         $this->query_vars[$query_var] = $value;
    263     }
    264 
    265     function &get_posts() {
    266         global $wpdb, $pagenow, $user_ID;
    267 
    268         do_action('pre_get_posts', array(&$this));
    269 
    270         // Shorthand.
    271         $q = $this->query_vars;
    272 
    273         // First let's clear some variables
    274         $whichcat = '';
    275         $whichauthor = '';
    276         $whichpage = '';
    277         $result = '';
    278         $where = '';
    279         $limits = '';
    280         $distinct = '';
    281         $join = '';
    282 
    283         if ( !isset($q['posts_per_page']) || $q['posts_per_page'] == 0 )
    284             $q['posts_per_page'] = get_settings('posts_per_page');
    285         if ( !isset($q['what_to_show']) )
    286             $q['what_to_show'] = get_settings('what_to_show');
    287         if ( isset($q['showposts']) && $q['showposts'] ) {
    288             $q['showposts'] = (int) $q['showposts'];
    289             $q['posts_per_page'] = $q['showposts'];
    290         }
    291         if ( (isset($q['posts_per_archive_page']) && $q['posts_per_archive_page'] != 0) && ($this->is_archive || $this->is_search) )
    292             $q['posts_per_page'] = $q['posts_per_archive_page'];
    293         if ( !isset($q['nopaging']) ) {
    294             if ($q['posts_per_page'] == -1) {
    295                 $q['nopaging'] = true;
    296             } else {
    297                 $q['nopaging'] = false;
    298             }
    299         }
    300         if ( $this->is_feed ) {
    301             $q['posts_per_page'] = get_settings('posts_per_rss');
    302             $q['what_to_show'] = 'posts';
    303         }
    304 
    305         if (isset($q['page'])) {
    306             $q['page'] = trim($q['page'], '/');
    307             $q['page'] = (int) $q['page'];
    308         }
    309    
    310         $add_hours = intval(get_settings('gmt_offset'));
    311         $add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
    312         $wp_posts_post_date_field = "post_date"; // "DATE_ADD(post_date, INTERVAL '$add_hours:$add_minutes' HOUR_MINUTE)";
    313 
    314         // If a month is specified in the querystring, load that month
    315         if ( (int) $q['m'] ) {
    316             $q['m'] = '' . preg_replace('|[^0-9]|', '', $q['m']);
    317             $where .= ' AND YEAR(post_date)=' . substr($q['m'], 0, 4);
    318             if (strlen($q['m'])>5)
    319                 $where .= ' AND MONTH(post_date)=' . substr($q['m'], 4, 2);
    320             if (strlen($q['m'])>7)
    321                 $where .= ' AND DAYOFMONTH(post_date)=' . substr($q['m'], 6, 2);
    322             if (strlen($q['m'])>9)
    323                 $where .= ' AND HOUR(post_date)=' . substr($q['m'], 8, 2);
    324             if (strlen($q['m'])>11)
    325                 $where .= ' AND MINUTE(post_date)=' . substr($q['m'], 10, 2);
    326             if (strlen($q['m'])>13)
    327                 $where .= ' AND SECOND(post_date)=' . substr($q['m'], 12, 2);
    328         }
    329 
    330         if ( (int) $q['hour'] ) {
    331             $q['hour'] = '' . intval($q['hour']);
    332             $where .= " AND HOUR(post_date)='" . $q['hour'] . "'";
    333         }
    334 
    335         if ( (int) $q['minute'] ) {
    336             $q['minute'] = '' . intval($q['minute']);
    337             $where .= " AND MINUTE(post_date)='" . $q['minute'] . "'";
    338         }
    339 
    340         if ( (int) $q['second'] ) {
    341             $q['second'] = '' . intval($q['second']);
    342             $where .= " AND SECOND(post_date)='" . $q['second'] . "'";
    343         }
    344 
    345         if ( (int) $q['year'] ) {
    346             $q['year'] = '' . intval($q['year']);
    347             $where .= " AND YEAR(post_date)='" . $q['year'] . "'";
    348         }
    349 
    350         if ( (int) $q['monthnum'] ) {
    351             $q['monthnum'] = '' . intval($q['monthnum']);
    352             $where .= " AND MONTH(post_date)='" . $q['monthnum'] . "'";
    353         }
    354 
    355         if ( (int) $q['day'] ) {
    356             $q['day'] = '' . intval($q['day']);
    357             $where .= " AND DAYOFMONTH(post_date)='" . $q['day'] . "'";
    358         }
    359 
    360         // Compat.  Map subpost to attachment.
    361         if ( '' != $q['subpost'] )
    362             $q['attachment'] = $q['subpost'];
    363         if ( '' != $q['subpost_id'] )
    364             $q['attachment_id'] = $q['subpost_id'];
    365 
    366         if ('' != $q['name']) {
    367             $q['name'] = sanitize_title($q['name']);
    368             $where .= " AND post_name = '" . $q['name'] . "'";
    369         } else if ('' != $q['pagename']) {
    370             $q['pagename'] = str_replace('%2F', '/', urlencode(urldecode($q['pagename'])));
    371             $page_paths = '/' . trim($q['pagename'], '/');
    372             $q['pagename'] = sanitize_title(basename($page_paths));
    373             $q['name'] = $q['pagename'];
    374             $page_paths = explode('/', $page_paths);
    375             foreach($page_paths as $pathdir)
    376                 $page_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
    377                
    378             $all_page_ids = get_all_page_ids();
    379             $reqpage = 0;
    380             if (is_array($all_page_ids)) { foreach ( $all_page_ids as $page_id ) {
    381                 $page = get_page($page_id);
    382                 if ( $page->fullpath == $page_path ) {
    383                     $reqpage = $page_id;
    384                     break;
    385                 }
    386             } }
    387            
    388             $where .= " AND (ID = '$reqpage')";
    389         } elseif ('' != $q['attachment']) {
    390             $q['attachment'] = str_replace('%2F', '/', urlencode(urldecode($q['attachment'])));
    391             $attach_paths = '/' . trim($q['attachment'], '/');
    392             $q['attachment'] = sanitize_title(basename($attach_paths));
    393             $q['name'] = $q['attachment'];
    394             $where .= " AND post_name = '" . $q['attachment'] . "'";
    395         }
    396 
    397         if ( (int) $q['w'] ) {
    398             $q['w'] = ''.intval($q['w']);
    399             $where .= " AND WEEK(post_date, 1)='" . $q['w'] . "'";
    400         }
    401 
    402         if ( intval($q['comments_popup']) )
    403             $q['p'] = intval($q['comments_popup']);
    404 
    405         // If a attachment is requested by number, let it supercede any post number.
    406         if ( ($q['attachment_id'] != '') && (intval($q['attachment_id']) != 0) )
    407             $q['p'] = (int) $q['attachment_id'];
    408 
    409         // If a post number is specified, load that post
    410         if (($q['p'] != '') && intval($q['p']) != 0) {
    411             $q['p'] =  (int) $q['p'];
    412             $where = ' AND ID = ' . $q['p'];
    413         }
    414 
    415         if (($q['page_id'] != '') && (intval($q['page_id']) != 0)) {
    416             $q['page_id'] = intval($q['page_id']);
    417             $q['p'] = $q['page_id'];
    418             $where = ' AND ID = '.$q['page_id'];
    419         }
    420 
    421         // If a search pattern is specified, load the posts that match
    422         if (!empty($q['s'])) {
    423             $q['s'] = addslashes_gpc($q['s']);
    424             $search = ' AND (';
    425             $q['s'] = preg_replace('/, +/', ' ', $q['s']);
    426             $q['s'] = str_replace(',', ' ', $q['s']);
    427             $q['s'] = str_replace('"', ' ', $q['s']);
    428             $q['s'] = trim($q['s']);
    429             if ($q['exact']) {
    430                 $n = '';
    431             } else {
    432                 $n = '%';
    433             }
    434             if (!$q['sentence']) {
    435                 $s_array = explode(' ',$q['s']);
    436                 $q['search_terms'] = $s_array;
    437                 $search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))';
    438                 for ( $i = 1; $i < count($s_array); $i = $i + 1) {
    439                     $search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))';
    440                 }
    441                 $search .= ' OR (post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\')';
    442                 $search .= ')';
    443             } else {
    444                 $search = ' AND ((post_title LIKE \''.$n.$q['s'].$n.'\') OR (post_content LIKE \''.$n.$q['s'].$n.'\'))';
    445             }
    446         }
    447 
    448         // Category stuff
    449 
    450         if ((empty($q['cat'])) || ($q['cat'] == '0') ||
    451                 // Bypass cat checks if fetching specific posts
    452                 ( $this->is_single || $this->is_page )) {
    453             $whichcat='';
    454         } else {
    455             $q['cat'] = ''.urldecode($q['cat']).'';
    456             $q['cat'] = addslashes_gpc($q['cat']);
    457             if (stristr($q['cat'],'-')) {
    458                 // Note: if we have a negative, we ignore all the positives. It must
    459                 // always mean 'everything /except/ this one'. We should be able to do
    460                 // multiple negatives but we don't :-(
    461                 $eq = '!=';
    462                 $andor = 'AND';
    463                 $q['cat'] = explode('-',$q['cat']);
    464                 $q['cat'] = intval($q['cat'][1]);
    465             } else {
    466                 $eq = '=';
    467                 $andor = 'OR';
    468             }
    469             $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) ";
    470             $cat_array = preg_split('/[,\s]+/', $q['cat']);
    471             $whichcat .= ' AND (category_id '.$eq.' '.intval($cat_array[0]);
    472             $whichcat .= get_category_children($cat_array[0], ' '.$andor.' category_id '.$eq.' ');
    473             for ($i = 1; $i < (count($cat_array)); $i = $i + 1) {
    474                 $whichcat .= ' '.$andor.' category_id '.$eq.' '.intval($cat_array[$i]);
    475                 $whichcat .= get_category_children($cat_array[$i], ' '.$andor.' category_id '.$eq.' ');
    476             }
    477             $whichcat .= ')';
    478             if ($eq == '!=') {
    479                 $q['cat'] = '-'.$q['cat']; // Put back the knowledge that we are excluding a category.
    480             }
    481         }
    482 
    483         // Category stuff for nice URIs
    484 
    485         global $cache_categories;
    486         if ('' != $q['category_name']) {
    487             $cat_paths = '/' . trim(urldecode($q['category_name']), '/');
    488             $q['category_name'] = sanitize_title(basename($cat_paths));
    489             $cat_paths = explode('/', $cat_paths);
    490             foreach($cat_paths as $pathdir)
    491                 $cat_path .= ($pathdir!=''?'/':'') . sanitize_title($pathdir);
    492 
    493             $all_cat_ids = get_all_category_ids();
    494             $q['cat'] = 0; $partial_match = 0;
    495             foreach ( $all_cat_ids as $cat_id ) {
    496                 $cat = get_category($cat_id);
    497                 if ( $cat->fullpath == $cat_path ) {
    498                     $q['cat'] = $cat_id;
    499                     break;
    500                 } elseif ( $cat->category_nicename == $q['category_name'] ) {
    501                     $partial_match = $cat_id;
    502                 }
    503             }
    504            
    505             //if we don't match the entire hierarchy fallback on just matching the nicename
    506             if (!$q['cat'] && $partial_match) {
    507                 $q['cat'] = $partial_match;
    508             }           
    509 
    510             $tables = ", $wpdb->post2cat, $wpdb->categories";
    511             $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) LEFT JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID) ";
    512             $whichcat = " AND (category_id = '" . $q['cat'] . "'";
    513             $whichcat .= get_category_children($q['cat'], " OR category_id = ");
    514             $whichcat .= ")";
    515         }
    516 
    517         // Author/user stuff
    518 
    519         if ((empty($q['author'])) || ($q['author'] == '0')) {
    520             $whichauthor='';
    521         } else {
    522             $q['author'] = ''.urldecode($q['author']).'';
    523             $q['author'] = addslashes_gpc($q['author']);
    524             if (stristr($q['author'], '-')) {
    525                 $eq = '!=';
    526                 $andor = 'AND';
    527                 $q['author'] = explode('-', $q['author']);
    528                 $q['author'] = ''.intval($q['author'][1]);
    529             } else {
    530                 $eq = '=';
    531                 $andor = 'OR';
    532             }
    533             $author_array = preg_split('/[,\s]+/', $q['author']);
    534             $whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]);
    535             for ($i = 1; $i < (count($author_array)); $i = $i + 1) {
    536                 $whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]);
    537             }
    538             $whichauthor .= ')';
    539         }
    540 
    541         // Author stuff for nice URIs
    542 
    543         if ('' != $q['author_name']) {
    544             if (stristr($q['author_name'],'/')) {
    545                 $q['author_name'] = explode('/',$q['author_name']);
    546                 if ($q['author_name'][count($q['author_name'])-1]) {
    547                     $q['author_name'] = $q['author_name'][count($q['author_name'])-1];#no trailing slash
    548                 } else {
    549                     $q['author_name'] = $q['author_name'][count($q['author_name'])-2];#there was a trailling slash
    550                 }
    551             }
    552             $q['author_name'] = sanitize_title($q['author_name']);
    553             $q['author'] = $wpdb->get_var("SELECT ID FROM $wpdb->users WHERE user_nicename='".$q['author_name']."'");
    554             $whichauthor .= ' AND (post_author = '.intval($q['author']).')';
    555         }
    556        
    557         $where .= $search.$whichcat.$whichauthor;
    558 
    559         if ((empty($q['order'])) || ((strtoupper($q['order']) != 'ASC') && (strtoupper($q['order']) != 'DESC'))) {
    560             $q['order']='DESC';
    561         }
    562 
    563         // Order by
    564         if (empty($q['orderby'])) {
    565             $q['orderby']='date '.$q['order'];
    566         } else {
    567             // Used to filter values
    568             $allowed_keys = array('author', 'date', 'category', 'title', 'modified');
    569             $q['orderby'] = urldecode($q['orderby']);
    570             $q['orderby'] = addslashes_gpc($q['orderby']);
    571             $orderby_array = explode(' ',$q['orderby']);
    572             if (!in_array($orderby_array[0],$allowed_keys)) {
    573                 $orderby_array[0] = 'date';
    574             }
    575             $q['orderby'] = $orderby_array[0].' '.$q['order'];
    576             if (count($orderby_array)>1) {
    577                 for ($i = 1; $i < (count($orderby_array)); $i = $i + 1) {
    578                     // Only allow certain values for safety
    579                     if (in_array($orderby_array[$i],$allowed_keys)) {
    580                         $q['orderby'] .= ',post_'.$orderby_array[$i].' '.$q['order'];
    581                     }
    582                 }
    583             }
    584         }
    585 
    586         $now = gmdate('Y-m-d H:i:59');
    587        
    588         //only select past-dated posts, except if a logged in user is viewing a single: then, if they
    589         //can edit the post, we let them through
    590         if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) {
    591             $where .= " AND post_date_gmt <= '$now'";
    592             $distinct = 'DISTINCT';
    593         }
    594 
    595         if ( $this->is_attachment ) {
    596             $where .= ' AND (post_status = "attachment")';
    597         } elseif ($this->is_page) {
    598             $where .= ' AND (post_status = "static")';
    599         } elseif ($this->is_single) {
    600             $where .= ' AND (post_status != "static")';
    601         } else {
    602             $where .= ' AND (post_status = "publish"';
    603 
    604             if (isset($user_ID) && ('' != intval($user_ID)))
    605                 $where .= " OR post_author = $user_ID AND post_status != 'draft' AND post_status != 'static')";
    606             else
    607                 $where .= ')';             
    608         }
    609 
    610         if (! $this->is_attachment )
    611             $where .= ' AND post_status != "attachment"';
    612 
    613         // Apply filters on where and join prior to paging so that any
    614         // manipulations to them are reflected in the paging by day queries.
    615         $where = apply_filters('posts_where', $where);
    616         $join = apply_filters('posts_join', $join);
    617 
    618         // Paging
    619         if (empty($q['nopaging']) && ! $this->is_single) {
    620             $page = $q['paged'];
    621             if (empty($page)) {
    622                 $page = 1;
    623             }
    624 
    625             if (($q['what_to_show'] == 'posts')) {
    626                 $pgstrt = '';
    627                 $pgstrt = (intval($page) -1) * $q['posts_per_page'] . ', ';
    628                 $limits = 'LIMIT '.$pgstrt.$q['posts_per_page'];
    629             } elseif ($q['what_to_show'] == 'days') {
    630                 $startrow = $q['posts_per_page'] * (intval($page)-1);
    631                 $start_date = $wpdb->get_var("SELECT max(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $startrow,1");
    632                 $endrow = $startrow + $q['posts_per_page'] - 1;
    633                 $end_date = $wpdb->get_var("SELECT min(post_date) FROM $wpdb->posts $join WHERE (1=1) $where GROUP BY year(post_date), month(post_date), dayofmonth(post_date) ORDER BY post_date DESC LIMIT $endrow,1");
    634 
    635                 if ($page > 1) {
    636                     $where .= " AND post_date >= '$end_date' AND post_date <= '$start_date'";
    637                 } else {
    638                     $where .= " AND post_date >= '$end_date'";
    639                 }
    640             }
    641         }
    642 
    643         // Apply post-paging filters on where and join.  Only plugins that
    644         // manipulate paging queries should use these hooks.
    645         $where = apply_filters('posts_where_paged', $where);
    646         $groupby = " $wpdb->posts.ID ";
    647         $groupby = apply_filters('posts_groupby', $groupby);
    648         $join = apply_filters('posts_join_paged', $join);
    649         $orderby = "post_" . $q['orderby'];
    650         $orderby = apply_filters('posts_orderby', $orderby);
    651         $request = " SELECT $distinct * FROM $wpdb->posts $join WHERE 1=1" . $where . " GROUP BY " . $groupby . " ORDER BY " . $orderby . " $limits";
    652         $this->request = apply_filters('posts_request', $request);
    653 
    654         $this->posts = $wpdb->get_results($this->request);
    655 
    656         // Check post status to determine if post should be displayed.
    657         if ($this->is_single) {
    658             $status = get_post_status($this->posts[0]);
    659             if ( ('publish' != $status) && ('static' != $status) ) {
    660                 if ( ! (isset($user_ID) && ('' != intval($user_ID))) ) {
    661                     // User must be logged in to view unpublished posts.
    662                     $this->posts = array();
    663                 } else {
    664                     if ('draft' == $status) {
    665                         // User must have edit permissions on the draft to preview.
    666                         if (! current_user_can('edit_post', $this->posts[0]->ID)) {
    667                             $this->posts = array();
    668                         } else {
    669                             $this->is_preview = true;
    670                             $this->posts[0]->post_date = current_time('mysql');
    671                         }
    672                     } else {
    673                         if (! current_user_can('read_post', $this->posts[0]->ID))
    674                             $this->posts = array();
    675                     }
    676                 }
    677             } else {
    678                 if (mysql2date('U', $this->posts[0]->post_date_gmt) > mysql2date('U', $now)) { //it's future dated
    679                     $this->is_preview = true;
    680                     if (!current_user_can('edit_post', $this->posts[0]->ID)) {
    681                         $this->posts = array ( );
    682                     }
    683                 }
    684             }
    685         }
    686 
    687         update_post_caches($this->posts);
    688 
    689         $this->posts = apply_filters('the_posts', $this->posts);
    690         $this->post_count = count($this->posts);
    691         if ($this->post_count > 0) {
    692             $this->post = $this->posts[0];
    693         }
    694        
    695         // Save any changes made to the query vars.
    696         $this->query_vars = $q;
    697         return $this->posts;
    698     }
    699 
    700     function next_post() {
    701        
    702         $this->current_post++;
    703 
    704         $this->post = $this->posts[$this->current_post];
    705         return $this->post;
    706     }
    707 
    708     function the_post() {
    709         global $post;
    710         $this->in_the_loop = true;
    711         $post = $this->next_post();
    712         setup_postdata($post);
    713 
    714         if ( $this->current_post == 0 ) // loop has just started
    715             do_action('loop_start');
    716     }
    717 
    718     function have_posts() {
    719         if ($this->current_post + 1 < $this->post_count) {
    720             return true;
    721         } elseif ($this->current_post + 1 == $this->post_count) {
    722             do_action('loop_end');
    723             // Do some cleaning up after the loop
    724             $this->rewind_posts();
    725         }
    726 
    727         $this->in_the_loop = false;
    728         return false;
    729     }
    730 
    731     function rewind_posts() {
    732         $this->current_post = -1;
    733         if ($this->post_count > 0) {
    734             $this->post = $this->posts[0];
    735         }
    736     }
    737    
    738     function &query($query) {
    739         $this->parse_query($query);
    740         return $this->get_posts();
    741     }
    742 
    743     function get_queried_object() {
    744         if (isset($this->queried_object)) {
    745             return $this->queried_object;
    746         }
    747 
    748         $this->queried_object = NULL;
    749         $this->queried_object_id = 0;
    750 
    751         if ($this->is_category) {
    752             $cat = $this->get('cat');
    753             $category = &get_category($cat);
    754             $this->queried_object = &$category;
    755             $this->queried_object_id = $cat;
    756         } else if ($this->is_single) {
    757             $this->queried_object = $this->post;
    758             $this->queried_object_id = $this->post->ID;
    759         } else if ($this->is_page) {
    760             $this->queried_object = $this->post;
    761             $this->queried_object_id = $this->post->ID;
    762         } else if ($this->is_author) {
    763             $author_id = $this->get('author');
    764             $author = get_userdata($author_id);
    765             $this->queried_object = $author;
    766             $this->queried_object_id = $author_id;
    767         }
    768 
    769         return $this->queried_object;
    770     }
    771 
    772     function get_queried_object_id() {
    773         $this->get_queried_object();
    774 
    775         if (isset($this->queried_object_id)) {
    776             return $this->queried_object_id;
    777         }
    778 
    779         return 0;
    780     }
    781 
    782     function WP_Query ($query = '') {
    783         if (! empty($query)) {
    784             $this->query($query);
    785         }
    786     }
    787 }
    788 
    789 class retrospam_mgr {
    790     var $spam_words;
    791     var $comments_list;
    792     var $found_comments;
    793 
    794     function retrospam_mgr() {
    795         global $wpdb;
    796 
    797         $list = explode("\n", get_settings('moderation_keys') );
    798         $list = array_unique( $list );
    799         $this->spam_words = $list;
    800 
    801         $this->comment_list = $wpdb->get_results("SELECT comment_ID AS ID, comment_content AS text, comment_approved AS approved, comment_author_url AS url, comment_author_ip AS ip, comment_author_email AS email FROM $wpdb->comments ORDER BY comment_ID ASC");
    802     }   // End of class constructor
    803 
    804     function move_spam( $id_list ) {
    805         global $wpdb;
    806         $cnt = 0;
    807         $id_list = explode( ',', $id_list );
    808 
    809         foreach ( $id_list as $comment ) {
    810             if ( $wpdb->query("update $wpdb->comments set comment_approved = '0' where comment_ID = '$comment'") ) {
    811                 $cnt++;
    812             }
    813         }
    814         echo "<div class='updated'><p>$cnt comment";
    815         if ($cnt != 1 ) echo "s";
    816         echo " moved to the moderation queue.</p></div>\n";
    817     }   // End function move_spam
    818 
    819     function find_spam() {
    820         $in_queue = 0;
    821 
    822         foreach( $this->comment_list as $comment ) {
    823             if( $comment->approved == 1 ) {
    824                 foreach( $this->spam_words as $word ) {
    825                     $word = trim($word);
    826                     if ( empty( $word ) )
    827                         continue;
    828                     $fulltext = strtolower($comment->email.' '.$comment->url.' '.$comment->ip.' '.$comment->text);
    829                     if( strpos( $fulltext, strtolower($word) ) != FALSE ) {
    830                         $this->found_comments[] = $comment->ID;
    831                         break;
    832                     }
    833                 }
    834             } else {
    835                 $in_queue++;
    836             }
    837         }
    838         return array( 'found' => $this->found_comments, 'in_queue' => $in_queue );
    839     }   // End function find_spam
    840 
    841     function display_edit_form( $counters ) {
    842         $numfound = count($counters[found]);
    843         $numqueue = $counters[in_queue];
    844 
    845         $body = '<p>' . sprintf(__('Suspected spam comments: <strong>%s</strong>'), $numfound) . '</p>';
    846 
    847         if ( count($counters[found]) > 0 ) {
    848             $id_list = implode( ',', $counters[found] );
    849             $body .= '<p><a href="options-discussion.php?action=retrospam&amp;move=true&amp;ids='.$id_list.'">'. __('Move suspect comments to moderation queue &raquo;') . '</a></p>';
    850 
    851         }
    852         $head = '<div class="wrap"><h2>' . __('Check Comments Results:') . '</h2>';
    853 
    854         $foot .= '<p><a href="options-discussion.php">' . __('&laquo; Return to Discussion Options page.') . '</a></p></div>';
    855        
    856         return $head . $body . $foot;
    857     }   // End function display_edit_form
    858 
    859 }
    860 
    861 class WP_Rewrite {
    862     var $permalink_structure;
    863     var $category_base;
    864     var $category_structure;
    865     var $author_base = 'author';
    866     var $author_structure;
    867     var $date_structure;
    868     var $page_structure;
    869     var $search_base = 'search';
    870     var $search_structure;
    871     var $comments_base = 'comments';
    872     var $feed_base = 'feed';
    873     var $comments_feed_structure;
    874     var $feed_structure;
    875     var $front;
    876     var $root = '';
    877     var $index = 'index.php';
    878     var $matches = '';
    879     var $rules;
    880     var $use_verbose_rules = false;
    881     var $rewritecode =
    882         array(
    883                     '%year%',
    884                     '%monthnum%',
    885                     '%day%',
    886                     '%hour%',
    887                     '%minute%',
    888                     '%second%',
    889                     '%postname%',
    890                     '%post_id%',
    891                     '%category%',
    892                     '%author%',
    893                     '%pagename%',
    894                     '%search%'
    895                     );
    896 
    897     var $rewritereplace =
    898         array(
    899                     '([0-9]{4})',
    900                     '([0-9]{1,2})',
    901                     '([0-9]{1,2})',
    902                     '([0-9]{1,2})',
    903                     '([0-9]{1,2})',
    904                     '([0-9]{1,2})',
    905                     '([^/]+)',
    906                     '([0-9]+)',
    907                     '(.+?)',
    908                     '([^/]+)',
    909                     '([^/]+)',
    910                     '(.+)'
    911                     );
    912 
    913     var $queryreplace =
    914         array (
    915                     'year=',
    916                     'monthnum=',
    917                     'day=',
    918                     'hour=',
    919                     'minute=',
    920                     'second=',
    921                     'name=',
    922                     'p=',
    923                     'category_name=',
    924                     'author_name=',
    925                     'pagename=',
    926                     's='
    927                     );
    928 
    929     var $feeds = array ('feed', 'rdf', 'rss', 'rss2', 'atom');
    930 
    931     function using_permalinks() {
    932         if (empty($this->permalink_structure))
    933             return false;
    934         else
    935             return true;
    936     }                   
    937 
    938     function using_index_permalinks() {
    939         if (empty($this->permalink_structure)) {
    940             return false;
    941         }
    942 
    943         // If the index is not in the permalink, we're using mod_rewrite.
    944         if (preg_match('#^/*' . $this->index . '#', $this->permalink_structure)) {
    945             return true;
    946         }
    947    
    948         return false;
    949     }
    950 
    951     function using_mod_rewrite_permalinks() {
    952         if ( $this->using_permalinks() && ! $this->using_index_permalinks())
    953             return true;
    954         else
    955             return false;
    956     }                   
    957 
    958     function preg_index($number) {
    959         $match_prefix = '$';
    960         $match_suffix = '';
    961 
    962         if (! empty($this->matches)) {
    963             $match_prefix = '$' . $this->matches . '[';
    964             $match_suffix = ']';
    965         }       
    966 
    967         return "$match_prefix$number$match_suffix";       
    968     }
    969 
    970     function page_rewrite_rules() {
    971         $uris = get_settings('page_uris');
    972         $attachment_uris = get_settings('page_attachment_uris');
    973 
    974         $rewrite_rules = array();
    975         $page_structure = $this->get_page_permastruct();
    976         if( is_array( $attachment_uris ) ) {
    977             foreach ($attachment_uris as $uri => $pagename) {
    978                 $this->add_rewrite_tag('%pagename%', "($uri)", 'attachment=');
    979                 $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure));
    980             }
    981         }
    982         if( is_array( $uris ) ) {
    983             foreach ($uris as $uri => $pagename) {
    984                 $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
    985                 $rewrite_rules = array_merge($rewrite_rules, $this->generate_rewrite_rules($page_structure));
    986             }
    987         }
    988 
    989         return $rewrite_rules;
    990     }
    991 
    992     function get_date_permastruct() {
    993         if (isset($this->date_structure)) {
    994             return $this->date_structure;
    995         }
    996 
    997         if (empty($this->permalink_structure)) {
    998             $this->date_structure = '';
    999             return false;
    1000         }
    1001        
    1002         // The date permalink must have year, month, and day separated by slashes.
    1003         $endians = array('%year%/%monthnum%/%day%', '%day%/%monthnum%/%year%', '%monthnum%/%day%/%year%');
    1004 
    1005         $this->date_structure = '';
    1006         $date_endian = '';
    1007 
    1008         foreach ($endians as $endian) {
    1009             if (false !== strpos($this->permalink_structure, $endian)) {
    1010                 $date_endian= $endian;
    1011                 break;
    1012             }
    1013         }
    1014 
    1015         if ( empty($date_endian) )
    1016             $date_endian = '%year%/%monthnum%/%day%';
    1017 
    1018         // Do not allow the date tags and %post_id% to overlap in the permalink
    1019         // structure. If they do, move the date tags to $front/date/. 
    1020         $front = $this->front;
    1021         preg_match_all('/%.+?%/', $this->permalink_structure, $tokens);
    1022         $tok_index = 1;
    1023         foreach ($tokens[0] as $token) {
    1024             if ( ($token == '%post_id%') && ($tok_index <= 3) ) {
    1025                 $front = $front . 'date/';
    1026                 break;
    1027             }
    1028         }
    1029 
    1030         $this->date_structure = $front . $date_endian;
    1031 
    1032         return $this->date_structure;
    1033     }
    1034 
    1035     function get_year_permastruct() {
    1036         $structure = $this->get_date_permastruct($this->permalink_structure);
    1037 
    1038         if (empty($structure)) {
    1039             return false;
    1040         }
    1041 
    1042         $structure = str_replace('%monthnum%', '', $structure);
    1043         $structure = str_replace('%day%', '', $structure);
    1044 
    1045         $structure = preg_replace('#/+#', '/', $structure);
    1046 
    1047         return $structure;
    1048     }
    1049 
    1050     function get_month_permastruct() {
    1051         $structure = $this->get_date_permastruct($this->permalink_structure);
    1052 
    1053         if (empty($structure)) {
    1054             return false;
    1055         }
    1056 
    1057         $structure = str_replace('%day%', '', $structure);
    1058 
    1059         $structure = preg_replace('#/+#', '/', $structure);
    1060 
    1061         return $structure;
    1062     }
    1063 
    1064     function get_day_permastruct() {
    1065         return $this->get_date_permastruct($this->permalink_structure);
    1066     }
    1067 
    1068     function get_category_permastruct() {
    1069         if (isset($this->category_structure)) {
    1070             return $this->category_structure;
    1071         }
    1072 
    1073         if (empty($this->permalink_structure)) {
    1074             $this->category_structure = '';
    1075             return false;
    1076         }
    1077 
    1078         if (empty($this->category_base))
    1079             $this->category_structure = $this->front . 'category/';
    1080         else
    1081             $this->category_structure = $this->category_base . '/';
    1082 
    1083         $this->category_structure .= '%category%';
    1084        
    1085         return $this->category_structure;
    1086     }
    1087 
    1088     function get_author_permastruct() {
    1089         if (isset($this->author_structure)) {
    1090             return $this->author_structure;
    1091         }
    1092 
    1093         if (empty($this->permalink_structure)) {
    1094             $this->author_structure = '';
    1095             return false;
    1096         }
    1097 
    1098         $this->author_structure = $this->front . $this->author_base . '/%author%';
    1099 
    1100         return $this->author_structure;
    1101     }
    1102 
    1103     function get_search_permastruct() {
    1104         if (isset($this->search_structure)) {
    1105             return $this->search_structure;
    1106         }
    1107 
    1108         if (empty($this->permalink_structure)) {
    1109             $this->search_structure = '';
    1110             return false;
    1111         }
    1112 
    1113         $this->search_structure = $this->root . $this->search_base . '/%search%';
    1114 
    1115         return $this->search_structure;
    1116     }
    1117 
    1118     function get_page_permastruct() {
    1119         if (isset($this->page_structure)) {
    1120             return $this->page_structure;
    1121         }
    1122 
    1123         if (empty($this->permalink_structure)) {
    1124             $this->page_structure = '';
    1125             return false;
    1126         }
    1127 
    1128         $this->page_structure = $this->root . '%pagename%';
    1129 
    1130         return $this->page_structure;
    1131     }
    1132 
    1133     function get_feed_permastruct() {
    1134         if (isset($this->feed_structure)) {
    1135             return $this->feed_structure;
    1136         }
    1137 
    1138         if (empty($this->permalink_structure)) {
    1139             $this->feed_structure = '';
    1140             return false;
    1141         }
    1142 
    1143         $this->feed_structure = $this->root . $this->feed_base . '/%feed%';
    1144 
    1145         return $this->feed_structure;
    1146     }
    1147 
    1148     function get_comment_feed_permastruct() {
    1149         if (isset($this->comment_feed_structure)) {
    1150             return $this->comment_feed_structure;
    1151         }
    1152 
    1153         if (empty($this->permalink_structure)) {
    1154             $this->comment_feed_structure = '';
    1155             return false;
    1156         }
    1157 
    1158         $this->comment_feed_structure = $this->root . $this->comments_base . '/' . $this->feed_base . '/%feed%';
    1159 
    1160         return $this->comment_feed_structure;
    1161     }
    1162 
    1163     function add_rewrite_tag($tag, $pattern, $query) {
    1164         // If the tag already exists, replace the existing pattern and query for
    1165         // that tag, otherwise add the new tag, pattern, and query to the end of
    1166         // the arrays.
    1167         $position = array_search($tag, $this->rewritecode);     
    1168         if (FALSE !== $position && NULL !== $position) {
    1169             $this->rewritereplace[$position] = $pattern;
    1170             $this->queryreplace[$position] = $query;           
    1171         } else {
    1172             $this->rewritecode[] = $tag;
    1173             $this->rewritereplace[] = $pattern;
    1174             $this->queryreplace[] = $query;
    1175         }
    1176     }
    1177 
    1178     function generate_rewrite_rules($permalink_structure, $paged = true, $feed = true, $forcomments = false, $walk_dirs = true) {
    1179         $feedregex2 = '';
    1180         foreach ($this->feeds as $feed_name) {
    1181             $feedregex2 .= $feed_name . '|';
    1182         }
    1183         $feedregex2 = '(' . trim($feedregex2, '|') .  ')/?$';
    1184         $feedregex = $this->feed_base  . '/' . $feedregex2;
    1185 
    1186         $trackbackregex = 'trackback/?$';
    1187         $pageregex = 'page/?([0-9]{1,})/?$';
    1188        
    1189         $front = substr($permalink_structure, 0, strpos($permalink_structure, '%'));
    1190         preg_match_all('/%.+?%/', $permalink_structure, $tokens);
    1191 
    1192         $num_tokens = count($tokens[0]);
    1193 
    1194         $index = $this->index;
    1195         $feedindex = $index;
    1196         $trackbackindex = $index;
    1197         for ($i = 0; $i < $num_tokens; ++$i) {
    1198             if (0 < $i) {
    1199                 $queries[$i] = $queries[$i - 1] . '&';
    1200             }
    1201              
    1202             $query_token = str_replace($this->rewritecode, $this->queryreplace, $tokens[0][$i]) . $this->preg_index($i+1);
    1203             $queries[$i] .= $query_token;
    1204         }
    1205 
    1206         $structure = $permalink_structure;
    1207         if ($front != '/') {
    1208             $structure = str_replace($front, '', $structure);
    1209         }
    1210         $structure = trim($structure, '/');
    1211         if ($walk_dirs) {
    1212             $dirs = explode('/', $structure);
    1213         } else {
    1214             $dirs[] = $structure;
    1215         }
    1216         $num_dirs = count($dirs);
    1217 
    1218         $front = preg_replace('|^/+|', '', $front);
    1219 
    1220         $post_rewrite = array();
    1221         $struct = $front;
    1222         for ($j = 0; $j < $num_dirs; ++$j) {
    1223             $struct .= $dirs[$j] . '/';
    1224             $struct = ltrim($struct, '/');
    1225             $match = str_replace($this->rewritecode, $this->rewritereplace, $struct);
    1226             $num_toks = preg_match_all('/%.+?%/', $struct, $toks);
    1227             $query = $queries[$num_toks - 1];
    1228 
    1229             $pagematch = $match . $pageregex;
    1230             $pagequery = $index . '?' . $query . '&paged=' . $this->preg_index($num_toks + 1);
    1231 
    1232             $feedmatch = $match . $feedregex;
    1233             $feedquery = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
    1234 
    1235             $feedmatch2 = $match . $feedregex2;
    1236             $feedquery2 = $feedindex . '?' . $query . '&feed=' . $this->preg_index($num_toks + 1);
    1237 
    1238             if ($forcomments) {
    1239                 $feedquery .= '&withcomments=1';
    1240                 $feedquery2 .= '&withcomments=1';
    1241             }
    1242 
    1243             $rewrite = array();
    1244             if ($feed)
    1245                 $rewrite = array($feedmatch => $feedquery, $feedmatch2 => $feedquery2);
    1246             if ($paged)
    1247                 $rewrite = array_merge($rewrite, array($pagematch => $pagequery));
    1248 
    1249             if ($num_toks) {
    1250                 $post = false;
    1251                 $page = false;
    1252                 if (strstr($struct, '%postname%') || strstr($struct, '%post_id%')
    1253                         || strstr($struct, '%pagename%')
    1254                         || (strstr($struct, '%year%') &&  strstr($struct, '%monthnum%') && strstr($struct, '%day%') && strstr($struct, '%hour%') && strstr($struct, '%minute') && strstr($struct, '%second%'))) {
    1255                     $post = true;
    1256                     if  ( strstr($struct, '%pagename%') )
    1257                         $page = true;
    1258                     $trackbackmatch = $match . $trackbackregex;
    1259                     $trackbackquery = $trackbackindex . '?' . $query . '&tb=1';
    1260                     $match = rtrim($match, '/');
    1261                     $submatchbase = str_replace(array('(',')'),'',$match);
    1262                     $sub1 = $submatchbase . '/([^/]+)/';
    1263                     $sub1tb = $sub1 . $trackbackregex;
    1264                     $sub1feed = $sub1 . $feedregex;
    1265                     $sub1feed2 = $sub1 . $feedregex2;
    1266                     $sub1 .= '?$';
    1267                     $sub2 = $submatchbase . '/attachment/([^/]+)/';
    1268                     $sub2tb = $sub2 . $trackbackregex;
    1269                     $sub2feed = $sub2 . $feedregex;
    1270                     $sub2feed2 = $sub2 . $feedregex2;
    1271                     $sub2 .= '?$';
    1272                     $subquery = $index . '?attachment=' . $this->preg_index(1);
    1273                     $subtbquery = $subquery . '&tb=1';
    1274                     $subfeedquery = $subquery . '&feed=' . $this->preg_index(2);
    1275                     $match = $match . '(/[0-9]+)?/?$';
    1276                     $query = $index . '?' . $query . '&page=' . $this->preg_index($num_toks + 1);
    1277                 } else {
    1278                     $match .= '?$';
    1279                     $query = $index . '?' . $query;
    1280                 }
    1281                        
    1282                 $rewrite = array_merge($rewrite, array($match => $query));
    1283 
    1284                 if ($post) {
    1285                     $rewrite = array_merge(array($trackbackmatch => $trackbackquery), $rewrite);
    1286                     if ( ! $page )
    1287                         $rewrite = array_merge($rewrite, array($sub1 => $subquery, $sub1tb => $subtbquery, $sub1feed => $subfeedquery, $sub1feed2 => $subfeedquery));
    1288                     $rewrite = array_merge($rewrite, array($sub2 => $subquery, $sub2tb => $subtbquery, $sub2feed => $subfeedquery, $sub2feed2 => $subfeedquery));
    1289                 }
    1290             }
    1291             $post_rewrite = array_merge($rewrite, $post_rewrite);
    1292         }
    1293         return $post_rewrite;
    1294     }
    1295 
    1296     function generate_rewrite_rule($permalink_structure, $walk_dirs = false) {
    1297         return $this->generate_rewrite_rules($permalink_structure, false, false, false, $walk_dirs);
    1298     }
    1299 
    1300     /* rewrite_rules
    1301      * Construct rewrite matches and queries from permalink structure.
    1302      * Returns an associate array of matches and queries.
    1303      */
    1304     function rewrite_rules() {
    1305         $rewrite = array();
    1306 
    1307         if (empty($this->permalink_structure)) {
    1308             return $rewrite;
    1309         }
    1310 
    1311         // Post
    1312         $post_rewrite = $this->generate_rewrite_rules($this->permalink_structure);
    1313         $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);
    1314 
    1315         // Date
    1316         $date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct());
    1317         $date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite);
    1318        
    1319         // Root
    1320         $root_rewrite = $this->generate_rewrite_rules($this->root . '/');
    1321         $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);
    1322 
    1323         // Comments
    1324         $comments_rewrite = $this->generate_rewrite_rules($this->root . $this->comments_base, true, true, true);
    1325         $comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite);
    1326 
    1327         // Search
    1328         $search_structure = $this->get_search_permastruct();
    1329         $search_rewrite = $this->generate_rewrite_rules($search_structure);
    1330         $search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite);
    1331 
    1332         // Categories
    1333         $category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct());
    1334         $category_rewrite = apply_filters('category_rewrite_rules', $category_rewrite);
    1335 
    1336         // Authors
    1337         $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct());
    1338         $author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);
    1339 
    1340         // Pages
    1341         $page_rewrite = $this->page_rewrite_rules();
    1342         $page_rewrite = apply_filters('page_rewrite_rules', $page_rewrite);
    1343 
    1344         // Put them together.
    1345         $this->rules = array_merge($page_rewrite, $root_rewrite, $comments_rewrite, $search_rewrite, $category_rewrite, $author_rewrite, $date_rewrite, $post_rewrite);
    1346 
    1347         do_action('generate_rewrite_rules', array(&$this));
    1348         $this->rules = apply_filters('rewrite_rules_array', $this->rules);
    1349 
    1350         return $this->rules;
    1351     }
    1352 
    1353     function wp_rewrite_rules() {
    1354         $this->rules = get_option('rewrite_rules');
    1355         if ( empty($this->rules) ) {
    1356             $this->matches = 'matches';
    1357             $this->rewrite_rules();
    1358             update_option('rewrite_rules', $this->rules);
    1359         }
    1360 
    1361         return $this->rules;
    1362     }
    1363 
    1364     function mod_rewrite_rules() {
    1365         if ( ! $this->using_permalinks()) {
    1366             return '';
    1367         }
    1368 
    1369         $site_root = parse_url(get_settings('siteurl'));
    1370         $site_root = trailingslashit($site_root['path']);
    1371 
    1372         $home_root = parse_url(get_settings('home'));
    1373         $home_root = trailingslashit($home_root['path']);
    1374    
    1375         $rules = "<IfModule mod_rewrite.c>\n";
    1376         $rules .= "RewriteEngine On\n";
    1377         $rules .= "RewriteBase $home_root\n";
    1378 
    1379         if ($this->use_verbose_rules) {
    1380             $this->matches = '';
    1381             $rewrite = $this->rewrite_rules();
    1382             $num_rules = count($rewrite);
    1383             $rules .= "RewriteCond %{REQUEST_FILENAME} -f [OR]\n" .
    1384                 "RewriteCond %{REQUEST_FILENAME} -d\n" .
    1385                 "RewriteRule ^.*$ - [S=$num_rules]\n";
    1386        
    1387             foreach ($rewrite as $match => $query) {
    1388                 // Apache 1.3 does not support the reluctant (non-greedy) modifier.
    1389                 $match = str_replace('.+?', '.+', $match);
    1390 
    1391                 // If the match is unanchored and greedy, prepend rewrite conditions
    1392                 // to avoid infinite redirects and eclipsing of real files.
    1393                 if ($match == '(.+)/?$' || $match == '([^/]+)/?$' ) {
    1394                     //nada.
    1395                 }
    1396            
    1397                 if (strstr($query, $this->index)) {
    1398                     $rules .= 'RewriteRule ^' . $match . ' ' . $home_root . $query . " [QSA,L]\n";
    1399                 } else {
    1400                     $rules .= 'RewriteRule ^' . $match . ' ' . $site_root . $query . " [QSA,L]\n";
    1401                 }
    1402             }
    1403         } else {
    1404             $rules .= "RewriteCond %{REQUEST_FILENAME} !-f\n" .
    1405                 "RewriteCond %{REQUEST_FILENAME} !-d\n" .
    1406                 "RewriteRule . {$home_root}{$this->index} [L]\n";
    1407         }
    1408 
    1409         $rules .= "</IfModule>\n";
    1410 
    1411         $rules = apply_filters('mod_rewrite_rules', $rules);
    1412         $rules = apply_filters('rewrite_rules', $rules);  // Deprecated
    1413 
    1414         return $rules;
    1415     }
    1416 
    1417     function flush_rules() {
    1418         generate_page_rewrite_rules();
    1419         delete_option('rewrite_rules');
    1420         $this->wp_rewrite_rules();
    1421         if ( function_exists('save_mod_rewrite_rules') )
    1422             save_mod_rewrite_rules();
    1423     }
    1424 
    1425     function init() {
    1426         $this->permalink_structure = get_settings('permalink_structure');
    1427         $this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%'));     
    1428         $this->root = '';
    1429         if ($this->using_index_permalinks()) {
    1430             $this->root = $this->index . '/';
    1431         }
    1432         $this->category_base = get_settings('category_base');
    1433         unset($this->category_structure);
    1434         unset($this->author_structure);
    1435         unset($this->date_structure);
    1436         unset($this->page_structure);
    1437         unset($this->search_structure);
    1438         unset($this->feed_structure);
    1439         unset($this->comment_feed_structure);
    1440     }
    1441 
    1442     function set_permalink_structure($permalink_structure) {
    1443         if ($permalink_structure != $this->permalink_structure) {
    1444             update_option('permalink_structure', $permalink_structure);
    1445             $this->init();
    1446         }
    1447     }
    1448 
    1449     function set_category_base($category_base) {
    1450         if ($category_base != $this->category_base) {
    1451             update_option('category_base', $category_base);
    1452             $this->init();
    1453         }
    1454     }
    1455 
    1456     function WP_Rewrite() {
    1457         $this->init();
    1458     }
    1459 }
    1460 
    14613class WP {
    1462     var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview');
    1463 
    1464     var $private_query_vars = array('posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'show_post_type');
     4    var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots');
     5
     6    var $private_query_vars = array('offset', 'posts_per_page', 'posts_per_archive_page', 'what_to_show', 'showposts', 'nopaging', 'post_type');
     7    var $extra_query_vars = array();
    14658
    14669    var $query_vars;
     
    147013    var $matched_query;
    147114    var $did_permalink = false;
     15   
     16    function add_query_var($qv) {
     17        $this->public_query_vars[] = $qv;
     18    }
    147219
    147320    function parse_request($extra_query_vars = '') {
     
    147623        $this->query_vars = array();
    147724
    1478         if (! empty($extra_query_vars))
    1479             parse_str($extra_query_vars, $extra_query_vars);
    1480         else
    1481             $extra_query_vars = array();
     25        if ( is_array($extra_query_vars) )
     26            $this->extra_query_vars = & $extra_query_vars;
     27        else if (! empty($extra_query_vars))
     28            parse_str($extra_query_vars, $this->extra_query_vars);
    148229
    148330        // Process PATH_INFO, REQUEST_URI, and 404 for permalinks.
     
    149138            $this->did_permalink = true;
    149239
    1493             $pathinfo = $_SERVER['PATH_INFO'];
     40            if ( isset($_SERVER['PATH_INFO']) )
     41                $pathinfo = $_SERVER['PATH_INFO'];
     42            else
     43                $pathinfo = '';
    149444            $pathinfo_array = explode('?', $pathinfo);
    1495             $pathinfo = $pathinfo_array[0];
     45            $pathinfo = str_replace("%", "%25", $pathinfo_array[0]);
    149646            $req_uri = $_SERVER['REQUEST_URI'];
    149747            $req_uri_array = explode('?', $req_uri);
    149848            $req_uri = $req_uri_array[0];
    149949            $self = $_SERVER['PHP_SELF'];
    1500             $home_path = parse_url(get_settings('home'));
    1501             $home_path = $home_path['path'];
     50            $home_path = parse_url(get_option('home'));
     51            if ( isset($home_path['path']) )
     52                $home_path = $home_path['path'];
     53            else
     54                $home_path = '';
    150255            $home_path = trim($home_path, '/');
    150356
     
    150558            // front.  For path info requests, this leaves us with the requesting
    150659            // filename, if any.  For 404 requests, this leaves us with the
    1507             // requested permalink. 
     60            // requested permalink.
    150861            $req_uri = str_replace($pathinfo, '', $req_uri);
    150962            $req_uri = trim($req_uri, '/');
     
    154497                    // Got a match.
    154598                    $this->matched_rule = $match;
    1546 
     99                   
    1547100                    // Trim the query of everything up to the '?'.
    1548101                    $query = preg_replace("!^.+\?!", '', $query);
     
    1553106
    1554107                    // Parse the query.
    1555                     parse_str($query, $query_vars);
     108                    parse_str($query, $perma_query_vars);
    1556109
    1557110                    // If we're processing a 404 request, clear the error var
     
    1574127                if (isset($error))
    1575128                    unset($error);
    1576                    
    1577                 if ( isset($query_vars) && strstr($_SERVER['PHP_SELF'], 'wp-admin/') )
    1578                     unset($query_vars);
    1579                    
     129
     130                if ( isset($perma_query_vars) && strstr($_SERVER['PHP_SELF'], 'wp-admin/') )
     131                    unset($perma_query_vars);
     132
    1580133                $this->did_permalink = false;
    1581134            }
     
    1586139        for ($i=0; $i<count($this->public_query_vars); $i += 1) {
    1587140            $wpvar = $this->public_query_vars[$i];
    1588             if (isset($extra_query_vars[$wpvar]))
    1589                 $this->query_vars[$wpvar] = $extra_query_vars[$wpvar];
     141            if (isset($this->extra_query_vars[$wpvar]))
     142                $this->query_vars[$wpvar] = $this->extra_query_vars[$wpvar];
    1590143            elseif (isset($GLOBALS[$wpvar]))
    1591144                $this->query_vars[$wpvar] = $GLOBALS[$wpvar];
     
    1594147            elseif (!empty($_GET[$wpvar]))
    1595148                $this->query_vars[$wpvar] = $_GET[$wpvar];
    1596             elseif (!empty($query_vars[$wpvar]))
    1597                 $this->query_vars[$wpvar] = $query_vars[$wpvar];
    1598             else
    1599                 $this->query_vars[$wpvar] = '';
     149            elseif (!empty($perma_query_vars[$wpvar]))
     150                $this->query_vars[$wpvar] = $perma_query_vars[$wpvar];
     151        }
     152
     153        foreach ($this->private_query_vars as $var) {
     154            if (isset($this->extra_query_vars[$var]))
     155                $this->query_vars[$var] = $this->extra_query_vars[$var];
     156            elseif (isset($GLOBALS[$var]) && '' != $GLOBALS[$var])
     157                $this->query_vars[$var] = $GLOBALS[$var];
    1600158        }
    1601159
    1602160        if ( isset($error) )
    1603161            $this->query_vars['error'] = $error;
     162
     163        $this->query_vars = apply_filters('request', $this->query_vars);
     164
     165        do_action_ref_array('parse_request', array(&$this));
    1604166    }
    1605167
    1606168    function send_headers() {
    1607         global $current_user;
    1608169        @header('X-Pingback: '. get_bloginfo('pingback_url'));
    1609170        if ( is_user_logged_in() )
     
    1611172        if ( !empty($this->query_vars['error']) && '404' == $this->query_vars['error'] ) {
    1612173            status_header( 404 );
     174            if ( !is_user_logged_in() )
     175                nocache_headers();
     176            @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    1613177        } else if ( empty($this->query_vars['feed']) ) {
    1614178            @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
     
    1624188
    1625189            // Support for Conditional GET
    1626             if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) $client_etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']);
     190            if (isset($_SERVER['HTTP_IF_NONE_MATCH']))
     191                $client_etag = stripslashes(stripslashes($_SERVER['HTTP_IF_NONE_MATCH']));
    1627192            else $client_etag = false;
    1628193
     
    1631196            $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
    1632197
    1633             // Make a timestamp for our most recent modification... 
     198            // Make a timestamp for our most recent modification...
    1634199            $wp_modified_timestamp = strtotime($wp_last_modified);
    1635200
     
    1641206            }
    1642207        }
     208
     209        do_action_ref_array('send_headers', array(&$this));
    1643210    }
    1644211
    1645212    function build_query_string() {
    1646213        $this->query_string = '';
    1647 
    1648         foreach ($this->public_query_vars as $wpvar) {
    1649             if (isset($this->query_vars[$wpvar]) && '' != $this->query_vars[$wpvar]) {
     214        foreach (array_keys($this->query_vars) as $wpvar) {
     215            if ( '' != $this->query_vars[$wpvar] ) {
    1650216                $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
    1651217                $this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]);
     
    1653219        }
    1654220
    1655         foreach ($this->private_query_vars as $wpvar) {
    1656             if (isset($GLOBALS[$wpvar]) && '' != $GLOBALS[$wpvar]) {
    1657                 $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&';
    1658                 $this->query_string .= $wpvar . '=' . rawurlencode($GLOBALS[$wpvar]);
    1659             }
    1660         }
    1661 
    1662         $this->query_string = apply_filters('query_string', $this->query_string);
     221        // query_string filter deprecated.  Use request filter instead.
     222        global $wp_filter;
     223        if ( isset($wp_filter['query_string']) ) {  // Don't bother filtering and parsing if no plugins are hooked in.
     224            $this->query_string = apply_filters('query_string', $this->query_string);
     225            parse_str($this->query_string, $this->query_vars);
     226        }
    1663227    }
    1664228
     
    1682246
    1683247    function init() {
    1684         get_currentuserinfo();
     248        wp_get_current_user();
    1685249    }
    1686250
    1687251    function query_posts() {
    1688252        $this->build_query_string();
    1689         query_posts($this->query_string);
     253        query_posts($this->query_vars);
    1690254    }
    1691255
     
    1699263            $wp_query->set_404();
    1700264            status_header( 404 );
     265            nocache_headers();
    1701266        }   elseif( is_404() != true ) {
    1702267            status_header( 200 );
     
    1711276        $this->handle_404();
    1712277        $this->register_globals();
     278        do_action_ref_array('wp', array(&$this));
    1713279    }
    1714280
     
    1718284}
    1719285
     286class WP_Error {
     287    var $errors = array();
     288    var $error_data = array();
     289
     290    function WP_Error($code = '', $message = '', $data = '') {
     291        if ( empty($code) )
     292            return;
     293
     294        $this->errors[$code][] = $message;
     295
     296        if ( ! empty($data) )
     297            $this->error_data[$code] = $data;
     298    }
     299
     300    function get_error_codes() {
     301        if ( empty($this->errors) )
     302            return array();
     303
     304        return array_keys($this->errors);
     305    }
     306
     307    function get_error_code() {
     308        $codes = $this->get_error_codes();
     309
     310        if ( empty($codes) )
     311            return '';
     312
     313        return $codes[0];   
     314    }
     315
     316    function get_error_messages($code = '') {
     317        // Return all messages if no code specified.
     318        if ( empty($code) ) {
     319            $all_messages = array();
     320            foreach ( $this->errors as $code => $messages )
     321                $all_messages = array_merge($all_messages, $messages);
     322
     323            return $all_messages;
     324        }
     325
     326        if ( isset($this->errors[$code]) )
     327            return $this->errors[$code];
     328        else
     329            return array();
     330    }
     331
     332    function get_error_message($code = '') {
     333        if ( empty($code) )
     334            $code = $this->get_error_code();
     335        $messages = $this->get_error_messages($code);
     336        if ( empty($messages) )
     337            return '';
     338        return $messages[0];
     339    }
     340
     341    function get_error_data($code = '') {
     342        if ( empty($code) )
     343            $code = $this->get_error_code();
     344
     345        if ( isset($this->error_data[$code]) )
     346            return $this->error_data[$code];
     347        return null;
     348    }
     349
     350    function add($code, $message, $data = '') {
     351        $this->errors[$code][] = $message;
     352        if ( ! empty($data) )
     353            $this->error_data[$code] = $data;
     354    }
     355
     356    function add_data($data, $code = '') {
     357        if ( empty($code) )
     358            $code = $this->get_error_code();
     359
     360        $this->error_data[$code] = $data;
     361    }
     362}
     363
     364function is_wp_error($thing) {
     365    if ( is_object($thing) && is_a($thing, 'WP_Error') )
     366        return true;
     367    return false;
     368}
     369
     370
     371// A class for displaying various tree-like structures. Extend the Walker class to use it, see examples at the bottom
     372
     373class Walker { 
     374    var $tree_type;
     375    var $db_fields;
     376   
     377    //abstract callbacks
     378    function start_lvl($output) { return $output; }
     379    function end_lvl($output)   { return $output; }
     380    function start_el($output)  { return $output; }
     381    function end_el($output)    { return $output; }
     382   
     383    function walk($elements, $to_depth) {
     384        $args = array_slice(func_get_args(), 2); $parents = array(); $depth = 1; $previous_element = ''; $output = '';
     385   
     386        //padding at the end
     387        $last_element->post_parent = 0;
     388        $last_element->post_id = 0;
     389        $elements[] = $last_element;
     390   
     391        $id_field = $this->db_fields['id'];
     392        $parent_field = $this->db_fields['parent'];
     393   
     394        $flat = ($to_depth == -1) ? true : false;
     395   
     396        foreach ( $elements as $element ) {
     397            // If flat, start and end the element and skip the level checks.
     398            if ( $flat) {
     399                // Start the element.
     400                if ( isset($element->$id_field) && $element->$id_field != 0 ) {
     401                    $cb_args = array_merge( array($output, $element, $depth - 1), $args);
     402                    $output = call_user_func_array(array(&$this, 'start_el'), $cb_args);
     403                }
     404   
     405                // End the element.
     406                if ( isset($element->$id_field) && $element->$id_field != 0 ) {
     407                    $cb_args = array_merge( array($output, $element, $depth - 1), $args);
     408                    $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
     409                }
     410   
     411                continue;   
     412            }
     413   
     414            // Walk the tree.
     415            if ( !empty($previous_element) && ($element->$parent_field == $previous_element->$id_field) ) {
     416                // Previous element is my parent. Descend a level.
     417                array_unshift($parents, $previous_element);
     418                $depth++; //always do this so when we start the element further down, we know where we are
     419                if ( !$to_depth || ($depth < $to_depth) ) { //only descend if we're below $to_depth
     420                    $cb_args = array_merge( array($output, $depth - 1), $args);
     421                    $output = call_user_func_array(array(&$this, 'start_lvl'), $cb_args);
     422                }
     423            } else if ( $element->$parent_field == $previous_element->$parent_field) {
     424                // On the same level as previous element.
     425                if ( !$to_depth || ($depth <= $to_depth) ) {
     426                    $cb_args = array_merge( array($output, $previous_element, $depth - 1), $args);
     427                    $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
     428                }
     429            } else if ( $depth > 1 ) {
     430                // Ascend one or more levels.
     431                if ( !$to_depth || ($depth <= $to_depth) ) {
     432                    $cb_args = array_merge( array($output, $previous_element, $depth - 1), $args);
     433                    $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
     434                }
     435   
     436                while ( $parent = array_shift($parents) ) {
     437                    $depth--;
     438                    if ( !$to_depth || ($depth < $to_depth) ) {
     439                        $cb_args = array_merge( array($output, $depth - 1), $args);
     440                        $output = call_user_func_array(array(&$this, 'end_lvl'), $cb_args);
     441                        $cb_args = array_merge( array($output, $parent, $depth - 1), $args);
     442                        $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
     443                    }
     444                    if ( $element->$parent_field == $parents[0]->$id_field ) {
     445                        break;
     446                    }
     447                }
     448            } else if ( !empty($previous_element) ) {
     449                // Close off previous element.
     450                if ( !$to_depth || ($depth <= $to_depth) ) {
     451                    $cb_args = array_merge( array($output, $previous_element, $depth - 1), $args);
     452                    $output = call_user_func_array(array(&$this, 'end_el'), $cb_args);
     453                }
     454            }
     455   
     456            // Start the element.
     457            if ( !$to_depth || ($depth <= $to_depth) ) {
     458                if ( $element->$id_field != 0 ) {
     459                    $cb_args = array_merge( array($output, $element, $depth - 1), $args);
     460                    $output = call_user_func_array(array(&$this, 'start_el'), $cb_args);
     461                }
     462            }
     463   
     464            $previous_element = $element;
     465        }
     466       
     467        return $output;
     468    }
     469}
     470
     471class Walker_Page extends Walker {
     472    var $tree_type = 'page';
     473    var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
     474   
     475    function start_lvl($output, $depth) {
     476        $indent = str_repeat("\t", $depth);
     477        $output .= "$indent<ul>\n";
     478        return $output;
     479    }
     480   
     481    function end_lvl($output, $depth) {
     482        $indent = str_repeat("\t", $depth);
     483        $output .= "$indent</ul>\n";
     484        return $output;
     485    }
     486   
     487    function start_el($output, $page, $depth, $current_page, $show_date, $date_format) {
     488        if ( $depth )
     489            $indent = str_repeat("\t", $depth);
     490
     491        $css_class = 'page_item';
     492        if ( $page->ID == $current_page )
     493            $css_class .= ' current_page_item';
     494
     495        $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" title="' . wp_specialchars($page->post_title, 1) . '">' . $page->post_title . '</a>';
     496   
     497        if ( !empty($show_date) ) {
     498            if ( 'modified' == $show_date )
     499                $time = $page->post_modified;
     500            else
     501                $time = $page->post_date;
     502   
     503            $output .= " " . mysql2date($date_format, $time);
     504        }
     505
     506        return $output;
     507    }
     508   
     509    function end_el($output, $page, $depth) {
     510        $output .= "</li>\n";
     511
     512        return $output;
     513    }
     514
     515}
     516
     517class Walker_PageDropdown extends Walker {
     518    var $tree_type = 'page';
     519    var $db_fields = array ('parent' => 'post_parent', 'id' => 'ID'); //TODO: decouple this
     520
     521    function start_el($output, $page, $depth, $args) {
     522        $pad = str_repeat('&nbsp;', $depth * 3);
     523
     524        $output .= "\t<option value=\"$page->ID\"";
     525        if ( $page->ID == $args['selected'] )
     526                $output .= ' selected="selected"';
     527        $output .= '>';
     528        $title = wp_specialchars($page->post_title);
     529        $output .= "$pad$title";
     530        $output .= "</option>\n";
     531
     532        return $output;
     533    }
     534}
     535
     536class Walker_Category extends Walker {
     537    var $tree_type = 'category';
     538    var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this
     539   
     540    function start_lvl($output, $depth, $args) {
     541        if ( 'list' != $args['style'] )
     542            return $output;
     543   
     544        $indent = str_repeat("\t", $depth);
     545        $output .= "$indent<ul class='children'>\n";
     546        return $output;
     547    }
     548   
     549    function end_lvl($output, $depth, $args) {
     550        if ( 'list' != $args['style'] )
     551            return $output;
     552   
     553        $indent = str_repeat("\t", $depth);
     554        $output .= "$indent</ul>\n";
     555        return $output;
     556    }
     557   
     558    function start_el($output, $category, $depth, $args) {
     559        extract($args);
     560   
     561        $link = '<a href="' . get_category_link($category->cat_ID) . '" ';
     562        if ( $use_desc_for_title == 0 || empty($category->category_description) )
     563            $link .= 'title="'. sprintf(__("View all posts filed under %s"), wp_specialchars($category->cat_name, 1)) . '"';
     564        else
     565            $link .= 'title="' . wp_specialchars(apply_filters('category_description',$category->category_description,$category),1) . '"';
     566        $link .= '>';
     567        $link .= apply_filters('list_cats', $category->cat_name, $category).'</a>';
     568   
     569        if ( (! empty($feed_image)) || (! empty($feed)) ) {
     570            $link .= ' ';
     571   
     572            if ( empty($feed_image) )
     573                $link .= '(';
     574   
     575            $link .= '<a href="' . get_category_rss_link(0, $category->cat_ID, $category->category_nicename) . '"';
     576   
     577            if ( !empty($feed) ) {
     578                $title = ' title="' . $feed . '"';
     579                $alt = ' alt="' . $feed . '"';
     580                $name = $feed;
     581                $link .= $title;
     582            }
     583   
     584            $link .= '>';
     585   
     586            if ( !empty($feed_image) )
     587                $link .= "<img src='$feed_image' $alt$title" . ' />';
     588            else
     589                $link .= $name;
     590            $link .= '</a>';
     591            if (empty($feed_image))
     592                $link .= ')';
     593        }
     594   
     595        if ( isset($show_count) && $show_count )
     596            $link .= ' ('.intval($category->category_count).')';
     597   
     598        if ( isset($show_date) && $show_date ) {
     599            $link .= ' ' . gmdate('Y-m-d', $category->last_update_timestamp);
     600        }
     601   
     602        if ( 'list' == $args['style'] ) {
     603            $output .= "\t<li";
     604            if ( ($category->cat_ID == $current_category) && is_category() )
     605                $output .=  ' class="current-cat"';
     606            $output .= ">$link\n";
     607        } else {
     608            $output .= "\t$link<br />\n";
     609        }
     610   
     611        return $output;
     612    }
     613   
     614    function end_el($output, $page, $depth, $args) {
     615        if ( 'list' != $args['style'] )
     616            return $output;
     617   
     618        $output .= "</li>\n";
     619        return $output;
     620    }
     621
     622}
     623
     624class Walker_CategoryDropdown extends Walker {
     625    var $tree_type = 'category';
     626    var $db_fields = array ('parent' => 'category_parent', 'id' => 'cat_ID'); //TODO: decouple this
     627   
     628    function start_el($output, $category, $depth, $args) {
     629        $pad = str_repeat('&nbsp;', $depth * 3);
     630       
     631        $cat_name = apply_filters('list_cats', $category->cat_name, $category);
     632        $output .= "\t<option value=\"".$category->cat_ID."\"";
     633        if ( $category->cat_ID == $args['selected'] )
     634            $output .= ' selected="selected"';
     635        $output .= '>';
     636        $output .= $pad.$cat_name;
     637        if ( $args['show_count'] )
     638            $output .= '&nbsp;&nbsp;('. $category->category_count .')';
     639        if ( $args['show_last_update'] ) {
     640            $format = 'Y-m-d';
     641            $output .= '&nbsp;&nbsp;' . gmdate($format, $category->last_update_timestamp);
     642        }
     643        $output .= "</option>\n";
     644       
     645        return $output;
     646    }
     647}
     648
     649class WP_Ajax_Response {
     650    var $responses = array();
     651
     652    function WP_Ajax_Response( $args = '' ) {
     653        if ( !empty($args) )
     654            $this->add($args);
     655    }
     656
     657    // a WP_Error object can be passed in 'id' or 'data'
     658    function add( $args = '' ) {
     659        if ( is_array($args) )
     660            $r = &$args;
     661        else
     662            parse_str($args, $r);
     663
     664        $defaults = array('what' => 'object', 'action' => false, 'id' => '0', 'old_id' => false,
     665                'data' => '', 'supplemental' => array());
     666
     667        $r = array_merge($defaults, $r);
     668        extract($r);
     669
     670        if ( is_wp_error($id) ) {
     671            $data = $id;
     672            $id = 0;
     673        }
     674
     675        $response = '';
     676        if ( is_wp_error($data) )
     677            foreach ( $data->get_error_codes() as $code )
     678                $response .= "<wp_error code='$code'><![CDATA[" . $data->get_error_message($code) . "]]></wp_error>";
     679        else
     680            $response = "<response_data><![CDATA[$data]]></response_data>";
     681
     682        $s = '';
     683        if ( (array) $supplemental )
     684            foreach ( $supplemental as $k => $v )
     685                $s .= "<$k><![CDATA[$v]]></$k>";
     686
     687        if ( false === $action )
     688            $action = $_POST['action'];
     689
     690        $x = '';
     691        $x .= "<response action='$action_$id'>"; // The action attribute in the xml output is formatted like a nonce action
     692        $x .=   "<$what id='$id'" . ( false !== $old_id ? "old_id='$old_id'>" : '>' );
     693        $x .=       $response;
     694        $x .=       $s;
     695        $x .=   "</$what>";
     696        $x .= "</response>";
     697
     698        $this->responses[] = $x;
     699        return $x;
     700    }
     701
     702    function send() {
     703        header('Content-type: text/xml');
     704        echo "<?xml version='1.0' standalone='yes'?><wp_ajax>";
     705        foreach ( $this->responses as $response )
     706            echo $response;
     707        echo '</wp_ajax>';
     708        die();
     709    }
     710}
     711
    1720712?>
  • trunk/wp-includes/default-filters.php

    r3503 r4431  
    2525add_filter('pre_comment_author_url', 'clean_url');
    2626
    27 add_filter('pre_comment_content', 'stripslashes', 1);
    2827add_filter('pre_comment_content', 'wp_rel_nofollow', 15);
    2928add_filter('pre_comment_content', 'balanceTags', 30);
    30 add_filter('pre_comment_content', 'addslashes', 50);
    3129
    3230add_filter('pre_comment_author_name', 'wp_filter_kses');
     
    4139add_filter('comment_email', 'antispambot');
    4240
     41add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3);
     42
    4343add_filter('comment_url', 'clean_url');
    4444
    4545add_filter('comment_text', 'convert_chars');
    4646add_filter('comment_text', 'make_clickable');
     47add_filter('comment_text', 'force_balance_tags', 25);
    4748add_filter('comment_text', 'wpautop', 30);
    4849add_filter('comment_text', 'convert_smilies', 20);
    4950
    5051add_filter('comment_excerpt', 'convert_chars');
     52
     53// Categories
     54add_filter('pre_category_name', 'strip_tags');
     55add_filter('pre_category_name', 'trim');
     56add_filter('pre_category_name', 'wp_filter_kses');
     57add_filter('pre_category_name', 'wp_specialchars', 30);
     58add_filter('pre_category_description', 'wp_filter_kses');
     59
     60//Links
     61add_filter('pre_link_name', 'strip_tags');
     62add_filter('pre_link_name', 'trim');
     63add_filter('pre_link_name', 'wp_filter_kses');
     64add_filter('pre_link_name', 'wp_specialchars', 30);
     65add_filter('pre_link_description', 'wp_filter_kses');
     66add_filter('pre_link_notes', 'wp_filter_kses');
     67add_filter('pre_link_url', 'strip_tags');
     68add_filter('pre_link_url', 'trim');
     69add_filter('pre_link_url', 'clean_url');
     70add_filter('pre_link_image', 'strip_tags');
     71add_filter('pre_link_image', 'trim');
     72add_filter('pre_link_image', 'clean_url');
     73add_filter('pre_link_rss', 'strip_tags');
     74add_filter('pre_link_rss', 'trim');
     75add_filter('pre_link_rss', 'clean_url');
     76add_filter('pre_link_target', 'strip_tags');
     77add_filter('pre_link_target', 'trim');
     78add_filter('pre_link_target', 'wp_filter_kses');
     79add_filter('pre_link_target', 'wp_specialchars', 30);
     80add_filter('pre_link_rel', 'strip_tags');
     81add_filter('pre_link_rel', 'trim');
     82add_filter('pre_link_rel', 'wp_filter_kses');
     83add_filter('pre_link_rel', 'wp_specialchars', 30);
     84
     85// Users
     86add_filter('pre_user_display_name', 'strip_tags');
     87add_filter('pre_user_display_name', 'trim');
     88add_filter('pre_user_display_name', 'wp_filter_kses');
     89add_filter('pre_user_display_name', 'wp_specialchars', 30);
     90add_filter('pre_user_first_name', 'strip_tags');
     91add_filter('pre_user_first_name', 'trim');
     92add_filter('pre_user_first_name', 'wp_filter_kses');
     93add_filter('pre_user_first_name', 'wp_specialchars', 30);
     94add_filter('pre_user_last_name', 'strip_tags');
     95add_filter('pre_user_last_name', 'trim');
     96add_filter('pre_user_last_name', 'wp_filter_kses');
     97add_filter('pre_user_last_name', 'wp_specialchars', 30);
     98add_filter('pre_user_nickname', 'strip_tags');
     99add_filter('pre_user_nickname', 'trim');
     100add_filter('pre_user_nickname', 'wp_filter_kses');
     101add_filter('pre_user_nickname', 'wp_specialchars', 30);
     102add_filter('pre_user_description', 'trim');
     103add_filter('pre_user_description', 'wp_filter_kses');
     104add_filter('pre_user_url', 'strip_tags');
     105add_filter('pre_user_url', 'trim');
     106add_filter('pre_user_url', 'clean_url');
     107add_filter('pre_user_email', 'trim');
     108add_filter('pre_user_email', 'sanitize_email');
    51109
    52110// Places to balance tags on input
     
    73131add_filter('the_title_rss', 'strip_tags');
    74132add_filter('the_title_rss', 'ent2ncr', 8);
     133add_filter('the_title_rss', 'wp_specialchars');
    75134add_filter('the_content_rss', 'ent2ncr', 8);
    76135add_filter('the_excerpt_rss', 'convert_chars');
    77136add_filter('the_excerpt_rss', 'ent2ncr', 8);
    78137add_filter('comment_author_rss', 'ent2ncr', 8);
    79 add_filter('comment_text_rss', 'htmlspecialchars');
     138add_filter('comment_text_rss', 'wp_specialchars');
    80139add_filter('comment_text_rss', 'ent2ncr', 8);
    81140add_filter('bloginfo_rss', 'ent2ncr', 8);
    82141add_filter('the_author', 'ent2ncr', 8);
    83142
     143// Misc filters
     144add_filter('option_ping_sites', 'privacy_ping_filter');
     145add_filter('option_blog_charset', 'wp_specialchars');
     146add_filter('mce_plugins', '_mce_load_rtl_plugin');
     147add_filter('mce_buttons', '_mce_add_direction_buttons');
     148
    84149// Actions
    85 add_action('publish_post', 'generic_ping');
    86150add_action('wp_head', 'rsd_link');
    87 
     151add_action('wp_head', 'locale_stylesheet');
     152add_action('publish_future_post', 'wp_publish_post', 10, 1);
     153add_action('wp_head', 'noindex', 1);
     154add_action('wp_head', 'wp_print_scripts');
     155if(!defined('DOING_CRON'))
     156    add_action('init', 'wp_cron');
     157add_action('do_feed_rdf', 'do_feed_rdf', 10, 1);
     158add_action('do_feed_rss', 'do_feed_rss', 10, 1);
     159add_action('do_feed_rss2', 'do_feed_rss2', 10, 1);
     160add_action('do_feed_atom', 'do_feed_atom', 10, 1);
     161add_action('do_pings', 'do_all_pings', 10, 1);
     162add_action('do_robots', 'do_robots');
     163add_action('sanitize_comment_cookies', 'sanitize_comment_cookies');
     164add_action('admin_print_scripts', 'wp_print_scripts', 20);
     165add_action('mce_options', '_mce_set_direction');
    88166?>
  • trunk/wp-includes/functions.php

    r3503 r4431  
    11<?php
    22
    3 require_once(dirname(__FILE__).'/functions-compat.php');
    4 
    5 if ( !function_exists('_') ) {
    6     function _($string) {
    7         return $string;
    8     }
    9 }
    10 
    11 function get_profile($field, $user = false) {
    12     global $wpdb;
    13     if ( !$user )
    14         $user = $wpdb->escape($_COOKIE[USER_COOKIE]);
    15     return $wpdb->get_var("SELECT $field FROM $wpdb->users WHERE user_login = '$user'");
    16 }
     3require_once(dirname(__FILE__).'/compat.php');
    174
    185function mysql2date($dateformatstring, $mysqlstring, $translate = true) {
    19     global $month, $weekday, $month_abbrev, $weekday_abbrev;
     6    global $wp_locale;
    207    $m = $mysqlstring;
    218    if ( empty($m) ) {
     
    2310    }
    2411    $i = mktime(substr($m,11,2),substr($m,14,2),substr($m,17,2),substr($m,5,2),substr($m,8,2),substr($m,0,4));
     12
     13    if( 'U' == $dateformatstring )
     14        return $i;
    2515   
    2616    if ( -1 == $i || false == $i )
    2717        $i = 0;
    2818
    29     if ( !empty($month) && !empty($weekday) && $translate ) {
    30         $datemonth = $month[date('m', $i)];
    31         $datemonth_abbrev = $month_abbrev[$datemonth];
    32         $dateweekday = $weekday[date('w', $i)];
    33         $dateweekday_abbrev = $weekday_abbrev[$dateweekday];
     19    if ( !empty($wp_locale->month) && !empty($wp_locale->weekday) && $translate ) {
     20        $datemonth = $wp_locale->get_month(date('m', $i));
     21        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
     22        $dateweekday = $wp_locale->get_weekday(date('w', $i));
     23        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
     24        $datemeridiem = $wp_locale->get_meridiem(date('a', $i));
     25        $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i));
    3426        $dateformatstring = ' '.$dateformatstring;
    3527        $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
     
    3729        $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
    3830        $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
     31        $dateformatstring = preg_replace("/([^\\\])a/", "\\1".backslashit($datemeridiem), $dateformatstring);
     32        $dateformatstring = preg_replace("/([^\\\])A/", "\\1".backslashit($datemeridiem_capital), $dateformatstring);
    3933
    4034        $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
     
    5246        case 'mysql':
    5347            if ( $gmt ) $d = gmdate('Y-m-d H:i:s');
    54             else $d = gmdate('Y-m-d H:i:s', (time() + (get_settings('gmt_offset') * 3600)));
     48            else $d = gmdate('Y-m-d H:i:s', (time() + (get_option('gmt_offset') * 3600)));
    5549            return $d;
    5650            break;
    5751        case 'timestamp':
    5852            if ( $gmt ) $d = time();
    59             else $d = time() + (get_settings('gmt_offset') * 3600);
     53            else $d = time() + (get_option('gmt_offset') * 3600);
    6054            return $d;
    6155            break;
     
    6458
    6559function date_i18n($dateformatstring, $unixtimestamp) {
    66     global $month, $weekday, $month_abbrev, $weekday_abbrev;
     60    global $wp_locale;
    6761    $i = $unixtimestamp;
    68     if ( (!empty($month)) && (!empty($weekday)) ) {
    69         $datemonth = $month[date('m', $i)];
    70         $datemonth_abbrev = $month_abbrev[$datemonth];
    71         $dateweekday = $weekday[date('w', $i)];
    72         $dateweekday_abbrev = $weekday_abbrev[$dateweekday];
     62    if ( (!empty($wp_locale->month)) && (!empty($wp_locale->weekday)) ) {
     63        $datemonth = $wp_locale->get_month(date('m', $i));
     64        $datemonth_abbrev = $wp_locale->get_month_abbrev($datemonth);
     65        $dateweekday = $wp_locale->get_weekday(date('w', $i));
     66        $dateweekday_abbrev = $wp_locale->get_weekday_abbrev($dateweekday);
     67        $datemeridiem = $wp_locale->get_meridiem(date('a', $i));
     68        $datemeridiem_capital = $wp_locale->get_meridiem(date('A', $i));
    7369        $dateformatstring = ' '.$dateformatstring;
    7470        $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring);
     
    7672        $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring);
    7773        $dateformatstring = preg_replace("/([^\\\])M/", "\\1".backslashit($datemonth_abbrev), $dateformatstring);
     74        $dateformatstring = preg_replace("/([^\\\])a/", "\\1".backslashit($datemeridiem), $dateformatstring);
     75        $dateformatstring = preg_replace("/([^\\\])A/", "\\1".backslashit($datemeridiem_capital), $dateformatstring);
     76
    7877        $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1);
    7978    }
    8079    $j = @date($dateformatstring, $i);
    8180    return $j;
    82     }
     81}
    8382
    8483function get_weekstartend($mysqlstring, $start_of_week) {
     
    9089    $i = 86400;
    9190
    92     if ( $weekday < get_settings('start_of_week') )
    93         $weekday = 7 - (get_settings('start_of_week') - $weekday);
    94 
    95     while ($weekday > get_settings('start_of_week')) {
     91    if ( $weekday < get_option('start_of_week') )
     92        $weekday = 7 - (get_option('start_of_week') - $weekday);
     93
     94    while ($weekday > get_option('start_of_week')) {
    9695        $weekday = date('w',$day);
    97         if ( $weekday < get_settings('start_of_week') )
    98             $weekday = 7 - (get_settings('start_of_week') - $weekday);
     96        if ( $weekday < get_option('start_of_week') )
     97            $weekday = 7 - (get_option('start_of_week') - $weekday);
    9998
    10099        $day = $day - 86400;
     
    109108function get_lastpostdate($timezone = 'server') {
    110109    global $cache_lastpostdate, $pagenow, $wpdb;
    111     $add_seconds_blog = get_settings('gmt_offset') * 3600;
     110    $add_seconds_blog = get_option('gmt_offset') * 3600;
    112111    $add_seconds_server = date('Z');
    113     $now = current_time('mysql', 1);
    114112    if ( !isset($cache_lastpostdate[$timezone]) ) {
    115113        switch(strtolower($timezone)) {
    116114            case 'gmt':
    117                 $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
     115                $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
    118116                break;
    119117            case 'blog':
    120                 $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
     118                $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
    121119                break;
    122120            case 'server':
    123                 $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
     121                $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
    124122                break;
    125123        }
     
    133131function get_lastpostmodified($timezone = 'server') {
    134132    global $cache_lastpostmodified, $pagenow, $wpdb;
    135     $add_seconds_blog = get_settings('gmt_offset') * 3600;
     133    $add_seconds_blog = get_option('gmt_offset') * 3600;
    136134    $add_seconds_server = date('Z');
    137     $now = current_time('mysql', 1);
    138135    if ( !isset($cache_lastpostmodified[$timezone]) ) {
    139136        switch(strtolower($timezone)) {
    140137            case 'gmt':
    141                 $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
     138                $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
    142139                break;
    143140            case 'blog':
    144                 $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
     141                $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
    145142                break;
    146143            case 'server':
    147                 $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
     144                $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
    148145                break;
    149146        }
     
    159156}
    160157
    161 function user_pass_ok($user_login,$user_pass) {
    162     global $cache_userdata;
    163     if ( empty($cache_userdata[$user_login]) ) {
    164         $userdata = get_userdatabylogin($user_login);
    165     } else {
    166         $userdata = $cache_userdata[$user_login];
    167     }
    168     return (md5($user_pass) == $userdata->user_pass);
    169 }
    170 
    171 
    172 function get_usernumposts($userid) {
    173     global $wpdb;
    174     return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '$userid' AND post_status = 'publish'");
    175 }
    176 
    177 
    178 // examine a url (supposedly from this blog) and try to
    179 // determine the post ID it represents.
    180 function url_to_postid($url) {
    181     global $wp_rewrite;
    182 
    183     // First, check to see if there is a 'p=N' or 'page_id=N' to match against
    184     preg_match('#[?&](p|page_id)=(\d+)#', $url, $values);
    185     $id = intval($values[2]);
    186     if ( $id ) return $id;
    187 
    188     // Check to see if we are using rewrite rules
    189     $rewrite = $wp_rewrite->wp_rewrite_rules();
    190 
    191     // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options
    192     if ( empty($rewrite) )
    193         return 0;
    194 
    195     // $url cleanup by Mark Jaquith
    196     // This fixes things like #anchors, ?query=strings, missing 'www.',
    197     // added 'www.', or added 'index.php/' that will mess up our WP_Query
    198     // and return a false negative
    199 
    200     // Get rid of the #anchor
    201     $url_split = explode('#', $url);
    202     $url = $url_split[0];
    203 
    204     // Get rid of URI ?query=string
    205     $url_split = explode('?', $url);
    206     $url = $url_split[0];
    207 
    208     // Add 'www.' if it is absent and should be there
    209     if ( false !== strpos(get_settings('home'), '://www.') && false === strpos($url, '://www.') )
    210         $url = str_replace('://', '://www.', $url);
    211 
    212     // Strip 'www.' if it is present and shouldn't be
    213     if ( false === strpos(get_settings('home'), '://www.') )
    214         $url = str_replace('://www.', '://', $url);
    215 
    216     // Strip 'index.php/' if we're not using path info permalinks
    217     if ( false === strpos($rewrite, 'index.php/') )
    218         $url = str_replace('index.php/', '', $url);
    219 
    220     if ( false !== strpos($url, get_settings('home')) ) {
    221         // Chop off http://domain.com
    222         $url = str_replace(get_settings('home'), '', $url);
    223     } else {
    224         // Chop off /path/to/blog
    225         $home_path = parse_url(get_settings('home'));
    226         $home_path = $home_path['path'];
    227         $url = str_replace($home_path, '', $url);
    228     }
    229 
    230     // Trim leading and lagging slashes
    231     $url = trim($url, '/');
    232 
    233     $request = $url;
    234 
    235     // Done with cleanup
    236 
    237     // Look for matches.
    238     $request_match = $request;
    239     foreach ($rewrite as $match => $query) {
    240         // If the requesting file is the anchor of the match, prepend it
    241         // to the path info.
    242         if ( (! empty($url)) && (strpos($match, $url) === 0) ) {
    243             $request_match = $url . '/' . $request;
    244         }
    245 
    246         if ( preg_match("!^$match!", $request_match, $matches) ) {
    247             // Got a match.
    248             // Trim the query of everything up to the '?'.
    249             $query = preg_replace("!^.+\?!", '', $query);
    250 
    251             // Substitute the substring matches into the query.
    252             eval("\$query = \"$query\";");
    253             $query = new WP_Query($query);
    254             if ( $query->is_single || $query->is_page )
    255                 return $query->post->ID;
    256             else
    257                 return 0;
    258         }
    259     }
    260     return 0;
    261 }
    262 
    263 
    264158function maybe_unserialize($original) {
    265     if ( false !== $gm = @ unserialize($original) )
    266         return $gm;
    267     else
    268         return $original;
     159    if ( is_serialized($original) ) // don't attempt to unserialize data that wasn't serialized going in
     160        if ( false !== $gm = @ unserialize($original) )
     161            return $gm;
     162    return $original;
     163}
     164
     165function is_serialized($data) {
     166    if ( !is_string($data) ) // if it isn't a string, it isn't serialized
     167        return false;
     168    $data = trim($data);
     169    if ( preg_match("/^[adobis]:[0-9]+:.*[;}]/si",$data) ) // this should fetch all legitimately serialized data
     170        return true;
     171    return false;
     172}
     173
     174function is_serialized_string($data) {
     175    if ( !is_string($data) ) // if it isn't a string, it isn't a serialized string
     176        return false;
     177    $data = trim($data);
     178    if ( preg_match("/^s:[0-9]+:.*[;}]/si",$data) ) // this should fetch all serialized strings
     179        return true;
     180    return false;
    269181}
    270182
    271183/* Options functions */
    272184
    273 function get_settings($setting) {
     185function get_option($setting) {
    274186    global $wpdb;
    275187
     
    293205    // If home is not set use siteurl.
    294206    if ( 'home' == $setting && '' == $value )
    295         return get_settings('siteurl');
     207        return get_option('siteurl');
    296208
    297209    if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting )
     
    301213}
    302214
    303 function get_option($option) {
    304     return get_settings($option);
    305 }
    306 
    307 function get_user_option( $option, $user = 0 ) {
    308     global $wpdb, $current_user;
    309    
    310     if ( empty($user) )
    311         $user = $current_user;
    312     else
    313         $user = get_userdata($user);
    314 
    315     if ( isset( $user->{$wpdb->prefix . $option} ) ) // Blog specific
    316         return $user->{$wpdb->prefix . $option};
    317     elseif ( isset( $user->{$option} ) ) // User specific and cross-blog
    318         return $user->{$option};
    319     else // Blog global
    320         return get_option( $option );
    321 }
    322 
    323215function form_option($option) {
    324     echo htmlspecialchars( get_option($option), ENT_QUOTES );
     216    echo wp_specialchars( get_option($option), 1 );
    325217}
    326218
     
    365257    }
    366258
    367     if ( is_array($newvalue) || is_object($newvalue) )
    368         $newvalue = serialize($newvalue);
     259    $_newvalue = $newvalue;
     260    $newvalue = maybe_serialize($newvalue);
    369261
    370262    wp_cache_set($option_name, $newvalue, 'options');
     
    374266    $wpdb->query("UPDATE $wpdb->options SET option_value = '$newvalue' WHERE option_name = '$option_name'");
    375267    if ( $wpdb->rows_affected == 1 ) {
    376         do_action("update_option_{$option_name}", $oldvalue, $newvalue);
     268        do_action("update_option_{$option_name}", $oldvalue, $_newvalue);
    377269        return true;
    378270    }
    379271    return false;
    380 }
    381 
    382 function update_user_option( $user_id, $option_name, $newvalue, $global = false ) {
    383     global $wpdb;
    384     if ( !$global )
    385         $option_name = $wpdb->prefix . $option_name;
    386     return update_usermeta( $user_id, $option_name, $newvalue );
    387272}
    388273
     
    395280        return;
    396281
    397     if ( is_array($value) || is_object($value) )
    398         $value = serialize($value);
     282    $value = maybe_serialize($value);
    399283
    400284    wp_cache_set($name, $value, 'options');
     
    418302}
    419303
    420 function add_post_meta($post_id, $key, $value, $unique = false) {
    421     global $wpdb, $post_meta_cache;
    422 
    423     if ( $unique ) {
    424         if ( $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key
    425 = '$key' AND post_id = '$post_id'") ) {
    426             return false;
    427         }
    428     }
    429 
    430     $original = $value;
    431     if ( is_array($value) || is_object($value) )
    432         $value = $wpdb->escape(serialize($value));
    433 
    434     $wpdb->query("INSERT INTO $wpdb->postmeta (post_id,meta_key,meta_value) VALUES ('$post_id','$key','$value')");
    435 
    436     $post_meta_cache['$post_id'][$key][] = $original;
    437 
    438     return true;
    439 }
    440 
    441 function delete_post_meta($post_id, $key, $value = '') {
    442     global $wpdb, $post_meta_cache;
    443 
    444     if ( empty($value) ) {
    445         $meta_id = $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE
    446 post_id = '$post_id' AND meta_key = '$key'");
    447     } else {
    448         $meta_id = $wpdb->get_var("SELECT meta_id FROM $wpdb->postmeta WHERE
    449 post_id = '$post_id' AND meta_key = '$key' AND meta_value = '$value'");
    450     }
    451 
    452     if ( !$meta_id )
    453         return false;
    454 
    455     if ( empty($value) ) {
    456         $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id'
    457 AND meta_key = '$key'");
    458         unset($post_meta_cache['$post_id'][$key]);
    459     } else {
    460         $wpdb->query("DELETE FROM $wpdb->postmeta WHERE post_id = '$post_id'
    461 AND meta_key = '$key' AND meta_value = '$value'");
    462         $cache_key = $post_meta_cache['$post_id'][$key];
    463         if ($cache_key) foreach ( $cache_key as $index => $data )
    464             if ( $data == $value )
    465                 unset($post_meta_cache['$post_id'][$key][$index]);
    466     }
    467 
    468     unset($post_meta_cache['$post_id'][$key]);
    469 
    470     return true;
    471 }
    472 
    473 function get_post_meta($post_id, $key, $single = false) {
    474     global $wpdb, $post_meta_cache;
    475 
    476     if ( isset($post_meta_cache[$post_id][$key]) ) {
    477         if ( $single ) {
    478             return maybe_unserialize( $post_meta_cache[$post_id][$key][0] );
    479         } else {
    480             return maybe_unserialize( $post_meta_cache[$post_id][$key] );
    481         }
    482     }
    483 
    484     $metalist = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE post_id = '$post_id' AND meta_key = '$key'", ARRAY_N);
    485 
    486     $values = array();
    487     if ( $metalist ) {
    488         foreach ($metalist as $metarow) {
    489             $values[] = $metarow[0];
    490         }
    491     }
    492 
    493     if ( $single ) {
    494         if ( count($values) ) {
    495             $return = maybe_unserialize( $values[0] );
    496         } else {
    497             return '';
    498         }
    499     } else {
    500         $return = $values;
    501     }
    502 
    503     return maybe_unserialize($return);
    504 }
    505 
    506 function update_post_meta($post_id, $key, $value, $prev_value = '') {
    507     global $wpdb, $post_meta_cache;
    508 
    509     $original_value = $value;
    510     if ( is_array($value) || is_object($value) )
    511         $value = $wpdb->escape(serialize($value));
    512 
    513     $original_prev = $prev_value;
    514     if ( is_array($prev_value) || is_object($prev_value) )
    515         $prev_value = $wpdb->escape(serialize($prev_value));
    516 
    517     if (! $wpdb->get_var("SELECT meta_key FROM $wpdb->postmeta WHERE meta_key
    518 = '$key' AND post_id = '$post_id'") ) {
    519         return false;
    520     }
    521 
    522     if ( empty($prev_value) ) {
    523         $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE
    524 meta_key = '$key' AND post_id = '$post_id'");
    525         $cache_key = $post_meta_cache['$post_id'][$key];
    526         if ( !empty($cache_key) )
    527             foreach ($cache_key as $index => $data)
    528                 $post_meta_cache['$post_id'][$key][$index] = $original_value;
    529     } else {
    530         $wpdb->query("UPDATE $wpdb->postmeta SET meta_value = '$value' WHERE
    531 meta_key = '$key' AND post_id = '$post_id' AND meta_value = '$prev_value'");
    532         $cache_key = $post_meta_cache['$post_id'][$key];
    533         if ( !empty($cache_key) )
    534             foreach ($cache_key as $index => $data)
    535                 if ( $data == $original_prev )
    536                     $post_meta_cache['$post_id'][$key][$index] = $original_value;
    537     }
    538 
    539     return true;
    540 }
    541 
    542 // Deprecated.  Use get_post().
    543 function get_postdata($postid) {
    544     $post = &get_post($postid);
    545 
    546     $postdata = array (
    547         'ID' => $post->ID,
    548         'Author_ID' => $post->post_author,
    549         'Date' => $post->post_date,
    550         'Content' => $post->post_content,
    551         'Excerpt' => $post->post_excerpt,
    552         'Title' => $post->post_title,
    553         'Category' => $post->post_category,
    554         'post_status' => $post->post_status,
    555         'comment_status' => $post->comment_status,
    556         'ping_status' => $post->ping_status,
    557         'post_password' => $post->post_password,
    558         'to_ping' => $post->to_ping,
    559         'pinged' => $post->pinged,
    560         'post_name' => $post->post_name
    561     );
    562 
    563     return $postdata;
    564 }
    565 
    566 // Retrieves post data given a post ID or post object.
    567 // Handles post caching.
    568 function &get_post(&$post, $output = OBJECT) {
    569     global $post_cache, $wpdb;
    570 
    571     if ( empty($post) ) {
    572         if ( isset($GLOBALS['post']) )
    573             $_post = & $GLOBALS['post'];
    574         else
    575             $_post = null;
    576     } elseif ( is_object($post) ) {
    577         if ( 'static' == $post->post_status )
    578             return get_page($post, $output);
    579         if ( !isset($post_cache[$post->ID]) )
    580             $post_cache[$post->ID] = &$post;
    581         $_post = & $post_cache[$post->ID];
    582     } else {
    583         if ( $_post = wp_cache_get($post, 'pages') )
    584             return get_page($_post, $output);
    585         elseif ( isset($post_cache[$post]) )
    586             $_post = & $post_cache[$post];
    587         else {
    588             $query = "SELECT * FROM $wpdb->posts WHERE ID = '$post' LIMIT 1";
    589             $_post = & $wpdb->get_row($query);
    590             if ( 'static' == $_post->post_status )
    591                 return get_page($_post, $output);
    592             $post_cache[$post] = & $_post;
    593         }
    594     }
    595 
    596     if ( defined(WP_IMPORTING) )
    597         unset($post_cache);
    598 
    599     if ( $output == OBJECT ) {
    600         return $_post;
    601     } elseif ( $output == ARRAY_A ) {
    602         return get_object_vars($_post);
    603     } elseif ( $output == ARRAY_N ) {
    604         return array_values(get_object_vars($_post));
    605     } else {
    606         return $_post;
    607     }
    608 }
    609 
    610 function &get_children($post = 0, $output = OBJECT) {
    611     global $post_cache, $wpdb;
    612 
    613     if ( empty($post) ) {
    614         if ( isset($GLOBALS['post']) )
    615             $post_parent = & $GLOBALS['post']->post_parent;
    616         else
    617             return false;
    618     } elseif ( is_object($post) ) {
    619         $post_parent = $post->post_parent;
    620     } else {
    621         $post_parent = $post;
    622     }
    623 
    624     $post_parent = (int) $post_parent;
    625 
    626     $query = "SELECT * FROM $wpdb->posts WHERE post_parent = $post_parent";
    627 
    628     $children = $wpdb->get_results($query);
    629 
    630     if ( $children ) {
    631         foreach ( $children as $key => $child ) {
    632             $post_cache[$child->ID] =& $children[$key];
    633             $kids[$child->ID] =& $children[$key];
    634         }
    635     } else {
    636         return false;
    637     }
    638 
    639     if ( $output == OBJECT ) {
    640         return $kids;
    641     } elseif ( $output == ARRAY_A ) {
    642         foreach ( $kids as $kid )
    643             $weeuns[$kid->ID] = get_object_vars($kids[$kid->ID]);
    644         return $weeuns;
    645     } elseif ( $output == ARRAY_N ) {
    646         foreach ( $kids as $kid )
    647             $babes[$kid->ID] = array_values(get_object_vars($kids[$kid->ID]));
    648         return $babes;
    649     } else {
    650         return $kids;
    651     }
    652 }
    653 
    654 function set_page_path($page) {
    655     $page->fullpath = '/' . $page->post_name;
    656     $path = $page->fullpath;
    657     $curpage = $page;
    658     while ($curpage->post_parent != 0) {
    659         $curpage = get_page($curpage->post_parent);
    660         $path = '/' . $curpage->post_name . $path;
    661     }
    662    
    663     $page->fullpath = $path;
    664 
    665     return $page;
    666 }
    667 
    668 // Retrieves page data given a page ID or page object.
    669 // Handles page caching.
    670 function &get_page(&$page, $output = OBJECT) {
    671     global $wpdb;
    672 
    673     if ( empty($page) ) {
    674         if ( isset($GLOBALS['page']) ) {
    675             $_page = & $GLOBALS['page'];
    676             wp_cache_add($_page->ID, $_page, 'pages');
    677         } else {
    678             $_page = null;
    679         }
    680     } elseif ( is_object($page) ) {
    681         if ( 'static' != $page->post_status )
    682             return get_post($page, $output);
    683         wp_cache_add($page->ID, $page, 'pages');
    684         $_page = $page;
    685     } else {
    686         if ( isset($GLOBALS['page']) && ($page == $GLOBALS['page']->ID) ) {
    687             $_page = & $GLOBALS['page'];
    688             wp_cache_add($_page->ID, $_page, 'pages');
    689         } elseif ( $_page = $GLOBALS['post_cache'][$page] ) {
    690             return get_post($page, $output);
    691         } elseif ( $_page = wp_cache_get($page, 'pages') ) {
    692             // Got it.
    693         } else {
    694             $query = "SELECT * FROM $wpdb->posts WHERE ID= '$page' LIMIT 1";
    695             $_page = & $wpdb->get_row($query);
    696             if ( 'static' != $_page->post_status )
    697                 return get_post($_page, $output);
    698             wp_cache_add($_page->ID, $_page, 'pages');
    699         }
    700     }
    701    
    702     if (!isset($_page->fullpath)) {
    703         $_page = set_page_path($_page);
    704         wp_cache_replace($_page->cat_ID, $_page, 'pages');
    705     }
    706 
    707     if ( $output == OBJECT ) {
    708         return $_page;
    709     } elseif ( $output == ARRAY_A ) {
    710         return get_object_vars($_page);
    711     } elseif ( $output == ARRAY_N ) {
    712         return array_values(get_object_vars($_page));
    713     } else {
    714         return $_page;
    715     }
    716 }
    717 
    718 function set_category_path($cat) {
    719     $cat->fullpath = '/' . $cat->category_nicename;
    720     $path = $cat->fullpath;
    721     $curcat = $cat;
    722     while ($curcat->category_parent != 0) {
    723         $curcat = get_category($curcat->category_parent);
    724         $path = '/' . $curcat->category_nicename . $path;
    725     }
    726    
    727     $cat->fullpath = $path;
    728 
    729     return $cat;
    730 }
    731 
    732 // Retrieves category data given a category ID or category object.
    733 // Handles category caching.
    734 function &get_category(&$category, $output = OBJECT) {
    735     global $wpdb;
    736 
    737     if ( empty($category) )
    738         return null;
    739 
    740     if ( is_object($category) ) {
    741         wp_cache_add($category->cat_ID, $category, 'category');
    742         $_category = $category;
    743     } else {
    744         if ( ! $_category = wp_cache_get($category, 'category') ) {
    745             $_category = $wpdb->get_row("SELECT * FROM $wpdb->categories WHERE cat_ID = '$category' LIMIT 1");
    746             wp_cache_add($category, $_category, 'category');
    747         }
    748     }
    749 
    750     if ( !isset($_category->fullpath) ) {
    751         $_category = set_category_path($_category);
    752         wp_cache_replace($_category->cat_ID, $_category, 'category');   
    753     }
    754 
    755     if ( $output == OBJECT ) {
    756         return $_category;
    757     } elseif ( $output == ARRAY_A ) {
    758         return get_object_vars($_category);
    759     } elseif ( $output == ARRAY_N ) {
    760         return array_values(get_object_vars($_category));
    761     } else {
    762         return $_category;
    763     }
    764 }
    765 
    766 // Retrieves comment data given a comment ID or comment object.
    767 // Handles comment caching.
    768 function &get_comment(&$comment, $output = OBJECT) {
    769     global $comment_cache, $wpdb;
    770 
    771     if ( empty($comment) )
    772         return null;
    773 
    774     if ( is_object($comment) ) {
    775         if ( !isset($comment_cache[$comment->comment_ID]) )
    776             $comment_cache[$comment->comment_ID] = &$comment;
    777         $_comment = & $comment_cache[$comment->comment_ID];
    778     } else {
    779         if ( !isset($comment_cache[$comment]) ) {
    780             $_comment = $wpdb->get_row("SELECT * FROM $wpdb->comments WHERE comment_ID = '$comment' LIMIT 1");
    781             $comment_cache[$comment->comment_ID] = & $_comment;
    782         } else {
    783             $_comment = & $comment_cache[$comment];
    784         }
    785     }
    786 
    787     if ( $output == OBJECT ) {
    788         return $_comment;
    789     } elseif ( $output == ARRAY_A ) {
    790         return get_object_vars($_comment);
    791     } elseif ( $output == ARRAY_N ) {
    792         return array_values(get_object_vars($_comment));
    793     } else {
    794         return $_comment;
    795     }
    796 }
    797 
    798 function get_catname($cat_ID) {
    799     $category = &get_category($cat_ID);
    800     return $category->cat_name;
    801 }
    802 
    803 function get_all_category_ids() {
    804     global $wpdb;
    805    
    806     if ( ! $cat_ids = wp_cache_get('all_category_ids', 'category') ) {
    807         $cat_ids = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories");
    808         wp_cache_add('all_category_ids', $cat_ids, 'category');
    809     }
    810    
    811     return $cat_ids;
    812 }
    813 
    814 function get_all_page_ids() {
    815     global $wpdb;
    816    
    817     if ( ! $page_ids = wp_cache_get('all_page_ids', 'pages') ) {
    818         $page_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_status='static'");
    819         wp_cache_add('all_page_ids', $page_ids, 'pages');
    820     }
    821    
    822     return $page_ids;
     304function maybe_serialize($data) {
     305    if ( is_string($data) )
     306        $data = trim($data);
     307    elseif ( is_array($data) || is_object($data) )
     308        return serialize($data);
     309    if ( is_serialized($data) )
     310        return serialize($data);
     311    return $data;
    823312}
    824313
    825314function gzip_compression() {
    826     if ( !get_settings('gzipcompression') ) return false;
     315    if ( !get_option('gzipcompression') ) return false;
    827316
    828317    if ( extension_loaded('zlib') ) {
    829318        ob_start('ob_gzhandler');
    830319    }
    831 }
    832 
    833 
    834 // functions to count the page generation time (from phpBB2)
    835 // ( or just any time between timer_start() and timer_stop() )
    836 
    837 function timer_stop($display = 0, $precision = 3) { //if called like timer_stop(1), will echo $timetotal
    838     global $timestart, $timeend;
    839     $mtime = microtime();
    840     $mtime = explode(' ',$mtime);
    841     $mtime = $mtime[1] + $mtime[0];
    842     $timeend = $mtime;
    843     $timetotal = $timeend-$timestart;
    844     if ( $display )
    845         echo number_format($timetotal,$precision);
    846     return $timetotal;
    847 }
    848 
    849 function weblog_ping($server = '', $path = '') {
    850     global $wp_version;
    851     include_once (ABSPATH . WPINC . '/class-IXR.php');
    852 
    853     // using a timeout of 3 seconds should be enough to cover slow servers
    854     $client = new IXR_Client($server, ((!strlen(trim($path)) || ('/' == $path)) ? false : $path));
    855     $client->timeout = 3;
    856     $client->useragent .= ' -- WordPress/'.$wp_version;
    857 
    858     // when set to true, this outputs debug messages by itself
    859     $client->debug = false;
    860     $home = trailingslashit( get_option('home') );
    861     if ( !$client->query('weblogUpdates.extendedPing', get_settings('blogname'), $home, get_bloginfo('rss2_url') ) ) // then try a normal ping
    862         $client->query('weblogUpdates.ping', get_settings('blogname'), $home);
    863 }
    864 
    865 function generic_ping($post_id = 0) {
    866     $services = get_settings('ping_sites');
    867     $services = preg_replace("|(\s)+|", '$1', $services); // Kill dupe lines
    868     $services = trim($services);
    869     if ( '' != $services ) {
    870         $services = explode("\n", $services);
    871         foreach ($services as $service) {
    872             weblog_ping($service);
    873         }
    874     }
    875 
    876     return $post_id;
    877 }
    878 
    879 // Send a Trackback
    880 function trackback($trackback_url, $title, $excerpt, $ID) {
    881     global $wpdb, $wp_version;
    882 
    883     if ( empty($trackback_url) )
    884         return;
    885 
    886     $title = urlencode($title);
    887     $excerpt = urlencode($excerpt);
    888     $blog_name = urlencode(get_settings('blogname'));
    889     $tb_url = $trackback_url;
    890     $url = urlencode(get_permalink($ID));
    891     $query_string = "title=$title&url=$url&blog_name=$blog_name&excerpt=$excerpt";
    892     $trackback_url = parse_url($trackback_url);
    893     $http_request = 'POST ' . $trackback_url['path'] . ($trackback_url['query'] ? '?'.$trackback_url['query'] : '') . " HTTP/1.0\r\n";
    894     $http_request .= 'Host: '.$trackback_url['host']."\r\n";
    895     $http_request .= 'Content-Type: application/x-www-form-urlencoded; charset='.get_settings('blog_charset')."\r\n";
    896     $http_request .= 'Content-Length: '.strlen($query_string)."\r\n";
    897     $http_request .= "User-Agent: WordPress/" . $wp_version;
    898     $http_request .= "\r\n\r\n";
    899     $http_request .= $query_string;
    900     if ( '' == $trackback_url['port'] )
    901         $trackback_url['port'] = 80;
    902     $fs = @fsockopen($trackback_url['host'], $trackback_url['port'], $errno, $errstr, 4);
    903     @fputs($fs, $http_request);
    904 /*
    905     $debug_file = 'trackback.log';
    906     $fp = fopen($debug_file, 'a');
    907     fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n");
    908     while(!@feof($fs)) {
    909         fwrite($fp, @fgets($fs, 4096));
    910     }
    911     fwrite($fp, "\n\n");
    912     fclose($fp);
    913 */
    914     @fclose($fs);
    915 
    916     $tb_url = addslashes( $tb_url );
    917     $wpdb->query("UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', '$tb_url') WHERE ID = '$ID'");
    918     return $wpdb->query("UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, '$tb_url', '')) WHERE ID = '$ID'");
    919320}
    920321
     
    930331        $link_text = $matches[4][$i];
    931332        $content = str_replace($link_match, $link_text.' '.$link_number, $content);
    932         $link_url = ((strtolower(substr($link_url,0,7)) != 'http://') && (strtolower(substr($link_url,0,8)) != 'https://')) ? get_settings('home') . $link_url : $link_url;
     333        $link_url = ((strtolower(substr($link_url,0,7)) != 'http://') && (strtolower(substr($link_url,0,8)) != 'https://')) ? get_option('home') . $link_url : $link_url;
    933334        $links_summary .= "\n".$link_number.' '.$link_url;
    934335    }
     
    991392        fclose($fp);
    992393    }
    993 }
    994 
    995 function spawn_pinger() {
    996     global $wpdb;
    997     $doping = false;
    998     if ( $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE TRIM(to_ping) != '' LIMIT 1") )
    999         $doping = true;
    1000 
    1001     if ( $wpdb->get_var("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_pingme' OR meta_key = '_encloseme' LIMIT 1") )
    1002         $doping = true;
    1003 
    1004     if ( substr(php_sapi_name(), 0, 3) == 'cgi' )
    1005         return $doping;
    1006 
    1007     if ( $doping ) {
    1008         $ping_url = get_settings('siteurl') .'/wp-admin/execute-pings.php';
    1009         $parts = parse_url($ping_url);
    1010         $argyle = @ fsockopen($parts['host'], $_SERVER['SERVER_PORT'], $errno, $errstr, 0.01);
    1011         if ( $argyle )
    1012             fputs($argyle, "GET {$parts['path']}?time=".time()." HTTP/1.0\r\nHost: {$_SERVER['HTTP_HOST']}\r\n\r\n");
    1013        }
    1014394}
    1015395
     
    1091471    }
    1092472
    1093     $code = preg_replace('/.*?(\d{3}).*/i', '$1', $response);
    1094    
    1095     $headers['status_code'] = $code;
    1096    
    1097     if ( '302' == $code || '301' == $code )
    1098         return wp_get_http_headers( $url, ++$red );
    1099 
    1100473    preg_match('/.*([0-9]{3}).*/', $response, $return);
    1101474    $headers['response'] = $return[1]; // HTTP response code eg 204, 200, 404
     475
     476    $code = $headers['response'];
     477    if ( ('302' == $code || '301' == $code) && isset($headers['location']) )
     478        return wp_get_http_headers( $headers['location'], ++$red );
     479
    1102480    return $headers;
    1103 }
    1104 
    1105 // Deprecated.  Use the new post loop.
    1106 function start_wp() {
    1107     global $wp_query, $post;
    1108 
    1109     // Since the old style loop is being used, advance the query iterator here.
    1110     $wp_query->next_post();
    1111 
    1112     setup_postdata($post);
    1113 }
    1114 
    1115 // Setup global post data.
    1116 function setup_postdata($post) {
    1117     global $id, $postdata, $authordata, $day, $page, $pages, $multipage, $more, $numpages, $wp_query;
    1118     global $pagenow;
    1119 
    1120     $id = $post->ID;
    1121 
    1122     $authordata = get_userdata($post->post_author);
    1123 
    1124     $day = mysql2date('d.m.y', $post->post_date);
    1125     $currentmonth = mysql2date('m', $post->post_date);
    1126     $numpages = 1;
    1127     $page = get_query_var('page');
    1128     if ( !$page )
    1129         $page = 1;
    1130     if ( is_single() || is_page() )
    1131         $more = 1;
    1132     $content = $post->post_content;
    1133     if ( preg_match('/<!--nextpage-->/', $content) ) {
    1134         if ( $page > 1 )
    1135             $more = 1;
    1136         $multipage = 1;
    1137         $content = str_replace("\n<!--nextpage-->\n", '<!--nextpage-->', $content);
    1138         $content = str_replace("\n<!--nextpage-->", '<!--nextpage-->', $content);
    1139         $content = str_replace("<!--nextpage-->\n", '<!--nextpage-->', $content);
    1140         $pages = explode('<!--nextpage-->', $content);
    1141         $numpages = count($pages);
    1142     } else {
    1143         $pages[0] = $post->post_content;
    1144         $multipage = 0;
    1145     }
    1146     return true;
    1147481}
    1148482
     
    1156490}
    1157491
    1158 // Filters: these are the core of WP's plugin architecture
    1159 
    1160 function merge_filters($tag) {
    1161     global $wp_filter;
    1162     if ( isset($wp_filter['all']) ) {
    1163         foreach ($wp_filter['all'] as $priority => $functions) {
    1164             if ( isset($wp_filter[$tag][$priority]) )
    1165                 $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], $wp_filter[$tag][$priority]);
    1166             else
    1167                 $wp_filter[$tag][$priority] = array_merge($wp_filter['all'][$priority], array());
    1168             $wp_filter[$tag][$priority] = array_unique($wp_filter[$tag][$priority]);
    1169         }
    1170     }
    1171 
    1172     if ( isset($wp_filter[$tag]) )
    1173         ksort( $wp_filter[$tag] );
    1174 }
    1175 
    1176 function apply_filters($tag, $string) {
    1177     global $wp_filter;
    1178 
    1179     $args = array_slice(func_get_args(), 2);
    1180 
    1181     merge_filters($tag);
    1182 
    1183     if ( !isset($wp_filter[$tag]) ) {
    1184         return $string;
    1185     }
    1186     foreach ($wp_filter[$tag] as $priority => $functions) {
    1187         if ( !is_null($functions) ) {
    1188             foreach($functions as $function) {
    1189 
    1190                 $all_args = array_merge(array($string), $args);
    1191                 $function_name = $function['function'];
    1192                 $accepted_args = $function['accepted_args'];
    1193 
    1194                 if ( $accepted_args == 1 )
    1195                     $the_args = array($string);
    1196                 elseif ( $accepted_args > 1 )
    1197                     $the_args = array_slice($all_args, 0, $accepted_args);
    1198                 elseif ( $accepted_args == 0 )
    1199                     $the_args = NULL;
    1200                 else
    1201                     $the_args = $all_args;
    1202 
    1203                 $string = call_user_func_array($function_name, $the_args);
    1204             }
    1205         }
    1206     }
    1207     return $string;
    1208 }
    1209 
    1210 function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
    1211     global $wp_filter;
    1212 
    1213     // check that we don't already have the same filter at the same priority
    1214     if ( isset($wp_filter[$tag]["$priority"]) ) {
    1215         foreach($wp_filter[$tag]["$priority"] as $filter) {
    1216             // uncomment if we want to match function AND accepted_args
    1217             // if ( $filter == array($function, $accepted_args) ) {
    1218             if ( $filter['function'] == $function_to_add ) {
    1219                 return true;
    1220             }
    1221         }
    1222     }
    1223 
    1224     // So the format is wp_filter['tag']['array of priorities']['array of ['array (functions, accepted_args)]']
    1225     $wp_filter[$tag]["$priority"][] = array('function'=>$function_to_add, 'accepted_args'=>$accepted_args);
    1226     return true;
    1227 }
    1228 
    1229 function remove_filter($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
    1230     global $wp_filter;
    1231 
    1232     // rebuild the list of filters
    1233     if ( isset($wp_filter[$tag]["$priority"]) ) {
    1234         foreach($wp_filter[$tag]["$priority"] as $filter) {
    1235             if ( $filter['function'] != $function_to_remove ) {
    1236                 $new_function_list[] = $filter;
    1237             }
    1238         }
    1239         $wp_filter[$tag]["$priority"] = $new_function_list;
    1240     }
    1241     return true;
    1242 }
    1243 
    1244 // The *_action functions are just aliases for the *_filter functions, they take special strings instead of generic content
    1245 
    1246 function do_action($tag, $arg = '') {
    1247     global $wp_filter;
    1248     $extra_args = array_slice(func_get_args(), 2);
    1249     if ( is_array($arg) )
    1250         $args = array_merge($arg, $extra_args);
    1251     else
    1252         $args = array_merge(array($arg), $extra_args);
    1253 
    1254     merge_filters($tag);
    1255 
    1256     if ( !isset($wp_filter[$tag]) ) {
    1257         return;
    1258     }
    1259     foreach ($wp_filter[$tag] as $priority => $functions) {
    1260         if ( !is_null($functions) ) {
    1261             foreach($functions as $function) {
    1262 
    1263                 $function_name = $function['function'];
    1264                 $accepted_args = $function['accepted_args'];
    1265 
    1266                 if ( $accepted_args == 1 ) {
    1267                     if ( is_array($arg) )
    1268                         $the_args = $arg;
    1269                     else
    1270                         $the_args = array($arg);
    1271                 } elseif ( $accepted_args > 1 ) {
    1272                     $the_args = array_slice($args, 0, $accepted_args);
    1273                 } elseif ( $accepted_args == 0 ) {
    1274                     $the_args = NULL;
    1275                 } else {
    1276                     $the_args = $args;
    1277                 }
    1278 
    1279                 $string = call_user_func_array($function_name, $the_args);
    1280             }
    1281         }
    1282     }
    1283 }
    1284 
    1285 function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
    1286     add_filter($tag, $function_to_add, $priority, $accepted_args);
    1287 }
    1288 
    1289 function remove_action($tag, $function_to_remove, $priority = 10, $accepted_args = 1) {
    1290     remove_filter($tag, $function_to_remove, $priority, $accepted_args);
    1291 }
    1292 
    1293 function get_page_uri($page_id) {
    1294     $page = get_page($page_id);
    1295     $uri = urldecode($page->post_name);
    1296 
    1297     // A page cannot be it's own parent.
    1298     if ( $page->post_parent == $page->ID )
    1299         return $uri;
    1300 
    1301     while ($page->post_parent != 0) {
    1302         $page = get_page($page->post_parent);
    1303         $uri = urldecode($page->post_name) . "/" . $uri;
    1304     }
    1305 
    1306     return $uri;
    1307 }
    1308 
    1309 function get_posts($args) {
    1310     global $wpdb;
    1311     parse_str($args, $r);
    1312     if ( !isset($r['numberposts']) )
    1313         $r['numberposts'] = 5;
    1314     if ( !isset($r['offset']) )
    1315         $r['offset'] = 0;
    1316     if ( !isset($r['category']) )
    1317         $r['category'] = '';
    1318     if ( !isset($r['orderby']) )
    1319         $r['orderby'] = 'post_date';
    1320     if ( !isset($r['order']) )
    1321         $r['order'] = 'DESC';
    1322 
    1323     $now = current_time('mysql');
    1324 
    1325     $posts = $wpdb->get_results(
    1326         "SELECT DISTINCT * FROM $wpdb->posts " .
    1327         ( empty( $r['category'] ) ? "" : ", $wpdb->post2cat " ) .
    1328         " WHERE post_date <= '$now' AND (post_status = 'publish') ".
    1329         ( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) .
    1330         " GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . " LIMIT " . $r['offset'] . ',' . $r['numberposts'] );
    1331 
    1332     update_post_caches($posts);
    1333 
    1334     return $posts;
    1335 }
    1336 
    1337 function &query_posts($query) {
    1338     global $wp_query;
    1339     return $wp_query->query($query);
    1340 }
    1341 
    1342492function update_post_cache(&$posts) {
    1343493    global $post_cache;
     
    1391541    if ( empty($dogs) )
    1392542        return;
    1393        
     543
    1394544    foreach ($dogs as $catt)
    1395545        $category_cache[$catt->post_id][$catt->category_id] = &get_category($catt->category_id);
     
    1397547
    1398548function update_post_caches(&$posts) {
    1399     global $post_cache, $category_cache, $comment_count_cache, $post_meta_cache;
     549    global $post_cache, $category_cache, $post_meta_cache;
    1400550    global $wpdb;
    1401551
     
    1408558        $post_id_array[] = $posts[$i]->ID;
    1409559        $post_cache[$posts[$i]->ID] = &$posts[$i];
    1410         $comment_count_cache[$posts[$i]->ID] = $posts[$i]->comment_count;
    1411560    }
    1412561
     
    1414563
    1415564    update_post_category_cache($post_id_list);
     565
     566    update_postmeta_cache($post_id_list);
     567}
     568
     569function update_postmeta_cache($post_id_list = '') {
     570    global $wpdb, $post_meta_cache;
     571
     572    // We should validate this comma-separated list for the upcoming SQL query
     573    $post_id_list = preg_replace('|[^0-9,]|', '', $post_id_list);
     574
     575    // we're marking each post as having its meta cached (with no keys... empty array), to prevent posts with no meta keys from being queried again
     576    // any posts that DO have keys will have this empty array overwritten with a proper array, down below
     577    $post_id_array = explode(',', $post_id_list);
     578    foreach ( (array) $post_id_array as $pid )
     579        $post_meta_cache[$pid] = array();
    1416580
    1417581    // Get post-meta info
    1418582    if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) {
    1419583        // Change from flat structure to hierarchical:
    1420         $post_meta_cache = array();
     584        if ( !isset($post_meta_cache) )
     585            $post_meta_cache = array();
     586
    1421587        foreach ($meta_list as $metarow) {
    1422             $mpid = $metarow['post_id'];
     588            $mpid = (int) $metarow['post_id'];
    1423589            $mkey = $metarow['meta_key'];
    1424590            $mval = $metarow['meta_value'];
     
    1438604function update_category_cache() {
    1439605    return true;
    1440 }
    1441 
    1442 function wp_head() {
    1443     do_action('wp_head');
    1444 }
    1445 
    1446 function wp_footer() {
    1447     do_action('wp_footer');
    1448 }
    1449 
    1450 function is_single ($post = '') {
    1451     global $wp_query;
    1452 
    1453     if ( !$wp_query->is_single )
    1454         return false;
    1455 
    1456     if ( empty( $post) )
    1457         return true;
    1458 
    1459     $post_obj = $wp_query->get_queried_object();
    1460 
    1461     if ( $post == $post_obj->ID )
    1462         return true;
    1463     elseif ( $post == $post_obj->post_title )
    1464         return true;
    1465     elseif ( $post == $post_obj->post_name )
    1466         return true;
    1467 
    1468     return false;
    1469 }
    1470 
    1471 function is_page ($page = '') {
    1472     global $wp_query;
    1473 
    1474     if ( !$wp_query->is_page )
    1475         return false;
    1476 
    1477     if ( empty($page) )
    1478         return true;
    1479 
    1480     $page_obj = $wp_query->get_queried_object();
    1481 
    1482     if ( $page == $page_obj->ID )
    1483         return true;
    1484     elseif ( $page == $page_obj->post_title )
    1485         return true;
    1486     else if ( $page == $page_obj->post_name )
    1487         return true;
    1488 
    1489     return false;
    1490 }
    1491 
    1492 function is_attachment () {
    1493     global $wp_query;
    1494 
    1495     return $wp_query->is_attachment;
    1496 }
    1497 
    1498 function is_preview() {
    1499     global $wp_query;
    1500    
    1501     return $wp_query->is_preview;
    1502 }
    1503 
    1504 function is_archive () {
    1505     global $wp_query;
    1506 
    1507     return $wp_query->is_archive;
    1508 }
    1509 
    1510 function is_date () {
    1511     global $wp_query;
    1512 
    1513     return $wp_query->is_date;
    1514 }
    1515 
    1516 function is_year () {
    1517     global $wp_query;
    1518 
    1519     return $wp_query->is_year;
    1520 }
    1521 
    1522 function is_month () {
    1523     global $wp_query;
    1524 
    1525     return $wp_query->is_month;
    1526 }
    1527 
    1528 function is_day () {
    1529     global $wp_query;
    1530 
    1531     return $wp_query->is_day;
    1532 }
    1533 
    1534 function is_time () {
    1535     global $wp_query;
    1536 
    1537     return $wp_query->is_time;
    1538 }
    1539 
    1540 function is_author ($author = '') {
    1541     global $wp_query;
    1542 
    1543     if ( !$wp_query->is_author )
    1544         return false;
    1545 
    1546     if ( empty($author) )
    1547         return true;
    1548 
    1549     $author_obj = $wp_query->get_queried_object();
    1550 
    1551     if ( $author == $author_obj->ID )
    1552         return true;
    1553     elseif ( $author == $author_obj->nickname )
    1554         return true;
    1555     elseif ( $author == $author_obj->user_nicename )
    1556         return true;
    1557 
    1558     return false;
    1559 }
    1560 
    1561 function is_category ($category = '') {
    1562     global $wp_query;
    1563 
    1564     if ( !$wp_query->is_category )
    1565         return false;
    1566 
    1567     if ( empty($category) )
    1568         return true;
    1569 
    1570     $cat_obj = $wp_query->get_queried_object();
    1571 
    1572     if ( $category == $cat_obj->cat_ID )
    1573         return true;
    1574     else if ( $category == $cat_obj->cat_name )
    1575         return true;
    1576     elseif ( $category == $cat_obj->category_nicename )
    1577         return true;
    1578 
    1579     return false;
    1580 }
    1581 
    1582 function is_search () {
    1583     global $wp_query;
    1584 
    1585     return $wp_query->is_search;
    1586 }
    1587 
    1588 function is_feed () {
    1589     global $wp_query;
    1590 
    1591     return $wp_query->is_feed;
    1592 }
    1593 
    1594 function is_trackback () {
    1595     global $wp_query;
    1596 
    1597     return $wp_query->is_trackback;
    1598 }
    1599 
    1600 function is_admin () {
    1601     global $wp_query;
    1602 
    1603     return ( $wp_query->is_admin || strstr($_SERVER['REQUEST_URI'], 'wp-admin/') );
    1604 }
    1605 
    1606 function is_home () {
    1607     global $wp_query;
    1608 
    1609     return $wp_query->is_home;
    1610 }
    1611 
    1612 function is_404 () {
    1613     global $wp_query;
    1614 
    1615     return $wp_query->is_404;
    1616 }
    1617 
    1618 function is_comments_popup () {
    1619     global $wp_query;
    1620 
    1621     return $wp_query->is_comments_popup;
    1622 }
    1623 
    1624 function is_paged () {
    1625     global $wp_query;
    1626 
    1627     return $wp_query->is_paged;
    1628 }
    1629 
    1630 function in_the_loop() {
    1631     global $wp_query;
    1632 
    1633     return $wp_query->in_the_loop;
    1634 }
    1635 
    1636 function get_query_var($var) {
    1637     global $wp_query;
    1638 
    1639     return $wp_query->get($var);
    1640 }
    1641 
    1642 function have_posts() {
    1643     global $wp_query;
    1644 
    1645     return $wp_query->have_posts();
    1646 }
    1647 
    1648 function rewind_posts() {
    1649     global $wp_query;
    1650 
    1651     return $wp_query->rewind_posts();
    1652 }
    1653 
    1654 function the_post() {
    1655     global $wp_query;
    1656 
    1657     $wp_query->the_post();
    1658 }
    1659 
    1660 function get_theme_root() {
    1661     return apply_filters('theme_root', ABSPATH . "wp-content/themes");
    1662 }
    1663 
    1664 function get_theme_root_uri() {
    1665     return apply_filters('theme_root_uri', get_settings('siteurl') . "/wp-content/themes", get_settings('siteurl'));
    1666 }
    1667 
    1668 function get_stylesheet() {
    1669     return apply_filters('stylesheet', get_settings('stylesheet'));
    1670 }
    1671 
    1672 function get_stylesheet_directory() {
    1673     $stylesheet = get_stylesheet();
    1674     $stylesheet_dir = get_theme_root() . "/$stylesheet";
    1675     return apply_filters('stylesheet_directory', $stylesheet_dir, $stylesheet);
    1676 }
    1677 
    1678 function get_stylesheet_directory_uri() {
    1679     $stylesheet = rawurlencode( get_stylesheet() );
    1680     $stylesheet_dir_uri = get_theme_root_uri() . "/$stylesheet";
    1681     return apply_filters('stylesheet_directory_uri', $stylesheet_dir_uri, $stylesheet);
    1682 }
    1683 
    1684 function get_stylesheet_uri() {
    1685     $stylesheet_dir_uri = get_stylesheet_directory_uri();
    1686     $stylesheet_uri = $stylesheet_dir_uri . "/style.css";
    1687     return apply_filters('stylesheet_uri', $stylesheet_uri, $stylesheet_dir_uri);
    1688 }
    1689 
    1690 function get_template() {
    1691     $template = get_settings('template');
    1692     if (!file_exists(get_theme_root() . "/$template")) { //works for dirs too
    1693         update_option('template', 'default');
    1694         update_option('stylesheet', 'default');
    1695     }
    1696     return apply_filters('template', get_settings('template'));
    1697 }
    1698 
    1699 function get_template_directory() {
    1700     $template = get_template();
    1701     $template_dir = get_theme_root() . "/$template";
    1702     return apply_filters('template_directory', $template_dir, $template);
    1703 }
    1704 
    1705 function get_template_directory_uri() {
    1706     $template = get_template();
    1707     $template_dir_uri = get_theme_root_uri() . "/$template";
    1708     return apply_filters('template_directory_uri', $template_dir_uri, $template);
    1709 }
    1710 
    1711 function get_theme_data($theme_file) {
    1712     $theme_data = implode('', file($theme_file));
    1713     preg_match("|Theme Name:(.*)|i", $theme_data, $theme_name);
    1714     preg_match("|Theme URI:(.*)|i", $theme_data, $theme_uri);
    1715     preg_match("|Description:(.*)|i", $theme_data, $description);
    1716     preg_match("|Author:(.*)|i", $theme_data, $author_name);
    1717     preg_match("|Author URI:(.*)|i", $theme_data, $author_uri);
    1718     preg_match("|Template:(.*)|i", $theme_data, $template);
    1719     if ( preg_match("|Version:(.*)|i", $theme_data, $version) )
    1720         $version = $version[1];
    1721     else
    1722         $version ='';
    1723     if ( preg_match("|Status:(.*)|i", $theme_data, $status) )
    1724         $status = $status[1];
    1725     else
    1726         $status ='publish';
    1727 
    1728     $description = wptexturize($description[1]);
    1729 
    1730     $name = $theme_name[1];
    1731     $name = trim($name);
    1732     $theme = $name;
    1733 
    1734     if ( '' == $author_uri[1] ) {
    1735         $author = $author_name[1];
    1736     } else {
    1737         $author = '<a href="' . $author_uri[1] . '" title="' . __('Visit author homepage') . '">' . $author_name[1] . '</a>';
    1738     }
    1739 
    1740     return array('Name' => $name, 'Title' => $theme, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template[1], 'Status' => $status);
    1741 }
    1742 
    1743 function get_themes() {
    1744     global $wp_themes;
    1745     global $wp_broken_themes;
    1746 
    1747     if ( isset($wp_themes) )
    1748         return $wp_themes;
    1749 
    1750     $themes = array();
    1751     $wp_broken_themes = array();
    1752     $theme_root = get_theme_root();
    1753     $theme_loc = str_replace(ABSPATH, '', $theme_root);
    1754 
    1755     // Files in wp-content/themes directory
    1756     $themes_dir = @ dir($theme_root);
    1757     if ( $themes_dir ) {
    1758         while(($theme_dir = $themes_dir->read()) !== false) {
    1759             if ( is_dir($theme_root . '/' . $theme_dir) && is_readable($theme_root . '/' . $theme_dir) ) {
    1760                 if ( $theme_dir{0} == '.' || $theme_dir == '..' || $theme_dir == 'CVS' ) {
    1761                     continue;
    1762                 }
    1763                 $stylish_dir = @ dir($theme_root . '/' . $theme_dir);
    1764                 $found_stylesheet = false;
    1765                 while (($theme_file = $stylish_dir->read()) !== false) {
    1766                     if ( $theme_file == 'style.css' ) {
    1767                         $theme_files[] = $theme_dir . '/' . $theme_file;
    1768                         $found_stylesheet = true;
    1769                         break;
    1770                     }
    1771                 }
    1772                 if ( !$found_stylesheet ) {
    1773                     $wp_broken_themes[$theme_dir] = array('Name' => $theme_dir, 'Title' => $theme_dir, 'Description' => __('Stylesheet is missing.'));
    1774                 }
    1775             }
    1776         }
    1777     }
    1778 
    1779     if ( !$themes_dir || !$theme_files ) {
    1780         return $themes;
    1781     }
    1782 
    1783     sort($theme_files);
    1784 
    1785     foreach($theme_files as $theme_file) {
    1786         if ( ! is_readable("$theme_root/$theme_file") ) {
    1787             $wp_broken_themes[$theme_file] = array('Name' => $theme_file, 'Title' => $theme_file, 'Description' => __('File not readable.'));
    1788             continue;
    1789         }
    1790 
    1791         $theme_data = get_theme_data("$theme_root/$theme_file");
    1792 
    1793         $name = $theme_data['Name'];
    1794         $title = $theme_data['Title'];
    1795         $description = wptexturize($theme_data['Description']);
    1796         $version = $theme_data['Version'];
    1797         $author = $theme_data['Author'];
    1798         $template = $theme_data['Template'];
    1799         $stylesheet = dirname($theme_file);
    1800 
    1801         foreach (array('png', 'gif', 'jpg', 'jpeg') as $ext) {
    1802             if (file_exists("$theme_root/$stylesheet/screenshot.$ext")) {
    1803                 $screenshot = "screenshot.$ext";
    1804                 break;
    1805             }
    1806         }
    1807 
    1808         if ( empty($name) ) {
    1809             $name = dirname($theme_file);
    1810             $title = $name;
    1811         }
    1812 
    1813         if ( empty($template) ) {
    1814             if ( file_exists(dirname("$theme_root/$theme_file/index.php")) ) {
    1815                 $template = dirname($theme_file);
    1816             } else {
    1817                 continue;
    1818             }
    1819         }
    1820 
    1821         $template = trim($template);
    1822 
    1823         if ( !file_exists("$theme_root/$template/index.php") ) {
    1824             $wp_broken_themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => __('Template is missing.'));
    1825             continue;
    1826         }
    1827 
    1828         $stylesheet_files = array();
    1829         $stylesheet_dir = @ dir("$theme_root/$stylesheet");
    1830         if ( $stylesheet_dir ) {
    1831             while(($file = $stylesheet_dir->read()) !== false) {
    1832                 if ( !preg_match('|^\.+$|', $file) && preg_match('|\.css$|', $file) )
    1833                     $stylesheet_files[] = "$theme_loc/$stylesheet/$file";
    1834             }
    1835         }
    1836 
    1837         $template_files = array();
    1838         $template_dir = @ dir("$theme_root/$template");
    1839         if ( $template_dir ) {
    1840             while(($file = $template_dir->read()) !== false) {
    1841                 if ( !preg_match('|^\.+$|', $file) && preg_match('|\.php$|', $file) )
    1842                     $template_files[] = "$theme_loc/$template/$file";
    1843             }
    1844         }
    1845 
    1846         $template_dir = dirname($template_files[0]);
    1847         $stylesheet_dir = dirname($stylesheet_files[0]);
    1848 
    1849         if ( empty($template_dir) )
    1850             $template_dir = '/';
    1851         if ( empty($stylesheet_dir) )
    1852             $stylesheet_dir = '/';
    1853 
    1854         // Check for theme name collision.  This occurs if a theme is copied to
    1855         // a new theme directory and the theme header is not updated.  Whichever
    1856         // theme is first keeps the name.  Subsequent themes get a suffix applied.
    1857         // The Default and Classic themes always trump their pretenders.
    1858         if ( isset($themes[$name]) ) {
    1859             if ( ('WordPress Default' == $name || 'WordPress Classic' == $name) &&
    1860                      ('default' == $stylesheet || 'classic' == $stylesheet) ) {
    1861                 // If another theme has claimed to be one of our default themes, move
    1862                 // them aside.
    1863                 $suffix = $themes[$name]['Stylesheet'];
    1864                 $new_name = "$name/$suffix";
    1865                 $themes[$new_name] = $themes[$name];
    1866                 $themes[$new_name]['Name'] = $new_name;
    1867             } else {
    1868                 $name = "$name/$stylesheet";
    1869             }
    1870         }
    1871 
    1872         $themes[$name] = array('Name' => $name, 'Title' => $title, 'Description' => $description, 'Author' => $author, 'Version' => $version, 'Template' => $template, 'Stylesheet' => $stylesheet, 'Template Files' => $template_files, 'Stylesheet Files' => $stylesheet_files, 'Template Dir' => $template_dir, 'Stylesheet Dir' => $stylesheet_dir, 'Status' => $theme_data['Status'], 'Screenshot' => $screenshot);
    1873     }
    1874 
    1875     // Resolve theme dependencies.
    1876     $theme_names = array_keys($themes);
    1877 
    1878     foreach ($theme_names as $theme_name) {
    1879         $themes[$theme_name]['Parent Theme'] = '';
    1880         if ( $themes[$theme_name]['Stylesheet'] != $themes[$theme_name]['Template'] ) {
    1881             foreach ($theme_names as $parent_theme_name) {
    1882                 if ( ($themes[$parent_theme_name]['Stylesheet'] == $themes[$parent_theme_name]['Template']) && ($themes[$parent_theme_name]['Template'] == $themes[$theme_name]['Template']) ) {
    1883                     $themes[$theme_name]['Parent Theme'] = $themes[$parent_theme_name]['Name'];
    1884                     break;
    1885                 }
    1886             }
    1887         }
    1888     }
    1889 
    1890     $wp_themes = $themes;
    1891 
    1892     return $themes;
    1893 }
    1894 
    1895 function get_theme($theme) {
    1896     $themes = get_themes();
    1897 
    1898     if ( array_key_exists($theme, $themes) )
    1899         return $themes[$theme];
    1900 
    1901     return NULL;
    1902 }
    1903 
    1904 function get_current_theme() {
    1905     $themes = get_themes();
    1906     $theme_names = array_keys($themes);
    1907     $current_template = get_settings('template');
    1908     $current_stylesheet = get_settings('stylesheet');
    1909     $current_theme = 'WordPress Default';
    1910 
    1911     if ( $themes ) {
    1912         foreach ($theme_names as $theme_name) {
    1913             if ( $themes[$theme_name]['Stylesheet'] == $current_stylesheet &&
    1914                     $themes[$theme_name]['Template'] == $current_template ) {
    1915                 $current_theme = $themes[$theme_name]['Name'];
    1916                 break;
    1917             }
    1918         }
    1919     }
    1920 
    1921     return $current_theme;
    1922 }
    1923 
    1924 function get_query_template($type) {
    1925     $template = '';
    1926     if ( file_exists(TEMPLATEPATH . "/{$type}.php") )
    1927         $template = TEMPLATEPATH . "/{$type}.php";
    1928 
    1929     return apply_filters("{$type}_template", $template);
    1930 }
    1931 
    1932 function get_404_template() {
    1933     return get_query_template('404');
    1934 }
    1935 
    1936 function get_archive_template() {
    1937     return get_query_template('archive');
    1938 }
    1939 
    1940 function get_author_template() {
    1941     return get_query_template('author');
    1942 }
    1943 
    1944 function get_category_template() {
    1945     $template = '';
    1946     if ( file_exists(TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php') )
    1947         $template = TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php';
    1948     else if ( file_exists(TEMPLATEPATH . "/category.php") )
    1949         $template = TEMPLATEPATH . "/category.php";
    1950 
    1951     return apply_filters('category_template', $template);
    1952 }
    1953 
    1954 function get_date_template() {
    1955     return get_query_template('date');
    1956 }
    1957 
    1958 function get_home_template() {
    1959     $template = '';
    1960 
    1961     if ( file_exists(TEMPLATEPATH . "/home.php") )
    1962         $template = TEMPLATEPATH . "/home.php";
    1963     else if ( file_exists(TEMPLATEPATH . "/index.php") )
    1964         $template = TEMPLATEPATH . "/index.php";
    1965 
    1966     return apply_filters('home_template', $template);
    1967 }
    1968 
    1969 function get_page_template() {
    1970     global $wp_query;
    1971 
    1972     $id = $wp_query->post->ID;
    1973     $template = get_post_meta($id, '_wp_page_template', true);
    1974 
    1975     if ( 'default' == $template )
    1976         $template = '';
    1977 
    1978     if ( ! empty($template) && file_exists(TEMPLATEPATH . "/$template") )
    1979         $template = TEMPLATEPATH . "/$template";
    1980     else if ( file_exists(TEMPLATEPATH . "/page.php") )
    1981         $template = TEMPLATEPATH . "/page.php";
    1982     else
    1983         $template = '';
    1984 
    1985     return apply_filters('page_template', $template);
    1986 }
    1987 
    1988 function get_paged_template() {
    1989     return get_query_template('paged');
    1990 }
    1991 
    1992 function get_search_template() {
    1993     return get_query_template('search');
    1994 }
    1995 
    1996 function get_single_template() {
    1997     return get_query_template('single');
    1998 }
    1999 
    2000 function get_attachment_template() {
    2001     global $posts;
    2002     $type = explode('/', $posts[0]->post_mime_type);
    2003     if ( $template = get_query_template($type[0]) )
    2004         return $template;
    2005     elseif ( $template = get_query_template($type[1]) )
    2006         return $template;
    2007     elseif ( $template = get_query_template("$type[0]_$type[1]") )
    2008         return $template;
    2009     else
    2010         return get_query_template('attachment');
    2011 }
    2012 
    2013 function get_comments_popup_template() {
    2014     if ( file_exists( TEMPLATEPATH . '/comments-popup.php') )
    2015         $template = TEMPLATEPATH . '/comments-popup.php';
    2016     else
    2017         $template = get_theme_root() . '/default/comments-popup.php';
    2018 
    2019     return apply_filters('comments_popup_template', $template);
    2020 }
    2021 
    2022 // Borrowed from the PHP Manual user notes. Convert entities, while
    2023 // preserving already-encoded entities:
    2024 function htmlentities2($myHTML) {
    2025     $translation_table=get_html_translation_table (HTML_ENTITIES,ENT_QUOTES);
    2026     $translation_table[chr(38)] = '&';
    2027     return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&amp;" , strtr($myHTML, $translation_table));
    2028 }
    2029 
    2030 
    2031 function is_plugin_page() {
    2032     global $plugin_page;
    2033 
    2034     if ( isset($plugin_page) )
    2035         return true;
    2036 
    2037     return false;
    2038606}
    2039607
     
    2051619    $ret = '';
    2052620    if ( is_array(func_get_arg(0)) ) {
    2053         if ( @func_num_args() < 2 )
     621        if ( @func_num_args() < 2 || '' == @func_get_arg(1) )
    2054622            $uri = $_SERVER['REQUEST_URI'];
    2055623        else
    2056624            $uri = @func_get_arg(1);
    2057625    } else {
    2058         if ( @func_num_args() < 3 )
     626        if ( @func_num_args() < 3 || '' == @func_get_arg(2) )
    2059627            $uri = $_SERVER['REQUEST_URI'];
    2060628        else
    2061629            $uri = @func_get_arg(2);
     630    }
     631
     632    if ( $frag = strstr($uri, '#') )
     633        $uri = substr($uri, 0, -strlen($frag));
     634    else
     635        $frag = '';
     636
     637    if ( preg_match('|^https?://|i', $uri, $matches) ) {
     638        $protocol = $matches[0];
     639        $uri = substr($uri, strlen($protocol));
     640    } else {
     641        $protocol = '';
    2062642    }
    2063643
     
    2071651            $query = $parts[1];
    2072652        }
    2073     }
    2074     else if ( strstr($uri, '/') ) {
     653    } else if ( !empty($protocol) || strstr($uri, '/') ) {
    2075654        $base = $uri . '?';
    2076655        $query = '';
     
    2095674        }
    2096675    }
    2097     $ret = $base . $ret;
     676    $ret = $protocol . $base . $ret . $frag;
     677    if ( get_magic_quotes_gpc() )
     678        $ret = stripslashes($ret); // parse_str() adds slashes if magicquotes is on.  See: http://php.net/parse_str
    2098679    return trim($ret, '?');
    2099680}
    2100681
    2101 function remove_query_arg($key, $query) {
     682/*
     683remove_query_arg: Returns a modified querystring by removing
     684a single key or an array of keys.
     685Omitting oldquery_or_uri uses the $_SERVER value.
     686
     687Parameters:
     688remove_query_arg(removekey, [oldquery_or_uri]) or
     689remove_query_arg(removekeyarray, [oldquery_or_uri])
     690*/
     691
     692function remove_query_arg($key, $query='') {
     693    if ( is_array($key) ) { // removing multiple keys
     694        foreach ( (array) $key as $k )
     695            $query = add_query_arg($k, '', $query);
     696        return $query;
     697    }
    2102698    return add_query_arg($key, '', $query);
    2103 }
    2104 
    2105 function load_template($file) {
    2106     global $posts, $post, $wp_did_header, $wp_did_template_redirect, $wp_query,
    2107         $wp_rewrite, $wpdb;
    2108 
    2109     extract($wp_query->query_vars);
    2110 
    2111     require_once($file);
    2112699}
    2113700
     
    2150737function wp($query_vars = '') {
    2151738    global $wp;
    2152    
     739
    2153740    $wp->main($query_vars);
    2154741}
     
    2179766}
    2180767
    2181 function get_usermeta( $user_id, $meta_key = '') {
    2182     global $wpdb;
    2183     $user_id = (int) $user_id;
    2184 
    2185     if ( !empty($meta_key) ) {
    2186         $meta_key = preg_replace('|a-z0-9_|i', '', $meta_key);
    2187         $metas = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
    2188     } else {
    2189         $metas = $wpdb->get_results("SELECT meta_key, meta_value FROM $wpdb->usermeta WHERE user_id = '$user_id'");
    2190     }
    2191 
    2192     if ( empty($metas) ) {
    2193         if ( empty($meta_key) )
    2194             return array();
    2195         else
    2196             return '';
    2197     }
    2198 
    2199     foreach ($metas as $index => $meta) {
    2200         @ $value = unserialize($meta->meta_value);
    2201         if ( $value === FALSE )
    2202             $value = $meta->meta_value;
    2203 
    2204         $values[] = $value;
    2205     }
    2206 
    2207     if ( count($values) == 1 )
    2208         return $values[0];
    2209     else
    2210         return $values;
    2211 }
    2212 
    2213 function update_usermeta( $user_id, $meta_key, $meta_value ) {
    2214     global $wpdb;
    2215     if ( !is_numeric( $user_id ) )
    2216         return false;
    2217     $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
    2218 
    2219     if ( is_array($meta_value) || is_object($meta_value) )
    2220         $meta_value = serialize($meta_value);
    2221     $meta_value = trim( $meta_value );
    2222    
    2223     if (empty($meta_value)) {
    2224         delete_usermeta($user_id, $meta_key);
    2225     }
    2226 
    2227     $cur = $wpdb->get_row("SELECT * FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
    2228     if ( !$cur ) {
    2229         $wpdb->query("INSERT INTO $wpdb->usermeta ( user_id, meta_key, meta_value )
    2230         VALUES
    2231         ( '$user_id', '$meta_key', '$meta_value' )");
    2232     } else if ( $cur->meta_value != $meta_value ) {
    2233         $wpdb->query("UPDATE $wpdb->usermeta SET meta_value = '$meta_value' WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
    2234     } else {
    2235         return false;   
    2236     }
    2237    
    2238     $user = get_userdata($user_id);
    2239     wp_cache_delete($user_id, 'users');
    2240     wp_cache_delete($user->user_login, 'userlogins');
    2241    
    2242     return true;
    2243 }
    2244 
    2245 function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) {
    2246     global $wpdb;
    2247     if ( !is_numeric( $user_id ) )
    2248         return false;
    2249     $meta_key = preg_replace('|[^a-z0-9_]|i', '', $meta_key);
    2250 
    2251     if ( is_array($meta_value) || is_object($meta_value) )
    2252         $meta_value = serialize($meta_value);
    2253     $meta_value = trim( $meta_value );
    2254 
    2255     if ( ! empty($meta_value) )
    2256         $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key' AND meta_value = '$meta_value'");
    2257     else
    2258         $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$user_id' AND meta_key = '$meta_key'");
    2259        
    2260     $user = get_userdata($user_id);
    2261     wp_cache_delete($user_id, 'users');
    2262     wp_cache_delete($user->user_login, 'userlogins');
    2263    
    2264     return true;
    2265 }
    2266 
    2267 function register_activation_hook($file, $function) {
    2268     $file = plugin_basename($file);
    2269 
    2270     add_action('activate_' . $file, $function);
    2271 }
    2272 
    2273 function register_deactivation_hook($file, $function) {
    2274     $file = plugin_basename($file);
    2275 
    2276     add_action('deactivate_' . $file, $function);
    2277 }
    2278 
    2279 function plugin_basename($file) {
    2280     $file = preg_replace('|\\\\+|', '\\\\', $file);
    2281     $file = preg_replace('/^.*wp-content[\\\\\/]plugins[\\\\\/]/', '', $file);
    2282     return $file;
     768function cache_javascript_headers() {
     769    $expiresOffset = 864000; // 10 days
     770    header("Content-type: text/javascript; charset=" . get_bloginfo('charset'));
     771    header("Vary: Accept-Encoding"); // Handle proxies
     772    header("Expires: " . gmdate("D, d M Y H:i:s", time() + $expiresOffset) . " GMT");
    2283773}
    2284774
     
    2288778}
    2289779
     780function bool_from_yn($yn) {
     781    if ($yn == 'Y') return 1;
     782    return 0;
     783}
     784
     785function do_feed() {
     786    $feed = get_query_var('feed');
     787
     788    // Remove the pad, if present.
     789    $feed = preg_replace('/^_+/', '', $feed);
     790
     791    if ($feed == '' || $feed == 'feed')
     792        $feed = 'rss2';
     793
     794    $for_comments = false;
     795    if ( is_singular() || get_query_var('withcomments') == 1 || $feed == 'comments-rss2' ) {
     796        $feed = 'rss2';
     797        $for_comments = true;   
     798    }
     799
     800    $hook = 'do_feed_' . $feed;
     801    do_action($hook, $for_comments);
     802}
     803
     804function do_feed_rdf() {
     805    load_template(ABSPATH . 'wp-rdf.php');
     806}
     807
     808function do_feed_rss() {
     809    load_template(ABSPATH . 'wp-rss.php');
     810}
     811
     812function do_feed_rss2($for_comments) {
     813    if ( $for_comments ) {
     814        load_template(ABSPATH . 'wp-commentsrss2.php');
     815    } else {
     816        load_template(ABSPATH . 'wp-rss2.php');
     817    }
     818}
     819
     820function do_feed_atom() {
     821    load_template(ABSPATH . 'wp-atom.php');
     822}
     823
     824function do_robots() {
     825    do_action('do_robotstxt');
     826    if ( '0' == get_option('blog_public') ) {
     827        echo "User-agent: *\n";
     828        echo "Disallow: /\n";
     829    } else {
     830        echo "User-agent: *\n";
     831        echo "Disallow:\n";
     832    }
     833}
     834
     835function is_blog_installed() {
     836    global $wpdb;
     837    $wpdb->hide_errors();
     838    $installed = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'");
     839    $wpdb->show_errors();
     840    return $installed;
     841}
     842
     843function wp_nonce_url($actionurl, $action = -1) {
     844    return wp_specialchars(add_query_arg('_wpnonce', wp_create_nonce($action), $actionurl));
     845}
     846
     847function wp_nonce_field($action = -1) {
     848    echo '<input type="hidden" name="_wpnonce" value="' . wp_create_nonce($action) . '" />';
     849    wp_referer_field();
     850}
     851
     852function wp_referer_field() {
     853    $ref = wp_specialchars($_SERVER['REQUEST_URI']);
     854    echo '<input type="hidden" name="_wp_http_referer" value="'. $ref . '" />';
     855    if ( wp_get_original_referer() ) {
     856        $original_ref = wp_specialchars(stripslashes(wp_get_original_referer()));
     857        echo '<input type="hidden" name="_wp_original_http_referer" value="'. $original_ref . '" />';
     858    }
     859}
     860
     861function wp_original_referer_field() {
     862    echo '<input type="hidden" name="_wp_original_http_referer" value="' . wp_specialchars(stripslashes($_SERVER['REQUEST_URI'])) . '" />';
     863}
     864
     865function wp_get_referer() {
     866    foreach ( array($_REQUEST['_wp_http_referer'], $_SERVER['HTTP_REFERER']) as $ref )
     867        if ( !empty($ref) )
     868            return $ref;
     869    return false;
     870}
     871
     872function wp_get_original_referer() {
     873    if ( !empty($_REQUEST['_wp_original_http_referer']) )
     874        return $_REQUEST['_wp_original_http_referer'];
     875    return false;
     876}
     877
     878function wp_mkdir_p($target) {
     879    // from php.net/mkdir user contributed notes
     880    if (file_exists($target)) {
     881        if (! @ is_dir($target))
     882            return false;
     883        else
     884            return true;
     885    }
     886
     887    // Attempting to create the directory may clutter up our display.
     888    if (@ mkdir($target)) {
     889        $stat = @ stat(dirname($target));
     890        $dir_perms = $stat['mode'] & 0007777;  // Get the permission bits.
     891        @ chmod($target, $dir_perms);
     892        return true;
     893    } else {
     894        if ( is_dir(dirname($target)) )
     895            return false;
     896    }
     897
     898    // If the above failed, attempt to create the parent node, then try again.
     899    if (wp_mkdir_p(dirname($target)))
     900        return wp_mkdir_p($target);
     901
     902    return false;
     903}
     904
     905// Returns an array containing the current upload directory's path and url, or an error message.
     906function wp_upload_dir() {
     907    $siteurl = get_option('siteurl');
     908    //prepend ABSPATH to $dir and $siteurl to $url if they're not already there
     909    $path = str_replace(ABSPATH, '', trim(get_option('upload_path')));
     910    $dir = ABSPATH . $path;
     911    $url = trailingslashit($siteurl) . $path;
     912
     913    if ( $dir == ABSPATH ) { //the option was empty
     914        $dir = ABSPATH . 'wp-content/uploads';
     915    }
     916
     917    if ( defined('UPLOADS') ) {
     918        $dir = ABSPATH . UPLOADS;
     919        $url = trailingslashit($siteurl) . UPLOADS;
     920    }
     921
     922    if ( get_option('uploads_use_yearmonth_folders')) {
     923        // Generate the yearly and monthly dirs
     924        $time = current_time( 'mysql' );
     925        $y = substr( $time, 0, 4 );
     926        $m = substr( $time, 5, 2 );
     927        $dir = $dir . "/$y/$m";
     928        $url = $url . "/$y/$m";
     929    }
     930
     931    // Make sure we have an uploads dir
     932    if ( ! wp_mkdir_p( $dir ) ) {
     933        $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), $dir);
     934        return array('error' => $message);
     935    }
     936
     937    $uploads = array('path' => $dir, 'url' => $url, 'error' => false);
     938    return apply_filters('upload_dir', $uploads);
     939}
     940
     941function wp_upload_bits($name, $type, $bits) {
     942    if ( empty($name) )
     943        return array('error' => __("Empty filename"));
     944
     945    $wp_filetype = wp_check_filetype($name);
     946    if ( !$wp_filetype['ext'] )
     947        return array('error' => __("Invalid file type"));
     948
     949    $upload = wp_upload_dir();
     950
     951    if ( $upload['error'] !== false )
     952        return $upload;
     953
     954    $number = '';
     955    $filename = $name;
     956    $path_parts = pathinfo($filename);
     957    $ext = $path_parts['extension'];
     958    if ( empty($ext) )
     959        $ext = '';
     960    else
     961        $ext = ".$ext";
     962    while ( file_exists($upload['path'] . "/$filename") ) {
     963        if ( '' == "$number$ext" )
     964            $filename = $filename . ++$number . $ext;
     965        else
     966            $filename = str_replace("$number$ext", ++$number . $ext, $filename);
     967    }
     968
     969    $new_file = $upload['path'] . "/$filename";
     970    if ( ! wp_mkdir_p( dirname($new_file) ) ) {
     971        $message = sprintf(__('Unable to create directory %s. Is its parent directory writable by the server?'), dirname($new_file));
     972        return array('error' => $message);
     973    }
     974
     975    $ifp = @ fopen($new_file, 'wb');
     976    if ( ! $ifp )
     977        return array('error' => sprintf(__('Could not write file %s'), $new_file));
     978
     979    $success = @ fwrite($ifp, $bits);
     980    fclose($ifp);
     981    // Set correct file permissions
     982    $stat = @ stat(dirname($new_file));
     983    $perms = $stat['mode'] & 0007777;
     984    $perms = $perms & 0000666;
     985    @ chmod($new_file, $perms);
     986
     987    // Compute the URL
     988    $url = $upload['url'] . "/$filename";
     989
     990    return array('file' => $new_file, 'url' => $url, 'error' => false);
     991}
     992
     993function wp_check_filetype($filename, $mimes = null) {
     994    // Accepted MIME types are set here as PCRE unless provided.
     995    $mimes = is_array($mimes) ? $mimes : apply_filters('upload_mimes', array (
     996        'jpg|jpeg|jpe' => 'image/jpeg',
     997        'gif' => 'image/gif',
     998        'png' => 'image/png',
     999        'bmp' => 'image/bmp',
     1000        'tif|tiff' => 'image/tiff',
     1001        'ico' => 'image/x-icon',
     1002        'asf|asx|wax|wmv|wmx' => 'video/asf',
     1003        'avi' => 'video/avi',
     1004        'mov|qt' => 'video/quicktime',
     1005        'mpeg|mpg|mpe' => 'video/mpeg',
     1006        'txt|c|cc|h' => 'text/plain',
     1007        'rtx' => 'text/richtext',
     1008        'css' => 'text/css',
     1009        'htm|html' => 'text/html',
     1010        'mp3|mp4' => 'audio/mpeg',
     1011        'ra|ram' => 'audio/x-realaudio',
     1012        'wav' => 'audio/wav',
     1013        'ogg' => 'audio/ogg',
     1014        'mid|midi' => 'audio/midi',
     1015        'wma' => 'audio/wma',
     1016        'rtf' => 'application/rtf',
     1017        'js' => 'application/javascript',
     1018        'pdf' => 'application/pdf',
     1019        'doc' => 'application/msword',
     1020        'pot|pps|ppt' => 'application/vnd.ms-powerpoint',
     1021        'wri' => 'application/vnd.ms-write',
     1022        'xla|xls|xlt|xlw' => 'application/vnd.ms-excel',
     1023        'mdb' => 'application/vnd.ms-access',
     1024        'mpp' => 'application/vnd.ms-project',
     1025        'swf' => 'application/x-shockwave-flash',
     1026        'class' => 'application/java',
     1027        'tar' => 'application/x-tar',
     1028        'zip' => 'application/zip',
     1029        'gz|gzip' => 'application/x-gzip',
     1030        'exe' => 'application/x-msdownload'
     1031    ));
     1032
     1033    $type = false;
     1034    $ext = false;
     1035
     1036    foreach ($mimes as $ext_preg => $mime_match) {
     1037        $ext_preg = '!\.(' . $ext_preg . ')$!i';
     1038        if ( preg_match($ext_preg, $filename, $ext_matches) ) {
     1039            $type = $mime_match;
     1040            $ext = $ext_matches[1];
     1041            break;
     1042        }
     1043    }
     1044
     1045    return compact('ext', 'type');
     1046}
     1047
     1048function wp_explain_nonce($action) {
     1049    if ( $action !== -1 && preg_match('/([a-z]+)-([a-z]+)(_(.+))?/', $action, $matches) ) {
     1050        $verb = $matches[1];
     1051        $noun = $matches[2];
     1052
     1053        $trans = array();
     1054        $trans['update']['attachment'] = array(__('Are you sure you want to edit this attachment: &quot;%s&quot;?'), 'get_the_title');
     1055
     1056        $trans['add']['category'] = array(__('Are you sure you want to add this category?'), false);
     1057        $trans['delete']['category'] = array(__('Are you sure you want to delete this category: &quot;%s&quot;?'), 'get_catname');
     1058        $trans['update']['category'] = array(__('Are you sure you want to edit this category: &quot;%s&quot;?'), 'get_catname');
     1059
     1060        $trans['delete']['comment'] = array(__('Are you sure you want to delete this comment: &quot;%s&quot;?'), 'use_id');
     1061        $trans['unapprove']['comment'] = array(__('Are you sure you want to unapprove this comment: &quot;%s&quot;?'), 'use_id');
     1062        $trans['approve']['comment'] = array(__('Are you sure you want to approve this comment: &quot;%s&quot;?'), 'use_id');
     1063        $trans['update']['comment'] = array(__('Are you sure you want to edit this comment: &quot;%s&quot;?'), 'use_id');
     1064        $trans['bulk']['comments'] = array(__('Are you sure you want to bulk modify comments?'), false);
     1065        $trans['moderate']['comments'] = array(__('Are you sure you want to moderate comments?'), false);
     1066
     1067        $trans['add']['bookmark'] = array(__('Are you sure you want to add this bookmark?'), false);
     1068        $trans['delete']['bookmark'] = array(__('Are you sure you want to delete this bookmark: &quot;%s&quot;?'), 'use_id');
     1069        $trans['update']['bookmark'] = array(__('Are you sure you want to edit this bookmark: &quot;%s&quot;?'), 'use_id');
     1070        $trans['bulk']['bookmarks'] = array(__('Are you sure you want to bulk modify bookmarks?'), false);
     1071
     1072        $trans['add']['page'] = array(__('Are you sure you want to add this page?'), false);
     1073        $trans['delete']['page'] = array(__('Are you sure you want to delete this page: &quot;%s&quot;?'), 'get_the_title');
     1074        $trans['update']['page'] = array(__('Are you sure you want to edit this page: &quot;%s&quot;?'), 'get_the_title');
     1075
     1076        $trans['edit']['plugin'] = array(__('Are you sure you want to edit this plugin file: &quot;%s&quot;?'), 'use_id');
     1077        $trans['activate']['plugin'] = array(__('Are you sure you want to activate this plugin: &quot;%s&quot;?'), 'use_id');
     1078        $trans['deactivate']['plugin'] = array(__('Are you sure you want to deactivate this plugin: &quot;%s&quot;?'), 'use_id');
     1079
     1080        $trans['add']['post'] = array(__('Are you sure you want to add this post?'), false);
     1081        $trans['delete']['post'] = array(__('Are you sure you want to delete this post: &quot;%s&quot;?'), 'get_the_title');
     1082        $trans['update']['post'] = array(__('Are you sure you want to edit this post: &quot;%s&quot;?'), 'get_the_title');
     1083
     1084        $trans['add']['user'] = array(__('Are you sure you want to add this user?'), false);
     1085        $trans['delete']['users'] = array(__('Are you sure you want to delete users?'), false);
     1086        $trans['bulk']['users'] = array(__('Are you sure you want to bulk modify users?'), false);
     1087        $trans['update']['user'] = array(__('Are you sure you want to edit this user: &quot;%s&quot;?'), 'get_author_name');
     1088        $trans['update']['profile'] = array(__('Are you sure you want to modify the profile for: &quot;%s&quot;?'), 'get_author_name');
     1089
     1090        $trans['update']['options'] = array(__('Are you sure you want to edit your settings?'), false);
     1091        $trans['update']['permalink'] = array(__('Are you sure you want to change your permalink structure to: %s?'), 'use_id');
     1092        $trans['edit']['file'] = array(__('Are you sure you want to edit this file: &quot;%s&quot;?'), 'use_id');
     1093        $trans['edit']['theme'] = array(__('Are you sure you want to edit this theme file: &quot;%s&quot;?'), 'use_id');
     1094        $trans['switch']['theme'] = array(__('Are you sure you want to switch to this theme: &quot;%s&quot;?'), 'use_id');
     1095
     1096        if ( isset($trans[$verb][$noun]) ) {
     1097            if ( !empty($trans[$verb][$noun][1]) ) {
     1098                $lookup = $trans[$verb][$noun][1];
     1099                $object = $matches[4];
     1100                if ( 'use_id' != $lookup )
     1101                    $object = call_user_func($lookup, $object);
     1102                return sprintf($trans[$verb][$noun][0], $object);
     1103            } else {
     1104                return $trans[$verb][$noun][0];
     1105            }
     1106        }
     1107    }
     1108
     1109    return apply_filters( 'explain_nonce_' . $verb . '-' . $noun, __('Are you sure you want to do this?'), $matches[4] );
     1110}
     1111
     1112function wp_nonce_ays($action) {
     1113    global $pagenow, $menu, $submenu, $parent_file, $submenu_file;
     1114
     1115    $adminurl = get_option('siteurl') . '/wp-admin';
     1116    if ( wp_get_referer() )
     1117        $adminurl = wp_get_referer();
     1118
     1119    $title = __('WordPress Confirmation');
     1120    // Remove extra layer of slashes.
     1121    $_POST   = stripslashes_deep($_POST  );
     1122    if ( $_POST ) {
     1123        $q = http_build_query($_POST);
     1124        $q = explode( ini_get('arg_separator.output'), $q);
     1125        $html .= "\t<form method='post' action='$pagenow'>\n";
     1126        foreach ( (array) $q as $a ) {
     1127            $v = substr(strstr($a, '='), 1);
     1128            $k = substr($a, 0, -(strlen($v)+1));
     1129            $html .= "\t\t<input type='hidden' name='" . wp_specialchars( urldecode($k), 1 ) . "' value='" . wp_specialchars( urldecode($v), 1 ) . "' />\n";
     1130        }
     1131        $html .= "\t\t<input type='hidden' name='_wpnonce' value='" . wp_create_nonce($action) . "' />\n";
     1132        $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";
     1133    } else {
     1134        $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";
     1135    }
     1136    $html .= "</body>\n</html>";
     1137    wp_die($html, $title);
     1138}
     1139
     1140function wp_die($message, $title = '') {
     1141    global $wp_locale;
     1142
     1143    header('Content-Type: text/html; charset=utf-8');
     1144
     1145    if ( empty($title) )
     1146        $title = __('WordPress &rsaquo; Error');
     1147
     1148    if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') )
     1149        $admin_dir = '';
     1150    else
     1151        $admin_dir = 'wp-admin/';
     1152
    22901153?>
     1154<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     1155<html xmlns="http://www.w3.org/1999/xhtml" <?php if ( function_exists('language_attributes') ) language_attributes(); ?>>
     1156<head>
     1157    <title><?php echo $title ?></title>
     1158    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     1159    <link rel="stylesheet" href="<?php echo $admin_dir; ?>install.css" type="text/css" />
     1160<?php if ( ('rtl' == $wp_locale->text_direction) ) : ?>
     1161    <link rel="stylesheet" href="<?php echo $admin_dir; ?>install-rtl.css" type="text/css" />
     1162<?php endif; ?>
     1163</head>
     1164<body>
     1165    <h1 id="logo"><img alt="WordPress" src="<?php echo $admin_dir; ?>images/wordpress-logo.png" /></h1>
     1166    <p><?php echo $message; ?></p>
     1167</body>
     1168</html>
     1169<?php
     1170
     1171    die();
     1172}
     1173
     1174function _mce_set_direction() {
     1175    global $wp_locale;
     1176
     1177    if ('rtl' == $wp_locale->text_direction) {
     1178        echo 'directionality : "rtl" ,';
     1179        echo 'theme_advanced_toolbar_align : "right" ,';
     1180    }
     1181}
     1182
     1183function _mce_load_rtl_plugin($input) {
     1184    global $wp_locale;
     1185
     1186    if ('rtl' == $wp_locale->text_direction)
     1187        $input[] = 'directionality';
     1188
     1189    return $input;
     1190}
     1191
     1192function _mce_add_direction_buttons($input) {
     1193    global $wp_locale;
     1194
     1195    if ('rtl' == $wp_locale->text_direction) {
     1196        $new_buttons = array('separator', 'ltr', 'rtl');
     1197        $input = array_merge($input, $new_buttons);
     1198    }
     1199
     1200    return $input;
     1201}
     1202
     1203?>
  • trunk/wp-includes/gettext.php

    r3503 r4431  
    6262   */
    6363  function readint() {
    64       $stream = $this->STREAM->read(4);
    6564      if ($this->BYTEORDER == 0) {
    6665        // low endian
    67         $unpacked = unpack('V',$stream);
    68         return array_shift($unpacked);
     66        return array_shift(unpack('V', $this->STREAM->read(4)));
    6967      } else {
    7068        // big endian
    71         $unpacked = unpack('N',$stream);
    72         return array_shift($unpacked);
     69        return array_shift(unpack('N', $this->STREAM->read(4)));
    7370      }
    7471    }
     
    9895  function gettext_reader($Reader, $enable_cache = true) {
    9996    // If there isn't a StreamReader, turn on short circuit mode.
    100     if (! $Reader) {
     97    if (! $Reader || isset($Reader->error) ) {
    10198      $this->short_circuit = true;
    10299      return;
     
    106103    $this->enable_cache = $enable_cache;
    107104
    108     // $MAGIC1 = (int)0x950412de; //bug in PHP 5
     105    // $MAGIC1 = (int)0x950412de; //bug in PHP 5.0.2, see https://savannah.nongnu.org/bugs/?func=detailitem&item_id=10565
    109106    $MAGIC1 = (int) - 1794895138;
    110107    // $MAGIC2 = (int)0xde120495; //bug
     
    113110    $this->STREAM = $Reader;
    114111    $magic = $this->readint();
    115     if ($magic == $MAGIC1) {
     112    if ($magic == ($MAGIC1 & 0xFFFFFFFF)) { // to make sure it works for 64-bit platforms
    116113      $this->BYTEORDER = 0;
    117     } elseif ($magic == $MAGIC2) {
     114    } elseif ($magic == ($MAGIC2 & 0xFFFFFFFF)) {
    118115      $this->BYTEORDER = 1;
    119116    } else {
     
    283280        $header = $this->get_translation_string(0);
    284281      }
    285       if (eregi("plural-forms: (.*)\n", $header, $regs))
     282      if (eregi("plural-forms: ([^\n]*)\n", $header, $regs))
    286283        $expr = $regs[1];
    287284      else
     
    309306
    310307    eval("$string");
    311     if ($plural >= $total) $plural = 0;
     308    if ($plural >= $total) $plural = $total - 1;
    312309    return $plural;
    313310  }
  • trunk/wp-includes/js/colorpicker.js

    r3503 r4431  
    140140function AnchorPosition_getWindowOffsetLeft (el) {
    141141    return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft;
    142     }   
     142    }
    143143function AnchorPosition_getPageOffsetTop (el) {
    144144    var ot=el.offsetTop;
     
    435435    this.visible = false;
    436436    this.autoHideEnabled = false;
    437    
     437
    438438    this.contents = "";
    439439    this.url="";
     
    557557    this.show(linkname);
    558558    }
    559    
     559
    560560// This function runs when you move your mouse over a color block, if you have a newer browser
    561561function ColorPicker_highlightColor(c) {
     
    580580        var divname = arguments[0];
    581581        }
    582    
     582
    583583    if (divname != "") {
    584584        var cp = new PopupWindow(divname);
     
    591591    // Object variables
    592592    cp.currentValue = "#FFFFFF";
    593    
     593
    594594    // Method Mappings
    595595    cp.writeDiv = ColorPicker_writeDiv;
  • trunk/wp-includes/js/dbx.js

    r3503 r4431  
    1 // DBX2.01 :: Docking Boxes (dbx)
     1// DBX2.05 :: Docking Boxes (dbx)
    22// *****************************************************
    33// DOM scripting by brothercake -- http://www.brothercake.com/
    44// GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html
    55//******************************************************
    6 var dbx;function dbxManager(sid){dbx = this;if(!/^[-_a-z0-9]+$/i.test(sid)) { alert('Error from dbxManager:\n"' + sid + '" is an invalid session ID'); return; }this.supported = !(document.getElementsByTagName('*').length == 0 || (navigator.vendor == 'KDE' && typeof window.sidebar == 'undefined'));if(!this.supported) { return; }this.etype = typeof document.addEventListener != 'undefined' ? 'addEventListener' : typeof document.attachEvent != 'undefined' ? 'attachEvent' : 'none';this.eprefix = (this.etype == 'attachEvent' ? 'on' : '');if(typeof window.opera != 'undefined' && parseFloat(navigator.userAgent.toLowerCase().split(/opera[\/ ]/)[1].split(' ')[0], 10) < 7.5){this.etype = 'none';}if(this.etype == 'none') { this.supported = false; return; }this.running = 0;this.sid = sid;this.savedata = {};this.cookiestate = this.getCookieState();};dbxManager.prototype.setCookieState = function(){var now = new Date();now.setTime(now.getTime() + (365*24*60*60*1000));var str = '';for(j in this.savedata){if(typeof this.savedata[j]!='function'){str += j + '=' + this.savedata[j] + '&'}}this.state = str.replace(/^(.+)&$/, '$1');if(typeof this.onstatechange == 'undefined' || this.onstatechange()){document.cookie = 'dbx-' + this.sid + '='+ this.state+ '; expires=' + now.toGMTString()+ '; path=/';}};dbxManager.prototype.getCookieState = function(){this.cookiestate = null;if(document.cookie){if(document.cookie.indexOf('dbx-' + this.sid)!=-1){this.cookie = document.cookie.split('dbx-' + this.sid + '=')[1].split('&');for(var i in this.cookie){if(typeof this.cookie[i]!='function'){this.cookie[i] = this.cookie[i].split('=');this.cookie[i][1] = this.cookie[i][1].split(',');}}this.cookiestate = {};for(i in this.cookie){if(typeof this.cookie[i]!='function'){this.cookiestate[this.cookie[i][0]] = this.cookie[i][1];}}}}return this.cookiestate;};dbxManager.prototype.addDataMember = function(gid, order){this.savedata[gid] = order;};dbxManager.prototype.createElement = function(tag){return typeof document.createElementNS != 'undefined' ? document.createElementNS('http://www.w3.org/1999/xhtml', tag) : document.createElement(tag);};dbxManager.prototype.getTarget = function(e, pattern, node){if(typeof node != 'undefined'){var target = node;}else{target = typeof e.target != 'undefined' ? e.target : e.srcElement;}var regex = new RegExp(pattern, '');while(!regex.test(target.className)){target = target.parentNode;}return target;};function dbxGroup(gid, dir, thresh, fix, ani, togs, def, open, close, move, toggle, kmove, ktoggle, syntax){if(!/^[-_a-z0-9]+$/i.test(gid)) { alert('Error from dbxGroup:\n"' + gid + '" is an invalid container ID'); return; }this.container = document.getElementById(gid);if(this.container == null || !dbx.supported) { return; }var self = this;this.gid = gid;this.dragok = false;this.box = null;this.vertical = dir == 'vertical';this.threshold = parseInt(thresh, 10);this.restrict = fix == 'yes';this.resolution = parseInt(ani, 10);this.toggles = togs == 'yes';this.defopen = def != 'closed';this.vocab = {'open' : open,'close' : close,'move' : move,'toggle' : toggle,'kmove' : kmove,'ktoggle' : ktoggle,'syntax' : syntax};this.container.style.position = 'relative';this.container.style.display = 'block';if(typeof window.opera != 'undefined'){this.container.style.display = 'run-in';}this.boxes = [];this.buttons = [];this.order = [];this.eles = this.container.getElementsByTagName('*');for(var i=0; i<this.eles.length; i++){if(/dbx\-box/i.test(this.eles[i].className) && !/dbx\-dummy/i.test(this.eles[i].className)){this.eles[i].style.position = 'relative';this.eles[i].style.display = 'block';this.boxes.push(this.eles[i]);this.eles[i].className += ' dbx-box-open';this.eles[i].className += ' dbxid' + this.order.length;this.order.push(this.order.length.toString() + '+');this.eles[i][dbx.etype](dbx.eprefix + 'mousedown', function(e){if(!e) { e = window.event; }self.mousedown(e, dbx.getTarget(e, 'dbx\-box'));}, false);}if(/dbx\-handle/i.test(this.eles[i].className)){this.eles[i].style.position = 'relative';this.eles[i].style.display = 'block';this.eles[i].className += ' dbx-handle-cursor';this.eles[i].setAttribute('title', this.eles[i].getAttribute('title') == null || this.eles[i].title == '' ? this.vocab.move : this.vocab.syntax.replace('%mytitle%', this.eles[i].title).replace('%dbxtitle%', this.vocab.move));if(this.toggles){this.buttons.push(this.addToggleBehavior(this.eles[i]));}else{this.eles[i][dbx.etype](dbx.eprefix + 'key' + (typeof document.uniqueID != 'undefined' || navigator.vendor == 'Apple Computer, Inc.' ? 'down' : 'press'), function(e){if(!e) { e = window.event; }return self.keypress(e, dbx.getTarget(e, 'dbx\-handle'));}, false);this.eles[i][dbx.etype](dbx.eprefix + 'focus', function(e){if(!e) { e = window.event; }self.createTooltip(null, dbx.getTarget(e, 'dbx\-handle'));}, false);this.eles[i][dbx.etype](dbx.eprefix + 'blur', function(){self.removeTooltip();}, false);}}}dbx.addDataMember(this.gid, this.order.join(','));var dummy = this.container.appendChild(dbx.createElement('span'));dummy.className = 'dbx-box dbx-dummy';dummy.style.display = 'block';dummy.style.width = '0';dummy.style.height = '0';dummy.style.overflow = 'hidden';if(this.vertical) { dummy.className += ' dbx-offdummy'; }this.boxes.push(dummy);if(dbx.cookiestate != null && typeof dbx.cookiestate[this.gid] != 'undefined'){var num = dbx.cookiestate[this.gid].length;if(num == this.boxes.length - 1){for(i=0; i<num; i++){var index = parseInt(dbx.cookiestate[this.gid][i], 10);this.container.insertBefore(this.boxes[index], dummy);if(this.toggles && dbx.cookiestate[this.gid][i].charAt(1) == '-'){this.toggleBoxState(this.buttons[index], false);}}this.getBoxOrder();}}else if(!this.defopen && this.toggles){var len = this.buttons.length;for(i=0; i<len; i++){this.toggleBoxState(this.buttons[i], true);}}document[dbx.etype](dbx.eprefix + 'mouseout', function(e){if(typeof e.target == 'undefined') { e = window.event; e.relatedTarget = e.toElement; }if(e.relatedTarget == null){self.mouseup(e);}}, false);document[dbx.etype](dbx.eprefix + 'mousemove', function(e){self.mousemove(e);}, false);document[dbx.etype](dbx.eprefix + 'mouseup', function(e){self.mouseup(e);}, false);this.keydown = false;document[dbx.etype](dbx.eprefix + 'keydown', function(){self.keydown = true;}, false);document[dbx.etype](dbx.eprefix + 'keyup', function(){self.keydown = false;}, false);};dbxGroup.prototype.addToggleBehavior = function(){var self = this;var button = arguments[0].appendChild(dbx.createElement('a'));button.appendChild(document.createTextNode('\u00a0'));button.style.cursor = 'pointer';button.href = 'javascript:void(null)';button.className = 'dbx-toggle dbx-toggle-open';button.setAttribute('title', this.vocab.toggle.replace('%toggle%', this.vocab.close));button.hasfocus = typeof window.opera != 'undefined' || navigator.vendor == 'Apple Computer, Inc.' ? null : false;this.tooltip = null;button.onclick = function(){if(this.hasfocus === true || this.hasfocus === null){self.removeTooltip();self.toggleBoxState(this, true);}};button['onkey' + (typeof document.uniqueID != 'undefined' || navigator.vendor == 'Apple Computer, Inc.' ? 'down' : 'press')] = function(e){if(!e) { e = window.event; }return self.keypress(e, this);};button.onfocus = function(){var len = self.buttons.length;for(var i=0; i<len; i++){self.buttons[i].className = self.buttons[i].className.replace(/[ ](dbx\-toggle\-hilite\-)(open|closed)/, '');}var isopen = (/dbx\-toggle\-open/.test(this.className));this.className += ' dbx-toggle-hilite-' + (isopen ? 'open' : 'closed');self.createTooltip(isopen, this);this.isactive = true;if(this.hasfocus !== null) { this.hasfocus = true; }};button.onblur = function(){this.className = this.className.replace(/[ ](dbx\-toggle\-hilite\-)(open|closed)/, '');self.removeTooltip();if(this.hasfocus !== null) { this.hasfocus = false; }};return button;};dbxGroup.prototype.toggleBoxState = function(button, regen){var isopen = (/dbx\-toggle\-open/.test(button.className));var parent = dbx.getTarget(null, 'dbx\-box', button);dbx.box = parent;dbx.toggle = button;if(typeof dbx.container == 'undefined'){dbx.group = dbx.getTarget(null, 'dbx\-group', parent);}else { dbx.group = dbx.container; }if((!isopen && (typeof dbx.onboxopen == 'undefined' || dbx.onboxopen()))||(isopen && (typeof dbx.onboxclose == 'undefined' || dbx.onboxclose()))){button.className = 'dbx-toggle dbx-toggle-' + (isopen ? 'closed' : 'open');button.title = this.vocab.toggle.replace('%toggle%', isopen ? this.vocab.open : this.vocab.close);if(typeof button.isactive != 'undefined'){button.className += ' dbx-toggle-hilite-' + (isopen ? 'closed' : 'open')}parent.className = parent.className.replace(/[ ](dbx-box-)(open|closed)/, ' $1' + (isopen ? 'closed' : 'open'));if(regen) { this.getBoxOrder(); }}};dbxGroup.prototype.shiftBoxPosition = function(e, anchor, positive){var parent = dbx.getTarget(null, 'dbx\-box', anchor);dbx.group = this.container;dbx.box = parent;dbx.event = e;if(typeof dbx.onboxdrag == 'undefined' || dbx.onboxdrag()){var positions = [];var len = this.boxes.length;for(var i=0; i<len; i++){positions[i] = [i, this.boxes[i][this.vertical ? 'offsetTop' : 'offsetLeft']];if(parent == this.boxes[i]) { this.idref = i; }}positions.sort(this.compare);for(i=0; i<len; i++){if(positions[i][0] == this.idref){if((positive && i < len - 2) || (!positive && i > 0)){var sibling = this.boxes[positions[i + (positive ? 1 : -1)][0]];if(this.resolution > 0){var visipos = { 'x' : parent.offsetLeft, 'y' : parent.offsetTop };var siblingpos = { 'x' : sibling.offsetLeft, 'y' : sibling.offsetTop };}var obj = { 'insert' : (positive ? sibling : parent), 'before' : (positive ? parent : sibling) };this.container.insertBefore(obj.insert, obj.before);if(this.resolution > 0){var animators ={'sibling' : new dbxAnimator(this, sibling, siblingpos, this.resolution, true, anchor),'parent' : new dbxAnimator(this, parent, visipos, this.resolution, true, anchor)};}else{anchor.focus();}break;}}}this.getBoxOrder();}};dbxGroup.prototype.compare = function(a, b){return a[1] - b[1];};dbxGroup.prototype.createTooltip = function(isopen, anchor){if(this.keydown){this.tooltip = this.container.appendChild(dbx.createElement('span'));this.tooltip.style.visibility = 'hidden';this.tooltip.className = 'dbx-tooltip';if(isopen != null){this.tooltip.appendChild(document.createTextNode(this.vocab.kmove + this.vocab.ktoggle.replace('%toggle%', isopen ? this.vocab.close : this.vocab.open)));}else{this.tooltip.appendChild(document.createTextNode(this.vocab.kmove));}var parent = dbx.getTarget(null, 'dbx\-box', anchor);this.tooltip.style.left = parent.offsetLeft + 'px';this.tooltip.style.top = parent.offsetTop + 'px';var tooltip = this.tooltip;window.setTimeout(function(){if(tooltip != null) { tooltip.style.visibility = 'visible'; }}, 500);}};dbxGroup.prototype.removeTooltip = function(){if(this.tooltip != null){this.tooltip.parentNode.removeChild(this.tooltip);this.tooltip = null;}};dbxGroup.prototype.mousedown = function(e, box){var node = typeof e.target != 'undefined' ? e.target : e.srcElement;if(node.nodeName == '#text') { node = node.parentNode; }if(!/dbx\-(toggle|box|group)/i.test(node.className)){while(!/dbx\-(handle|box|group)/i.test(node.className)){node = node.parentNode;}}if(/dbx\-handle/i.test(node.className)){this.removeTooltip();this.released = false;this.initial = { 'x' : e.clientX, 'y' : e.clientY };this.current = { 'x' : 0, 'y' : 0 };this.createCloneBox(box);if(typeof e.preventDefault != 'undefined' ) { e.preventDefault(); }if(typeof document.onselectstart != 'undefined'){document.onselectstart = function() { return false; }}}};dbxGroup.prototype.mousemove = function(e){if(this.dragok && this.box != null){this.positive = this.vertical ? (e.clientY > this.current.y ? true : false) : (e.clientX > this.current.x ? true : false);this.current = { 'x' : e.clientX, 'y' : e.clientY };var overall = { 'x' : this.current.x - this.initial.x, 'y' : this.current.y - this.initial.y };if(((overall.x >= 0 && overall.x <= this.threshold) || (overall.x <= 0 && overall.x >= 0 - this.threshold))&&((overall.y >= 0 && overall.y <= this.threshold) || (overall.y <= 0 && overall.y >= 0 - this.threshold))){this.current.x -= overall.x;this.current.y -= overall.y;}if(this.released || overall.x > this.threshold || overall.x < (0 - this.threshold) || overall.y > this.threshold || overall.y < (0 - this.threshold)){dbx.group = this.container;dbx.box = this.box;dbx.event = e;if(typeof dbx.onboxdrag == 'undefined' || dbx.onboxdrag()){this.released = true;if(!this.restrict || !this.vertical) { this.boxclone.style.left = (this.current.x - this.difference.x) + 'px'; }if(!this.restrict || this.vertical) { this.boxclone.style.top = (this.current.y - this.difference.y) + 'px'; }this.moveOriginalToPosition(this.current.x, this.current.y);if(typeof e.preventDefault != 'undefined' ) { e.preventDefault(); }}}}return true;};dbxGroup.prototype.mouseup = function(e){if(this.box != null){this.moveOriginalToPosition(e.clientX, e.clientY);this.removeCloneBox();this.getBoxOrder();if(typeof document.onselectstart != 'undefined'){document.onselectstart = function() { return true; }}}this.dragok = false;};dbxGroup.prototype.keypress = function(e, anchor){if(/^(3[7-9])|(40)$/.test(e.keyCode)){this.removeTooltip();if((this.vertical && /^(38|40)$/.test(e.keyCode)) || (!this.vertical && /^(37|39)$/.test(e.keyCode))){this.shiftBoxPosition(e, anchor, /^[3][78]$/.test(e.keyCode) ? false : true);if(typeof e.preventDefault != 'undefined') { e.preventDefault(); }else { return false; }typeof e.stopPropagation != 'undefined' ? e.stopPropagation() : e.cancelBubble = true;this.keydown = false;}}return true;};dbxGroup.prototype.getBoxOrder = function(){this.order = [];var len = this.eles.length;for(var j=0; j<len; j++){if(/dbx\-box/i.test(this.eles[j].className) && !/dbx\-(clone|dummy)/i.test(this.eles[j].className)){this.order.push(this.eles[j].className.split('dbxid')[1] + (/dbx\-box\-open/i.test(this.eles[j].className) ? '+' : '-'));}}dbx.savedata[this.gid] = this.order.join(',');dbx.setCookieState();};dbxGroup.prototype.createClone = function(){var clone = this.container.appendChild(arguments[0].cloneNode(true));clone.className += ' dbx-clone';clone.style.position = 'absolute';clone.style.visibility = 'hidden';clone.style.zIndex = arguments[1];clone.style.left = arguments[2].x + 'px';clone.style.top = arguments[2].y + 'px';clone.style.width = arguments[0].offsetWidth + 'px';clone.style.height = arguments[0].offsetHeight + 'px';return clone;};dbxGroup.prototype.createCloneBox = function(box){this.box = box;this.position = { 'x' : this.box.offsetLeft, 'y' : this.box.offsetTop };this.difference = { 'x' : (this.initial.x - this.position.x), 'y' : (this.initial.y - this.position.y) };this.boxclone = this.createClone(this.box, 30000, this.position);this.boxclone.style.cursor = 'move';this.dragok = true;};dbxGroup.prototype.removeCloneBox = function(){this.container.removeChild(this.boxclone);this.box.style.visibility = 'visible';this.box = null;};dbxGroup.prototype.moveOriginalToPosition = function(clientX, clientY){var cloneprops = {'xy' : this.vertical ? clientY - this.difference.y : clientX - this.difference.x,'wh' : this.vertical ? this.boxclone.offsetHeight : this.boxclone.offsetWidth};this.box.style.visibility = 'hidden';this.boxclone.style.visibility = 'visible';var len = this.boxes.length;for(var i=0; i<len; i++){var boxprops = {'xy' : this.vertical ? this.boxes[i].offsetTop : this.boxes[i].offsetLeft,'wh' : this.vertical ? this.boxes[i].offsetHeight : this.boxes[i].offsetWidth};if((this.positive && cloneprops.xy + cloneprops.wh > boxprops.xy && cloneprops.xy < boxprops.xy)||(!this.positive && cloneprops.xy < boxprops.xy && cloneprops.xy + cloneprops.wh > boxprops.xy)){if(this.boxes[i] == this.box) { return; }var sibling = this.box.nextSibling;while(sibling.className == null || !/dbx\-box/.test(sibling.className)){sibling = sibling.nextSibling;}if(this.boxes[i] == sibling) { return; }if(this.resolution > 0){if(this.box[this.vertical ? 'offsetTop' : 'offsetLeft'] < boxprops.xy){var visibox = this.boxes[i].previousSibling;while(visibox.className == null || !/dbx\-box/.test(visibox.className)){visibox = visibox.previousSibling;}}else{visibox = this.boxes[i];}var visipos = { 'x' : visibox.offsetLeft, 'y' : visibox.offsetTop };}var prepos = { 'x' : this.box.offsetLeft, 'y' : this.box.offsetTop };this.container.insertBefore(this.box, this.boxes[i]);this.initial.x += (this.box.offsetLeft - prepos.x);this.initial.y += (this.box.offsetTop - prepos.y);if(this.resolution > 0 && visibox != this.box){var animator = new dbxAnimator(this, visibox, visipos, this.resolution, false, null);}else{}break;}}};function dbxAnimator(caller, box, pos, res, kbd, anchor){this.caller = caller;this.box = box;this.timer = null;var before = pos[this.caller.vertical ? 'y' : 'x'];var after = this.box[this.caller.vertical ? 'offsetTop' : 'offsetLeft'];if(before != after){if(dbx.running > this.caller.boxes.length - 1) { return; }var clone = this.caller.createClone(this.box, 29999, arguments[2]);clone.style.visibility = 'visible';this.box.style.visibility = 'hidden';this.animateClone(clone,before,after > before ? after - before : 0 - (before - after),this.caller.vertical ? 'top' : 'left',res,kbd,anchor);}};dbxAnimator.prototype.animateClone = function(clone, current, change, dir, res, kbd, anchor){var self = this;var count = 0;dbx.running ++;this.timer = window.setInterval(function(){count ++;current += change / res;clone.style[dir] = current + 'px';if(count == res){window.clearTimeout(self.timer);self.timer = null;dbx.running --;self.caller.container.removeChild(clone);self.box.style.visibility = 'visible';if(kbd){if(anchor != null && anchor.parentNode.style.visibility != 'hidden'){anchor.focus();}else if(self.caller.toggles){var button = self.caller.buttons[parseInt(self.box.className.split('dbxid')[1],10)];if(button != null && typeof button.isactive != 'undefined'){button.focus();}}}}}, 20);};if(typeof window.attachEvent != 'undefined'){window.attachEvent('onunload', function(){var ev = ['mousedown', 'mousemove', 'mouseup', 'mouseout', 'click', 'keydown', 'keyup', 'focus', 'blur', 'selectstart', 'statechange', 'boxdrag', 'boxopen', 'boxclose'];var el = ev.length;var dl = document.all.length;for(var i=0; i<dl; i++){for(var j=0; j<el; j++){document.all[i]['on' + ev[j]] = null;}}});}
     6var dbx;function dbxManager(sid){dbx = this;if(!/^[-_a-z0-9]+$/i.test(sid)) { alert('Error from dbxManager:\n"' + sid + '" is an invalid session ID'); return; }this.supported = !(document.getElementsByTagName('*').length == 0 || (navigator.vendor == 'KDE' && typeof window.sidebar == 'undefined'));if(!this.supported) { return; }this.etype = typeof document.addEventListener != 'undefined' ? 'addEventListener' : typeof document.attachEvent != 'undefined' ? 'attachEvent' : 'none';this.eprefix = (this.etype == 'attachEvent' ? 'on' : '');if(typeof window.opera != 'undefined' && parseFloat(navigator.userAgent.toLowerCase().split(/opera[\/ ]/)[1].split(' ')[0], 10) < 7.5){this.etype = 'none';}if(this.etype == 'none') { this.supported = false; return; }this.running = 0;this.sid = sid;this.savedata = {};this.cookiestate = this.getCookieState();};dbxManager.prototype.setCookieState = function(){var now = new Date();now.setTime(now.getTime() + (365*24*60*60*1000));var str = '';for(j in this.savedata){if(typeof this.savedata[j]!='function'){str += j + '=' + this.savedata[j] + '&'}}this.state = str.replace(/^(.+)&$/, '$1');this.cookiestring = this.state.replace(/,/g, '|');this.cookiestring = this.cookiestring.replace(/=/g, ':');if(typeof this.onstatechange == 'undefined' || this.onstatechange()){document.cookie = 'dbx-' + this.sid + '='+ this.cookiestring+ '; expires=' + now.toGMTString()+ '; path=/';}};dbxManager.prototype.getCookieState = function(){this.cookiestate = null;if(document.cookie){if(document.cookie.indexOf('dbx-' + this.sid)!=-1){this.cookie = document.cookie.split('dbx-' + this.sid + '=')[1].split(';')[0].split('&');for(var i in this.cookie){if(typeof this.cookie[i]!='function'){this.cookie[i] = this.cookie[i].replace(/\|/g, ',');this.cookie[i]= this.cookie[i].replace(/:/g, '=');this.cookie[i] = this.cookie[i].split('=');this.cookie[i][1] = this.cookie[i][1].split(',');}}this.cookiestate = {};for(i in this.cookie){if(typeof this.cookie[i]!='function'){this.cookiestate[this.cookie[i][0]] = this.cookie[i][1];}}}}return this.cookiestate;};dbxManager.prototype.addDataMember = function(gid, order){this.savedata[gid] = order;};dbxManager.prototype.createElement = function(tag){return typeof document.createElementNS != 'undefined' ? document.createElementNS('http://www.w3.org/1999/xhtml', tag) : document.createElement(tag);};dbxManager.prototype.getTarget = function(e, pattern, node){if(typeof node != 'undefined'){var target = node;}else{target = typeof e.target != 'undefined' ? e.target : e.srcElement;}var regex = new RegExp(pattern, '');while(!regex.test(target.className)){target = target.parentNode;}return target;};function dbxGroup(gid, dir, thresh, fix, ani, togs, def, open, close, move, toggle, kmove, ktoggle, syntax){if(!/^[-_a-z0-9]+$/i.test(gid)) { alert('Error from dbxGroup:\n"' + gid + '" is an invalid container ID'); return; }this.container = document.getElementById(gid);if(this.container == null || !dbx.supported) { return; }var self = this;this.gid = gid;this.dragok = false;this.box = null;this.vertical = dir == 'vertical';this.threshold = parseInt(thresh, 10);this.restrict = fix == 'yes';this.resolution = parseInt(ani, 10);this.toggles = togs == 'yes';this.defopen = def != 'closed';this.vocab = {'open' : open,'close' : close,'move' : move,'toggle' : toggle,'kmove' : kmove,'ktoggle' : ktoggle,'syntax' : syntax};this.container.style.position = 'relative';this.container.style.display = 'block';if(typeof window.opera != 'undefined'){this.container.style.display = 'run-in';}this.boxes = [];this.buttons = [];this.order = [];this.eles = this.container.getElementsByTagName('*');for(var i=0; i<this.eles.length; i++){if(/dbx\-box/i.test(this.eles[i].className) && !/dbx\-dummy/i.test(this.eles[i].className)){this.eles[i].style.position = 'relative';this.eles[i].style.display = 'block';this.boxes.push(this.eles[i]);this.eles[i].className += ' dbx-box-open';this.eles[i].className += ' dbxid' + this.order.length;this.order.push(this.order.length.toString() + '+');this.eles[i][dbx.etype](dbx.eprefix + 'mousedown', function(e){if(!e) { e = window.event; }self.mousedown(e, dbx.getTarget(e, 'dbx\-box'));}, false);}if(/dbx\-handle/i.test(this.eles[i].className)){this.eles[i].style.position = 'relative';this.eles[i].style.display = 'block';this.eles[i].className += ' dbx-handle-cursor';this.eles[i].setAttribute('title', this.eles[i].getAttribute('title') == null || this.eles[i].title == '' ? this.vocab.move : this.vocab.syntax.replace('%mytitle%', this.eles[i].title).replace('%dbxtitle%', this.vocab.move));if(this.toggles){this.buttons.push(this.addToggleBehavior(this.eles[i]));}else{this.eles[i][dbx.etype](dbx.eprefix + 'key' + (typeof document.uniqueID != 'undefined' || navigator.vendor == 'Apple Computer, Inc.' ? 'down' : 'press'), function(e){if(!e) { e = window.event; }return self.keypress(e, dbx.getTarget(e, 'dbx\-handle'));}, false);this.eles[i][dbx.etype](dbx.eprefix + 'focus', function(e){if(!e) { e = window.event; }self.createTooltip(null, dbx.getTarget(e, 'dbx\-handle'));}, false);this.eles[i][dbx.etype](dbx.eprefix + 'blur', function(){self.removeTooltip();}, false);}}}dbx.addDataMember(this.gid, this.order.join(','));var dummy = this.container.appendChild(dbx.createElement('span'));dummy.className = 'dbx-box dbx-dummy';dummy.style.display = 'block';dummy.style.width = '0';dummy.style.height = '0';dummy.style.overflow = 'hidden';if(this.vertical) { dummy.className += ' dbx-offdummy'; }this.boxes.push(dummy);if(dbx.cookiestate != null && typeof dbx.cookiestate[this.gid] != 'undefined'){var num = dbx.cookiestate[this.gid].length;if(num == this.boxes.length - 1){for(i=0; i<num; i++){var index = parseInt(dbx.cookiestate[this.gid][i], 10);this.container.insertBefore(this.boxes[index], dummy);if(this.toggles && /\-$/.test(dbx.cookiestate[this.gid][i])){this.toggleBoxState(this.buttons[index], false);}}this.getBoxOrder();}}else if(!this.defopen && this.toggles){var len = this.buttons.length;for(i=0; i<len; i++){this.toggleBoxState(this.buttons[i], true);}}document[dbx.etype](dbx.eprefix + 'mouseout', function(e){if(typeof e.target == 'undefined') { e = window.event; e.relatedTarget = e.toElement; }if(e.relatedTarget == null){self.mouseup(e);}}, false);document[dbx.etype](dbx.eprefix + 'mousemove', function(e){self.mousemove(e);return !self.dragok;}, false);document[dbx.etype](dbx.eprefix + 'mouseup', function(e){self.mouseup(e);}, false);this.keydown = false;document[dbx.etype](dbx.eprefix + 'keydown', function(){self.keydown = true;}, false);document[dbx.etype](dbx.eprefix + 'keyup', function(){self.keydown = false;}, false);};dbxGroup.prototype.addToggleBehavior = function(){var self = this;var button = arguments[0].appendChild(dbx.createElement('a'));button.appendChild(document.createTextNode('\u00a0'));button.style.cursor = 'pointer';button.href = 'javascript:void(null)';button.className = 'dbx-toggle dbx-toggle-open';button.setAttribute('title', this.vocab.toggle.replace('%toggle%', this.vocab.close));button.hasfocus = typeof window.opera != 'undefined' || navigator.vendor == 'Apple Computer, Inc.' ? null : false;this.tooltip = null;button.onclick = function(){if(this.hasfocus === true || this.hasfocus === null){self.removeTooltip();self.toggleBoxState(this, true);}};button['onkey' + (typeof document.uniqueID != 'undefined' || navigator.vendor == 'Apple Computer, Inc.' ? 'down' : 'press')] = function(e){if(!e) { e = window.event; }return self.keypress(e, this);};button.onfocus = function(){var len = self.buttons.length;for(var i=0; i<len; i++){self.buttons[i].className = self.buttons[i].className.replace(/[ ](dbx\-toggle\-hilite\-)(open|closed)/, '');}var isopen = (/dbx\-toggle\-open/.test(this.className));this.className += ' dbx-toggle-hilite-' + (isopen ? 'open' : 'closed');self.createTooltip(isopen, this);this.isactive = true;if(this.hasfocus !== null) { this.hasfocus = true; }};button.onblur = function(){this.className = this.className.replace(/[ ](dbx\-toggle\-hilite\-)(open|closed)/, '');self.removeTooltip();if(this.hasfocus !== null) { this.hasfocus = false; }};return button;};dbxGroup.prototype.toggleBoxState = function(button, regen){var isopen = (/dbx\-toggle\-open/.test(button.className));var parent = dbx.getTarget(null, 'dbx\-box', button);dbx.box = parent;dbx.toggle = button;if(typeof dbx.container == 'undefined'){dbx.group = dbx.getTarget(null, 'dbx\-group', parent);}else { dbx.group = dbx.container; }if((!isopen && (typeof dbx.onboxopen == 'undefined' || dbx.onboxopen()))||(isopen && (typeof dbx.onboxclose == 'undefined' || dbx.onboxclose()))){button.className = 'dbx-toggle dbx-toggle-' + (isopen ? 'closed' : 'open');button.title = this.vocab.toggle.replace('%toggle%', isopen ? this.vocab.open : this.vocab.close);if(typeof button.isactive != 'undefined'){button.className += ' dbx-toggle-hilite-' + (isopen ? 'closed' : 'open')}parent.className = parent.className.replace(/[ ](dbx-box-)(open|closed)/, ' $1' + (isopen ? 'closed' : 'open'));if(regen) { this.getBoxOrder(); }}};dbxGroup.prototype.shiftBoxPosition = function(e, anchor, positive){var parent = dbx.getTarget(null, 'dbx\-box', anchor);dbx.group = this.container;dbx.box = parent;dbx.event = e;if(typeof dbx.onboxdrag == 'undefined' || dbx.onboxdrag()){var positions = [];var len = this.boxes.length;for(var i=0; i<len; i++){positions[i] = [i, this.boxes[i][this.vertical ? 'offsetTop' : 'offsetLeft']];if(parent == this.boxes[i]) { this.idref = i; }}positions.sort(this.compare);for(i=0; i<len; i++){if(positions[i][0] == this.idref){if((positive && i < len - 2) || (!positive && i > 0)){var sibling = this.boxes[positions[i + (positive ? 1 : -1)][0]];if(this.resolution > 0){var visipos = { 'x' : parent.offsetLeft, 'y' : parent.offsetTop };var siblingpos = { 'x' : sibling.offsetLeft, 'y' : sibling.offsetTop };}var obj = { 'insert' : (positive ? sibling : parent), 'before' : (positive ? parent : sibling) };this.container.insertBefore(obj.insert, obj.before);if(this.resolution > 0){var animators ={'sibling' : new dbxAnimator(this, sibling, siblingpos, this.resolution, true, anchor),'parent' : new dbxAnimator(this, parent, visipos, this.resolution, true, anchor)};}else{anchor.focus();}break;}}}this.getBoxOrder();}};dbxGroup.prototype.compare = function(a, b){return a[1] - b[1];};dbxGroup.prototype.createTooltip = function(isopen, anchor){if(this.keydown){this.tooltip = this.container.appendChild(dbx.createElement('span'));this.tooltip.style.visibility = 'hidden';this.tooltip.className = 'dbx-tooltip';if(isopen != null){this.tooltip.appendChild(document.createTextNode(this.vocab.kmove + this.vocab.ktoggle.replace('%toggle%', isopen ? this.vocab.close : this.vocab.open)));}else{this.tooltip.appendChild(document.createTextNode(this.vocab.kmove));}var parent = dbx.getTarget(null, 'dbx\-box', anchor);this.tooltip.style.left = parent.offsetLeft + 'px';this.tooltip.style.top = parent.offsetTop + 'px';var tooltip = this.tooltip;window.setTimeout(function(){if(tooltip != null) { tooltip.style.visibility = 'visible'; }}, 500);}};dbxGroup.prototype.removeTooltip = function(){if(this.tooltip != null){this.tooltip.parentNode.removeChild(this.tooltip);this.tooltip = null;}};dbxGroup.prototype.mousedown = function(e, box){var node = typeof e.target != 'undefined' ? e.target : e.srcElement;if(node.nodeName == '#text') { node = node.parentNode; }if(!/dbx\-(toggle|box|group)/i.test(node.className)){while(!/dbx\-(handle|box|group)/i.test(node.className)){node = node.parentNode;}}if(/dbx\-handle/i.test(node.className)){this.removeTooltip();this.released = false;this.initial = { 'x' : e.clientX, 'y' : e.clientY };this.current = { 'x' : 0, 'y' : 0 };this.createCloneBox(box);if(typeof e.preventDefault != 'undefined' ) { e.preventDefault(); }if(typeof document.onselectstart != 'undefined'){document.onselectstart = function() { return false; }}}};dbxGroup.prototype.mousemove = function(e){if(this.dragok && this.box != null){this.positive = this.vertical ? (e.clientY > this.current.y ? true : false) : (e.clientX > this.current.x ? true : false);this.current = { 'x' : e.clientX, 'y' : e.clientY };var overall = { 'x' : this.current.x - this.initial.x, 'y' : this.current.y - this.initial.y };if(((overall.x >= 0 && overall.x <= this.threshold) || (overall.x <= 0 && overall.x >= 0 - this.threshold))&&((overall.y >= 0 && overall.y <= this.threshold) || (overall.y <= 0 && overall.y >= 0 - this.threshold))){this.current.x -= overall.x;this.current.y -= overall.y;}if(this.released || overall.x > this.threshold || overall.x < (0 - this.threshold) || overall.y > this.threshold || overall.y < (0 - this.threshold)){dbx.group = this.container;dbx.box = this.box;dbx.event = e;if(typeof dbx.onboxdrag == 'undefined' || dbx.onboxdrag()){this.released = true;if(!this.restrict || !this.vertical) { this.boxclone.style.left = (this.current.x - this.difference.x) + 'px'; }if(!this.restrict || this.vertical) { this.boxclone.style.top = (this.current.y - this.difference.y) + 'px'; }this.moveOriginalToPosition(this.current.x, this.current.y);if(typeof e.preventDefault != 'undefined' ) { e.preventDefault(); }}}}return true;};dbxGroup.prototype.mouseup = function(e){if(this.box != null){this.moveOriginalToPosition(e.clientX, e.clientY);this.removeCloneBox();this.getBoxOrder();if(typeof document.onselectstart != 'undefined'){document.onselectstart = function() { return true; }}}this.dragok = false;};dbxGroup.prototype.keypress = function(e, anchor){if(/^(3[7-9])|(40)$/.test(e.keyCode)){this.removeTooltip();if((this.vertical && /^(38|40)$/.test(e.keyCode)) || (!this.vertical && /^(37|39)$/.test(e.keyCode))){this.shiftBoxPosition(e, anchor, /^[3][78]$/.test(e.keyCode) ? false : true);if(typeof e.preventDefault != 'undefined') { e.preventDefault(); }else { return false; }typeof e.stopPropagation != 'undefined' ? e.stopPropagation() : e.cancelBubble = true;this.keydown = false;}}return true;};dbxGroup.prototype.getBoxOrder = function(){this.order = [];var len = this.eles.length;for(var j=0; j<len; j++){if(/dbx\-box/i.test(this.eles[j].className) && !/dbx\-(clone|dummy)/i.test(this.eles[j].className)){this.order.push(this.eles[j].className.split('dbxid')[1] + (/dbx\-box\-open/i.test(this.eles[j].className) ? '+' : '-'));}}dbx.savedata[this.gid] = this.order.join(',');dbx.setCookieState();};dbxGroup.prototype.createClone = function(){var clone = this.container.appendChild(arguments[0].cloneNode(true));clone.className += ' dbx-clone';clone.style.position = 'absolute';clone.style.visibility = 'hidden';clone.style.zIndex = arguments[1];clone.style.left = arguments[2].x + 'px';clone.style.top = arguments[2].y + 'px';clone.style.width = arguments[0].offsetWidth + 'px';clone.style.height = arguments[0].offsetHeight + 'px';return clone;};dbxGroup.prototype.createCloneBox = function(box){this.box = box;this.position = { 'x' : this.box.offsetLeft, 'y' : this.box.offsetTop };this.difference = { 'x' : (this.initial.x - this.position.x), 'y' : (this.initial.y - this.position.y) };this.boxclone = this.createClone(this.box, 30000, this.position);this.boxclone.style.cursor = 'move';this.dragok = true;};dbxGroup.prototype.removeCloneBox = function(){this.container.removeChild(this.boxclone);this.box.style.visibility = 'visible';this.box = null;};dbxGroup.prototype.moveOriginalToPosition = function(clientX, clientY){var cloneprops = {'xy' : this.vertical ? clientY - this.difference.y : clientX - this.difference.x,'wh' : this.vertical ? this.boxclone.offsetHeight : this.boxclone.offsetWidth};this.box.style.visibility = 'hidden';this.boxclone.style.visibility = 'visible';var len = this.boxes.length;for(var i=0; i<len; i++){var boxprops = {'xy' : this.vertical ? this.boxes[i].offsetTop : this.boxes[i].offsetLeft,'wh' : this.vertical ? this.boxes[i].offsetHeight : this.boxes[i].offsetWidth};if((this.positive && cloneprops.xy + cloneprops.wh > boxprops.xy && cloneprops.xy < boxprops.xy)||(!this.positive && cloneprops.xy < boxprops.xy && cloneprops.xy + cloneprops.wh > boxprops.xy)){if(this.boxes[i] == this.box) { return; }var sibling = this.box.nextSibling;while(sibling.className == null || !/dbx\-box/.test(sibling.className)){sibling = sibling.nextSibling;}if(this.boxes[i] == sibling) { return; }if(this.resolution > 0){if(this.box[this.vertical ? 'offsetTop' : 'offsetLeft'] < boxprops.xy){var visibox = this.boxes[i].previousSibling;while(visibox.className == null || !/dbx\-box/.test(visibox.className)){visibox = visibox.previousSibling;}}else{visibox = this.boxes[i];}var visipos = { 'x' : visibox.offsetLeft, 'y' : visibox.offsetTop };}var prepos = { 'x' : this.box.offsetLeft, 'y' : this.box.offsetTop };this.container.insertBefore(this.box, this.boxes[i]);this.initial.x += (this.box.offsetLeft - prepos.x);this.initial.y += (this.box.offsetTop - prepos.y);if(this.resolution > 0 && visibox != this.box){var animator = new dbxAnimator(this, visibox, visipos, this.resolution, false, null);}else{}break;}}};function dbxAnimator(caller, box, pos, res, kbd, anchor){this.caller = caller;this.box = box;this.timer = null;var before = pos[this.caller.vertical ? 'y' : 'x'];var after = this.box[this.caller.vertical ? 'offsetTop' : 'offsetLeft'];if(before != after){if(dbx.running > this.caller.boxes.length - 1) { return; }var clone = this.caller.createClone(this.box, 29999, arguments[2]);clone.style.visibility = 'visible';this.box.style.visibility = 'hidden';this.animateClone(clone,before,after > before ? after - before : 0 - (before - after),this.caller.vertical ? 'top' : 'left',res,kbd,anchor);}};dbxAnimator.prototype.animateClone = function(clone, current, change, dir, res, kbd, anchor){var self = this;var count = 0;dbx.running ++;this.timer = window.setInterval(function(){count ++;current += change / res;clone.style[dir] = current + 'px';if(count == res){window.clearTimeout(self.timer);self.timer = null;dbx.running --;self.caller.container.removeChild(clone);self.box.style.visibility = 'visible';if(kbd){if(anchor != null && anchor.parentNode.style.visibility != 'hidden'){anchor.focus();}else if(self.caller.toggles){var button = self.caller.buttons[parseInt(self.box.className.split('dbxid')[1],10)];if(button != null && typeof button.isactive != 'undefined'){button.focus();}}}}}, 20);};if(typeof window.attachEvent != 'undefined'){window.attachEvent('onunload', function(){var ev = ['mousedown', 'mousemove', 'mouseup', 'mouseout', 'click', 'keydown', 'keyup', 'focus', 'blur', 'selectstart', 'statechange', 'boxdrag', 'boxopen', 'boxclose'];var el = ev.length;var dl = document.all.length;for(var i=0; i<dl; i++){for(var j=0; j<el; j++){document.all[i]['on' + ev[j]] = null;}}});}
  • trunk/wp-includes/js/fat.js

    r3503 r4431  
    1212        return "#" + r + g + b;
    1313    },
    14     fade_all : function ()
     14    fade_all : function (dur)
    1515    {
    1616        var a = document.getElementsByTagName("*");
     
    2222            {
    2323                if (!r[1]) r[1] = "";
    24                 if (o.id) Fat.fade_element(o.id,null,null,"#"+r[1]);
     24                if (o.id) Fat.fade_element(o.id,null,dur,"#"+r[1]);
    2525            }
    2626        }
     
    3232        if (!from || from=="#") from = "#FFFF33";
    3333        if (!to) to = this.get_bgcolor(id);
    34        
     34
    3535        var frames = Math.round(fps * (duration / 1000));
    3636        var interval = duration / frames;
    3737        var delay = interval;
    3838        var frame = 0;
    39        
     39
    4040        if (from.length < 7) from += from.substr(1,3);
    4141        if (to.length < 7) to += to.substr(1,3);
    42        
     42
    4343        var rf = parseInt(from.substr(1,2),16);
    4444        var gf = parseInt(from.substr(3,2),16);
     
    4747        var gt = parseInt(to.substr(3,2),16);
    4848        var bt = parseInt(to.substr(5,2),16);
    49        
     49
    5050        var r,g,b,h;
    5151        while (frame < frames)
     
    5555            b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames));
    5656            h = this.make_hex(r,g,b);
    57        
     57
    5858            setTimeout("Fat.set_bgcolor('"+id+"','"+h+"')", delay);
    5959
  • trunk/wp-includes/js/quicktags.js

    r3503 r4431  
    206206        return false; // tag not found
    207207    }
    208 }   
     208}
    209209
    210210function edCloseAllTags() {
  • trunk/wp-includes/js/tinymce/langs/en.js

    r3503 r4431  
    11// UK lang variables
    22
    3 tinyMCELang['lang_bold_desc'] = 'Bold (Alt+b)';
    4 tinyMCELang['lang_italic_desc'] = 'Italic (Alt+i)';
    5 tinyMCELang['lang_underline_desc'] = 'Underline';
    6 tinyMCELang['lang_striketrough_desc'] = 'Striketrough (Alt-d)';
    7 tinyMCELang['lang_justifyleft_desc'] = 'Align left (Alt-f)';
    8 tinyMCELang['lang_justifycenter_desc'] = 'Align center (Alt-c)';
    9 tinyMCELang['lang_justifyright_desc'] = 'Align right (Alt-r)';
    10 tinyMCELang['lang_justifyfull_desc'] = 'Align full';
    11 tinyMCELang['lang_bullist_desc'] = 'Unordered list (Alt-l)';
    12 tinyMCELang['lang_numlist_desc'] = 'Ordered list (Alt-o)';
    13 tinyMCELang['lang_outdent_desc'] = 'Outdent (Alt-w)';
    14 tinyMCELang['lang_indent_desc'] = 'Indent/Blockquote (Alt-q)';
    15 tinyMCELang['lang_undo_desc'] = 'Undo (Alt-u)';
    16 tinyMCELang['lang_redo_desc'] = 'Redo (Alt-y)';
    17 tinyMCELang['lang_link_desc'] = 'Insert/edit link (Alt-a)';
    18 tinyMCELang['lang_unlink_desc'] = 'Unlink (Alt-s)';
    19 tinyMCELang['lang_image_desc'] = 'Insert/edit image (Alt-m)';
    20 tinyMCELang['lang_cleanup_desc'] = 'Cleanup messy code';
    21 tinyMCELang['lang_focus_alert'] = 'A editor instance must be focused before using this command.';
    22 tinyMCELang['lang_edit_confirm'] = 'Do you want to use the WYSIWYG mode for this textarea?';
    23 tinyMCELang['lang_insert_link_title'] = 'Insert/edit link';
    24 tinyMCELang['lang_insert'] = 'Insert';
    25 tinyMCELang['lang_update'] = 'Update';
    26 tinyMCELang['lang_cancel'] = 'Cancel';
    27 tinyMCELang['lang_insert_link_url'] = 'Link URL';
    28 tinyMCELang['lang_insert_link_target'] = 'Target';
    29 tinyMCELang['lang_insert_link_target_same'] = 'Open link in the same window';
    30 tinyMCELang['lang_insert_link_target_blank'] = 'Open link in a new window';
    31 tinyMCELang['lang_insert_image_title'] = 'Insert/edit image';
    32 tinyMCELang['lang_insert_image_src'] = 'Image URL';
    33 tinyMCELang['lang_insert_image_alt'] = 'Image description';
    34 tinyMCELang['lang_help_desc'] = 'Help';
    35 tinyMCELang['lang_bold_img'] = "bold.gif";
    36 tinyMCELang['lang_italic_img'] = "italic.gif";
    37 tinyMCELang['lang_underline_img'] = "underline.gif";
    38 tinyMCELang['lang_clipboard_msg'] = 'Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?';
    39 tinyMCELang['lang_popup_blocked'] = 'Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.';
     3tinyMCE.addToLang('',{
     4bold_desc : 'Bold (Ctrl+B)',
     5italic_desc : 'Italic (Ctrl+I)',
     6underline_desc : 'Underline (Ctrl+U)',
     7striketrough_desc : 'Strikethrough',
     8justifyleft_desc : 'Align left',
     9justifycenter_desc : 'Align center',
     10justifyright_desc : 'Align right',
     11justifyfull_desc : 'Align full',
     12bullist_desc : 'Unordered list',
     13numlist_desc : 'Ordered list',
     14outdent_desc : 'Outdent',
     15indent_desc : 'Indent',
     16undo_desc : 'Undo (Ctrl+Z)',
     17redo_desc : 'Redo (Ctrl+Y)',
     18link_desc : 'Insert/edit link',
     19unlink_desc : 'Unlink',
     20image_desc : 'Insert/edit image',
     21cleanup_desc : 'Cleanup messy code',
     22focus_alert : 'A editor instance must be focused before using this command.',
     23edit_confirm : 'Do you want to use the WYSIWYG mode for this textarea?',
     24insert_link_title : 'Insert/edit link',
     25insert : 'Insert',
     26update : 'Update',
     27cancel : 'Cancel',
     28insert_link_url : 'Link URL',
     29insert_link_target : 'Target',
     30insert_link_target_same : 'Open link in the same window',
     31insert_link_target_blank : 'Open link in a new window',
     32insert_image_title : 'Insert/edit image',
     33insert_image_src : 'Image URL',
     34insert_image_alt : 'Image description',
     35help_desc : 'Help',
     36bold_img : "bold.gif",
     37italic_img : "italic.gif",
     38underline_img : "underline.gif",
     39clipboard_msg : 'Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?',
     40popup_blocked : 'Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.'
     41});
  • trunk/wp-includes/js/tinymce/plugins/autosave/editor_plugin.js

    r3503 r4431  
     1/**
     2 * $RCSfile: editor_plugin_src.js,v $
     3 * $Revision: 1.11 $
     4 * $Date: 2006/03/22 12:21:21 $
     5 *
     6 * @author Moxiecode
     7 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
     8 */
     9
    110/* Import plugin specific language pack */
    2  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;
     11tinyMCE.importPluginLanguagePack('autosave', 'en,tr,sv,cs,he,nb,hu,de,da,ru,ru_KOI8-R,ru_UTF-8,nn,fi,cy,es,is,pl,pt_br');
     12
     13var TinyMCE_AutoSavePlugin = {
     14    getInfo : function() {
     15        return {
     16            longname : 'Auto save',
     17            author : 'Moxiecode Systems',
     18            authorurl : 'http://tinymce.moxiecode.com',
     19            infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_autosave.html',
     20            version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
     21        };
     22    },
     23
     24    // Private plugin internal methods
     25
     26    _beforeUnloadHandler : function() {
     27        var n, inst, anyDirty = false, msg = tinyMCE.getLang("lang_autosave_unload_msg");
     28
     29        if (tinyMCE.getParam("fullscreen_is_enabled"))
     30            return;
     31
     32        for (n in tinyMCE.instances) {
     33            inst = tinyMCE.instances[n];
     34
     35            if (!tinyMCE.isInstance(inst))
     36                continue;
     37
     38            if (inst.isDirty())
     39                return msg;
     40        }
     41
     42        return;
     43    }
     44};
     45
     46window.onbeforeunload = TinyMCE_AutoSavePlugin._beforeUnloadHandler;
     47
     48tinyMCE.addPlugin("autosave", TinyMCE_AutoSavePlugin);
  • trunk/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js

    r3503 r4431  
     1/**
     2 * $RCSfile: editor_plugin_src.js,v $
     3 * $Revision: 1.16 $
     4 * $Date: 2006/02/10 21:34:28 $
     5 *
     6 * @author Moxiecode
     7 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
     8 */
     9
    110/* Import plugin specific language pack */
    2 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');
     11tinyMCE.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');
    312
    4 function TinyMCE_directionality_getInfo() {
    5     return {
    6         longname : 'Directionality',
    7         author : 'Moxiecode Systems',
    8         authorurl : 'http://tinymce.moxiecode.com',
    9         infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html',
    10         version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
    11     };
     13var TinyMCE_DirectionalityPlugin = {
     14    getInfo : function() {
     15        return {
     16            longname : 'Directionality',
     17            author : 'Moxiecode Systems',
     18            authorurl : 'http://tinymce.moxiecode.com',
     19            infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html',
     20            version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
     21        };
     22    },
     23
     24    getControlHTML : function(cn) {
     25        switch (cn) {
     26            case "ltr":
     27                return tinyMCE.getButtonHTML(cn, 'lang_directionality_ltr_desc', '{$pluginurl}/images/ltr.gif', 'mceDirectionLTR');
     28
     29            case "rtl":
     30                return tinyMCE.getButtonHTML(cn, 'lang_directionality_rtl_desc', '{$pluginurl}/images/rtl.gif', 'mceDirectionRTL');
     31        }
     32
     33        return "";
     34    },
     35
     36    execCommand : function(editor_id, element, command, user_interface, value) {
     37        // Handle commands
     38        switch (command) {
     39            case "mceDirectionLTR":
     40                var inst = tinyMCE.getInstanceById(editor_id);
     41                var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
     42
     43                if (elm)
     44                    elm.setAttribute("dir", "ltr");
     45
     46                tinyMCE.triggerNodeChange(false);
     47                return true;
     48
     49            case "mceDirectionRTL":
     50                var inst = tinyMCE.getInstanceById(editor_id);
     51                var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
     52
     53                if (elm)
     54                    elm.setAttribute("dir", "rtl");
     55
     56                tinyMCE.triggerNodeChange(false);
     57                return true;
     58        }
     59
     60        // Pass to next handler in chain
     61        return false;
     62    },
     63
     64    handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
     65        function getAttrib(elm, name) {
     66            return elm.getAttribute(name) ? elm.getAttribute(name) : "";
     67        }
     68
     69        if (node == null)
     70            return;
     71
     72        var elm = tinyMCE.getParentElement(node, "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
     73        if (!elm) {
     74            tinyMCE.switchClass(editor_id + '_ltr', 'mceButtonDisabled');
     75            tinyMCE.switchClass(editor_id + '_rtl', 'mceButtonDisabled');
     76            return true;
     77        }
     78
     79        tinyMCE.switchClass(editor_id + '_ltr', 'mceButtonNormal');
     80        tinyMCE.switchClass(editor_id + '_rtl', 'mceButtonNormal');
     81
     82        var dir = getAttrib(elm, "dir");
     83        if (dir == "ltr" || dir == "")
     84            tinyMCE.switchClass(editor_id + '_ltr', 'mceButtonSelected');
     85        else
     86            tinyMCE.switchClass(editor_id + '_rtl', 'mceButtonSelected');
     87
     88        return true;
     89    }
    1290};
    1391
    14 function TinyMCE_directionality_getControlHTML(control_name) {
    15     switch (control_name) {
    16         case "ltr":
    17             var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionLTR\');return false;';
    18             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>'
    19             + '<div class="zerosize"><input type="button" accesskey="." onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionLTR\',false);" /></div>';
    20 
    21         case "rtl":
    22             var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionRTL\');return false;';
    23             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>'
    24             + '<div class="zerosize"><input type="button" accesskey="," onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionRTL\',false);" /></div>';
    25     }
    26 
    27     return "";
    28 }
    29 
    30 function TinyMCE_directionality_execCommand(editor_id, element, command, user_interface, value) {
    31     // Handle commands
    32     switch (command) {
    33         case "mceDirectionLTR":
    34             var inst = tinyMCE.getInstanceById(editor_id);
    35             var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
    36 
    37             if (elm)
    38                 elm.setAttribute("dir", "ltr");
    39 
    40             tinyMCE.triggerNodeChange(false);
    41             return true;
    42 
    43         case "mceDirectionRTL":
    44             var inst = tinyMCE.getInstanceById(editor_id);
    45             var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
    46 
    47             if (elm)
    48                 elm.setAttribute("dir", "rtl");
    49 
    50             tinyMCE.triggerNodeChange(false);
    51             return true;
    52     }
    53 
    54     // Pass to next handler in chain
    55     return false;
    56 }
    57 
    58 function TinyMCE_directionality_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
    59     function getAttrib(elm, name) {
    60         return elm.getAttribute(name) ? elm.getAttribute(name) : "";
    61     }
    62 
    63     tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonNormal', false);
    64     tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonNormal', false);
    65 
    66     if (node == null)
    67         return;
    68 
    69     var elm = tinyMCE.getParentElement(node, "p,div,td,h1,h2,h3,h4,h5,h6,pre,address");
    70     if (!elm) {
    71         tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonDisabled', true);
    72         tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonDisabled', true);
    73         return;
    74     }
    75 
    76     var dir = getAttrib(elm, "dir");
    77     if (dir == "ltr" || dir == "")
    78         tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonSelected', false);
    79     else
    80         tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonSelected', false);
    81 
    82     return true;
    83 }
     92tinyMCE.addPlugin("directionality", TinyMCE_DirectionalityPlugin);
  • trunk/wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css

    r3503 r4431  
     1/* Window classes */
     2
     3.mceWindow {
     4    position: absolute;
     5    left: 0;
     6    top: 0;
     7    border: 1px solid black;
     8    background-color: #D4D0C8;
     9}
     10
     11.mceWindowHead {
     12    background-color: #334F8D;
     13    width: 100%;
     14    height: 18px;
     15    cursor: move;
     16    overflow: hidden;
     17}
     18
     19.mceWindowBody {
     20    clear: both;
     21    background-color: white;
     22}
     23
     24.mceWindowStatusbar {
     25    background-color: #D4D0C8;
     26    height: 12px;
     27    border-top: 1px solid black;
     28}
     29
     30.mceWindowTitle {
     31    float: left;
     32    font-family: "MS Sans Serif";
     33    font-size: 9pt;
     34    font-weight: bold;
     35    line-height: 18px;
     36    color: white;
     37    margin-left: 2px;
     38    overflow: hidden;
     39}
     40
     41.mceWindowHeadTools {
     42    margin-right: 2px;
     43}
     44
     45.mceWindowClose, .mceWindowMinimize, .mceWindowMaximize {
     46    display: block;
     47    float: right;
     48    overflow: hidden;
     49    margin-top: 2px;
     50}
     51
     52.mceWindowClose {
     53    margin-left: 2px;
     54}
     55
     56.mceWindowMinimize {
     57}
     58
     59.mceWindowMaximize {
     60}
     61
     62.mceWindowResize {
     63    display: block;
     64    float: right;
     65    overflow: hidden;
     66    cursor: se-resize;
     67    width: 12px;
     68    height: 12px;
     69}
  • trunk/wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js

    r3503 r4431  
     1/**
     2 * $RCSfile: editor_plugin_src.js,v $
     3 * $Revision: 1.8 $
     4 * $Date: 2006/02/06 20:02:38 $
     5 *
     6 * Moxiecode DHTML Windows script.
     7 *
     8 * @author Moxiecode
     9 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
     10 */
     11
     12// Patch openWindow, closeWindow TinyMCE functions
     13
     14var TinyMCE_InlinePopupsPlugin = {
     15    getInfo : function() {
     16        return {
     17            longname : 'Inline Popups',
     18            author : 'Moxiecode Systems',
     19            authorurl : 'http://tinymce.moxiecode.com',
     20            infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_inlinepopups.html',
     21            version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
     22        };
     23    }
     24};
     25
     26tinyMCE.addPlugin("inlinepopups", TinyMCE_InlinePopupsPlugin);
     27
     28// Patch openWindow, closeWindow TinyMCE functions
     29
     30TinyMCE_Engine.prototype.orgOpenWindow = TinyMCE_Engine.prototype.openWindow;
     31
     32TinyMCE_Engine.prototype.openWindow = function(template, args) {
     33    // Does the caller support inline
     34    if (args['inline'] != "yes" || tinyMCE.isOpera || tinyMCE.getParam("plugins").indexOf('inlinepopups') == -1) {
     35        mcWindows.selectedWindow = null;
     36        args['mce_inside_iframe'] = false;
     37        this.orgOpenWindow(template, args);
     38        return;
     39    }
     40
     41    var url, resizable, scrollbars;
     42
     43    args['mce_inside_iframe'] = true;
     44    tinyMCE.windowArgs = args;
     45
     46    if (template['file'].charAt(0) != '/' && template['file'].indexOf('://') == -1)
     47        url = tinyMCE.baseURL + "/themes/" + tinyMCE.getParam("theme") + "/" + template['file'];
     48    else
     49        url = template['file'];
     50
     51    if (!(width = parseInt(template['width'])))
     52        width = 320;
     53
     54    if (!(height = parseInt(template['height'])))
     55        height = 200;
     56
     57    resizable = (args && args['resizable']) ? args['resizable'] : "no";
     58    scrollbars = (args && args['scrollbars']) ? args['scrollbars'] : "no";
     59
     60    height += 18;
     61
     62    // Replace all args as variables in URL
     63    for (var name in args) {
     64        if (typeof(args[name]) == 'function')
     65            continue;
     66
     67        url = tinyMCE.replaceVar(url, name, escape(args[name]));
     68    }
     69
     70    var elm = document.getElementById(this.selectedInstance.editorId + '_parent');
     71    var pos = tinyMCE.getAbsPosition(elm);
     72
     73    // Center div in editor area
     74    pos.absLeft += Math.round((elm.firstChild.clientWidth / 2) - (width / 2));
     75    pos.absTop += Math.round((elm.firstChild.clientHeight / 2) - (height / 2));
     76
     77    url += tinyMCE.settings['imp_version'] ? (url.indexOf('?')==-1?'?':'&') + 'ver=' + tinyMCE.settings['imp_version'] : '';
     78
     79    mcWindows.open(url, mcWindows.idCounter++, "modal=yes,width=" + width+ ",height=" + height + ",resizable=" + resizable + ",scrollbars=" + scrollbars + ",statusbar=" + resizable + ",left=" + pos.absLeft + ",top=" + pos.absTop);
     80};
     81
     82TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow;
     83
     84TinyMCE_Engine.prototype.closeWindow = function(win) {
     85    if (mcWindows.selectedWindow != null)
     86        mcWindows.selectedWindow.close();
     87    else
     88        this.orgCloseWindow(win);
     89};
     90
     91TinyMCE_Engine.prototype.setWindowTitle = function(win_ref, title) {
     92    for (var n in mcWindows.windows) {
     93        var win = mcWindows.windows[n];
     94        if (typeof(win) == 'function')
     95            continue;
     96
     97        if (win_ref.name == win.id + "_iframe")
     98            window.frames[win.id + "_iframe"].document.getElementById(win.id + '_title').innerHTML = title;
     99    }
     100};
     101
     102// * * * * * TinyMCE_Windows classes below
     103
     104// Windows handler
     105function TinyMCE_Windows() {
     106    this.settings = new Array();
     107    this.windows = new Array();
     108    this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
     109    this.isGecko = navigator.userAgent.indexOf('Gecko') != -1;
     110    this.isSafari = navigator.userAgent.indexOf('Safari') != -1;
     111    this.isMac = navigator.userAgent.indexOf('Mac') != -1;
     112    this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1);
     113    this.action = "none";
     114    this.selectedWindow = null;
     115    this.lastSelectedWindow = null;
     116    this.zindex = 100;
     117    this.mouseDownScreenX = 0;
     118    this.mouseDownScreenY = 0;
     119    this.mouseDownLayerX = 0;
     120    this.mouseDownLayerY = 0;
     121    this.mouseDownWidth = 0;
     122    this.mouseDownHeight = 0;
     123    this.idCounter = 0;
     124};
     125
     126TinyMCE_Windows.prototype.init = function(settings) {
     127    this.settings = settings;
     128
     129    if (this.isMSIE)
     130        this.addEvent(document, "mousemove", mcWindows.eventDispatcher);
     131    else
     132        this.addEvent(window, "mousemove", mcWindows.eventDispatcher);
     133
     134    this.addEvent(document, "mouseup", mcWindows.eventDispatcher);
     135
     136    this.doc = document;
     137};
     138
     139TinyMCE_Windows.prototype.getParam = function(name, default_value) {
     140    var value = null;
     141
     142    value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
     143
     144    // Fix bool values
     145    if (value == "true" || value == "false")
     146        return (value == "true");
     147
     148    return value;
     149};
     150
     151TinyMCE_Windows.prototype.eventDispatcher = function(e) {
     152    e = typeof(e) == "undefined" ? window.event : e;
     153
     154    if (mcWindows.selectedWindow == null)
     155        return;
     156
     157    // Switch focus
     158    if (mcWindows.isGecko && e.type == "mousedown") {
     159        var elm = e.currentTarget;
     160
     161        for (var n in mcWindows.windows) {
     162            var win = mcWindows.windows[n];
     163
     164            if (win.headElement == elm || win.resizeElement == elm) {
     165                win.focus();
     166                break;
     167            }
     168        }
     169    }
     170
     171    switch (e.type) {
     172        case "mousemove":
     173            mcWindows.selectedWindow.onMouseMove(e);
     174            break;
     175
     176        case "mouseup":
     177            mcWindows.selectedWindow.onMouseUp(e);
     178            break;
     179
     180        case "mousedown":
     181            mcWindows.selectedWindow.onMouseDown(e);
     182            break;
     183
     184        case "focus":
     185            mcWindows.selectedWindow.onFocus(e);
     186            break;
     187    }
     188};
     189
     190TinyMCE_Windows.prototype.addEvent = function(obj, name, handler) {
     191    if (this.isMSIE)
     192        obj.attachEvent("on" + name, handler);
     193    else
     194        obj.addEventListener(name, handler, true);
     195};
     196
     197TinyMCE_Windows.prototype.cancelEvent = function(e) {
     198    if (this.isMSIE) {
     199        e.returnValue = false;
     200        e.cancelBubble = true;
     201    } else
     202        e.preventDefault();
     203};
     204
     205TinyMCE_Windows.prototype.parseFeatures = function(opts) {
     206    // Cleanup the options
     207    opts = opts.toLowerCase();
     208    opts = opts.replace(/;/g, ",");
     209    opts = opts.replace(/[^0-9a-z=,]/g, "");
     210
     211    var optionChunks = opts.split(',');
     212    var options = new Array();
     213
     214    options['left'] = "10";
     215    options['top'] = "10";
     216    options['width'] = "300";
     217    options['height'] = "300";
     218    options['resizable'] = "yes";
     219    options['minimizable'] = "yes";
     220    options['maximizable'] = "yes";
     221    options['close'] = "yes";
     222    options['movable'] = "yes";
     223    options['statusbar'] = "yes";
     224    options['scrollbars'] = "auto";
     225    options['modal'] = "no";
     226
     227    if (opts == "")
     228        return options;
     229
     230    for (var i=0; i<optionChunks.length; i++) {
     231        var parts = optionChunks[i].split('=');
     232
     233        if (parts.length == 2)
     234            options[parts[0]] = parts[1];
     235    }
     236
     237    options['left'] = parseInt(options['left']);
     238    options['top'] = parseInt(options['top']);
     239    options['width'] = parseInt(options['width']);
     240    options['height'] = parseInt(options['height']);
     241
     242    return options;
     243};
     244
     245TinyMCE_Windows.prototype.open = function(url, name, features) {
     246    this.lastSelectedWindow = this.selectedWindow;
     247
     248    var win = new TinyMCE_Window();
     249    var winDiv, html = "", id;
     250    var imgPath = this.getParam("images_path");
     251
     252    features = this.parseFeatures(features);
     253
     254    // Create div
     255    id = "mcWindow_" + name;
     256    win.deltaHeight = 18;
     257
     258    if (features['statusbar'] == "yes") {
     259        win.deltaHeight += 13;
     260
     261        if (this.isMSIE)
     262            win.deltaHeight += 1;
     263    }
     264
     265    width = parseInt(features['width']);
     266    height = parseInt(features['height'])-win.deltaHeight;
     267
     268    if (this.isMSIE)
     269        width -= 2;
     270
     271    // Setup first part of window
     272    win.id = id;
     273    win.url = url;
     274    win.name = name;
     275    win.features = features;
     276    this.windows[name] = win;
     277
     278    iframeWidth = width;
     279    iframeHeight = height;
     280
     281    // Create inner content
     282    html += '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
     283    html += '<html>';
     284    html += '<head>';
     285    html += '<title>Wrapper iframe</title>';
     286    html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
     287    html += '<link href="' + this.getParam("css_file") + '" rel="stylesheet" type="text/css" />';
     288    if ( this.isMac ) html += '<style type="text/css">.mceWindowTitle{float:none;margin:0;text-align:center;}.mceWindowClose{float:none;position:absolute;left:0px;top:0px;}</style>';
     289    html += '</head>';
     290    html += '<body onload="parent.mcWindows.onLoad(\'' + name + '\');">';
     291
     292    html += '<div id="' + id + '_container" class="mceWindow">';
     293    html += '<div id="' + id + '_head" class="mceWindowHead" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';
     294    html += '  <div id="' + id + '_title" class="mceWindowTitle"';
     295    html += '  onselectstart="return false;" unselectable="on" style="-moz-user-select: none !important;"></div>';
     296    html += '    <div class="mceWindowHeadTools">';
     297    html += '      <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].close();" target="_self" onmousedown="return false;" class="mceWindowClose"><img border="0" src="' + imgPath + '/window_close.gif" /></a>';
     298//  html += '      <a href="javascript:mcWindows.windows[\'' + name + '\'].maximize();" target="_self" onmousedown="return false;" class="mceWindowMaximize"></a>';
     299//  html += '      <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" target="_self" onmousedown="return false;" class="mceWindowMinimize"></a>';
     300    html += '    </div>';
     301    html += '</div><div id="' + id + '_body" class="mceWindowBody" style="width: ' + width + 'px; height: ' + height + 'px;">';
     302    html += '<iframe id="' + id + '_iframe" name="' + id + '_iframe" frameborder="0" width="' + iframeWidth + '" height="' + iframeHeight + '" src="' + url + '" class="mceWindowBodyIframe" scrolling="' + features['scrollbars'] + '"></iframe></div>';
     303
     304    if (features['statusbar'] == "yes") {
     305        html += '<div id="' + id + '_statusbar" class="mceWindowStatusbar" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';
     306
     307        if (features['resizable'] == "yes") {
     308            if (this.isGecko)
     309                html += '<div id="' + id + '_resize" class="mceWindowResize"><div style="background-image: url(\'' + imgPath + '/window_resize.gif\'); width: 12px; height: 12px;"></div></div>';
     310            else
     311                html += '<div id="' + id + '_resize" class="mceWindowResize"><img onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();" border="0" src="' + imgPath + '/window_resize.gif" /></div>';
     312        }
     313
     314        html += '</div>';
     315    }
     316
     317    html += '</div>';
     318
     319    html += '</body>';
     320    html += '</html>';
     321
     322    // Create iframe
     323    this.createFloatingIFrame(id, features['left'], features['top'], features['width'], features['height'], html);
     324};
     325
     326// Blocks the document events by placing a image over the whole document
     327TinyMCE_Windows.prototype.setDocumentLock = function(state) {
     328    if (state) {
     329        var elm = document.getElementById('mcWindowEventBlocker');
     330        if (elm == null) {
     331            elm = document.createElement("div");
     332
     333            elm.id = "mcWindowEventBlocker";
     334            elm.style.position = "absolute";
     335            elm.style.left = "0";
     336            elm.style.top = "0";
     337
     338            document.body.appendChild(elm);
     339        }
     340
     341        elm.style.display = "none";
     342
     343        var imgPath = this.getParam("images_path");
     344        var width = document.body.clientWidth;
     345        var height = document.body.clientHeight;
     346
     347        elm.style.width = width;
     348        elm.style.height = height;
     349        elm.innerHTML = '<img src="' + imgPath + '/spacer.gif" width="' + width + '" height="' + height + '" />';
     350
     351        elm.style.zIndex = mcWindows.zindex-1;
     352        elm.style.display = "block";
     353    } else {
     354        var elm = document.getElementById('mcWindowEventBlocker');
     355
     356        if (mcWindows.windows.length == 0)
     357            elm.parentNode.removeChild(elm);
     358        else
     359            elm.style.zIndex = mcWindows.zindex-1;
     360    }
     361};
     362
     363// Gets called when wrapper iframe is initialized
     364TinyMCE_Windows.prototype.onLoad = function(name) {
     365    var win = mcWindows.windows[name];
     366    var id = "mcWindow_" + name;
     367    var wrapperIframe = window.frames[id + "_iframe"].frames[0];
     368    var wrapperDoc = window.frames[id + "_iframe"].document;
     369    var doc = window.frames[id + "_iframe"].document;
     370    var winDiv = document.getElementById("mcWindow_" + name + "_div");
     371    var realIframe = window.frames[id + "_iframe"].frames[0];
     372
     373    // Set window data
     374    win.id = "mcWindow_" + name;
     375    win.winElement = winDiv;
     376    win.bodyElement = doc.getElementById(id + '_body');
     377    win.iframeElement = doc.getElementById(id + '_iframe');
     378    win.headElement = doc.getElementById(id + '_head');
     379    win.titleElement = doc.getElementById(id + '_title');
     380    win.resizeElement = doc.getElementById(id + '_resize');
     381    win.containerElement = doc.getElementById(id + '_container');
     382    win.left = win.features['left'];
     383    win.top = win.features['top'];
     384    win.frame = window.frames[id + '_iframe'].frames[0];
     385    win.wrapperFrame = window.frames[id + '_iframe'];
     386    win.wrapperIFrameElement = document.getElementById(id + "_iframe");
     387
     388    // Add event handlers
     389    mcWindows.addEvent(win.headElement, "mousedown", mcWindows.eventDispatcher);
     390
     391    if (win.resizeElement != null)
     392        mcWindows.addEvent(win.resizeElement, "mousedown", mcWindows.eventDispatcher);
     393
     394    if (mcWindows.isMSIE) {
     395        mcWindows.addEvent(realIframe.document, "mousemove", mcWindows.eventDispatcher);
     396        mcWindows.addEvent(realIframe.document, "mouseup", mcWindows.eventDispatcher);
     397    } else {
     398        mcWindows.addEvent(realIframe, "mousemove", mcWindows.eventDispatcher);
     399        mcWindows.addEvent(realIframe, "mouseup", mcWindows.eventDispatcher);
     400        mcWindows.addEvent(realIframe, "focus", mcWindows.eventDispatcher);
     401    }
     402
     403    for (var i=0; i<window.frames.length; i++) {
     404        if (!window.frames[i]._hasMouseHandlers) {
     405            if (mcWindows.isMSIE) {
     406                mcWindows.addEvent(window.frames[i].document, "mousemove", mcWindows.eventDispatcher);
     407                mcWindows.addEvent(window.frames[i].document, "mouseup", mcWindows.eventDispatcher);
     408            } else {
     409                mcWindows.addEvent(window.frames[i], "mousemove", mcWindows.eventDispatcher);
     410                mcWindows.addEvent(window.frames[i], "mouseup", mcWindows.eventDispatcher);
     411            }
     412
     413            window.frames[i]._hasMouseHandlers = true;
     414        }
     415    }
     416
     417    if (mcWindows.isMSIE) {
     418        mcWindows.addEvent(win.frame.document, "mousemove", mcWindows.eventDispatcher);
     419        mcWindows.addEvent(win.frame.document, "mouseup", mcWindows.eventDispatcher);
     420    } else {
     421        mcWindows.addEvent(win.frame, "mousemove", mcWindows.eventDispatcher);
     422        mcWindows.addEvent(win.frame, "mouseup", mcWindows.eventDispatcher);
     423        mcWindows.addEvent(win.frame, "focus", mcWindows.eventDispatcher);
     424    }
     425
     426    // Dispatch open window event
     427    var func = this.getParam("on_open_window", "");
     428    if (func != "")
     429        eval(func + "(win);");
     430
     431    win.focus();
     432
     433    if (win.features['modal'] == "yes")
     434        mcWindows.setDocumentLock(true);
     435};
     436
     437TinyMCE_Windows.prototype.createFloatingIFrame = function(id_prefix, left, top, width, height, html) {
     438    var iframe = document.createElement("iframe");
     439    var div = document.createElement("div");
     440
     441    width = parseInt(width);
     442    height = parseInt(height)+1;
     443
     444    // Create wrapper div
     445    div.setAttribute("id", id_prefix + "_div");
     446    div.setAttribute("width", width);
     447    div.setAttribute("height", (height));
     448    div.style.position = "absolute";
     449    div.style.left = left + "px";
     450    div.style.top = top + "px";
     451    div.style.width = width + "px";
     452    div.style.height = (height) + "px";
     453    div.style.backgroundColor = "white";
     454    div.style.display = "none";
     455
     456    if (this.isGecko) {
     457        iframeWidth = width + 2;
     458        iframeHeight = height + 2;
     459    } else {
     460        iframeWidth = width;
     461        iframeHeight = height + 1;
     462    }
     463
     464    // Create iframe
     465    iframe.setAttribute("id", id_prefix + "_iframe");
     466    iframe.setAttribute("name", id_prefix + "_iframe");
     467    iframe.setAttribute("border", "0");
     468    iframe.setAttribute("frameBorder", "0");
     469    iframe.setAttribute("marginWidth", "0");
     470    iframe.setAttribute("marginHeight", "0");
     471    iframe.setAttribute("leftMargin", "0");
     472    iframe.setAttribute("topMargin", "0");
     473    iframe.setAttribute("width", iframeWidth);
     474    iframe.setAttribute("height", iframeHeight);
     475//  iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");
     476    // iframe.setAttribute("allowtransparency", "false");
     477    iframe.setAttribute("scrolling", "no");
     478    iframe.style.width = iframeWidth + "px";
     479    iframe.style.height = iframeHeight + "px";
     480    iframe.style.backgroundColor = "white";
     481    div.appendChild(iframe);
     482
     483    document.body.appendChild(div);
     484
     485    // Fixed MSIE 5.0 issue
     486    div.innerHTML = div.innerHTML;
     487
     488    if (this.isSafari) {
     489        // Give Safari some time to setup
     490        window.setTimeout(function() {
     491            doc = window.frames[id_prefix + '_iframe'].document;
     492            doc.open();
     493            doc.write(html);
     494            doc.close();
     495        }, 10);
     496    } else {
     497        doc = window.frames[id_prefix + '_iframe'].window.document;
     498        doc.open();
     499        doc.write(html);
     500        doc.close();
     501    }
     502
     503    div.style.display = "block";
     504
     505    return div;
     506};
     507
     508// Window instance
     509function TinyMCE_Window() {
     510};
     511
     512TinyMCE_Window.prototype.focus = function() {
     513    if (this != mcWindows.selectedWindow) {
     514        this.winElement.style.zIndex = ++mcWindows.zindex;
     515        mcWindows.lastSelectedWindow = mcWindows.selectedWindow;
     516        mcWindows.selectedWindow = this;
     517    }
     518};
     519
     520TinyMCE_Window.prototype.minimize = function() {
     521};
     522
     523TinyMCE_Window.prototype.maximize = function() {
     524   
     525};
     526
     527TinyMCE_Window.prototype.startResize = function() {
     528    mcWindows.action = "resize";
     529};
     530
     531TinyMCE_Window.prototype.startMove = function(e) {
     532    mcWindows.action = "move";
     533};
     534
     535TinyMCE_Window.prototype.close = function() {
     536    if (this.frame && this.frame['tinyMCEPopup'])
     537        this.frame['tinyMCEPopup'].restoreSelection();
     538
     539    if (mcWindows.lastSelectedWindow != null)
     540        mcWindows.lastSelectedWindow.focus();
     541
     542    var mcWindowsNew = new Array();
     543    for (var n in mcWindows.windows) {
     544        var win = mcWindows.windows[n];
     545        if (typeof(win) == 'function')
     546            continue;
     547
     548        if (win.name != this.name)
     549            mcWindowsNew[n] = win;
     550    }
     551
     552    mcWindows.windows = mcWindowsNew;
     553
     554//  alert(mcWindows.doc.getElementById(this.id + "_iframe"));
     555
     556    var e = mcWindows.doc.getElementById(this.id + "_iframe");
     557    e.parentNode.removeChild(e);
     558
     559    var e = mcWindows.doc.getElementById(this.id + "_div");
     560    e.parentNode.removeChild(e);
     561
     562    mcWindows.setDocumentLock(false);
     563};
     564
     565TinyMCE_Window.prototype.onMouseMove = function(e) {
     566    var scrollX = 0;//this.doc.body.scrollLeft;
     567    var scrollY = 0;//this.doc.body.scrollTop;
     568
     569    // Calculate real X, Y
     570    var dx = e.screenX - mcWindows.mouseDownScreenX;
     571    var dy = e.screenY - mcWindows.mouseDownScreenY;
     572
     573    switch (mcWindows.action) {
     574        case "resize":
     575            width = mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX);
     576            height = mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY);
     577
     578            width = width < 100 ? 100 : width;
     579            height = height < 100 ? 100 : height;
     580
     581            this.wrapperIFrameElement.style.width = width+2;
     582            this.wrapperIFrameElement.style.height = height+2;
     583            this.wrapperIFrameElement.width = width+2;
     584            this.wrapperIFrameElement.height = height+2;
     585            this.winElement.style.width = width;
     586            this.winElement.style.height = height;
     587
     588            height = height - this.deltaHeight;
     589
     590            this.containerElement.style.width = width;
     591
     592            this.iframeElement.style.width = width;
     593            this.iframeElement.style.height = height;
     594            this.bodyElement.style.width = width;
     595            this.bodyElement.style.height = height;
     596            this.headElement.style.width = width;
     597            //this.statusElement.style.width = width;
     598
     599            mcWindows.cancelEvent(e);
     600            break;
     601
     602        case "move":
     603            this.left = mcWindows.mouseDownLayerX + (e.screenX - mcWindows.mouseDownScreenX);
     604            this.top = mcWindows.mouseDownLayerY + (e.screenY - mcWindows.mouseDownScreenY);
     605            this.winElement.style.left = this.left + "px";
     606            this.winElement.style.top = this.top + "px";
     607
     608            mcWindows.cancelEvent(e);
     609            break;
     610    }
     611};
     612
     613function debug(msg) {
     614    document.getElementById('debug').value += msg + "\n";
     615}
     616
     617TinyMCE_Window.prototype.onMouseUp = function(e) {
     618    mcWindows.action = "none";
     619};
     620
     621TinyMCE_Window.prototype.onFocus = function(e) {
     622    // Gecko only handler
     623    var winRef = e.currentTarget;
     624
     625    for (var n in mcWindows.windows) {
     626        var win = mcWindows.windows[n];
     627        if (typeof(win) == 'function')
     628            continue;
     629
     630        if (winRef.name == win.id + "_iframe") {
     631            win.focus();
     632            return;
     633        }
     634    }
     635};
     636
     637TinyMCE_Window.prototype.onMouseDown = function(e) {
     638    var elm = mcWindows.isMSIE ? this.wrapperFrame.event.srcElement : e.target;
     639
     640    var scrollX = 0;//this.doc.body.scrollLeft;
     641    var scrollY = 0;//this.doc.body.scrollTop;
     642
     643    mcWindows.mouseDownScreenX = e.screenX;
     644    mcWindows.mouseDownScreenY = e.screenY;
     645    mcWindows.mouseDownLayerX = this.left;
     646    mcWindows.mouseDownLayerY = this.top;
     647    mcWindows.mouseDownWidth = parseInt(this.winElement.style.width);
     648    mcWindows.mouseDownHeight = parseInt(this.winElement.style.height);
     649
     650    if (this.resizeElement != null && elm == this.resizeElement.firstChild)
     651        this.startResize(e);
     652    else
     653        this.startMove(e);
     654
     655    mcWindows.cancelEvent(e);
     656};
     657
     658// Global instance
     659var mcWindows = new TinyMCE_Windows();
     660
     661// Initialize windows
     662mcWindows.init({
     663    images_path : tinyMCE.baseURL + "/plugins/inlinepopups/images",
     664    css_file : tinyMCE.baseURL + "/plugins/inlinepopups/css/inlinepopup.css"
     665});
  • trunk/wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js

    r3503 r4431  
     1/**
     2 * $RCSfile: mcwindows.js,v $
     3 * $Revision: 1.2 $
     4 * $Date: 2005/10/18 13:59:43 $
     5 *
     6 * Moxiecode DHTML Windows script.
     7 *
     8 * @author Moxiecode
     9 * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.
     10 */
     11
     12// Windows handler
     13function MCWindows() {
     14    this.settings = new Array();
     15    this.windows = new Array();
     16    this.isMSIE = (navigator.appName == "Microsoft Internet Explorer");
     17    this.isGecko = navigator.userAgent.indexOf('Gecko') != -1;
     18    this.isSafari = navigator.userAgent.indexOf('Safari') != -1;
     19    this.isMac = navigator.userAgent.indexOf('Mac') != -1;
     20    this.isMSIE5_0 = this.isMSIE && (navigator.userAgent.indexOf('MSIE 5.0') != -1);
     21    this.action = "none";
     22    this.selectedWindow = null;
     23    this.zindex = 100;
     24    this.mouseDownScreenX = 0;
     25    this.mouseDownScreenY = 0;
     26    this.mouseDownLayerX = 0;
     27    this.mouseDownLayerY = 0;
     28    this.mouseDownWidth = 0;
     29    this.mouseDownHeight = 0;
     30};
     31
     32MCWindows.prototype.init = function(settings) {
     33    this.settings = settings;
     34
     35    if (this.isMSIE)
     36        this.addEvent(document, "mousemove", mcWindows.eventDispatcher);
     37    else
     38        this.addEvent(window, "mousemove", mcWindows.eventDispatcher);
     39
     40    this.addEvent(document, "mouseup", mcWindows.eventDispatcher);
     41};
     42
     43MCWindows.prototype.getParam = function(name, default_value) {
     44    var value = null;
     45
     46    value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
     47
     48    // Fix bool values
     49    if (value == "true" || value == "false")
     50        return (value == "true");
     51
     52    return value;
     53};
     54
     55MCWindows.prototype.eventDispatcher = function(e) {
     56    e = typeof(e) == "undefined" ? window.event : e;
     57
     58    if (mcWindows.selectedWindow == null)
     59        return;
     60
     61    // Switch focus
     62    if (mcWindows.isGecko && e.type == "mousedown") {
     63        var elm = e.currentTarget;
     64
     65        for (var n in mcWindows.windows) {
     66            var win = mcWindows.windows[n];
     67            if (typeof(win) == 'function')
     68                continue;
     69
     70            if (win.headElement == elm || win.resizeElement == elm) {
     71                win.focus();
     72                break;
     73            }
     74        }
     75    }
     76
     77    switch (e.type) {
     78        case "mousemove":
     79            mcWindows.selectedWindow.onMouseMove(e);
     80            break;
     81
     82        case "mouseup":
     83            mcWindows.selectedWindow.onMouseUp(e);
     84            break;
     85
     86        case "mousedown":
     87            mcWindows.selectedWindow.onMouseDown(e);
     88            break;
     89
     90        case "focus":
     91            mcWindows.selectedWindow.onFocus(e);
     92            break;
     93    }
     94}
     95
     96MCWindows.prototype.addEvent = function(obj, name, handler) {
     97    if (this.isMSIE)
     98        obj.attachEvent("on" + name, handler);
     99    else
     100        obj.addEventListener(name, handler, true);
     101};
     102
     103MCWindows.prototype.cancelEvent = function(e) {
     104    if (this.isMSIE) {
     105        e.returnValue = false;
     106        e.cancelBubble = true;
     107    } else
     108        e.preventDefault();
     109};
     110
     111MCWindows.prototype.parseFeatures = function(opts) {
     112    // Cleanup the options
     113    opts = opts.toLowerCase();
     114    opts = opts.replace(/;/g, ",");
     115    opts = opts.replace(/[^0-9a-z=,]/g, "");
     116
     117    var optionChunks = opts.split(',');
     118    var options = new Array();
     119
     120    options['left'] = 10;
     121    options['top'] = 10;
     122    options['width'] = 300;
     123    options['height'] = 300;
     124    options['resizable'] = true;
     125    options['minimizable'] = true;
     126    options['maximizable'] = true;
     127    options['close'] = true;
     128    options['movable'] = true;
     129
     130    if (opts == "")
     131        return options;
     132
     133    for (var i=0; i<optionChunks.length; i++) {
     134        var parts = optionChunks[i].split('=');
     135
     136        if (parts.length == 2)
     137            options[parts[0]] = parts[1];
     138    }
     139
     140    return options;
     141};
     142
     143MCWindows.prototype.open = function(url, name, features) {
     144    var win = new MCWindow();
     145    var winDiv, html = "", id;
     146
     147    features = this.parseFeatures(features);
     148
     149    // Create div
     150    id = "mcWindow_" + name;
     151
     152    width = parseInt(features['width']);
     153    height = parseInt(features['height'])-12-19;
     154
     155    if (this.isMSIE)
     156        width -= 2;
     157
     158    // Setup first part of window
     159    win.id = id;
     160    win.url = url;
     161    win.name = name;
     162    win.features = features;
     163    this.windows[name] = win;
     164
     165    iframeWidth = width;
     166    iframeHeight = height;
     167
     168    // Create inner content
     169    html += '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">';
     170    html += '<html>';
     171    html += '<head>';
     172    html += '<title>Wrapper iframe</title>';
     173    html += '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">';
     174    html += '<link href="../jscripts/tiny_mce/themes/advanced/css/editor_ui.css" rel="stylesheet" type="text/css" />';
     175    html += '</head>';
     176    html += '<body onload="parent.mcWindows.onLoad(\'' + name + '\');">';
     177
     178    html += '<div id="' + id + '_container" class="mceWindow">';
     179    html += '<div id="' + id + '_head" class="mceWindowHead" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';
     180    html += '  <div id="' + id + '_title" class="mceWindowTitle"';
     181    html += '  onselectstart="return false;" unselectable="on" style="-moz-user-select: none !important;">No name window</div>';
     182    html += '    <div class="mceWindowHeadTools">';
     183    html += '      <a href="javascript:parent.mcWindows.windows[\'' + name + '\'].close();" onmousedown="return false;" class="mceWindowClose"><img border="0" src="../jscripts/tiny_mce/themes/advanced/images/window_close.gif" /></a>';
     184//  html += '      <a href="javascript:mcWindows.windows[\'' + name + '\'].maximize();" onmousedown="return false;" class="mceWindowMaximize"></a>';
     185//  html += '      <a href="javascript:mcWindows.windows[\'' + name + '\'].minimize();" onmousedown="return false;" class="mceWindowMinimize"></a>';
     186    html += '    </div>';
     187    html += '</div><div id="' + id + '_body" class="mceWindowBody" style="width: ' + width + 'px; height: ' + height + 'px;">';
     188    html += '<iframe id="' + id + '_iframe" name="' + id + '_iframe" onfocus="parent.mcWindows.windows[\'' + name + '\'].focus();" frameborder="0" width="' + iframeWidth + '" height="' + iframeHeight + '" src="' + url + '" class="mceWindowBodyIframe"></iframe></div>';
     189    html += '<div id="' + id + '_statusbar" class="mceWindowStatusbar" onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();">';
     190    html += '<div id="' + id + '_resize" class="mceWindowResize"><img onmousedown="parent.mcWindows.windows[\'' + name + '\'].focus();" border="0" src="../jscripts/tiny_mce/themes/advanced/images/window_resize.gif" /></div>';
     191    html += '</div>';
     192    html += '</div>';
     193
     194    html += '</body>';
     195    html += '</html>';
     196
     197    // Create iframe
     198    this.createFloatingIFrame(id, features['left'], features['top'], features['width'], features['height'], html);
     199};
     200
     201// Gets called when wrapper iframe is initialized
     202MCWindows.prototype.onLoad = function(name) {
     203    var win = mcWindows.windows[name];
     204    var id = "mcWindow_" + name;
     205    var wrapperIframe = window.frames[id + "_iframe"].frames[0];
     206    var wrapperDoc = window.frames[id + "_iframe"].document;
     207    var doc = window.frames[id + "_iframe"].document;
     208    var winDiv = document.getElementById("mcWindow_" + name + "_div");
     209    var realIframe = window.frames[id + "_iframe"].frames[0];
     210
     211    // Set window data
     212    win.id = "mcWindow_" + name + "_iframe";
     213    win.winElement = winDiv;
     214    win.bodyElement = doc.getElementById(id + '_body');
     215    win.iframeElement = doc.getElementById(id + '_iframe');
     216    win.headElement = doc.getElementById(id + '_head');
     217    win.titleElement = doc.getElementById(id + '_title');
     218    win.resizeElement = doc.getElementById(id + '_resize');
     219    win.containerElement = doc.getElementById(id + '_container');
     220    win.left = win.features['left'];
     221    win.top = win.features['top'];
     222    win.frame = window.frames[id + '_iframe'].frames[0];
     223    win.wrapperFrame = window.frames[id + '_iframe'];
     224    win.wrapperIFrameElement = document.getElementById(id + "_iframe");
     225
     226    // Add event handlers
     227    mcWindows.addEvent(win.headElement, "mousedown", mcWindows.eventDispatcher);
     228    mcWindows.addEvent(win.resizeElement, "mousedown", mcWindows.eventDispatcher);
     229
     230    if (mcWindows.isMSIE) {
     231        mcWindows.addEvent(realIframe.document, "mousemove", mcWindows.eventDispatcher);
     232        mcWindows.addEvent(realIframe.document, "mouseup", mcWindows.eventDispatcher);
     233    } else {
     234        mcWindows.addEvent(realIframe, "mousemove", mcWindows.eventDispatcher);
     235        mcWindows.addEvent(realIframe, "mouseup", mcWindows.eventDispatcher);
     236        mcWindows.addEvent(realIframe, "focus", mcWindows.eventDispatcher);
     237    }
     238
     239    for (var i=0; i<window.frames.length; i++) {
     240        if (!window.frames[i]._hasMouseHandlers) {
     241            if (mcWindows.isMSIE) {
     242                mcWindows.addEvent(window.frames[i].document, "mousemove", mcWindows.eventDispatcher);
     243                mcWindows.addEvent(window.frames[i].document, "mouseup", mcWindows.eventDispatcher);
     244            } else {
     245                mcWindows.addEvent(window.frames[i], "mousemove", mcWindows.eventDispatcher);
     246                mcWindows.addEvent(window.frames[i], "mouseup", mcWindows.eventDispatcher);
     247            }
     248
     249            window.frames[i]._hasMouseHandlers = true;
     250        }
     251    }
     252
     253    if (mcWindows.isMSIE) {
     254        mcWindows.addEvent(win.frame.document, "mousemove", mcWindows.eventDispatcher);
     255        mcWindows.addEvent(win.frame.document, "mouseup", mcWindows.eventDispatcher);
     256    } else {
     257        mcWindows.addEvent(win.frame, "mousemove", mcWindows.eventDispatcher);
     258        mcWindows.addEvent(win.frame, "mouseup", mcWindows.eventDispatcher);
     259        mcWindows.addEvent(win.frame, "focus", mcWindows.eventDispatcher);
     260    }
     261
     262    this.selectedWindow = win;
     263};
     264
     265MCWindows.prototype.createFloatingIFrame = function(id_prefix, left, top, width, height, html) {
     266    var iframe = document.createElement("iframe");
     267    var div = document.createElement("div");
     268
     269    width = parseInt(width);
     270    height = parseInt(height)+1;
     271
     272    // Create wrapper div
     273    div.setAttribute("id", id_prefix + "_div");
     274    div.setAttribute("width", width);
     275    div.setAttribute("height", (height));
     276    div.style.position = "absolute";
     277    div.style.left = left + "px";
     278    div.style.top = top + "px";
     279    div.style.width = width + "px";
     280    div.style.height = (height) + "px";
     281    div.style.backgroundColor = "white";
     282    div.style.display = "none";
     283
     284    if (this.isGecko) {
     285        iframeWidth = width + 2;
     286        iframeHeight = height + 2;
     287    } else {
     288        iframeWidth = width;
     289        iframeHeight = height + 1;
     290    }
     291
     292    // Create iframe
     293    iframe.setAttribute("id", id_prefix + "_iframe");
     294    iframe.setAttribute("name", id_prefix + "_iframe");
     295    iframe.setAttribute("border", "0");
     296    iframe.setAttribute("frameBorder", "0");
     297    iframe.setAttribute("marginWidth", "0");
     298    iframe.setAttribute("marginHeight", "0");
     299    iframe.setAttribute("leftMargin", "0");
     300    iframe.setAttribute("topMargin", "0");
     301    iframe.setAttribute("width", iframeWidth);
     302    iframe.setAttribute("height", iframeHeight);
     303//  iframe.setAttribute("src", "../jscripts/tiny_mce/blank.htm");
     304    // iframe.setAttribute("allowtransparency", "false");
     305    iframe.setAttribute("scrolling", "no");
     306    iframe.style.width = iframeWidth + "px";
     307    iframe.style.height = iframeHeight + "px";
     308    iframe.style.backgroundColor = "white";
     309    div.appendChild(iframe);
     310
     311    document.body.appendChild(div);
     312
     313    // Fixed MSIE 5.0 issue
     314    div.innerHTML = div.innerHTML;
     315
     316    if (this.isSafari) {
     317        // Give Safari some time to setup
     318        window.setTimeout(function() {
     319            doc = window.frames[id_prefix + '_iframe'].document;
     320            doc.open();
     321            doc.write(html);
     322            doc.close();
     323        }, 10);
     324    } else {
     325        doc = window.frames[id_prefix + '_iframe'].window.document
     326        doc.open();
     327        doc.write(html);
     328        doc.close();
     329    }
     330
     331    div.style.display = "block";
     332
     333    return div;
     334};
     335
     336// Window instance
     337function MCWindow() {
     338};
     339
     340MCWindow.prototype.focus = function() {
     341    this.winElement.style.zIndex = mcWindows.zindex++;
     342    mcWindows.selectedWindow = this;
     343};
     344
     345MCWindow.prototype.minimize = function() {
     346};
     347
     348MCWindow.prototype.maximize = function() {
     349   
     350};
     351
     352MCWindow.prototype.startResize = function() {
     353    mcWindows.action = "resize";
     354};
     355
     356MCWindow.prototype.startMove = function(e) {
     357    mcWindows.action = "move";
     358};
     359
     360MCWindow.prototype.close = function() {
     361    document.body.removeChild(this.winElement);
     362    mcWindows.windows[this.name] = null;
     363};
     364
     365MCWindow.prototype.onMouseMove = function(e) {
     366    var scrollX = 0;//this.doc.body.scrollLeft;
     367    var scrollY = 0;//this.doc.body.scrollTop;
     368
     369    // Calculate real X, Y
     370    var dx = e.screenX - mcWindows.mouseDownScreenX;
     371    var dy = e.screenY - mcWindows.mouseDownScreenY;
     372
     373    switch (mcWindows.action) {
     374        case "resize":
     375            width = mcWindows.mouseDownWidth + (e.screenX - mcWindows.mouseDownScreenX);
     376            height = mcWindows.mouseDownHeight + (e.screenY - mcWindows.mouseDownScreenY);
     377
     378            width = width < 100 ? 100 : width;
     379            height = height < 100 ? 100 : height;
     380
     381            this.wrapperIFrameElement.style.width = width+2;
     382            this.wrapperIFrameElement.style.height = height+2;
     383            this.wrapperIFrameElement.width = width+2;
     384            this.wrapperIFrameElement.height = height+2;
     385            this.winElement.style.width = width;
     386            this.winElement.style.height = height;
     387
     388            height = height-12-19;
     389
     390            this.containerElement.style.width = width;
     391
     392            this.iframeElement.style.width = width;
     393            this.iframeElement.style.height = height;
     394            this.bodyElement.style.width = width;
     395            this.bodyElement.style.height = height;
     396            this.headElement.style.width = width;
     397            //this.statusElement.style.width = width;
     398
     399            mcWindows.cancelEvent(e);
     400            break;
     401
     402        case "move":
     403            this.left = mcWindows.mouseDownLayerX + (e.screenX - mcWindows.mouseDownScreenX);
     404            this.top = mcWindows.mouseDownLayerY + (e.screenY - mcWindows.mouseDownScreenY);
     405            this.winElement.style.left = this.left + "px";
     406            this.winElement.style.top = this.top + "px";
     407
     408            mcWindows.cancelEvent(e);
     409            break;
     410    }
     411};
     412
     413MCWindow.prototype.onMouseUp = function(e) {
     414    mcWindows.action = "none";
     415};
     416
     417MCWindow.prototype.onFocus = function(e) {
     418    // Gecko only handler
     419    var winRef = e.currentTarget;
     420
     421    for (var n in mcWindows.windows) {
     422        var win = mcWindows.windows[n];
     423        if (typeof(win) == 'function')
     424            continue;
     425
     426        if (winRef.name == win.id) {
     427            win.focus();
     428            return;
     429        }
     430    }
     431};
     432
     433MCWindow.prototype.onMouseDown = function(e) {
     434    var elm = mcWindows.isMSIE ? this.wrapperFrame.event.srcElement : e.target;
     435
     436    var scrollX = 0;//this.doc.body.scrollLeft;
     437    var scrollY = 0;//this.doc.body.scrollTop;
     438
     439    mcWindows.mouseDownScreenX = e.screenX;
     440    mcWindows.mouseDownScreenY = e.screenY;
     441    mcWindows.mouseDownLayerX = this.left;
     442    mcWindows.mouseDownLayerY = this.top;
     443    mcWindows.mouseDownWidth = parseInt(this.winElement.style.width);
     444    mcWindows.mouseDownHeight = parseInt(this.winElement.style.height);
     445
     446    if (elm == this.resizeElement.firstChild)
     447        this.startResize(e);
     448    else
     449        this.startMove(e);
     450
     451    mcWindows.cancelEvent(e);
     452};
     453
     454// Global instance
     455var mcWindows = new MCWindows();
  • trunk/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js

    r3503 r4431  
    11/* Import plugin specific language pack */
    2 tinyMCE.importPluginLanguagePack('wordpress', '');
    3 
    4 function TinyMCE_wordpress_initInstance(inst) {
    5     if (!tinyMCE.settings['wordpress_skip_plugin_css'])
    6         tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/plugins/wordpress/wordpress.css");
    7 }
    8 
    9 function TinyMCE_wordpress_getControlHTML(control_name) {
    10     switch (control_name) {
    11         case "wordpress":
    12             var titleMore = tinyMCE.getLang('lang_wordpress_more_button');
    13             var titlePage = tinyMCE.getLang('lang_wordpress_page_button');
    14             var titleHelp = tinyMCE.getLang('lang_wordpress_help_button');
    15             var buttons = '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\')" target="_self" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpressmore\');return false;"><img id="{$editor_id}_wordpress_more" src="{$pluginurl}/images/more.gif" title="'+titleMore+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
    16             // Add this to the buttons var to put the Page button into the toolbar.
    17             // '<a href="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\')" target="_self" onclick="javascript:tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mcewordpresspage\');return false;"><img id="{$editor_id}_wordpress_page" src="{$pluginurl}/images/page.gif" title="'+titlePage+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';
    18             return buttons;
    19     }
    20 
    21     return '';
    22 }
    23 
    24 function TinyMCE_wordpress_parseAttributes(attribute_string) {
    25     var attributeName = "";
    26     var attributeValue = "";
    27     var withInName;
    28     var withInValue;
    29     var attributes = new Array();
    30     var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
    31     var titleText = tinyMCE.getLang('lang_wordpress_more');
    32     var titleTextPage = tinyMCE.getLang('lang_wordpress_page');
    33 
    34     if (attribute_string == null || attribute_string.length < 2)
    35         return null;
    36 
    37     withInName = withInValue = false;
    38 
    39     for (var i=0; i<attribute_string.length; i++) {
    40         var chr = attribute_string.charAt(i);
    41 
    42         if ((chr == '"' || chr == "'") && !withInValue)
    43             withInValue = true;
    44         else if ((chr == '"' || chr == "'") && withInValue) {
    45             withInValue = false;
    46 
    47             var pos = attributeName.lastIndexOf(' ');
    48             if (pos != -1)
    49                 attributeName = attributeName.substring(pos+1);
    50 
    51             attributes[attributeName.toLowerCase()] = attributeValue.substring(1).toLowerCase();
    52 
    53             attributeName = "";
    54             attributeValue = "";
    55         } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)
    56             withInName = true;
    57 
    58         if (chr == '=' && withInName)
    59             withInName = false;
    60 
    61         if (withInName)
    62             attributeName += chr;
    63 
    64         if (withInValue)
    65             attributeValue += chr;
    66     }
    67 
    68     return attributes;
    69 }
    70 
    71 function TinyMCE_wordpress_execCommand(editor_id, element, command, user_interface, value) {
    72     var inst = tinyMCE.getInstanceById(editor_id);
    73     var focusElm = inst.getFocusElement();
    74     var doc = inst.getDoc();
    75 
    76     function getAttrib(elm, name) {
    77         return elm.getAttribute(name) ? elm.getAttribute(name) : "";
    78     }
    79 
    80     // Handle commands
    81     switch (command) {
    82             case "mcewordpressmore":
     2tinyMCE.importPluginLanguagePack('wordpress', 'en');
     3
     4var TinyMCE_wordpressPlugin = {
     5    getInfo : function() {
     6        return {
     7            longname : 'WordPress Plugin',
     8            author : 'WordPress',
     9            authorurl : 'http://wordpress.org',
     10            infourl : 'http://wordpress.org',
     11            version : '1'
     12        };
     13    },
     14
     15    getControlHTML : function(control_name) {
     16        switch (control_name) {
     17            case "wp_more":
     18                return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_more_button', '{$pluginurl}/images/more.gif', 'wpMore');
     19            case "wp_page":
     20                return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_page_button', '{$pluginurl}/images/page.gif', 'wpPage');
     21            case "wp_help":
     22                var buttons = tinyMCE.getButtonHTML(control_name, 'lang_help_button_title', '{$pluginurl}/images/help.gif', 'wpHelp');
     23                var hiddenControls = '<div class="zerosize">'
     24                + '<input type="button" accesskey="n" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSpellCheck\',false);" />'
     25                + '<input type="button" accesskey="k" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Strikethrough\',false);" />'
     26                + '<input type="button" accesskey="l" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'InsertUnorderedList\',false);" />'
     27                + '<input type="button" accesskey="o" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'InsertOrderedList\',false);" />'
     28                + '<input type="button" accesskey="w" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Outdent\',false);" />'
     29                + '<input type="button" accesskey="q" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Indent\',false);" />'
     30                + '<input type="button" accesskey="f" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyLeft\',false);" />'
     31                + '<input type="button" accesskey="c" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyCenter\',false);" />'
     32                + '<input type="button" accesskey="r" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyRight\',false);" />'
     33                + '<input type="button" accesskey="j" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'JustifyFull\',false);" />'
     34                + '<input type="button" accesskey="a" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceLink\',true);" />'
     35                + '<input type="button" accesskey="s" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'unlink\',false);" />'
     36                + '<input type="button" accesskey="m" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceImage\',true);" />'
     37                + '<input type="button" accesskey="t" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpMore\');" />'
     38                + '<input type="button" accesskey="g" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpPage\');" />'
     39                + '<input type="button" accesskey="u" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Undo\',false);" />'
     40                + '<input type="button" accesskey="y" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Redo\',false);" />'
     41                + '<input type="button" accesskey="h" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpHelp\',false);" />'
     42                + '<input type="button" accesskey="b" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'Bold\',false);" />'
     43                + '<input type="button" accesskey="v" onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'wpAdv\',false);" />'
     44                + '</div>';
     45                return buttons+hiddenControls;
     46            case "wp_adv":
     47                return tinyMCE.getButtonHTML(control_name, 'lang_wordpress_adv_button', '{$pluginurl}/images/toolbars.gif', 'wpAdv');
     48            case "wp_adv_start":
     49                return '<div id="wpadvbar" style="display:none;"><br />';
     50            case "wp_adv_end":
     51                return '</div>';
     52        }
     53        return '';
     54    },
     55
     56    execCommand : function(editor_id, element, command, user_interface, value) {
     57        var inst = tinyMCE.getInstanceById(editor_id);
     58        var focusElm = inst.getFocusElement();
     59        var doc = inst.getDoc();
     60
     61        function getAttrib(elm, name) {
     62            return elm.getAttribute(name) ? elm.getAttribute(name) : "";
     63        }
     64
     65        // Handle commands
     66        switch (command) {
     67            case "wpMore":
    8368                var flag = "";
    8469                var template = new Array();
     
    8873                if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
    8974                    flag = getAttrib(focusElm, 'class');
    90    
     75
    9176                    if (flag != 'mce_plugin_wordpress_more') // Not a wordpress
    9277                        return true;
    93    
     78
    9479                    action = "update";
    9580                }
    96    
     81
    9782                html = ''
    9883                    + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
    9984                    + ' width="100%" height="10px" '
    10085                    + 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
    101                 tinyMCE.execCommand("mceInsertContent",true,html);
     86                tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, html);
    10287                tinyMCE.selectedInstance.repaint();
    10388                return true;
    104             case "mcewordpresspage":
     89
     90            case "wpPage":
    10591                var flag = "";
    10692                var template = new Array();
    10793                var altPage = tinyMCE.getLang('lang_wordpress_more_alt');
    108    
     94
    10995                // Is selection a image
    11096                if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") {
    11197                    flag = getAttrib(focusElm, 'name');
    112    
     98
    11399                    if (flag != 'mce_plugin_wordpress_page') // Not a wordpress
    114100                        return true;
    115    
     101
    116102                    action = "update";
    117103                }
    118    
     104
    119105                html = ''
    120106                    + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '
     
    124110                tinyMCE.selectedInstance.repaint();
    125111                return true;
    126     }
    127 
    128     // Pass to next handler in chain
    129     return false;
     112
     113            case "wpHelp":
     114                var template = new Array();
     115
     116                template['file']   = tinyMCE.baseURL + '/wp-mce-help.php';
     117                template['width']  = 480;
     118                template['height'] = 380;
     119
     120                args = {
     121                    resizable : 'yes',
     122                    scrollbars : 'yes'
     123                };
     124
     125                tinyMCE.openWindow(template, args);
     126                return true;
     127            case "wpAdv":
     128                var adv = document.getElementById('wpadvbar');
     129                if ( adv.style.display == 'none' ) {
     130                    adv.style.display = 'block';
     131                    tinyMCE.switchClass(editor_id + '_wp_adv', 'mceButtonSelected');
     132                } else {
     133                    adv.style.display = 'none';
     134                    tinyMCE.switchClass(editor_id + '_wp_adv', 'mceButtonNormal');
     135                }
     136                return true;
     137        }
     138
     139        // Pass to next handler in chain
     140        return false;
     141    },
     142
     143    cleanup : function(type, content) {
     144        switch (type) {
     145
     146            case "insert_to_editor":
     147                var startPos = 0;
     148                var altMore = tinyMCE.getLang('lang_wordpress_more_alt');
     149                var altPage = tinyMCE.getLang('lang_wordpress_page_alt');
     150
     151                // Parse all <!--more--> tags and replace them with images
     152                while ((startPos = content.indexOf('<!--more', startPos)) != -1) {
     153                    var endPos = content.indexOf('-->', startPos) + 3;
     154                    // Insert image
     155                    var moreText = content.substring(startPos + 8, endPos - 3);
     156                    var contentAfter = content.substring(endPos);
     157                    content = content.substring(0, startPos);
     158                    content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
     159                    content += ' width="100%" height="10px" moretext="'+moreText+'" ';
     160                    content += 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />';
     161                    content += contentAfter;
     162
     163                    startPos++;
     164                }
     165                var startPos = 0;
     166
     167                // Parse all <!--page--> tags and replace them with images
     168                while ((startPos = content.indexOf('<!--nextpage-->', startPos)) != -1) {
     169                    // Insert image
     170                    var contentAfter = content.substring(startPos + 15);
     171                    content = content.substring(0, startPos);
     172                    content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
     173                    content += ' width="100%" height="10px" ';
     174                    content += 'alt="'+altPage+'" title="'+altPage+'" class="mce_plugin_wordpress_page" name="mce_plugin_wordpress_page" />';
     175                    content += contentAfter;
     176
     177                    startPos++;
     178                }
     179
     180                // Look for \n in <pre>, replace with <br>
     181                var startPos = -1;
     182                while ((startPos = content.indexOf('<pre', startPos+1)) != -1) {
     183                    var endPos = content.indexOf('</pre>', startPos+1);
     184                    var innerPos = content.indexOf('>', startPos+1);
     185                    var chunkBefore = content.substring(0, innerPos);
     186                    var chunkAfter = content.substring(endPos);
     187                   
     188                    var innards = content.substring(innerPos, endPos);
     189                    innards = innards.replace(/\n/g, '<br />');
     190                    content = chunkBefore + innards + chunkAfter;
     191                }
     192
     193                break;
     194
     195            case "get_from_editor":
     196                // Parse all img tags and replace them with <!--more-->
     197                var startPos = -1;
     198                while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
     199                    var endPos = content.indexOf('/>', startPos);
     200                    var attribs = this._parseAttributes(content.substring(startPos + 4, endPos));
     201
     202                    if (attribs['class'] == "mce_plugin_wordpress_more" || attribs['name'] == "mce_plugin_wordpress_more") {
     203                        endPos += 2;
     204
     205                        var moreText = attribs['moretext'] ? attribs['moretext'] : '';
     206                        var embedHTML = '<!--more'+moreText+'-->';
     207
     208                        // Insert embed/object chunk
     209                        chunkBefore = content.substring(0, startPos);
     210                        chunkAfter = content.substring(endPos);
     211                        content = chunkBefore + embedHTML + chunkAfter;
     212                    }
     213                    if (attribs['class'] == "mce_plugin_wordpress_page" || attribs['name'] == "mce_plugin_wordpress_page") {
     214                        endPos += 2;
     215
     216                        var embedHTML = '<!--nextpage-->';
     217
     218                        // Insert embed/object chunk
     219                        chunkBefore = content.substring(0, startPos);
     220                        chunkAfter = content.substring(endPos);
     221                        content = chunkBefore + embedHTML + chunkAfter;
     222                    }
     223                }
     224
     225                // Remove normal line breaks
     226                content = content.replace(/\n|\r/g, ' ');
     227
     228                // Look for <br> in <pre>, replace with \n
     229                var startPos = -1;
     230                while ((startPos = content.indexOf('<pre', startPos+1)) != -1) {
     231                    var endPos = content.indexOf('</pre>', startPos+1);
     232                    var innerPos = content.indexOf('>', startPos+1);
     233                    var chunkBefore = content.substring(0, innerPos);
     234                    var chunkAfter = content.substring(endPos);
     235                   
     236                    var innards = content.substring(innerPos, endPos);
     237                    innards = innards.replace(new RegExp('<br\\s?/?>', 'g'), '\n');
     238                    innards = innards.replace(new RegExp('\\s$', ''), '');
     239                    content = chunkBefore + innards + chunkAfter;
     240                }
     241
     242                // Remove anonymous, empty paragraphs.
     243                content = content.replace(new RegExp('<p>(\\s|&nbsp;)*</p>', 'mg'), '');
     244
     245                // Handle table badness.
     246                content = content.replace(new RegExp('<(table( [^>]*)?)>.*?<((tr|thead)( [^>]*)?)>', 'mg'), '<$1><$3>');
     247                content = content.replace(new RegExp('<(tr|thead|tfoot)>.*?<((td|th)( [^>]*)?)>', 'mg'), '<$1><$2>');
     248                content = content.replace(new RegExp('</(td|th)>.*?<(td( [^>]*)?|th( [^>]*)?|/tr|/thead|/tfoot)>', 'mg'), '</$1><$2>');
     249                content = content.replace(new RegExp('</tr>.*?<(tr|/table)>', 'mg'), '</tr><$1>');
     250                content = content.replace(new RegExp('<(/?(table|tbody|tr|th|td)[^>]*)>(\\s*|(<br ?/?>)*)*', 'g'), '<$1>');
     251
     252                // Pretty it up for the source editor.
     253                var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre|p';
     254                content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
     255                content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>', 'mg'), '\n<$1>');
     256                content = content.replace(new RegExp('<((li|/?tr|/?thead|/?tfoot)( [^>]*)?)>', 'g'), '\t<$1>');
     257                content = content.replace(new RegExp('<((td|th)( [^>]*)?)>', 'g'), '\t\t<$1>');
     258                content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'mg'), '<br />\n');
     259                content = content.replace(new RegExp('^\\s*', ''), '');
     260                content = content.replace(new RegExp('\\s*$', ''), '');
     261
     262                break;
     263        }
     264
     265        // Pass through to next handler in chain
     266        return content;
     267    },
     268
     269    handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
     270
     271        tinyMCE.switchClass(editor_id + '_wp_more', 'mceButtonNormal');
     272        tinyMCE.switchClass(editor_id + '_wp_page', 'mceButtonNormal');
     273
     274        if (node == null)
     275            return;
     276
     277        do {
     278            if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0)
     279                tinyMCE.switchClass(editor_id + '_wp_more', 'mceButtonSelected');
     280            if (node.nodeName.toLowerCase() == "img" && tinyMCE.getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0)
     281                tinyMCE.switchClass(editor_id + '_wp_page', 'mceButtonSelected');
     282        } while ((node = node.parentNode));
     283
     284        return true;
     285    },
     286
     287    saveCallback : function(el, content, body) {
     288        // We have a TON of cleanup to do.
     289
     290        // Mark </p> if it has any attributes.
     291        content = content.replace(new RegExp('(<p[^>]+>.*?)</p>', 'mg'), '$1</p#>');
     292
     293        // Decode the ampersands of time.
     294        // content = content.replace(new RegExp('&amp;', 'g'), '&');
     295
     296        // Get it ready for wpautop.
     297        content = content.replace(new RegExp('\\s*<p>', 'mgi'), '');
     298        content = content.replace(new RegExp('\\s*</p>\\s*', 'mgi'), '\n\n');
     299        content = content.replace(new RegExp('\\n\\s*\\n', 'mgi'), '\n\n');
     300        content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
     301
     302        // Fix some block element newline issues
     303        var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre';
     304        content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
     305        content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
     306        content = content.replace(new RegExp('<li>', 'g'), '\t<li>');
     307
     308        // Unmark special paragraph closing tags
     309        content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
     310        content = content.replace(new RegExp('\\s*(<p[^>]+>.*</p>)', 'mg'), '\n$1');
     311
     312        // Trim trailing whitespace
     313        content = content.replace(new RegExp('\\s*$', ''), '');
     314
     315        // Hope.
     316        return content;
     317
     318    },
     319
     320    _parseAttributes : function(attribute_string) {
     321        var attributeName = "";
     322        var attributeValue = "";
     323        var withInName;
     324        var withInValue;
     325        var attributes = new Array();
     326        var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
     327        var titleText = tinyMCE.getLang('lang_wordpress_more');
     328        var titleTextPage = tinyMCE.getLang('lang_wordpress_page');
     329
     330        if (attribute_string == null || attribute_string.length < 2)
     331            return null;
     332
     333        withInName = withInValue = false;
     334
     335        for (var i=0; i<attribute_string.length; i++) {
     336            var chr = attribute_string.charAt(i);
     337
     338            if ((chr == '"' || chr == "'") && !withInValue)
     339                withInValue = true;
     340            else if ((chr == '"' || chr == "'") && withInValue) {
     341                withInValue = false;
     342
     343                var pos = attributeName.lastIndexOf(' ');
     344                if (pos != -1)
     345                    attributeName = attributeName.substring(pos+1);
     346
     347                attributes[attributeName.toLowerCase()] = attributeValue.substring(1);
     348
     349                attributeName = "";
     350                attributeValue = "";
     351            } else if (!whiteSpaceRegExp.test(chr) && !withInName && !withInValue)
     352                withInName = true;
     353
     354            if (chr == '=' && withInName)
     355                withInName = false;
     356
     357            if (withInName)
     358                attributeName += chr;
     359
     360            if (withInValue)
     361                attributeValue += chr;
     362        }
     363
     364        return attributes;
     365    }
     366};
     367
     368tinyMCE.addPlugin("wordpress", TinyMCE_wordpressPlugin);
     369
     370/* This little hack protects our More and Page placeholders from the removeformat command */
     371tinyMCE.orgExecCommand = tinyMCE.execCommand;
     372tinyMCE.execCommand = function (command, user_interface, value) {
     373    re = this.orgExecCommand(command, user_interface, value);
     374
     375    if ( command == 'removeformat' ) {
     376        var inst = tinyMCE.getInstanceById('mce_editor_0');
     377        doc = inst.getDoc();
     378        var imgs = doc.getElementsByTagName('img');
     379        for (i=0;img=imgs[i];i++)
     380            img.className = img.name;
     381    }
     382    return re;
     383};
     384wpInstTriggerSave = function (skip_cleanup, skip_callback) {
     385    var e, nl = new Array(), i, s;
     386
     387    this.switchSettings();
     388    s = tinyMCE.settings;
     389
     390    // Force hidden tabs visible while serializing
     391    if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
     392        e = this.iframeElement;
     393
     394        do {
     395            if (e.style && e.style.display == 'none') {
     396                e.style.display = 'block';
     397                nl[nl.length] = {elm : e, type : 'style'};
     398            }
     399
     400            if (e.style && s.hidden_tab_class.length > 0 && e.className.indexOf(s.hidden_tab_class) != -1) {
     401                e.className = s.display_tab_class;
     402                nl[nl.length] = {elm : e, type : 'class'};
     403            }
     404        } while ((e = e.parentNode) != null)
     405    }
     406
     407    tinyMCE.settings['preformatted'] = false;
     408
     409    // Default to false
     410    if (typeof(skip_cleanup) == "undefined")
     411        skip_cleanup = false;
     412
     413    // Default to false
     414    if (typeof(skip_callback) == "undefined")
     415        skip_callback = false;
     416
     417//  tinyMCE._setHTML(this.getDoc(), this.getBody().innerHTML);
     418
     419    // Remove visual aids when cleanup is disabled
     420    if (this.settings['cleanup'] == false) {
     421        tinyMCE.handleVisualAid(this.getBody(), true, false, this);
     422        tinyMCE._setEventsEnabled(this.getBody(), true);
     423    }
     424
     425    tinyMCE._customCleanup(this, "submit_content_dom", this.contentWindow.document.body);
     426    tinyMCE.selectedInstance.getWin().oldfocus=tinyMCE.selectedInstance.getWin().focus;
     427    tinyMCE.selectedInstance.getWin().focus=function() {};
     428    var htm = tinyMCE._cleanupHTML(this, this.getDoc(), this.settings, this.getBody(), tinyMCE.visualAid, true, true);
     429    tinyMCE.selectedInstance.getWin().focus=tinyMCE.selectedInstance.getWin().oldfocus;
     430    htm = tinyMCE._customCleanup(this, "submit_content", htm);
     431
     432    if (!skip_callback && tinyMCE.settings['save_callback'] != "")
     433        var content = eval(tinyMCE.settings['save_callback'] + "(this.formTargetElementId,htm,this.getBody());");
     434
     435    // Use callback content if available
     436    if ((typeof(content) != "undefined") && content != null)
     437        htm = content;
     438
     439    // Replace some weird entities (Bug: #1056343)
     440    htm = tinyMCE.regexpReplace(htm, "&#40;", "(", "gi");
     441    htm = tinyMCE.regexpReplace(htm, "&#41;", ")", "gi");
     442    htm = tinyMCE.regexpReplace(htm, "&#59;", ";", "gi");
     443    htm = tinyMCE.regexpReplace(htm, "&#34;", "&quot;", "gi");
     444    htm = tinyMCE.regexpReplace(htm, "&#94;", "^", "gi");
     445
     446    if (this.formElement)
     447        this.formElement.value = htm;
     448
     449    if (tinyMCE.isSafari && this.formElement)
     450        this.formElement.innerText = htm;
     451
     452    // Hide them again (tabs in MSIE)
     453    for (i=0; i<nl.length; i++) {
     454        if (nl[i].type == 'style')
     455            nl[i].elm.style.display = 'none';
     456        else
     457            nl[i].elm.className = s.hidden_tab_class;
     458    }
    130459}
    131 
    132 function TinyMCE_wordpress_cleanup(type, content) {
    133     switch (type) {
    134    
    135         case "insert_to_editor":
    136             var startPos = 0;
    137             var altMore = tinyMCE.getLang('lang_wordpress_more_alt');
    138             var altPage = tinyMCE.getLang('lang_wordpress_page_alt');
    139 
    140             // Parse all <!--more--> tags and replace them with images
    141             while ((startPos = content.indexOf('<!--more-->', startPos)) != -1) {
    142                 // Insert image
    143                 var contentAfter = content.substring(startPos + 11);
    144                 content = content.substring(0, startPos);
    145                 content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
    146                 content += ' width="100%" height="10px" ';
    147                 content += 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" />';
    148                 content += contentAfter;
    149 
    150                 startPos++;
    151             }
    152             var startPos = 0;
    153 
    154             // Parse all <!--page--> tags and replace them with images
    155             while ((startPos = content.indexOf('<!--nextpage-->', startPos)) != -1) {
    156                 // Insert image
    157                 var contentAfter = content.substring(startPos + 15);
    158                 content = content.substring(0, startPos);
    159                 content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ';
    160                 content += ' width="100%" height="10px" ';
    161                 content += 'alt="'+altPage+'" title="'+altPage+'" class="mce_plugin_wordpress_page" />';
    162                 content += contentAfter;
    163 
    164                 startPos++;
    165             }
    166 
    167             // It's supposed to be WYSIWYG, right?
    168             content = content.replace(new RegExp('&', 'g'), '&amp;');
    169 
    170             break;
    171 
    172         case "get_from_editor":
    173             // Parse all img tags and replace them with <!--more-->
    174             var startPos = -1;
    175             while ((startPos = content.indexOf('<img', startPos+1)) != -1) {
    176                 var endPos = content.indexOf('/>', startPos);
    177                 var attribs = TinyMCE_wordpress_parseAttributes(content.substring(startPos + 4, endPos));
    178 
    179                 if (attribs['class'] == "mce_plugin_wordpress_more") {
    180                     endPos += 2;
    181    
    182                     var embedHTML = '<!--more-->';
    183    
    184                     // Insert embed/object chunk
    185                     chunkBefore = content.substring(0, startPos);
    186                     chunkAfter = content.substring(endPos);
    187                     content = chunkBefore + embedHTML + chunkAfter;
    188                 }
    189                 if (attribs['class'] == "mce_plugin_wordpress_page") {
    190                     endPos += 2;
    191    
    192                     var embedHTML = '<!--nextpage-->';
    193    
    194                     // Insert embed/object chunk
    195                     chunkBefore = content.substring(0, startPos);
    196                     chunkAfter = content.substring(endPos);
    197                     content = chunkBefore + embedHTML + chunkAfter;
    198                 }
    199             }
    200 
    201             // If it says & in the WYSIWYG editor, it should say &amp; in the html.
    202             content = content.replace(new RegExp('&', 'g'), '&amp;');
    203             content = content.replace(new RegExp('&amp;nbsp;', 'g'), '&nbsp;');
    204 
    205             // Remove anonymous, empty paragraphs.
    206             content = content.replace(new RegExp('<p>(\\s|&nbsp;)*</p>', 'mg'), '');
    207 
    208             // Handle table badness.
    209             content = content.replace(new RegExp('<(table( [^>]*)?)>.*?<((tr|thead)( [^>]*)?)>', 'mg'), '<$1><$3>');
    210             content = content.replace(new RegExp('<(tr|thead|tfoot)>.*?<((td|th)( [^>]*)?)>', 'mg'), '<$1><$2>');
    211             content = content.replace(new RegExp('</(td|th)>.*?<(td( [^>]*)?|th( [^>]*)?|/tr|/thead|/tfoot)>', 'mg'), '</$1><$2>');
    212             content = content.replace(new RegExp('</tr>.*?<(tr|/table)>', 'mg'), '</tr><$1>');
    213             content = content.replace(new RegExp('<(/?(table|tbody|tr|th|td)[^>]*)>(\\s*|(<br ?/?>)*)*', 'g'), '<$1>');
    214 
    215             // Pretty it up for the source editor.
    216             var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre|p';
    217             content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
    218             content = content.replace(new RegExp('\\s*<(('+blocklist+')[^>]*)>\\s*', 'mg'), '\n<$1>');
    219             content = content.replace(new RegExp('<((li|/?tr|/?thead|/?tfoot)( [^>]*)?)>', 'g'), '\t<$1>');
    220             content = content.replace(new RegExp('<((td|th)( [^>]*)?)>', 'g'), '\t\t<$1>');
    221             content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'mg'), '<br />\n');
    222             content = content.replace(new RegExp('^\\s*', ''), '');
    223             content = content.replace(new RegExp('\\s*$', ''), '');
    224            
    225             break;
    226     }
    227 
    228     // Pass through to next handler in chain
    229     return content;
     460tinyMCE.wpTriggerSave = function () {
     461    var inst, n;
     462    for (n in tinyMCE.instances) {
     463        inst = tinyMCE.instances[n];
     464        if (!tinyMCE.isInstance(inst))
     465            continue;
     466        inst.wpTriggerSave = wpInstTriggerSave;
     467        inst.wpTriggerSave(false, false);
     468    }
    230469}
    231470
    232 function TinyMCE_wordpress_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) {
    233     function getAttrib(elm, name) {
    234         return elm.getAttribute(name) ? elm.getAttribute(name) : "";
    235     }
    236 
    237     tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonNormal');
    238     tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonNormal');
    239 
    240     if (node == null)
    241         return;
    242 
    243     do {
    244         if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_more') == 0)
    245             tinyMCE.switchClassSticky(editor_id + '_wordpress_more', 'mceButtonSelected');
    246         if (node.nodeName.toLowerCase() == "img" && getAttrib(node, 'class').indexOf('mce_plugin_wordpress_page') == 0)
    247             tinyMCE.switchClassSticky(editor_id + '_wordpress_page', 'mceButtonSelected');
    248     } while ((node = node.parentNode));
    249 
    250     return true;
     471function switchEditors(id) {
     472    var inst = tinyMCE.getInstanceById(id);
     473    var qt = document.getElementById('quicktags');
     474    var H = document.getElementById('edButtonHTML');
     475    var P = document.getElementById('edButtonPreview');
     476    var ta = document.getElementById(id);
     477    var pdr = ta.parentNode;
     478
     479    if ( inst ) {
     480        edToggle(H, P);
     481
     482        if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) {
     483            // IE rejects the later overflow assignment so we skip this step.
     484            // Alternate code might be nice. Until then, IE reflows.
     485        } else {
     486            // Lock the fieldset's height to prevent reflow/flicker
     487            pdr.style.height = pdr.clientHeight + 'px';
     488            pdr.style.overflow = 'hidden';
     489        }
     490
     491        // Save the coords of the bottom right corner of the rich editor
     492        var table = document.getElementById(inst.editorId + '_parent').getElementsByTagName('table')[0];
     493        var y1 = table.offsetTop + table.offsetHeight;
     494
     495        if ( TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_height") == null ) {
     496            var expires = new Date();
     497            expires.setTime(expires.getTime() + 3600000 * 24 * 30);
     498            var offset = tinyMCE.isMSIE ? 1 : 2;
     499            TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + inst.editorId + "_height", "" + (table.offsetHeight - offset), expires);
     500        }
     501
     502        // Unload the rich editor
     503        inst.triggerSave(false, false);
     504        htm = inst.formElement.value;
     505        tinyMCE.removeMCEControl(id);
     506        document.getElementById(id).value = htm;
     507        --tinyMCE.idCounter;
     508
     509        // Reveal Quicktags and textarea
     510        qt.style.display = 'block';
     511        ta.style.display = 'inline';
     512
     513        // Set the textarea height to match the rich editor
     514        y2 = ta.offsetTop + ta.offsetHeight;
     515        ta.style.height = (ta.clientHeight + y1 - y2) + 'px';
     516
     517        // Tweak the widths
     518        ta.parentNode.style.paddingRight = '2px';
     519
     520        if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) {
     521        } else {
     522            // Unlock the fieldset's height
     523            pdr.style.height = 'auto';
     524            pdr.style.overflow = 'display';
     525        }
     526    } else {
     527        edToggle(P, H);
     528        edCloseAllTags(); // :-(
     529
     530        if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) {
     531        } else {
     532            // Lock the fieldset's height
     533            pdr.style.height = pdr.clientHeight + 'px';
     534            pdr.style.overflow = 'hidden';
     535        }
     536
     537        // Hide Quicktags and textarea
     538        qt.style.display = 'none';
     539        ta.style.display = 'none';
     540
     541        // Tweak the widths
     542        ta.parentNode.style.paddingRight = '0px';
     543
     544        // Load the rich editor with formatted html
     545        if ( tinyMCE.isMSIE ) {
     546            ta.value = wpautop(ta.value);
     547            tinyMCE.addMCEControl(ta, id);
     548        } else {
     549            htm = wpautop(ta.value);
     550            tinyMCE.addMCEControl(ta, id);
     551            tinyMCE.getInstanceById(id).execCommand('mceSetContent', null, htm);
     552        }
     553
     554        if ( tinyMCE.isMSIE && !tinyMCE.isOpera ) {
     555        } else {
     556            // Unlock the fieldset's height
     557            pdr.style.height = 'auto';
     558            pdr.style.overflow = 'display';
     559        }
     560    }
    251561}
    252562
    253 function wp_save_callback(el, content, body) {
    254     // We have a TON of cleanup to do.
    255 
    256     // Mark </p> if it has any attributes.
    257     content = content.replace(new RegExp('(<p[^>]+>.*?)</p>', 'mg'), '$1</p#>');
    258 
    259     // Decode the ampersands of time.
    260     content = content.replace(new RegExp('&amp;', 'g'), '&');
    261 
    262     // Get it ready for wpautop.
    263     content = content.replace(new RegExp('[\\s]*<p>[\\s]*', 'mgi'), '');
    264     content = content.replace(new RegExp('[\\s]*</p>[\\s]*', 'mgi'), '\n\n');
    265     content = content.replace(new RegExp('\\n\\s*\\n\\s*\\n*', 'mgi'), '\n\n');
    266     content = content.replace(new RegExp('\\s*<br ?/?>\\s*', 'gi'), '\n');
    267 
    268     // Fix some block element newline issues
    269     var blocklist = 'blockquote|ul|ol|li|table|thead|tr|th|td|div|h\\d|pre';
    270     content = content.replace(new RegExp('\\s*<(('+blocklist+') ?[^>]*)\\s*>', 'mg'), '\n<$1>');
    271     content = content.replace(new RegExp('\\s*</('+blocklist+')>\\s*', 'mg'), '</$1>\n');
    272     content = content.replace(new RegExp('<li>', 'g'), '\t<li>');
    273 
    274     // Unmark special paragraph closing tags
    275     content = content.replace(new RegExp('</p#>', 'g'), '</p>\n');
    276     content = content.replace(new RegExp('\\s*(<p[^>]+>.*</p>)', 'mg'), '\n$1');
    277 
    278     // Trim any whitespace
    279     content = content.replace(new RegExp('^\\s*', ''), '');
    280     content = content.replace(new RegExp('\\s*$', ''), '');
    281 
    282     // Hope.
    283     return content;
    284 
     563function edToggle(A, B) {
     564    A.className = 'edButtonFore';
     565    B.className = 'edButtonBack';
     566
     567    B.onclick = A.onclick;
     568    A.onclick = null;
    285569}
     570
     571function wpautop(pee) {
     572    pee = pee + "\n\n";
     573    pee = pee.replace(new RegExp('<br />\\s*<br />', 'gi'), "\n\n");
     574    pee = pee.replace(new RegExp('(<(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)', 'gi'), "\n$1");
     575    pee = pee.replace(new RegExp('(</(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])>)', 'gi'), "$1\n\n");
     576    pee = pee.replace(new RegExp("\\r\\n|\\r", 'g'), "\n");
     577    pee = pee.replace(new RegExp("\\n\\s*\\n+", 'g'), "\n\n");
     578    pee = pee.replace(new RegExp('\n*([^\Z]+?)\\n{2}', 'mg'), "<p>$1</p>\n");
     579    pee = pee.replace(new RegExp('<p>\\s*?</p>', 'gi'), '');
     580    pee = pee.replace(new RegExp('<p>\\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\\s*</p>', 'gi'), "$1");
     581    pee = pee.replace(new RegExp("<p>(<li.+?)</p>", 'gi'), "$1");
     582    pee = pee.replace(new RegExp('<p><blockquote([^>]*)>', 'gi'), "<blockquote$1><p>");
     583    pee = pee.replace(new RegExp('</blockquote></p>', 'gi'), '</p></blockquote>');
     584    pee = pee.replace(new RegExp('<p>\\s*(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|hr|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)', 'gi'), "$1");
     585    pee = pee.replace(new RegExp('(</?(?:table|thead|tfoot|caption|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\\s*</p>', 'gi'), "$1");
     586    pee = pee.replace(new RegExp('\\s*\\n', 'gi'), "<br />\n");
     587    pee = pee.replace(new RegExp('(</?(?:table|thead|tfoot|caption|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|blockquote|address|math|p|h[1-6])[^>]*>)\\s*<br />', 'gi'), "$1");
     588    pee = pee.replace(new RegExp('<br />(\\s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)>)', 'gi'), '$1');
     589    pee = pee.replace(new RegExp('^((?:&nbsp;)*)\\s', 'mg'), '$1&nbsp;');
     590    //pee = pee.replace(new RegExp('(<pre.*?>)(.*?)</pre>!ise', " stripslashes('$1') .  stripslashes(clean_pre('$2'))  . '</pre>' "); // Hmm...
     591    return pee;
     592}
  • trunk/wp-includes/js/tinymce/plugins/wordpress/langs/en.js

    r3503 r4431  
    11// EN lang variables
    22
     3if (navigator.userAgent.indexOf('Mac OS') != -1) {
     4// Mac OS browsers use Ctrl to hit accesskeys
     5    var metaKey = 'Ctrl';
     6}
     7else {
     8    var metaKey = 'Alt';
     9}
     10
    311tinyMCE.addToLang('',{
    4 wordpress_more_button : 'Split post with More tag (Alt-t)',
     12wordpress_more_button : 'Split post with More tag (' + metaKey + '+t)',
    513wordpress_page_button : 'Split post with Page tag',
     14wordpress_adv_button : 'Show/Hide Advanced Toolbar (' + metaKey + '+b)',
    615wordpress_more_alt : 'More...',
    7 wordpress_page_alt : '...page...'
     16wordpress_page_alt : '...page...',
     17help_button_title : 'Help (' + metaKey + '+h)',
     18bold_desc : 'Bold (Ctrl+B)',
     19italic_desc : 'Italic (Ctrl+I)',
     20underline_desc : 'Underline (Ctrl+U)',
     21link_desc : 'Insert/edit link (' + metaKey + '+a)',
     22unlink_desc : 'Unlink (' + metaKey + '+s)',
     23image_desc : 'Insert/edit image (' + metaKey + '+m)',
     24striketrough_desc : 'Strikethrough (' + metaKey + '+k)',
     25justifyleft_desc : 'Align left (' + metaKey + '+f)',
     26justifycenter_desc : 'Align center (' + metaKey + '+c)',
     27justifyright_desc : 'Align right (' + metaKey + '+r)',
     28justifyfull_desc : 'Align full (' + metaKey + '+j)',
     29bullist_desc : 'Unordered list (' + metaKey + '+l)',
     30numlist_desc : 'Ordered list (' + metaKey + '+o)',
     31outdent_desc : 'Outdent (' + metaKey + '+w)',
     32indent_desc : 'Indent List/Blockquote (' + metaKey + '+q)'
    833});
  • trunk/wp-includes/js/tinymce/plugins/wordpress/wordpress.css

    r3503 r4431  
    2020    background-position: right top;
    2121}
     22
     23/* This file contains the CSS data for the editable area(iframe) of TinyMCE */
     24/* You can extend this CSS by adding your own CSS file with the the content_css option */
     25
     26body {
     27    background: #fff;
     28    font: 1em/1.3em Georgia, "Times New Roman", Times, serif;
     29    padding: .5em;
     30}
     31
     32td {
     33    font-size: 10px;
     34}
     35
     36pre {
     37    font-family: "Courier New", fixed;
     38    font-size: 11px;
     39    line-height: 13px;
     40}
     41
     42.mceVisualAid {
     43    border: 1px dashed #BBBBBB !important;
     44}
     45
     46.mceItemAnchor {
     47    width: 12px;
     48    line-height: 6px;
     49    overflow: hidden;
     50    padding-left: 12px;
     51    background-image: url('../images/anchor_symbol.gif');
     52    background-position: bottom;
     53    background-repeat: no-repeat;
     54}
     55
     56/* Important is needed in Gecko browsers inorder to style links */
     57/*
     58a {
     59    color: green !important;
     60}
     61*/
     62
     63/* Style selection range colors in Gecko browsers */
     64/*
     65::-moz-selection {
     66    background-color: red;
     67    color: green;
     68}
     69*/
     70
     71/* MSIE specific */
     72
     73* html body {
     74    scrollbar-3dlight-color: #F0F0EE;
     75    scrollbar-arrow-color: #676662;
     76    scrollbar-base-color: #F0F0EE;
     77    scrollbar-darkshadow-color: #DDDDDD;
     78    scrollbar-face-color: #E0E0DD;
     79    scrollbar-highlight-color: #F0F0EE;
     80    scrollbar-shadow-color: #F0F0EE;
     81    scrollbar-track-color: #F5F5F5;
     82}
  • trunk/wp-includes/js/tinymce/themes/advanced/about.htm

    r3503 r4431  
    55    <script language="javascript" type="text/javascript" src="../../utils/mctabs.js"></script>
    66    <script language="javascript" type="text/javascript" src="jscripts/about.js"></script>
    7     <link href="css/dialog_about.css" rel="stylesheet" type="text/css" />
     7    <base target="_self" />
    88</head>
    99<body id="about" onload="tinyMCEPopup.executeOnLoad('init();');" style="display: none">
     
    2222                <p>TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under <a href="../../license.txt" target="_blank">LGPL</a>
    2323                by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances.</p>
    24                 <p>Copyright &copy; 2005, <a href="http://www.moxiecode.com" target="_blank">Moxiecode Systems AB</a>, All rights reserved.</p>
     24                <p>Copyright &copy; 2003-2006, <a href="http://www.moxiecode.com" target="_blank">Moxiecode Systems AB</a>, All rights reserved.</p>
    2525                <p>For more information about this software visit the <a href="http://tinymce.moxiecode.com" target="_blank">TinyMCE website</a>.</p>
    2626
  • trunk/wp-includes/js/tinymce/themes/advanced/anchor.htm

    r3503 r4431  
    44    <script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
    55    <script language="javascript" type="text/javascript" src="jscripts/anchor.js"></script>
     6    <base target="_self" />
    67</head>
    78<body onload="tinyMCEPopup.executeOnLoad('init();');" style="display: none">
  • trunk/wp-includes/js/tinymce/themes/advanced/charmap.htm

    r3503 r4431  
    55    <script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
    66    <script language="javascript" type="text/javascript" src="jscripts/charmap.js"></script>
     7    <base target="_self" />
    78</head>
    8 <body onload="tinyMCEPopup.executeOnLoad('init();');" style="display: none">
     9<body onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('insert').focus();" style="display: none">
    910<table align="center" border="0" cellspacing="0" cellpadding="2">
    1011    <tr>
  • trunk/wp-includes/js/tinymce/themes/advanced/color_picker.htm

    r3503 r4431  
    44    <script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
    55    <script language="javascript" type="text/javascript" src="jscripts/color_picker.js"></script>
     6    <base target="_self" />
    67</head>
    7 <body onload="tinyMCEPopup.executeOnLoad('init();');" marginheight="3" topmargin="3" leftmargin="3" marginwidth="3" style="display: none">
     8<body onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('insert').focus();" style="margin: 3px; display: none">
    89    <div align="center">
    910       <script language="javascript" type="text/javascript">renderColorMap();</script>
  • trunk/wp-includes/js/tinymce/themes/advanced/css/editor_content.css

    r3503 r4431  
    22/* You can extend this CSS by adding your own CSS file with the the content_css option */
    33
    4 body {
    5     background-color: #FFFFFF;
    6     font-family: Verdana, Arial, Helvetica, sans-serif;
    7     font-size: 0.9em;
    8     line-height: 1.2em;
    9     padding: .3em;
    10 }
    11 
    12 td {
     4body, td, pre {
    135    font-family: Verdana, Arial, Helvetica, sans-serif;
    146    font-size: 10px;
    157}
    168
    17 pre {
    18     font-family: Verdana, Arial, Helvetica, sans-serif;
    19     font-size: 10px;
     9body {
     10    background-color: #FFFFFF;
    2011}
    2112
     
    4839}
    4940*/
     41
     42/* MSIE specific */
     43
     44* html body {
     45    scrollbar-3dlight-color: #F0F0EE;
     46    scrollbar-arrow-color: #676662;
     47    scrollbar-base-color: #F0F0EE;
     48    scrollbar-darkshadow-color: #DDDDDD;
     49    scrollbar-face-color: #E0E0DD;
     50    scrollbar-highlight-color: #F0F0EE;
     51    scrollbar-shadow-color: #F0F0EE;
     52    scrollbar-track-color: #F5F5F5;
     53}
  • trunk/wp-includes/js/tinymce/themes/advanced/css/editor_popup.css

    r3503 r4431  
    3636
    3737.input_noborder {
    38     border: 0px solid #808080;
    39 }
    40 
    41 #insert {
     38    border: 0;
     39}
     40
     41#insert, .updateButton {
    4242   font-weight: bold;
    4343   width: 90px;
    4444   height: 21px;
    45    border: 0px;
     45   border: 0;
    4646   background-image: url('../images/insert_button_bg.gif');
    4747   cursor: pointer;
     
    5252   width: 90px;
    5353   height: 21px;
    54    border: 0px;
     54   border: 0;
    5555   background-image: url('../images/cancel_button_bg.gif');
    5656   cursor: pointer;
     
    8585td.charmapOver {
    8686    background-color: #CCCCCC;
    87     cursor: arrow;
     87    cursor: default;
    8888}
    8989
     
    121121    border-right: 1px solid;
    122122    border-color: #F0F0EE;
    123     cursor: arrow;
     123    cursor: default;
    124124}
    125125
    126126.mceButtonOver {
    127127    border: 1px solid #0A246A;
    128     cursor: arrow;
     128    cursor: default;
    129129    background-color: #B6BDD2;
    130130}
    131131
    132132.mceButtonDown {
    133     cursor: arrow;
     133    cursor: default;
    134134    border: 1px solid #0A246A;
    135135    background-color: #8592B5;
     
    145145    border-right: 1px solid;
    146146    border-color: #F0F0EE;
    147     cursor: arrow;
     147    cursor: default;
    148148}
    149149
     
    163163.tabs ul {
    164164    margin: 0;
    165     padding: 0px 0px 0;
     165    padding: 0 0 0;
    166166    list-style: none;
    167167}
     
    171171    background: url("../images/xp/tab_bg.gif") no-repeat left top;
    172172    margin: 0;
    173     margin-left: 0px;
     173    margin-left: 0;
    174174    margin-right: 2px;
    175175    padding: 0 0 0 10px;
     
    186186    display: block;
    187187    background: url("../images/xp/tab_end.gif") no-repeat right top;
    188     padding: 0px 10px 0px 0px;
     188    padding: 0px 10px 0 0;
    189189}
    190190
     
    236236    font-family: Verdana, Arial;
    237237    font-size: 10px;
    238     padding: 0px;
    239     margin: 0px;
     238    padding: 0;
     239    margin: 0;
    240240    padding: 4px;
    241241}
     
    296296h1, h2, h3, h4 {
    297297    color: #2B6FB6;
    298     margin: 0px;
    299     padding: 0px;
     298    margin: 0;
     299    padding: 0;
    300300    padding-top: 5px;
    301301}
     
    303303h3 {
    304304    font-size: 14px;
     305}
     306
     307#link .panel_wrapper, #link div.current {
     308    height: 125px;
     309}
     310
     311#image .panel_wrapper, #image div.current {
     312    height: 190px;
    305313}
    306314
     
    318326}
    319327*/
     328
     329/* Below this line is WordPress customizations */
     330#insert, #cancel, .submitbutton {
     331    font: 11px Verdana, Arial, Helvetica, sans-serif;
     332    height: auto;
     333    width: auto;
     334    background-color: transparent;
     335    background-image: url(../../../../../../wp-admin/images/fade-butt.png);
     336    background-repeat: repeat;
     337    border: 3px double;
     338    border-right-color: rgb(153, 153, 153);
     339    border-bottom-color: rgb(153, 153, 153);
     340    border-left-color: rgb(204, 204, 204);
     341    border-top-color: rgb(204, 204, 204);
     342    color: rgb(51, 51, 51);
     343    padding: 0.1em 0.5em;
     344}
     345
     346#insert:active, #cancel:active, .submitbutton:active {
     347    background: #f4f4f4;
     348    border-left-color: #999;
     349    border-top-color: #999;
     350}
     351
     352#styleSelectRow {
     353    display: none;
     354}
  • trunk/wp-includes/js/tinymce/themes/advanced/css/editor_ui.css

    r3503 r4431  
    22
    33.mceToolbarTop a, .mceToolbarTop a:visited, .mceToolbarTop a:hover, .mceToolbarBottom a, .mceToolbarBottom a:visited, .mceToolbarBottom a:hover {
    4     border: 0px; margin: 0px; padding: 0px; background: transparent;
    5 }
    6 
    7 .mceButtonNormal, .mceButtonOver, .mceButtonDown, .mceSeparator, .mceSeparatorLine, .mceButtonDisabled, .mceButtonSelected {
    8     border: 0px; margin: 0px; padding: 0px; background: transparent;
    9     margin-top: 1px;
    10     margin-left: 1px;
    11 }
    12 
    13 .mceButtonNormal {
    14     border-top: 1px solid;
    15     border-left: 1px solid;
    16     border-bottom: 1px solid;
    17     border-right: 1px solid;
    18     border-color: #F0F0EE;
    19     cursor: arrow;
    20 }
    21 
    22 .mceButtonOver {
    23     border: 1px solid #0A246A;
    24     cursor: arrow;
    25     background-color: #B6BDD2;
    26 }
    27 
    28 .mceButtonDown {
    29     cursor: arrow;
    30     border: 1px solid #0A246A;
    31     background-color: #8592B5;
    32 }
    33 
    34 .mceButtonSelected {
    35     border: 1px solid;
    36     border-color: #C0C0BB;
    37     cursor: arrow;
    38 }
    39 
    40 .mceButtonDisabled {
    41     filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);
    42     -moz-opacity:0.3;
    43     opacity: 0.3;
    44     border-top: 1px solid;
    45     border-left: 1px solid;
    46     border-bottom: 1px solid;
    47     border-right: 1px solid;
    48     border-color: #F0F0EE;
    49     cursor: arrow;
    50 }
    51 
    52 .mceSeparator {
    53     border-top: 1px solid buttonhighlight;
    54     border-left: 1px solid buttonhighlight;
    55     border-bottom: 1px solid buttonshadow;
    56     border-right: 1px solid buttonshadow;
     4    border: 0; margin: 0; padding: 0; background: transparent;
     5}
     6
     7.mceSeparatorLine {
     8    border: 0;
     9    padding: 0;
     10    margin-left: 4px;
    5711    margin-right: 2px;
    58     margin-left: 2px;
    59 }
    60 
    61 .mceSeparatorLine {
    62     margin:2px;
    63     margin-left: 4px;
    64     background-color: #F0F0EE;
    65     border-top: 1px solid buttonshadow;
    66     border-left: 1px solid buttonshadow;
    67     border-bottom: 1px solid buttonhighlight;
    68     border-right: 1px solid buttonhighlight;
    69     width: 0px;
    70     height: 15px;
    7112}
    7213
    7314.mceSelectList {
    74     font-family: "MS Sans Serif";
    75     font-size: 7pt;
     15    font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
     16    font-size: 7pt !important;
    7617    font-weight: normal;
    7718    margin-top: 3px;
    78     padding: 0px;
     19    padding: 0;
    7920    display: inline;
    8021    vertical-align: top;
    81     background-color: #F0F0EE
     22    background-color: #F0F0EE;
    8223}
    8324
     
    9940    background: #F0F0EE;
    10041    border: 1px solid #cccccc;
    101     padding: 0px;
    102     margin: 0px;
     42    padding: 0;
     43    margin: 0;
    10344}
    10445
     
    10647    font-family: 'MS Sans Serif', sans-serif, Verdana, Arial;
    10748    background: #FFFFFF;
    108     padding: 0px;
    109     margin: 0px;
     49    padding: 0;
     50    margin: 0;
    11051}
    11152
     
    11859.mceToolbarTop {
    11960    border-bottom: 1px solid #cccccc;
     61    padding-bottom: 1px;
    12062}
    12163
     
    177119    display: none;
    178120    border: 1px dotted gray;
    179     margin: 0px;
    180     padding: 0px;
    181 }
     121    margin: 0;
     122    padding: 0;
     123}
     124
     125/* Button CSS rules */
     126
     127a.mceButtonDisabled img, a.mceButtonNormal img, a.mceButtonSelected img {
     128    width: 20px;
     129    height: 20px;
     130    cursor: default;
     131    margin-top: 1px;
     132    margin-left: 1px;
     133}
     134
     135a.mceButtonDisabled img {
     136    border: 0 !important;
     137}
     138
     139a.mceButtonNormal img, a.mceButtonSelected img {
     140    border: 1px solid #F0F0EE !important;
     141}
     142
     143a.mceButtonSelected img {
     144    border: 1px solid #6779AA !important;
     145    background-color: #D4D5D8;
     146}
     147
     148a.mceButtonNormal img:hover, a.mceButtonSelected img:hover {
     149    border: 1px solid #0A246A !important;
     150    cursor: default;
     151    background-color: #B6BDD2;
     152}
     153
     154a.mceButtonDisabled img {
     155    -moz-opacity:0.3;
     156    opacity: 0.3;
     157    border: 1px solid #F0F0EE !important;
     158    cursor: default;
     159}
     160
     161a.mceTiledButton img {
     162    background-image: url('../images/buttons.gif');
     163    background-repeat: no-repeat;
     164}
     165
     166/* MSIE specific rules */
     167
     168* html a.mceButtonNormal img, * html a.mceButtonSelected img, * html a.mceButtonDisabled img {
     169    border: 0 !important;
     170    margin-top: 2px;
     171    margin-bottom: 1px;
     172}
     173
     174* html a.mceButtonDisabled img {
     175    filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);
     176    border: 0 !important;
     177}
     178
     179* html a.mceButtonDisabled {
     180    border: 1px solid #F0F0EE !important;
     181}
     182
     183* html a.mceButtonNormal, * html a.mceButtonSelected {
     184    border: 1px solid #F0F0EE !important;
     185    cursor: default;
     186}
     187
     188* html a.mceButtonSelected {
     189    border: 1px solid #6779AA !important;
     190    background-color: #D4D5D8;
     191}
     192
     193* html a.mceButtonNormal:hover, * html a.mceButtonSelected:hover {
     194    border: 1px solid #0A246A !important;
     195    cursor: default;
     196    background-color: #B6BDD2;
     197}
     198
     199* html .mceSelectList {
     200    margin-top: 2px;
     201}
     202
     203/* Menu button CSS rules */
     204
     205span.mceMenuButton img, span.mceMenuButtonSelected img {
     206    border: 1px solid #F0F0EE;
     207    margin-left: 1px;
     208}
     209
     210span.mceMenuButtonSelected img {
     211    border: 1px solid #6779AA;
     212    background-color: #B6BDD2;
     213}
     214
     215span.mceMenuButtonSelected img.mceMenuButton {
     216    border: 1px solid #F0F0EE;
     217    background-color: transparent;
     218}
     219
     220span.mceMenuButton img.mceMenuButton, span.mceMenuButtonSelected img.mceMenuButton {
     221    border-left: 0;
     222    margin-left: 0;
     223}
     224
     225span.mceMenuButton:hover img, span.mceMenuButtonSelected:hover img {
     226    border: 1px solid #0A246A;
     227    background-color: #B6BDD2;
     228}
     229
     230span.mceMenuButton:hover img.mceMenuButton, span.mceMenuButtonSelected:hover img.mceMenuButton {
     231    border-left: 0;
     232}
     233
     234span.mceMenuButtonFocus img {
     235    border: 1px solid gray;
     236    border-right: 0;
     237    margin-left: 1px;
     238    background-color: #F5F4F2;
     239}
     240
     241span.mceMenuButtonFocus img.mceMenuButton {
     242    border: 1px solid gray;
     243    border-left: 1px solid #F5F4F2;
     244    margin-left: 0;
     245}
     246
     247/* Menu button MSIE specific rules */
     248
     249* html span.mceMenuButton, * html span.mceMenuButtonFocus {
     250    position: relative;
     251    left: 0;
     252    top: 0;
     253}
     254
     255* html span.mceMenuButton img, * html span.mceMenuButtonSelected img, * html span.mceMenuButtonFocus img {
     256    position: relative;
     257    top: 1px;
     258}
     259
     260* html span.mceMenuHover img {
     261    border: 1px solid #0A246A;
     262    background-color: #B6BDD2;
     263}
     264
     265* html span.mceMenuButtonSelected.mceMenuHover img.mceMenuButton {
     266    border: 1px solid #0A246A;
     267    background-color: #B6BDD2;
     268    border-left: 0;
     269}
     270
     271/* Menu */
     272
     273.mceMenu {
     274    position: absolute;
     275    left: 0;
     276    top: 0;
     277    display: none;
     278    z-index: 100;
     279    background-color: white;
     280    border: 1px solid gray;
     281    font-weight: normal;
     282}
     283
     284.mceMenu a, .mceMenuTitle, .mceMenuDisabled {
     285    display: block;
     286    width: 100%;
     287    text-decoration: none;
     288    background-color: white;
     289    font-family: Tahoma, Verdana, Arial, Helvetica;
     290    font-size: 11px;
     291    line-height: 20px;
     292    color: black;
     293}
     294
     295.mceMenu a:hover {
     296    background-color: #B6BDD2;
     297    color: black;
     298}
     299
     300.mceMenu span {
     301    padding-left: 10px;
     302    padding-right: 10px;
     303    display: block;
     304    line-height: 20px;
     305}
     306
     307.mceMenuSeparator {
     308    border-bottom: 1px solid gray;
     309    background-color: gray;
     310    height: 1px;
     311}
     312
     313.mceMenuTitle span {
     314    padding-left: 5px;
     315}
     316
     317.mceMenuTitle {
     318    background-color: #DDDDDD;
     319    font-weight: bold;
     320}
     321
     322.mceMenuDisabled {
     323    color: gray;
     324}
     325
     326span.mceMenuSelectedItem {
     327    background-image: url('../images/menu_check.gif');
     328    background-repeat: no-repeat;
     329    background-position: 5px 8px;
     330    padding-left: 20px;
     331}
     332
     333span.mceMenuCheckItem {
     334    padding-left: 20px;
     335}
     336
     337span.mceMenuLine {
     338    display: block;
     339    position: absolute;
     340    left: 0;
     341    top: -1px;
     342    background-color: #F5F4F2;
     343    width: 30px;
     344    height: 1px;
     345    overflow: hidden;
     346    padding-left: 0;
     347    padding-right: 0;
     348}
  • trunk/wp-includes/js/tinymce/themes/advanced/editor_template.js

    r3503 r4431  
     1/**
     2 * $RCSfile: editor_template_src.js,v $
     3 * $Revision: 1.96 $
     4 * $Date: 2006/04/18 13:32:52 $
     5 *
     6 * @author Moxiecode
     7 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
     8 */
     9
    110/* Import theme specific language pack */
    2  tinyMCE.importThemeLanguagePack('advanced');var TinyMCE_advanced_autoImportCSSClasses=true;var TinyMCE_advanced_resizer=new Object();var TinyMCE_advanced_buttons=[['bold','{$lang_bold_img}','{$lang_bold_desc}','Bold'],['italic','{$lang_italic_img}','{$lang_italic_desc}','Italic'],['underline','{$lang_underline_img}','{$lang_underline_desc}','Underline'],['strikethrough','strikethrough.gif','{$lang_striketrough_desc}','Strikethrough'],['justifyleft','left.gif','{$lang_justifyleft_desc}','JustifyLeft'],['justifycenter','center.gif','{$lang_justifycenter_desc}','JustifyCenter'],['justifyright','right.gif','{$lang_justifyright_desc}','JustifyRight'],['justifyfull','full.gif','{$lang_justifyfull_desc}','JustifyFull'],['bullist','bullist.gif','{$lang_bullist_desc}','InsertUnorderedList'],['numlist','numlist.gif','{$lang_numlist_desc}','InsertOrderedList'],['outdent','outdent.gif','{$lang_outdent_desc}','Outdent'],['indent','indent.gif','{$lang_indent_desc}','Indent'],['cut','cut.gif','{$lang_cut_desc}','Cut'],['copy','copy.gif','{$lang_copy_desc}','Copy'],['paste','paste.gif','{$lang_paste_desc}','Paste'],['undo','undo.gif','{$lang_undo_desc}','Undo'],['redo','redo.gif','{$lang_redo_desc}','Redo'],['link','link.gif','{$lang_link_desc}','mceLink',true],['unlink','unlink.gif','{$lang_unlink_desc}','unlink'],['image','image.gif','{$lang_image_desc}','mceImage',true],['cleanup','cleanup.gif','{$lang_cleanup_desc}','mceCleanup'],['help','help.gif','{$lang_help_desc}','mceHelp'],['code','code.gif','{$lang_theme_code_desc}','mceCodeEditor'],['hr','hr.gif','{$lang_theme_hr_desc}','inserthorizontalrule'],['removeformat','removeformat.gif','{$lang_theme_removeformat_desc}','removeformat'],['sub','sub.gif','{$lang_theme_sub_desc}','subscript'],['sup','sup.gif','{$lang_theme_sup_desc}','superscript'],['forecolor','forecolor.gif','{$lang_theme_forecolor_desc}','mceForeColor',true],['backcolor','backcolor.gif','{$lang_theme_backcolor_desc}','mceBackColor',true],['charmap','charmap.gif','{$lang_theme_charmap_desc}','mceCharMap'],['visualaid','visualaid.gif','{$lang_theme_visualaid_desc}','mceToggleVisualAid'],['anchor','anchor.gif','{$lang_theme_anchor_desc}','mceInsertAnchor'],['newdocument','newdocument.gif','{$lang_newdocument_desc}','mceNewDocument']];function TinyMCE_advanced_getControlHTML(button_name){var buttonTileMap=new Array('anchor.gif','backcolor.gif','bullist.gif','center.gif','charmap.gif','cleanup.gif','code.gif','copy.gif','custom_1.gif','cut.gif','forecolor.gif','full.gif','help.gif','hr.gif','image.gif','indent.gif','left.gif','link.gif','numlist.gif','outdent.gif','paste.gif','redo.gif','removeformat.gif','right.gif','strikethrough.gif','sub.gif','sup.gif','undo.gif','unlink.gif','visualaid.gif');for(var i=0;i<TinyMCE_advanced_buttons.length;i++){var but=TinyMCE_advanced_buttons[i];if(but[0]==button_name){if(tinyMCE.settings['button_tile_map']){for(var x=0;!tinyMCE.isMSIE&&x<buttonTileMap.length;x++){if(buttonTileMap[x]==but[1]){var cmd='tinyMCE.execInstanceCommand(\'{$editor_id}\',\''+but[3]+'\','+(but.length>4?but[4]:false)+(but.length>5?',\''+but[5]+'\'':'')+')';return '<a href="javascript:'+cmd+'" onclick="'+cmd+';return false;" onmousedown="return false;" target="_self"><img id="{$editor_id}_'+but[0]+'" src="{$themeurl}/images/spacer.gif" style="background-image:url({$themeurl}/images/buttons.gif); background-position: '+(0-(x*20))+'px 0px" title="'+but[2]+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';}}}var cmd='tinyMCE.execInstanceCommand(\'{$editor_id}\',\''+but[3]+'\','+(but.length>4?but[4]:false)+(but.length>5?',\''+but[5]+'\'':'')+')';return '<a href="javascript:'+cmd+'" onclick="'+cmd+';return false;" onmousedown="return false;" target="_self"><img id="{$editor_id}_'+but[0]+'" src="{$themeurl}/images/'+but[1]+'" title="'+but[2]+'" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>';}}switch(button_name){case "formatselect":var html='<select id="{$editor_id}_formatSelect" name="{$editor_id}_formatSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FormatBlock\',false,this.options[this.selectedIndex].value);" class="mceSelectList">';var formats=tinyMCE.getParam("theme_advanced_blockformats","p,address,pre,h1,h2,h3,h4,h5,h6",true).split(',');var lookup=[['p','{$lang_theme_paragraph}'],['address','{$lang_theme_address}'],['pre','{$lang_theme_pre}'],['h1','{$lang_theme_h1}'],['h2','{$lang_theme_h2}'],['h3','{$lang_theme_h3}'],['h4','{$lang_theme_h4}'],['h5','{$lang_theme_h5}'],['h6','{$lang_theme_h6}']];html+='<option value="">{$lang_theme_block}</option>';for(var i=0;i<formats.length;i++){for(var x=0;x<lookup.length;x++){if(formats[i]==lookup[x][0]){html+='<option value="<'+lookup[x][0]+'>">'+lookup[x][1]+'</option>';}}}html+='</select>';return html;case "styleselect":return '<select id="{$editor_id}_styleSelect" onmousedown="TinyMCE_advanced_setupCSSClasses(\'{$editor_id}\');" name="{$editor_id}_styleSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSetCSSClass\',false,this.options[this.selectedIndex].value);" class="mceSelectList">{$style_select_options}</select>';case "fontselect":var fontHTML='<select id="{$editor_id}_fontNameSelect" name="{$editor_id}_fontNameSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontName\',false,this.options[this.selectedIndex].value);" class="mceSelectList"><option value="">{$lang_theme_fontdefault}</option>';var iFonts='Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;WingDings=wingdings';var nFonts='Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sand;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats';var fonts=tinyMCE.getParam("theme_advanced_fonts",nFonts).split(';');for(var i=0;i<fonts.length;i++){if(fonts[i]!=''){var parts=fonts[i].split('=');fontHTML+='<option value="'+parts[1]+'">'+parts[0]+'</option>';}}fontHTML+='</select>';return fontHTML;case "fontsizeselect":return '<select id="{$editor_id}_fontSizeSelect" name="{$editor_id}_fontSizeSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontSize\',false,this.options[this.selectedIndex].value);" class="mceSelectList">\
    3         <option value="0">{$lang_theme_font_size}</option>\
    4         <option value="1">1 (8 pt)</option>\
    5         <option value="2">2 (10 pt)</option>\
    6         <option value="3">3 (12 pt)</option>\
    7         <option value="4">4 (14 pt)</option>\
    8         <option value="5">5 (18 pt)</option>\
    9         <option value="6">6 (24 pt)</option>\
    10         <option value="7">7 (36 pt)</option>\
    11         </select>';case "|":case "separator":return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" class="mceSeparatorLine">';case "spacer":return '<img src="{$themeurl}/images/spacer.gif" width="1" height="15" border="0" class="mceSeparatorLine" style="vertical-align: middle" />';case "rowseparator":return '<br />';}return "";}function TinyMCE_advanced_execCommand(editor_id,element,command,user_interface,value){switch(command){case "mceForeColor":var template=new Array();var elm=tinyMCE.selectedInstance.getFocusElement();var inputColor=tinyMCE.getAttrib(elm,"color");if(inputColor=='')inputColor=elm.style.color;if(!inputColor)inputColor="#000000";template['file']='color_picker.htm';template['width']=220;template['height']=190;tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes",command:"forecolor",input_color:inputColor});return true;case "mceBackColor":var template=new Array();var elm=tinyMCE.selectedInstance.getFocusElement();var inputColor=elm.style.backgroundColor;if(!inputColor)inputColor="#000000";template['file']='color_picker.htm';template['width']=220;template['height']=190;template['width']+=tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes",command:"HiliteColor",input_color:inputColor});return true;case "mceColorPicker":if(user_interface){var template=new Array();var inputColor=value['document'].getElementById(value['element_id']).value;template['file']='color_picker.htm';template['width']=220;template['height']=190;template['close_previous']="no";template['width']+=tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height',0);if(typeof(value['store_selection'])=="undefined")value['store_selection']=true;tinyMCE.lastColorPickerValue=value;tinyMCE.openWindow(template,{editor_id:editor_id,mce_store_selection:value['store_selection'],inline:"yes",command:"mceColorPicker",input_color:inputColor});}else{var savedVal=tinyMCE.lastColorPickerValue;var elm=savedVal['document'].getElementById(savedVal['element_id']);elm.value=value;eval('elm.onchange();');}return true;case "mceCodeEditor":var template=new Array();template['file']='source_editor.htm';template['width']=parseInt(tinyMCE.getParam("theme_advanced_source_editor_width",500));template['height']=parseInt(tinyMCE.getParam("theme_advanced_source_editor_height",400));tinyMCE.openWindow(template,{editor_id:editor_id,resizable:"yes",scrollbars:"no",inline:"yes"});return true;case "mceCharMap":var template=new Array();template['file']='charmap.htm';template['width']=550+(tinyMCE.isOpera?40:0);template['height']=250;template['width']+=tinyMCE.getLang('lang_theme_advanced_charmap_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_charmap_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes"});return true;case "mceInsertAnchor":var template=new Array();template['file']='anchor.htm';template['width']=320;template['height']=90+(tinyMCE.isNS7?30:0);template['width']+=tinyMCE.getLang('lang_theme_advanced_anchor_delta_width',0);template['height']+=tinyMCE.getLang('lang_theme_advanced_anchor_delta_height',0);tinyMCE.openWindow(template,{editor_id:editor_id,inline:"yes"});return true;case "mceNewDocument":if(confirm(tinyMCE.getLang('lang_newdocument')))tinyMCE.execInstanceCommand(editor_id,'mceSetContent',false,'');return true;}return false;}function TinyMCE_advanced_getEditorTemplate(settings,editorId){function removeFromArray(in_array,remove_array){var outArray=new Array();for(var i=0;i<in_array.length;i++){skip=false;for(var j=0;j<remove_array.length;j++){if(in_array[i]==remove_array[j]){skip=true;}}if(!skip){outArray[outArray.length]=in_array[i];}}return outArray;}function addToArray(in_array,add_array){for(var i=0;i<add_array.length;i++){in_array[in_array.length]=add_array[i];}return in_array;}var template=new Array();var deltaHeight=0;var resizing=tinyMCE.getParam("theme_advanced_resizing",false);var path=tinyMCE.getParam("theme_advanced_path",true);var statusbarHTML='<div id="{$editor_id}_path" class="mceStatusbarPathText" style="display: '+(path?"block":"none")+'">&nbsp;</div><div id="{$editor_id}_resize" class="mceStatusbarResize" style="display: '+(resizing?"block":"none")+'" onmousedown="TinyMCE_advanced_setResizing(event,\'{$editor_id}\',true);"></div><br style="clear: both" />';var layoutManager=tinyMCE.getParam("theme_advanced_layout_manager","SimpleLayout");var styleSelectHTML='<option value="">{$lang_theme_style_select}</option>';if(settings['theme_advanced_styles']){var stylesAr=settings['theme_advanced_styles'].split(';');for(var i=0;i<stylesAr.length;i++){var key,value;key=stylesAr[i].split('=')[0];value=stylesAr[i].split('=')[1];styleSelectHTML+='<option value="'+value+'">'+key+'</option>';}TinyMCE_advanced_autoImportCSSClasses=false;}switch(layoutManager){case "SimpleLayout":var toolbarHTML="";var toolbarLocation=tinyMCE.getParam("theme_advanced_toolbar_location","bottom");var toolbarAlign=tinyMCE.getParam("theme_advanced_toolbar_align","center");var pathLocation=tinyMCE.getParam("theme_advanced_path_location","none");var statusbarLocation=tinyMCE.getParam("theme_advanced_statusbar_location",pathLocation);var defVals={theme_advanced_buttons1:"bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect",theme_advanced_buttons2:"bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code",theme_advanced_buttons3:"hr,removeformat,visualaid,separator,sub,sup,separator,charmap"};/*toolbarHTML+='<a href="#" accesskey="q" title="'+tinyMCE.getLang("lang_toolbar_focus")+'"></a>';*/for(var i=1;i<100;i++){var def=defVals["theme_advanced_buttons"+i];var buttons=tinyMCE.getParam("theme_advanced_buttons"+i,def==null?'':def,true,',');if(buttons.length==0)break;buttons=removeFromArray(buttons,tinyMCE.getParam("theme_advanced_disable","",true,','));buttons=addToArray(buttons,tinyMCE.getParam("theme_advanced_buttons"+i+"_add","",true,','));buttons=addToArray(tinyMCE.getParam("theme_advanced_buttons"+i+"_add_before","",true,','),buttons);for(var b=0;b<buttons.length;b++)toolbarHTML+=tinyMCE.getControlHTML(buttons[b]);if(buttons.length>0){toolbarHTML+="<br />";deltaHeight-=23;}}toolbarHTML+='<a href="#" accesskey="z" onfocus="tinyMCE.getInstanceById(\''+editorId+'\').getWin().focus();"></a>';template['html']='<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';if(toolbarLocation=="top"){template['html']+='<tr><td class="mceToolbarTop" align="'+toolbarAlign+'" height="1" nowrap="nowrap">'+toolbarHTML+'</td></tr>';}if(statusbarLocation=="top"){template['html']+='<tr><td class="mceStatusbarTop" height="1">'+statusbarHTML+'</td></tr>';deltaHeight-=23;}template['html']+='<tr><td align="center"><span id="{$editor_id}"></span></td></tr>';if(toolbarLocation=="bottom"){template['html']+='<tr><td class="mceToolbarBottom" align="'+toolbarAlign+'" height="1">'+toolbarHTML+'</td></tr>';}if(toolbarLocation=="external"){var bod=document.body;var elm=document.createElement("div");toolbarHTML=tinyMCE.replaceVars(toolbarHTML,tinyMCE.settings);toolbarHTML=tinyMCE.replaceVars(toolbarHTML,tinyMCELang);toolbarHTML=tinyMCE.replaceVar(toolbarHTML,'style_select_options',styleSelectHTML);toolbarHTML=tinyMCE.replaceVar(toolbarHTML,"editor_id",editorId);toolbarHTML=tinyMCE.applyTemplate(toolbarHTML);elm.className="mceToolbarExternal";elm.id=editorId+"_toolbar";elm.innerHTML='<table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table>';bod.appendChild(elm);deltaHeight=0;tinyMCE.getInstanceById(editorId).toolbarElement=elm;}else{tinyMCE.getInstanceById(editorId).toolbarElement=null;}if(statusbarLocation=="bottom"){template['html']+='<tr><td class="mceStatusbarBottom" height="1">'+statusbarHTML+'</td></tr>';deltaHeight-=23;}template['html']+='</tbody></table>';break;case "RowLayout":template['html']='<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';var containers=tinyMCE.getParam("theme_advanced_containers","",true,",");var defaultContainerCSS=tinyMCE.getParam("theme_advanced_containers_default_class","container");var defaultContainerAlign=tinyMCE.getParam("theme_advanced_containers_default_align","center");for(var i=0;i<containers.length;i++){if(containers[i]=="mceEditor"){template['html']+='<tr><td align="center" class="mceEditor_border">\
    12                                                 <span id="{$editor_id}"></span>\
    13                                                 </td></tr>';}else if(containers[i]=="mceElementpath"||containers[i]=="mceStatusbar"){var pathClass="mceStatusbar";if(i==containers.length-1){pathClass="mceStatusbarBottom";}else if(i==0){pathClass="mceStatusbar";}else{deltaHeight-=2;}template['html']+='<tr><td class="'+pathClass+'" height="1">'+statusbarHTML+'</td></tr>';deltaHeight-=22;}else{var curContainer=tinyMCE.getParam("theme_advanced_container_"+containers[i],"",true,',');var curContainerHTML="";var curAlign=tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align",defaultContainerAlign);var curCSS=tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class",defaultContainerCSS);for(var j=0;j<curContainer.length;j++){curContainerHTML+=tinyMCE.getControlHTML(curContainer[j]);}if(curContainer.length>0){curContainerHTML+="<br />";deltaHeight-=23;}template['html']+='<tr><td class="'+curCSS+'" align="'+curAlign+'" height="1">'+curContainerHTML+'</td></tr>';}}template['html']+='</tbody></table>';break;case "BorderLayout":break;case "CustomLayout":var customLayout=tinyMCE.getParam("theme_advanced_custom_layout","");if(customLayout!=""&&eval("typeof("+customLayout+")")!="undefined"){template=eval(customLayout+"(template);");}break;default:alert('UNDEFINED LAYOUT MANAGER! PLEASE CHECK YOUR TINYMCE CONFIG!');break;}template['html']+='<div id="{$editor_id}_resize_box" class="mceResizeBox"></div>';template['html']=tinyMCE.replaceVar(template['html'],'style_select_options',styleSelectHTML);template['delta_width']=0;template['delta_height']=deltaHeight;return template;}function TinyMCE_advanced_setResizing(e,editor_id,state){e=typeof(e)=="undefined"?window.event:e;var resizer=TinyMCE_advanced_resizer;var editorContainer=document.getElementById(editor_id+'_parent');var editorArea=document.getElementById(editor_id+'_parent').firstChild;var resizeBox=document.getElementById(editor_id+'_resize_box');var inst=tinyMCE.getInstanceById(editor_id);if(state){var width=editorArea.clientWidth;var height=editorArea.clientHeight;resizeBox.style.width=width+"px";resizeBox.style.height=height+"px";resizer.iframeWidth=inst.iframeElement.clientWidth;resizer.iframeHeight=inst.iframeElement.clientHeight;editorArea.style.display="none";resizeBox.style.display="block";if(!resizer.eventHandlers){if(tinyMCE.isMSIE)tinyMCE.addEvent(document,"mousemove",TinyMCE_advanced_resizeEventHandler);else tinyMCE.addEvent(window,"mousemove",TinyMCE_advanced_resizeEventHandler);tinyMCE.addEvent(document,"mouseup",TinyMCE_advanced_resizeEventHandler);resizer.eventHandlers=true;}resizer.resizing=true;resizer.downX=e.screenX;resizer.downY=e.screenY;resizer.width=parseInt(resizeBox.style.width);resizer.height=parseInt(resizeBox.style.height);resizer.editorId=editor_id;resizer.resizeBox=resizeBox;resizer.horizontal=tinyMCE.getParam("theme_advanced_resize_horizontal",true);}else{resizer.resizing=false;resizeBox.style.display="none";editorArea.style.display=tinyMCE.isMSIE?"block":"table";tinyMCE.execCommand('mceResetDesignMode');}}function TinyMCE_advanced_initInstance(inst){if(tinyMCE.getParam("theme_advanced_resizing",false)){if(tinyMCE.getParam("theme_advanced_resizing_use_cookie",true)){var w=TinyMCE_advanced_getCookie("TinyMCE_"+inst.editorId+"_width");var h=TinyMCE_advanced_getCookie("TinyMCE_"+inst.editorId+"_height");TinyMCE_advanced_resizeTo(inst,w,h,tinyMCE.getParam("theme_advanced_resize_horizontal",true));}}}function TinyMCE_advanced_setCookie(name,value,expires,path,domain,secure){var curCookie=name+"="+escape(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+escape(path):"")+((domain)?"; domain="+domain:"")+((secure)?"; secure":"");document.cookie=curCookie;}function TinyMCE_advanced_getCookie(name){var dc=document.cookie;var prefix=name+"=";var begin=dc.indexOf("; "+prefix);if(begin==-1){begin=dc.indexOf(prefix);if(begin!=0)return null;}else begin+=2;var end=document.cookie.indexOf(";",begin);if(end==-1)end=dc.length;return unescape(dc.substring(begin+prefix.length,end));}function TinyMCE_advanced_resizeTo(inst,w,h,set_w){var editorContainer=document.getElementById(inst.editorId+'_parent');var tableElm=editorContainer.firstChild;var iframe=inst.iframeElement;if(w==null||w=="null"){set_w=false;w=0;}if(h==null||h=="null")return;w=parseInt(w);h=parseInt(h);if(tinyMCE.isGecko){w+=2;h+=2;}var dx=w-tableElm.clientWidth;var dy=h-tableElm.clientHeight;if(set_w)tableElm.style.width=w+"px";tableElm.style.height=h+"px";iw=iframe.clientWidth+dx;ih=iframe.clientHeight+dy;if(tinyMCE.isGecko){iw-=2;ih-=2;}if(set_w)iframe.style.width=iw+"px";iframe.style.height=ih+"px";if(set_w){var tableBodyElm=tableElm.firstChild;var minIframeWidth=tableBodyElm.scrollWidth;if(inst.iframeElement.clientWidth<minIframeWidth){dx=minIframeWidth-inst.iframeElement.clientWidth;inst.iframeElement.style.width=(iw+dx)+"px";}}}function TinyMCE_advanced_resizeEventHandler(e){var resizer=TinyMCE_advanced_resizer;if(!resizer.resizing)return;e=typeof(e)=="undefined"?window.event:e;var dx=e.screenX-resizer.downX;var dy=e.screenY-resizer.downY;var resizeBox=resizer.resizeBox;var editorId=resizer.editorId;switch(e.type){case "mousemove":if(resizer.horizontal)resizeBox.style.width=(resizer.width+dx)+"px";resizeBox.style.height=(resizer.height+dy)+"px";break;case "mouseup":TinyMCE_advanced_setResizing(e,editorId,false);TinyMCE_advanced_resizeTo(tinyMCE.getInstanceById(editorId),resizer.width+dx,resizer.height+dy,resizer.horizontal);if(tinyMCE.getParam("theme_advanced_resizing_use_cookie",true)){var expires=new Date();expires.setTime(expires.getTime()+3600000*24*30);TinyMCE_advanced_setCookie("TinyMCE_"+editorId+"_width",""+(resizer.horizontal?resizer.width+dx:""),expires);TinyMCE_advanced_setCookie("TinyMCE_"+editorId+"_height",""+(resizer.height+dy),expires);}break;}}function TinyMCE_advanced_getInsertLinkTemplate(){var template=new Array();template['file']='link.htm';template['width']=330;template['height']=160;template['width']+=tinyMCE.getLang('lang_insert_link_delta_width',0);template['height']+=tinyMCE.getLang('lang_insert_link_delta_height',0);return template;};function TinyMCE_advanced_getInsertImageTemplate(){var template=new Array();template['file']='image.htm?src={$src}';template['width']=340;template['height']=165;template['width']+=tinyMCE.getLang('lang_insert_image_delta_width',0);template['height']+=tinyMCE.getLang('lang_insert_image_delta_height',0);return template;};function TinyMCE_advanced_handleNodeChange(editor_id,node,undo_index,undo_levels,visual_aid,any_selection,setup_content){function selectByValue(select_elm,value,first_index){first_index=typeof(first_index)=="undefined"?false:true;if(select_elm){for(var i=0;i<select_elm.options.length;i++){var ov=""+select_elm.options[i].value;if(first_index&&ov.toLowerCase().indexOf(value.toLowerCase())==0){select_elm.selectedIndex=i;return true;}if(ov==value){select_elm.selectedIndex=i;return true;}}}return false;};function getAttrib(elm,name){return elm.getAttribute(name)?elm.getAttribute(name):"";};if(node==null){return;}var pathElm=document.getElementById(editor_id+"_path");var inst=tinyMCE.getInstanceById(editor_id);var doc=inst.getDoc();if(pathElm){var parentNode=node;var path=new Array();while(parentNode!=null){if(parentNode.nodeName.toUpperCase()=="BODY"){break;}if(parentNode.nodeType==1){path[path.length]=parentNode;}parentNode=parentNode.parentNode;}var html="";for(var i=path.length-1;i>=0;i--){var nodeName=path[i].nodeName.toLowerCase();var nodeData="";if(nodeName=="b"){nodeName="strong";}if(nodeName=="i"){nodeName="em";}if(nodeName=="span"){var cn=tinyMCE.getAttrib(path[i],"class");if(cn!=""&&cn.indexOf('mceItem')==-1)nodeData+="class: "+cn+" ";var st=tinyMCE.getAttrib(path[i],"style");if(st!=""){st=tinyMCE.serializeStyle(tinyMCE.parseStyle(st));nodeData+="style: "+st+" ";}}if(nodeName=="font"){if(tinyMCE.getParam("convert_fonts_to_spans"))nodeName="span";var face=tinyMCE.getAttrib(path[i],"face");if(face!="")nodeData+="font: "+face+" ";var size=tinyMCE.getAttrib(path[i],"size");if(size!="")nodeData+="size: "+size+" ";var color=tinyMCE.getAttrib(path[i],"color");if(color!="")nodeData+="color: "+color+" ";}if(getAttrib(path[i],'id')!=""){nodeData+="id: "+path[i].getAttribute('id')+" ";}var className=tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i],"class"),false);if(className!=""&&className.indexOf('mceItem')==-1)nodeData+="class: "+className+" ";if(getAttrib(path[i],'src')!=""){nodeData+="src: "+path[i].getAttribute('src')+" ";}if(getAttrib(path[i],'href')!=""){nodeData+="href: "+path[i].getAttribute('href')+" ";}if(nodeName=="img"&&tinyMCE.getAttrib(path[i],"class").indexOf('mceItemFlash')!=-1){nodeName="flash";nodeData="src: "+path[i].getAttribute('title');}if(nodeName=="a"&&(anchor=tinyMCE.getAttrib(path[i],"name"))!=""){nodeName="a";nodeName+="#"+anchor;nodeData="";}if(getAttrib(path[i],'name').indexOf("mce_")!=0){var className=tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i],"class"),false);if(className!=""&&className.indexOf('mceItem')==-1){nodeName+="."+className;}}var cmd='tinyMCE.execInstanceCommand(\''+editor_id+'\',\'mceSelectNodeDepth\',false,\''+i+'\');';html+='<a title="'+nodeData+'" href="javascript:'+cmd+'" onclick="'+cmd+'return false;" onmousedown="return false;" target="_self" class="mcePathItem">'+nodeName+'</a>';if(i>0){html+=" &raquo; ";}}pathElm.innerHTML='<a href="#" accesskey="x"></a>'+tinyMCE.getLang('lang_theme_path')+": "+html+'&nbsp;';}tinyMCE.switchClassSticky(editor_id+'_justifyleft','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifyright','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifycenter','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_justifyfull','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_bold','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_italic','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_underline','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_strikethrough','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_bullist','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_numlist','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_sub','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_sup','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_anchor','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_link','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_unlink','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_outdent','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_image','mceButtonNormal');tinyMCE.switchClassSticky(editor_id+'_hr','mceButtonNormal');if(node.nodeName=="A"&&tinyMCE.getAttrib(node,"class").indexOf('mceItemAnchor')!=-1)tinyMCE.switchClassSticky(editor_id+'_anchor','mceButtonSelected');var anchorLink=tinyMCE.getParentElement(node,"a","href");if(anchorLink||any_selection){tinyMCE.switchClassSticky(editor_id+'_link',anchorLink?'mceButtonSelected':'mceButtonNormal',false);tinyMCE.switchClassSticky(editor_id+'_unlink',anchorLink?'mceButtonSelected':'mceButtonNormal',false);}tinyMCE.switchClassSticky(editor_id+'_visualaid',visual_aid?'mceButtonSelected':'mceButtonNormal',false);if(undo_levels!=-1){tinyMCE.switchClassSticky(editor_id+'_undo','mceButtonDisabled',true);tinyMCE.switchClassSticky(editor_id+'_redo','mceButtonDisabled',true);}if(tinyMCE.getParentElement(node,"li,blockquote")){tinyMCE.switchClassSticky(editor_id+'_outdent','mceButtonNormal',false);}if(undo_index!=-1&&(undo_index<undo_levels-1&&undo_levels>0)){tinyMCE.switchClassSticky(editor_id+'_redo','mceButtonNormal',false);}if(undo_index!=-1&&(undo_index>0&&undo_levels>0)){tinyMCE.switchClassSticky(editor_id+'_undo','mceButtonNormal',false);}var selectElm=document.getElementById(editor_id+"_styleSelect");if(selectElm){TinyMCE_advanced_setupCSSClasses(editor_id);classNode=node;breakOut=false;var index=0;do{if(classNode&&classNode.className){for(var i=0;i<selectElm.options.length;i++){if(selectElm.options[i].value==classNode.className){index=i;breakOut=true;break;}}}}while(!breakOut&&classNode!=null&&(classNode=classNode.parentNode)!=null);selectElm.selectedIndex=index;}var selectElm=document.getElementById(editor_id+"_formatSelect");if(selectElm){var elm=tinyMCE.getParentElement(node,"p,div,h1,h2,h3,h4,h5,h6,pre,address");if(elm){selectByValue(selectElm,"<"+elm.nodeName.toLowerCase()+">");}else{selectByValue(selectElm,"");}}var selectElm=document.getElementById(editor_id+"_fontNameSelect");if(selectElm){if(!tinyMCE.isSafari&&!(tinyMCE.isMSIE&&!tinyMCE.isOpera)){var face=doc.queryCommandValue('FontName');face=face==null||face==""?"":face;selectByValue(selectElm,face,face!="");}else{var elm=tinyMCE.getParentElement(node,"font","face");if(elm){var family=tinyMCE.getAttrib(elm,"face");if(family=='')family=''+elm.style.fontFamily;if(!selectByValue(selectElm,family,family!=""))selectByValue(selectElm,"");}else selectByValue(selectElm,"");}}var selectElm=document.getElementById(editor_id+"_fontSizeSelect");if(selectElm){if(!tinyMCE.isSafari&&!tinyMCE.isOpera){var size=doc.queryCommandValue('FontSize');selectByValue(selectElm,size==null||size==""?"0":size);}else{var elm=tinyMCE.getParentElement(node,"font","size");if(elm){var size=tinyMCE.getAttrib(elm,"size");if(size==''){var sizes=new Array('','8px','10px','12px','14px','18px','24px','36px');size=''+elm.style.fontSize;for(var i=0;i<sizes.length;i++){if((''+sizes[i])==size){size=i;break;}}}if(!selectByValue(selectElm,size))selectByValue(selectElm,"");}else selectByValue(selectElm,"0");}}alignNode=node;breakOut=false;do{if(!alignNode.getAttribute||!alignNode.getAttribute('align')){continue;}switch(alignNode.getAttribute('align').toLowerCase()){case "left":tinyMCE.switchClassSticky(editor_id+'_justifyleft','mceButtonSelected');breakOut=true;break;case "right":tinyMCE.switchClassSticky(editor_id+'_justifyright','mceButtonSelected');breakOut=true;break;case "middle":case "center":tinyMCE.switchClassSticky(editor_id+'_justifycenter','mceButtonSelected');breakOut=true;break;case "justify":tinyMCE.switchClassSticky(editor_id+'_justifyfull','mceButtonSelected');breakOut=true;break;}}while(!breakOut&&(alignNode=alignNode.parentNode)!=null);var div=tinyMCE.getParentElement(node,"div");if(div&&div.style.textAlign=="center")tinyMCE.switchClassSticky(editor_id+'_justifycenter','mceButtonSelected');if(!setup_content){var ar=new Array("Bold","_bold","Italic","_italic","Strikethrough","_strikethrough","superscript","_sup","subscript","_sub");for(var i=0;i<ar.length;i+=2){if(doc.queryCommandState(ar[i]))tinyMCE.switchClassSticky(editor_id+ar[i+1],'mceButtonSelected');}if(doc.queryCommandState("Underline")&&(node.parentNode==null||node.parentNode.nodeName!="A")){tinyMCE.switchClassSticky(editor_id+'_underline','mceButtonSelected');}}do{switch(node.nodeName){case "UL":tinyMCE.switchClassSticky(editor_id+'_bullist','mceButtonSelected');break;case "OL":tinyMCE.switchClassSticky(editor_id+'_numlist','mceButtonSelected');break;case "HR":tinyMCE.switchClassSticky(editor_id+'_hr','mceButtonSelected');break;case "IMG":if(getAttrib(node,'name').indexOf('mce_')!=0){tinyMCE.switchClassSticky(editor_id+'_image','mceButtonSelected');}break;}}while((node=node.parentNode)!=null);};function TinyMCE_advanced_setupCSSClasses(editor_id){if(!TinyMCE_advanced_autoImportCSSClasses){return;}var selectElm=document.getElementById(editor_id+'_styleSelect');if(selectElm&&selectElm.getAttribute('cssImported')!='true'){var csses=tinyMCE.getCSSClasses(editor_id);if(csses&&selectElm){for(var i=0;i<csses.length;i++){selectElm.options[selectElm.length]=new Option(csses[i],csses[i]);}}if(csses!=null&&csses.length>0){selectElm.setAttribute('cssImported','true');}}};
     11tinyMCE.importThemeLanguagePack('advanced');
     12
     13var TinyMCE_AdvancedTheme = {
     14    // Private theme fields
     15    _autoImportCSSClasses : true,
     16    _resizer : {},
     17    _buttons : [
     18        // Control id, button img, button title, command, user_interface, value
     19        ['bold', '{$lang_bold_img}', 'lang_bold_desc', 'Bold'],
     20        ['italic', '{$lang_italic_img}', 'lang_italic_desc', 'Italic'],
     21        ['underline', '{$lang_underline_img}', 'lang_underline_desc', 'Underline'],
     22        ['strikethrough', 'strikethrough.gif', 'lang_striketrough_desc', 'Strikethrough'],
     23        ['justifyleft', 'justifyleft.gif', 'lang_justifyleft_desc', 'JustifyLeft'],
     24        ['justifycenter', 'justifycenter.gif', 'lang_justifycenter_desc', 'JustifyCenter'],
     25        ['justifyright', 'justifyright.gif', 'lang_justifyright_desc', 'JustifyRight'],
     26        ['justifyfull', 'justifyfull.gif', 'lang_justifyfull_desc', 'JustifyFull'],
     27        ['bullist', 'bullist.gif', 'lang_bullist_desc', 'InsertUnorderedList'],
     28        ['numlist', 'numlist.gif', 'lang_numlist_desc', 'InsertOrderedList'],
     29        ['outdent', 'outdent.gif', 'lang_outdent_desc', 'Outdent'],
     30        ['indent', 'indent.gif', 'lang_indent_desc', 'Indent'],
     31        ['cut', 'cut.gif', 'lang_cut_desc', 'Cut'],
     32        ['copy', 'copy.gif', 'lang_copy_desc', 'Copy'],
     33        ['paste', 'paste.gif', 'lang_paste_desc', 'Paste'],
     34        ['undo', 'undo.gif', 'lang_undo_desc', 'Undo'],
     35        ['redo', 'redo.gif', 'lang_redo_desc', 'Redo'],
     36        ['link', 'link.gif', 'lang_link_desc', 'mceLink', true],
     37        ['unlink', 'unlink.gif', 'lang_unlink_desc', 'unlink'],
     38        ['image', 'image.gif', 'lang_image_desc', 'mceImage', true],
     39        ['cleanup', 'cleanup.gif', 'lang_cleanup_desc', 'mceCleanup'],
     40        ['help', 'help.gif', 'lang_help_desc', 'mceHelp'],
     41        ['code', 'code.gif', 'lang_theme_code_desc', 'mceCodeEditor'],
     42        ['hr', 'hr.gif', 'lang_theme_hr_desc', 'inserthorizontalrule'],
     43        ['removeformat', 'removeformat.gif', 'lang_theme_removeformat_desc', 'removeformat'],
     44        ['sub', 'sub.gif', 'lang_theme_sub_desc', 'subscript'],
     45        ['sup', 'sup.gif', 'lang_theme_sup_desc', 'superscript'],
     46        ['forecolor', 'forecolor.gif', 'lang_theme_forecolor_desc', 'mceForeColor', true],
     47        ['backcolor', 'backcolor.gif', 'lang_theme_backcolor_desc', 'mceBackColor', true],
     48        ['charmap', 'charmap.gif', 'lang_theme_charmap_desc', 'mceCharMap'],
     49        ['visualaid', 'visualaid.gif', 'lang_theme_visualaid_desc', 'mceToggleVisualAid'],
     50        ['anchor', 'anchor.gif', 'lang_theme_anchor_desc', 'mceInsertAnchor'],
     51        ['newdocument', 'newdocument.gif', 'lang_newdocument_desc', 'mceNewDocument']
     52    ],
     53
     54    _buttonMap : 'anchor,backcolor,bold,bullist,charmap,cleanup,code,copy,cut,forecolor,help,hr,image,indent,italic,justifycenter,justifyfull,justifyleft,justifyright,link,newdocument,numlist,outdent,paste,redo,removeformat,strikethrough,sub,sup,underline,undo,unlink,visualaid,advhr,ltr,rtl,emotions,flash,fullpage,fullscreen,iespell,insertdate,inserttime,pastetext,pasteword,selectall,preview,print,save,replace,search,table,cell_props,delete_col,delete_row,col_after,col_before,row_after,row_before,merge_cells,row_props,split_cells',
     55
     56    /**
     57     * Returns HTML code for the specificed control.
     58     */
     59    getControlHTML : function(button_name) {
     60        var i, x;
     61
     62        // Lookup button in button list
     63        for (i=0; i<TinyMCE_AdvancedTheme._buttons.length; i++) {
     64            var but = TinyMCE_AdvancedTheme._buttons[i];
     65
     66            if (but[0] == button_name)
     67                return tinyMCE.getButtonHTML(but[0], but[2], '{$themeurl}/images/' + but[1], but[3], (but.length > 4 ? but[4] : false), (but.length > 5 ? but[5] : null));
     68        }
     69
     70        // Custom controlls other than buttons
     71        switch (button_name) {
     72            case "formatselect":
     73                var html = '<select id="{$editor_id}_formatSelect" name="{$editor_id}_formatSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FormatBlock\',false,this.options[this.selectedIndex].value);" class="mceSelectList">';
     74                var formats = tinyMCE.getParam("theme_advanced_blockformats", "p,address,pre,h1,h2,h3,h4,h5,h6", true).split(',');
     75                var lookup = [
     76                    ['p', '{$lang_theme_paragraph}'],
     77                    ['address', '{$lang_theme_address}'],
     78                    ['pre', '{$lang_theme_pre}'],
     79                    ['h1', '{$lang_theme_h1}'],
     80                    ['h2', '{$lang_theme_h2}'],
     81                    ['h3', '{$lang_theme_h3}'],
     82                    ['h4', '{$lang_theme_h4}'],
     83                    ['h5', '{$lang_theme_h5}'],
     84                    ['h6', '{$lang_theme_h6}'],
     85                    ['div', '{$lang_theme_div}'],
     86                    ['blockquote', '{$lang_theme_blockquote}'],
     87                    ['code', '{$lang_theme_code}'],
     88                    ['dt', '{$lang_theme_dt}'],
     89                    ['dd', '{$lang_theme_dd}'],
     90                    ['samp', '{$lang_theme_samp}']
     91                ];
     92
     93                html += '<option value="">{$lang_theme_block}</option>';
     94
     95                // Build format select
     96                for (var i=0; i<formats.length; i++) {
     97                    for (var x=0; x<lookup.length; x++) {
     98                        if (formats[i] == lookup[x][0])
     99                            html += '<option value="&lt;' + lookup[x][0] + '&gt;">' + lookup[x][1] + '</option>';
     100                    }
     101                }
     102
     103                html += '</select>';
     104
     105                return html;
     106
     107            case "styleselect":
     108                return '<select id="{$editor_id}_styleSelect" onmousedown="tinyMCE.themes.advanced._setupCSSClasses(\'{$editor_id}\');" name="{$editor_id}_styleSelect" onfocus="tinyMCE.addSelectAccessibility(event,this,window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceSetCSSClass\',false,this.options[this.selectedIndex].value);" class="mceSelectList">{$style_select_options}</select>';
     109
     110            case "fontselect":
     111                var fontHTML = '<select id="{$editor_id}_fontNameSelect" name="{$editor_id}_fontNameSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontName\',false,this.options[this.selectedIndex].value);" class="mceSelectList"><option value="">{$lang_theme_fontdefault}</option>';
     112                var iFonts = 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;WingDings=wingdings';
     113                var nFonts = 'Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sand;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats';
     114                var fonts = tinyMCE.getParam("theme_advanced_fonts", nFonts).split(';');
     115                for (i=0; i<fonts.length; i++) {
     116                    if (fonts[i] != '') {
     117                        var parts = fonts[i].split('=');
     118                        fontHTML += '<option value="' + parts[1] + '">' + parts[0] + '</option>';
     119                    }
     120                }
     121
     122                fontHTML += '</select>';
     123                return fontHTML;
     124
     125            case "fontsizeselect":
     126                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">'+
     127                        '<option value="0">{$lang_theme_font_size}</option>'+
     128                        '<option value="1">1 (8 pt)</option>'+
     129                        '<option value="2">2 (10 pt)</option>'+
     130                        '<option value="3">3 (12 pt)</option>'+
     131                        '<option value="4">4 (14 pt)</option>'+
     132                        '<option value="5">5 (18 pt)</option>'+
     133                        '<option value="6">6 (24 pt)</option>'+
     134                        '<option value="7">7 (36 pt)</option>'+
     135                        '</select>';
     136
     137            case "|":
     138            case "separator":
     139                return '<img src="{$themeurl}/images/separator.gif" width="2" height="20" class="mceSeparatorLine" />';
     140
     141            case "spacer":
     142                return '<img src="{$themeurl}/images/separator.gif" width="2" height="15" border="0" class="mceSeparatorLine" style="vertical-align: middle" />';
     143
     144            case "rowseparator":
     145                return '<br />';
     146        }
     147
     148        return "";
     149    },
     150
     151    /**
     152     * Theme specific execcommand handling.
     153     */
     154    execCommand : function(editor_id, element, command, user_interface, value) {
     155        switch (command) {
     156            case "mceLink":
     157                var inst = tinyMCE.getInstanceById(editor_id);
     158                var doc = inst.getDoc();
     159                var selectedText = "";
     160
     161                if (tinyMCE.isMSIE) {
     162                    var rng = doc.selection.createRange();
     163                    selectedText = rng.text;
     164                } else
     165                    selectedText = inst.getSel().toString();
     166
     167                if (!tinyMCE.linkElement) {
     168                    if ((tinyMCE.selectedElement.nodeName.toLowerCase() != "img") && (selectedText.length <= 0))
     169                        return true;
     170                }
     171
     172                var href = "", target = "", title = "", onclick = "", action = "insert", style_class = "";
     173
     174                if (tinyMCE.selectedElement.nodeName.toLowerCase() == "a")
     175                    tinyMCE.linkElement = tinyMCE.selectedElement;
     176
     177                // Is anchor not a link
     178                if (tinyMCE.linkElement != null && tinyMCE.getAttrib(tinyMCE.linkElement, 'href') == "")
     179                    tinyMCE.linkElement = null;
     180
     181                if (tinyMCE.linkElement) {
     182                    href = tinyMCE.getAttrib(tinyMCE.linkElement, 'href');
     183                    target = tinyMCE.getAttrib(tinyMCE.linkElement, 'target');
     184                    title = tinyMCE.getAttrib(tinyMCE.linkElement, 'title');
     185                    onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');
     186                    style_class = tinyMCE.getAttrib(tinyMCE.linkElement, 'class');
     187
     188                    // Try old onclick to if copy/pasted content
     189                    if (onclick == "")
     190                        onclick = tinyMCE.getAttrib(tinyMCE.linkElement, 'onclick');
     191
     192                    onclick = tinyMCE.cleanupEventStr(onclick);
     193
     194                    href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");
     195
     196                    // Use mce_href if defined
     197                    mceRealHref = tinyMCE.getAttrib(tinyMCE.linkElement, 'mce_href');
     198                    if (mceRealHref != "") {
     199                        href = mceRealHref;
     200
     201                        if (tinyMCE.getParam('convert_urls'))
     202                            href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement, true);");
     203                    }
     204
     205                    action = "update";
     206                }
     207
     208                var template = new Array();
     209
     210                template['file'] = 'link.htm';
     211                template['width'] = 310;
     212                template['height'] = 200;
     213
     214                // Language specific width and height addons
     215                template['width'] += tinyMCE.getLang('lang_insert_link_delta_width', 0);
     216                template['height'] += tinyMCE.getLang('lang_insert_link_delta_height', 0);
     217
     218                if (inst.settings['insertlink_callback']) {
     219                    var returnVal = eval(inst.settings['insertlink_callback'] + "(href, target, title, onclick, action, style_class);");
     220                    if (returnVal && returnVal['href'])
     221                        TinyMCE_AdvancedTheme._insertLink(returnVal['href'], returnVal['target'], returnVal['title'], returnVal['onclick'], returnVal['style_class']);
     222                } else {
     223                    tinyMCE.openWindow(template, {href : href, target : target, title : title, onclick : onclick, action : action, className : style_class, inline : "yes"});
     224                }
     225
     226                return true;
     227
     228            case "mceImage":
     229                var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = "";
     230                var title = "", onmouseover = "", onmouseout = "", action = "insert";
     231                var img = tinyMCE.imgElement;
     232                var inst = tinyMCE.getInstanceById(editor_id);
     233
     234                if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") {
     235                    img = tinyMCE.selectedElement;
     236                    tinyMCE.imgElement = img;
     237                }
     238
     239                if (img) {
     240                    // Is it a internal MCE visual aid image, then skip this one.
     241                    if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0)
     242                        return true;
     243
     244                    src = tinyMCE.getAttrib(img, 'src');
     245                    alt = tinyMCE.getAttrib(img, 'alt');
     246
     247                    // Try polling out the title
     248                    if (alt == "")
     249                        alt = tinyMCE.getAttrib(img, 'title');
     250
     251                    // Fix width/height attributes if the styles is specified
     252                    if (tinyMCE.isGecko) {
     253                        var w = img.style.width;
     254                        if (w != null && w != "")
     255                            img.setAttribute("width", w);
     256
     257                        var h = img.style.height;
     258                        if (h != null && h != "")
     259                            img.setAttribute("height", h);
     260                    }
     261
     262                    border = tinyMCE.getAttrib(img, 'border');
     263                    hspace = tinyMCE.getAttrib(img, 'hspace');
     264                    vspace = tinyMCE.getAttrib(img, 'vspace');
     265                    width = tinyMCE.getAttrib(img, 'width');
     266                    height = tinyMCE.getAttrib(img, 'height');
     267                    align = tinyMCE.getAttrib(img, 'align');
     268                    onmouseover = tinyMCE.getAttrib(img, 'onmouseover');
     269                    onmouseout = tinyMCE.getAttrib(img, 'onmouseout');
     270                    title = tinyMCE.getAttrib(img, 'title');
     271
     272                    // Is realy specified?
     273                    if (tinyMCE.isMSIE) {
     274                        width = img.attributes['width'].specified ? width : "";
     275                        height = img.attributes['height'].specified ? height : "";
     276                    }
     277
     278                    //onmouseover = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseover));
     279                    //onmouseout = tinyMCE.getImageSrc(tinyMCE.cleanupEventStr(onmouseout));
     280
     281                    src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
     282
     283                    // Use mce_src if defined
     284                    mceRealSrc = tinyMCE.getAttrib(img, 'mce_src');
     285                    if (mceRealSrc != "") {
     286                        src = mceRealSrc;
     287
     288                        if (tinyMCE.getParam('convert_urls'))
     289                            src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
     290                    }
     291
     292                    //if (onmouseover != "")
     293                    //  onmouseover = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, img, true);");
     294
     295                    //if (onmouseout != "")
     296                    //  onmouseout = eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, img, true);");
     297
     298                    action = "update";
     299                }
     300
     301                var template = new Array();
     302
     303                template['file'] = 'image.htm?src={$src}';
     304                template['width'] = 355;
     305                template['height'] = 265 + (tinyMCE.isMSIE ? 25 : 0);
     306
     307                // Language specific width and height addons
     308                template['width'] += tinyMCE.getLang('lang_insert_image_delta_width', 0);
     309                template['height'] += tinyMCE.getLang('lang_insert_image_delta_height', 0);
     310
     311                if (inst.settings['insertimage_callback']) {
     312                    var returnVal = eval(inst.settings['insertimage_callback'] + "(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout, action);");
     313                    if (returnVal && returnVal['src'])
     314                        TinyMCE_AdvancedTheme._insertImage(returnVal['src'], returnVal['alt'], returnVal['border'], returnVal['hspace'], returnVal['vspace'], returnVal['width'], returnVal['height'], returnVal['align'], returnVal['title'], returnVal['onmouseover'], returnVal['onmouseout']);
     315                } else
     316                    tinyMCE.openWindow(template, {src : src, alt : alt, border : border, hspace : hspace, vspace : vspace, width : width, height : height, align : align, title : title, onmouseover : onmouseover, onmouseout : onmouseout, action : action, inline : "yes"});
     317
     318                return true;
     319
     320            case "mceForeColor":
     321                var template = new Array();
     322                var elm = tinyMCE.selectedInstance.getFocusElement();
     323                var inputColor = tinyMCE.getAttrib(elm, "color");
     324
     325                if (inputColor == '')
     326                    inputColor = elm.style.color;
     327
     328                if (!inputColor)
     329                    inputColor = "#000000";
     330
     331                template['file'] = 'color_picker.htm';
     332                template['width'] = 220;
     333                template['height'] = 190;
     334
     335                tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "forecolor", input_color : inputColor});
     336            return true;
     337
     338            case "mceBackColor":
     339                var template = new Array();
     340                var elm = tinyMCE.selectedInstance.getFocusElement();
     341                var inputColor = elm.style.backgroundColor;
     342
     343                if (!inputColor)
     344                    inputColor = "#000000";
     345
     346                template['file'] = 'color_picker.htm';
     347                template['width'] = 220;
     348                template['height'] = 190;
     349
     350                template['width'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_width', 0);
     351                template['height'] += tinyMCE.getLang('lang_theme_advanced_backcolor_delta_height', 0);
     352
     353                tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes", command : "HiliteColor", input_color : inputColor});
     354                //mceBackColor
     355            return true;
     356
     357            case "mceColorPicker":
     358                if (user_interface) {
     359                    var template = new Array();
     360                    var inputColor = value['document'].getElementById(value['element_id']).value;
     361
     362                    template['file'] = 'color_picker.htm';
     363                    template['width'] = 220;
     364                    template['height'] = 190;
     365                    template['close_previous'] = "no";
     366
     367                    template['width'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_width', 0);
     368                    template['height'] += tinyMCE.getLang('lang_theme_advanced_colorpicker_delta_height', 0);
     369
     370                    if (typeof(value['store_selection']) == "undefined")
     371                        value['store_selection'] = true;
     372
     373                    tinyMCE.lastColorPickerValue = value;
     374                    tinyMCE.openWindow(template, {editor_id : editor_id, mce_store_selection : value['store_selection'], inline : "yes", command : "mceColorPicker", input_color : inputColor});
     375                } else {
     376                    var savedVal = tinyMCE.lastColorPickerValue;
     377                    var elm = savedVal['document'].getElementById(savedVal['element_id']);
     378                    elm.value = value;
     379
     380                    if (elm.onchange != null && elm.onchange != '')
     381                        eval('elm.onchange();');
     382                }
     383            return true;
     384
     385            case "mceCodeEditor":
     386                var template = new Array();
     387
     388                template['file'] = 'source_editor.htm';
     389                template['width'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_width", 720));
     390                template['height'] = parseInt(tinyMCE.getParam("theme_advanced_source_editor_height", 580));
     391
     392                tinyMCE.openWindow(template, {editor_id : editor_id, resizable : "yes", scrollbars : "no", inline : "yes"});
     393                return true;
     394
     395            case "mceCharMap":
     396                var template = new Array();
     397
     398                template['file'] = 'charmap.htm';
     399                template['width'] = 550 + (tinyMCE.isOpera ? 40 : 0);
     400                template['height'] = 250;
     401
     402                template['width'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_width', 0);
     403                template['height'] += tinyMCE.getLang('lang_theme_advanced_charmap_delta_height', 0);
     404
     405                tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
     406                return true;
     407
     408            case "mceInsertAnchor":
     409                var template = new Array();
     410
     411                template['file'] = 'anchor.htm';
     412                template['width'] = 320;
     413                template['height'] = 90 + (tinyMCE.isNS7 ? 30 : 0);
     414
     415                template['width'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_width', 0);
     416                template['height'] += tinyMCE.getLang('lang_theme_advanced_anchor_delta_height', 0);
     417
     418                tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"});
     419                return true;
     420
     421            case "mceNewDocument":
     422                if (confirm(tinyMCE.getLang('lang_newdocument')))
     423                    tinyMCE.execInstanceCommand(editor_id, 'mceSetContent', false, ' ');
     424
     425                return true;
     426        }
     427
     428        return false;
     429    },
     430
     431    /**
     432     * Editor instance template function.
     433     */
     434    getEditorTemplate : function(settings, editorId) {
     435        function removeFromArray(in_array, remove_array) {
     436            var outArray = new Array();
     437           
     438            for (var i=0; i<in_array.length; i++) {
     439                skip = false;
     440
     441                for (var j=0; j<remove_array.length; j++) {
     442                    if (in_array[i] == remove_array[j]) {
     443                        skip = true;
     444                    }
     445                }
     446
     447                if (!skip) {
     448                    outArray[outArray.length] = in_array[i];
     449                }
     450            }
     451
     452            return outArray;
     453        }
     454
     455        function addToArray(in_array, add_array) {
     456            for (var i=0; i<add_array.length; i++) {
     457                in_array[in_array.length] = add_array[i];
     458            }
     459
     460            return in_array;
     461        }
     462
     463        var template = new Array();
     464        var deltaHeight = 0;
     465        var resizing = tinyMCE.getParam("theme_advanced_resizing", false);
     466        var path = tinyMCE.getParam("theme_advanced_path", true);
     467        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" />';
     468        var layoutManager = tinyMCE.getParam("theme_advanced_layout_manager", "SimpleLayout");
     469
     470        // Setup style select options -- MOVED UP FOR EXTERNAL TOOLBAR COMPATABILITY!
     471        var styleSelectHTML = '<option value="">{$lang_theme_style_select}</option>';
     472        if (settings['theme_advanced_styles']) {
     473            var stylesAr = settings['theme_advanced_styles'].split(';');
     474           
     475            for (var i=0; i<stylesAr.length; i++) {
     476                var key, value;
     477
     478                key = stylesAr[i].split('=')[0];
     479                value = stylesAr[i].split('=')[1];
     480
     481                styleSelectHTML += '<option value="' + value + '">' + key + '</option>';
     482            }
     483
     484            TinyMCE_AdvancedTheme._autoImportCSSClasses = false;
     485        }
     486
     487        switch(layoutManager) {
     488            case "SimpleLayout" : //the default TinyMCE Layout (for backwards compatibility)...
     489                var toolbarHTML = "";
     490                var toolbarLocation = tinyMCE.getParam("theme_advanced_toolbar_location", "bottom");
     491                var toolbarAlign = tinyMCE.getParam("theme_advanced_toolbar_align", "center");
     492                var pathLocation = tinyMCE.getParam("theme_advanced_path_location", "none"); // Compatiblity
     493                var statusbarLocation = tinyMCE.getParam("theme_advanced_statusbar_location", pathLocation);
     494                var defVals = {
     495                    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,styleselect,formatselect",
     496                    theme_advanced_buttons2 : "bullist,numlist,separator,outdent,indent,separator,undo,redo,separator,link,unlink,anchor,image,cleanup,help,code",
     497                    theme_advanced_buttons3 : "hr,removeformat,visualaid,separator,sub,sup,separator,charmap"
     498                };
     499
     500                // Add accessibility control
     501                toolbarHTML += '<a href="#" accesskey="q" title="' + tinyMCE.getLang("lang_toolbar_focus") + '"';
     502
     503                if (!tinyMCE.getParam("accessibility_focus"))
     504                    toolbarHTML += ' onfocus="tinyMCE.getInstanceById(\'' + editorId + '\').getWin().focus();"';
     505
     506                toolbarHTML += '></a>';
     507
     508                // Render rows
     509                for (var i=1; i<100; i++) {
     510                    var def = defVals["theme_advanced_buttons" + i];
     511
     512                    var buttons = tinyMCE.getParam("theme_advanced_buttons" + i, def == null ? '' : def, true, ',');
     513                    if (buttons.length == 0)
     514                        break;
     515
     516                    buttons = removeFromArray(buttons, tinyMCE.getParam("theme_advanced_disable", "", true, ','));
     517                    buttons = addToArray(buttons, tinyMCE.getParam("theme_advanced_buttons" + i + "_add", "", true, ','));
     518                    buttons = addToArray(tinyMCE.getParam("theme_advanced_buttons" + i + "_add_before", "", true, ','), buttons);
     519
     520                    for (var b=0; b<buttons.length; b++)
     521                        toolbarHTML += tinyMCE.getControlHTML(buttons[b]);
     522
     523                    if (buttons.length > 0) {
     524                        toolbarHTML += "<br />";
     525                        deltaHeight -= 23;
     526                    }
     527                }
     528
     529                // Add accessibility control
     530                toolbarHTML += '<a href="#" accesskey="z" onfocus="tinyMCE.getInstanceById(\'' + editorId + '\').getWin().focus();"></a>';
     531
     532                // Setup template html
     533                template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';
     534
     535                if (toolbarLocation == "top") {
     536                    template['html'] += '<tr><td class="mceToolbarTop" align="' + toolbarAlign + '" height="1" nowrap="nowrap">' + toolbarHTML + '</td></tr>';
     537                }
     538
     539                if (statusbarLocation == "top") {
     540                    template['html'] += '<tr><td class="mceStatusbarTop" height="1">' + statusbarHTML + '</td></tr>';
     541                    deltaHeight -= 23;
     542                }
     543
     544                template['html'] += '<tr><td align="center"><span id="{$editor_id}"></span></td></tr>';
     545
     546                if (toolbarLocation == "bottom") {
     547                    template['html'] += '<tr><td class="mceToolbarBottom" align="' + toolbarAlign + '" height="1">' + toolbarHTML + '</td></tr>';
     548                }
     549
     550                // External toolbar changes
     551                if (toolbarLocation == "external") {
     552                    var bod = document.body;
     553                    var elm = document.createElement ("div");
     554
     555                    toolbarHTML = tinyMCE.replaceVar(toolbarHTML, 'style_select_options', styleSelectHTML);
     556                    toolbarHTML = tinyMCE.applyTemplate(toolbarHTML, {editor_id : editorId});
     557
     558                    elm.className = "mceToolbarExternal";
     559                    elm.id = editorId+"_toolbar";
     560                    elm.innerHTML = '<table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table>';
     561                    bod.appendChild (elm);
     562                    // bod.style.marginTop = elm.offsetHeight + "px";
     563
     564                    deltaHeight = 0;
     565                    tinyMCE.getInstanceById(editorId).toolbarElement = elm;
     566
     567                    //template['html'] = '<div id="mceExternalToolbar" align="center" class="mceToolbarExternal"><table width="100%" border="0" align="center"><tr><td align="center">'+toolbarHTML+'</td></tr></table></div>' + template["html"];
     568                } else {
     569                    tinyMCE.getInstanceById(editorId).toolbarElement = null;
     570                }
     571
     572                if (statusbarLocation == "bottom") {
     573                    template['html'] += '<tr><td class="mceStatusbarBottom" height="1">' + statusbarHTML + '</td></tr>';
     574                    deltaHeight -= 23;
     575                }
     576
     577                template['html'] += '</tbody></table>';
     578                //"SimpleLayout"
     579            break;
     580
     581            case "RowLayout" : //Container Layout - containers defined in "theme_advanced_containers" are rendered from top to bottom.
     582                template['html'] = '<table class="mceEditor" border="0" cellpadding="0" cellspacing="0" width="{$width}" height="{$height}" style="width:{$width}px;height:{$height}px"><tbody>';
     583
     584                var containers = tinyMCE.getParam("theme_advanced_containers", "", true, ",");
     585                var defaultContainerCSS = tinyMCE.getParam("theme_advanced_containers_default_class", "container");
     586                var defaultContainerAlign = tinyMCE.getParam("theme_advanced_containers_default_align", "center");
     587
     588                //Render Containers:
     589                for (var i = 0; i < containers.length; i++)
     590                {
     591                    if (containers[i] == "mceEditor") //Exceptions for mceEditor and ...
     592                        template['html'] += '<tr><td align="center" class="mceEditor_border"><span id="{$editor_id}"></span></td></tr>';
     593                    else if (containers[i] == "mceElementpath" || containers[i] == "mceStatusbar") // ... mceElementpath:
     594                    {
     595                        var pathClass = "mceStatusbar";
     596
     597                        if (i == containers.length-1)
     598                        {
     599                            pathClass = "mceStatusbarBottom";
     600                        }
     601                        else if (i == 0)
     602                        {
     603                            pathClass = "mceStatusbar";
     604                        }
     605                        else
     606                        {
     607                            deltaHeight-=2;
     608                        }
     609
     610                        template['html'] += '<tr><td class="' + pathClass + '" height="1">' + statusbarHTML + '</td></tr>';
     611                        deltaHeight -= 22;
     612                    } else { // Render normal Container
     613                        var curContainer = tinyMCE.getParam("theme_advanced_container_"+containers[i], "", true, ',');
     614                        var curContainerHTML = "";
     615                        var curAlign = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_align", defaultContainerAlign);
     616                        var curCSS = tinyMCE.getParam("theme_advanced_container_"+containers[i]+"_class", defaultContainerCSS);
     617
     618                        for (var j=0; j<curContainer.length; j++) {
     619                            curContainerHTML += tinyMCE.getControlHTML(curContainer[j]);
     620                        }
     621
     622                        if (curContainer.length > 0) {
     623                            curContainerHTML += "<br />";
     624                            deltaHeight -= 23;
     625                        }
     626
     627                        template['html'] += '<tr><td class="' + curCSS + '" align="' + curAlign + '" height="1">' + curContainerHTML + '</td></tr>';
     628                    }
     629                }
     630
     631                template['html'] += '</tbody></table>';
     632                //RowLayout
     633            break;
     634
     635            case "CustomLayout" : //User defined layout callback...
     636                var customLayout = tinyMCE.getParam("theme_advanced_custom_layout","");
     637
     638                if (customLayout != "" && eval("typeof(" + customLayout + ")") != "undefined") {
     639                    template = eval(customLayout + "(template);");
     640                }
     641            break;
     642        }
     643
     644        if (resizing)
     645            template['html'] += '<span id="{$editor_id}_resize_box" class="mceResizeBox"></span>';
     646
     647        template['html'] = tinyMCE.replaceVar(template['html'], 'style_select_options', styleSelectHTML);
     648        template['delta_width'] = 0;
     649        template['delta_height'] = deltaHeight;
     650
     651        return template;
     652    },
     653
     654    initInstance : function(inst) {
     655        if (tinyMCE.getParam("theme_advanced_resizing", false)) {
     656            if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) {
     657                var w = TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_width");
     658                var h = TinyMCE_AdvancedTheme._getCookie("TinyMCE_" + inst.editorId + "_height");
     659
     660                TinyMCE_AdvancedTheme._resizeTo(inst, w, h, tinyMCE.getParam("theme_advanced_resize_horizontal", true));
     661            }
     662        }
     663
     664        inst.addShortcut('ctrl', 'k', 'lang_link_desc', 'mceLink');
     665    },
     666
     667    /**
     668     * Node change handler.
     669     */
     670    handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection, setup_content) {
     671        function selectByValue(select_elm, value, first_index) {
     672            first_index = typeof(first_index) == "undefined" ? false : true;
     673
     674            if (select_elm) {
     675                for (var i=0; i<select_elm.options.length; i++) {
     676                    var ov = "" + select_elm.options[i].value;
     677
     678                    if (first_index && ov.toLowerCase().indexOf(value.toLowerCase()) == 0) {
     679                        select_elm.selectedIndex = i;
     680                        return true;
     681                    }
     682
     683                    if (ov == value) {
     684                        select_elm.selectedIndex = i;
     685                        return true;
     686                    }
     687                }
     688            }
     689
     690            return false;
     691        };
     692
     693        function getAttrib(elm, name) {
     694            return elm.getAttribute(name) ? elm.getAttribute(name) : "";
     695        };
     696
     697        // No node provided
     698        if (node == null)
     699            return;
     700
     701        // Update path
     702        var pathElm = document.getElementById(editor_id + "_path");
     703        var inst = tinyMCE.getInstanceById(editor_id);
     704        var doc = inst.getDoc();
     705
     706        if (pathElm) {
     707            // Get node path
     708            var parentNode = node;
     709            var path = new Array();
     710           
     711            while (parentNode != null) {
     712                if (parentNode.nodeName.toUpperCase() == "BODY") {
     713                    break;
     714                }
     715
     716                // Only append element nodes to path
     717                if (parentNode.nodeType == 1 && tinyMCE.getAttrib(parentNode, "class").indexOf('mceItemHidden') == -1) {
     718                    path[path.length] = parentNode;
     719                }
     720
     721                parentNode = parentNode.parentNode;
     722            }
     723
     724            // Setup HTML
     725            var html = "";
     726            for (var i=path.length-1; i>=0; i--) {
     727                var nodeName = path[i].nodeName.toLowerCase();
     728                var nodeData = "";
     729
     730                if (nodeName == "b") {
     731                    nodeName = "strong";
     732                }
     733
     734                if (nodeName == "i") {
     735                    nodeName = "em";
     736                }
     737
     738                if (nodeName == "span") {
     739                    var cn = tinyMCE.getAttrib(path[i], "class");
     740                    if (cn != "" && cn.indexOf('mceItem') == -1)
     741                        nodeData += "class: " + cn + " ";
     742
     743                    var st = tinyMCE.getAttrib(path[i], "style");
     744                    if (st != "") {
     745                        st = tinyMCE.serializeStyle(tinyMCE.parseStyle(st));
     746                        nodeData += "style: " + st + " ";
     747                    }
     748                }
     749
     750                if (nodeName == "font") {
     751                    if (tinyMCE.getParam("convert_fonts_to_spans"))
     752                        nodeName = "span";
     753
     754                    var face = tinyMCE.getAttrib(path[i], "face");
     755                    if (face != "")
     756                        nodeData += "font: " + face + " ";
     757
     758                    var size = tinyMCE.getAttrib(path[i], "size");
     759                    if (size != "")
     760                        nodeData += "size: " + size + " ";
     761
     762                    var color = tinyMCE.getAttrib(path[i], "color");
     763                    if (color != "")
     764                        nodeData += "color: " + color + " ";
     765                }
     766
     767                if (getAttrib(path[i], 'id') != "") {
     768                    nodeData += "id: " + path[i].getAttribute('id') + " ";
     769                }
     770
     771                var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false);
     772                if (className != "" && className.indexOf('mceItem') == -1)
     773                    nodeData += "class: " + className + " ";
     774
     775                if (getAttrib(path[i], 'src') != "") {
     776                    var src = tinyMCE.getAttrib(path[i], "mce_src");
     777
     778                    if (src == "")
     779                         src = tinyMCE.getAttrib(path[i], "src");
     780
     781                    nodeData += "src: " + src + " ";
     782                }
     783
     784                if (getAttrib(path[i], 'href') != "") {
     785                    var href = tinyMCE.getAttrib(path[i], "mce_href");
     786
     787                    if (href == "")
     788                         href = tinyMCE.getAttrib(path[i], "href");
     789
     790                    nodeData += "href: " + href + " ";
     791                }
     792
     793                if (nodeName == "img" && tinyMCE.getAttrib(path[i], "class").indexOf('mceItemFlash') != -1) {
     794                    nodeName = "flash";
     795                    nodeData = "src: " + path[i].getAttribute('title');
     796                }
     797
     798                if (nodeName == "a" && (anchor = tinyMCE.getAttrib(path[i], "name")) != "") {
     799                    nodeName = "a";
     800                    nodeName += "#" + anchor;
     801                    nodeData = "";
     802                }
     803
     804                if (getAttrib(path[i], 'name').indexOf("mce_") != 0) {
     805                    var className = tinyMCE.getVisualAidClass(tinyMCE.getAttrib(path[i], "class"), false);
     806                    if (className != "" && className.indexOf('mceItem') == -1) {
     807                        nodeName += "." + className;
     808                    }
     809                }
     810
     811                var cmd = 'tinyMCE.execInstanceCommand(\'' + editor_id + '\',\'mceSelectNodeDepth\',false,\'' + i + '\');';
     812                html += '<a title="' + nodeData + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" target="_self" class="mcePathItem">' + nodeName + '</a>';
     813
     814                if (i > 0) {
     815                    html += " &raquo; ";
     816                }
     817            }
     818
     819            pathElm.innerHTML = '<a href="#" accesskey="x"></a>' + tinyMCE.getLang('lang_theme_path') + ": " + html + '&#160;';
     820        }
     821
     822        // Reset old states
     823        tinyMCE.switchClass(editor_id + '_justifyleft', 'mceButtonNormal');
     824        tinyMCE.switchClass(editor_id + '_justifyright', 'mceButtonNormal');
     825        tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonNormal');
     826        tinyMCE.switchClass(editor_id + '_justifyfull', 'mceButtonNormal');
     827        tinyMCE.switchClass(editor_id + '_bold', 'mceButtonNormal');
     828        tinyMCE.switchClass(editor_id + '_italic', 'mceButtonNormal');
     829        tinyMCE.switchClass(editor_id + '_underline', 'mceButtonNormal');
     830        tinyMCE.switchClass(editor_id + '_strikethrough', 'mceButtonNormal');
     831        tinyMCE.switchClass(editor_id + '_bullist', 'mceButtonNormal');
     832        tinyMCE.switchClass(editor_id + '_numlist', 'mceButtonNormal');
     833        tinyMCE.switchClass(editor_id + '_sub', 'mceButtonNormal');
     834        tinyMCE.switchClass(editor_id + '_sup', 'mceButtonNormal');
     835        tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonNormal');
     836        tinyMCE.switchClass(editor_id + '_link', 'mceButtonDisabled');
     837        tinyMCE.switchClass(editor_id + '_unlink', 'mceButtonDisabled');
     838        tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonDisabled');
     839        tinyMCE.switchClass(editor_id + '_image', 'mceButtonNormal');
     840        tinyMCE.switchClass(editor_id + '_hr', 'mceButtonNormal');
     841
     842        if (node.nodeName == "A" && tinyMCE.getAttrib(node, "class").indexOf('mceItemAnchor') != -1)
     843            tinyMCE.switchClass(editor_id + '_anchor', 'mceButtonSelected');
     844
     845        // Get link
     846        var anchorLink = tinyMCE.getParentElement(node, "a", "href");
     847
     848        if (anchorLink || any_selection) {
     849            tinyMCE.switchClass(editor_id + '_link', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal');
     850            tinyMCE.switchClass(editor_id + '_unlink', anchorLink ? 'mceButtonSelected' : 'mceButtonNormal');
     851        }
     852
     853        // Handle visual aid
     854        tinyMCE.switchClass(editor_id + '_visualaid', visual_aid ? 'mceButtonSelected' : 'mceButtonNormal');
     855
     856        if (undo_levels != -1) {
     857            tinyMCE.switchClass(editor_id + '_undo', 'mceButtonDisabled');
     858            tinyMCE.switchClass(editor_id + '_redo', 'mceButtonDisabled');
     859        }
     860
     861        // Within li, blockquote
     862        if (tinyMCE.getParentElement(node, "li,blockquote"))
     863            tinyMCE.switchClass(editor_id + '_outdent', 'mceButtonNormal');
     864
     865        // Has redo levels
     866        if (undo_index != -1 && (undo_index < undo_levels-1 && undo_levels > 0))
     867            tinyMCE.switchClass(editor_id + '_redo', 'mceButtonNormal');
     868
     869        // Has undo levels
     870        if (undo_index != -1 && (undo_index > 0 && undo_levels > 0))
     871            tinyMCE.switchClass(editor_id + '_undo', 'mceButtonNormal');
     872
     873        // Select class in select box
     874        var selectElm = document.getElementById(editor_id + "_styleSelect");
     875       
     876        if (selectElm) {
     877            TinyMCE_AdvancedTheme._setupCSSClasses(editor_id);
     878
     879            classNode = node;
     880            breakOut = false;
     881            var index = 0;
     882
     883            do {
     884                if (classNode && classNode.className) {
     885                    for (var i=0; i<selectElm.options.length; i++) {
     886                        if (selectElm.options[i].value == classNode.className) {
     887                            index = i;
     888                            breakOut = true;
     889                            break;
     890                        }
     891                    }
     892                }
     893            } while (!breakOut && classNode != null && (classNode = classNode.parentNode) != null);
     894
     895            selectElm.selectedIndex = index;
     896        }
     897
     898        // Select formatblock
     899        var selectElm = document.getElementById(editor_id + "_formatSelect");
     900        if (selectElm) {
     901            var elm = tinyMCE.getParentElement(node, "p,div,h1,h2,h3,h4,h5,h6,pre,address");
     902
     903            if (elm)
     904                selectByValue(selectElm, "<" + elm.nodeName.toLowerCase() + ">");
     905            else
     906                selectByValue(selectElm, "");
     907        }
     908
     909        // Select fontselect
     910        var selectElm = document.getElementById(editor_id + "_fontNameSelect");
     911        if (selectElm) {
     912            if (!tinyMCE.isSafari && !(tinyMCE.isMSIE && !tinyMCE.isOpera)) {
     913                var face = inst.queryCommandValue('FontName');
     914
     915                face = face == null || face == "" ? "" : face;
     916
     917                selectByValue(selectElm, face, face != "");
     918            } else {
     919                var elm = tinyMCE.getParentElement(node, "font", "face");
     920
     921                if (elm) {
     922                    var family = tinyMCE.getAttrib(elm, "face");
     923
     924                    if (family == '')
     925                        family = '' + elm.style.fontFamily;
     926
     927                    if (!selectByValue(selectElm, family, family != ""))
     928                        selectByValue(selectElm, "");
     929                } else
     930                    selectByValue(selectElm, "");
     931            }
     932        }
     933
     934        // Select fontsize
     935        var selectElm = document.getElementById(editor_id + "_fontSizeSelect");
     936        if (selectElm) {
     937            if (!tinyMCE.isSafari && !tinyMCE.isOpera) {
     938                var size = inst.queryCommandValue('FontSize');
     939                selectByValue(selectElm, size == null || size == "" ? "0" : size);
     940            } else {
     941                var elm = tinyMCE.getParentElement(node, "font", "size");
     942                if (elm) {
     943                    var size = tinyMCE.getAttrib(elm, "size");
     944
     945                    if (size == '') {
     946                        var sizes = new Array('', '8px', '10px', '12px', '14px', '18px', '24px', '36px');
     947
     948                        size = '' + elm.style.fontSize;
     949
     950                        for (var i=0; i<sizes.length; i++) {
     951                            if (('' + sizes[i]) == size) {
     952                                size = i;
     953                                break;
     954                            }
     955                        }
     956                    }
     957
     958                    if (!selectByValue(selectElm, size))
     959                        selectByValue(selectElm, "");
     960                } else
     961                    selectByValue(selectElm, "0");
     962            }
     963        }
     964
     965        // Handle align attributes
     966        alignNode = node;
     967        breakOut = false;
     968        do {
     969            if (!alignNode.getAttribute || !alignNode.getAttribute('align'))
     970                continue;
     971
     972            switch (alignNode.getAttribute('align').toLowerCase()) {
     973                case "left":
     974                    tinyMCE.switchClass(editor_id + '_justifyleft', 'mceButtonSelected');
     975                    breakOut = true;
     976                break;
     977
     978                case "right":
     979                    tinyMCE.switchClass(editor_id + '_justifyright', 'mceButtonSelected');
     980                    breakOut = true;
     981                break;
     982
     983                case "middle":
     984                case "center":
     985                    tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonSelected');
     986                    breakOut = true;
     987                break;
     988
     989                case "justify":
     990                    tinyMCE.switchClass(editor_id + '_justifyfull', 'mceButtonSelected');
     991                    breakOut = true;
     992                break;
     993            }
     994        } while (!breakOut && (alignNode = alignNode.parentNode) != null);
     995
     996        // Div justification
     997        var div = tinyMCE.getParentElement(node, "div");
     998        if (div && div.style.textAlign == "center")
     999            tinyMCE.switchClass(editor_id + '_justifycenter', 'mceButtonSelected');
     1000
     1001        // Do special text
     1002        if (!setup_content) {
     1003            // , "JustifyLeft", "_justifyleft", "JustifyCenter", "justifycenter", "JustifyRight", "justifyright", "JustifyFull", "justifyfull", "InsertUnorderedList", "bullist", "InsertOrderedList", "numlist", "InsertUnorderedList", "bullist", "Outdent", "outdent", "Indent", "indent", "subscript", "sub"
     1004            var ar = new Array("Bold", "_bold", "Italic", "_italic", "Strikethrough", "_strikethrough", "superscript", "_sup", "subscript", "_sub");
     1005            for (var i=0; i<ar.length; i+=2) {
     1006                if (inst.queryCommandState(ar[i]))
     1007                    tinyMCE.switchClass(editor_id + ar[i+1], 'mceButtonSelected');
     1008            }
     1009
     1010            if (inst.queryCommandState("Underline") && (node.parentNode == null || node.parentNode.nodeName != "A"))
     1011                tinyMCE.switchClass(editor_id + '_underline', 'mceButtonSelected');
     1012        }
     1013
     1014        // Handle elements
     1015        do {
     1016            switch (node.nodeName) {
     1017                case "UL":
     1018                    tinyMCE.switchClass(editor_id + '_bullist', 'mceButtonSelected');
     1019                break;
     1020
     1021                case "OL":
     1022                    tinyMCE.switchClass(editor_id + '_numlist', 'mceButtonSelected');
     1023                break;
     1024
     1025                case "HR":
     1026                     tinyMCE.switchClass(editor_id + '_hr', 'mceButtonSelected');
     1027                break;
     1028
     1029                case "IMG":
     1030                if (getAttrib(node, 'name').indexOf('mce_') != 0) {
     1031                    tinyMCE.switchClass(editor_id + '_image', 'mceButtonSelected');
     1032                }
     1033                break;
     1034            }
     1035        } while ((node = node.parentNode) != null);
     1036    },
     1037
     1038    // Private theme internal functions
     1039
     1040    // This function auto imports CSS classes into the class selection droplist
     1041    _setupCSSClasses : function(editor_id) {
     1042        var i, selectElm;
     1043
     1044        if (!TinyMCE_AdvancedTheme._autoImportCSSClasses)
     1045            return;
     1046
     1047        selectElm = document.getElementById(editor_id + '_styleSelect');
     1048
     1049        if (selectElm && selectElm.getAttribute('cssImported') != 'true') {
     1050            var csses = tinyMCE.getCSSClasses(editor_id);
     1051            if (csses && selectElm) {
     1052                for (i=0; i<csses.length; i++)
     1053                    selectElm.options[selectElm.options.length] = new Option(csses[i], csses[i]);
     1054            }
     1055
     1056            // Only do this once
     1057            if (csses != null && csses.length > 0)
     1058                selectElm.setAttribute('cssImported', 'true');
     1059        }
     1060    },
     1061
     1062    _setCookie : function(name, value, expires, path, domain, secure) {
     1063        var curCookie = name + "=" + escape(value) +
     1064            ((expires) ? "; expires=" + expires.toGMTString() : "") +
     1065            ((path) ? "; path=" + escape(path) : "") +
     1066            ((domain) ? "; domain=" + domain : "") +
     1067            ((secure) ? "; secure" : "");
     1068
     1069        document.cookie = curCookie;
     1070    },
     1071
     1072    _getCookie : function(name) {
     1073        var dc = document.cookie;
     1074        var prefix = name + "=";
     1075        var begin = dc.indexOf("; " + prefix);
     1076
     1077        if (begin == -1) {
     1078            begin = dc.indexOf(prefix);
     1079
     1080            if (begin != 0)
     1081                return null;
     1082        } else
     1083            begin += 2;
     1084
     1085        var end = document.cookie.indexOf(";", begin);
     1086
     1087        if (end == -1)
     1088            end = dc.length;
     1089
     1090        return unescape(dc.substring(begin + prefix.length, end));
     1091    },
     1092
     1093    _resizeTo : function(inst, w, h, set_w) {
     1094        var editorContainer = document.getElementById(inst.editorId + '_parent');
     1095        var tableElm = editorContainer.firstChild;
     1096        var iframe = inst.iframeElement;
     1097
     1098        if (w == null || w == "null") {
     1099            set_w = false;
     1100            w = 0;
     1101        }
     1102
     1103        if (h == null || h == "null")
     1104            return;
     1105
     1106        w = parseInt(w);
     1107        h = parseInt(h);
     1108
     1109        if (tinyMCE.isGecko) {
     1110            w += 2;
     1111            h += 2;
     1112        }
     1113
     1114        var dx = w - tableElm.clientWidth;
     1115        var dy = h - tableElm.clientHeight;
     1116
     1117        w = w < 1 ? 30 : w;
     1118        h = h < 1 ? 30 : h;
     1119
     1120        if (set_w)
     1121            tableElm.style.width = w + "px";
     1122
     1123        tableElm.style.height = h + "px";
     1124
     1125        iw = iframe.clientWidth + dx;
     1126        ih = iframe.clientHeight + dy;
     1127
     1128        iw = iw < 1 ? 30 : iw;
     1129        ih = ih < 1 ? 30 : ih;
     1130
     1131        if (tinyMCE.isGecko) {
     1132            iw -= 2;
     1133            ih -= 2;
     1134        }
     1135
     1136        if (set_w)
     1137            iframe.style.width = iw + "px";
     1138
     1139        iframe.style.height = ih + "px";
     1140
     1141        // Is it to small, make it bigger again
     1142        if (set_w) {
     1143            var tableBodyElm = tableElm.firstChild;
     1144            var minIframeWidth = tableBodyElm.scrollWidth;
     1145            if (inst.iframeElement.clientWidth < minIframeWidth) {
     1146                dx = minIframeWidth - inst.iframeElement.clientWidth;
     1147
     1148                inst.iframeElement.style.width = (iw + dx) + "px";
     1149            }
     1150        }
     1151    },
     1152
     1153    /**
     1154     * Handles resizing events.
     1155     */
     1156    _resizeEventHandler : function(e) {
     1157        var resizer = TinyMCE_AdvancedTheme._resizer;
     1158
     1159        // Do nothing
     1160        if (!resizer.resizing)
     1161            return;
     1162
     1163        e = typeof(e) == "undefined" ? window.event : e;
     1164
     1165        var dx = e.screenX - resizer.downX;
     1166        var dy = e.screenY - resizer.downY;
     1167        var resizeBox = resizer.resizeBox;
     1168        var editorId = resizer.editorId;
     1169
     1170        switch (e.type) {
     1171            case "mousemove":
     1172                var w, h;
     1173
     1174                w = resizer.width + dx;
     1175                h = resizer.height + dy;
     1176
     1177                w = w < 1 ? 1 : w;
     1178                h = h < 1 ? 1 : h;
     1179
     1180                if (resizer.horizontal)
     1181                    resizeBox.style.width = w + "px";
     1182
     1183                resizeBox.style.height = h + "px";
     1184                break;
     1185
     1186            case "mouseup":
     1187                TinyMCE_AdvancedTheme._setResizing(e, editorId, false);
     1188                TinyMCE_AdvancedTheme._resizeTo(tinyMCE.getInstanceById(editorId), resizer.width + dx, resizer.height + dy, resizer.horizontal);
     1189
     1190                // Expire in a month
     1191                if (tinyMCE.getParam("theme_advanced_resizing_use_cookie", true)) {
     1192                    var expires = new Date();
     1193                    expires.setTime(expires.getTime() + 3600000 * 24 * 30);
     1194
     1195                    // Set the cookies
     1196                    TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + editorId + "_width", "" + (resizer.horizontal ? resizer.width + dx : ""), expires);
     1197                    TinyMCE_AdvancedTheme._setCookie("TinyMCE_" + editorId + "_height", "" + (resizer.height + dy), expires);
     1198                }
     1199                break;
     1200        }
     1201    },
     1202
     1203    /**
     1204     * Starts/stops the editor resizing.
     1205     */
     1206    _setResizing : function(e, editor_id, state) {
     1207        e = typeof(e) == "undefined" ? window.event : e;
     1208
     1209        var resizer = TinyMCE_AdvancedTheme._resizer;
     1210        var editorContainer = document.getElementById(editor_id + '_parent');
     1211        var editorArea = document.getElementById(editor_id + '_parent').firstChild;
     1212        var resizeBox = document.getElementById(editor_id + '_resize_box');
     1213        var inst = tinyMCE.getInstanceById(editor_id);
     1214
     1215        if (state) {
     1216            // Place box over editor area
     1217            var width = editorArea.clientWidth;
     1218            var height = editorArea.clientHeight;
     1219
     1220            resizeBox.style.width = width + "px";
     1221            resizeBox.style.height = height + "px";
     1222
     1223            resizer.iframeWidth = inst.iframeElement.clientWidth;
     1224            resizer.iframeHeight = inst.iframeElement.clientHeight;
     1225
     1226            // Hide editor and show resize box
     1227            editorArea.style.display = "none";
     1228            resizeBox.style.display = "block";
     1229
     1230            // Add event handlers, only once
     1231            if (!resizer.eventHandlers) {
     1232                if (tinyMCE.isMSIE)
     1233                    tinyMCE.addEvent(document, "mousemove", TinyMCE_AdvancedTheme._resizeEventHandler);
     1234                else
     1235                    tinyMCE.addEvent(window, "mousemove", TinyMCE_AdvancedTheme._resizeEventHandler);
     1236
     1237                tinyMCE.addEvent(document, "mouseup", TinyMCE_AdvancedTheme._resizeEventHandler);
     1238
     1239                resizer.eventHandlers = true;
     1240            }
     1241
     1242            resizer.resizing = true;
     1243            resizer.downX = e.screenX;
     1244            resizer.downY = e.screenY;
     1245            resizer.width = parseInt(resizeBox.style.width);
     1246            resizer.height = parseInt(resizeBox.style.height);
     1247            resizer.editorId = editor_id;
     1248            resizer.resizeBox = resizeBox;
     1249            resizer.horizontal = tinyMCE.getParam("theme_advanced_resize_horizontal", true);
     1250        } else {
     1251            resizer.resizing = false;
     1252            resizeBox.style.display = "none";
     1253            editorArea.style.display = tinyMCE.isMSIE && !tinyMCE.isOpera ? "block" : "table";
     1254            tinyMCE.execCommand('mceResetDesignMode');
     1255        }
     1256    },
     1257
     1258    _insertImage : function(src, alt, border, hspace, vspace, width, height, align, title, onmouseover, onmouseout) {
     1259        tinyMCE.execCommand('mceBeginUndoLevel');
     1260
     1261        if (src == "")
     1262            return;
     1263
     1264        if (!tinyMCE.imgElement && tinyMCE.isSafari) {
     1265            var html = "";
     1266
     1267            html += '<img src="' + src + '" alt="' + alt + '"';
     1268            html += ' border="' + border + '" hspace="' + hspace + '"';
     1269            html += ' vspace="' + vspace + '" width="' + width + '"';
     1270            html += ' height="' + height + '" align="' + align + '" title="' + title + '" onmouseover="' + onmouseover + '" onmouseout="' + onmouseout + '" />';
     1271
     1272            tinyMCE.execCommand("mceInsertContent", false, html);
     1273        } else {
     1274            if (!tinyMCE.imgElement && tinyMCE.selectedInstance) {
     1275                if (tinyMCE.isSafari)
     1276                    tinyMCE.execCommand("mceInsertContent", false, '<img src="' + tinyMCE.uniqueURL + '" />');
     1277                else
     1278                    tinyMCE.selectedInstance.contentDocument.execCommand("insertimage", false, tinyMCE.uniqueURL);
     1279
     1280                tinyMCE.imgElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "img", "src", tinyMCE.uniqueURL);
     1281            }
     1282        }
     1283
     1284        if (tinyMCE.imgElement) {
     1285            var needsRepaint = false;
     1286            var msrc = src;
     1287
     1288            src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, tinyMCE.imgElement);");
     1289
     1290            if (tinyMCE.getParam('convert_urls'))
     1291                msrc = src;
     1292
     1293            if (onmouseover && onmouseover != "")
     1294                onmouseover = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseover, tinyMCE.imgElement);") + "';";
     1295
     1296            if (onmouseout && onmouseout != "")
     1297                onmouseout = "this.src='" + eval(tinyMCE.settings['urlconverter_callback'] + "(onmouseout, tinyMCE.imgElement);") + "';";
     1298
     1299            // Use alt as title if it's undefined
     1300            if (typeof(title) == "undefined")
     1301                title = alt;
     1302
     1303            if (width != tinyMCE.imgElement.getAttribute("width") || height != tinyMCE.imgElement.getAttribute("height") || align != tinyMCE.imgElement.getAttribute("align"))
     1304                needsRepaint = true;
     1305
     1306            tinyMCE.setAttrib(tinyMCE.imgElement, 'src', src);
     1307            tinyMCE.setAttrib(tinyMCE.imgElement, 'mce_src', msrc);
     1308            tinyMCE.setAttrib(tinyMCE.imgElement, 'alt', alt);
     1309            tinyMCE.setAttrib(tinyMCE.imgElement, 'title', title);
     1310            tinyMCE.setAttrib(tinyMCE.imgElement, 'align', align);
     1311            tinyMCE.setAttrib(tinyMCE.imgElement, 'border', border, true);
     1312            tinyMCE.setAttrib(tinyMCE.imgElement, 'hspace', hspace, true);
     1313            tinyMCE.setAttrib(tinyMCE.imgElement, 'vspace', vspace, true);
     1314            tinyMCE.setAttrib(tinyMCE.imgElement, 'width', width, true);
     1315            tinyMCE.setAttrib(tinyMCE.imgElement, 'height', height, true);
     1316            tinyMCE.setAttrib(tinyMCE.imgElement, 'onmouseover', onmouseover);
     1317            tinyMCE.setAttrib(tinyMCE.imgElement, 'onmouseout', onmouseout);
     1318
     1319            // Fix for bug #989846 - Image resize bug
     1320            if (width && width != "")
     1321                tinyMCE.imgElement.style.pixelWidth = width;
     1322
     1323            if (height && height != "")
     1324                tinyMCE.imgElement.style.pixelHeight = height;
     1325
     1326            if (needsRepaint)
     1327                tinyMCE.selectedInstance.repaint();
     1328        }
     1329
     1330        tinyMCE.execCommand('mceEndUndoLevel');
     1331    },
     1332
     1333    _insertLink : function(href, target, title, onclick, style_class) {
     1334        tinyMCE.execCommand('mceBeginUndoLevel');
     1335
     1336        if (tinyMCE.selectedInstance && tinyMCE.selectedElement && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") {
     1337            var doc = tinyMCE.selectedInstance.getDoc();
     1338            var linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
     1339            var newLink = false;
     1340
     1341            if (!linkElement) {
     1342                linkElement = doc.createElement("a");
     1343                newLink = true;
     1344            }
     1345
     1346            var mhref = href;
     1347            var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, linkElement);");
     1348            mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
     1349
     1350            tinyMCE.setAttrib(linkElement, 'href', thref);
     1351            tinyMCE.setAttrib(linkElement, 'mce_href', mhref);
     1352            tinyMCE.setAttrib(linkElement, 'target', target);
     1353            tinyMCE.setAttrib(linkElement, 'title', title);
     1354            tinyMCE.setAttrib(linkElement, 'onclick', onclick);
     1355            tinyMCE.setAttrib(linkElement, 'class', style_class);
     1356
     1357            if (newLink) {
     1358                linkElement.appendChild(tinyMCE.selectedElement.cloneNode(true));
     1359                tinyMCE.selectedElement.parentNode.replaceChild(linkElement, tinyMCE.selectedElement);
     1360            }
     1361
     1362            return;
     1363        }
     1364
     1365        if (!tinyMCE.linkElement && tinyMCE.selectedInstance) {
     1366            if (tinyMCE.isSafari) {
     1367                tinyMCE.execCommand("mceInsertContent", false, '<a href="' + tinyMCE.uniqueURL + '">' + tinyMCE.selectedInstance.selection.getSelectedHTML() + '</a>');
     1368            } else
     1369                tinyMCE.selectedInstance.contentDocument.execCommand("createlink", false, tinyMCE.uniqueURL);
     1370
     1371            tinyMCE.linkElement = tinyMCE.getElementByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);
     1372
     1373            var elementArray = tinyMCE.getElementsByAttributeValue(tinyMCE.selectedInstance.contentDocument.body, "a", "href", tinyMCE.uniqueURL);
     1374
     1375            for (var i=0; i<elementArray.length; i++) {
     1376                var mhref = href;
     1377                var thref = eval(tinyMCE.settings['urlconverter_callback'] + "(href, elementArray[i]);");
     1378                mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
     1379
     1380                tinyMCE.setAttrib(elementArray[i], 'href', thref);
     1381                tinyMCE.setAttrib(elementArray[i], 'mce_href', mhref);
     1382                tinyMCE.setAttrib(elementArray[i], 'target', target);
     1383                tinyMCE.setAttrib(elementArray[i], 'title', title);
     1384                tinyMCE.setAttrib(elementArray[i], 'onclick', onclick);
     1385                tinyMCE.setAttrib(elementArray[i], 'class', style_class);
     1386            }
     1387
     1388            tinyMCE.linkElement = elementArray[0];
     1389        }
     1390
     1391        if (tinyMCE.linkElement) {
     1392            var mhref = href;
     1393            href = eval(tinyMCE.settings['urlconverter_callback'] + "(href, tinyMCE.linkElement);");
     1394            mhref = tinyMCE.getParam('convert_urls') ? href : mhref;
     1395
     1396            tinyMCE.setAttrib(tinyMCE.linkElement, 'href', href);
     1397            tinyMCE.setAttrib(tinyMCE.linkElement, 'mce_href', mhref);
     1398            tinyMCE.setAttrib(tinyMCE.linkElement, 'target', target);
     1399            tinyMCE.setAttrib(tinyMCE.linkElement, 'title', title);
     1400            tinyMCE.setAttrib(tinyMCE.linkElement, 'onclick', onclick);
     1401            tinyMCE.setAttrib(tinyMCE.linkElement, 'class', style_class);
     1402        }
     1403
     1404        tinyMCE.execCommand('mceEndUndoLevel');
     1405    }
     1406};
     1407
     1408tinyMCE.addTheme("advanced", TinyMCE_AdvancedTheme);
     1409
     1410// Add default buttons maps for advanced theme and all internal plugins
     1411tinyMCE.addButtonMap(TinyMCE_AdvancedTheme._buttonMap);
  • trunk/wp-includes/js/tinymce/themes/advanced/image.htm

    r3503 r4431  
    33    <title>{$lang_insert_image_title}</title>
    44    <script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
     5    <script language="javascript" type="text/javascript" src="../../utils/mctabs.js"></script>
    56    <script language="javascript" type="text/javascript" src="../../utils/form_utils.js"></script>
    67    <script language="javascript" type="text/javascript" src="jscripts/image.js"></script>
    7     <style type="text/css">
    8         #insert, #cancel {
    9             font: 13px Verdana, Arial, Helvetica, sans-serif;
    10             height:auto;
    11             width: auto;
    12             background-color: transparent;
    13             background-image: url(../../../../../wp-admin/images/fade-butt.png);
    14             background-repeat: repeat;
    15             border: 3px double;
    16             border-right-color: rgb(153, 153, 153);
    17             border-bottom-color: rgb(153, 153, 153);
    18             border-left-color: rgb(204, 204, 204);
    19             border-top-color: rgb(204, 204, 204);
    20             color: rgb(51, 51, 51);
    21             padding: 0.25em 1em;
    22         }
    23         #insert:active, #cancel:active {
    24             background: #f4f4f4;
    25             border-left-color: #999;
    26             border-top-color: #999;
    27         }
    28     </style>
     8    <base target="_self" />
    299</head>
    30 <body onload="tinyMCEPopup.executeOnLoad('init();');document.getElementById('src').focus();" style="display: none">
    31 <form onsubmit="insertImage();return false;">
    32   <table border="0" cellpadding="0" cellspacing="0" width="200">
    33     <tr>
    34       <td align="center" valign="middle"><table border="0" cellpadding="4" cellspacing="0">
     10<body id="image" onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('src').focus();" style="display: none">
     11<form onsubmit="insertImage();return false;" action="#">
     12    <div class="tabs">
     13        <ul>
     14            <li id="general_tab" class="current"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{$lang_insert_image_title}</a></span></li>
     15        </ul>
     16    </div>
     17
     18    <div class="panel_wrapper">
     19        <div id="general_panel" class="panel current">
     20     <table border="0" cellpadding="4" cellspacing="0">
    3521          <tr>
    36             <td colspan="2" class="title" nowrap="nowrap">{$lang_insert_image_title}</td>
    37           </tr>
    38           <tr>
    39             <td nowrap="nowrap">{$lang_insert_image_src}:</td>
     22            <td nowrap="nowrap"><label for="src">{$lang_insert_image_src}</label></td>
    4023            <td><table border="0" cellspacing="0" cellpadding="0">
    4124                <tr>
    42                   <td><input name="src" type="text" id="src" value="" style="width: 200px" onchange="getImageData();"></td>
     25                  <td><input id="src" name="src" type="text" value="" style="width: 200px" onchange="getImageData();"></td>
    4326                  <td id="srcbrowsercontainer">&nbsp;</td>
    4427                </tr>
     
    5033                var html = "";
    5134
    52                 html += '<tr><td>{$lang_image_list}:</td>';
    53                 html += '<td><select name="image_list" style="width: 200px" onchange="this.form.src.value=this.options[this.selectedIndex].value;resetImageData();getImageData();">';
     35                html += '<tr><td><label for="image_list">{$lang_image_list}</label></td>';
     36                html += '<td><select id="image_list" name="image_list" style="width: 200px" onchange="this.form.src.value=this.options[this.selectedIndex].value;resetImageData();getImageData();">';
    5437                html += '<option value="">---</option>';
    5538
     
    6447          <!-- /Image list -->
    6548          <tr>
    66             <td nowrap="nowrap">{$lang_insert_image_alt}:</td>
    67             <td><input name="alt" type="text" id="alt" value="" style="width: 200px"></td>
     49            <td nowrap="nowrap"><label for="alt">{$lang_insert_image_alt}</label></td>
     50            <td><input id="alt" name="alt" type="text" value="" style="width: 200px"></td>
    6851          </tr>
    6952          <tr>
    70             <td nowrap="nowrap">{$lang_insert_image_align}:</td>
    71             <td><select name="align">
     53            <td nowrap="nowrap"><label for="align">{$lang_insert_image_align}</label></td>
     54            <td><select id="align" name="align">
    7255                <option value="">{$lang_insert_image_align_default}</option>
    7356                <option value="baseline">{$lang_insert_image_align_baseline}</option>
     
    8366          </tr>
    8467          <tr>
    85             <td nowrap="nowrap"><!--{$lang_insert_image_dimensions}:</td>
    86             <td><input name="width" type="text" id="width" value="" size="3" maxlength="3">
     68            <td nowrap="nowrap"><label for="width">{$lang_insert_image_dimensions}</label></td>
     69            <td><input id="width" name="width" type="text" value="" size="4" maxlength="4">
    8770              x
    88               <input name="height" type="text" id="height" value="" size="3" maxlength="3">--></td>
    89           </tr>
    90 <!--          <tr>
    91             <td nowrap="nowrap">{$lang_insert_image_border}:</td>
    92             <td><input name="border" type="text" id="border" value="" size="3" maxlength="3"></td>
     71              <input id="height" name="height" type="text" value="" size="4" maxlength="4"></td>
    9372          </tr>
    9473          <tr>
    95             <td nowrap="nowrap">{$lang_insert_image_vspace}:</td>
    96             <td><input name="vspace" type="text" id="vspace" value="" size="3" maxlength="3"></td>
     74            <td nowrap="nowrap"><label for="border">{$lang_insert_image_border}</label></td>
     75            <td><input id="border" name="border" type="text" value="" size="4" maxlength="4"></td>
    9776          </tr>
    9877          <tr>
    99             <td nowrap="nowrap">{$lang_insert_image_hspace}:</td>
    100             <td><input name="hspace" type="text" id="hspace" value="" size="3" maxlength="3"></td>
     78            <td nowrap="nowrap"><label for="vspace">{$lang_insert_image_vspace}</label></td>
     79            <td><input id="vspace" name="vspace" type="text" value="" size="4" maxlength="4"></td>
    10180          </tr>
    102 -->          <tr>
    103             <td nowrap="nowrap"><input type="submit" id="insert" name="insert" value="{$lang_insert}" onclick="insertImage();">
    104             </td>
    105             <td align="right"><input type="button" id="cancel" name="cancel" value="{$lang_cancel}" onclick="tinyMCEPopup.close();"></td>
     81          <tr>
     82            <td nowrap="nowrap"><label for="hspace">{$lang_insert_image_hspace}</label></td>
     83            <td><input id="hspace" name="hspace" type="text" value="" size="4" maxlength="4"></td>
    10684          </tr>
    107         </table></td>
    108     </tr>
    109   </table>
     85        </table>
     86        </div>
     87    </div>
     88
     89    <div class="mceActionPanel">
     90        <div style="float: left">
     91            <input type="button" id="cancel" name="cancel" value="{$lang_cancel}" onclick="tinyMCEPopup.close();" />
     92        </div>
     93
     94        <div style="float: right">
     95            <input type="submit" id="insert" name="insert" value="{$lang_insert}" onclick="insertImage();" />
     96        </div>
     97    </div>
    11098</form>
    11199</body>
  • trunk/wp-includes/js/tinymce/themes/advanced/jscripts/about.js

    r3503 r4431  
    11function init() {
     2    var inst;
     3
    24    tinyMCEPopup.resizeToInnerSize();
     5    inst = tinyMCE.selectedInstance;
    36
    47    // Give FF some time
     
    2124    html += '<tbody>';
    2225
    23     for (var i=0; i<plugins.length; i++) {
    24         var info = getPluginInfo(plugins[i]);
     26    for (var i=0; i<inst.plugins.length; i++) {
     27        var info = getPluginInfo(inst.plugins[i]);
    2528
    2629        html += '<tr>';
     
    4750
    4851function getPluginInfo(name) {
    49     var fn = eval('tinyMCEPopup.windowOpener.TinyMCE_' + name + '_getInfo');
    50 
    51     if (typeof(fn) != 'undefined')
    52         return fn();
     52    if (tinyMCE.plugins[name].getInfo)
     53        return tinyMCE.plugins[name].getInfo();
    5354
    5455    return {
  • trunk/wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js

    r3503 r4431  
    2727function insertAnchor() {
    2828    var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id'));
    29     var name = document.forms[0].anchorName.value;
     29    var name = document.forms[0].anchorName.value, e;
    3030
    3131    tinyMCEPopup.execCommand("mceBeginUndoLevel");
     
    4545        name = name.replace(/\"/g, '&quot;');
    4646        name = name.replace(/</g, '&lt;');
    47         name = name.replace(/>/g, '&gr;');
     47        name = name.replace(/>/g, '&gt;');
    4848
    49         html = '<a name="' + name + '"></a>';
     49        // Fix for bug #1447335
     50        if (tinyMCE.isGecko)
     51            html = '<a id="mceNewAnchor" name="' + name + '"></a>';
     52        else
     53            html = '<a name="' + name + '"></a>';
    5054
    5155        tinyMCEPopup.execCommand("mceInsertContent", false, html);
     56
     57        // Fix for bug #1447335 force cursor after the anchor element
     58        if (tinyMCE.isGecko) {
     59            e = inst.getDoc().getElementById('mceNewAnchor');
     60
     61            if (e) {
     62                inst.selection.selectNode(e, true, false, false);
     63                e.removeAttribute('id');
     64            }
     65        }
     66
    5267        tinyMCE.handleVisualAid(inst.getBody(), true, inst.visualAid, inst);
    5368    }
  • trunk/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js

    r3503 r4431  
    171171    ['&thorn;',   '&#254;',  true, 'thorn'],
    172172    ['&yuml;',    '&#255;',  true, 'y - diaeresis'],
    173 // ['&Alpha;',   '&#913;',  true, 'Alpha'],
     173    ['&Alpha;',   '&#913;',  true, 'Alpha'],
    174174    ['&Beta;',    '&#914;',  true, 'Beta'],
    175175    ['&Gamma;',   '&#915;',  true, 'Gamma'],
     
    280280            html += ''
    281281                + '<td width="' + tdWidth + '" height="' + tdHeight + '" class="charmap"'
    282                 + ' onmouseover="tinyMCE.switchClass(this,\'charmapOver\');'
     282                + ' onmouseover="this.className=\'charmapOver\';'
    283283                + 'previewChar(\'' + charmap[i][1].substring(1,charmap[i][1].length) + '\',\'' + charmap[i][0].substring(1,charmap[i][0].length) + '\',\'' + charmap[i][3] + '\');"'
    284                 + ' onmouseout="tinyMCE.restoreClass(this,\'charmapOver\');"'
     284                + ' onmouseout="this.className=\'charmap\';"'
    285285                + ' nowrap="nowrap" onclick="insertChar(\'' + charmap[i][1].substring(2,charmap[i][1].length-1) + '\');"><a style="text-decoration: none;" onfocus="previewChar(\'' + charmap[i][1].substring(1,charmap[i][1].length) + '\',\'' + charmap[i][0].substring(1,charmap[i][0].length) + '\',\'' + charmap[i][3] + '\');" href="javascript:insertChar(\'' + charmap[i][1].substring(2,charmap[i][1].length-1) + '\');" onclick="return false;" onmousedown="return false;" title="' + charmap[i][3] + '">'
    286286                + charmap[i][1]
     
    300300
    301301function insertChar(chr) {
    302     tinyMCEPopup.execCommand('mceInsertContent', false, '\&#' + chr + ';');
     302    tinyMCEPopup.execCommand('mceInsertContent', false, '&#' + chr + ';');
    303303
    304304    // Refocus in window
    305305    if (tinyMCEPopup.isWindow)
    306306        window.focus();
     307
     308    tinyMCEPopup.close();
    307309}
    308310
  • trunk/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js

    r3503 r4431  
    100100        + '</td></tr>'
    101101        + '</table>'
    102         + '<input type="button" id="insert" name="insert" value="{$lang_theme_colorpicker_apply}" style="margin-top:3px" onclick="selectColor();">'
     102        + '<div style="float: left"><input type="button" id="insert" name="insert" value="{$lang_theme_colorpicker_apply}" style="margin-top:3px" onclick="selectColor();"></div>'
     103        + '<div style="float: right"><input type="button" name="cancel" value="{$lang_cancel}" style="margin-top:3px" onclick="tinyMCEPopup.close();" id="cancel" /></div>'
    103104        + '</td></tr>'
    104105        + '</table>';
  • trunk/wp-includes/js/tinymce/themes/advanced/jscripts/image.js

    r3503 r4431  
    99
    1010function insertImage() {
    11     if (window.opener) {
    12         var src = document.forms[0].src.value;
    13         var alt = document.forms[0].alt.value;
    14         var border = '';//document.forms[0].border.value;
    15         var vspace = '';//document.forms[0].vspace.value;
    16         var hspace = '';//document.forms[0].hspace.value;
    17         var width = '';//document.forms[0].width.value;
    18         var height = '';//document.forms[0].height.value;
    19         var align = document.forms[0].align.options[document.forms[0].align.selectedIndex].value;
     11    var src = document.forms[0].src.value;
     12    var alt = document.forms[0].alt.value;
     13    var border = document.forms[0].border.value;
     14    var vspace = document.forms[0].vspace.value;
     15    var hspace = document.forms[0].hspace.value;
     16    var width = document.forms[0].width.value;
     17    var height = document.forms[0].height.value;
     18    var align = document.forms[0].align.options[document.forms[0].align.selectedIndex].value;
    2019
    21         window.opener.tinyMCE.insertImage(src, alt, border, hspace, vspace, width, height, align);
    22         top.close();
    23     }
     20    tinyMCEPopup.restoreSelection();
     21    tinyMCE.themes['advanced']._insertImage(src, alt, border, hspace, vspace, width, height, align);
     22    tinyMCEPopup.close();
    2423}
    2524
     
    3837    formObj.src.value = tinyMCE.getWindowArg('src');
    3938    formObj.alt.value = tinyMCE.getWindowArg('alt');
    40 //  formObj.border.value = tinyMCE.getWindowArg('border');
    41 //  formObj.vspace.value = tinyMCE.getWindowArg('vspace');
    42 //  formObj.hspace.value = tinyMCE.getWindowArg('hspace');
    43 //  formObj.width.value = tinyMCE.getWindowArg('width');
    44 //  formObj.height.value = tinyMCE.getWindowArg('height');
     39    formObj.border.value = tinyMCE.getWindowArg('border');
     40    formObj.vspace.value = tinyMCE.getWindowArg('vspace');
     41    formObj.hspace.value = tinyMCE.getWindowArg('hspace');
     42    formObj.width.value = tinyMCE.getWindowArg('width');
     43    formObj.height.value = tinyMCE.getWindowArg('height');
    4544    formObj.insert.value = tinyMCE.getLang('lang_' + tinyMCE.getWindowArg('action'), 'Insert', true);
    4645
     
    6867    var formObj = document.forms[0];
    6968
    70 //  if (formObj.width.value == "")
    71 //      formObj.width.value = preloadImg.width;
     69    if (formObj.width.value == "")
     70        formObj.width.value = preloadImg.width;
    7271
    73 //  if (formObj.height.value == "")
    74 //      formObj.height.value = preloadImg.height;
     72    if (formObj.height.value == "")
     73        formObj.height.value = preloadImg.height;
    7574}
    7675
  • trunk/wp-includes/js/tinymce/themes/advanced/jscripts/link.js

    r3503 r4431  
    1111    tinyMCEPopup.resizeToInnerSize();
    1212
    13 //  document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','theme_advanced_link');
     13    document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','theme_advanced_link');
     14
     15    // Handle file browser
     16    if (isVisible('hrefbrowser'))
     17        document.getElementById('href').style.width = '180px';
    1418
    1519    var formObj = document.forms[0];
     
    2630    document.forms[0].insert.value = tinyMCE.getLang('lang_' + tinyMCE.getWindowArg('action'), 'Insert', true);
    2731
    28 //  addClassesToList('styleSelect', 'theme_advanced_link_styles');
    29 //  selectByValue(formObj, 'styleSelect', tinyMCE.getWindowArg('className'), true);
     32    addClassesToList('styleSelect', 'theme_advanced_link_styles');
     33    selectByValue(formObj, 'styleSelect', tinyMCE.getWindowArg('className'), true);
    3034
    31     // Handle file browser
    32     if (isVisible('hrefbrowser'))
    33         document.getElementById('href').style.width = '180px';
     35    // Hide css select row if no CSS classes
     36    if (formObj.styleSelect && formObj.styleSelect.options.length <= 1) {
     37        var sr = document.getElementById('styleSelectRow');
     38        sr.style.display = 'none';
     39        sr.parentNode.removeChild(sr);
     40    }
    3441
    3542    // Auto select link in list
     
    4552
    4653function insertLink() {
    47     if (window.opener) {
    48         var href = document.forms[0].href.value;
    49         var target = document.forms[0].target.options[document.forms[0].target.selectedIndex].value;
    50         var title = document.forms[0].linktitle.value;
    51         var style_class = '';//document.forms[0].styleSelect.value;
    52         var dummy;
     54    var href = document.forms[0].href.value;
     55    var target = document.forms[0].target.options[document.forms[0].target.selectedIndex].value;
     56    var title = document.forms[0].linktitle.value;
     57    var style_class = document.forms[0].styleSelect ? document.forms[0].styleSelect.value : "";
     58    var dummy;
    5359
    54         // Make anchors absolute
    55         if (href.charAt(0) == '#')
    56             href = tinyMCE.settings['document_base_url'] + href;
     60    // Make anchors absolute
     61    if (href.charAt(0) == '#')
     62        href = tinyMCE.settings['document_base_url'] + href;
    5763
    58         if (target == '_self')
    59             target = '';
     64    if (target == '_self')
     65        target = '';
    6066
    61         window.opener.tinyMCE.insertLink(href, target, title, dummy, style_class);
    62         tinyMCEPopup.close();
    63     }
     67    tinyMCEPopup.restoreSelection();
     68    tinyMCE.themes['advanced']._insertLink(href, target, title, dummy, style_class);
     69    tinyMCEPopup.close();
    6470}
  • trunk/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js

    r3503 r4431  
    66// Fixes some charcode issues
    77function fixContent(html) {
    8     // WP
    9     return html;
    10 
    11     html = html.replace(new RegExp('<(p|hr|table|tr|td|ol|ul|object|embed|li|blockquote)', 'gi'),'\n<$1');
     8/*  html = html.replace(new RegExp('<(p|hr|table|tr|td|ol|ul|object|embed|li|blockquote)', 'gi'),'\n<$1');
    129    html = html.replace(new RegExp('<\/(p|ol|ul|li|table|tr|td|blockquote|object)>', 'gi'),'</$1>\n');
    1310    html = tinyMCE.regexpReplace(html, '<br />','<br />\n','gi');
    14     html = tinyMCE.regexpReplace(html, '\n\n','\n','gi');
     11    html = tinyMCE.regexpReplace(html, '\n\n','\n','gi');*/
    1512    return html;
    1613}
     
    2118    document.forms[0].htmlSource.value = fixContent(tinyMCE.getContent(tinyMCE.getWindowArg('editor_id')));
    2219    resizeInputs();
    23     setWrap('off');
    2420}
    2521
    2622function setWrap(val) {
    27     // hard soft off
    28     document.forms[0].htmlSource.wrap = val;
     23    var s = document.forms[0].htmlSource;
     24
     25    s.wrap = val;
     26
     27    if (tinyMCE.isGecko) {
     28        var v = s.value;
     29        var n = s.cloneNode(false);
     30        n.setAttribute("wrap", val);
     31        s.parentNode.replaceChild(n, s);
     32        n.value = v;
     33    }
    2934}
    3035
     
    5257
    5358function renderWordWrap() {
    54     if (tinyMCE.isMSIE)
     59    if (tinyMCE.isMSIE || tinyMCE.isGecko)
    5560        document.write('<input type="checkbox" name="wraped" id="wraped" onclick="toggleWordWrap(this);" class="wordWrapCode" /><label for="wraped">{$lang_theme_code_wordwrap}</label>');
    5661}
  • trunk/wp-includes/js/tinymce/themes/advanced/langs/en.js

    r3503 r4431  
    33tinyMCE.addToLang('',{
    44theme_style_select : '-- Styles --',
    5 theme_code_desc : 'Edit HTML Source (Alt+e)',
     5theme_code_desc : 'Edit HTML Source',
    66theme_code_title : 'HTML Source Editor',
    77theme_code_wordwrap : 'Word wrap',
  • trunk/wp-includes/js/tinymce/themes/advanced/link.htm

    r3503 r4431  
    33    <title>{$lang_insert_link_title}</title>
    44    <script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
     5    <script language="javascript" type="text/javascript" src="../../utils/mctabs.js"></script>
    56    <script language="javascript" type="text/javascript" src="../../utils/form_utils.js"></script>
    67    <script language="javascript" type="text/javascript" src="jscripts/link.js"></script>
    7     <style type="text/css">
    8         #insert, #cancel {
    9             font: 13px Verdana, Arial, Helvetica, sans-serif;
    10             height: auto;
    11             width: auto;
    12             background-color: transparent;
    13             background-image: url(../../../../../wp-admin/images/fade-butt.png);
    14             background-repeat: repeat;
    15             border: 3px double;
    16             border-right-color: rgb(153, 153, 153);
    17             border-bottom-color: rgb(153, 153, 153);
    18             border-left-color: rgb(204, 204, 204);
    19             border-top-color: rgb(204, 204, 204);
    20             color: rgb(51, 51, 51);
    21             padding: 0.25em 0.75em;
    22         }
    23         #insert:active, #cancel:active {
    24             background: #f4f4f4;
    25             border-left-color: #999;
    26             border-top-color: #999;
    27         }
    28     </style>
     8    <base target="_self" />
    299</head>
    30 <body onload="tinyMCEPopup.executeOnLoad('init();');document.getElementById('href').focus();" style="display: none">
    31 <form onsubmit="insertLink();return false;">
    32   <table border="0" cellpadding="0" cellspacing="0" width="100">
    33     <tr>
    34       <td align="center" valign="middle"><table border="0" cellpadding="4" cellspacing="0">
     10<body id="link" onload="tinyMCEPopup.executeOnLoad('init();');document.body.style.display='';document.getElementById('href').focus();" style="display: none">
     11<form onsubmit="insertLink();return false;" action="#">
     12    <div class="tabs">
     13        <ul>
     14            <li id="general_tab" class="current"><span><a href="javascript:mcTabs.displayTab('general_tab','general_panel');" onmousedown="return false;">{$lang_insert_link_title}</a></span></li>
     15        </ul>
     16    </div>
     17
     18    <div class="panel_wrapper">
     19        <div id="general_panel" class="panel current">
     20
     21        <table border="0" cellpadding="4" cellspacing="0">
    3522          <tr>
    36             <td colspan="2" class="title" nowrap="nowrap">{$lang_insert_link_title}</td>
    37           </tr>
    38           <tr>
    39             <td nowrap="nowrap">{$lang_insert_link_url}:</td>
    40             <td>              <table border="0" cellspacing="0" cellpadding="0">
    41                 <tr>
    42                   <td><input name="href" type="text" id="href" value="" style="width: 200px"></td>
    43                   <td id="hrefbrowsercontainer">&nbsp;</td>
    44                 </tr>
    45               </table></td>
     23            <td nowrap="nowrap"><label for="href">{$lang_insert_link_url}</label></td>
     24            <td><table border="0" cellspacing="0" cellpadding="0">
     25                  <tr>
     26                    <td><input id="href" name="href" type="text" value="" style="width: 200px" /></td>
     27                    <td id="hrefbrowsercontainer">&nbsp;</td>
     28                  </tr>
     29                </table></td>
    4630          </tr>
    4731          <!-- Link list -->
     
    5034                var html = "";
    5135
    52                 html += '<tr><td>{$lang_link_list}:</td>';
    53                 html += '<td><select name="link_list" style="width: 200px" onchange="this.form.href.value=this.options[this.selectedIndex].value;">';
     36                html += '<tr><td><label for="link_list">{$lang_link_list}</label></td>';
     37                html += '<td><select id="link_list" name="link_list" style="width: 200px" onchange="this.form.href.value=this.options[this.selectedIndex].value;">';
    5438                html += '<option value="">---</option>';
    5539
     
    6448          <!-- /Link list -->
    6549          <tr>
    66             <td nowrap="nowrap">{$lang_insert_link_target}:</td>
    67             <td><select name="target" style="width: 200px">
     50            <td nowrap="nowrap"><label for="target">{$lang_insert_link_target}</label></td>
     51            <td><select id="target" name="target" style="width: 200px">
    6852                <option value="_self">{$lang_insert_link_target_same}</option>
    6953                <option value="_blank">{$lang_insert_link_target_blank}</option>
     
    8973          </tr>
    9074          <tr>
    91             <td nowrap="nowrap">{$lang_theme_insert_link_titlefield}:</td>
    92             <td><input name="linktitle" type="text" id="linktitle" value="" style="width: 200px"></td>
     75            <td nowrap="nowrap"><label for="linktitle">{$lang_theme_insert_link_titlefield}</label></td>
     76            <td><input id="linktitle" name="linktitle" type="text" value="" style="width: 200px"></td>
    9377          </tr>
    9478          <tr id="styleSelectRow">
    95             <td><!--{$lang_class_name}:</td>
     79            <td><label for="styleSelect">{$lang_class_name}</label></td>
    9680            <td>
    9781             <select id="styleSelect" name="styleSelect">
    9882                <option value="" selected>{$lang_theme_style_select}</option>
    9983             </select></td>
    100             <td align="right">&nbsp;</td>
    101             <td align="right">&nbsp;--></td>
    10284          </tr>
    103           <tr>
    104             <td><input type="submit" id="insert" name="insert" value="{$lang_insert}" onclick="insertLink();">
    105             </td>
    106             <td align="right"><input type="button" id="cancel" name="cancel" value="{$lang_cancel}" onclick="tinyMCEPopup.close();"></td>
    107           </tr>
    108         </table></td>
    109     </tr>
    110   </table>
     85        </table>
     86        </div>
     87    </div>
     88
     89    <div class="mceActionPanel">
     90        <div style="float: left">
     91            <input type="button" id="cancel" name="cancel" value="{$lang_cancel}" onclick="tinyMCEPopup.close();" />
     92        </div>
     93
     94        <div style="float: right">
     95            <input type="submit" id="insert" name="insert" value="{$lang_insert}" onclick="insertLink();" />
     96        </div>
     97    </div>
    11198</form>
    11299</body>
  • trunk/wp-includes/js/tinymce/themes/advanced/source_editor.htm

    r3503 r4431  
    55    <script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script>
    66    <script language="javascript" type="text/javascript" src="jscripts/source_editor.js"></script>
    7     <style type="text/css">
    8         #insert, #cancel {
    9             font: 13px Verdana, Arial, Helvetica, sans-serif;
    10             height: auto;
    11             width: auto;
    12             background-color: transparent;
    13             background-image: url(../../../../../wp-admin/images/fade-butt.png);
    14             background-repeat: repeat;
    15             border: 3px double;
    16             border-right-color: rgb(153, 153, 153);
    17             border-bottom-color: rgb(153, 153, 153);
    18             border-left-color: rgb(204, 204, 204);
    19             border-top-color: rgb(204, 204, 204);
    20             color: rgb(51, 51, 51);
    21             padding: 0.25em 0.75em;
    22         }
    23         #insert:active, #cancel:active {
    24             background: #f4f4f4;
    25             border-left-color: #999;
    26             border-top-color: #999;
    27         }
    28     </style>
     7    <base target="_self" />
    298</head>
    30 <body onload="tinyMCEPopup.executeOnLoad('onLoadInit();');document.getElementById('htmlSource').focus();" onresize="resizeInputs();" style="display: none">
     9<body onload="tinyMCEPopup.executeOnLoad('onLoadInit();');document.body.style.display='';document.getElementById('htmlSource').focus();" onresize="resizeInputs();" style="display: none">
    3110    <form name="source" onsubmit="saveContent();" action="#">
    3211        <div style="float: left" class="title">{$lang_theme_code_title}</div>
     
    3615        </div>
    3716
    38         <textarea name="htmlSource" id="htmlSource" rows="15" cols="100" style="width: 100%; height: 100%; font-family: 'Courier New',Courier,mono; font-size: 12px;" dir="ltr" wrap="soft"></textarea>
     17        <textarea name="htmlSource" id="htmlSource" rows="15" cols="100" style="width: 100%; height: 100%; font-family: 'Courier New',Courier,mono; font-size: 12px" dir="ltr" wrap="off"></textarea>
    3918
    4019        <div class="mceActionPanel">
    4120            <div style="float: left">
    42                 <input type="button" name="insert" value="{$lang_update}" onclick="saveContent();" id="insert" />
     21                <input type="button" name="cancel" value="{$lang_cancel}" onclick="tinyMCEPopup.close();" id="cancel" />
    4322            </div>
    4423
    4524            <div style="float: right">
    46                 <input type="button" name="cancel" value="{$lang_cancel}" onclick="tinyMCEPopup.close();" id="cancel" />
     25                <input type="submit" name="insert" value="{$lang_update}" onclick="saveContent();" id="insert" />
    4726            </div>
    4827        </div>
  • trunk/wp-includes/js/tinymce/tiny_mce.js

    r3503 r4431  
    1 /**
    2  * $RCSfile: tiny_mce_src.js,v $
    3  * $Revision: 1.281 $
    4  * $Date: 2005/12/02 08:12:07 $
    5  *
    6  * @author Moxiecode
    7  * @copyright Copyright © 2004, Moxiecode Systems AB, All rights reserved.
    8  */
    9 
    10 function TinyMCE() {
     1
     2/* file:jscripts/tiny_mce/classes/TinyMCE_Engine.class.js */
     3
     4function TinyMCE_Engine() {
    115    this.majorVersion = "2";
    12     this.minorVersion = "0";
    13     this.releaseDate = "2005-12-01";
     6    this.minorVersion = "0.6.1";
     7    this.releaseDate = "2006-05-04";
    148
    159    this.instances = new Array();
    16     this.stickyClassesLookup = new Array();
     10    this.switchClassCache = new Array();
    1711    this.windowArgs = new Array();
    1812    this.loadedFiles = new Array();
     13    this.pendingFiles = new Array();
     14    this.loadingIndex = 0;
    1915    this.configs = new Array();
    2016    this.currentConfig = 0;
     
    3329    this.isNS71 = ua.indexOf('Netscape/7.1') != -1;
    3430    this.dialogCounter = 0;
     31    this.plugins = new Array();
     32    this.themes = new Array();
     33    this.menus = new Array();
     34    this.loadedPlugins = new Array();
     35    this.buttonMap = new Array();
     36    this.isLoaded = false;
    3537
    3638    // Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those
     
    4547};
    4648
    47 TinyMCE.prototype.defParam = function(key, def_val) {
    48     this.settings[key] = tinyMCE.getParam(key, def_val);
    49 };
    50 
    51 TinyMCE.prototype.init = function(settings) {
    52     var theme;
    53 
    54     this.settings = settings;
    55 
    56     // Check if valid browser has execcommand support
    57     if (typeof(document.execCommand) == 'undefined')
    58         return;
    59 
    60     // Get script base path
    61     if (!tinyMCE.baseURL) {
    62         var elements = document.getElementsByTagName('script');
    63 
    64         for (var i=0; i<elements.length; i++) {
    65             if (elements[i].src && (elements[i].src.indexOf("tiny_mce.js") != -1 || elements[i].src.indexOf("tiny_mce_src.js") != -1 || elements[i].src.indexOf("tiny_mce_gzip") != -1)) {
    66                 var src = elements[i].src;
    67 
    68                 tinyMCE.srcMode = (src.indexOf('_src') != -1) ? '_src' : '';
    69                 src = src.substring(0, src.lastIndexOf('/'));
    70 
    71                 tinyMCE.baseURL = src;
    72                 break;
    73             }
    74         }
    75     }
    76 
    77     // Get document base path
    78     this.documentBasePath = document.location.href;
    79     if (this.documentBasePath.indexOf('?') != -1)
    80         this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.indexOf('?'));
    81     this.documentURL = this.documentBasePath;
    82     this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.lastIndexOf('/'));
    83 
    84     // If not HTTP absolute
    85     if (tinyMCE.baseURL.indexOf('://') == -1 && tinyMCE.baseURL.charAt(0) != '/') {
    86         // If site absolute
    87         tinyMCE.baseURL = this.documentBasePath + "/" + tinyMCE.baseURL;
    88     }
    89 
    90     // Set default values on settings
    91     this.defParam("mode", "none");
    92     this.defParam("theme", "advanced");
    93     this.defParam("plugins", "", true);
    94     this.defParam("language", "en");
    95     this.defParam("docs_language", this.settings['language']);
    96     this.defParam("elements", "");
    97     this.defParam("textarea_trigger", "mce_editable");
    98     this.defParam("editor_selector", "");
    99     this.defParam("editor_deselector", "mceNoEditor");
    100     this.defParam("valid_elements", "+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong/b[class|style],-em/i[class|style],-strike[class|style],-u[class|style],+p[style|dir|class|align],-ol[class|style],-ul[class|style],-li[class|style],br,img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border=0|alt|title|hspace|vspace|width|height|align],-sub[style|class],-sup[style|class],-blockquote[dir|style],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],-td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[style|class|align],-pre[class|align|style],address[class|align|style],-h1[style|dir|class|align],-h2[style|dir|class|align],-h3[style|dir|class|align],-h4[style|dir|class|align],-h5[style|dir|class|align],-h6[style|dir|class|align],hr[class|style],font[face|size|style|id|class|dir|color]");
    101     this.defParam("extended_valid_elements", "");
    102     this.defParam("invalid_elements", "");
    103     this.defParam("encoding", "");
    104     this.defParam("urlconverter_callback", tinyMCE.getParam("urlconvertor_callback", "TinyMCE.prototype.convertURL"));
    105     this.defParam("save_callback", "");
    106     this.defParam("debug", false);
    107     this.defParam("force_br_newlines", false);
    108     this.defParam("force_p_newlines", true);
    109     this.defParam("add_form_submit_trigger", true);
    110     this.defParam("relative_urls", true);
    111     this.defParam("remove_script_host", true);
    112     this.defParam("focus_alert", true);
    113     this.defParam("document_base_url", this.documentURL);
    114     this.defParam("visual", true);
    115     this.defParam("visual_table_class", "mceVisualAid");
    116     this.defParam("setupcontent_callback", "");
    117     this.defParam("fix_content_duplication", true);
    118     this.defParam("custom_undo_redo", true);
    119     this.defParam("custom_undo_redo_levels", -1);
    120     this.defParam("custom_undo_redo_keyboard_shortcuts", true);
    121     this.defParam("verify_css_classes", false);
    122     this.defParam("verify_html", true);
    123     this.defParam("apply_source_formatting", false);
    124     this.defParam("directionality", "ltr");
    125     this.defParam("cleanup_on_startup", false);
    126     this.defParam("inline_styles", false);
    127     this.defParam("convert_newlines_to_brs", false);
    128     this.defParam("auto_reset_designmode", true);
    129     this.defParam("entities", "160,nbsp,38,amp,34,quot,162,cent,8364,euro,163,pound,165,yen,169,copy,174,reg,8482,trade,8240,permil,181,micro,183,middot,8226,bull,8230,hellip,8242,prime,8243,Prime,167,sect,182,para,223,szlig,8249,lsaquo,8250,rsaquo,171,laquo,187,raquo,8216,lsquo,8217,rsquo,8220,ldquo,8221,rdquo,8218,sbquo,8222,bdquo,60,lt,62,gt,8804,le,8805,ge,8211,ndash,8212,mdash,175,macr,8254,oline,164,curren,166,brvbar,168,uml,161,iexcl,191,iquest,710,circ,732,tilde,176,deg,8722,minus,177,plusmn,247,divide,8260,frasl,215,times,185,sup1,178,sup2,179,sup3,188,frac14,189,frac12,190,frac34,402,fnof,8747,int,8721,sum,8734,infin,8730,radic,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8712,isin,8713,notin,8715,ni,8719,prod,8743,and,8744,or,172,not,8745,cap,8746,cup,8706,part,8704,forall,8707,exist,8709,empty,8711,nabla,8727,lowast,8733,prop,8736,ang,180,acute,184,cedil,170,ordf,186,ordm,8224,dagger,8225,Dagger,192,Agrave,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,202,Ecirc,203,Euml,204,Igrave,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,212,Ocirc,213,Otilde,214,Ouml,216,Oslash,338,OElig,217,Ugrave,219,Ucirc,220,Uuml,376,Yuml,222,THORN,224,agrave,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,234,ecirc,235,euml,236,igrave,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,244,ocirc,245,otilde,246,ouml,248,oslash,339,oelig,249,ugrave,251,ucirc,252,uuml,254,thorn,255,yuml,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,8501,alefsym,982,piv,8476,real,977,thetasym,978,upsih,8472,weierp,8465,image,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8756,there4,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,173,shy,233,eacute,237,iacute,243,oacute,250,uacute,193,Aacute,225,aacute,201,Eacute,205,Iacute,211,Oacute,218,Uacute,221,Yacute,253,yacute");
    130     this.defParam("entity_encoding", "named");
    131     this.defParam("cleanup_callback", "");
    132     this.defParam("add_unload_trigger", true);
    133     this.defParam("ask", false);
    134     this.defParam("nowrap", false);
    135     this.defParam("auto_resize", false);
    136     this.defParam("auto_focus", false);
    137     this.defParam("cleanup", true);
    138     this.defParam("remove_linebreaks", true);
    139     this.defParam("button_tile_map", false);
    140     this.defParam("submit_patch", true);
    141     this.defParam("browsers", "msie,safari,gecko,opera");
    142     this.defParam("dialog_type", "window");
    143     this.defParam("accessibility_warnings", true);
    144     this.defParam("merge_styles_invalid_parents", "");
    145     this.defParam("force_hex_style_colors", true);
    146     this.defParam("trim_span_elements", true);
    147     this.defParam("convert_fonts_to_spans", false);
    148     this.defParam("doctype", '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">');
    149     this.defParam("font_size_classes", '');
    150     this.defParam("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large');
    151     this.defParam("event_elements", 'a,img');
    152     this.defParam("convert_urls", true);
    153     this.defParam("table_inline_editing", false);
    154     this.defParam("object_resizing", true);
    155 
    156     // Browser check IE
    157     if (this.isMSIE && this.settings['browsers'].indexOf('msie') == -1)
    158         return;
    159 
    160     // Browser check Gecko
    161     if (this.isGecko && this.settings['browsers'].indexOf('gecko') == -1)
    162         return;
    163 
    164     // Browser check Safari
    165     if (this.isSafari && this.settings['browsers'].indexOf('safari') == -1)
    166         return;
    167 
    168     // Browser check Opera
    169     if (this.isOpera && this.settings['browsers'].indexOf('opera') == -1)
    170         return;
    171 
    172     // If not super absolute make it so
    173     var baseHREF = tinyMCE.settings['document_base_url'];
    174     var h = document.location.href;
    175     var p = h.indexOf('://');
    176     if (p > 0 && document.location.protocol != "file:") {
    177         p = h.indexOf('/', p + 3);
    178         h = h.substring(0, p);
    179 
    180         if (baseHREF.indexOf('://') == -1)
    181             baseHREF = h + baseHREF;
    182 
    183         tinyMCE.settings['document_base_url'] = baseHREF;
    184         tinyMCE.settings['document_base_prefix'] = h;
    185     }
    186 
    187     // Trim away query part
    188     if (baseHREF.indexOf('?') != -1)
    189         baseHREF = baseHREF.substring(0, baseHREF.indexOf('?'));
    190 
    191     this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/";
    192 
    193     theme = this.settings['theme'];
    194     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");
    195     this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);
    196     this.uniqueURL = 'http://tinymce.moxiecode.cp/mce_temp_url'; // Make unique URL non real URL
    197     this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>';
    198 
    199     // Theme url
    200     this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme;
    201 
    202     if (!tinyMCE.isMSIE)
    203         this.settings['force_br_newlines'] = false;
    204 
    205     if (tinyMCE.getParam("content_css", false)) {
    206         var cssPath = tinyMCE.getParam("content_css", "");
    207 
    208         // Is relative
    209         if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
    210             this.settings['content_css'] = this.documentBasePath + "/" + cssPath;
    211         else
    212             this.settings['content_css'] = cssPath;
    213     } else
    214         this.settings['content_css'] = '';
    215 
    216     if (tinyMCE.getParam("popups_css", false)) {
    217         var cssPath = tinyMCE.getParam("popups_css", "");
    218 
    219         // Is relative
    220         if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
    221             this.settings['popups_css'] = this.documentBasePath + "/" + cssPath;
    222         else
    223             this.settings['popups_css'] = cssPath;
    224     } else
    225         this.settings['popups_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css";
    226 
    227     if (tinyMCE.getParam("editor_css", false)) {
    228         var cssPath = tinyMCE.getParam("editor_css", "");
    229 
    230         // Is relative
    231         if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
    232             this.settings['editor_css'] = this.documentBasePath + "/" + cssPath;
    233         else
    234             this.settings['editor_css'] = cssPath;
    235     } else
    236         this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";
    237 
    238     if (tinyMCE.settings['debug']) {
    239         var msg = "Debug: \n";
    240 
    241         msg += "baseURL: " + this.baseURL + "\n";
    242         msg += "documentBasePath: " + this.documentBasePath + "\n";
    243         msg += "content_css: " + this.settings['content_css'] + "\n";
    244         msg += "popups_css: " + this.settings['popups_css'] + "\n";
    245         msg += "editor_css: " + this.settings['editor_css'] + "\n";
    246 
    247         alert(msg);
    248     }
    249 
    250     // Init HTML cleanup
    251     this._initCleanup();
    252 
    253     // Only do this once
    254     if (this.configs.length == 0) {
    255         // Is Safari enabled
    256         if (this.isSafari && this.getParam('safari_warning', true))
    257             alert("Safari support is very limited and should be considered experimental.\nSo there is no need to even submit bugreports on this early version.\nYou can disable this message by setting: safari_warning option to false");
    258 
    259         tinyMCE.addEvent(window, "load", TinyMCE.prototype.onLoad);
    260 
     49TinyMCE_Engine.prototype = {
     50    init : function(settings) {
     51        var theme;
     52
     53        this.settings = settings;
     54
     55        // Check if valid browser has execcommand support
     56        if (typeof(document.execCommand) == 'undefined')
     57            return;
     58
     59        // Get script base path
     60        if (!tinyMCE.baseURL) {
     61            var elements = document.getElementsByTagName('script');
     62
     63            for (var i=0; i<elements.length; i++) {
     64                if (elements[i].src && (elements[i].src.indexOf("tiny_mce.js") != -1 || elements[i].src.indexOf("tiny_mce_dev.js") != -1 || elements[i].src.indexOf("tiny_mce_src.js") != -1 || elements[i].src.indexOf("tiny_mce_gzip") != -1)) {
     65                    var src = elements[i].src;
     66
     67                    tinyMCE.srcMode = (src.indexOf('_src') != -1 || src.indexOf('_dev') != -1) ? '_src' : '';
     68                    tinyMCE.gzipMode = src.indexOf('_gzip') != -1;
     69                    src = src.substring(0, src.lastIndexOf('/'));
     70
     71                    if (settings.exec_mode == "src" || settings.exec_mode == "normal")
     72                        tinyMCE.srcMode = settings.exec_mode == "src" ? '_src' : '';
     73
     74                    tinyMCE.baseURL = src;
     75                    break;
     76                }
     77            }
     78        }
     79
     80        // Get document base path
     81        this.documentBasePath = document.location.href;
     82        if (this.documentBasePath.indexOf('?') != -1)
     83            this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.indexOf('?'));
     84        this.documentURL = this.documentBasePath;
     85        this.documentBasePath = this.documentBasePath.substring(0, this.documentBasePath.lastIndexOf('/'));
     86
     87        // If not HTTP absolute
     88        if (tinyMCE.baseURL.indexOf('://') == -1 && tinyMCE.baseURL.charAt(0) != '/') {
     89            // If site absolute
     90            tinyMCE.baseURL = this.documentBasePath + "/" + tinyMCE.baseURL;
     91        }
     92
     93        // Set default values on settings
     94        this._def("mode", "none");
     95        this._def("theme", "advanced");
     96        this._def("plugins", "", true);
     97        this._def("language", "en");
     98        this._def("docs_language", this.settings['language']);
     99        this._def("elements", "");
     100        this._def("textarea_trigger", "mce_editable");
     101        this._def("editor_selector", "");
     102        this._def("editor_deselector", "mceNoEditor");
     103        this._def("valid_elements", "+a[id|style|rel|rev|charset|hreflang|dir|lang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup],-strong/-b[class|style],-em/-i[class|style],-strike[class|style],-u[class|style],#p[id|style|dir|class|align],-ol[class|style],-ul[class|style],-li[class|style],br,img[id|dir|lang|longdesc|usemap|style|class|src|onmouseover|onmouseout|border|alt=|title|hspace|vspace|width|height|align],-sub[style|class],-sup[style|class],-blockquote[dir|style],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|style|dir|id|lang|bgcolor|background|bordercolor],-tr[id|lang|dir|class|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor],tbody[id|class],thead[id|class],tfoot[id|class],-td[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|bgcolor|background|bordercolor|scope],-th[id|lang|dir|class|colspan|rowspan|width|height|align|valign|style|scope],caption[id|lang|dir|class|style],-div[id|dir|class|align|style],-span[style|class|align],-pre[class|align|style],address[class|align|style],-h1[id|style|dir|class|align],-h2[id|style|dir|class|align],-h3[id|style|dir|class|align],-h4[id|style|dir|class|align],-h5[id|style|dir|class|align],-h6[id|style|dir|class|align],hr[class|style],-font[face|size|style|id|class|dir|color],dd[id|class|title|style|dir|lang],dl[id|class|title|style|dir|lang],dt[id|class|title|style|dir|lang]");
     104        this._def("extended_valid_elements", "");
     105        this._def("invalid_elements", "");
     106        this._def("encoding", "");
     107        this._def("urlconverter_callback", tinyMCE.getParam("urlconvertor_callback", "TinyMCE_Engine.prototype.convertURL"));
     108        this._def("save_callback", "");
     109        this._def("debug", false);
     110        this._def("force_br_newlines", false);
     111        this._def("force_p_newlines", true);
     112        this._def("add_form_submit_trigger", true);
     113        this._def("relative_urls", true);
     114        this._def("remove_script_host", true);
     115        this._def("focus_alert", true);
     116        this._def("document_base_url", this.documentURL);
     117        this._def("visual", true);
     118        this._def("visual_table_class", "mceVisualAid");
     119        this._def("setupcontent_callback", "");
     120        this._def("fix_content_duplication", true);
     121        this._def("custom_undo_redo", true);
     122        this._def("custom_undo_redo_levels", -1);
     123        this._def("custom_undo_redo_keyboard_shortcuts", true);
     124        this._def("custom_undo_redo_restore_selection", true);
     125        this._def("verify_html", true);
     126        this._def("apply_source_formatting", false);
     127        this._def("directionality", "ltr");
     128        this._def("cleanup_on_startup", false);
     129        this._def("inline_styles", false);
     130        this._def("convert_newlines_to_brs", false);
     131        this._def("auto_reset_designmode", true);
     132        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);
     133        this._def("entity_encoding", "named");
     134        this._def("cleanup_callback", "");
     135        this._def("add_unload_trigger", true);
     136        this._def("ask", false);
     137        this._def("nowrap", false);
     138        this._def("auto_resize", false);
     139        this._def("auto_focus", false);
     140        this._def("cleanup", true);
     141        this._def("remove_linebreaks", true);
     142        this._def("button_tile_map", false);
     143        this._def("submit_patch", true);
     144        this._def("browsers", "msie,safari,gecko,opera", true);
     145        this._def("dialog_type", "window");
     146        this._def("accessibility_warnings", true);
     147        this._def("accessibility_focus", true);
     148        this._def("merge_styles_invalid_parents", "");
     149        this._def("force_hex_style_colors", true);
     150        this._def("trim_span_elements", true);
     151        this._def("convert_fonts_to_spans", false);
     152        this._def("doctype", '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">');
     153        this._def("font_size_classes", '');
     154        this._def("font_size_style_values", 'xx-small,x-small,small,medium,large,x-large,xx-large', true);
     155        this._def("event_elements", 'a,img', true);
     156        this._def("convert_urls", true);
     157        this._def("table_inline_editing", false);
     158        this._def("object_resizing", true);
     159        this._def("custom_shortcuts", true);
     160        this._def("convert_on_click", false);
     161        this._def("content_css", '');
     162        this._def("fix_list_elements", false);
     163        this._def("fix_table_elements", false);
     164        this._def("strict_loading_mode", document.contentType == 'application/xhtml+xml');
     165        this._def("hidden_tab_class", '');
     166        this._def("display_tab_class", '');
     167
     168        // Force strict loading mode to false on non Gecko browsers
     169        if (this.isMSIE && !this.isOpera)
     170            this.settings.strict_loading_mode = false;
     171
     172        // Browser check IE
     173        if (this.isMSIE && this.settings['browsers'].indexOf('msie') == -1)
     174            return;
     175
     176        // Browser check Gecko
     177        if (this.isGecko && this.settings['browsers'].indexOf('gecko') == -1)
     178            return;
     179
     180        // Browser check Safari
     181        if (this.isSafari && this.settings['browsers'].indexOf('safari') == -1)
     182            return;
     183
     184        // Browser check Opera
     185        if (this.isOpera && this.settings['browsers'].indexOf('opera') == -1)
     186            return;
     187
     188        // If not super absolute make it so
     189        var baseHREF = tinyMCE.settings['document_base_url'];
     190        var h = document.location.href;
     191        var p = h.indexOf('://');
     192        if (p > 0 && document.location.protocol != "file:") {
     193            p = h.indexOf('/', p + 3);
     194            h = h.substring(0, p);
     195
     196            if (baseHREF.indexOf('://') == -1)
     197                baseHREF = h + baseHREF;
     198
     199            tinyMCE.settings['document_base_url'] = baseHREF;
     200            tinyMCE.settings['document_base_prefix'] = h;
     201        }
     202
     203        // Trim away query part
     204        if (baseHREF.indexOf('?') != -1)
     205            baseHREF = baseHREF.substring(0, baseHREF.indexOf('?'));
     206
     207        this.settings['base_href'] = baseHREF.substring(0, baseHREF.lastIndexOf('/')) + "/";
     208
     209        theme = this.settings['theme'];
     210        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");
     211        this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40);
     212        this.uniqueURL = 'javascript:TINYMCE_UNIQUEURL();'; // Make unique URL non real URL
     213        this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>';
     214        this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup');
     215
     216        // Theme url
     217        this.settings['theme_href'] = tinyMCE.baseURL + "/themes/" + theme;
     218
     219        if (!tinyMCE.isMSIE)
     220            this.settings['force_br_newlines'] = false;
     221
     222        if (tinyMCE.getParam("popups_css", false)) {
     223            var cssPath = tinyMCE.getParam("popups_css", "");
     224
     225            // Is relative
     226            if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
     227                this.settings['popups_css'] = this.documentBasePath + "/" + cssPath;
     228            else
     229                this.settings['popups_css'] = cssPath;
     230        } else
     231            this.settings['popups_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_popup.css";
     232
     233        if (tinyMCE.getParam("editor_css", false)) {
     234            var cssPath = tinyMCE.getParam("editor_css", "");
     235
     236            // Is relative
     237            if (cssPath.indexOf('://') == -1 && cssPath.charAt(0) != '/')
     238                this.settings['editor_css'] = this.documentBasePath + "/" + cssPath;
     239            else
     240                this.settings['editor_css'] = cssPath;
     241        } else
     242            this.settings['editor_css'] = tinyMCE.baseURL + "/themes/" + theme + "/css/editor_ui.css";
     243
     244        if (tinyMCE.settings['debug']) {
     245            var msg = "Debug: \n";
     246
     247            msg += "baseURL: " + this.baseURL + "\n";
     248            msg += "documentBasePath: " + this.documentBasePath + "\n";
     249            msg += "content_css: " + this.settings['content_css'] + "\n";
     250            msg += "popups_css: " + this.settings['popups_css'] + "\n";
     251            msg += "editor_css: " + this.settings['editor_css'] + "\n";
     252
     253            alert(msg);
     254        }
     255
     256        // Only do this once
     257        if (this.configs.length == 0) {
     258            // Is Safari enabled
     259            if (this.isSafari && this.getParam('safari_warning', false))
     260                alert("Safari support is very limited and should be considered experimental.\nSo there is no need to even submit bugreports on this early version.\nYou can disable this message by setting: safari_warning option to false");
     261
     262            if (typeof(TinyMCECompressed) == "undefined") {
     263                tinyMCE.addEvent(window, "DOMContentLoaded", TinyMCE_Engine.prototype.onLoad);
     264
     265                if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
     266                    if (document.body)
     267                        tinyMCE.addEvent(document.body, "readystatechange", TinyMCE_Engine.prototype.onLoad);
     268                    else
     269                        tinyMCE.addEvent(document, "readystatechange", TinyMCE_Engine.prototype.onLoad);
     270                }
     271
     272                tinyMCE.addEvent(window, "load", TinyMCE_Engine.prototype.onLoad);
     273                tinyMCE._addUnloadEvents();
     274            }
     275        }
     276
     277        this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings['theme'] + '/editor_template' + tinyMCE.srcMode + '.js');
     278        this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings['language'] +  '.js');
     279        this.loadCSS(this.settings['editor_css']);
     280
     281        // Add plugins
     282        var p = tinyMCE.getParam('plugins', '', true, ',');
     283        if (p.length > 0) {
     284            for (var i=0; i<p.length; i++) {
     285                if (p[i].charAt(0) != '-')
     286                    this.loadScript(tinyMCE.baseURL + '/plugins/' + p[i] + '/editor_plugin' + tinyMCE.srcMode + '.js');
     287            }
     288        }
     289
     290        // Setup entities
     291        settings['cleanup_entities'] = new Array();
     292        var entities = tinyMCE.getParam('entities', '', true, ',');
     293        for (var i=0; i<entities.length; i+=2)
     294            settings['cleanup_entities']['c' + entities[i]] = entities[i+1];
     295
     296        // Save away this config
     297        settings['index'] = this.configs.length;
     298        this.configs[this.configs.length] = settings;
     299
     300        // Start loading first one in chain
     301        this.loadNextScript();
     302    },
     303
     304    _addUnloadEvents : function() {
    261305        if (tinyMCE.isMSIE) {
    262306            if (tinyMCE.settings['add_unload_trigger']) {
    263                 tinyMCE.addEvent(window, "unload", TinyMCE.prototype.unloadHandler);
    264                 tinyMCE.addEvent(window.document, "beforeunload", TinyMCE.prototype.unloadHandler);
     307                tinyMCE.addEvent(window, "unload", TinyMCE_Engine.prototype.unloadHandler);
     308                tinyMCE.addEvent(window.document, "beforeunload", TinyMCE_Engine.prototype.unloadHandler);
    265309            }
    266310        } else {
     
    268312                tinyMCE.addEvent(window, "unload", function () {tinyMCE.triggerSave(true, true);});
    269313        }
    270     }
    271 
    272     this.loadScript(tinyMCE.baseURL + '/themes/' + this.settings['theme'] + '/editor_template' + tinyMCE.srcMode + '.js');
    273     this.loadScript(tinyMCE.baseURL + '/langs/' + this.settings['language'] +  '.js');
    274     this.loadCSS(this.settings['editor_css']);
    275 
    276     // Add plugins
    277     var themePlugins = tinyMCE.getParam('plugins', '', true, ',');
    278     if (this.settings['plugins'] != '') {
    279         for (var i=0; i<themePlugins.length; i++)
    280             this.loadScript(tinyMCE.baseURL + '/plugins/' + themePlugins[i] + '/editor_plugin' + tinyMCE.srcMode + '.js');
    281     }
    282 
    283     // Setup entities
    284     settings['cleanup_entities'] = new Array();
    285     var entities = tinyMCE.getParam('entities', '', true, ',');
    286     for (var i=0; i<entities.length; i+=2)
    287         settings['cleanup_entities']['c' + entities[i]] = entities[i+1];
    288 
    289     // Save away this config
    290     settings['index'] = this.configs.length;
    291     this.configs[this.configs.length] = settings;
    292 };
    293 
    294 TinyMCE.prototype.loadScript = function(url) {
    295     for (var i=0; i<this.loadedFiles.length; i++) {
    296         if (this.loadedFiles[i] == url)
     314    },
     315
     316    _def : function(key, def_val, t) {
     317        var v = tinyMCE.getParam(key, def_val);
     318
     319        v = t ? v.replace(/\s+/g,"") : v;
     320
     321        this.settings[key] = v;
     322    },
     323
     324    hasPlugin : function(n) {
     325        return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null;
     326    },
     327
     328    addPlugin : function(n, p) {
     329        var op = this.plugins[n];
     330
     331        // Use the previous plugin object base URL used when loading external plugins
     332        p.baseURL = op ? op.baseURL : tinyMCE.baseURL + "/plugins/" + n;
     333        this.plugins[n] = p;
     334
     335        this.loadNextScript();
     336    },
     337
     338    setPluginBaseURL : function(n, u) {
     339        var op = this.plugins[n];
     340
     341        if (op)
     342            op.baseURL = u;
     343        else
     344            this.plugins[n] = {baseURL : u};
     345    },
     346
     347    loadPlugin : function(n, u) {
     348        u = u.indexOf('.js') != -1 ? u.substring(0, u.lastIndexOf('/')) : u;
     349        u = u.charAt(u.length-1) == '/' ? u.substring(0, u.length-1) : u;
     350        this.plugins[n] = {baseURL : u};
     351        this.loadScript(u + "/editor_plugin" + (tinyMCE.srcMode ? '_src' : '') + ".js");
     352    },
     353
     354    hasTheme : function(n) {
     355        return typeof(this.themes[n]) != "undefined" && this.themes[n] != null;
     356    },
     357
     358    addTheme : function(n, t) {
     359        this.themes[n] = t;
     360
     361        this.loadNextScript();
     362    },
     363
     364    addMenu : function(n, m) {
     365        this.menus[n] = m;
     366    },
     367
     368    hasMenu : function(n) {
     369        return typeof(this.plugins[n]) != "undefined" && this.plugins[n] != null;
     370    },
     371
     372    loadScript : function(url) {
     373        var i;
     374
     375        for (i=0; i<this.loadedFiles.length; i++) {
     376            if (this.loadedFiles[i] == url)
     377                return;
     378        }
     379
     380        if (tinyMCE.settings.strict_loading_mode)
     381            this.pendingFiles[this.pendingFiles.length] = url;
     382        else
     383            document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></script>');
     384
     385        this.loadedFiles[this.loadedFiles.length] = url;
     386    },
     387
     388    loadNextScript : function() {
     389        var d = document, se;
     390
     391        if (!tinyMCE.settings.strict_loading_mode)
    297392            return;
    298     }
    299 
    300     document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></script>');
    301 
    302     this.loadedFiles[this.loadedFiles.length] = url;
    303 };
    304 
    305 TinyMCE.prototype.loadCSS = function(url) {
    306     for (var i=0; i<this.loadedFiles.length; i++) {
    307         if (this.loadedFiles[i] == url)
    308             return;
    309     }
    310 
    311     document.write('<link href="' + url + '" rel="stylesheet" type="text/css" />');
    312 
    313     this.loadedFiles[this.loadedFiles.length] = url;
    314 };
    315 
    316 TinyMCE.prototype.importCSS = function(doc, css_file) {
    317     if (css_file == '')
    318         return;
    319 
    320     if (typeof(doc.createStyleSheet) == "undefined") {
    321         var elm = doc.createElement("link");
    322 
    323         elm.rel = "stylesheet";
    324         elm.href = css_file;
    325 
    326         if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0)
    327             headArr[0].appendChild(elm);
    328     } else
    329         var styleSheet = doc.createStyleSheet(css_file);
    330 };
    331 
    332 TinyMCE.prototype.confirmAdd = function(e, settings) {
    333     var elm = tinyMCE.isMSIE ? event.srcElement : e.target;
    334     var elementId = elm.name ? elm.name : elm.id;
    335 
    336     tinyMCE.settings = settings;
    337 
    338     if (!elm.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm']))
    339         tinyMCE.addMCEControl(elm, elementId);
    340 
    341     elm.setAttribute('mce_noask', 'true');
    342 };
    343 
    344 TinyMCE.prototype.updateContent = function(form_element_name) {
    345     // Find MCE instance linked to given form element and copy it's value
    346     var formElement = document.getElementById(form_element_name);
    347     for (var n in tinyMCE.instances) {
    348         var inst = tinyMCE.instances[n];
    349         if (!tinyMCE.isInstance(inst))
    350             continue;
    351 
    352         inst.switchSettings();
    353 
    354         if (inst.formElement == formElement) {
    355             var doc = inst.getDoc();
    356    
    357             tinyMCE._setHTML(doc, inst.formElement.value);
    358 
    359             if (!tinyMCE.isMSIE)
    360                 doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid);
    361         }
    362     }
    363 };
    364 
    365 TinyMCE.prototype.addMCEControl = function(replace_element, form_element_name, target_document) {
    366     var id = "mce_editor_" + tinyMCE.idCounter++;
    367     var inst = new TinyMCEControl(tinyMCE.settings);
    368 
    369     inst.editorId = id;
    370     this.instances[id] = inst;
    371 
    372     inst.onAdd(replace_element, form_element_name, target_document);
    373 };
    374 
    375 TinyMCE.prototype.triggerSave = function(skip_cleanup, skip_callback) {
    376     // Cleanup and set all form fields
    377     for (var n in tinyMCE.instances) {
    378         var inst = tinyMCE.instances[n];
    379         if (!tinyMCE.isInstance(inst))
    380             continue;
    381 
    382         inst.switchSettings();
    383 
    384         tinyMCE.settings['preformatted'] = false;
     393
     394        if (this.loadingIndex < this.pendingFiles.length) {
     395            se = d.createElementNS('http://www.w3.org/1999/xhtml', 'script');
     396            se.setAttribute('language', 'javascript');
     397            se.setAttribute('type', 'text/javascript');
     398            se.setAttribute('src', this.pendingFiles[this.loadingIndex++]);
     399
     400            d.getElementsByTagName("head")[0].appendChild(se);
     401        } else
     402            this.loadingIndex = -1; // Done with loading
     403    },
     404
     405    loadCSS : function(url) {
     406        var ar = url.replace(/\s+/, '').split(',');
     407        var lflen = 0, csslen = 0;
     408        var skip = false;
     409        var x = 0, i = 0, nl, le;
     410
     411        for (x = 0,csslen = ar.length; x<csslen; x++) {
     412            ignore_css = false;
     413
     414            if (ar[x] != null && ar[x] != 'null' && ar[x].length > 0) {
     415                /* Make sure it doesn't exist. */
     416                for (i=0, lflen=this.loadedFiles.length; i<lflen; i++) {
     417                    if (this.loadedFiles[i] == ar[x]) {
     418                        skip = true;
     419                        break;
     420                    }
     421                }
     422
     423                if (!skip) {
     424                    if (tinyMCE.settings.strict_loading_mode) {
     425                        nl = document.getElementsByTagName("head");
     426
     427                        le = document.createElement('link');
     428                        le.setAttribute('href', ar[x]);
     429                        le.setAttribute('rel', 'stylesheet');
     430                        le.setAttribute('type', 'text/css');
     431
     432                        nl[0].appendChild(le);         
     433                    } else
     434                        document.write('<link href="' + ar[x] + '" rel="stylesheet" type="text/css" />');
     435
     436                    this.loadedFiles[this.loadedFiles.length] = ar[x];
     437                }
     438            }
     439        }
     440    },
     441
     442    importCSS : function(doc, css) {
     443        var css_ary = css.replace(/\s+/, '').split(',');
     444        var csslen, elm, headArr, x, css_file;
     445
     446        for (x = 0, csslen = css_ary.length; x<csslen; x++) {
     447            css_file = css_ary[x];
     448
     449            if (css_file != null && css_file != 'null' && css_file.length > 0) {
     450                // Is relative, make absolute
     451                if (css_file.indexOf('://') == -1 && css_file.charAt(0) != '/')
     452                    css_file = this.documentBasePath + "/" + css_file;
     453
     454                if (typeof(doc.createStyleSheet) == "undefined") {
     455                    elm = doc.createElement("link");
     456
     457                    elm.rel = "stylesheet";
     458                    elm.href = css_file;
     459
     460                    if ((headArr = doc.getElementsByTagName("head")) != null && headArr.length > 0)
     461                        headArr[0].appendChild(elm);
     462                } else
     463                    doc.createStyleSheet(css_file);
     464            }
     465        }
     466    },
     467
     468    confirmAdd : function(e, settings) {
     469        var elm = tinyMCE.isMSIE ? event.srcElement : e.target;
     470        var elementId = elm.name ? elm.name : elm.id;
     471
     472        tinyMCE.settings = settings;
     473
     474        if (tinyMCE.settings['convert_on_click'] || (!elm.getAttribute('mce_noask') && confirm(tinyMCELang['lang_edit_confirm'])))
     475            tinyMCE.addMCEControl(elm, elementId);
     476
     477        elm.setAttribute('mce_noask', 'true');
     478    },
     479
     480    updateContent : function(form_element_name) {
     481        // Find MCE instance linked to given form element and copy it's value
     482        var formElement = document.getElementById(form_element_name);
     483        for (var n in tinyMCE.instances) {
     484            var inst = tinyMCE.instances[n];
     485            if (!tinyMCE.isInstance(inst))
     486                continue;
     487
     488            inst.switchSettings();
     489
     490            if (inst.formElement == formElement) {
     491                var doc = inst.getDoc();
     492       
     493                tinyMCE._setHTML(doc, inst.formElement.value);
     494
     495                if (!tinyMCE.isMSIE)
     496                    doc.body.innerHTML = tinyMCE._cleanupHTML(inst, doc, this.settings, doc.body, inst.visualAid);
     497            }
     498        }
     499    },
     500
     501    addMCEControl : function(replace_element, form_element_name, target_document) {
     502        var id = "mce_editor_" + tinyMCE.idCounter++;
     503        var inst = new TinyMCE_Control(tinyMCE.settings);
     504
     505        inst.editorId = id;
     506        this.instances[id] = inst;
     507
     508        inst._onAdd(replace_element, form_element_name, target_document);
     509    },
     510
     511    removeMCEControl : function(editor_id) {
     512        var inst = tinyMCE.getInstanceById(editor_id);
     513
     514        if (inst) {
     515            inst.switchSettings();
     516
     517            editor_id = inst.editorId;
     518            var html = tinyMCE.getContent(editor_id);
     519
     520            // Remove editor instance from instances array
     521            var tmpInstances = new Array();
     522            for (var instanceName in tinyMCE.instances) {
     523                var instance = tinyMCE.instances[instanceName];
     524                if (!tinyMCE.isInstance(instance))
     525                    continue;
     526
     527                if (instanceName != editor_id)
     528                        tmpInstances[instanceName] = instance;
     529            }
     530            tinyMCE.instances = tmpInstances;
     531
     532            tinyMCE.selectedElement = null;
     533            tinyMCE.selectedInstance = null;
     534
     535            // Remove element
     536            var replaceElement = document.getElementById(editor_id + "_parent");
     537            var oldTargetElement = inst.oldTargetElement;
     538            var targetName = oldTargetElement.nodeName.toLowerCase();
     539
     540            if (targetName == "textarea" || targetName == "input") {
     541                // Just show the old text area
     542                replaceElement.parentNode.removeChild(replaceElement);
     543                oldTargetElement.style.display = "inline";
     544                oldTargetElement.value = html;
     545            } else {
     546                oldTargetElement.innerHTML = html;
     547                oldTargetElement.style.display = 'block';
     548
     549                replaceElement.parentNode.insertBefore(oldTargetElement, replaceElement);
     550                replaceElement.parentNode.removeChild(replaceElement);
     551            }
     552        }
     553    },
     554
     555    triggerSave : function(skip_cleanup, skip_callback) {
     556        var inst, n;
    385557
    386558        // Default to false
     
    392564            skip_callback = false;
    393565
    394         tinyMCE._setHTML(inst.getDoc(), inst.getBody().innerHTML);
     566        // Cleanup and set all form fields
     567        for (n in tinyMCE.instances) {
     568            inst = tinyMCE.instances[n];
     569
     570            if (!tinyMCE.isInstance(inst))
     571                continue;
     572
     573            inst.triggerSave(skip_cleanup, skip_callback);
     574        }
     575    },
     576
     577    resetForm : function(form_index) {
     578        var i, inst, n, formObj = document.forms[form_index];
     579
     580        for (n in tinyMCE.instances) {
     581            inst = tinyMCE.instances[n];
     582
     583            if (!tinyMCE.isInstance(inst))
     584                continue;
     585
     586            inst.switchSettings();
     587
     588            for (i=0; i<formObj.elements.length; i++) {
     589                if (inst.formTargetElementId == formObj.elements[i].name)
     590                    inst.getBody().innerHTML = inst.startContent;
     591            }
     592        }
     593    },
     594
     595    execInstanceCommand : function(editor_id, command, user_interface, value, focus) {
     596        var inst = tinyMCE.getInstanceById(editor_id);
     597        if (inst) {
     598            if (typeof(focus) == "undefined")
     599                focus = true;
     600
     601            if (focus)
     602                inst.contentWindow.focus();
     603
     604            // Reset design mode if lost
     605            inst.autoResetDesignMode();
     606
     607            this.selectedElement = inst.getFocusElement();
     608            this.selectedInstance = inst;
     609            tinyMCE.execCommand(command, user_interface, value);
     610
     611            // Cancel event so it doesn't call onbeforeonunlaod
     612            if (tinyMCE.isMSIE && window.event != null)
     613                tinyMCE.cancelEvent(window.event);
     614        }
     615    },
     616
     617    execCommand : function(command, user_interface, value) {
     618        // Default input
     619        user_interface = user_interface ? user_interface : false;
     620        value = value ? value : null;
     621
     622        if (tinyMCE.selectedInstance)
     623            tinyMCE.selectedInstance.switchSettings();
     624
     625        switch (command) {
     626            case 'mceHelp':
     627                tinyMCE.openWindow({
     628                    file : 'about.htm',
     629                    width : 480,
     630                    height : 380
     631                }, {
     632                    tinymce_version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion,
     633                    tinymce_releasedate : tinyMCE.releaseDate,
     634                    inline : "yes"
     635                });
     636            return;
     637
     638            case 'mceFocus':
     639                var inst = tinyMCE.getInstanceById(value);
     640                if (inst)
     641                    inst.contentWindow.focus();
     642            return;
     643
     644            case "mceAddControl":
     645            case "mceAddEditor":
     646                tinyMCE.addMCEControl(tinyMCE._getElementById(value), value);
     647                return;
     648
     649            case "mceAddFrameControl":
     650                tinyMCE.addMCEControl(tinyMCE._getElementById(value['element'], value['document']), value['element'], value['document']);
     651                return;
     652
     653            case "mceRemoveControl":
     654            case "mceRemoveEditor":
     655                tinyMCE.removeMCEControl(value);
     656                return;
     657
     658            case "mceResetDesignMode":
     659                // Resets the designmode state of the editors in Gecko
     660                if (!tinyMCE.isMSIE) {
     661                    for (var n in tinyMCE.instances) {
     662                        if (!tinyMCE.isInstance(tinyMCE.instances[n]))
     663                            continue;
     664
     665                        try {
     666                            tinyMCE.instances[n].getDoc().designMode = "on";
     667                        } catch (e) {
     668                            // Ignore any errors
     669                        }
     670                    }
     671                }
     672
     673                return;
     674        }
     675
     676        if (this.selectedInstance) {
     677            this.selectedInstance.execCommand(command, user_interface, value);
     678        } else if (tinyMCE.settings['focus_alert'])
     679            alert(tinyMCELang['lang_focus_alert']);
     680    },
     681
     682    _createIFrame : function(replace_element, doc, win) {
     683        var iframe, id = replace_element.getAttribute("id");
     684        var aw, ah;
     685
     686        if (typeof(doc) == "undefined")
     687            doc = document;
     688
     689        if (typeof(win) == "undefined")
     690            win = window;
     691
     692        iframe = doc.createElement("iframe");
     693
     694        aw = "" + tinyMCE.settings['area_width'];
     695        ah = "" + tinyMCE.settings['area_height'];
     696
     697        if (aw.indexOf('%') == -1) {
     698            aw = parseInt(aw);
     699            aw = aw < 0 ? 300 : aw;
     700            aw = aw + "px";
     701        }
     702
     703        if (ah.indexOf('%') == -1) {
     704            ah = parseInt(ah);
     705            ah = ah < 0 ? 240 : ah;
     706            ah = ah + "px";
     707        }
     708
     709        iframe.setAttribute("id", id);
     710        iframe.setAttribute("class", "mceEditorIframe");
     711        iframe.setAttribute("border", "0");
     712        iframe.setAttribute("frameBorder", "0");
     713        iframe.setAttribute("marginWidth", "0");
     714        iframe.setAttribute("marginHeight", "0");
     715        iframe.setAttribute("leftMargin", "0");
     716        iframe.setAttribute("topMargin", "0");
     717        iframe.setAttribute("width", aw);
     718        iframe.setAttribute("height", ah);
     719        iframe.setAttribute("allowtransparency", "true");
     720        iframe.className = 'mceEditorIframe';
     721
     722        if (tinyMCE.settings["auto_resize"])
     723            iframe.setAttribute("scrolling", "no");
     724
     725        // Must have a src element in MSIE HTTPs breaks aswell as absoute URLs
     726        if (tinyMCE.isMSIE && !tinyMCE.isOpera)
     727            iframe.setAttribute("src", this.settings['default_document']);
     728
     729        iframe.style.width = aw;
     730        iframe.style.height = ah;
     731
     732        // Ugly hack for Gecko problem in strict mode
     733        if (tinyMCE.settings.strict_loading_mode)
     734            iframe.style.marginBottom = '-5px';
     735
     736        // MSIE 5.0 issue
     737        if (tinyMCE.isMSIE && !tinyMCE.isOpera)
     738            replace_element.outerHTML = iframe.outerHTML;
     739        else
     740            replace_element.parentNode.replaceChild(iframe, replace_element);
     741
     742        if (tinyMCE.isMSIE && !tinyMCE.isOpera)
     743            return win.frames[id];
     744        else
     745            return iframe;
     746    },
     747
     748    setupContent : function(editor_id) {
     749        var inst = tinyMCE.instances[editor_id];
     750        var doc = inst.getDoc();
     751        var head = doc.getElementsByTagName('head').item(0);
     752        var content = inst.startContent;
     753
     754        // HTML values get XML encoded in strict mode
     755        if (tinyMCE.settings.strict_loading_mode) {
     756            content = content.replace(/&lt;/g, '<');
     757            content = content.replace(/&gt;/g, '>');
     758            content = content.replace(/&quot;/g, '"');
     759            content = content.replace(/&amp;/g, '&');
     760        }
     761
     762        inst.switchSettings();
     763
     764        // Not loaded correctly hit it again, Mozilla bug #997860
     765        if (!tinyMCE.isMSIE && tinyMCE.getParam("setupcontent_reload", false) && doc.title != "blank_page") {
     766            // This part will remove the designMode status
     767            // Failes first time in Firefox 1.5b2 on Mac
     768            try {doc.location.href = tinyMCE.baseURL + "/blank.htm";} catch (ex) {}
     769            window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 1000);
     770            return;
     771        }
     772
     773        if (!head) {
     774            window.setTimeout("tinyMCE.setupContent('" + editor_id + "');", 10);
     775            return;
     776        }
     777
     778        // Import theme specific content CSS the user specific
     779        tinyMCE.importCSS(inst.getDoc(), tinyMCE.baseURL + "/themes/" + inst.settings['theme'] + "/css/editor_content.css");
     780        tinyMCE.importCSS(inst.getDoc(), inst.settings['content_css']);
     781        tinyMCE.dispatchCallback(inst, 'init_instance_callback', 'initInstance', inst);
     782
     783        // Setup keyboard shortcuts
     784        if (tinyMCE.getParam('custom_undo_redo_keyboard_shortcuts')) {
     785            inst.addShortcut('ctrl', 'z', 'lang_undo_desc', 'Undo');
     786            inst.addShortcut('ctrl', 'y', 'lang_redo_desc', 'Redo');
     787        }
     788
     789        // Add default shortcuts for gecko
     790        if (tinyMCE.isGecko) {
     791            inst.addShortcut('ctrl', 'b', 'lang_bold_desc', 'Bold');
     792            inst.addShortcut('ctrl', 'i', 'lang_italic_desc', 'Italic');
     793            inst.addShortcut('ctrl', 'u', 'lang_underline_desc', 'Underline');
     794        }
     795
     796        // Setup span styles
     797        if (tinyMCE.getParam("convert_fonts_to_spans"))
     798            inst.getDoc().body.setAttribute('id', 'mceSpanFonts');
     799
     800        if (tinyMCE.settings['nowrap'])
     801            doc.body.style.whiteSpace = "nowrap";
     802
     803        doc.body.dir = this.settings['directionality'];
     804        doc.editorId = editor_id;
     805
     806        // Add on document element in Mozilla
     807        if (!tinyMCE.isMSIE)
     808            doc.documentElement.editorId = editor_id;
     809
     810        inst.setBaseHREF(tinyMCE.settings['base_href']);
     811
     812        // Replace new line characters to BRs
     813        if (tinyMCE.settings['convert_newlines_to_brs']) {
     814            content = tinyMCE.regexpReplace(content, "\r\n", "<br />", "gi");
     815            content = tinyMCE.regexpReplace(content, "\r", "<br />", "gi");
     816            content = tinyMCE.regexpReplace(content, "\n", "<br />", "gi");
     817        }
     818
     819        // Open closed anchors
     820    //  content = content.replace(new RegExp('<a(.*?)/>', 'gi'), '<a$1></a>');
     821
     822        // Call custom cleanup code
     823        content = tinyMCE.storeAwayURLs(content);
     824        content = tinyMCE._customCleanup(inst, "insert_to_editor", content);
     825
     826        if (tinyMCE.isMSIE) {
     827            // Ugly!!!
     828            window.setInterval('try{tinyMCE.getCSSClasses(tinyMCE.instances["' + editor_id + '"].getDoc(), "' + editor_id + '");}catch(e){}', 500);
     829
     830            if (tinyMCE.settings["force_br_newlines"])
     831                doc.styleSheets[0].addRule("p", "margin: 0;");
     832
     833            var body = inst.getBody();
     834            body.editorId = editor_id;
     835        }
     836
     837        content = tinyMCE.cleanupHTMLCode(content);
     838
     839        // Fix for bug #958637
     840        if (!tinyMCE.isMSIE) {
     841            var contentElement = inst.getDoc().createElement("body");
     842            var doc = inst.getDoc();
     843
     844            contentElement.innerHTML = content;
     845
     846            // Remove weridness!
     847            if (tinyMCE.isGecko && tinyMCE.settings['remove_lt_gt'])
     848                content = content.replace(new RegExp('&lt;&gt;', 'g'), "");
     849
     850            if (tinyMCE.settings['cleanup_on_startup'])
     851                tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, doc, this.settings, contentElement));
     852            else {
     853                // Convert all strong/em to b/i
     854                content = tinyMCE.regexpReplace(content, "<strong", "<b", "gi");
     855                content = tinyMCE.regexpReplace(content, "<em(/?)>", "<i$1>", "gi");
     856                content = tinyMCE.regexpReplace(content, "<em ", "<i ", "gi");
     857                content = tinyMCE.regexpReplace(content, "</strong>", "</b>", "gi");
     858                content = tinyMCE.regexpReplace(content, "</em>", "</i>", "gi");
     859                tinyMCE.setInnerHTML(inst.getBody(), content);
     860            }
     861
     862            tinyMCE.convertAllRelativeURLs(inst.getBody());
     863        } else {
     864            if (tinyMCE.settings['cleanup_on_startup']) {
     865                tinyMCE._setHTML(inst.getDoc(), content);
     866
     867                // Produces permission denied error in MSIE 5.5
     868                eval('try {tinyMCE.setInnerHTML(inst.getBody(), tinyMCE._cleanupHTML(inst, inst.contentDocument, this.settings, inst.getBody()));} catch(e) {}');
     869            } else
     870                tinyMCE._setHTML(inst.getDoc(), content);
     871        }
     872
     873        // Fix for bug #957681
     874        //inst.getDoc().designMode = inst.getDoc().designMode;
     875
     876        // Setup element references
     877        var parentElm = inst.targetDoc.getElementById(inst.editorId + '_parent');
     878        inst.formElement = tinyMCE.isGecko ? parentElm.previousSibling : parentElm.nextSibling;
     879
     880        tinyMCE.handleVisualAid(inst.getBody(), true, tinyMCE.settings['visual'], inst);
     881        tinyMCE.dispatchCallback(inst, 'setupcontent_callback', 'setupContent', editor_id, inst.getBody(), inst.getDoc());
     882
     883        // Re-add design mode on mozilla
     884        if (!tinyMCE.isMSIE)
     885            tinyMCE.addEventHandlers(inst);
     886
     887        // Add blur handler
     888        if (tinyMCE.isMSIE) {
     889            tinyMCE.addEvent(inst.getBody(), "blur", TinyMCE_Engine.prototype._eventPatch);
     890            tinyMCE.addEvent(inst.getBody(), "beforedeactivate", TinyMCE_Engine.prototype._eventPatch); // Bug #1439953
     891
     892            // Workaround for drag drop/copy paste base href bug
     893            if (!tinyMCE.isOpera) {
     894                tinyMCE.addEvent(doc.body, "mousemove", TinyMCE_Engine.prototype.onMouseMove);
     895                tinyMCE.addEvent(doc.body, "beforepaste", TinyMCE_Engine.prototype._eventPatch);
     896                tinyMCE.addEvent(doc.body, "drop", TinyMCE_Engine.prototype._eventPatch);
     897            }
     898        }
     899
     900        // Trigger node change, this call locks buttons for tables and so forth
     901        tinyMCE.selectedInstance = inst;
     902        tinyMCE.selectedElement = inst.contentWindow.document.body;
     903
     904        // Call custom DOM cleanup
     905        tinyMCE._customCleanup(inst, "insert_to_editor_dom", inst.getBody());
     906        tinyMCE._customCleanup(inst, "setup_content_dom", inst.getBody());
     907        tinyMCE._setEventsEnabled(inst.getBody(), false);
     908        tinyMCE.cleanupAnchors(inst.getDoc());
     909
     910        if (tinyMCE.getParam("convert_fonts_to_spans"))
     911            tinyMCE.convertSpansToFonts(inst.getDoc());
     912
     913        inst.startContent = tinyMCE.trim(inst.getBody().innerHTML);
     914        inst.undoRedo.add({ content : inst.startContent });
     915
     916        // Cleanup any mess left from storyAwayURLs
     917        if (tinyMCE.isGecko) {
     918            // Remove mce_src from textnodes and comments
     919            tinyMCE.selectNodes(inst.getBody(), function(n) {
     920                if (n.nodeType == 3 || n.nodeType == 8) {
     921                    n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), "");
     922                    n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), "");
     923                }
     924
     925                return false;
     926            });
     927        }
     928
     929        // Cleanup any mess left from storyAwayURLs
     930        tinyMCE._removeInternal(inst.getBody());
     931
     932        tinyMCE.selectedInstance = inst;
     933        tinyMCE.triggerNodeChange(false, true);
     934    },
     935
     936    storeAwayURLs : function(s) {
     937        // Remove all mce_src, mce_href and replace them with new ones
     938    //  s = s.replace(new RegExp('mce_src\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
     939    //  s = s.replace(new RegExp('mce_href\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');
     940
     941        if (!s.match(/(mce_src|mce_href)/gi, s)) {
     942            s = s.replace(new RegExp('src\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'src="$1" mce_src="$1"');
     943            s = s.replace(new RegExp('href\\s*=\\s*\"([^ >\"]*)\"', 'gi'), 'href="$1" mce_href="$1"');
     944        }
     945
     946        return s;
     947    },
     948
     949    _removeInternal : function(n) {
     950        if (tinyMCE.isGecko) {
     951            // Remove mce_src from textnodes and comments
     952            tinyMCE.selectNodes(n, function(n) {
     953                if (n.nodeType == 3 || n.nodeType == 8) {
     954                    n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), "");
     955                    n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), "");
     956                }
     957
     958                return false;
     959            });
     960        }
     961    },
     962
     963    removeTinyMCEFormElements : function(form_obj) {
     964        // Check if form is valid
     965        if (typeof(form_obj) == "undefined" || form_obj == null)
     966            return;
     967
     968        // If not a form, find the form
     969        if (form_obj.nodeName != "FORM") {
     970            if (form_obj.form)
     971                form_obj = form_obj.form;
     972            else
     973                form_obj = tinyMCE.getParentElement(form_obj, "form");
     974        }
     975
     976        // Still nothing
     977        if (form_obj == null)
     978            return;
     979
     980        // Disable all UI form elements that TinyMCE created
     981        for (var i=0; i<form_obj.elements.length; i++) {
     982            var elementId = form_obj.elements[i].name ? form_obj.elements[i].name : form_obj.elements[i].id;
     983
     984            if (elementId.indexOf('mce_editor_') == 0)
     985                form_obj.elements[i].disabled = true;
     986        }
     987    },
     988
     989    handleEvent : function(e) {
     990        var inst = tinyMCE.selectedInstance;
     991
     992        // Remove odd, error
     993        if (typeof(tinyMCE) == "undefined")
     994            return true;
     995
     996        //tinyMCE.debug(e.type + " " + e.target.nodeName + " " + (e.relatedTarget ? e.relatedTarget.nodeName : ""));
     997
     998        if (tinyMCE.executeCallback(tinyMCE.selectedInstance, 'handle_event_callback', 'handleEvent', e))
     999            return false;
     1000
     1001        switch (e.type) {
     1002            case "beforedeactivate": // Was added due to bug #1439953
     1003            case "blur":
     1004                if (tinyMCE.selectedInstance)
     1005                    tinyMCE.selectedInstance.execCommand('mceEndTyping');
     1006
     1007                tinyMCE.hideMenus();
     1008
     1009                return;
     1010
     1011            // Workaround for drag drop/copy paste base href bug
     1012            case "drop":
     1013            case "beforepaste":
     1014                if (tinyMCE.selectedInstance)
     1015                    tinyMCE.selectedInstance.setBaseHREF(null);
     1016
     1017                // Fixes odd MSIE bug where drag/droping elements in a iframe with height 100% breaks
     1018                // This logic forces the width/height to be in pixels while the user is drag/dropping
     1019                if (tinyMCE.isMSIE && !tinyMCE.isOpera) {
     1020                    var ife = tinyMCE.selectedInstance.iframeElement;
     1021
     1022                    /*if (ife.style.width.indexOf('%') != -1) {
     1023                        ife._oldWidth = ife.width.height;
     1024                        ife.style.width = ife.clientWidth;
     1025                    }*/
     1026
     1027                    if (ife.style.height.indexOf('%') != -1) {
     1028                        ife._oldHeight = ife.style.height;
     1029                        ife.style.height = ife.clientHeight;
     1030                    }
     1031                }
     1032
     1033                window.setTimeout("tinyMCE.selectedInstance.setBaseHREF(tinyMCE.settings['base_href']);tinyMCE._resetIframeHeight();", 1);
     1034                return;
     1035
     1036            case "submit":
     1037                tinyMCE.removeTinyMCEFormElements(tinyMCE.isMSIE ? window.event.srcElement : e.target);
     1038                tinyMCE.triggerSave();
     1039                tinyMCE.isNotDirty = true;
     1040                return;
     1041
     1042            case "reset":
     1043                var formObj = tinyMCE.isMSIE ? window.event.srcElement : e.target;
     1044
     1045                for (var i=0; i<document.forms.length; i++) {
     1046                    if (document.forms[i] == formObj)
     1047                        window.setTimeout('tinyMCE.resetForm(' + i + ');', 10);
     1048                }
     1049
     1050                return;
     1051
     1052            case "keypress":
     1053                if (inst && inst.handleShortcut(e))
     1054                    return false;
     1055
     1056                if (e.target.editorId) {
     1057                    tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
     1058                } else {
     1059                    if (e.target.ownerDocument.editorId)
     1060                        tinyMCE.selectedInstance = tinyMCE.instances[e.target.ownerDocument.editorId];
     1061                }
     1062
     1063                if (tinyMCE.selectedInstance)
     1064                    tinyMCE.selectedInstance.switchSettings();
     1065
     1066                // Insert P element
     1067                if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && e.keyCode == 13 && !e.shiftKey) {
     1068                    // Insert P element instead of BR
     1069                    if (TinyMCE_ForceParagraphs._insertPara(tinyMCE.selectedInstance, e)) {
     1070                        // Cancel event
     1071                        tinyMCE.execCommand("mceAddUndoLevel");
     1072                        tinyMCE.cancelEvent(e);
     1073                        return false;
     1074                    }
     1075                }
     1076
     1077                // Handle backspace
     1078                if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
     1079                    // Insert P element instead of BR
     1080                    if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) {
     1081                        // Cancel event
     1082                        tinyMCE.execCommand("mceAddUndoLevel");
     1083                        tinyMCE.cancelEvent(e);
     1084                        return false;
     1085                    }
     1086                }
     1087
     1088                // Return key pressed
     1089                if (tinyMCE.isMSIE && tinyMCE.settings['force_br_newlines'] && e.keyCode == 13) {
     1090                    if (e.target.editorId)
     1091                        tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
     1092
     1093                    if (tinyMCE.selectedInstance) {
     1094                        var sel = tinyMCE.selectedInstance.getDoc().selection;
     1095                        var rng = sel.createRange();
     1096
     1097                        if (tinyMCE.getParentElement(rng.parentElement(), "li") != null)
     1098                            return false;
     1099
     1100                        // Cancel event
     1101                        e.returnValue = false;
     1102                        e.cancelBubble = true;
     1103
     1104                        // Insert BR element
     1105                        rng.pasteHTML("<br />");
     1106                        rng.collapse(false);
     1107                        rng.select();
     1108
     1109                        tinyMCE.execCommand("mceAddUndoLevel");
     1110                        tinyMCE.triggerNodeChange(false);
     1111                        return false;
     1112                    }
     1113                }
     1114
     1115                // Backspace or delete
     1116                if (e.keyCode == 8 || e.keyCode == 46) {
     1117                    tinyMCE.selectedElement = e.target;
     1118                    tinyMCE.linkElement = tinyMCE.getParentElement(e.target, "a");
     1119                    tinyMCE.imgElement = tinyMCE.getParentElement(e.target, "img");
     1120                    tinyMCE.triggerNodeChange(false);
     1121                }
     1122
     1123                return false;
     1124            break;
     1125
     1126            case "keyup":
     1127            case "keydown":
     1128                tinyMCE.hideMenus();
     1129                tinyMCE.hasMouseMoved = false;
     1130
     1131                if (inst && inst.handleShortcut(e))
     1132                    return false;
     1133
     1134                if (e.target.editorId)
     1135                    tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
     1136                else
     1137                    return;
     1138
     1139                if (tinyMCE.selectedInstance)
     1140                    tinyMCE.selectedInstance.switchSettings();
     1141
     1142                var inst = tinyMCE.selectedInstance;
     1143
     1144                // Handle backspace
     1145                if (tinyMCE.isGecko && tinyMCE.settings['force_p_newlines'] && (e.keyCode == 8 || e.keyCode == 46) && !e.shiftKey) {
     1146                    // Insert P element instead of BR
     1147                    if (TinyMCE_ForceParagraphs._handleBackSpace(tinyMCE.selectedInstance, e.type)) {
     1148                        // Cancel event
     1149                        tinyMCE.execCommand("mceAddUndoLevel");
     1150                        e.preventDefault();
     1151                        return false;
     1152                    }
     1153                }
     1154
     1155                tinyMCE.selectedElement = null;
     1156                tinyMCE.selectedNode = null;
     1157                var elm = tinyMCE.selectedInstance.getFocusElement();
     1158                tinyMCE.linkElement = tinyMCE.getParentElement(elm, "a");
     1159                tinyMCE.imgElement = tinyMCE.getParentElement(elm, "img");
     1160                tinyMCE.selectedElement = elm;
     1161
     1162                // Update visualaids on tabs
     1163                if (tinyMCE.isGecko && e.type == "keyup" && e.keyCode == 9)
     1164                    tinyMCE.handleVisualAid(tinyMCE.selectedInstance.getBody(), true, tinyMCE.settings['visual'], tinyMCE.selectedInstance);
     1165
     1166                // Fix empty elements on return/enter, check where enter occured
     1167                if (tinyMCE.isMSIE && e.type == "keydown" && e.keyCode == 13)
     1168                    tinyMCE.enterKeyElement = tinyMCE.selectedInstance.getFocusElement();
     1169
     1170                // Fix empty elements on return/enter
     1171                if (tinyMCE.isMSIE && e.type == "keyup" && e.keyCode == 13) {
     1172                    var elm = tinyMCE.enterKeyElement;
     1173                    if (elm) {
     1174                        var re = new RegExp('^HR|IMG|BR$','g'); // Skip these
     1175                        var dre = new RegExp('^H[1-6]$','g'); // Add double on these
     1176
     1177                        if (!elm.hasChildNodes() && !re.test(elm.nodeName)) {
     1178                            if (dre.test(elm.nodeName))
     1179                                elm.innerHTML = "&nbsp;&nbsp;";
     1180                            else
     1181                                elm.innerHTML = "&nbsp;";
     1182                        }
     1183                    }
     1184                }
     1185
     1186                // Check if it's a position key
     1187                var keys = tinyMCE.posKeyCodes;
     1188                var posKey = false;
     1189                for (var i=0; i<keys.length; i++) {
     1190                    if (keys[i] == e.keyCode) {
     1191                        posKey = true;
     1192                        break;
     1193                    }
     1194                }
     1195
     1196                // MSIE custom key handling
     1197                if (tinyMCE.isMSIE && tinyMCE.settings['custom_undo_redo']) {
     1198                    var keys = new Array(8,46); // Backspace,Delete
     1199                    for (var i=0; i<keys.length; i++) {
     1200                        if (keys[i] == e.keyCode) {
     1201                            if (e.type == "keyup")
     1202                                tinyMCE.triggerNodeChange(false);
     1203                        }
     1204                    }
     1205                }
     1206
     1207                // If Ctrl key
     1208                if (e.keyCode == 17)
     1209                    return true;
     1210
     1211                // Handle Undo/Redo when typing content
     1212
     1213                // Start typing (non position key)
     1214                if (!posKey && e.type == "keyup")
     1215                    tinyMCE.execCommand("mceStartTyping");
     1216
     1217                // Store undo bookmark
     1218                if (e.type == "keydown" && (posKey || e.ctrlKey) && inst)
     1219                    inst.undoBookmark = inst.selection.getBookmark();
     1220
     1221                // End typing (position key) or some Ctrl event
     1222                if (e.type == "keyup" && (posKey || e.ctrlKey))
     1223                    tinyMCE.execCommand("mceEndTyping");
     1224
     1225                if (posKey && e.type == "keyup")
     1226                    tinyMCE.triggerNodeChange(false);
     1227
     1228                if (tinyMCE.isMSIE && e.ctrlKey)
     1229                    window.setTimeout('tinyMCE.triggerNodeChange(false);', 1);
     1230            break;
     1231
     1232            case "mousedown":
     1233            case "mouseup":
     1234            case "click":
     1235            case "focus":
     1236                tinyMCE.hideMenus();
     1237
     1238                if (tinyMCE.selectedInstance) {
     1239                    tinyMCE.selectedInstance.switchSettings();
     1240                    tinyMCE.selectedInstance.isFocused = true;
     1241                }
     1242
     1243                // Check instance event trigged on
     1244                var targetBody = tinyMCE.getParentElement(e.target, "body");
     1245                for (var instanceName in tinyMCE.instances) {
     1246                    if (!tinyMCE.isInstance(tinyMCE.instances[instanceName]))
     1247                        continue;
     1248
     1249                    var inst = tinyMCE.instances[instanceName];
     1250
     1251                    // Reset design mode if lost (on everything just in case)
     1252                    inst.autoResetDesignMode();
     1253
     1254                    if (inst.getBody() == targetBody) {
     1255                        tinyMCE.selectedInstance = inst;
     1256                        tinyMCE.selectedElement = e.target;
     1257                        tinyMCE.linkElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
     1258                        tinyMCE.imgElement = tinyMCE.getParentElement(tinyMCE.selectedElement, "img");
     1259                        break;
     1260                    }
     1261                }
     1262
     1263                // Add first bookmark location
     1264                if (!tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark)
     1265                    tinyMCE.selectedInstance.undoRedo.undoLevels[0].bookmark = tinyMCE.selectedInstance.selection.getBookmark();
     1266
     1267                if (tinyMCE.isSafari) {
     1268                    tinyMCE.selectedInstance.lastSafariSelection = tinyMCE.selectedInstance.selection.getBookmark();
     1269                    tinyMCE.selectedInstance.lastSafariSelectedElement = tinyMCE.selectedElement;
     1270
     1271                    var lnk = tinyMCE.getParentElement(tinyMCE.selectedElement, "a");
     1272
     1273                    // Patch the darned link
     1274                    if (lnk && e.type == "mousedown") {
     1275                        lnk.setAttribute("mce_real_href", lnk.getAttribute("href"));
     1276                        lnk.setAttribute("href", "javascript:void(0);");
     1277                    }
     1278
     1279                    // Patch back
     1280                    if (lnk && e.type == "click") {
     1281                        window.setTimeout(function() {
     1282                            lnk.setAttribute("href", lnk.getAttribute("mce_real_href"));
     1283                            lnk.removeAttribute("mce_real_href");
     1284                        }, 10);
     1285                    }
     1286                }
     1287
     1288                // Reset selected node
     1289                if (e.type != "focus")
     1290                    tinyMCE.selectedNode = null;
     1291
     1292                tinyMCE.triggerNodeChange(false);
     1293                tinyMCE.execCommand("mceEndTyping");
     1294
     1295                if (e.type == "mouseup")
     1296                    tinyMCE.execCommand("mceAddUndoLevel");
     1297
     1298                // Just in case
     1299                if (!tinyMCE.selectedInstance && e.target.editorId)
     1300                    tinyMCE.selectedInstance = tinyMCE.instances[e.target.editorId];
     1301
     1302                return false;
     1303            break;
     1304        }
     1305    },
     1306
     1307    getButtonHTML : function(id, lang, img, cmd, ui, val) {
     1308        var h = '', m, x;
     1309
     1310        cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'' + cmd + '\'';
     1311
     1312        if (typeof(ui) != "undefined" && ui != null)
     1313            cmd += ',' + ui;
     1314
     1315        if (typeof(val) != "undefined" && val != null)
     1316            cmd += ",'" + val + "'";
     1317
     1318        cmd += ');';
     1319
     1320        // Use tilemaps when enabled and found and never in MSIE since it loads the tile each time from cache if cahce is disabled
     1321        if (tinyMCE.getParam('button_tile_map') && (!tinyMCE.isMSIE || tinyMCE.isOpera) && (m = this.buttonMap[id]) != null && (tinyMCE.getParam("language") == "en" || img.indexOf('$lang') == -1)) {
     1322            // Tiled button
     1323            x = 0 - (m * 20) == 0 ? '0' : 0 - (m * 20);
     1324            h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceTiledButton mceButtonNormal" target="_self">';
     1325            h += '<img src="{$themeurl}/images/spacer.gif" style="background-position: ' + x + 'px 0" title="{$' + lang + '}" />';
     1326            h += '</a>';
     1327        } else {
     1328            // Normal button
     1329            h += '<a id="{$editor_id}_' + id + '" href="javascript:' + cmd + '" onclick="' + cmd + 'return false;" onmousedown="return false;" class="mceButtonNormal" target="_self">';
     1330            h += '<img src="' + img + '" title="{$' + lang + '}" />';
     1331            h += '</a>';
     1332        }
     1333
     1334        return h;
     1335    },
     1336
     1337    addButtonMap : function(m) {
     1338        var i, a = m.replace(/\s+/, '').split(',');
     1339
     1340        for (i=0; i<a.length; i++)
     1341            this.buttonMap[a[i]] = i;
     1342    },
     1343
     1344    submitPatch : function() {
     1345        tinyMCE.removeTinyMCEFormElements(this);
     1346        tinyMCE.triggerSave();
     1347        this.mceOldSubmit();
     1348        tinyMCE.isNotDirty = true;
     1349    },
     1350
     1351    onLoad : function() {
     1352        // Wait for everything to be loaded first
     1353        if (tinyMCE.settings.strict_loading_mode && this.loadingIndex != -1) {
     1354            window.setTimeout('tinyMCE.onLoad();', 1);
     1355            return;
     1356        }
     1357
     1358        if (tinyMCE.isMSIE && !tinyMCE.isOpera && window.event.type == "readystatechange" && document.readyState !