Changes in trunk [3503:4431]
- Location:
- trunk
- Files:
-
- 116 added
- 23 deleted
- 155 edited
-
readme.html (modified) (3 diffs)
-
wp-admin/admin-ajax.php (added)
-
wp-admin/admin-db.php (modified) (15 diffs)
-
wp-admin/admin-footer.php (modified) (1 diff)
-
wp-admin/admin-functions.php (modified) (64 diffs)
-
wp-admin/admin-header.php (modified) (2 diffs)
-
wp-admin/admin.php (modified) (3 diffs)
-
wp-admin/bookmarklet.php (modified) (4 diffs)
-
wp-admin/cat-js.php (modified) (1 diff)
-
wp-admin/categories.js (added)
-
wp-admin/categories.php (modified) (7 diffs)
-
wp-admin/comment.php (added)
-
wp-admin/custom-fields.js (added)
-
wp-admin/dbx-admin-key-js.php (added)
-
wp-admin/edit-category-form.php (added)
-
wp-admin/edit-comments.js (added)
-
wp-admin/edit-comments.php (modified) (9 diffs)
-
wp-admin/edit-form-advanced.php (modified) (15 diffs)
-
wp-admin/edit-form-ajax-cat.php (deleted)
-
wp-admin/edit-form-comment.php (modified) (4 diffs)
-
wp-admin/edit-form.php (modified) (3 diffs)
-
wp-admin/edit-link-form.php (modified) (2 diffs)
-
wp-admin/edit-page-form.php (modified) (11 diffs)
-
wp-admin/edit-pages.php (modified) (4 diffs)
-
wp-admin/edit.php (modified) (11 diffs)
-
wp-admin/execute-pings.php (deleted)
-
wp-admin/export.php (added)
-
wp-admin/images/box-bg-left.gif (added)
-
wp-admin/images/box-bg-right.gif (added)
-
wp-admin/images/box-butt-left.gif (added)
-
wp-admin/images/box-butt-right.gif (added)
-
wp-admin/images/box-head-left.gif (added)
-
wp-admin/images/box-head-right.gif (added)
-
wp-admin/images/login-bkg-bottom.gif (added)
-
wp-admin/images/login-bkg-tile.gif (added)
-
wp-admin/import.php (modified) (4 diffs)
-
wp-admin/import/blogger.php (modified) (21 diffs)
-
wp-admin/import/blogware.php (added)
-
wp-admin/import/dotclear.php (modified) (42 diffs, 1 prop)
-
wp-admin/import/greymatter.php (modified) (1 diff)
-
wp-admin/import/livejournal.php (modified) (8 diffs)
-
wp-admin/import/mt.php (modified) (13 diffs)
-
wp-admin/import/rss.php (modified) (7 diffs)
-
wp-admin/import/textpattern.php (modified) (43 diffs)
-
wp-admin/import/wordpress.php (added)
-
wp-admin/index.php (modified) (11 diffs)
-
wp-admin/inline-uploading.php (deleted)
-
wp-admin/install-rtl.css (added)
-
wp-admin/install.css (added)
-
wp-admin/install.php (modified) (5 diffs)
-
wp-admin/link-add.php (modified) (2 diffs)
-
wp-admin/link-categories.php (deleted)
-
wp-admin/link-import.php (modified) (7 diffs)
-
wp-admin/link-manager.php (modified) (2 diffs)
-
wp-admin/link.php (added)
-
wp-admin/list-manipulation.js (deleted)
-
wp-admin/list-manipulation.php (deleted)
-
wp-admin/menu-header.php (modified) (3 diffs)
-
wp-admin/menu.php (modified) (3 diffs)
-
wp-admin/moderation.php (modified) (8 diffs)
-
wp-admin/options-discussion.php (modified) (5 diffs)
-
wp-admin/options-general.php (modified) (7 diffs)
-
wp-admin/options-head.php (modified) (1 diff)
-
wp-admin/options-misc.php (modified) (5 diffs)
-
wp-admin/options-permalink.php (modified) (10 diffs)
-
wp-admin/options-privacy.php (added)
-
wp-admin/options-reading.php (modified) (5 diffs)
-
wp-admin/options-writing.php (modified) (6 diffs)
-
wp-admin/options.php (modified) (5 diffs)
-
wp-admin/page-new.php (modified) (2 diffs)
-
wp-admin/page.php (added)
-
wp-admin/plugin-editor.php (modified) (7 diffs)
-
wp-admin/plugins.php (modified) (8 diffs)
-
wp-admin/post-new.php (added)
-
wp-admin/post.php (modified) (7 diffs)
-
wp-admin/profile-update.php (modified) (1 diff)
-
wp-admin/profile.php (modified) (5 diffs)
-
wp-admin/rtl.css (added)
-
wp-admin/setup-config.php (modified) (4 diffs)
-
wp-admin/sidebar.php (modified) (2 diffs)
-
wp-admin/templates.php (modified) (9 diffs)
-
wp-admin/theme-editor.php (modified) (8 diffs)
-
wp-admin/themes.php (modified) (3 diffs)
-
wp-admin/update-links.php (modified) (3 diffs)
-
wp-admin/upgrade-functions.php (modified) (23 diffs)
-
wp-admin/upgrade-schema.php (modified) (13 diffs)
-
wp-admin/upgrade.php (modified) (3 diffs)
-
wp-admin/upload-functions.php (added)
-
wp-admin/upload-js.php (added)
-
wp-admin/upload-rtl.css (added)
-
wp-admin/upload.css (added)
-
wp-admin/upload.php (added)
-
wp-admin/user-edit.php (modified) (5 diffs)
-
wp-admin/users.js (added)
-
wp-admin/users.php (modified) (11 diffs)
-
wp-admin/wp-admin.css (modified) (35 diffs)
-
wp-admin/xfn.js (modified) (1 diff)
-
wp-atom.php (modified) (3 diffs)
-
wp-blog-header.php (modified) (1 diff)
-
wp-comments-post.php (modified) (2 diffs)
-
wp-commentsrss2.php (modified) (4 diffs)
-
wp-config-sample.php (modified) (1 prop)
-
wp-content/plugins/hello.php (modified) (1 diff)
-
wp-content/plugins/wp-db-backup.php (deleted)
-
wp-content/themes/classic/comments-popup.php (modified) (5 diffs)
-
wp-content/themes/classic/comments.php (modified) (1 diff)
-
wp-content/themes/classic/header.php (modified) (2 diffs)
-
wp-content/themes/classic/index.php (modified) (1 diff)
-
wp-content/themes/classic/sidebar.php (modified) (1 diff)
-
wp-content/themes/default/archive.php (modified) (5 diffs)
-
wp-content/themes/default/archives.php (modified) (1 diff)
-
wp-content/themes/default/attachment.php (modified) (3 diffs)
-
wp-content/themes/default/comments-popup.php (modified) (5 diffs)
-
wp-content/themes/default/comments.php (modified) (3 diffs)
-
wp-content/themes/default/footer.php (modified) (1 diff)
-
wp-content/themes/default/functions.php (modified) (15 diffs)
-
wp-content/themes/default/header.php (modified) (2 diffs)
-
wp-content/themes/default/index.php (modified) (2 diffs)
-
wp-content/themes/default/links.php (modified) (1 diff)
-
wp-content/themes/default/page.php (modified) (1 diff)
-
wp-content/themes/default/search.php (modified) (4 diffs)
-
wp-content/themes/default/searchform.php (modified) (1 diff)
-
wp-content/themes/default/sidebar.php (modified) (5 diffs)
-
wp-content/themes/default/single.php (modified) (2 diffs)
-
wp-content/themes/default/style.css (modified) (18 diffs)
-
wp-cron.php (added)
-
wp-feed.php (modified) (1 diff)
-
wp-includes/author-template.php (added)
-
wp-includes/bookmark-template.php (added)
-
wp-includes/bookmark.php (added)
-
wp-includes/cache.php (modified) (14 diffs)
-
wp-includes/capabilities.php (modified) (20 diffs)
-
wp-includes/category-template.php (added)
-
wp-includes/category.php (added)
-
wp-includes/class-simplepie.php (added)
-
wp-includes/class-snoopy.php (modified) (72 diffs)
-
wp-includes/classes.php (modified) (19 diffs)
-
wp-includes/comment-functions.php (deleted)
-
wp-includes/comment-template.php (added)
-
wp-includes/comment.php (added)
-
wp-includes/compat.php (added)
-
wp-includes/cron.php (added)
-
wp-includes/default-filters.php (modified) (3 diffs)
-
wp-includes/deprecated.php (added)
-
wp-includes/feed-functions.php (deleted)
-
wp-includes/feed.php (added)
-
wp-includes/formatting.php (added)
-
wp-includes/functions-compat.php (deleted)
-
wp-includes/functions-formatting.php (deleted)
-
wp-includes/functions-post.php (deleted)
-
wp-includes/functions.php (modified) (31 diffs)
-
wp-includes/general-template.php (added)
-
wp-includes/gettext.php (modified) (6 diffs)
-
wp-includes/js/autosave.js.php (added)
-
wp-includes/js/colorpicker.js (modified) (5 diffs)
-
wp-includes/js/dbx-key.js (deleted)
-
wp-includes/js/dbx.js (modified) (1 diff)
-
wp-includes/js/fat.js (modified) (5 diffs)
-
wp-includes/js/list-manipulation-js.php (added)
-
wp-includes/js/prototype.js (added)
-
wp-includes/js/quicktags.js (modified) (1 diff)
-
wp-includes/js/tinymce/langs/en.js (modified) (1 diff)
-
wp-includes/js/tinymce/plugins/autosave/editor_plugin.js (modified) (1 diff)
-
wp-includes/js/tinymce/plugins/directionality/editor_plugin.js (modified) (1 diff)
-
wp-includes/js/tinymce/plugins/inlinepopups/css/inlinepopup.css (modified) (1 diff)
-
wp-includes/js/tinymce/plugins/inlinepopups/editor_plugin.js (modified) (1 diff)
-
wp-includes/js/tinymce/plugins/inlinepopups/jscripts/mcwindows.js (modified) (1 diff)
-
wp-includes/js/tinymce/plugins/paste (added)
-
wp-includes/js/tinymce/plugins/paste/blank.htm (added)
-
wp-includes/js/tinymce/plugins/paste/css (added)
-
wp-includes/js/tinymce/plugins/paste/css/blank.css (added)
-
wp-includes/js/tinymce/plugins/paste/css/pasteword.css (added)
-
wp-includes/js/tinymce/plugins/paste/editor_plugin.js (added)
-
wp-includes/js/tinymce/plugins/paste/images (added)
-
wp-includes/js/tinymce/plugins/paste/images/pastetext.gif (added)
-
wp-includes/js/tinymce/plugins/paste/images/pasteword.gif (added)
-
wp-includes/js/tinymce/plugins/paste/images/selectall.gif (added)
-
wp-includes/js/tinymce/plugins/paste/jscripts (added)
-
wp-includes/js/tinymce/plugins/paste/jscripts/pastetext.js (added)
-
wp-includes/js/tinymce/plugins/paste/jscripts/pasteword.js (added)
-
wp-includes/js/tinymce/plugins/paste/langs (added)
-
wp-includes/js/tinymce/plugins/paste/langs/en.js (added)
-
wp-includes/js/tinymce/plugins/paste/pastetext.htm (added)
-
wp-includes/js/tinymce/plugins/paste/pasteword.htm (added)
-
wp-includes/js/tinymce/plugins/spellchecker (added)
-
wp-includes/js/tinymce/plugins/spellchecker/classes (added)
-
wp-includes/js/tinymce/plugins/spellchecker/classes/HttpClient.class.php (added)
-
wp-includes/js/tinymce/plugins/spellchecker/classes/TinyGoogleSpell.class.php (added)
-
wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspell.class.php (added)
-
wp-includes/js/tinymce/plugins/spellchecker/classes/TinyPspellShell.class.php (added)
-
wp-includes/js/tinymce/plugins/spellchecker/config.php (added)
-
wp-includes/js/tinymce/plugins/spellchecker/css (added)
-
wp-includes/js/tinymce/plugins/spellchecker/css/content.css (added)
-
wp-includes/js/tinymce/plugins/spellchecker/css/spellchecker.css (added)
-
wp-includes/js/tinymce/plugins/spellchecker/editor_plugin.js (added)
-
wp-includes/js/tinymce/plugins/spellchecker/images (added)
-
wp-includes/js/tinymce/plugins/spellchecker/images/spellchecker.gif (added)
-
wp-includes/js/tinymce/plugins/spellchecker/images/wline.gif (added)
-
wp-includes/js/tinymce/plugins/spellchecker/langs (added)
-
wp-includes/js/tinymce/plugins/spellchecker/langs/en.js (added)
-
wp-includes/js/tinymce/plugins/spellchecker/tinyspell.php (added)
-
wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js (modified) (3 diffs)
-
wp-includes/js/tinymce/plugins/wordpress/images/help.gif (modified) (previous)
-
wp-includes/js/tinymce/plugins/wordpress/images/toolbars.gif (added)
-
wp-includes/js/tinymce/plugins/wordpress/langs/en.js (modified) (1 diff)
-
wp-includes/js/tinymce/plugins/wordpress/popups.css (added)
-
wp-includes/js/tinymce/plugins/wordpress/wordpress.css (modified) (1 diff)
-
wp-includes/js/tinymce/themes/advanced/about.htm (modified) (2 diffs)
-
wp-includes/js/tinymce/themes/advanced/anchor.htm (modified) (1 diff)
-
wp-includes/js/tinymce/themes/advanced/charmap.htm (modified) (1 diff)
-
wp-includes/js/tinymce/themes/advanced/color_picker.htm (modified) (1 diff)
-
wp-includes/js/tinymce/themes/advanced/css/editor_content.css (modified) (2 diffs)
-
wp-includes/js/tinymce/themes/advanced/css/editor_popup.css (modified) (12 diffs)
-
wp-includes/js/tinymce/themes/advanced/css/editor_ui.css (modified) (5 diffs)
-
wp-includes/js/tinymce/themes/advanced/editor_template.js (modified) (1 diff)
-
wp-includes/js/tinymce/themes/advanced/image.htm (modified) (4 diffs)
-
wp-includes/js/tinymce/themes/advanced/images/bold_es.gif (added)
-
wp-includes/js/tinymce/themes/advanced/images/bold_tw.gif (added)
-
wp-includes/js/tinymce/themes/advanced/images/button_menu.gif (added)
-
wp-includes/js/tinymce/themes/advanced/images/buttons.gif (modified) (previous)
-
wp-includes/js/tinymce/themes/advanced/images/help.gif (added)
-
wp-includes/js/tinymce/themes/advanced/images/italic_es.gif (added)
-
wp-includes/js/tinymce/themes/advanced/images/italic_tw.gif (added)
-
wp-includes/js/tinymce/themes/advanced/images/justifycenter.gif (added)
-
wp-includes/js/tinymce/themes/advanced/images/justifyfull.gif (added)
-
wp-includes/js/tinymce/themes/advanced/images/justifyleft.gif (added)
-
wp-includes/js/tinymce/themes/advanced/images/justifyright.gif (added)
-
wp-includes/js/tinymce/themes/advanced/images/menu_check.gif (added)
-
wp-includes/js/tinymce/themes/advanced/images/opacity.png (added)
-
wp-includes/js/tinymce/themes/advanced/images/separator.gif (added)
-
wp-includes/js/tinymce/themes/advanced/images/underline_es.gif (added)
-
wp-includes/js/tinymce/themes/advanced/images/underline_tw.gif (added)
-
wp-includes/js/tinymce/themes/advanced/jscripts/about.js (modified) (3 diffs)
-
wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js (modified) (2 diffs)
-
wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js (modified) (3 diffs)
-
wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js (modified) (1 diff)
-
wp-includes/js/tinymce/themes/advanced/jscripts/image.js (modified) (3 diffs)
-
wp-includes/js/tinymce/themes/advanced/jscripts/link.js (modified) (3 diffs)
-
wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js (modified) (3 diffs)
-
wp-includes/js/tinymce/themes/advanced/langs/en.js (modified) (1 diff)
-
wp-includes/js/tinymce/themes/advanced/link.htm (modified) (4 diffs)
-
wp-includes/js/tinymce/themes/advanced/source_editor.htm (modified) (2 diffs)
-
wp-includes/js/tinymce/tiny_mce.js (modified) (18 diffs)
-
wp-includes/js/tinymce/tiny_mce_config.php (added)
-
wp-includes/js/tinymce/tiny_mce_gzip.php (modified) (1 diff)
-
wp-includes/js/tinymce/tiny_mce_popup.js (modified) (14 diffs)
-
wp-includes/js/tinymce/utils/form_utils.js (modified) (6 diffs)
-
wp-includes/js/tinymce/utils/mclayer.js (added)
-
wp-includes/js/tinymce/utils/mctabs.js (modified) (1 diff)
-
wp-includes/js/tinymce/utils/validate.js (modified) (1 diff)
-
wp-includes/js/tinymce/wp-mce-help.php (modified) (6 diffs)
-
wp-includes/js/tw-sack.js (modified) (3 diffs)
-
wp-includes/js/wp-ajax-js.php (added)
-
wp-includes/kses.php (modified) (7 diffs)
-
wp-includes/l10n.php (added)
-
wp-includes/link-template.php (added)
-
wp-includes/links.php (deleted)
-
wp-includes/locale.php (modified) (1 diff)
-
wp-includes/pluggable-functions.php (deleted)
-
wp-includes/pluggable.php (added)
-
wp-includes/plugin.php (added)
-
wp-includes/post-template.php (added)
-
wp-includes/post.php (added)
-
wp-includes/query.php (added)
-
wp-includes/registration-functions.php (deleted)
-
wp-includes/registration.php (added)
-
wp-includes/rewrite.php (added)
-
wp-includes/rss-functions.php (deleted)
-
wp-includes/rss.php (added)
-
wp-includes/script-loader.php (added)
-
wp-includes/streams.php (modified) (1 diff)
-
wp-includes/template-functions-author.php (deleted)
-
wp-includes/template-functions-category.php (deleted)
-
wp-includes/template-functions-general.php (deleted)
-
wp-includes/template-functions-links.php (deleted)
-
wp-includes/template-functions-post.php (deleted)
-
wp-includes/template-loader.php (modified) (3 diffs)
-
wp-includes/theme.php (added)
-
wp-includes/user.php (added)
-
wp-includes/vars.php (modified) (3 diffs)
-
wp-includes/version.php (modified) (1 diff)
-
wp-includes/wp-db.php (modified) (12 diffs)
-
wp-includes/wp-l10n.php (deleted)
-
wp-links-opml.php (modified) (2 diffs)
-
wp-login.php (modified) (5 diffs)
-
wp-mail.php (modified) (5 diffs)
-
wp-pass.php (modified) (1 diff)
-
wp-rdf.php (modified) (2 diffs)
-
wp-register.php (modified) (1 diff)
-
wp-rss.php (modified) (2 diffs)
-
wp-rss2.php (modified) (2 diffs)
-
wp-settings.php (modified) (14 diffs)
-
wp-trackback.php (modified) (4 diffs)
-
xmlrpc.php (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/readme.html
r3503 r4431 2 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 3 <head> 4 <title>WordPress › 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 › 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" /> 40 7 </head> 41 8 <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 45 15 <h1>First Things First</h1> 46 16 <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> 47 17 <p style="text-align: right;">— Matt Mullenweg </p> 48 18 49 <h1 id="installation">Installation: Famous 5-minute install</h1>19 <h1>Installation: Famous 5-minute install</h1> 50 20 <ol> 51 21 <li>Unzip the package in an empty directory</li> … … 69 39 <h2>Template Changes</h2> 70 40 <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 71 42 <h1>Online Resources</h1> 72 43 <p>If you have any questions that aren't addressed in this document, please take advantage of WordPress' numerous online resources:</p> 73 44 <dl> 74 45 <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> 76 47 <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> 78 49 <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> 80 51 <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> 82 53 <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> 84 55 </dl> 85 56 86 <h1 id="requirements">System Recommendations</h1>57 <h1>System Recommendations</h1> 87 58 <ul> 88 59 <li>PHP version <strong>4.1</strong> or higher</li> … … 95 66 <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> 96 67 97 <h1 id="templates">XML-RPC Interface</h1>68 <h1>XML-RPC Interface</h1> 98 69 <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> 99 70 100 71 <h1>Post via Email</h1> 101 <p>You can post from an email client! To set this up go to your "Writing" 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 "Writing" 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> 104 74 75 <h1>User Roles</h1> 105 76 <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> 106 77 -
trunk/wp-admin/admin-db.php
r3503 r4431 4 4 global $wpdb; 5 5 $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"; 7 7 $query = apply_filters('get_users_drafts', $query); 8 8 return $wpdb->get_results( $query ); … … 15 15 16 16 $editable = get_editable_user_ids( $user_id ); 17 17 18 18 if( !$editable ) { 19 19 $other_drafts = ''; 20 20 } else { 21 21 $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' "); 23 23 } 24 24 … … 35 35 } else { 36 36 $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" ); 38 38 } 39 39 … … 43 43 function get_editable_user_ids( $user_id, $exclude_zeros = true ) { 44 44 global $wpdb; 45 45 46 46 $user = new WP_User( $user_id ); 47 47 48 48 if ( ! $user->has_cap('edit_others_posts') ) { 49 49 if ( $user->has_cap('edit_posts') || $exclude_zeros == false ) … … 58 58 if ( $exclude_zeros ) 59 59 $query .= " AND meta_value != '0'"; 60 60 61 61 return $wpdb->get_col( $query ); 62 62 } … … 84 84 85 85 extract($catarr); 86 87 if( trim( $cat_name ) == '' ) 88 return 0; 86 89 87 90 $cat_ID = (int) $cat_ID; … … 93 96 $update = false; 94 97 95 $cat_name = wp_specialchars($cat_name);96 98 $cat_name = apply_filters('pre_category_name', $cat_name); 99 97 100 if (empty ($category_nicename)) 98 101 $category_nicename = sanitize_title($cat_name); 99 102 else 100 103 $category_nicename = sanitize_title($category_nicename); 104 $category_nicename = apply_filters('pre_category_nicename', $category_nicename); 101 105 102 106 if (empty ($category_description)) 103 107 $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 ) 106 112 $category_parent = 0; 107 113 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 108 124 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')"); 110 126 $cat_ID = $wpdb->insert_id; 111 127 } 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 115 131 if ( $category_nicename == '' ) { 116 132 $category_nicename = sanitize_title($cat_name, $cat_ID ); … … 154 170 155 171 // 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') ) 157 176 return 0; 158 177 … … 162 181 163 182 // 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; 165 185 166 186 // Update children to point to new parent. 167 187 $wpdb->query("UPDATE $wpdb->categories SET category_parent = '$parent' WHERE category_parent = '$cat_ID'"); 168 188 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 172 212 wp_cache_delete($cat_ID, 'category'); 173 213 wp_cache_delete('all_category_ids', 'category'); … … 194 234 195 235 if ($post_id) 196 wp_set_post_cat s('',$post_id, $cat_ids);236 wp_set_post_categories($post_id, $cat_ids); 197 237 198 238 return $cat_ids; … … 230 270 231 271 // FINALLY, delete user 272 do_action('delete_user', $id); 273 232 274 $wpdb->query("DELETE FROM $wpdb->users WHERE ID = $id"); 233 275 $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = '$id'"); … … 236 278 wp_cache_delete($user->user_login, 'userlogins'); 237 279 238 do_action('delete_user', $id);239 240 280 return true; 241 281 } 242 282 243 function get_link($link_id, $output = OBJECT) {244 global $wpdb;283 function wp_revoke_user($id) { 284 $id = (int) $id; 245 285 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(); 257 288 } 258 289 259 290 function wp_insert_link($linkdata) { 260 291 global $wpdb, $current_user; 261 292 262 293 extract($linkdata); 263 294 264 295 $update = false; 296 265 297 if ( !empty($link_id) ) 266 298 $update = true; 267 299 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 268 308 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); 270 316 271 317 if ( empty($link_target) ) 272 $link_target = ''; 318 $link_target = ''; 319 $link_target = apply_filters('pre_link_target', $link_target); 273 320 274 321 if ( empty($link_visible) ) 275 322 $link_visible = 'Y'; 276 323 $link_visibile = preg_replace('/[^YNyn]/', '', $link_visible); 324 277 325 if ( empty($link_owner) ) 278 326 $link_owner = $current_user->id; 327 else 328 $link_owner = (int) $link_owner; 279 329 280 330 if ( empty($link_notes) ) 281 331 $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 } 282 350 283 351 if ( $update ) { 284 352 $wpdb->query("UPDATE $wpdb->links SET link_url='$link_url', 285 353 link_name='$link_name', link_image='$link_image', 286 link_target='$link_target', link_category='$link_category',354 link_target='$link_target', 287 355 link_visible='$link_visible', link_description='$link_description', 288 356 link_rating='$link_rating', link_rel='$link_rel', … … 290 358 WHERE link_id='$link_id'"); 291 359 } 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')"); 293 361 $link_id = $wpdb->insert_id; 294 362 } 295 363 364 wp_set_link_cats($link_id, $link_category); 365 296 366 if ( $update ) 297 367 do_action('edit_link', $link_id); … … 306 376 307 377 $link_id = (int) $linkdata['link_id']; 308 378 309 379 $link = get_link($link_id, ARRAY_A); 310 380 311 381 // Escape data pulled from DB. 312 382 $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 314 391 // Merge old and new fields with new fields overwriting old ones. 315 392 $linkdata = array_merge($link, $linkdata); 393 $linkdata['link_category'] = $link_cats; 316 394 317 395 return wp_insert_link($linkdata); … … 322 400 323 401 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 415 function 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 431 function 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() 326 483 327 484 function post_exists($title, $content = '', $post_date = '') { -
trunk/wp-admin/admin-footer.php
r3503 r4431 1 1 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> — <a href="http://wordpress.org/support/"><?php _e('Support Forums'); ?></a> <br /> 5 <?php bloginfo('version'); ?> — <?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>'); ?> — <?php _e('<a href="http://wordpress.org/support/">Support Forums</a>'); ?><br /> 5 <?php bloginfo('version'); ?> — <?php printf(__('%s seconds'), timer_stop(0, 2)); ?></p> 8 6 </div> 9 7 <?php do_action('admin_footer', ''); ?> 10 8 <script type="text/javascript">if(typeof wpOnload=='function')wpOnload();</script> 11 12 <?php13 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 18 9 </body> 19 10 </html> -
trunk/wp-admin/admin-functions.php
r3503 r4431 1 1 <?php 2 2 3 function 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 3 11 // Creates a new post from the "Write Post" form using $_POST information. 4 function w rite_post() {12 function wp_write_post() { 5 13 global $user_ID; 6 14 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 } 9 22 10 23 // Rename. … … 16 29 if (!empty ($_POST['post_author_override'])) { 17 30 $_POST['post_author'] = (int) $_POST['post_author_override']; 18 } else 31 } else { 19 32 if (!empty ($_POST['post_author'])) { 20 33 $_POST['post_author'] = (int) $_POST['post_author']; … … 23 36 } 24 37 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 } 27 50 28 51 // What to do based on which button they pressed … … 35 58 if ('' != $_POST['advanced']) 36 59 $_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 105 function 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. 113 function 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. 155 function 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']) 41 197 $_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'; 45 218 46 219 if (!empty ($_POST['edit_date'])) { … … 59 232 } 60 233 61 // Create the post.62 $post_ID = wp_insert_post($_POST);63 add_meta($post_ID);64 65 // Reunite any orphaned attachments with their parent66 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 hrefs70 fix_attachment_links($post_ID);71 72 return $post_ID;73 }74 75 // Move child posts to a new parent76 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" links92 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 } else139 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 pressed149 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 187 234 // Meta Stuff 188 235 if ($_POST['meta']) { … … 190 237 update_meta($key, $value['key'], $value['value']); 191 238 } 192 239 193 240 if ($_POST['deletemeta']) { 194 241 foreach ($_POST['deletemeta'] as $key => $value) … … 213 260 214 261 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.')); 216 263 217 264 $_POST['comment_author'] = $_POST['newcomment_author']; … … 241 288 // Get an existing post and format it for editing. 242 289 function get_post_to_edit($id) { 243 global $richedit;244 $richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false;245 290 246 291 $post = get_post($id); 247 292 248 $post->post_content = format_to_edit($post->post_content, $richedit);293 $post->post_content = format_to_edit($post->post_content, user_can_richedit()); 249 294 $post->post_content = apply_filters('content_edit_pre', $post->post_content); 250 295 … … 255 300 $post->post_title = apply_filters('title_edit_pre', $post->post_title); 256 301 257 if ($post->post_status == 'static') 302 $post->post_password = format_to_edit($post->post_password); 303 304 if ($post->post_type == 'page') 258 305 $post->page_template = get_post_meta($id, '_wp_page_template', true); 259 306 … … 287 334 288 335 $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'); 293 340 $post->post_content = apply_filters('default_content', $post_content); 294 341 $post->post_title = apply_filters('default_title', $post_title); … … 302 349 303 350 function get_comment_to_edit($id) { 304 global $richedit;305 $richedit = ( 'true' == get_user_option('rich_editing') ) ? true : false;306 307 351 $comment = get_comment($id); 308 352 309 $comment->comment_content = format_to_edit($comment->comment_content, $richedit);353 $comment->comment_content = format_to_edit($comment->comment_content, user_can_richedit()); 310 354 $comment->comment_content = apply_filters('comment_edit_pre', $comment->comment_content); 311 355 … … 323 367 } 324 368 369 function 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 381 function 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 325 398 // Creates a new user from the "Users" form using $_POST information. 326 399 327 400 function 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 } 329 415 } 330 416 331 417 function edit_user($user_id = 0) { 332 418 global $current_user, $wp_roles, $wpdb; 333 334 419 if ($user_id != 0) { 335 420 $update = true; … … 351 436 $pass2 = $_POST['pass2']; 352 437 353 if (isset ($_POST['role']) ) {438 if (isset ($_POST['role']) && current_user_can('edit_users')) { 354 439 if($user_id != $current_user->id || $wp_roles->role_objects[$_POST['role']]->has_cap('edit_users')) 355 440 $user->role = $_POST['role']; … … 371 456 $user->display_name = wp_specialchars(trim($_POST['display_name'])); 372 457 if (isset ($_POST['description'])) 373 $user->description = wp_specialchars(trim($_POST['description']));458 $user->description = trim($_POST['description']); 374 459 if (isset ($_POST['jabber'])) 375 460 $user->jabber = wp_specialchars(trim($_POST['jabber'])); … … 379 464 $user->yim = wp_specialchars(trim($_POST['yim'])); 380 465 381 $errors = array();466 $errors = new WP_Error(); 382 467 383 468 /* checking that username has been typed */ 384 469 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.')); 386 471 387 472 /* 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)); 389 474 390 475 if (!$update) { 391 476 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.')); 393 478 } else { 394 479 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.")); 396 481 } 397 482 398 483 /* Check for "\" in password */ 399 484 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 "\\".')); 401 486 402 487 /* checking the password has been typed twice the same */ 403 488 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.')); 405 490 406 491 if (!empty ($pass1)) … … 408 493 409 494 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.')); 411 496 412 497 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.')); 414 499 415 500 /* checking e-mail address */ 416 501 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")); 418 503 } else 419 504 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() ) 424 509 return $errors; 425 510 … … 430 515 wp_new_user_notification($user_id); 431 516 } 432 433 return $errors; 517 return $user_id; 434 518 } 435 519 … … 437 521 function get_link_to_edit($link_id) { 438 522 $link = get_link($link_id); 439 523 440 524 $link->link_url = wp_specialchars($link->link_url, 1); 441 525 $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); 443 528 $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 446 533 return $link; 447 534 } … … 452 539 else 453 540 $link->link_url = ''; 454 541 455 542 if ( isset($_GET['name']) ) 456 543 $link->link_name = wp_specialchars($_GET['name'], 1); 457 544 else 458 545 $link->link_name = ''; 459 546 547 $link->link_visible = 'Y'; 548 460 549 return $link; 461 550 } 462 551 463 552 function add_link() { 464 return edit_link(); 553 return edit_link(); 465 554 } 466 555 467 556 function edit_link($link_id = '') { 468 557 if (!current_user_can('manage_links')) 469 die(__("Cheatin' uh ?"));558 wp_die(__("Cheatin' uh ?")); 470 559 471 560 $_POST['link_url'] = wp_specialchars($_POST['link_url']); … … 474 563 $_POST['link_image'] = wp_specialchars($_POST['link_image']); 475 564 $_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']; 484 566 485 567 if ( !empty($link_id) ) { … … 513 595 function return_categories_list($parent = 0) { 514 596 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"); 516 598 } 517 599 … … 521 603 522 604 function get_nested_categories($default = 0, $parent = 0) { 523 global $post_ID, $ mode, $wpdb;605 global $post_ID, $link_id, $mode, $wpdb; 524 606 525 607 if ($post_ID) { … … 534 616 $checked_categories[] = $default; 535 617 } 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 } 537 629 } else { 538 630 $checked_categories[] = $default; … … 550 642 } 551 643 } 552 644 553 645 usort($result, 'sort_cats'); 554 646 … … 558 650 function write_nested_categories($categories) { 559 651 foreach ($categories as $category) { 560 echo '<l abel 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"; 564 656 write_nested_categories($category['children']); 565 echo "</ span>\n";657 echo "</ul>\n"; 566 658 } 567 659 } … … 572 664 } 573 665 666 function 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 671 function 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 706 function dropdown_link_categories($default = 0) { 707 write_nested_categories(get_nested_link_categories($default)); 708 } 709 574 710 // Dandy new recursive multiple category stuff. 575 711 function cat_rows($parent = 0, $level = 0, $categories = 0) { 576 global $wpdb, $class;577 578 712 if (!$categories) 579 $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name");713 $categories = get_categories('hide_empty=0'); 580 714 581 715 if ($categories) { 582 716 foreach ($categories as $category) { 583 717 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('— ', $level); 587 if ( current_user_can('manage_categories') ) { 588 $edit = "<a href='categories.php?action=edit&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&cat_ID=$category->cat_ID' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '".sprintf(__("You are about to delete the category "%s". All of its posts will go to the default category.\\n"OK" to delete, "Cancel" 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 ); 605 719 cat_rows($category->cat_ID, $level +1, $categories); 606 720 } … … 611 725 } 612 726 613 function page_rows($parent = 0, $level = 0, $pages = 0) { 727 function _cat_row( $category, $level, $name_override = false ) { 728 global $class; 729 730 $pad = str_repeat('— ', $level); 731 if ( current_user_can('manage_categories') ) { 732 $edit = "<a href='categories.php?action=edit&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&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 "%s".\\nAll of its posts will go into the default category of "%s"\\nAll of its bookmarks will go into the default category of "%s".\\n"OK" to delete, "Cancel" 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 756 function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) { 614 757 global $wpdb, $class, $post; 758 615 759 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('— ', $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('— ', $level); 772 $id = $post->ID; 773 $class = ('alternate' == $class) ? '' : 'alternate'; 626 774 ?> 627 775 <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> 629 777 <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>'); ?> 631 780 </td> 632 781 <td><?php the_author() ?></td> 633 782 <td><?php echo mysql2date('Y-m-d g:i a', $post->post_modified); ?></td> 634 783 <td><a href="<?php the_permalink(); ?>" rel="permalink" class="edit"><?php _e('View'); ?></a></td> 635 <td><?php if ( current_user_can('edit_page s') ) { echo "<a href='post.php?action=edit&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td>636 <td><?php if ( current_user_can(' edit_pages') ) { echo "<a href='post.php?action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" 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&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&post=$id", 'delete-page_' . $id) . "' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), js_escape(get_the_title()) ) . "' );\">" . __('Delete') . "</a>"; } ?></td> 637 786 </tr> 638 787 639 788 <?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 793 function 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; 647 822 } 648 823 649 824 function 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 654 829 if ($categories) { 655 830 foreach ($categories as $category) { 656 831 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");658 832 $pad = str_repeat('– ', $level); 659 833 $category->cat_name = wp_specialchars($category->cat_name); … … 668 842 return false; 669 843 } 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";687 844 } 688 845 … … 777 934 return $error; 778 935 } else { 936 apply_filters( 'wp_create_thumbnail', $thumbpath ); 779 937 return $thumbpath; 780 938 } … … 796 954 global $post_ID; 797 955 // Exit if no meta 798 if (!$meta) 956 if (!$meta) { 957 echo '<tbody id="the-list"><tr style="display: none;"><td> </td></tr></tbody>'; //TBODY needed for list-manipulation JS 799 958 return; 959 } 800 960 $count = 0; 801 961 ?> 802 <table id='meta-list' cellpadding="3">962 <thead> 803 963 <tr> 804 964 <th><?php _e('Key') ?></th> … … 806 966 <th colspan='2'><?php _e('Action') ?></th> 807 967 </tr> 968 </thead> 808 969 <?php 809 810 970 $r ="\n\t<tbody id='the-list'>"; 811 971 foreach ($meta as $entry) { 812 972 ++ $count; … … 817 977 if ('_' == $entry['meta_key'] { 0 }) 818 978 $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 "%s" custom field on this post.\\n"OK" to delete, "Cancel" 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>"; 831 1005 } 832 1006 … … 846 1020 function meta_form() { 847 1021 global $wpdb; 1022 $limit = (int) apply_filters('postmeta_form_limit', 30); 848 1023 $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); 854 1030 ?> 855 1031 <h3><?php _e('Add a new custom field:') ?></h3> 856 <table cellspacing="3" cellpadding="3">1032 <table id="newmeta" cellspacing="3" cellpadding="3"> 857 1033 <tr> 858 1034 <th colspan="2"><?php _e('Key') ?></th> … … 861 1037 <tr valign="top"> 862 1038 <td align="right" width="18%"> 863 <?php if ( $keys) : ?>1039 <?php if ( $keys ) : ?> 864 1040 <select id="metakeyselect" name="metakeyselect" tabindex="7"> 865 1041 <option value="#NONE#"><?php _e('- Select -'); ?></option> 866 1042 <?php 867 1043 868 foreach ($keys as $key) { 1044 foreach ( $keys as $key ) { 1045 $key = wp_specialchars($key, 1); 869 1046 echo "\n\t<option value='$key'>$key</option>"; 870 1047 } … … 878 1055 879 1056 </table> 880 <p class="submit"><input type="submit" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field »') ?>" /></p>1057 <p class="submit"><input type="submit" id="updatemetasub" name="updatemeta" tabindex="9" value="<?php _e('Add Custom Field »') ?>" /></p> 881 1058 <?php 882 1059 … … 885 1062 function add_meta($post_ID) { 886 1063 global $wpdb; 1064 $post_ID = (int) $post_ID; 887 1065 888 1066 $metakeyselect = $wpdb->escape(stripslashes(trim($_POST['metakeyselect']))); 889 1067 $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); 891 1070 892 1071 if ( ('0' === $metavalue || !empty ($metavalue)) && ((('#NONE#' != $metakeyselect) && !empty ($metakeyselect)) || !empty ($metakeyinput)) ) { … … 894 1073 // input for the key have data, the input takes precedence: 895 1074 896 if ('#NONE#' != $metakeyselect)1075 if ('#NONE#' != $metakeyselect) 897 1076 $metakey = $metakeyselect; 898 1077 … … 905 1084 VALUES ('$post_ID','$metakey','$metavalue') 906 1085 "); 907 } 1086 return $wpdb->insert_id; 1087 } 1088 return false; 908 1089 } // add_meta 909 1090 910 1091 function delete_meta($mid) { 911 1092 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'"); 914 1096 } 915 1097 916 1098 function update_meta($mid, $mkey, $mvalue) { 917 1099 global $wpdb; 918 1100 $mvalue = maybe_serialize(stripslashes($mvalue)); 1101 $mvalue = $wpdb->escape($mvalue); 1102 $mid = (int) $mid; 919 1103 return $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '$mkey', meta_value = '$mvalue' WHERE meta_id = '$mid'"); 920 1104 } 921 1105 1106 function 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 922 1116 function touch_time($edit = 1, $for_post = 1) { 923 global $ month, $post, $comment;1117 global $wp_locale, $post, $comment; 924 1118 925 1119 if ( $for_post ) … … 928 1122 echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__('Edit timestamp').'</label></legend>'; 929 1123 930 $time_adj = time() + (get_ settings('gmt_offset') * 3600);1124 $time_adj = time() + (get_option('gmt_offset') * 3600); 931 1125 $post_date = ($for_post) ? $post->post_date : $comment->comment_date; 932 1126 $jj = ($edit) ? mysql2date('d', $post_date) : gmdate('d', $time_adj); … … 937 1131 $ss = ($edit) ? mysql2date('s', $post_date) : gmdate('s', $time_adj); 938 1132 939 echo "<select name=\"mm\" >\n";1133 echo "<select name=\"mm\" onchange=\"edit_date.checked=true\">\n"; 940 1134 for ($i = 1; $i < 13; $i = $i +1) { 941 1135 echo "\t\t\t<option value=\"$i\""; 942 1136 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"; 950 1139 } 951 1140 ?> 952 1141 </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" /> 958 1147 <?php 959 1148 if ( $edit ) { 960 1149 _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); 962 1152 } 963 1153 ?> … … 984 1174 if ($markerdata) { 985 1175 $state = true; 986 foreach ($markerdata as $ markerline) {1176 foreach ($markerdata as $n => $markerline) { 987 1177 if (strstr($markerline, "# BEGIN {$marker}")) 988 1178 $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 } 991 1185 if (strstr($markerline, "# END {$marker}")) { 992 1186 fwrite($f, "# BEGIN {$marker}\n"); … … 1071 1265 } 1072 1266 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 WP1075 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 support1086 if (document.selection) {1087 myField.focus();1088 sel = document.selection.createRange();1089 sel.text = myValue;1090 myField.focus();1091 }1092 //MOZILLA/NETSCAPE support1093 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 + myValue1098 + 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 1135 1267 function get_broken_themes() { 1136 1268 global $wp_broken_themes; … … 1177 1309 function parent_dropdown($default = 0, $parent = 0, $level = 0) { 1178 1310 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"); 1180 1312 1181 1313 if ($items) { … … 1205 1337 global $menu; 1206 1338 global $submenu; 1339 global $_wp_menu_nopriv; 1340 global $_wp_submenu_nopriv; 1341 global $plugin_page; 1207 1342 1208 1343 $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]) ) 1214 1364 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; 1219 1369 } 1220 1370 … … 1222 1372 foreach ($submenu[$parent] as $submenu_array) { 1223 1373 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 1225 1377 return false; 1226 } else {1227 return true;1228 }1229 1378 } 1230 1379 } 1231 1380 } 1232 1381 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 1233 1391 return true; 1234 1392 } … … 1287 1445 global $pagenow; 1288 1446 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 1291 1455 return $parent_file; 1292 1456 } … … 1296 1460 if ($parent_menu[2] == $plugin_page) { 1297 1461 $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; 1299 1465 } 1300 1466 } 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; 1301 1480 } 1302 1481 1303 1482 foreach (array_keys($submenu) as $parent) { 1304 1483 foreach ($submenu[$parent] as $submenu_array) { 1484 if ( isset($_wp_real_parent_file[$parent]) ) 1485 $parent = $_wp_real_parent_file[$parent]; 1305 1486 if ($submenu_array[2] == $pagenow) { 1306 1487 $parent_file = $parent; … … 1337 1518 global $submenu; 1338 1519 global $menu; 1520 global $_wp_real_parent_file; 1521 global $_wp_submenu_nopriv; 1522 global $_wp_menu_nopriv; 1523 1524 $file = plugin_basename($file); 1339 1525 1340 1526 $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 } 1342 1534 1343 1535 // If the parent doesn't already have a submenu, add a link to the parent … … 1345 1537 // parent file someone is trying to link back to the parent manually. In 1346 1538 // 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 ) { 1348 1540 foreach ($menu as $parent_menu) { 1349 if ( $parent_menu[2] == $parent) {1541 if ( $parent_menu[2] == $parent && current_user_can($parent_menu[1]) ) { 1350 1542 $submenu[$parent][] = $parent_menu; 1351 1543 } … … 1397 1589 switch ($code) { 1398 1590 case 1 : 1399 die(__('Sorry, can’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’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.')); 1400 1592 1401 1593 case 2 : 1402 die(__('Sorry, can’t call files with their real path.'));1594 wp_die(__('Sorry, can’t call files with their real path.')); 1403 1595 1404 1596 case 3 : 1405 die(__('Sorry, that file cannot be edited.'));1597 wp_die(__('Sorry, that file cannot be edited.')); 1406 1598 } 1407 1599 } 1408 1600 1409 1601 function 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')) { 1412 1604 $home_path = parse_url($home); 1413 1605 $home_path = $home_path['path']; … … 1441 1633 return $wp_file_descriptions[basename($file)]; 1442 1634 } 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 )); 1445 1637 if (preg_match("|Template Name:(.*)|i", $template_data, $name)) 1446 1638 return $name[1]; … … 1473 1665 preg_match("|Author URI:(.*)|i", $plugin_data, $author_uri); 1474 1666 if (preg_match("|Version:(.*)|i", $plugin_data, $version)) 1475 $version = $version[1];1667 $version = trim($version[1]); 1476 1668 else 1477 1669 $version = ''; 1478 1670 1479 $description = wptexturize( $description[1]);1671 $description = wptexturize(trim($description[1])); 1480 1672 1481 1673 $name = $plugin_name[1]; … … 1483 1675 $plugin = $name; 1484 1676 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>'; 1486 1678 } 1487 1679 1488 1680 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>'; 1492 1684 } 1493 1685 … … 1503 1695 1504 1696 $wp_plugins = array (); 1505 $plugin_loc = 'wp-content/plugins'; 1506 $plugin_root = ABSPATH.$plugin_loc; 1697 $plugin_root = ABSPATH . PLUGINDIR; 1507 1698 1508 1699 // Files in wp-content/plugins directory … … 1529 1720 } 1530 1721 1531 if ( !$plugins_dir || !$plugin_files) {1722 if ( !$plugins_dir || !$plugin_files ) 1532 1723 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") ) 1539 1727 continue; 1540 1728 1541 1729 $plugin_data = get_plugin_data("$plugin_root/$plugin_file"); 1542 1730 1543 if ( empty ($plugin_data['Name'])) {1731 if ( empty ($plugin_data['Name']) ) 1544 1732 continue; 1545 }1546 1733 1547 1734 $wp_plugins[plugin_basename($plugin_file)] = $plugin_data; 1548 1735 } 1736 1737 uasort($wp_plugins, create_function('$a, $b', 'return strnatcasecmp($a["Name"], $b["Name"]);')); 1549 1738 1550 1739 return $wp_plugins; … … 1655 1844 __("Failed to write file to disk.")); 1656 1845 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 1696 1846 // All tests are on by default. Most can be turned off by $override[{test_name}] = false; 1697 1847 $test_form = true; … … 1721 1871 return $upload_error_handler($file, __('Specified file failed upload test.')); 1722 1872 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. 1724 1874 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); 1734 1878 1735 1879 if ( !$type || !$ext ) … … 1758 1902 $filename = str_replace("$number$ext", ++$number . $ext, $filename); 1759 1903 } 1904 $filename = str_replace($ext, '', $filename); 1905 $filename = sanitize_title_with_dashes($filename) . $ext; 1760 1906 } 1761 1907 … … 1763 1909 $new_file = $uploads['path'] . "/$filename"; 1764 1910 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'])); 1766 1912 1767 1913 // Set correct file permissions … … 1772 1918 // Compute the URL 1773 1919 $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; 1776 1924 } 1777 1925 … … 1790 1938 1791 1939 function 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; 1792 1948 ?> 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" /> 1803 1953 <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'); ?> »" /> 1958 </p> 1808 1959 </form> 1809 <?php 1960 <?php 1810 1961 } 1811 1962 … … 1818 1969 1819 1970 $url = $file['url']; 1820 $file = $file['file'];1971 $file = addslashes( $file['file'] ); 1821 1972 $filename = basename($file); 1822 1973 … … 1835 1986 } 1836 1987 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 guess1845 }1846 1847 1988 function the_attachment_links($id = false) { 1848 1989 $id = (int) $id; 1849 1990 $post = & get_post($id); 1850 1991 1851 if ( $post->post_ status!= 'attachment' )1992 if ( $post->post_type != 'attachment' ) 1852 1993 return false; 1853 1994 1854 1995 $icon = get_attachment_icon($post->ID); 1855 1996 $attachment_data = get_post_meta( $id, '_wp_attachment_metadata', true ); 1997 $thumb = isset($attachment_data['thumb']); 1856 1998 ?> 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> 1861 2007 <?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> 1866 2025 <?php endif; ?> 2026 </table> 2027 </form> 1867 2028 <?php 1868 2029 } … … 1877 2038 } 1878 2039 2040 function 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. 2059 function 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 2073 add_action('update_option_home', 'update_home_siteurl', 10, 2); 2074 add_action('update_option_siteurl', 'update_home_siteurl', 10, 2); 2075 2076 function 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 2106 function 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 1879 2123 ?> -
trunk/wp-admin/admin-header.php
r3503 r4431 1 <?php 1 <?php 2 2 @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); 3 3 if (!isset($_GET["page"])) require_once('admin.php'); 4 4 if ( $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' ); 7 10 } 8 if ( $list_js || $cat_js ) 9 $sack_js = true; 11 12 get_admin_page_title(); 13 10 14 ?> 11 <?php get_admin_page_title(); ?>12 15 <!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(); ?>> 14 17 <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'); ?>" /> 16 19 <title><?php bloginfo('name') ?> › <?php echo $title; ?> — 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; ?> 18 24 <script type="text/javascript"> 19 25 //<![CDATA[ … … 21 27 //]]> 22 28 </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 } ?>54 29 <?php if ( ($parent_file != 'link-manager.php') && ($parent_file != 'options-general.php') ) : ?> 55 30 <style type="text/css">* html { overflow-x: hidden; }</style> 56 <?php endif; ?> 57 <?php do_action('admin_head'); ?> 31 <?php endif; 32 if ( isset($page_hook) ) 33 do_action('admin_print_scripts-' . $page_hook); 34 else if ( isset($plugin_page) ) 35 do_action('admin_print_scripts-' . $plugin_page); 36 do_action('admin_print_scripts'); 37 38 if ( isset($page_hook) ) 39 do_action('admin_head-' . $page_hook); 40 else if ( isset($plugin_page) ) 41 do_action('admin_head-' . $plugin_page); 42 do_action('admin_head'); 43 ?> 58 44 </head> 59 45 <body> 60 46 <div id="wphead"> 61 <h1><?php echo wptexturize(get_ settings(('blogname'))); ?> <span>(<a href="<?php echo get_settings('home') . '/'; ?>"><?php _e('View site') ?> »</a>)</span></h1>47 <h1><?php echo wptexturize(get_option(('blogname'))); ?> <span>(<a href="<?php echo get_option('home') . '/'; ?>"><?php _e('View site »') ?></a>)</span></h1> 62 48 </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> 64 50 65 51 <?php -
trunk/wp-admin/admin.php
r3503 r4431 6 6 7 7 if ( 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')); 9 9 10 10 require_once(ABSPATH . 'wp-admin/admin-functions.php'); 11 11 require_once(ABSPATH . 'wp-admin/admin-db.php'); 12 require_once(ABSPATH . WPINC . '/registration -functions.php');12 require_once(ABSPATH . WPINC . '/registration.php'); 13 13 14 14 auth_redirect(); … … 18 18 update_category_cache(); 19 19 20 get_currentuserinfo();20 wp_get_current_user(); 21 21 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'); 26 26 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 } 27 wp_reset_vars(array('profile', 'redirect', 'redirect_url', 'a', 'popuptitle', 'popupurl', 'text', 'trackback', 'pingback')); 28 29 wp_enqueue_script( 'fat' ); 30 31 $editing = false; 32 33 if (isset($_GET['page'])) { 34 $plugin_page = stripslashes($_GET['page']); 35 $plugin_page = plugin_basename($plugin_page); 41 36 } 42 43 $xfn_js = $sack_js = $list_js = $cat_js = $dbx_js = $editing = false;44 37 45 38 require(ABSPATH . '/wp-admin/menu.php'); 46 39 47 40 // Handle plugin admin pages. 48 if (isset($_GET['page'])) { 49 $plugin_page = stripslashes($_GET['page']); 50 $plugin_page = plugin_basename($plugin_page); 41 if (isset($plugin_page)) { 51 42 $page_hook = get_plugin_page_hook($plugin_page, $pagenow); 52 43 53 44 if ( $page_hook ) { 45 do_action('load-' . $page_hook); 54 46 if (! isset($_GET['noheader'])) 55 47 require_once(ABSPATH . '/wp-admin/admin-header.php'); 56 48 57 49 do_action($page_hook); 58 50 } else { 59 51 if ( validate_file($plugin_page) ) { 60 die(__('Invalid plugin page'));52 wp_die(__('Invalid plugin page')); 61 53 } 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); 65 59 66 60 if (! isset($_GET['noheader'])) 67 61 require_once(ABSPATH . '/wp-admin/admin-header.php'); 68 69 include(ABSPATH . "wp-content/plugins/$plugin_page");62 63 include(ABSPATH . PLUGINDIR . "/$plugin_page"); 70 64 } 71 65 72 66 include(ABSPATH . 'wp-admin/admin-footer.php'); 73 67 74 68 exit(); 75 69 } else if (isset($_GET['import'])) { 76 70 77 71 $importer = $_GET['import']; 78 72 73 if ( ! current_user_can('import') ) 74 wp_die(__('You are not allowed to import.')); 75 79 76 if ( validate_file($importer) ) { 80 die(__('Invalid importer.'));77 wp_die(__('Invalid importer.')); 81 78 } 82 79 83 80 if (! file_exists(ABSPATH . "wp-admin/import/$importer.php")) 84 die(__('Cannot load importer.'));85 81 wp_die(__('Cannot load importer.')); 82 86 83 include(ABSPATH . "wp-admin/import/$importer.php"); 87 84 88 $parent_file = 'import.php'; 85 $parent_file = 'edit.php'; 86 $submenu_file = 'import.php'; 89 87 $title = __('Import'); 90 88 91 89 if (! isset($_GET['noheader'])) 92 90 require_once(ABSPATH . 'wp-admin/admin-header.php'); … … 98 96 99 97 call_user_func($wp_importers[$importer][2]); 100 98 101 99 include(ABSPATH . 'wp-admin/admin-footer.php'); 102 100 103 101 exit(); 102 } else { 103 do_action("load-$pagenow"); 104 104 } 105 105 -
trunk/wp-admin/bookmarklet.php
r3503 r4431 4 4 5 5 if ( ! current_user_can('edit_posts') ) 6 die ("Cheatin' uh?");6 wp_die(__('Cheatin’ uh?')); 7 7 8 8 if ('b' == $a): … … 26 26 $popuptitle = wp_specialchars(stripslashes($popuptitle)); 27 27 $text = wp_specialchars(stripslashes(urldecode($text))); 28 28 29 29 $popuptitle = funky_javascript_fix($popuptitle); 30 30 $text = funky_javascript_fix($text); 31 31 32 32 $post_title = wp_specialchars($_REQUEST['post_title']); 33 33 if (!empty($post_title)) … … 35 35 else 36 36 $post->post_title = $popuptitle; 37 37 38 38 39 39 $content = wp_specialchars($_REQUEST['content']); … … 51 51 <head> 52 52 <title><?php bloginfo('name') ?> › Bookmarklet — 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'); ?>" /> 54 54 <link rel="stylesheet" href="wp-admin.css" type="text/css" /> 55 55 -
trunk/wp-admin/cat-js.php
r3503 r4431 1 1 <?php 2 require_once(' admin.php');3 header('Content-type: text/javascript; charset=' . get_settings('blog_charset'), true);2 require_once('../wp-config.php'); 3 cache_javascript_headers(); 4 4 ?> 5 var ajaxCat = new sack(); 6 var newcat; 7 5 addLoadEvent(function(){catList=new listMan('categorychecklist');catList.ajaxRespEl='jaxcat';catList.topAdder=1;catList.alt=0;catList.showLink=0;}); 6 addLoadEvent(newCatAddIn); 8 7 function 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'); }; 36 14 } 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'); // trim167 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 4 4 $title = __('Categories'); 5 5 $parent_file = 'edit.php'; 6 $list_js = true;7 6 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 } 7 wp_reset_vars(array('action', 'cat')); 23 8 24 9 switch($action) { … … 26 11 case 'addcat': 27 12 13 check_admin_referer('add-category'); 14 28 15 if ( !current_user_can('manage_categories') ) 29 die (__('Cheatin’ uh?')); 30 31 wp_insert_category($_POST); 16 wp_die(__('Cheatin’ uh?')); 32 17 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 } 34 23 break; 35 24 36 25 case 'delete': 37 38 check_admin_referer( );26 $cat_ID = (int) $_GET['cat_ID']; 27 check_admin_referer('delete-category_' . $cat_ID); 39 28 40 29 if ( !current_user_can('manage_categories') ) 41 die(__('Cheatin’ uh?'));30 wp_die(__('Cheatin’ uh?')); 42 31 43 $cat_ID = (int) $_GET['cat_ID'];44 32 $cat_name = get_catname($cat_ID); 45 33 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)); 48 40 49 41 wp_delete_category($cat_ID); 50 42 51 header('Location:categories.php?message=2');43 wp_redirect('categories.php?message=2'); 52 44 53 45 break; … … 58 50 $cat_ID = (int) $_GET['cat_ID']; 59 51 $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') ?> »" /></p> 89 </form> 90 <p><a href="categories.php"><?php _e('« Return to category list'); ?></a></p> 91 </div> 92 <?php 52 include('edit-category-form.php'); 93 53 94 54 break; 95 55 96 56 case 'editedcat': 57 $cat_ID = (int) $_POST['cat_ID']; 58 check_admin_referer('update-category_' . $cat_ID); 59 97 60 if ( !current_user_can('manage_categories') ) 98 die(__('Cheatin’ uh?'));99 61 wp_die(__('Cheatin’ uh?')); 62 100 63 wp_update_category($_POST); 101 64 102 header('Location:categories.php?message=3');65 wp_redirect('categories.php?message=3'); 103 66 break; 104 67 105 68 default: 106 69 70 wp_enqueue_script( 'admin-categories' ); 107 71 require_once ('admin-header.php'); 108 72 … … 110 74 $messages[2] = __('Category deleted.'); 111 75 $messages[3] = __('Category updated.'); 76 $messages[4] = __('Category not added.'); 112 77 ?> 113 78 … … 122 87 <h2><?php _e('Categories') ?> </h2> 123 88 <?php endif; ?> 124 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3"> 89 <table class="widefat"> 90 <thead> 125 91 <tr> 126 <th scope="col" ><?php _e('ID') ?></th>92 <th scope="col" style="text-align: center"><?php _e('ID') ?></th> 127 93 <th scope="col"><?php _e('Name') ?></th> 128 94 <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> 131 98 </tr> 99 </thead> 100 <tbody id="the-list"> 132 101 <?php 133 102 cat_rows(); 134 103 ?> 104 </tbody> 135 105 </table> 136 137 <div id="ajax-response"></div>138 106 139 107 </div> … … 141 109 <?php if ( current_user_can('manage_categories') ) : ?> 142 110 <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> 144 112 </div> 145 113 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 »') ?>" /></p> 160 </form> 161 </div> 114 <?php include('edit-category-form.php'); ?> 162 115 <?php endif; ?> 163 116 … … 167 120 168 121 include('admin-footer.php'); 122 169 123 ?> -
trunk/wp-admin/edit-comments.php
r3503 r4431 4 4 $title = __('Edit Comments'); 5 5 $parent_file = 'edit.php'; 6 $list_js = true;6 wp_enqueue_script( 'admin-comments' ); 7 7 8 8 require_once('admin-header.php'); … … 24 24 } 25 25 } 26 27 function 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 } 26 38 //--> 27 39 </script> 28 40 <div class="wrap"> 29 41 <h2><?php _e('Comments'); ?></h2> 30 <form name="searchform" action="" method="get" >42 <form name="searchform" action="" method="get" id="editcomments"> 31 43 <fieldset> 32 44 <legend><?php _e('Show Comments That Contain...') ?></legend> … … 34 46 <input type="submit" name="submit" value="<?php _e('Search') ?>" /> 35 47 <input type="hidden" name="mode" value="<?php echo $mode; ?>" /> 36 <?php _e('(Searches within comment text, e-mail, UR I, and IP address.)') ?>48 <?php _e('(Searches within comment text, e-mail, URL, and IP address.)') ?> 37 49 </fieldset> 38 50 </form> … … 40 52 <?php 41 53 if ( !empty( $_POST['delete_comments'] ) ) : 54 check_admin_referer('bulk-comments'); 55 42 56 $i = 0; 43 57 foreach ($_POST['delete_comments'] as $comment) : // Check the permissions on each 44 58 $comment = (int) $comment; 45 59 $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'); 49 66 ++$i; 50 endif;67 } 51 68 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>'; 53 75 endif; 54 76 … … 78 100 $start = ''; 79 101 80 echo "<ol id='the- list' class='commentlist' $start>";102 echo "<ol id='the-comment-list' class='commentlist' $start>"; 81 103 $i = 0; 82 104 foreach ($comments as $comment) { … … 89 111 $class .= ' alternate'; 90 112 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&comment=".$comment->comment_ID."\">" . __('Edit Comment') . "</a>"; 99 echo " | <a href=\"post.php?action=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" to delete."), wp_specialchars( $comment->comment_author, 1 )) . "' );\">" . __('Delete Comment') . "</a> — "; 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&post=<?php echo $comment->comment_post_ID; ?>"><?php printf(__('Edit Post “%s”'), 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'); ?> — [ 119 <?php 120 if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 121 echo " <a href='comment.php?action=editcomment&comment=".$comment->comment_ID."'>" . __('Edit') . '</a>'; 122 echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&p=' . $comment->comment_post_ID . '&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 "%s".\\n"Cancel" to stop, "OK" 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&p=' . $comment->comment_post_ID . '&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&p=' . $comment->comment_post_ID . '&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&delete_type=spam&p=" . $comment->comment_post_ID . "&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 "%s".\\n"Cancel" to stop, "OK" 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> 108 134 </li> 109 135 110 <?php } // end foreach ?>136 <?php } // end foreach($comment) ?> 111 137 </ol> 112 138 … … 114 140 115 141 <?php 116 } else { 142 } else { //no comments to show 117 143 118 144 ?> 119 145 <p> 120 146 <strong><?php _e('No comments found.') ?></strong></p> 121 147 122 148 <?php 123 149 } // end if ($comments) … … 125 151 126 152 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> 129 157 <tr> 130 <th scope="col" >*</th>158 <th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById(\'deletecomments\'));" /></th> 131 159 <th scope="col">' . __('Name') . '</th> 132 160 <th scope="col">' . __('E-mail') . '</th> 133 161 <th scope="col">' . __('IP') . '</th> 134 162 <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>'; 137 166 foreach ($comments as $comment) { 138 167 $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); 139 169 $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; ?>'> 142 173 <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> 143 174 <td><?php comment_author_link() ?></td> … … 145 176 <td><a href="http://ws.arin.net/cgi-bin/whois.pl?queryinput=<?php comment_author_IP() ?>"><?php comment_author_IP() ?></a></td> 146 177 <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> 148 185 <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 149 echo "<a href=' post.php?action=editcomment&comment=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td>186 echo "<a href='comment.php?action=editcomment&comment=$comment->comment_ID' class='edit'>" . __('Edit') . "</a>"; } ?></td> 150 187 <td><?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 151 echo "<a href=\"post.php?action=deletecomment&p=".$comment->comment_post_ID."&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&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" to delete."), js_escape( $comment->comment_author )) . "', theCommentList );\" class='delete'>" . __('Delete') . "</a> "; 189 } ?></td> 152 190 </tr> 153 191 <?php 154 192 } // end foreach 155 193 ?></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') ?> »" 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 »') ?>" 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 »') ?>" onclick="return confirm('<?php _e("You are about to mark these comments as spam \\n \'Cancel\' to stop, \'OK\' to mark as spam.") ?>')" /></p> 158 196 </form> 197 <div id="ajax-response"></div> 159 198 <?php 160 199 } else { -
trunk/wp-admin/edit-form-advanced.php
r3503 r4431 15 15 16 16 <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 ↓'); ?></a></small><?php endif; ?></h2>19 17 <?php 20 18 … … 22 20 $form_action = 'post'; 23 21 $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'); 25 24 } else { 26 25 $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); 28 28 } 29 29 … … 38 38 $already_pinged = explode("\n", trim($post->pinged)); 39 39 foreach ($already_pinged as $pinged_url) { 40 $pings .= "\n\t<li> $pinged_url</li>";40 $pings .= "\n\t<li>" . wp_specialchars($pinged_url) . "</li>"; 41 41 } 42 42 $pings .= '</ul>'; … … 50 50 51 51 <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 ?>" /> 53 54 <input type="hidden" name="post_author" value="<?php echo $post->post_author ?>" /> 55 <input type="hidden" id="post_type" name="post_type" value="post" /> 54 56 55 57 <?php echo $form_extra ?> … … 67 69 <div id="moremeta"> 68 70 <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> 69 78 70 79 <fieldset id="commentstatusdiv" class="dbx-box"> … … 80 89 81 90 <fieldset id="passworddiv" class="dbx-box"> 82 <h3 class="dbx-handle"><?php _e('P assword-Protect Post') ?></h3>91 <h3 class="dbx-handle"><?php _e('Post Password') ?></h3> 83 92 <div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password ?>" /></div> 84 93 </fieldset> 85 94 86 95 <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> 88 97 <div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo $post->post_name ?>" /></div> 89 98 </fieldset> 90 99 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"> 99 101 <h3 class="dbx-handle"><?php _e('Post Status') ?></h3> 100 102 <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> 102 104 <?php endif; ?> 103 105 <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> … … 106 108 107 109 <?php if ( current_user_can('edit_posts') ) : ?> 108 <fieldset class="dbx-box">110 <fieldset id="posttimestampdiv" class="dbx-box"> 109 111 <h3 class="dbx-handle"><?php _e('Post Timestamp'); ?>:</h3> 110 112 <div class="dbx-content"><?php touch_time(($action == 'edit')); ?></div> … … 112 114 <?php endif; ?> 113 115 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 118 if ( $authors && count( $authors ) > 1 ) : 119 ?> 115 120 <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> 117 122 <div class="dbx-content"> 118 123 <select name="post_author_override" id="post_author_override"> … … 143 148 <legend><?php _e('Post') ?></legend> 144 149 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> 194 152 195 153 <?php echo $form_pingback ?> … … 197 155 198 156 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" /> 200 161 <?php 201 162 if ('publish' != $post->post_status || 0 == $post_ID) { … … 210 171 if ( !empty($_REQUEST['popupurl']) ) 211 172 echo wp_specialchars($_REQUEST['popupurl']); 212 else if ( url_to_postid( $_SERVER['HTTP_REFERER']) == $post_ID )173 else if ( url_to_postid(wp_get_referer()) == $post_ID ) 213 174 echo 'redo'; 214 175 else 215 echo wp_specialchars( $_SERVER['HTTP_REFERER']);176 echo wp_specialchars(wp_get_referer()); 216 177 ?>" /></p> 217 178 … … 221 182 if (current_user_can('upload_files')) { 222 183 $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID); 223 $uploading_iframe_src = "inline-uploading.php?action=view&post=$uploading_iframe_ID";184 $uploading_iframe_src = wp_nonce_url("upload.php?style=inline&tab=upload&post_id=$uploading_iframe_ID", 'inlineuploading'); 224 185 $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src); 225 186 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>'; 227 188 } 228 189 ?> … … 230 191 <div id="advancedstuff" class="dbx-group" > 231 192 193 <div class="dbx-box-wrapper"> 232 194 <fieldset id="postexcerpt" class="dbx-box"> 195 <div class="dbx-handle-wrapper"> 233 196 <h3 class="dbx-handle"><?php _e('Optional Excerpt') ?></h3> 197 </div> 198 <div class="dbx-content-wrapper"> 234 199 <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"> 238 207 <h3 class="dbx-handle"><?php _e('Trackbacks') ?></h3> 208 </div> 209 <div class="dbx-content-wrapper"> 239 210 <div class="dbx-content"><?php _e('Send trackbacks to'); ?>: <?php echo $form_trackback; ?> (<?php _e('Separate multiple URIs with spaces'); ?>) 240 211 <?php … … 243 214 ?> 244 215 </div> 245 </fieldset> 246 216 </div> 217 </fieldset> 218 </div> 219 220 <div class="dbx-box-wrapper"> 247 221 <fieldset id="postcustom" class="dbx-box"> 222 <div class="dbx-handle-wrapper"> 248 223 <h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3> 224 </div> 225 <div class="dbx-content-wrapper"> 249 226 <div id="postcustomstuff" class="dbx-content"> 250 < ?php251 if($metadata = has_meta($post_ID)) { 252 ?> 253 <?php 254 list_meta($metadata); 255 ?> 256 < ?php257 } 227 <table cellpadding="3"> 228 <?php 229 $metadata = has_meta($post_ID); 230 list_meta($metadata); 231 ?> 232 233 </table> 234 <?php 258 235 meta_form(); 259 236 ?> 260 </div> 261 </fieldset> 237 <div id="ajax-response"></div> 238 </div> 239 </div> 240 </fieldset> 241 </div> 262 242 263 243 <?php do_action('dbx_post_advanced'); ?> … … 265 245 </div> 266 246 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;\""; ?> /> 269 249 <?php endif; ?> 270 250 -
trunk/wp-admin/edit-form-comment.php
r3503 r4431 6 6 ?> 7 7 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) ?> 9 10 <div class="wrap"> 10 11 <input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" /> … … 18 19 </script> 19 20 <fieldset id="namediv"> 20 <legend>< ?php _e('Name:') ?></legend>21 <legend><label for="name"><?php _e('Name:') ?></label></legend> 21 22 <div> 22 <input type="text" name="newcomment_author" size="2 2" 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" /> 23 24 </div> 24 25 </fieldset> 25 26 <fieldset id="emaildiv"> 26 <legend>< ?php _e('E-mail:') ?></legend>27 <legend><label for="email"><?php _e('E-mail:') ?></label></legend> 27 28 <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" /> 29 30 </div> 30 31 </fieldset> 31 32 <fieldset id="uridiv"> 32 <legend>< ?php _e('URI:') ?></legend>33 <legend><label for="URL"><?php _e('URL:') ?></label></legend> 33 34 <div> 34 35 <input type="text" id="newcomment_author_url" name="newcomment_author_url" size="35" value="<?php echo $comment->comment_author_url ?>" tabindex="3" id="URL" /> … … 38 39 <fieldset style="clear: both;"> 39 40 <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'); ?> 49 42 </fieldset> 50 43 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 else72 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 90 44 <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(); ?>" /> 92 46 </p> 93 47 … … 107 61 <?php if ( current_user_can('edit_posts') ) : ?> 108 62 <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> 111 65 </tr> 112 66 <?php endif; ?> 113 67 114 68 <tr> 115 <th scope="row"><?php _e('Delete'); ?>:</th> 116 <td><p><a class="delete" href="post.php?action=confirmdeletecomment&noredir=true&comment=<?php echo $comment->comment_ID; ?>&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> 117 75 </tr> 118 76 </table> -
trunk/wp-admin/edit-form.php
r3503 r4431 35 35 <?php the_quicktags(); ?> 36 36 <?php 37 $rows = get_ settings('default_post_edit_rows');37 $rows = get_option('default_post_edit_rows'); 38 38 if (($rows < 3) || ($rows > 100)) { 39 39 $rows = 10; … … 52 52 <input type="hidden" name="post_pingback" value="<?php echo get_option('default_pingback_flag') ?>" id="post_pingback" /> 53 53 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') ?> 55 55 <input type="text" name="trackback_url" style="width: 360px" id="trackback" tabindex="7" /></p> 56 56 … … 65 65 echo '<input name="advanced" type="submit" id="advancededit" tabindex="7" value="' . __('Advanced Editing »') . '" />'; 66 66 } ?> 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()); ?>" /> 68 68 </p> 69 69 -
trunk/wp-admin/edit-link-form.php
r3503 r4431 1 1 <?php 2 2 if ( ! empty($link_id) ) { 3 $editing = true; 4 $heading = __('Edit a link:'); 3 $heading = __('Edit Link'); 5 4 $submit_text = __('Save Changes »'); 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; 7 7 } else { 8 $editing = false; 9 $heading = __('<strong>Add</strong> a link:'); 8 $heading = __('Add Link'); 10 9 $submit_text = __('Add Link »'); 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'; 12 12 } 13 13 … … 29 29 } 30 30 } 31 32 31 ?> 33 32 34 33 <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> 56 93 </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> 169 210 </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 <?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> <?php _e('(Leave at 0 for no rating.)') ?> 241 </td> 242 </tr> 224 243 </table> 225 244 </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 ?>" /> 232 252 <?php else: ?> 233 <input type="hidden" name="action" value="Add" />253 <input type="hidden" name="action" value="add" /> 234 254 <?php endif; ?> 235 </form> 236 </div> 255 </div> 256 </form> 257 </div> -
trunk/wp-admin/edit-page-form.php
r3503 r4431 1 1 2 2 <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 ↓'); ?></a></small><?php endif; ?></h2> 3 <h2 id="write-post"><?php _e('Write Page'); ?></h2> 5 4 <?php 6 5 if (0 == $post_ID) { 7 6 $form_action = 'post'; 7 $nonce_action = 'add-page'; 8 8 $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' />"; 10 10 } else { 11 11 $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' />"; 13 14 } 14 15 15 $sendto = $_SERVER['HTTP_REFERER'];16 $sendto = wp_get_referer(); 16 17 17 18 if ( 0 != $post_ID && $sendto == get_permalink($post_ID) ) … … 21 22 ?> 22 23 23 <form name="post" action="p ost.php" method="post" id="post">24 <form name="post" action="page.php" method="post" id="post"> 24 25 25 26 <?php 27 wp_nonce_field($nonce_action); 28 26 29 if (isset($mode) && 'bookmarklet' == $mode) { 27 30 echo '<input type="hidden" name="mode" value="bookmarklet" />'; … … 29 32 ?> 30 33 <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 ?>" /> 32 36 <?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" /> 34 38 35 39 <script type="text/javascript"> 36 <!-- 40 // <![CDATA[ 37 41 function focusit() { // focus on first input field 38 42 document.post.title.focus(); 39 43 } 40 44 addLoadEvent(focusit); 41 // -->45 // ]]> 42 46 </script> 43 47 <div id="poststuff"> … … 56 60 </fieldset> 57 61 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 58 71 <fieldset id="passworddiv" class="dbx-box"> 59 <h3 class="dbx-handle"><?php _e('Pa ssword-Protect Post') ?></h3>72 <h3 class="dbx-handle"><?php _e('Page Password') ?></h3> 60 73 <div class="dbx-content"><input name="post_password" type="text" size="13" id="post_password" value="<?php echo $post->post_password ?>" /></div> 61 74 </fieldset> … … 71 84 72 85 <?php if ( 0 != count( get_page_templates() ) ) { ?> 73 <fieldset id="page parent" class="dbx-box">86 <fieldset id="pagetemplate" class="dbx-box"> 74 87 <h3 class="dbx-handle"><?php _e('Page Template:') ?></h3> 75 88 <div class="dbx-content"><p><select name="page_template"> … … 82 95 83 96 <fieldset id="slugdiv" class="dbx-box"> 84 <h3 class="dbx-handle"><?php _e('P ost slug') ?></h3>97 <h3 class="dbx-handle"><?php _e('Page Slug') ?></h3> 85 98 <div class="dbx-content"><input name="post_name" type="text" size="13" id="post_name" value="<?php echo $post->post_name ?>" /></div> 86 99 </fieldset> … … 88 101 <?php if ( $authors = get_editable_authors( $current_user->id ) ) : // TODO: ROLE SYSTEM ?> 89 102 <fieldset id="authordiv" class="dbx-box"> 90 <h3 class="dbx-handle"><?php _e('P ost author'); ?>:</h3>103 <h3 class="dbx-handle"><?php _e('Page Author'); ?>:</h3> 91 104 <div class="dbx-content"> 92 105 <select name="post_author_override" id="post_author_override"> … … 122 135 <fieldset id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>"> 123 136 <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); ?> 133 138 </fieldset> 134 139 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 else156 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 174 140 <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') ?> »" /> 178 <?php else : ?> 179 <input name="savepage" type="submit" id="savepage" tabindex="6" value="<?php _e('Create New Page') ?> »" /> 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 145 if ('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;?> 181 150 <input name="referredby" type="hidden" id="referredby" value="<?php echo $sendto; ?>" /> 182 151 </p> … … 187 156 if (current_user_can('upload_files')) { 188 157 $uploading_iframe_ID = (0 == $post_ID ? $temp_ID : $post_ID); 189 $uploading_iframe_src = "inline-uploading.php?action=view&post=$uploading_iframe_ID";158 $uploading_iframe_src = wp_nonce_url("upload.php?style=inline&tab=upload&post_id=$uploading_iframe_ID", 'inlineuploading'); 190 159 $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src); 191 160 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>'; 193 162 } 194 163 ?> … … 199 168 <h3 class="dbx-handle"><?php _e('Custom Fields') ?></h3> 200 169 <div id="postcustomstuff" class="dbx-content"> 170 <table cellpadding="3"> 201 171 <?php 202 if($metadata = has_meta($post_ID)) { 172 $metadata = has_meta($post_ID); 173 list_meta($metadata); 203 174 ?> 175 176 </table> 204 177 <?php 205 list_meta($metadata);206 ?>207 <?php208 }209 178 meta_form(); 210 179 ?> 211 180 </div> 181 <div id="ajax-response"></div> 212 182 </fieldset> 213 183 … … 216 186 </div> 217 187 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;\""; ?> /> 220 192 <?php endif; ?> 193 </div> 194 221 195 </form> 222 196 223 197 </div> 224 225 </div> -
trunk/wp-admin/edit-pages.php
r3503 r4431 3 3 $title = __('Pages'); 4 4 $parent_file = 'edit.php'; 5 $list_js = true;5 wp_enqueue_script( 'listman' ); 6 6 require_once('admin-header.php'); 7 7 ?> … … 9 9 <div class="wrap"> 10 10 <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 '); ?> »</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 »'); ?></a></p> 12 12 13 13 <form name="searchform" action="" method="get"> … … 20 20 21 21 <?php 22 wp('post_type=page&orderby=menu_order&what_to_show=posts&posts_per_page=-1&posts_per_archive_page=-1'); 22 23 23 $show_post_type = 'page'; 24 25 if ( isset($_GET['s']) ) 26 wp(); 24 if ( $_GET['s'] ) 25 $all = false; 27 26 else 28 $ posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'static'");27 $all = true; 29 28 30 29 if ($posts) { 31 30 ?> 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> 36 36 <th scope="col"><?php _e('Owner') ?></th> 37 37 <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"> 42 42 <?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&post=$id' class='edit'>" . __('Edit') . "</a>"; } ?></td> 55 <td><?php if ( current_user_can('edit_pages') ) { echo "<a href='post.php?action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'page', " . $id . ", '" . sprintf(__("You are about to delete the "%s" page.\\n"OK" to delete, "Cancel" to stop."), wp_specialchars(get_the_title('','',0), 1)) . "' );\">" . __('Delete') . "</a>"; } ?></td> 56 </tr> 57 <?php 58 endforeach; 59 } else { 60 page_rows(); 61 } 43 page_rows(0, 0, $posts, $all); 62 44 ?> 63 </table> 45 </tbody> 46 </table> 64 47 65 48 <div id="ajax-response"></div> … … 73 56 ?> 74 57 75 <h3><a href="page-new.php"><?php _e('Create New Page '); ?> »</a></h3>58 <h3><a href="page-new.php"><?php _e('Create New Page »'); ?></a></h3> 76 59 77 60 </div> -
trunk/wp-admin/edit.php
r3503 r4431 4 4 $title = __('Posts'); 5 5 $parent_file = 'edit.php'; 6 $list_js = true;6 wp_enqueue_script( 1 == $_GET['c'] ? 'admin-comments' : 'listman' ); 7 7 require_once('admin-header.php'); 8 8 … … 56 56 <h2> 57 57 <?php 58 $what_to_show = 'posts'; 59 $posts_per_page = 15; 60 $posts_per_archive_page = -1; 61 62 wp(); 58 59 wp('what_to_show=posts&posts_per_page=15&posts_per_archive_page=-1'); 63 60 64 61 if ( is_month() ) { … … 77 74 </h2> 78 75 79 <form name="searchform" action="" method="get" style="float: left; width: 16em; margin-right: 3em;">76 <form name="searchform" id="searchform" action="" method="get"> 80 77 <fieldset> 81 78 <legend><?php _e('Search Posts…') ?></legend> 82 79 <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" /> 84 81 </fieldset> 85 82 </form> 86 83 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"); 88 85 89 86 if ( count($arc_result) ) { ?> 90 87 91 <form name="viewarc" action="" method="get" style="float: left; width: 20em; margin-bottom: 1em;">88 <form name="viewarc" id="viewarc" action="" method="get"> 92 89 <fieldset> 93 90 <legend><?php _e('Browse Month…') ?></legend> 94 91 <select name='m'> 95 92 <?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'] ) 101 99 $default = 'selected="selected"'; 102 100 else 103 101 $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"; 107 105 echo "</option>\n"; 108 106 } 109 107 ?> 110 108 </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" /> 112 110 </fieldset> 113 111 </form> … … 115 113 <?php } ?> 116 114 115 <form name="viewcat" id="viewcat" action="" method="get"> 116 <fieldset> 117 <legend><?php _e('Browse Category…') ?></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 117 125 <br style="clear:both;" /> 118 126 119 127 <?php 120 121 128 // define the columns to display, the syntax is 'internal name' => 'display name' 122 129 $posts_columns = array( … … 137 144 ?> 138 145 139 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3"> 146 <table class="widefat"> 147 <thead> 140 148 <tr> 141 149 … … 145 153 146 154 </tr> 155 </thead> 156 <tbody id="the-list"> 147 157 <?php 148 158 if ($posts) { 149 159 $bgcolor = ''; 150 160 foreach ($posts as $post) { start_wp(); 161 add_filter('the_title','wp_specialchars'); 151 162 $class = ('alternate' == $class) ? '' : 'alternate'; 152 163 ?> … … 158 169 159 170 switch($column_name) { 160 171 161 172 case 'id': 162 173 ?> 163 <th scope="row" ><?php echo $id ?></th>174 <th scope="row" style="text-align: center"><?php echo $id ?></th> 164 175 <?php 165 176 break; … … 185 196 case 'comments': 186 197 ?> 187 <td ><a href="edit.php?p=<?php echo $id ?>&c=1">198 <td style="text-align: center"><a href="edit.php?p=<?php echo $id ?>&c=1"> 188 199 <?php comments_number(__('0'), __('1'), __('%')) ?> 189 200 </a></td> … … 211 222 case 'control_delete': 212 223 ?> 213 <td><?php if ( current_user_can(' edit_post',$post->ID) ) { echo "<a href='post.php?action=delete&post=$id' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . sprintf(__("You are about to delete this post "%s".\\n"OK" to delete, "Cancel" 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&post=$id", 'delete-post_' . $post->ID) . "' class='delete' onclick=\"return deleteSomething( 'post', " . $id . ", '" . sprintf(__("You are about to delete this post "%s".\\n"OK" to delete, "Cancel" to stop."), js_escape(get_the_title()) ) . "' );\">" . __('Delete') . "</a>"; } ?></td> 214 225 <?php 215 226 break; … … 233 244 <?php 234 245 } // end if ($posts) 235 ?> 246 ?> 247 </tbody> 236 248 </table> 237 249 … … 249 261 if ($comments) { 250 262 ?> 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; 254 267 foreach ($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&comment=".$comment->comment_ID."\">" . __('Edit') . "</a>"; 265 echo " - <a href=\"post.php?action=deletecomment&p=".$post->ID."&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&p=".$post->ID."&comment=".$comment->comment_ID."\">" . __('Unapprove') . "</a> "; 269 } else { 270 echo " - <a href=\"post.php?action=approvecomment&p=".$post->ID."&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'); ?> — [ 283 <?php 284 if ( current_user_can('edit_post', $comment->comment_post_ID) ) { 285 echo " <a href='comment.php?action=editcomment&comment=".$comment->comment_ID."\'>" . __('Edit') . '</a>'; 286 echo ' | <a href="' . wp_nonce_url('comment.php?action=deletecomment&p=' . $post->ID . '&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 "%s".\\n"Cancel" to stop, "OK" 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&p=' . $post->ID . '&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&p=' . $post->ID . '&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&delete_type=spam&p=".$comment->comment_post_ID."&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 "%s".\\n"Cancel" to stop, "OK" 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 290 297 <?php //end of the loop, don't delete 291 298 } // end foreach -
trunk/wp-admin/import.php
r3503 r4431 2 2 require_once ('admin.php'); 3 3 $title = __('Import'); 4 $parent_file = ' import.php';4 $parent_file = 'edit.php'; 5 5 require_once ('admin-header.php'); 6 6 ?> … … 31 31 } else { 32 32 ?> 33 <table width="100%" cellpadding="3" cellspacing="3">33 <table class="widefat"> 34 34 35 35 <?php … … 37 37 foreach ($importers as $id => $data) { 38 38 $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>"; 40 40 41 41 if ($style != '') … … 43 43 echo " 44 44 <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> 47 47 </tr>"; 48 48 } -
trunk/wp-admin/import/blogger.php
r3503 r4431 26 26 function restart() { 27 27 delete_option('import-blogger'); 28 header("Location:admin.php?import=blogger");28 wp_redirect("admin.php?import=blogger"); 29 29 die(); 30 30 } … … 136 136 if ($header) curl_setopt($ch, CURLOPT_HTTPHEADER, $header); 137 137 $response = curl_exec ($ch); 138 138 139 139 if ($parse) { 140 140 $response = $this->parse_response($response); … … 142 142 return $response; 143 143 } 144 144 145 145 return $response; 146 146 } … … 211 211 update_option('import-blogger', $this->import); 212 212 } 213 213 214 214 // Redirects to next step 215 215 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']}"); 217 217 die(); 218 218 } … … 225 225 $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>'); 226 226 } 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. 229 229 $this->import['cookies'] = $this->login_blogger($_POST['user'], $_POST['pass']); 230 230 if ( !is_array( $this->import['cookies'] ) ) { 231 231 $this->login_form(__('Login failed. Please enter your credentials again.')); 232 232 } 233 233 234 234 // Save the password so we can log the browser in when it's time to publish. 235 235 $this->import['pass'] = $_POST['pass']; … … 242 242 preg_match_all('#posts\.g\?blogID=(\d+)">([^<]+)</a>#U', $response['body'], $blogsary); 243 243 if ( ! count( $blogsary[1] < 1 ) ) 244 die(__('No blogs found for this user.'));244 wp_die(__('No blogs found for this user.')); 245 245 $this->import['blogs'] = array(); 246 246 $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>'; … … 274 274 } 275 275 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"); 277 277 } 278 278 die(); … … 307 307 $response = $this->get_blogger("http://www.blogger.com/blog-publishing.g?blogID={$_GET['blog']}&publishMode=0", $headers); 308 308 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>'); 310 310 $this->import['blogs'][$_GET['blog']]['url'] = 'http://' . $optary['modify']['subdomain'] . '.blogspot.com/'; 311 311 sleep(2); … … 322 322 $response = $this->post_blogger($posturl, $headers, $paramary); 323 323 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))); 325 325 } 326 326 $output .= "<del><p>$blog_opt</p></del>\n"; … … 342 342 $form.= $body; 343 343 $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"; 345 345 } else { 346 346 $output.= "<p>$blog_opt</p>\n"; … … 365 365 $bloghtml = $this->get_blogger($this->import['blogs'][$_GET['blog']]['url']); 366 366 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.')); 368 368 preg_match_all('#<a class="archive" href="([^"]*)"#', $bloghtml['body'], $archives); 369 369 foreach ($archives[1] as $archive) { … … 396 396 $archive = $this->get_blogger($url); 397 397 if ( $archive['code'] > 200 ) 398 continue; 398 continue; 399 399 $posts = explode('<wordpresspost>', $archive['body']); 400 400 for ($i = 1; $i < count($posts); $i = $i + 1) { … … 410 410 $post_author_name = $wpdb->escape(trim($postinfo[1])); 411 411 $post_author_email = $postinfo[5] ? $postinfo[5] : 'user@wordpress.org'; 412 412 413 413 if ( $this->lump_authors ) { 414 414 // Ignore Blogger authors. Use the current user_ID for all posts imported. … … 421 421 $user_password = substr(md5(uniqid(microtime())), 0, 6); 422 422 $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); 424 424 $this->import['blogs'][$_GET['blog']]['newusers'][] = $user_login; 425 425 } … … 436 436 $postminute = zeroise($post_date_His[1], 2); 437 437 $postsecond = zeroise($post_date_His[2], 2); 438 438 439 439 if (($post_date[2] == 'PM') && ($posthour != '12')) 440 440 $posthour = $posthour + 12; 441 441 else if (($post_date[2] == 'AM') && ($posthour == '12')) 442 442 $posthour = '00'; 443 443 444 444 $post_date = "$postyear-$postmonth-$postday $posthour:$postminute:$postsecond"; 445 445 446 446 $post_content = addslashes($post_content); 447 447 $post_content = str_replace(array('<br>','<BR>','<br/>','<BR/>','<br />','<BR />'), "\n", $post_content); // the XHTML touch... ;) 448 448 449 449 $post_title = addslashes($post_title); 450 450 451 451 $post_status = 'publish'; 452 452 453 453 if ( $ID = post_exists($post_title, '', $post_date) ) { 454 454 $post_array[$i]['ID'] = $ID; … … 510 510 } 511 511 $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).' '. 513 513 ' <strong>'.__('Done').'</strong>'; 514 514 $import = $this->import; … … 547 547 sleep(2); 548 548 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)) ); 550 550 } 551 551 } … … 598 598 $this->restart(); 599 599 } 600 600 601 601 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'); 603 605 604 606 if ( false === $this->import ) { … … 614 616 } 615 617 //echo "Step $step."; 616 // die('<pre>'.print_r($this->import,1).'</pre');618 //wp_die('<pre>'.print_r($this->import,1).'</pre'); 617 619 switch ($step) { 618 620 case 0 : … … 648 650 } 649 651 die; 650 652 651 653 } else { 652 654 $this->greet(); … … 661 663 $blogger_import = new Blogger_Import(); 662 664 663 register_importer('blogger', 'Blogger', __('Import posts and comments from aBlogger account'), array ($blogger_import, 'start'));665 register_importer('blogger', __('Blogger and Blog*Spot'), __('Import <strong>posts and comments</strong> from your Blogger account'), array ($blogger_import, 'start')); 664 666 665 667 ?> -
trunk/wp-admin/import/dotclear.php
-
Property
svn:eol-style
set to
native
r3503 r4431 1 1 <?php 2 /* 3 * Dotclear import plugin 4 * by Thomas Quinot - http://thomas.quinot.org/ 5 */ 6 2 7 /** 3 8 Add These Functions to make our lives easier … … 8 13 { 9 14 global $wpdb; 10 15 11 16 $cat_id -= 0; // force numeric 12 17 $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"'); 13 18 14 19 return $name; 15 20 } … … 128 133 { 129 134 echo '<div class="wrap">'; 130 echo '<h2>'.__('Import Dot clear').'</h2>';135 echo '<h2>'.__('Import DotClear').'</h2>'; 131 136 echo '<p>'.__('Steps may take a few minutes depending on the size of your database. Please be patient.').'</p>'; 132 137 } … … 136 141 echo '</div>'; 137 142 } 138 143 139 144 function greet() 140 145 { 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 Dot clear 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>'; 143 148 echo '<form action="admin.php?import=dotclear&step=1" method="post">'; 144 149 $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').' »" /></p>'; 151 echo '</form></div>'; 147 152 } 148 153 … … 153 158 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); 154 159 set_magic_quotes_runtime(0); 155 $ prefix = get_option('tpre');156 160 $dbprefix = get_option('dcdbprefix'); 161 157 162 // 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 161 166 function get_dc_users() 162 167 { … … 165 170 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); 166 171 set_magic_quotes_runtime(0); 167 $ prefix = get_option('tpre');168 172 $dbprefix = get_option('dcdbprefix'); 173 169 174 // 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 174 179 function get_dc_posts() 175 180 { … … 177 182 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); 178 183 set_magic_quotes_runtime(0); 179 $ prefix = get_option('tpre');180 184 $dbprefix = get_option('dcdbprefix'); 185 181 186 // Get Posts 182 return $dcdb->get_results('SELECT dc_post.*, dc_categorie.cat_libelle_url AS post_cat_name183 FROM dc_post INNER JOIN dc_categorie184 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 187 192 function get_dc_comments() 188 193 { … … 191 196 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); 192 197 set_magic_quotes_runtime(0); 193 $ prefix = get_option('tpre');194 198 $dbprefix = get_option('dcdbprefix'); 199 195 200 // 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 199 204 function get_dc_links() 200 205 { … … 202 207 $dcdb = new wpdb(get_option('dcuser'), get_option('dcpass'), get_option('dcname'), get_option('dchost')); 203 208 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 209 214 function cat2wp($categories='') 210 215 { … … 221 226 $count++; 222 227 extract($category); 223 228 224 229 // Make Nice Variables 225 230 $name = $wpdb->escape($cat_libelle_url); … … 237 242 $dccat2wpcat[$id] = $ret_id; 238 243 } 239 244 240 245 // Store category translation for future use 241 246 add_option('dccat2wpcat',$dccat2wpcat); … … 246 251 return false; 247 252 } 248 253 249 254 function users2wp($users='') 250 255 { … … 253 258 $count = 0; 254 259 $dcid2wpid = array(); 255 260 256 261 // Midnight Mojo 257 262 if(is_array($users)) … … 262 267 $count++; 263 268 extract($user); 264 269 265 270 // Make Nice Variables 266 271 $name = $wpdb->escape(csc ($name)); 267 272 $RealName = $wpdb->escape(csc ($user_pseudo)); 268 273 269 274 if($uinfo = get_userdatabylogin($name)) 270 275 { 271 276 272 277 $ret_id = wp_insert_user(array( 273 278 'ID' => $uinfo->ID, … … 290 295 } 291 296 $dcid2wpid[$user_id] = $ret_id; 292 297 293 298 // Set Dotclear-to-WordPress permissions translation 294 299 295 300 // Update Usermeta Data 296 301 $user = new WP_User($ret_id); … … 303 308 else if(2 <= $wp_perms) { $user->set_role('contributor'); } 304 309 else { $user->set_role('subscriber'); } 305 310 306 311 update_usermeta( $ret_id, 'wp_user_level', $wp_perms); 307 312 update_usermeta( $ret_id, 'rich_editing', 'false'); … … 309 314 update_usermeta( $ret_id, 'last_name', csc ($user_nom)); 310 315 }// End foreach($users as $user) 311 316 312 317 // Store id translation array for future use 313 318 add_option('dcid2wpid',$dcid2wpid); 314 315 319 320 316 321 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>'; 317 322 return true; 318 323 }// End if(is_array($users) 319 324 320 325 echo __('No Users to Import!'); 321 326 return false; 322 327 323 328 }// End function user2wp() 324 329 325 330 function posts2wp($posts='') 326 331 { … … 339 344 $count++; 340 345 extract($post); 341 346 342 347 // Set Dotclear-to-WordPress status translation 343 348 $stattrans = array(0 => 'draft', 1 => 'publish'); 344 349 $comment_status_map = array (0 => 'closed', 1 => 'open'); 345 350 346 351 //Can we do this more efficiently? 347 352 $uinfo = ( get_userdatabylogin( $user_id ) ) ? get_userdatabylogin( $user_id ) : 1; … … 350 355 $Title = $wpdb->escape(csc ($post_titre)); 351 356 $post_content = textconv ($post_content); 357 $post_excerpt = ""; 352 358 if ($post_chapo != "") { 353 359 $post_excerpt = textconv ($post_chapo); … … 357 363 $post_content = $wpdb->escape ($post_content); 358 364 $post_status = $stattrans[$post_pub]; 359 365 360 366 // Import Post data into WordPress 361 367 362 368 if($pinfo = post_exists($Title,$post_content)) 363 369 { … … 398 404 } 399 405 $dcposts2wpposts[$post_id] = $ret_id; 400 406 401 407 // Make Post-to-Category associations 402 408 $cats = array(); 403 409 if($cat1 = get_catbynicename($post_cat_name)) { $cats[1] = $cat1; } 404 410 405 if(!empty($cats)) { wp_set_post_cat s('',$ret_id, $cats); }411 if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); } 406 412 } 407 413 } 408 414 // Store ID translation for later use 409 415 add_option('dcposts2wpposts',$dcposts2wpposts); 410 416 411 417 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>'; 412 return true; 413 } 414 418 return true; 419 } 420 415 421 function comments2wp($comments='') 416 422 { … … 420 426 $dccm2wpcm = array(); 421 427 $postarr = get_option('dcposts2wpposts'); 422 428 423 429 // Magic Mojo 424 430 if(is_array($comments)) … … 429 435 $count++; 430 436 extract($comment); 431 437 432 438 // WordPressify Data 433 439 $comment_ID = ltrim($comment_id, '0'); … … 438 444 $web = "http://".$wpdb->escape($comment_site); 439 445 $message = $wpdb->escape(textconv ($comment_content)); 440 446 441 447 if($cinfo = comment_exists($name, $comment_dt)) 442 448 { … … 473 479 } 474 480 // Store Comment ID translation for future use 475 add_option('dccm2wpcm', $dccm2wpcm); 476 481 add_option('dccm2wpcm', $dccm2wpcm); 482 477 483 // Associate newly formed categories with posts 478 484 get_comment_count($ret_id); 479 480 485 486 481 487 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>'; 482 488 return true; … … 485 491 return false; 486 492 } 487 493 488 494 function links2wp($links='') 489 495 { … … 491 497 global $wpdb; 492 498 $count = 0; 493 499 494 500 // Deal with the links 495 501 if(is_array($links)) … … 500 506 $count++; 501 507 extract($link); 502 508 503 509 if ($title != "") { 504 510 if ($cinfo = link_cat_exists (csc ($title))) { … … 512 518 $linkname = $wpdb->escape(csc ($label)); 513 519 $description = $wpdb->escape(csc ($title)); 514 520 515 521 if($linfo = link_exists($linkname)) { 516 522 $ret_id = wp_insert_link(array( … … 541 547 return false; 542 548 } 543 549 544 550 function import_categories() 545 { 546 // Category Import 551 { 552 // Category Import 547 553 $cats = $this->get_dc_cats(); 548 554 $this->cat2wp($cats); 549 555 add_option('dc_cats', $cats); 550 551 552 556 557 558 553 559 echo '<form action="admin.php?import=dotclear&step=2" method="post">'; 554 560 printf('<input type="submit" name="submit" value="%s" />', __('Import Users')); … … 556 562 557 563 } 558 564 559 565 function import_users() 560 566 { … … 562 568 $users = $this->get_dc_users(); 563 569 $this->users2wp($users); 564 570 565 571 echo '<form action="admin.php?import=dotclear&step=3" method="post">'; 566 572 printf('<input type="submit" name="submit" value="%s" />', __('Import Posts')); 567 573 echo '</form>'; 568 574 } 569 575 570 576 function import_posts() 571 577 { … … 573 579 $posts = $this->get_dc_posts(); 574 580 $this->posts2wp($posts); 575 581 576 582 echo '<form action="admin.php?import=dotclear&step=4" method="post">'; 577 583 printf('<input type="submit" name="submit" value="%s" />', __('Import Comments')); 578 584 echo '</form>'; 579 585 } 580 586 581 587 function import_comments() 582 588 { … … 584 590 $comments = $this->get_dc_comments(); 585 591 $this->comments2wp($comments); 586 592 587 593 echo '<form action="admin.php?import=dotclear&step=5" method="post">'; 588 594 printf('<input type="submit" name="submit" value="%s" />', __('Import Links')); 589 595 echo '</form>'; 590 596 } 591 597 592 598 function import_links() 593 599 { … … 596 602 $this->links2wp($links); 597 603 add_option('dc_links', $links); 598 604 599 605 echo '<form action="admin.php?import=dotclear&step=6" method="post">'; 600 606 printf('<input type="submit" name="submit" value="%s" />', __('Finish')); 601 607 echo '</form>'; 602 608 } 603 609 604 610 function cleanup_dcimport() 605 611 { 606 delete_option(' tpre');612 delete_option('dcdbprefix'); 607 613 delete_option('dc_cats'); 608 614 delete_option('dcid2wpid'); … … 618 624 $this->tips(); 619 625 } 620 626 621 627 function tips() 622 628 { 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 Dot clear, 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>'; 624 630 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 Dot clear, 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>'; 626 632 echo '<h3>'.__('Preserving Authors').'</h3>'; 627 633 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>'; 628 634 echo '<h3>'.__('Textile').'</h3>'; 629 echo '<p>'.__('Also, since you\'re coming from Dot clear, 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>'; 630 636 echo '<h3>'.__('WordPress Resources').'</h3>'; 631 637 echo '<p>'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'</p>'; 632 638 echo '<ul>'; 633 639 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>'; 635 641 echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>'; 636 642 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 640 646 function db_form() 641 647 { 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 652 658 function dispatch() 653 659 { … … 658 664 $step = (int) $_GET['step']; 659 665 $this->header(); 660 666 661 667 if ( $step > 0 ) 662 668 { … … 664 670 { 665 671 if(get_option('dcuser')) 666 delete_option('dcuser'); 672 delete_option('dcuser'); 667 673 add_option('dcuser',$_POST['dbuser']); 668 674 } … … 670 676 { 671 677 if(get_option('dcpass')) 672 delete_option('dcpass'); 678 delete_option('dcpass'); 673 679 add_option('dcpass',$_POST['dbpass']); 674 680 } 675 681 676 682 if($_POST['dbname']) 677 683 { 678 684 if(get_option('dcname')) 679 delete_option('dcname'); 685 delete_option('dcname'); 680 686 add_option('dcname',$_POST['dbname']); 681 687 } … … 691 697 delete_option('dccharset'); 692 698 add_option('dccharset',$_POST['dccharset']); 693 } 699 } 694 700 if($_POST['dbprefix']) 695 701 { 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 } 700 706 701 707 … … 727 733 break; 728 734 } 729 735 730 736 $this->footer(); 731 737 } … … 733 739 function Dotclear_Import() 734 740 { 735 // Nothing. 741 // Nothing. 736 742 } 737 743 } 738 744 739 745 $dc_import = new Dotclear_Import(); 740 register_importer('dotclear', 'Dotclear', __('Import posts from a Dotclear Blog'), array ($dc_import, 'dispatch'));746 register_importer('dotclear', __('DotClear'), __('Import posts from a DotClear Blog'), array ($dc_import, 'dispatch')); 741 747 ?> -
Property
svn:eol-style
set to
-
trunk/wp-admin/import/greymatter.php
r3503 r4431 1 <?php 2 3 class 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> </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> </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> </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 312 register_importer('greymatter', __('Greymatter'), __('Import posts and comments from your Greymatter blog'), array ($gm_import, 'dispatch')); 313 ?> -
trunk/wp-admin/import/livejournal.php
r3503 r4431 19 19 return strtr($string, $trans_tbl); 20 20 } 21 21 22 22 function greet() { 23 echo '<div class="narrow">'; 23 24 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>'; 24 25 wp_import_upload_form("admin.php?import=livejournal&step=1"); 26 echo '</div>'; 25 27 } 26 28 27 29 function import_posts() { 28 30 global $wpdb, $current_user; 29 31 30 32 set_magic_quotes_runtime(0); 31 33 $importdata = file($this->file); // Read the file into an array … … 36 38 $posts = $posts[1]; 37 39 unset($importdata); 38 echo '<ol>'; 40 echo '<ol>'; 39 41 foreach ($posts as $post) { 40 flush();41 42 preg_match('|<subject>(.*?)</subject>|is', $post, $post_title); 42 43 $post_title = $wpdb->escape(trim($post_title[1])); … … 79 80 preg_match_all('|<comment>(.*?)</comment>|is', $post, $comments); 80 81 $comments = $comments[1]; 81 82 82 83 if ( $comments ) { 83 84 $comment_post_ID = $post_id; … … 119 120 } 120 121 echo '</li>'; 121 flush();122 ob_flush();123 122 } 124 123 echo '</ol>'; … … 135 134 $this->import_posts(); 136 135 wp_import_cleanup($file['id']); 137 136 138 137 echo '<h3>'; 139 138 printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')); … … 148 147 149 148 $this->header(); 150 149 151 150 switch ($step) { 152 151 case 0 : … … 157 156 break; 158 157 } 159 158 160 159 $this->footer(); 161 160 } 162 161 163 162 function LJ_Import() { 164 // Nothing. 163 // Nothing. 165 164 } 166 165 } … … 168 167 $livejournal_import = new LJ_Import(); 169 168 170 register_importer('livejournal', 'LiveJournal', __('Import posts from LiveJournal'), array ($livejournal_import, 'dispatch'));169 register_importer('livejournal', __('LiveJournal'), __('Import posts from LiveJournal'), array ($livejournal_import, 'dispatch')); 171 170 ?> -
trunk/wp-admin/import/mt.php
r3503 r4431 12 12 function header() { 13 13 echo '<div class="wrap">'; 14 echo '<h2>'.__('Import Movable Type ').'</h2>';14 echo '<h2>'.__('Import Movable Type and TypePad').'</h2>'; 15 15 } 16 16 … … 22 22 $this->header(); 23 23 ?> 24 <div class="narrow"> 24 25 <p><?php _e('Howdy! We’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> 25 26 <?php wp_import_upload_form( add_query_arg('step', 1) ); ?> 26 27 <p><?php _e('The importer is smart enough not to import duplicates, so you can run this multiple times without worry if—for whatever reason—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> 27 29 <?php 28 30 $this->footer(); … … 33 35 $users = $wpdb->get_results("SELECT * FROM $wpdb->users ORDER BY ID"); 34 36 ?><select name="userselect[<?php echo $n; ?>]"> 35 <option value="#NONE#"> - Select -</option>37 <option value="#NONE#"><?php _e('- Select -') ?></option> 36 38 <?php 37 39 … … 135 137 function mt_authors_form() { 136 138 ?> 139 <div class="wrap"> 140 <h2><?php _e('Assign Authors'); ?></h2> 137 141 <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> 138 142 <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> … … 147 151 foreach ($authors as $author) { 148 152 ++ $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 />'); 150 154 $this->users_form($j); 151 155 echo '</li>'; 152 156 } 153 157 154 echo '<input type="submit" value=" Submit">'.'<br/>';158 echo '<input type="submit" value="'.__('Submit').'">'.'<br/>'; 155 159 echo '</form>'; 156 echo '</ol>'; 157 158 flush(); 160 echo '</ol></div>'; 161 159 162 } 160 163 … … 162 165 $file = wp_import_handle_upload(); 163 166 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(); 165 171 return; 166 172 } … … 175 181 global $wpdb; 176 182 $i = -1; 177 echo "< ol>";183 echo "<div class='wrap'><ol>"; 178 184 foreach ($this->posts as $post) { 179 185 if ('' != trim($post)) { … … 194 200 // We want the excerpt 195 201 preg_match("|-----\nEXCERPT:(.*)|s", $post, $excerpt); 196 $ excerpt = $wpdb->escape(trim($excerpt[1]));202 $post_excerpt = $wpdb->escape(trim($excerpt[1])); 197 203 $post = preg_replace("|(-----\nEXCERPT:.*)|s", '', $post); 198 204 … … 331 337 } 332 338 if ( $num_comments ) 333 printf( __('(%s comments)'), $num_comments);339 printf(' '.__('(%s comments)'), $num_comments); 334 340 335 341 // Finally the pings … … 379 385 } 380 386 if ( $num_pings ) 381 printf( __('(%s pings)'), $num_pings);382 387 printf(' '.__('(%s pings)'), $num_pings); 388 383 389 echo "</li>"; 384 390 } 385 flush();386 391 } 387 392 … … 390 395 wp_import_cleanup($this->id); 391 396 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>'; 393 398 } 394 399 395 400 function import() { 396 401 $this->id = (int) $_GET['id']; 402 397 403 $this->file = get_attached_file($this->id); 398 404 $this->get_authors_from_post(); … … 421 427 422 428 function MT_Import() { 423 // Nothing. 429 // Nothing. 424 430 } 425 431 } … … 427 433 $mt_import = new MT_Import(); 428 434 429 register_importer('mt', 'Movable Type', __('Import posts and comments from your Movable Typeblog'), array ($mt_import, 'dispatch'));435 register_importer('mt', __('Movable Type and TypePad'), __('Imports <strong>posts and comments</strong> from your Movable Type or TypePad blog'), array ($mt_import, 'dispatch')); 430 436 ?> -
trunk/wp-admin/import/rss.php
r3503 r4431 20 20 return strtr($string, $trans_tbl); 21 21 } 22 22 23 23 function greet() { 24 echo '<div class="narrow">'; 24 25 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>'; 25 26 wp_import_upload_form("admin.php?import=rss&step=1"); 27 echo '</div>'; 26 28 } 27 29 28 30 function get_posts() { 29 31 global $wpdb; 30 32 31 33 set_magic_quotes_runtime(0); 32 34 $datalines = file($this->file); // Read the file into an array … … 39 41 foreach ($this->posts as $post) { 40 42 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]) )); 42 44 43 preg_match('|<pubdate>(.*?)</pubdate>|is', $post, $post_date );45 preg_match('|<pubdate>(.*?)</pubdate>|is', $post, $post_date_gmt); 44 46 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]); 47 49 } else { 48 50 // 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); 53 55 } 54 56 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 ); 56 59 57 60 preg_match_all('|<category>(.*?)</category>|is', $post, $categories); … … 91 94 $post_author = 1; 92 95 $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'); 94 97 $index++; 95 98 } … … 135 138 $this->import_posts(); 136 139 wp_import_cleanup($file['id']); 137 140 138 141 echo '<h3>'; 139 142 printf(__('All done. <a href="%s">Have fun!</a>'), get_option('home')); … … 148 151 149 152 $this->header(); 150 153 151 154 switch ($step) { 152 155 case 0 : … … 157 160 break; 158 161 } 159 162 160 163 $this->footer(); 161 164 } 162 165 163 166 function RSS_Import() { 164 // Nothing. 167 // Nothing. 165 168 } 166 169 } … … 168 171 $rss_import = new RSS_Import(); 169 172 170 register_importer('rss', 'RSS', __('Import posts from an RSS feed'), array ($rss_import, 'dispatch'));173 register_importer('rss', __('RSS'), __('Import posts from an RSS feed'), array ($rss_import, 'dispatch')); 171 174 ?> -
trunk/wp-admin/import/textpattern.php
r3503 r4431 8 8 { 9 9 global $wpdb; 10 10 11 11 $cat_id -= 0; // force numeric 12 12 $name = $wpdb->get_var('SELECT cat_ID FROM '.$wpdb->categories.' WHERE category_nicename="'.$category_nicename.'"'); 13 13 14 14 return $name; 15 15 } … … 50 50 echo '</div>'; 51 51 } 52 53 function greet() 54 {52 53 function greet() { 54 echo '<div class="narrow">'; 55 55 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>'; 56 56 echo '<p>'.__('Your Textpattern Configuration settings are as follows:').'</p>'; 57 57 echo '<form action="admin.php?import=textpattern&step=1" method="post">'; 58 58 $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').' »" /></p>'; 60 60 echo '</form>'; 61 echo '</div>'; 61 62 } 62 63 … … 68 69 set_magic_quotes_runtime(0); 69 70 $prefix = get_option('tpre'); 70 71 71 72 // Get Categories 72 73 return $txpdb->get_results('SELECT … … 78 79 ARRAY_A); 79 80 } 80 81 81 82 function get_txp_users() 82 83 { … … 86 87 set_magic_quotes_runtime(0); 87 88 $prefix = get_option('tpre'); 88 89 89 90 // Get Users 90 91 91 92 return $txpdb->get_results('SELECT 92 93 user_id, … … 97 98 FROM '.$prefix.'txp_users', ARRAY_A); 98 99 } 99 100 100 101 function get_txp_posts() 101 102 { … … 104 105 set_magic_quotes_runtime(0); 105 106 $prefix = get_option('tpre'); 106 107 107 108 // Get Posts 108 109 return $txpdb->get_results('SELECT … … 123 124 ', ARRAY_A); 124 125 } 125 126 126 127 function get_txp_comments() 127 128 { … … 131 132 set_magic_quotes_runtime(0); 132 133 $prefix = get_option('tpre'); 133 134 134 135 // Get Comments 135 136 return $txpdb->get_results('SELECT * FROM '.$prefix.'txp_discuss', ARRAY_A); 136 137 } 137 138 138 139 function get_txp_links() 139 140 { … … 142 143 set_magic_quotes_runtime(0); 143 144 $prefix = get_option('tpre'); 144 145 145 146 return $txpdb->get_results('SELECT 146 147 id, … … 153 154 ARRAY_A); 154 155 } 155 156 156 157 function cat2wp($categories='') 157 158 { … … 168 169 $count++; 169 170 extract($category); 170 171 171 172 172 173 // Make Nice Variables 173 174 $name = $wpdb->escape($name); 174 175 $title = $wpdb->escape($title); 175 176 176 177 if($cinfo = category_exists($name)) 177 178 { … … 184 185 $txpcat2wpcat[$id] = $ret_id; 185 186 } 186 187 187 188 // Store category translation for future use 188 189 add_option('txpcat2wpcat',$txpcat2wpcat); … … 193 194 return false; 194 195 } 195 196 196 197 function users2wp($users='') 197 198 { … … 200 201 $count = 0; 201 202 $txpid2wpid = array(); 202 203 203 204 // Midnight Mojo 204 205 if(is_array($users)) … … 209 210 $count++; 210 211 extract($user); 211 212 212 213 // Make Nice Variables 213 214 $name = $wpdb->escape($name); 214 215 $RealName = $wpdb->escape($RealName); 215 216 216 217 if($uinfo = get_userdatabylogin($name)) 217 218 { 218 219 219 220 $ret_id = wp_insert_user(array( 220 221 'ID' => $uinfo->ID, … … 237 238 } 238 239 $txpid2wpid[$user_id] = $ret_id; 239 240 240 241 // Set Textpattern-to-WordPress permissions translation 241 242 $transperms = array(1 => '10', 2 => '9', 3 => '5', 4 => '4', 5 => '3', 6 => '2', 7 => '0'); 242 243 243 244 // Update Usermeta Data 244 245 $user = new WP_User($ret_id); … … 250 251 if('2' == $transperms[$privs]) { $user->set_role('contributor'); } 251 252 if('0' == $transperms[$privs]) { $user->set_role('subscriber'); } 252 253 253 254 update_usermeta( $ret_id, 'wp_user_level', $transperms[$privs] ); 254 255 update_usermeta( $ret_id, 'rich_editing', 'false'); 255 256 }// End foreach($users as $user) 256 257 257 258 // Store id translation array for future use 258 259 add_option('txpid2wpid',$txpid2wpid); 259 260 260 261 261 262 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> users imported.'), $count).'<br /><br /></p>'; 262 263 return true; 263 264 }// End if(is_array($users) 264 265 265 266 echo __('No Users to Import!'); 266 267 return false; 267 268 268 269 }// End function user2wp() 269 270 270 271 function posts2wp($posts='') 271 272 { … … 284 285 $count++; 285 286 extract($post); 286 287 287 288 // Set Textpattern-to-WordPress status translation 288 289 $stattrans = array(1 => 'draft', 2 => 'private', 3 => 'draft', 4 => 'publish', 5 => 'publish'); 289 290 290 291 //Can we do this more efficiently? 291 292 $uinfo = ( get_userdatabylogin( $AuthorID ) ) ? get_userdatabylogin( $AuthorID ) : 1; … … 296 297 $Excerpt = $wpdb->escape($Excerpt); 297 298 $post_status = $stattrans[$Status]; 298 299 299 300 // Import Post data into WordPress 300 301 301 302 if($pinfo = post_exists($Title,$Body)) 302 303 { … … 333 334 } 334 335 $txpposts2wpposts[$ID] = $ret_id; 335 336 336 337 // Make Post-to-Category associations 337 338 $cats = array(); … … 339 340 if($cat2 = get_catbynicename($Category2)) { $cats[2] = $cat2; } 340 341 341 if(!empty($cats)) { wp_set_post_cat s('',$ret_id, $cats); }342 if(!empty($cats)) { wp_set_post_categories($ret_id, $cats); } 342 343 } 343 344 } 344 345 // Store ID translation for later use 345 346 add_option('txpposts2wpposts',$txpposts2wpposts); 346 347 347 348 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> posts imported.'), $count).'<br /><br /></p>'; 348 return true; 349 } 350 349 return true; 350 } 351 351 352 function comments2wp($comments='') 352 353 { … … 356 357 $txpcm2wpcm = array(); 357 358 $postarr = get_option('txpposts2wpposts'); 358 359 359 360 // Magic Mojo 360 361 if(is_array($comments)) … … 365 366 $count++; 366 367 extract($comment); 367 368 368 369 // WordPressify Data 369 370 $comment_ID = ltrim($discussid, '0'); … … 374 375 $web = $wpdb->escape($web); 375 376 $message = $wpdb->escape($message); 376 377 377 378 if($cinfo = comment_exists($name, $posted)) 378 379 { … … 406 407 } 407 408 // Store Comment ID translation for future use 408 add_option('txpcm2wpcm', $txpcm2wpcm); 409 409 add_option('txpcm2wpcm', $txpcm2wpcm); 410 410 411 // Associate newly formed categories with posts 411 412 get_comment_count($ret_id); 412 413 413 414 414 415 echo '<p>'.sprintf(__('Done! <strong>%1$s</strong> comments imported.'), $count).'<br /><br /></p>'; 415 416 return true; … … 418 419 return false; 419 420 } 420 421 421 422 function links2wp($links='') 422 423 { … … 424 425 global $wpdb; 425 426 $count = 0; 426 427 427 428 // Deal with the links 428 429 if(is_array($links)) … … 433 434 $count++; 434 435 extract($link); 435 436 436 437 // Make nice vars 437 438 $category = $wpdb->escape($category); 438 439 $linkname = $wpdb->escape($linkname); 439 440 $description = $wpdb->escape($description); 440 441 441 442 if($linfo = link_exists($linkname)) 442 443 { … … 471 472 return false; 472 473 } 473 474 474 475 function import_categories() 475 { 476 // Category Import 476 { 477 // Category Import 477 478 $cats = $this->get_txp_cats(); 478 479 $this->cat2wp($cats); 479 480 add_option('txp_cats', $cats); 480 481 482 481 482 483 483 484 echo '<form action="admin.php?import=textpattern&step=2" method="post">'; 484 485 printf('<input type="submit" name="submit" value="%s" />', __('Import Users')); … … 486 487 487 488 } 488 489 489 490 function import_users() 490 491 { … … 492 493 $users = $this->get_txp_users(); 493 494 $this->users2wp($users); 494 495 495 496 echo '<form action="admin.php?import=textpattern&step=3" method="post">'; 496 497 printf('<input type="submit" name="submit" value="%s" />', __('Import Posts')); 497 498 echo '</form>'; 498 499 } 499 500 500 501 function import_posts() 501 502 { … … 503 504 $posts = $this->get_txp_posts(); 504 505 $this->posts2wp($posts); 505 506 506 507 echo '<form action="admin.php?import=textpattern&step=4" method="post">'; 507 508 printf('<input type="submit" name="submit" value="%s" />', __('Import Comments')); 508 509 echo '</form>'; 509 510 } 510 511 511 512 function import_comments() 512 513 { … … 514 515 $comments = $this->get_txp_comments(); 515 516 $this->comments2wp($comments); 516 517 517 518 echo '<form action="admin.php?import=textpattern&step=5" method="post">'; 518 519 printf('<input type="submit" name="submit" value="%s" />', __('Import Links')); 519 520 echo '</form>'; 520 521 } 521 522 522 523 function import_links() 523 524 { … … 526 527 $this->links2wp($links); 527 528 add_option('txp_links', $links); 528 529 529 530 echo '<form action="admin.php?import=textpattern&step=6" method="post">'; 530 531 printf('<input type="submit" name="submit" value="%s" />', __('Finish')); 531 532 echo '</form>'; 532 533 } 533 534 534 535 function cleanup_txpimport() 535 536 { … … 547 548 $this->tips(); 548 549 } 549 550 550 551 function tips() 551 552 { … … 556 557 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>'; 557 558 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>'; 559 560 echo '<h3>'.__('WordPress Resources').'</h3>'; 560 561 echo '<p>'.__('Finally, there are numerous WordPress resources around the internet. Some of them are:').'</p>'; 561 562 echo '<ul>'; 562 563 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>'; 564 565 echo '<li>'.__('<a href="http://codex.wordpress.org">The Codex (In other words, the WordPress Bible)</a>').'</li>'; 565 566 echo '</ul>'; 566 567 echo '<p>'.sprintf(__('That\'s it! What are you waiting for? Go <a href="%1$s">login</a>!'), '/wp-login.php').'</p>'; 567 568 } 568 569 569 570 function db_form() 570 571 { 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 580 581 function dispatch() 581 582 { … … 586 587 $step = (int) $_GET['step']; 587 588 $this->header(); 588 589 589 590 if ( $step > 0 ) 590 591 { … … 592 593 { 593 594 if(get_option('txpuser')) 594 delete_option('txpuser'); 595 delete_option('txpuser'); 595 596 add_option('txpuser',$_POST['dbuser']); 596 597 } … … 598 599 { 599 600 if(get_option('txppass')) 600 delete_option('txppass'); 601 delete_option('txppass'); 601 602 add_option('txppass',$_POST['dbpass']); 602 603 } 603 604 604 605 if($_POST['dbname']) 605 606 { 606 607 if(get_option('txpname')) 607 delete_option('txpname'); 608 delete_option('txpname'); 608 609 add_option('txpname',$_POST['dbname']); 609 610 } … … 619 620 delete_option('tpre'); 620 621 add_option('tpre',$_POST['dbprefix']); 621 } 622 } 622 623 623 624 … … 649 650 break; 650 651 } 651 652 652 653 $this->footer(); 653 654 } … … 655 656 function Textpattern_Import() 656 657 { 657 // Nothing. 658 // Nothing. 658 659 } 659 660 } 660 661 661 662 $txp_import = new Textpattern_Import(); 662 register_importer('textpattern', 'Textpattern', __('Import posts from a Textpattern Blog'), array ($txp_import, 'dispatch'));663 register_importer('textpattern', __('Textpattern'), __('Import posts from a Textpattern Blog'), array ($txp_import, 'dispatch')); 663 664 ?> -
trunk/wp-admin/index.php
r3503 r4431 2 2 require_once('admin.php'); 3 3 $title = __('Dashboard'); 4 $parent_file = 'index.php'; 4 5 require_once('admin-header.php'); 5 require_once (ABSPATH . WPINC . '/rss -functions.php');6 require_once (ABSPATH . WPINC . '/rss.php'); 6 7 7 8 $today = current_time('mysql', 1); … … 10 11 <div class="wrap"> 11 12 12 <h2><?php _e(' Dashboard'); ?></h2>13 <h2><?php _e('Welcome to WordPress'); ?></h2> 13 14 14 15 <div id="zeitgeist"> … … 20 21 ?> 21 22 <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 '); ?> »</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 »'); ?></a></cite></h3> 23 24 <ul> 24 25 <?php … … 26 27 foreach ($rss->items as $item ) { 27 28 ?> 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> 29 30 <?php } ?> 30 31 </ul> … … 44 45 <p><strong><a href="moderation.php"><?php echo sprintf(__('Comments in moderation (%s)'), number_format($numcomments) ); ?> »</a></strong></p> 45 46 <?php endif; ?> 46 </div>47 47 48 48 <ul> … … 57 57 ?> 58 58 </ul> 59 59 </div> 60 60 <?php endif; ?> 61 61 62 62 <?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") ) :63 if ( $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") ) : 64 64 ?> 65 65 <div> … … 80 80 81 81 <?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") ) :82 if ( $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") ) : 83 83 ?> 84 84 <div> … … 99 99 <h3><?php _e('Blog Stats'); ?></h3> 100 100 <?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'"); 102 102 if (0 < $numposts) $numposts = number_format($numposts); 103 103 … … 114 114 </div> 115 115 116 <h3><?php _e('Welcome to WordPress'); ?></h3>117 118 116 <p><?php _e('Use these links to get started:'); ?></p> 119 117 120 118 <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’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’s look or theme'); ?></a></li> 128 <?php endif; ?> 125 129 </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> 128 131 <?php 129 132 $rss = @fetch_rss('http://wordpress.org/development/feed/'); 130 133 if ( isset($rss->items) && 0 != count($rss->items) ) { 131 134 ?> 135 <div id="devnews"> 132 136 <h3><?php _e('WordPress Development Blog'); ?></h3> 133 137 <?php … … 141 145 } 142 146 ?> 143 147 </div> 144 148 145 149 <?php … … 148 152 ?> 149 153 <div id="planetnews"> 150 <h3><?php _e('Other WordPress News'); ?> <a href="http://planet.wordpress.org/"><?php _e('more'); ?> »</a></h3>154 <h3><?php _e('Other WordPress News'); ?></h3> 151 155 <ul> 152 156 <?php 153 157 $rss->items = array_slice($rss->items, 0, 20); 154 158 foreach ($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'] ); 155 162 ?> 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> 157 164 <?php 158 165 } 159 166 ?> 160 167 </ul> 168 <p class="readmore"><a href="http://planet.wordpress.org/"><?php _e('Read more'); ?> »</a></p> 161 169 </div> 162 170 <?php -
trunk/wp-admin/install.php
r3503 r4431 1 1 <?php 2 2 define('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."); 3 if (!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 › Error"); 6 } 5 7 6 8 require_once('../wp-config.php'); 7 9 require_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']) );11 10 12 11 if (isset($_GET['step'])) … … 17 16 ?> 18 17 <!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(); ?>> 20 19 <head> 20 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 21 21 <title><?php _e('WordPress › 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; ?> 75 26 </head> 76 27 <body> … … 78 29 <?php 79 30 // 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(); 31 if ( 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>'); 84 32 85 33 switch($step) { 86 87 34 case 0: 88 35 ?> 89 36 <p><?php printf(__('Welcome to WordPress installation. We’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 »'); ?></a></h2>37 <h2 class="step"><a href="install.php?step=1"><?php _e('First Step »'); ?></a></h2> 91 38 <?php 92 break; 93 39 break; 94 40 case 1: 95 96 41 ?> 97 42 <h1><?php _e('First Step'); ?></h1> … … 99 44 100 45 <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 »'); ?>" /> 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 »'); ?>" /></h2> 115 62 </form> 116 63 117 64 <?php 118 break;65 break; 119 66 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 } 120 77 121 // Fill in the data we gathered122 $weblog_title = stripslashes($_POST['weblog_title']);123 $admin_email = stripslashes($_POST['admin_email']);124 // check e-mail address125 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 131 78 ?> 132 79 <h1><?php _e('Second Step'); ?></h1> … … 135 82 136 83 <?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); 204 86 ?> 205 87 206 88 <p><em><?php _e('Finished!'); ?></em></p> 207 89 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 211 93 <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> 216 98 <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> 218 100 </dl> 219 101 <p><?php _e('Were you expecting more steps? Sorry to disappoint. All done! :)'); ?></p> 102 220 103 <?php 221 break;104 break; 222 105 } 223 106 ?> 107 224 108 <p id="footer"><?php _e('<a href="http://wordpress.org/">WordPress</a>, personal publishing platform.'); ?></p> 225 109 </body> -
trunk/wp-admin/link-add.php
r3503 r4431 2 2 require_once('admin.php'); 3 3 4 $title = __('Add Link');4 $title = __('Add Bookmark'); 5 5 $this_file = 'link-manager.php'; 6 6 $parent_file = 'link-manager.php'; 7 7 8 8 9 $wpvarstoreset =array('action', 'cat_id', 'linkurl', 'name', 'image',9 wp_reset_vars(array('action', 'cat_id', 'linkurl', 'name', 'image', 10 10 'description', 'visible', 'target', 'category', 'link_id', 11 11 '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[]')); 27 13 28 $xfn_js = true; 14 wp_enqueue_script( array('xfn', 'dbx-admin-key?pagenow=link.php') ); 15 if ( current_user_can( 'manage_categories' ) ) 16 wp_enqueue_script( 'ajaxcat' ); 29 17 require('admin-header.php'); 30 18 ?> … … 39 27 ?> 40 28 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’re on to your links! Right now this only works on Mozilla or Netscape, but we’re working on it.</p>'), "javascript:void(linkmanpopup=window.open('" . get_settings('siteurl') . "/wp-admin/link-add.php?action=popup&linkurl='+escape(location.href)+'&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&linkurl='+escape(location.href)+'&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();") ?> 43 33 </div> 44 34 -
trunk/wp-admin/link-import.php
r3503 r4431 17 17 include_once('admin-header.php'); 18 18 if ( !current_user_can('manage_links') ) 19 die (__("Cheatin’ uh?"));19 wp_die(__('Cheatin’ uh?')); 20 20 21 21 $opmltype = 'blogrolling'; // default. … … 25 25 <h2><?php _e('Import your blogroll from another system') ?> </h2> 26 26 <form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll"> 27 <?php wp_nonce_field('import-bookmarks') ?> 27 28 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.'); ?> 29 30 <div style="width: 70%; margin: auto; height: 8em;"> 30 31 <input type="hidden" name="step" value="1" /> … … 43 44 </div> 44 45 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 /> 46 47 <?php _e('Category:') ?> <select name="cat_id"> 47 48 <?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'); 49 50 foreach ($categories as $category) { 50 51 ?> 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> 52 53 <?php 53 54 } // end foreach … … 55 56 </select></p> 56 57 57 <p class="submit"><input type="submit" name="submit" value="<?php _e('Import OPML File ') ?> »" /></p>58 <p class="submit"><input type="submit" name="submit" value="<?php _e('Import OPML File »') ?>" /></p> 58 59 </form> 59 60 … … 64 65 65 66 case 1: { 67 check_admin_referer('import-bookmarks'); 68 66 69 include_once('admin-header.php'); 67 70 if ( !current_user_can('manage_links') ) 68 die (__("Cheatin' uh ?"));71 wp_die(__('Cheatin’ uh?')); 69 72 ?> 70 73 <div class="wrap"> … … 87 90 88 91 if ( isset($file['error']) ) 89 die($file['error']);92 wp_die($file['error']); 90 93 91 94 $url = $file['url']; … … 104 107 if ('http' == substr($titles[$i], 0, 4)) 105 108 $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); 110 111 echo sprintf('<p>'.__('Inserted <strong>%s</strong>').'</p>', $names[$i]); 111 112 } 112 113 ?> 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> 114 115 <?php 115 116 } // end if got url -
trunk/wp-admin/link-manager.php
r3503 r4431 1 1 <?php 2 3 2 4 // Links 3 5 // Copyright (C) 2002, 2003 Mike Little -- mike@zed1.com 4 6 5 require_once ('admin.php');7 require_once ('admin.php'); 6 8 7 $title = __('Manage Links');9 $title = __('Manage Bookmarks'); 8 10 $this_file = $parent_file = 'link-manager.php'; 9 $list_js = true;11 wp_enqueue_script( 'listman' ); 10 12 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[]'); 13 wp_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[]')); 15 14 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 } 15 if (empty ($cat_id)) 16 $cat_id = 'all'; 17 18 if (empty ($order_by)) 19 $order_by = 'order_name'; 20 21 $title = __('Manage Bookmarks'); 22 include_once ("./admin-header.php"); 23 24 if (!current_user_can('manage_links')) 25 wp_die(__("You do not have sufficient permissions to edit the bookmarks for this blog.")); 26 27 switch ($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; 29 47 } 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 >= the49 //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 change62 $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 visibility77 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 proceed85 $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 change92 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 value114 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 change120 $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 Add135 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 Save157 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 Delete181 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 linkedit196 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 through209 } // end Show210 case "popup":211 {212 $link_url = stripslashes($_GET["linkurl"]);213 $link_name = stripslashes($_GET["name"]);214 //break; fall through215 }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") {251 48 ?> 252 49 <script type="text/javascript"> … … 266 63 </script> 267 64 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> </td>279 </tr>280 <tr>281 <td>282 65 <?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"; 66 if ( 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 } 299 72 ?> 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>317 73 318 </div>319 320 <form name="links" id="links" method="post" action="">321 74 <div class="wrap"> 322 75 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> </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’s called a “blogroll.”'); ?></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"; 83 foreach ((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 93 printf(__('Currently showing %1$s links ordered by %2$s'), $select_cat, $select_order); 94 ?> 95 <input type="submit" name="action" value="<?php _e('Update »') ?>" /></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"> 338 117 <?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 "; 118 if ( 'all' == $cat_id ) 119 $cat_id = ''; 120 $links = get_bookmarks("category=$cat_id&hide_invisible=0&orderby=$sqlorderby&hide_empty=0"); 121 if ($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).'...'; 345 133 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 350 141 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).'...';365 142 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.'&action=edit" class="edit">'.__('Edit').'</a></td>'; 165 echo '<td><a href="' . wp_nonce_url('link.php?link_id='.$link->link_id.'&action=delete', 'delete-bookmark_' . $link->link_id ) . '"'." onclick=\"return deleteSomething( 'link', $link->link_id , '".sprintf(__("You are about to delete the "%s" bookmark to %s.\\n"Cancel" to stop, "OK" 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 } 370 169 ?> 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 . '&action=linkedit" class="edit">' . __('Edit') . '</a></td>'; 386 echo '<td><a href="link-manager.php?link_id=' . $link->link_id . '&action=Delete"' . " onclick=\"return deleteSomething( 'link', $link->link_id , '" . sprintf(__("You are about to delete the "%s" link to %s.\\n"Cancel" to stop, "OK" 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> </td><td> </td><td> </td>\n"; 390 } 391 echo "\n </tr>\n"; 392 } 393 } 394 ?> 170 </tbody> 395 171 </table> 396 172 397 173 <div id="ajax-response"></div> 398 174 175 <p class="submit"><input type="submit" class="button" name="deletebookmarks" id="deletebookmarks" value="<?php _e('Delete Checked Bookmarks') ?> »" onclick="return confirm('<?php _e("You are about to delete these bookmarks permanently \\n \'Cancel\' to stop, \'OK\' to delete.") ?>')" /></p> 176 </form> 399 177 </div> 400 178 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 <?php409 $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 <?php433 } // end if !popup434 ?>435 </div>436 </form>437 438 439 <?php440 break;441 } // end default442 } // end case443 ?>444 445 179 <?php include('admin-footer.php'); ?> -
trunk/wp-admin/menu-header.php
r3503 r4431 12 12 if (( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file))) $class = ' class="current"'; 13 13 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>"; 17 17 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>"; 19 19 } 20 20 } … … 41 41 $menu_hook = get_plugin_page_hook($item[2], $parent_file); 42 42 43 if (file_exists(ABSPATH . "wp-content/plugins/{$item[2]}") || ! empty($menu_hook)) {43 if (file_exists(ABSPATH . PLUGINDIR . "/{$item[2]}") || ! empty($menu_hook)) { 44 44 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>"; 46 46 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>"; 48 48 } 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>"; 50 50 } 51 51 endforeach; … … 53 53 54 54 </ul> 55 <?php endif; ?> 55 <?php 56 else : 57 ?> 58 <div id="minisub"></div> 59 <?php 60 61 endif; 62 63 do_action('admin_notices'); 64 65 ?> -
trunk/wp-admin/menu.php
r3503 r4431 6 6 // The URL of the item's file 7 7 $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 9 if ( strstr($_SERVER['REQUEST_URI'], 'edit-pages.php') ) 10 $menu[5] = array(__('Write'), 'edit_pages', 'page-new.php'); 11 else 12 $menu[5] = array(__('Write'), 'edit_posts', 'post-new.php'); 13 if ( strstr($_SERVER['REQUEST_URI'], 'page-new.php') ) 14 $menu[10] = array(__('Manage'), 'edit_pages', 'edit-pages.php'); 15 else 16 $menu[10] = array(__('Manage'), 'edit_posts', 'edit.php'); 17 18 $menu[20] = array(__('Blogroll'), 'manage_links', 'link-manager.php'); 11 19 $menu[25] = array(__('Presentation'), 'switch_themes', 'themes.php'); 12 20 $menu[30] = array(__('Plugins'), 'activate_plugins', 'plugins.php'); 13 21 if ( current_user_can('edit_users') ) 14 $menu[35] = array(__('Users'), ' read', 'profile.php');22 $menu[35] = array(__('Users'), 'edit_users', 'users.php'); 15 23 else 16 24 $menu[35] = array(__('Profile'), 'read', 'profile.php'); 17 25 $menu[40] = array(__('Options'), 'manage_options', 'options-general.php'); 18 $menu[45] = array(__('Import'), 'import', 'import.php');19 26 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'); 22 30 23 31 $submenu['edit.php'][5] = array(__('Posts'), 'edit_posts', 'edit.php'); 24 32 $submenu['edit.php'][10] = array(__('Pages'), 'edit_pages', 'edit-pages.php'); 33 $submenu['edit.php'][12] = array(__('Uploads'), 'upload_files', 'upload.php'); 25 34 $submenu['edit.php'][15] = array(__('Categories'), 'manage_categories', 'categories.php'); 26 35 $submenu['edit.php'][20] = array(__('Comments'), 'edit_posts', 'edit-comments.php'); 27 36 $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'); 29 38 $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'); 30 41 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'); 32 43 $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');34 44 $submenu['link-manager.php'][20] = array(__('Import Links'), 'manage_links', 'link-import.php'); 35 45 36 $submenu['profile.php'][5] = array(__('Your Profile'), 'read', 'profile.php'); 37 $submenu['profile.php'][10] = array(__('Authors & Users'), 'edit_users', 'users.php'); 46 if ( 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 & 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 } 38 53 39 54 $submenu['options-general.php'][10] = array(__('General'), 'manage_options', 'options-general.php'); … … 41 56 $submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php'); 42 57 $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'); 45 61 46 62 $submenu['plugins.php'][5] = array(__('Plugins'), 'activate_plugins', 'plugins.php'); … … 55 71 } 56 72 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. 76 foreach ($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. 91 foreach ( $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 57 113 do_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. 117 foreach ( $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 128 unset($id); 129 130 uksort($menu, "strnatcasecmp"); // make it all pretty 59 131 60 132 if (! 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.') ); 62 134 } 63 135 -
trunk/wp-admin/moderation.php
r3503 r4431 4 4 $title = __('Moderate comments'); 5 5 $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 } 6 wp_enqueue_script( 'admin-comments' ); 7 8 wp_reset_vars(array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky')); 23 9 24 10 $comment = array(); … … 33 19 case 'update': 34 20 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.')); 37 25 38 26 $item_ignored = 0; … … 60 48 case 'approve': 61 49 wp_set_comment_status($key, 'approve'); 62 if ( get_ settings('comments_notify') == true ) {50 if ( get_option('comments_notify') == true ) { 63 51 wp_notify_postauthor($key); 64 52 } … … 69 57 70 58 $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"); 72 60 exit(); 73 61 … … 116 104 117 105 ?> 118 106 119 107 <div class="wrap"> 120 108 … … 131 119 <h2><?php _e('Moderation Queue') ?></h2> 132 120 <form name="approval" action="moderation.php" method="post"> 121 <?php wp_nonce_field('moderate-comments') ?> 133 122 <input type="hidden" name="action" value="update" /> 134 <ol id="the- list" class="commentlist">123 <ol id="the-comment-list" class="commentlist"> 135 124 <?php 136 125 $i = 0; 137 126 foreach($comments as $comment) { 138 127 ++$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); 140 129 $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'>"; 144 133 ?> 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> 146 135 <?php comment_text() ?> 147 <p><?php 148 echo '<a href="post.php?action=editcomment&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&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" 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'); ?> — [ <?php 137 echo '<a href="comment.php?action=editcomment&comment='.$comment->comment_ID.'">' . __('Edit') . '</a> | '; 138 echo " <a href=\"post.php?action=deletecomment&p=".$comment->comment_post_ID."&comment=".$comment->comment_ID."\" onclick=\"return deleteSomething( 'comment', $comment->comment_ID, '" . sprintf(__("You are about to delete this comment by "%s".\\n"Cancel" to stop, "OK" 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> ] — 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> 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> 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> 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> 156 150 </p> 157 151 … … 164 158 <div id="ajax-response"></div> 165 159 166 <p class="submit"><input type="submit" name="submit" value="<?php _e(' Moderate Comments »') ?>" /></p>160 <p class="submit"><input type="submit" name="submit" value="<?php _e('Bulk Moderate Comments »') ?>" /></p> 167 161 <script type="text/javascript"> 168 162 // <![CDATA[ … … 220 214 221 215 222 include('admin-footer.php') ?> 216 include('admin-footer.php'); 217 218 ?> -
trunk/wp-admin/options-discussion.php
r3503 r4431 6 6 7 7 include('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 }19 8 ?> 20 9 … … 22 11 <h2><?php _e('Discussion Options') ?></h2> 23 12 <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 »') ?>" /></p> 24 15 <fieldset class="options"> 25 16 <legend><?php _e('Usual settings for an article:<br /><small><em>(These settings may be overridden for individual articles.)</em></small>') ?></legend> … … 27 18 <li> 28 19 <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')); ?> /> 30 21 <?php _e('Attempt to notify any Weblogs linked to from the article (slows down posting.)') ?></label> 31 22 </li> 32 23 <li> 33 24 <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')); ?> /> 35 26 <?php _e('Allow link notifications from other Weblogs (pingbacks and trackbacks.)') ?></label> 36 27 </li> 37 28 <li> 38 29 <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')); ?> /> 40 31 <?php _e('Allow people to post comments on the article') ?></label> 41 32 </li> … … 47 38 <li> 48 39 <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')); ?> /> 50 41 <?php _e('Anyone posts a comment') ?> </label> 51 42 </li> 52 43 <li> 53 44 <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')); ?> /> 55 46 <?php _e('A comment is held for moderation') ?> </label> 56 47 </li> … … 62 53 <li> 63 54 <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 a pprove 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> 66 57 </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> 69 60 </ul> 70 61 </fieldset> 71 62 <fieldset class="options"> 72 63 <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> 74 65 75 <p><?php _e('When a comment contains any of these words in its content, name, UR I, 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> 76 67 <p> 77 68 <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>81 69 </p> 82 70 </fieldset> 83 71 <fieldset class="options"> 84 72 <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> 86 74 <p> 87 75 <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> 88 76 </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>92 77 </fieldset> 93 78 <p class="submit"> 94 79 <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 »') ?>" /> 82 </p> 83 </form> 99 84 </div> 85 100 86 <?php include('./admin-footer.php'); ?> -
trunk/wp-admin/options-general.php
r3503 r4431 11 11 <h2><?php _e('General Options') ?></h2> 12 12 <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 »') ?>" /></p> 13 15 <table class="optiontable"> 14 16 <tr valign="top"> … … 23 25 </tr> 24 26 <tr valign="top"> 25 <th scope="row"><?php _e('WordPress address (UR I):') ?></th>27 <th scope="row"><?php _e('WordPress address (URL):') ?></th> 26 28 <td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>" size="40" class="code" /></td> 27 29 </tr> 28 30 <tr valign="top"> 29 <th scope="row"><?php _e('Blog address (UR I):') ?></th>31 <th scope="row"><?php _e('Blog address (URL):') ?></th> 30 32 <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> 31 33 </tr> … … 39 41 <th scope="row"><?php _e('Membership:') ?></th> 40 42 <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')); ?> /> 42 44 <?php _e('Anyone can register') ?></label><br /> 43 45 <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')); ?> /> 45 47 <?php _e('Users must be registered and logged in to comment') ?> 46 48 </label> … … 50 52 <th scope="row"><?php _e('New User Default Role:') ?></th> 51 53 <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> 58 55 </td> 59 56 </tr> … … 69 66 <th scope="row"><?php _e('Times in the weblog should differ by:') ?> </th> 70 67 <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> 72 69 </tr> 73 70 <tr> 74 71 <th scope="row"><?php _e('Default date format:') ?></th> 75 72 <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> 77 74 </tr> 78 75 <tr> 79 76 <th scope="row"><?php _e('Default time format:') ?></th> 80 77 <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> 82 79 </tr> 83 80 <tr> 84 81 <th scope="row"> </th> 85 <td><?php _e('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Save optionto 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> 86 83 </tr> 87 84 <tr> … … 90 87 <?php 91 88 for ($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>'; 95 91 endfor; 96 92 ?> … … 100 96 </fieldset> 101 97 102 <p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options ') ?> »" />98 <p class="submit"><input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /> 103 99 <input type="hidden" name="action" value="update" /> 104 100 <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')); ?> 19 2 20 3 <br clear="all" /> -
trunk/wp-admin/options-misc.php
r3503 r4431 12 12 <h2><?php _e('Miscellaneous Options') ?></h2> 13 13 <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 »') ?>" /></p> 15 16 <fieldset class="options"> 16 17 <legend><?php _e('Uploading'); ?></legend> … … 18 19 <tr valign="top"> 19 20 <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" /> 21 22 <br /> 22 23 <?php _e('Default is <code>wp-content/uploads</code>'); ?> … … 27 28 <td> 28 29 <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')); ?> /> 30 31 <?php _e('Organize my uploads into month- and year-based folders'); ?> 31 32 </label> … … 35 36 </fieldset> 36 37 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’ 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’ Update Times') ?></label></p> 39 40 <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> 41 42 </p> 42 43 … … 44 45 <input type="hidden" name="action" value="update" /> 45 46 <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 ') ?> »" />47 <input type="submit" name="Submit" value="<?php _e('Update Options »') ?>" /> 47 48 </p> 48 49 </form> -
trunk/wp-admin/options-permalink.php
r3503 r4431 42 42 var aInputs = document.getElementsByTagName('input'); 43 43 44 for (var i = 0; i < aInputs.length; i++) { 44 for (var i = 0; i < aInputs.length; i++) { 45 45 aInputs[i].onclick = aInputs[i].onkeyup = upit; 46 46 } … … 58 58 $home_path = get_home_path(); 59 59 60 if ( isset($_POST) ) { 60 if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) { 61 check_admin_referer('update-permalink'); 62 61 63 if ( isset($_POST['permalink_structure']) ) { 62 64 $permalink_structure = $_POST['permalink_structure']; … … 65 67 $wp_rewrite->set_permalink_structure($permalink_structure); 66 68 } 67 69 68 70 if ( isset($_POST['category_base']) ) { 69 71 $category_base = $_POST['category_base']; … … 73 75 } 74 76 } 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'); 78 80 79 81 if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') ) … … 101 103 <div class="wrap"> 102 104 <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 »') ?>" /></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> 104 109 105 110 <?php … … 115 120 ); 116 121 ?> 117 <form name="form" action="options-permalink.php" method="post">118 122 <h3><?php _e('Common options:'); ?></h3> 119 123 <p> 120 124 <label> 121 125 <input name="selection" type="radio" value="" class="tog" <?php checked('', $permalink_structure); ?> /> 122 <?php _e('Default'); ?><br /> <span> » <code><?php echo get_ settings('home'); ?>/?p=123</code></span>126 <?php _e('Default'); ?><br /> <span> » <code><?php echo get_option('home'); ?>/?p=123</code></span> 123 127 </label> 124 128 </p> … … 126 130 <label> 127 131 <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> » <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> » <code><?php echo get_option('home') . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/sample-post/'; ?></code></span> 129 133 </label> 130 134 </p> … … 132 136 <label> 133 137 <input name="selection" type="radio" value="<?php echo $structures[2]; ?>" class="tog" <?php checked($structures[2], $permalink_structure); ?> /> 134 <?php _e('Numeric'); ?><br /> <span> » <code><?php echo get_ settings('home') . $prefix ; ?>/archives/123</code></span>138 <?php _e('Numeric'); ?><br /> <span> » <code><?php echo get_option('home') . $prefix ; ?>/archives/123</code></span> 135 139 </label> 136 140 </p> … … 142 146 <?php } ?> 143 147 /> 144 <?php _e('Custom, specify below'); ?> 148 <?php _e('Custom, specify below'); ?> 145 149 </label> 146 150 <br /> 147 151 </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> 149 153 150 154 <h3><?php _e('Optional'); ?></h3> 151 155 <?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> 153 157 <?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> 155 159 <?php endif; ?> 156 160 <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" /> 158 162 </p> 159 163 <p class="submit"> … … 164 168 <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’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> 165 169 <form action="options-permalink.php" method="post"> 170 <?php wp_nonce_field('update-permalink') ?> 166 171 <p> 167 172 <textarea rows="5" style="width: 98%;" name="rules"><?php echo $wp_rewrite->mod_rewrite_rules(); ?> -
trunk/wp-admin/options-reading.php
r3503 r4431 10 10 <div class="wrap"> 11 11 <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 »') ?>" /></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 13 50 <fieldset class="options"> 14 51 <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"> 16 53 <tr valign="top"> 17 54 <th width="33%" scope="row"><?php _e('Show at most:') ?></th> … … 19 56 <input name="posts_per_page" type="text" id="posts_per_page" value="<?php form_option('posts_per_page'); ?>" size="3" /> 20 57 <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> 23 60 </select> 24 61 </td> … … 29 66 <fieldset class="options"> 30 67 <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"> 32 69 <tr valign="top"> 33 70 <th width="33%" scope="row"><?php _e('Show the most recent:') ?></th> … … 37 74 <th scope="row"><?php _e('For each article, show:') ?> </th> 38 75 <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><--more--></code> feature, it will cut off posts in RSS feeds.'); ?></p> 41 79 </td> 42 80 </tr> 43 81 </table> 44 82 </fieldset> 45 <table width="100%" cellspacing="2" cellpadding="5" class=" editform">83 <table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform"> 46 84 <tr valign="top"> 47 85 <th width="33%" scope="row"><?php _e('Encoding for pages and feeds:') ?></th> … … 51 89 </table> 52 90 <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')); ?> /> 54 92 <?php _e('WordPress should compress articles (gzip) if browsers ask for them') ?></label> 55 93 </p> 56 94 <p class="submit"> 57 95 <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 ') ?> »" />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 »') ?>" /> 60 98 </p> 61 99 </form> -
trunk/wp-admin/options-writing.php
r3503 r4431 11 11 <h2><?php _e('Writing Options') ?></h2> 12 12 <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 »') ?>" /></p> 15 <table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform"> 14 16 <tr valign="top"> 15 17 <th width="33%" scope="row"> <?php _e('Size of the post box:') ?></th> … … 21 23 <td> 22 24 <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')); ?> /> 24 26 <?php _e('Users should use the visual rich editor by default') ?></label><br /> 25 27 <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')); ?> /> 27 29 <?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> 29 31 </td> 30 32 </tr> … … 35 37 $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories ORDER BY cat_name"); 36 38 foreach ($categories as $category) : 37 if ($category->cat_ID == get_settings('default_category')) $selected = " selected='selected'"; 39 if ($category->cat_ID == get_option('default_category')) $selected = " selected='selected'"; 40 else $selected = ''; 41 echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>"; 42 endforeach; 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 50 foreach ($categories as $category) : 51 if ($category->cat_ID == get_option('default_link_category')) $selected = " selected='selected'"; 38 52 else $selected = ''; 39 53 echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>"; … … 45 59 46 60 <fieldset class="options"> 47 <legend><?php _e(' Writing bye-mail') ?></legend>61 <legend><?php _e('Post via e-mail') ?></legend> 48 62 <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’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> 49 63 50 <table width="100%" cellspacing="2" cellpadding="5" class=" editform">64 <table width="100%" cellspacing="2" cellpadding="5" class="optiontable editform"> 51 65 <tr valign="top"> 52 66 <th scope="row"><?php _e('Mail server:') ?></th> … … 67 81 </tr> 68 82 <tr valign="top"> 69 <th scope="row"><?php _e('Default post bymail category:') ?></th>83 <th scope="row"><?php _e('Default mail category:') ?></th> 70 84 <td><select name="default_email_category" id="default_email_category"> 71 85 <?php 72 86 //Alreay have $categories from default_category 73 87 foreach ($categories as $category) : 74 if ($category->cat_ID == get_ settings('default_email_category')) $selected = " selected='selected'";88 if ($category->cat_ID == get_option('default_email_category')) $selected = " selected='selected'"; 75 89 else $selected = ''; 76 90 echo "\n\t<option value='$category->cat_ID' $selected>$category->cat_name</option>"; … … 84 98 <fieldset class="options"> 85 99 <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> 87 104 88 105 <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 89 113 </fieldset> 90 114 91 115 <p class="submit"> 92 116 <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 ') ?> »" />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 »') ?>" /> 95 119 </p> 96 120 </form> -
trunk/wp-admin/options.php
r3503 r4431 6 6 $parent_file = 'options-general.php'; 7 7 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 } 8 wp_reset_vars(array('action')); 23 9 24 10 if ( !current_user_can('manage_options') ) 25 die ( __('Cheatin’ uh?') ); 11 wp_die(__('Cheatin’ uh?')); 12 13 function 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 } 26 83 27 84 switch($action) { … … 29 86 case 'update': 30 87 $any_changed = 0; 31 32 check_admin_referer();33 88 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; 37 95 } 38 96 } else { … … 40 98 } 41 99 42 // Save for later.43 $old_siteurl = get_settings('siteurl');44 $old_home = get_settings('home');45 46 // HACK47 // Options that if not there have 0 value but need to be something like "closed"48 $nonbools = array('default_ping_status', 'default_comment_status');49 100 if ($options) { 50 101 foreach ($options as $option) { 51 102 $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); 63 106 } 64 107 } 65 108 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()); 84 111 $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback); 85 112 wp_redirect($goback); … … 90 117 91 118 <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') ?> 94 122 <input type="hidden" name="action" value="update" /> 123 <p class="submit"><input type="submit" name="Update" value="<?php _e('Update Options »') ?>" /></p> 95 124 <table width="98%"> 96 125 <?php 97 126 $options = $wpdb->get_results("SELECT * FROM $wpdb->options ORDER BY option_name"); 98 127 99 foreach ($options as $option) : 100 $value = wp_specialchars($option->option_value); 128 foreach ( (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 } 101 146 echo " 102 147 <tr> 103 148 <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> 105 155 <td>$option->option_description</td> 106 156 </tr>"; … … 108 158 ?> 109 159 </table> 110 <p class="submit"><input type="submit" name="Update" value="<?php _e('Update Settings »') ?>" /></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 »') ?>" /></p> 111 162 </form> 112 163 </div> -
trunk/wp-admin/page-new.php
r3503 r4431 2 2 require_once('admin.php'); 3 3 $title = __('New Page'); 4 $parent_file = 'post .php';4 $parent_file = 'post-new.php'; 5 5 $editing = true; 6 wp_enqueue_script('prototype'); 7 wp_enqueue_script('autosave'); 6 8 require_once('admin-header.php'); 7 9 ?> 8 10 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'); ?> »</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') ; ?> »</a></p></div> 11 13 <?php endif; ?> 12 14 … … 14 16 if ( current_user_can('edit_pages') ) { 15 17 $action = 'post'; 16 get_currentuserinfo();17 18 18 $post = get_default_post_to_edit(); 19 $post->post_ status = 'static';19 $post->post_type = 'page'; 20 20 21 21 include('edit-page-form.php'); -
trunk/wp-admin/plugin-editor.php
r3503 r4431 5 5 $parent_file = 'plugins.php'; 6 6 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 } 7 wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file')); 22 8 23 9 $plugins = get_plugins(); … … 29 15 30 16 $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"); 32 18 33 19 switch($action) { … … 35 21 case 'update': 36 22 23 check_admin_referer('edit-plugin_' . $file); 24 37 25 if ( !current_user_can('edit_plugins') ) 38 die('<p>'.__('You havedo 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>'); 39 27 40 28 $newcontent = stripslashes($_POST['newcontent']); … … 43 31 fwrite($f, $newcontent); 44 32 fclose($f); 45 header("Location:plugin-editor.php?file=$file&a=te");33 wp_redirect("plugin-editor.php?file=$file&a=te"); 46 34 } else { 47 header("Location:plugin-editor.php?file=$file");35 wp_redirect("plugin-editor.php?file=$file"); 48 36 } 49 37 … … 53 41 54 42 default: 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 56 47 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>');59 48 60 update_recently_edited( "wp-content/plugins/$file");61 49 update_recently_edited(PLUGINDIR . "/$file"); 50 62 51 if (!is_file($real_file)) 63 52 $error = 1; 64 53 65 54 if (!$error) { 66 55 $f = fopen($real_file, 'r'); … … 96 85 <?php if (!$error) { ?> 97 86 <form name="template" id="template" action="plugin-editor.php" method="post"> 87 <?php wp_nonce_field('edit-plugin_' . $file) ?> 98 88 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea> 99 89 <input type="hidden" name="action" value="update" /> … … 103 93 <p class="submit"> 104 94 <?php 105 echo "<input type='submit' name='submit' value=' " . __('Update File ') . " »' tabindex='2' />";95 echo "<input type='submit' name='submit' value=' " . __('Update File »') . "' tabindex='2' />"; 106 96 ?> 107 97 </p> -
trunk/wp-admin/plugins.php
r3503 r4431 3 3 4 4 if ( isset($_GET['action']) ) { 5 check_admin_referer();6 7 5 if ('activate' == $_GET['action']) { 8 $current = get_settings('active_plugins'); 6 check_admin_referer('activate-plugin_' . $_GET['plugin']); 7 $current = get_option('active_plugins'); 9 8 if (!in_array($_GET['plugin'], $current)) { 10 9 $current[] = trim( $_GET['plugin'] ); 11 10 sort($current); 12 11 update_option('active_plugins', $current); 13 include(ABSPATH . 'wp-content/plugins/' . trim( $_GET['plugin'] ));12 include(ABSPATH . PLUGINDIR . '/' . trim( $_GET['plugin'] )); 14 13 do_action('activate_' . trim( $_GET['plugin'] )); 15 14 } 16 header('Location:plugins.php?activate=true');15 wp_redirect('plugins.php?activate=true'); 17 16 } 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'); 19 19 array_splice($current, array_search( $_GET['plugin'], $current), 1 ); // Array-fu! 20 20 update_option('active_plugins', $current); 21 21 do_action('deactivate_' . trim( $_GET['plugin'] )); 22 header('Location:plugins.php?deactivate=true');22 wp_redirect('plugins.php?deactivate=true'); 23 23 } 24 24 exit; … … 31 31 // If any plugins don't exist, axe 'em 32 32 33 $check_plugins = get_ settings('active_plugins');33 $check_plugins = get_option('active_plugins'); 34 34 35 35 // Sanity check. If the active plugin list is not an array, make it an … … 37 37 if ( !is_array($check_plugins) ) { 38 38 $check_plugins = array(); 39 update_option('active_plugins', $check_plugins); 39 update_option('active_plugins', $check_plugins); 40 40 } 41 41 … … 43 43 // plugins. 44 44 foreach ($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'); 47 47 $key = array_search($check_plugin, $current); 48 48 if ( false !== $key && NULL !== $key ) { … … 68 68 <?php 69 69 70 if ( get_ settings('active_plugins') )71 $current_plugins = get_ settings('active_plugins');70 if ( get_option('active_plugins') ) 71 $current_plugins = get_option('active_plugins'); 72 72 73 73 $plugins = get_plugins(); … … 79 79 } else { 80 80 ?> 81 <table width="100%" cellpadding="3" cellspacing="3"> 81 <table class="widefat plugins"> 82 <thead> 82 83 <tr> 83 84 <th><?php _e('Plugin'); ?></th> 84 <th ><?php _e('Version'); ?></th>85 <th style="text-align: center"><?php _e('Version'); ?></th> 85 86 <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> 87 88 </tr> 89 </thead> 88 90 <?php 89 91 $style = ''; 90 91 function sort_plugins($plug1, $plug2) {92 return strnatcasecmp($plug1['Name'], $plug2['Name']);93 }94 95 uksort($plugins, 'sort_plugins');96 92 97 93 foreach($plugins as $plugin_file => $plugin_data) { … … 99 95 100 96 if (!empty($current_plugins) && in_array($plugin_file, $current_plugins)) { 101 $ action = "<a href='plugins.php?action=deactivate&plugin=$plugin_file' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>";97 $toggle = "<a href='" . wp_nonce_url("plugins.php?action=deactivate&plugin=$plugin_file", 'deactivate-plugin_' . $plugin_file) . "' title='".__('Deactivate this plugin')."' class='delete'>".__('Deactivate')."</a>"; 102 98 $plugin_data['Title'] = "<strong>{$plugin_data['Title']}</strong>"; 103 99 $style .= $style == 'alternate' ? ' active' : 'active'; 104 100 } else { 105 $ action = "<a href='plugins.php?action=activate&plugin=$plugin_file' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>";101 $toggle = "<a href='" . wp_nonce_url("plugins.php?action=activate&plugin=$plugin_file", 'activate-plugin_' . $plugin_file) . "' title='".__('Activate this plugin')."' class='edit'>".__('Activate')."</a>"; 106 102 } 107 103 $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 109 111 echo " 110 112 <tr $style> 111 113 <td class='name'>{$plugin_data['Title']}</td> 112 114 <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" 115 121 </tr>"; 116 122 } … … 122 128 ?> 123 129 124 <p><?php _e( 'If something goes wrong with a plugin and you can’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’t use WordPress, delete or rename that file in the <code>%s</code> directory and it will be automatically deactivated.', PLUGINDIR)); ?></p> 125 131 126 132 <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> 128 135 129 136 </div> -
trunk/wp-admin/post.php
r3503 r4431 2 2 require_once('admin.php'); 3 3 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'; 5 6 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 } 7 wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder')); 20 8 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; 9 if ( isset( $_POST['deletepost'] ) ) 10 $action = 'delete'; 30 11 31 12 switch($action) { 13 case 'postajaxpost': 32 14 case '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(); 35 20 36 21 // Redirect. … … 44 29 break; 45 30 default: 46 $location = 'post .php';31 $location = 'post-new.php'; 47 32 break; 48 33 } 49 34 } else { 50 $location = 'post.php?posted=true';35 $location = "post-new.php?posted=$post_ID"; 51 36 } 52 53 if ( 'static' == $_POST['post_status'] )54 $location = "page-new.php?saved=true";55 37 56 38 if ( isset($_POST['save']) ) 57 39 $location = "post.php?action=edit&post=$post_ID"; 58 40 59 header("Location: $location");41 wp_redirect($location); 60 42 exit(); 61 43 break; … … 63 45 case 'edit': 64 46 $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 } 66 54 require_once('admin-header.php'); 67 68 $post_ID = $p = (int) $_GET['post'];69 55 70 56 if ( !current_user_can('edit_post', $post_ID) ) … … 72 58 73 59 $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'); 79 62 80 63 ?> 81 64 <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 ↑'); ?></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> 84 67 </div> 85 68 <?php … … 89 72 $post_id = (int) $_POST['post_ID']; 90 73 74 check_admin_referer('update-attachment_' . $post_id); 75 91 76 // Don't let these be changed 92 77 unset($_POST['guid']); 93 $_POST['post_ status'] = 'attachment';78 $_POST['post_type'] = 'attachment'; 94 79 95 80 // Update the thumbnail filename … … 103 88 104 89 case 'editpost': 90 $post_ID = (int) $_POST['post_ID']; 91 check_admin_referer('update-post_' . $post_ID); 92 105 93 $post_ID = edit_post(); 106 94 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"; 119 114 } 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 } 121 135 } 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 123 138 124 139 exit(); … … 126 141 127 142 case 'delete': 128 check_admin_referer();129 130 143 $post_id = (isset($_GET['post'])) ? intval($_GET['post']) : intval($_POST['post_ID']); 144 check_admin_referer('delete-post_' . $post_id); 131 145 132 146 $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.') );136 147 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' ) { 138 152 if ( ! wp_delete_attachment($post_id) ) 139 die( __('Error in deleting...') );153 wp_die( __('Error in deleting...') ); 140 154 } else { 141 155 if ( !wp_delete_post($post_id) ) 142 die( __('Error in deleting...') );156 wp_die( __('Error in deleting...') ); 143 157 } 144 158 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'; 148 162 $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 " "; 203 echo "<input type='button' value='" . __('No') . "' onclick=\"self.location='". get_settings('siteurl') ."/wp-admin/edit.php?p=$p&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(); 329 165 break; 330 166 331 167 default: 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 »</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&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) ); ?> »</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)+'&popupurl='+encodeURIComponent(location.href)+'&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)+'&popupurl='+encodeURIComponent(location.href)+'&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’re a newcomer, you’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’re promoted, just reload this page and you’ll be able to blog. :)'), get_settings('admin_email')); ?> 415 </p> 416 </div> 417 <?php 418 } 419 168 wp_redirect('edit.php'); 169 exit(); 420 170 break; 421 171 } // end switch 422 /* </Edit> */423 172 include('admin-footer.php'); 424 173 ?> -
trunk/wp-admin/profile-update.php
r3503 r4431 1 1 <?php 2 2 3 $parent_file = 'profile.php'; 4 $submenu_file = 'profile.php'; 3 5 require_once('admin.php'); 4 6 5 check_admin_referer( );7 check_admin_referer('update-profile_' . $user_ID); 6 8 7 9 if ( !$_POST ) 8 die( __('No post?') );10 wp_die( __('No post?') ); 9 11 10 12 $errors = edit_user($user_ID); 11 13 12 if (count($errors) != 0) { 13 foreach ($errors as $id => $error) { 14 echo $error . '<br/>'; 15 } 14 if ( is_wp_error( $errors ) ) { 15 foreach( $errors->get_error_messages() as $message ) 16 echo "$message<br />"; 16 17 exit; 17 18 } 18 19 19 if ( !isset( $_POST['rich_editing'] ) ) 20 $_POST['rich_editing'] = 'false'; 21 update_user_option( $current_user->id, 'rich_editing', $_POST['rich_editing'], true ); 20 if ( 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 } 22 25 23 26 do_action('personal_options_update'); -
trunk/wp-admin/profile.php
r3503 r4431 4 4 $title = __('Profile'); 5 5 6 $parent_file = 'profile.php'; 6 if ( current_user_can('edit_users') ) 7 $parent_file = 'users.php'; 8 else 9 $parent_file = 'profile.php'; 7 10 include_once('admin-header.php'); 8 $profileuser = new WP_User($user_ID);11 $profileuser = get_user_to_edit($user_ID); 9 12 10 13 $bookmarklet_height= 440; … … 20 23 <h2><?php _e('Your Profile and Personal Options'); ?></h2> 21 24 <form name="profile" id="your-profile" action="profile-update.php" method="post"> 25 <?php wp_nonce_field('update-profile_' . $user_ID) ?> 22 26 <p> 23 27 <input type="hidden" name="from" value="profile" /> 24 28 <input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" /> 25 29 </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 »') ?>" name="submit" /></p> 26 41 27 42 <fieldset> … … 82 97 <br clear="all" /> 83 98 <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> 86 101 <p><textarea name="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea></p> 87 102 </fieldset> … … 107 122 <br clear="all" /> 108 123 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 116 124 <table width="99%" border="0" cellspacing="2" cellpadding="3" class="editform"> 117 125 <?php … … 135 143 ?> 136 144 </table> 137 <p class="submit"> 138 <input type="submit" value="<?php _e('Update Profile »') ?>" name="submit" /> 139 </p> 145 <p class="submit"><input type="submit" value="<?php _e('Update Profile »') ?>" name="submit" /></p> 140 146 </form> 141 147 -
trunk/wp-admin/setup-config.php
r3503 r4431 2 2 define('WP_INSTALLING', true); 3 3 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 7 4 if (!file_exists('../wp-config-sample.php')) 8 5 die('Sorry, I need a wp-config-sample.php file to work from. Please re-upload this file from your WordPress installation.'); 6 9 7 $configFile = file('../wp-config-sample.php'); 10 8 11 9 if (!is_writable('../')) die("Sorry, I can't write to the directory. You'll have to either change the permissions on your WordPress directory or create your wp-config.php manually."); 12 10 13 $step = 0; 14 if(isset($_GET['step'])) $step = $_GET['step']; 11 12 if (isset($_GET['step'])) 13 $step = $_GET['step']; 14 else 15 $step = 0; 15 16 header( 'Content-Type: text/html; charset=utf-8' ); 16 17 ?> … … 21 22 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 22 23 <style media="screen" type="text/css"> 23 <!-- 24 <!-- 25 html { 26 background: #eee; 27 } 24 28 body { 29 background: #fff; 30 color: #000; 25 31 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; 28 54 } 29 55 #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; 36 57 } 37 #logo a { 38 display: block; 39 height: 60px; 58 .step a, .step input { 59 font-size: 2em; 40 60 } 41 #logo a span{42 display: none;61 td input { 62 font-size: 1.5em; 43 63 } 44 p, li{45 line-height: 140%;64 .step, th { 65 text-align: right; 46 66 } 47 --> 67 #footer { 68 text-align: center; 69 border-top: 1px solid #ccc; 70 padding-top: 1em; 71 font-style: italic; 72 } 73 --> 48 74 </style> 49 75 </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> 52 78 <?php 79 // Check if wp-config.php has been created 80 if (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>"); 53 82 54 83 switch($step) { 55 84 case 0: 56 85 ?> 86 57 87 <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> 58 88 <ol> 59 89 <li>Database name</li> 60 90 <li>Database username</li> 61 <li>Database password</li> 91 <li>Database password</li> 62 92 <li>Database host</li> 63 93 <li>Table prefix (if you want to run more than one WordPress in a single database) </li> … … 71 101 ?> 72 102 </p> 73 <form method="post" action="setup-config.php?step=2"> 103 <form method="post" action="setup-config.php?step=2"> 74 104 <p>Below you should enter your database connection details. If you're not sure about these, contact your host. </p> 75 105 <table> 76 106 <tr> 77 107 <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> 79 109 <td>The name of the database you want to run WP in. </td> 80 110 </tr> 81 111 <tr> 82 112 <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> 84 114 <td>Your MySQL username</td> 85 115 </tr> 86 116 <tr> 87 117 <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> 89 119 <td>...and MySQL password.</td> 90 120 </tr> 91 121 <tr> 92 122 <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> 94 124 <td>99% chance you won't need to change this value.</td> 95 125 </tr> 96 126 <tr> 97 127 <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> 99 129 <td>If you want to run multiple WordPress installations in a single database, change this.</td> 100 130 </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> 103 135 </form> 104 136 <?php 105 137 break; 106 138 107 139 case 2: 108 140 $dbname = trim($_POST['dbname']); … … 150 182 <?php 151 183 break; 152 153 184 } 154 ?> 185 ?> 186 <p id="footer"><a href="http://wordpress.org/">WordPress</a>, personal publishing platform.</p> 155 187 </body> 156 188 </html> -
trunk/wp-admin/sidebar.php
r3503 r4431 5 5 6 6 if ( ! current_user_can('edit_posts') ) 7 die ("Cheatin' uh ?");7 wp_die(__('Cheatin’ uh?')); 8 8 9 9 if ('b' == $_GET['a']) { … … 49 49 <body id="sidebar"> 50 50 <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"> 52 52 <div><input type="hidden" name="action" value="post" /> 53 53 <input type="hidden" name="user_ID" value="<?php echo $user_ID ?>" /> -
trunk/wp-admin/templates.php
r3503 r4431 4 4 $parent_file = 'edit.php'; 5 5 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 } 6 wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file')); 21 7 22 8 $recents = get_option('recently_edited'); … … 37 23 case 'update': 38 24 25 check_admin_referer('edit-file_' . $file); 26 39 27 if ( ! current_user_can('edit_files') ) 40 die('<p>'.__('You havedo 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>'); 41 29 42 30 $newcontent = stripslashes($_POST['newcontent']); … … 46 34 fwrite($f, $newcontent); 47 35 fclose($f); 48 header("Location:templates.php?file=$file&a=te");36 wp_redirect("templates.php?file=$file&a=te"); 49 37 } else { 50 header("Location:templates.php?file=$file&a=err");38 wp_redirect("templates.php?file=$file&a=err"); 51 39 } 52 40 } else { 53 header("Location:templates.php?file=$file&a=err");41 wp_redirect("templates.php?file=$file&a=err"); 54 42 } 55 43 … … 61 49 62 50 require_once('./admin-header.php'); 63 51 64 52 if ( ! current_user_can('edit_files') ) 65 die('<p>'.__('You havedo 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>'); 66 54 67 55 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>'); 69 57 70 58 update_recently_edited($file); … … 72 60 if (!is_file($real_file)) 73 61 $error = true; 74 62 75 63 if (!$error) { 76 64 $f = @ fopen($real_file, 'r'); 77 65 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 } 80 72 } else { 81 73 $error = true; … … 89 81 <?php else: ?> 90 82 <div id="message" class="updated fade"><p><?php _e('File edited successfully.') ?></p></div> 91 <?php endif; ?> 83 <?php endif; ?> 92 84 <?php endif; ?> 93 85 <div class="wrap"> … … 107 99 echo '<ol>'; 108 100 foreach ($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>"; 110 102 endforeach; 111 103 echo '</ol>'; … … 127 119 <?php if (!$error) { ?> 128 120 <form name="template" id="template" action="templates.php" method="post"> 121 <?php wp_nonce_field('edit-file_' . $file) ?> 129 122 <div><textarea cols="70" rows="25" name="newcontent" id='newcontent' tabindex="1"><?php echo $content ?></textarea> 130 123 <input type="hidden" name="action" value="update" /> … … 134 127 <p class="submit"> 135 128 <?php 136 echo "<input type='submit' name='submit' value=' " . __('Update File ') . " »' tabindex='2' />";129 echo "<input type='submit' name='submit' value=' " . __('Update File »') . "' tabindex='2' />"; 137 130 ?> 138 131 </p> -
trunk/wp-admin/theme-editor.php
r3503 r4431 5 5 $parent_file = 'themes.php'; 6 6 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 } 7 wp_reset_vars(array('action', 'redirect', 'profile', 'error', 'warning', 'a', 'file', 'theme')); 22 8 23 9 $themes = get_themes(); … … 31 17 32 18 if ( ! isset($themes[$theme]) ) 33 die(__('The requested theme does not exist.'));19 wp_die(__('The requested theme does not exist.')); 34 20 35 21 $allowed_files = array_merge($themes[$theme]['Stylesheet Files'], $themes[$theme]['Template Files']); … … 48 34 case 'update': 49 35 36 check_admin_referer('edit-theme_' . $file . $theme); 37 50 38 if ( !current_user_can('edit_themes') ) 51 die('<p>'.__('You havedo 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>'); 52 40 53 41 $newcontent = stripslashes($_POST['newcontent']); … … 57 45 fwrite($f, $newcontent); 58 46 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"; 60 48 } else { 61 header("Location: theme-editor.php?file=$file&theme=$theme");49 $location = "theme-editor.php?file=$file&theme=$theme"; 62 50 } 63 51 52 $location = wp_kses_no_null($location); 53 $strip = array('%0d', '%0a'); 54 $location = str_replace($strip, '', $location); 55 header("Location: $location"); 64 56 exit(); 65 57 … … 67 59 68 60 default: 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 70 65 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>');73 66 74 67 update_recently_edited($file); 75 68 76 69 if (!is_file($real_file)) 77 70 $error = 1; 78 71 79 72 if (!$error && filesize($real_file) > 0) { 80 73 $f = fopen($real_file, 'r'); … … 101 94 ?> 102 95 </select> 103 <input type="submit" name="Submit" value="<?php _e('Select ') ?> »" />96 <input type="submit" name="Submit" value="<?php _e('Select »') ?>" class="button" /> 104 97 </form> 105 98 </div> … … 130 123 ?> 131 124 <form name="template" id="template" action="theme-editor.php" method="post"> 125 <?php wp_nonce_field('edit-theme_' . $file . $theme) ?> 132 126 <div><textarea cols="70" rows="25" name="newcontent" id="newcontent" tabindex="1"><?php echo $content ?></textarea> 133 127 <input type="hidden" name="action" value="update" /> … … 138 132 <p class="submit"> 139 133 <?php 140 echo "<input type='submit' name='submit' value=' " . __('Update File ') . " »' tabindex='2' />";134 echo "<input type='submit' name='submit' value=' " . __('Update File »') . "' tabindex='2' />"; 141 135 ?> 142 136 </p> -
trunk/wp-admin/themes.php
r3503 r4431 3 3 4 4 if ( isset($_GET['action']) ) { 5 check_admin_referer( );6 5 check_admin_referer('switch-theme_' . $_GET['template']); 6 7 7 if ('activate' == $_GET['action']) { 8 8 if ( isset($_GET['template']) ) 9 9 update_option('template', $_GET['template']); 10 10 11 11 if ( isset($_GET['stylesheet']) ) 12 12 update_option('stylesheet', $_GET['stylesheet']); 13 13 14 14 do_action('switch_theme', get_current_theme()); 15 16 header('Location:themes.php?activated=true');15 16 wp_redirect('themes.php?activated=true'); 17 17 exit; 18 18 } … … 70 70 $screenshot = $themes[$theme_name]['Screenshot']; 71 71 $stylesheet_dir = $themes[$theme_name]['Stylesheet Dir']; 72 $activate_link = "themes.php?action=activate&template=$template&stylesheet=$stylesheet";72 $activate_link = wp_nonce_url("themes.php?action=activate&template=$template&stylesheet=$stylesheet", 'switch-theme_' . $template); 73 73 ?> 74 74 <div class="available-theme"> … … 103 103 <?php 104 104 $theme = ''; 105 105 106 106 $theme_names = array_keys($broken_themes); 107 107 natcasesort($theme_names); -
trunk/wp-admin/update-links.php
r3503 r4431 4 4 5 5 if ( !get_option('use_linksupdate') ) 6 die(__('Feature disabled.'));6 wp_die(__('Feature disabled.')); 7 7 8 8 $link_uris = $wpdb->get_col("SELECT link_url FROM $wpdb->links"); 9 9 10 10 if ( !$link_uris ) 11 die('No links');11 wp_die(__('No links')); 12 12 13 13 $link_uris = urlencode( join( $link_uris, "\n" ) ); … … 17 17 $http_request = "POST /updated-batch/ HTTP/1.0\r\n"; 18 18 $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"; 20 20 $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n"; 21 21 $http_request .= 'User-Agent: WordPress/' . $wp_version . "\r\n"; … … 24 24 25 25 $response = ''; 26 if ( false !== ( $fs =fsockopen('api.pingomatic.com', 80, $errno, $errstr, 5) ) ) {26 if ( false !== ( $fs = @fsockopen('api.pingomatic.com', 80, $errno, $errstr, 5) ) ) { 27 27 fwrite($fs, $http_request); 28 28 while ( !feof($fs) ) -
trunk/wp-admin/upgrade-functions.php
r3503 r4431 1 1 <?php 2 2 3 if ( file_exists(ABSPATH . 'wp-content/install.php') ) 4 require (ABSPATH . 'wp-content/install.php'); 3 5 require_once(ABSPATH . '/wp-admin/admin-functions.php'); 6 require_once(ABSPATH . '/wp-admin/admin-db.php'); 4 7 require_once(ABSPATH . '/wp-admin/upgrade-schema.php'); 8 require_once(ABSPATH . WPINC . '/registration.php'); 9 10 if ( !function_exists('wp_install') ) : 11 function 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 } 53 endif; 54 55 if ( !function_exists('wp_install_defaults') ) : 56 function 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'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 } 100 endif; 101 102 if ( !function_exists('wp_new_blog_notification') ) : 103 function 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 112 You can log in to the administrator account with the following information: 113 114 Username: %2\$s 115 Password: %3\$s 116 117 We hope you enjoy your new weblog. Thanks! 118 119 --The WordPress Team 120 http://wordpress.org/ 121 "), $blog_url, $name, $password); 122 123 @wp_mail($email, __('New WordPress Blog'), $message, $message_headers); 124 } 125 endif; 126 127 if ( !function_exists('wp_upgrade') ) : 128 function 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 } 142 endif; 143 5 144 // Functions to be called in install and upgrade scripts 6 145 function upgrade_all() { … … 21 160 $wp_current_db_version = 2541; 22 161 } 23 162 24 163 populate_options(); 25 164 … … 30 169 upgrade_130(); 31 170 } 32 171 33 172 if ( $wp_current_db_version < 3308 ) 34 173 upgrade_160(); 35 174 175 if ( $wp_current_db_version < 3845 ) 176 upgrade_210(); 177 36 178 $wp_rewrite->flush_rules(); 37 179 38 180 update_option('db_version', $wp_db_version); 39 181 } … … 52 194 } 53 195 } 54 196 55 197 $categories = $wpdb->get_results("SELECT cat_ID, cat_name, category_nicename FROM $wpdb->categories"); 56 198 foreach ($categories as $category) { … … 75 217 $catwhere = ''; 76 218 endif; 77 219 78 220 $allposts = $wpdb->get_results("SELECT ID, post_category FROM $wpdb->posts WHERE post_category != '0' $catwhere"); 79 221 if ($allposts) : … … 109 251 function upgrade_110() { 110 252 global $wpdb; 111 253 112 254 // Set user_nicename. 113 255 $users = $wpdb->get_results("SELECT ID, user_nickname, user_nicename FROM $wpdb->users"); … … 164 306 165 307 function upgrade_130() { 166 global $wpdb , $table_prefix;308 global $wpdb; 167 309 168 310 // Remove extraneous backslashes. … … 217 359 218 360 // 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'); 223 365 224 366 // Update comments table to use comment_type … … 241 383 242 384 function upgrade_160() { 243 global $wpdb, $ table_prefix, $wp_current_db_version;385 global $wpdb, $wp_current_db_version; 244 386 245 387 populate_roles_160(); … … 254 396 update_usermeta( $user->ID, 'nickname', $wpdb->escape($user->user_nickname) ); 255 397 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 ); 257 399 if ( !empty( $user->user_icq ) ) 258 400 update_usermeta( $user->ID, 'icq', $wpdb->escape($user->user_icq) ); … … 278 420 $wpdb->query("UPDATE $wpdb->users SET display_name = '$id' WHERE ID = '$user->ID'"); 279 421 endif; 280 422 281 423 // 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'); 283 425 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'); 285 427 $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 289 431 endforeach; 290 432 $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' ); … … 293 435 $wpdb->query("ALTER TABLE $wpdb->users DROP $old"); 294 436 $wpdb->show_errors(); 295 437 296 438 if ( 0 == $wpdb->get_var("SELECT SUM(category_count) FROM $wpdb->categories") ) { // Create counts 297 439 $categories = $wpdb->get_col("SELECT cat_ID FROM $wpdb->categories"); … … 319 461 post_type = '' 320 462 WHERE ID = $object->ID"); 321 463 322 464 $meta = get_post_meta($object->ID, 'imagedata', true); 323 465 if ( ! empty($meta['file']) ) 324 466 add_post_meta($object->ID, '_wp_attached_file', $meta['file']); 467 } 468 } 469 } 470 471 function 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 } 325 543 } 326 544 } … … 447 665 function dbDelta($queries, $execute = true) { 448 666 global $wpdb; 449 667 450 668 // Seperate individual queries into an array 451 669 if( !is_array($queries) ) { … … 453 671 if('' == $queries[count($queries) - 1]) array_pop($queries); 454 672 } 455 673 456 674 $cqueries = array(); // Creation Queries 457 675 $iqueries = array(); // Insertion Queries 458 676 $for_update = array(); 459 677 460 678 // Create a tablename index for an array ($cqueries) of queries 461 679 foreach($queries as $qry) { … … 476 694 // Unrecognized query type 477 695 } 478 } 696 } 479 697 480 698 // Check to see which tables and fields exist … … 495 713 496 714 //echo "<hr/><pre>\n".print_r(strtolower($table), true).":\n".print_r($cqueries, true)."</pre><hr/>"; 497 715 498 716 // For every field line specified in the query 499 717 foreach($flds as $fld) { … … 501 719 preg_match("|^([^ ]*)|", trim($fld), $fvals); 502 720 $fieldname = $fvals[1]; 503 721 504 722 // Verify the found field name 505 723 $validfield = true; … … 517 735 } 518 736 $fld = trim($fld); 519 737 520 738 // If it's a valid field, add it to the field array 521 739 if($validfield) { … … 523 741 } 524 742 } 525 743 526 744 // Fetch the table column structure from the database 527 745 $tablefields = $wpdb->get_results("DESCRIBE {$table};"); 528 746 529 747 // For every field in the table 530 foreach($tablefields as $tablefield) { 748 foreach($tablefields as $tablefield) { 531 749 // If the table field exists in the field array... 532 750 if(array_key_exists(strtolower($tablefield->Field), $cfields)) { … … 541 759 $for_update[$table.'.'.$tablefield->Field] = "Changed type of {$table}.{$tablefield->Field} from {$tablefield->Type} to {$fieldtype}"; 542 760 } 543 761 544 762 // Get the default value from the array 545 763 //echo "{$cfields[strtolower($tablefield->Field)]}<br>"; … … 568 786 $for_update[$table.'.'.$fieldname] = 'Added column '.$table.'.'.$fieldname; 569 787 } 570 788 571 789 // Index stuff goes here 572 790 // Fetch the table index structure from the database 573 791 $tableindices = $wpdb->get_results("SHOW INDEX FROM {$table};"); 574 792 575 793 if($tableindices) { 576 794 // Clear the index array … … 601 819 $index_columns = ''; 602 820 // For each column in the index 603 foreach($index_data['columns'] as $column_data) { 821 foreach($index_data['columns'] as $column_data) { 604 822 if($index_columns != '') $index_columns .= ','; 605 823 // Add the field to the column list string -
trunk/wp-admin/upgrade-schema.php
r3503 r4431 9 9 category_parent bigint(20) NOT NULL default '0', 10 10 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', 11 14 PRIMARY KEY (cat_ID), 12 15 KEY category_nicename (category_nicename) … … 32 35 KEY comment_post_ID (comment_post_ID) 33 36 ); 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) 37 CREATE 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) 49 43 ); 50 44 CREATE TABLE $wpdb->links ( … … 107 101 post_category int(4) NOT NULL default '0', 108 102 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', 110 104 comment_status enum('open','closed','registered_only') NOT NULL default 'open', 111 105 ping_status enum('open','closed') NOT NULL default 'open', … … 120 114 guid varchar(255) NOT NULL default '', 121 115 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', 123 117 post_mime_type varchar(100) NOT NULL default '', 124 118 comment_count bigint(20) NOT NULL default '0', 125 119 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) 127 122 ); 128 123 CREATE TABLE $wpdb->users ( … … 212 207 add_option('blacklist_keys'); 213 208 add_option('comment_registration', 0); 214 add_option('open_proxy_check', 1);215 209 add_option('rss_language', 'en'); 216 210 add_option('html_type', 'text/html'); … … 230 224 add_option('upload_path', 'wp-content/uploads'); 231 225 } 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'); 232 234 233 235 // 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'); 235 237 foreach ($unusedoptions as $option) : 236 238 delete_option($option); … … 245 247 246 248 function populate_roles() { 247 populate_roles_160(); 249 populate_roles_160(); 250 populate_roles_210(); 248 251 } 249 252 … … 257 260 add_role('contributor', __('Contributor')); 258 261 add_role('subscriber', __('Subscriber')); 259 262 260 263 // Add caps for Administrator role 261 264 $role = get_role('administrator'); … … 290 293 $role->add_cap('level_1'); 291 294 $role->add_cap('level_0'); 292 295 293 296 // Add caps for Editor role 294 297 $role = get_role('editor'); … … 312 315 $role->add_cap('level_1'); 313 316 $role->add_cap('level_0'); 314 317 315 318 // Add caps for Author role 316 319 $role = get_role('author'); … … 323 326 $role->add_cap('level_1'); 324 327 $role->add_cap('level_0'); 325 328 326 329 // Add caps for Contributor role 327 330 $role = get_role('contributor'); … … 330 333 $role->add_cap('level_1'); 331 334 $role->add_cap('level_0'); 332 335 333 336 // Add caps for Subscriber role 334 337 $role = get_role('subscriber'); … … 337 340 } 338 341 342 function 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 339 384 ?> -
trunk/wp-admin/upgrade.php
r3503 r4431 1 1 <?php 2 2 define('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."); 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://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 4 6 require('../wp-config.php'); 5 7 timer_start(); 6 8 require_once(ABSPATH . '/wp-admin/upgrade-functions.php'); 7 9 8 $step = $_GET['step']; 9 if (!$step) $step = 0; 10 header( 'Content-Type: text/html; charset=utf-8' ); 10 if (isset($_GET['step'])) 11 $step = $_GET['step']; 12 else 13 $step = 0; 14 @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); 11 15 ?> 12 16 <!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(); ?>> 14 18 <head> 15 <title>WordPress › 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 › 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; ?> 63 25 </head> 64 26 <body> … … 66 28 <?php 67 29 switch($step) { 68 69 30 case 0: 70 $goback = wp_specialchars($_SERVER['HTTP_REFERER'], 1);31 $goback = wp_specialchars(wp_get_referer()); 71 32 ?> 72 33 <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&backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress »'); ?></a></h2>34 <h2 class="step"><a href="upgrade.php?step=1&backto=<?php echo $goback; ?>"><?php _e('Upgrade WordPress »'); ?></a></h2> 74 35 <?php 75 break; 76 36 break; 77 37 case 1: 78 wp_cache_flush(); 79 make_db_current_silent(); 80 upgrade_all(); 81 wp_cache_flush(); 38 wp_upgrade(); 82 39 83 if ( empty( $_GET['backto'] ) )84 $backto = __get_option('home');85 else86 $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 ); 87 44 ?> 88 45 <h2><?php _e('Step 1'); ?></h2> … … 98 55 99 56 <?php 100 break;57 break; 101 58 } 102 59 ?> -
trunk/wp-admin/user-edit.php
r3503 r4431 3 3 4 4 $title = __('Edit User'); 5 $parent_file = 'profile.php'; 5 if ( current_user_can('edit_users') ) 6 $parent_file = 'users.php'; 7 else 8 $parent_file = 'profile.php'; 6 9 $submenu_file = 'users.php'; 7 10 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 } 11 wp_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 17 if ( !$user_id ) 18 wp_die(__('Invalid user ID.')); 23 19 24 20 switch ($action) { … … 33 29 case 'update': 34 30 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"); 31 check_admin_referer('update-user_' . $user_id); 32 33 if ( !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 38 if( !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); 44 42 exit; 45 43 } 46 44 47 45 default: 46 $profileuser = get_user_to_edit($user_id); 47 48 if ( !current_user_can('edit_user', $user_id) ) 49 wp_die(__('You do not have permission to edit this user.')); 50 48 51 include ('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.');53 52 ?> 54 53 … … 56 55 <div id="message" class="updated fade"> 57 56 <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('« Back to Authors and Users'); ?></a></p> 59 <?php endif; ?> 58 60 </div> 59 61 <?php endif; ?> 60 <?php if ( count($errors) != 0) : ?>62 <?php if ( is_wp_error( $errors ) ) : ?> 61 63 <div class="error"> 62 64 <ul> 63 65 <?php 64 foreach($errors as $error) echo "<li>$error</li>"; 66 foreach( $errors->get_error_messages() as $message ) 67 echo "<li>$message</li>"; 65 68 ?> 66 69 </ul> … … 72 75 73 76 <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; ?> 74 81 <p> 75 82 <input type="hidden" name="from" value="profile" /> … … 87 94 // print_r($profileuser); 88 95 echo '<select name="role">'; 96 $role_list = ''; 97 $user_has_role = false; 89 98 foreach($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>"; 92 106 } 93 echo '</select>'; 107 if ( $user_has_role ) 108 $role_list .= '<option value="">' . __('— No role for this blog —') . '</option>'; 109 else 110 $role_list .= '<option value="" selected="selected">' . __('— No role for this blog —') . '</option>'; 111 echo $role_list . '</select>'; 94 112 ?></label></p> 95 113 -
trunk/wp-admin/users.php
r3503 r4431 1 1 <?php 2 2 require_once('admin.php'); 3 require_once( ABSPATH . WPINC . '/registration -functions.php');3 require_once( ABSPATH . WPINC . '/registration.php'); 4 4 5 5 $title = __('Users'); 6 $parent_file = 'profile.php'; 7 6 if ( current_user_can('edit_users') ) 7 $parent_file = 'users.php'; 8 else 9 $parent_file = 'profile.php'; 10 8 11 $action = $_REQUEST['action']; 9 12 $update = ''; 10 13 14 if ( 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 28 class 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' => '« Previous Page', 89 'next_text' => 'Next Page »', 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 11 119 switch ($action) { 12 120 13 121 case 'promote': 14 check_admin_referer( );122 check_admin_referer('bulk-users'); 15 123 16 124 if (empty($_POST['users'])) { 17 header('Location: users.php');125 wp_redirect($redirect); 18 126 } 19 127 20 128 if ( !current_user_can('edit_users') ) 21 die(__('You can’t edit users.'));22 23 $userids = $_POST['users'];129 wp_die(__('You can’t edit users.')); 130 131 $userids = $_POST['users']; 24 132 $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’t edit that user.')); 26 136 // The new role of the current user must also have edit_users caps 27 137 if($id == $current_user->id && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) { … … 30 140 } 31 141 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)); 37 147 38 148 break; … … 40 150 case 'dodelete': 41 151 42 check_admin_referer( );152 check_admin_referer('delete-users'); 43 153 44 154 if ( empty($_POST['users']) ) { 45 header('Location: users.php');46 } 47 48 if ( !current_user_can(' edit_users') )49 die(__('You can’t delete users.'));155 wp_redirect($redirect); 156 } 157 158 if ( !current_user_can('delete_users') ) 159 wp_die(__('You can’t delete users.')); 50 160 51 161 $userids = $_POST['users']; 52 53 162 $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’t delete that user.')); 168 55 169 if($id == $current_user->id) { 56 170 $update = 'err_admin_del'; 57 171 continue; 58 172 } 59 switch($_POST['delete_option']) {173 switch($_POST['delete_option']) { 60 174 case 'delete': 61 175 wp_delete_user($id); … … 65 179 break; 66 180 } 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)); 70 187 71 188 break; … … 73 190 case 'delete': 74 191 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’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’t delete users.')); 83 199 84 200 $userids = $_POST['users']; … … 87 203 ?> 88 204 <form action="" method="post" name="updateusers" id="updateusers"> 205 <?php wp_nonce_field('delete-users') ?> 206 <?php echo $referer; ?> 89 207 <div class="wrap"> 90 208 <h2><?php _e('Delete Users'); ?></h2> … … 93 211 <?php 94 212 $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 ) { 98 216 echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n"; 99 217 } else { … … 101 219 $go_delete = true; 102 220 } 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> 116 232 <ul style="list-style:none;"> 117 233 <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" /> … … 132 248 133 249 case '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’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); 140 263 die(); 141 264 } 142 265 143 266 default: 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 ) { 150 276 $tmp_user = new WP_User($userid); 151 277 $roles = $tmp_user->roles; 152 278 $role = array_shift($roles); 153 279 $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']) ) : 160 283 switch($_GET['update']) { 161 284 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> 164 289 <?php 165 290 break; … … 187 312 break; 188 313 } 189 endif; 190 if ( isset($errors) ) : ?> 314 endif; ?> 315 316 <?php if ( is_wp_error( $errors ) ) : ?> 191 317 <div class="error"> 192 318 <ul> 193 319 <?php 194 foreach($errors as $error) echo "<li>$error</li>"; 320 foreach ( $errors->get_error_messages() as $message ) 321 echo "<li>$message</li>"; 195 322 ?> 196 323 </ul> 197 324 </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 »'); ?>" 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('« 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 – %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 202 367 <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 371 foreach($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"> 217 383 <th><?php _e('ID') ?></th> 218 384 <th><?php _e('Username') ?></th> … … 220 386 <th><?php _e('E-mail') ?></th> 221 387 <th><?php _e('Website') ?></th> 222 <th ><?php _e('Posts') ?></th>223 <th> </th>224 </tr>225 <?php226 $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 = ''; 393 foreach ( (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 »'); ?>" /> 418 </p> 419 </form> 420 <?php endif; ?> 421 </div> 256 422 257 423 <?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); 258 430 } 259 431 ?> 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 »'); ?>" /></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 »') ?>" /> 485 </p> 276 486 </div> 277 487 </form> 278 488 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 305 500 <?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') ?> »" />319 </p>320 </form>321 </div>322 <?php323 324 501 break; 325 } 502 503 } // end of the $action switch 326 504 327 505 include('admin-footer.php'); -
trunk/wp-admin/wp-admin.css
r3503 r4431 19 19 background: #c00; 20 20 color: #fff; 21 } 22 23 #devnews h4 { 24 font-family: Georgia, "Times New Roman", Times, serif; 25 font-size: 18px; 26 font-weight: normal; 21 27 } 22 28 … … 41 47 } 42 48 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 92 thead, .thead { 93 background: #dfdfdf 94 } 95 96 #import-upload-form { 97 margin: auto; 98 background: #eee; 99 padding: 1em; 100 } 101 43 102 a.edit, a.delete, a.edit:hover, a.delete:hover { 44 103 border-bottom: none; … … 92 151 } 93 152 94 fieldset span.cat-nest {95 display: block;96 margin-left: 10px;97 }98 99 153 fieldset.options { 100 154 padding: 1em; … … 102 156 103 157 fieldset.options legend { 104 font-size: 16px; 158 font-size: 1.5em; 159 font-weight: bold; 160 font-family: Georgia, "Times New Roman", Times, serif; 105 161 } 106 162 … … 111 167 112 168 h2 { 113 border-bottom: .5em solid # f0f8ff;169 border-bottom: .5em solid #e5f3ff; 114 170 color: #333; 115 font: normal 3 0px/5px serif;171 font: normal 32px/5px serif; 116 172 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;130 173 } 131 174 … … 148 191 149 192 p, li, dl, dd, dt { 150 line-height: 1 30%;193 line-height: 140%; 151 194 } 152 195 … … 164 207 padding: 0px; 165 208 margin-bottom: 16px; 166 height: 1 5em;209 height: 17em; 167 210 width: 100%; 168 211 /* overflow-y: hidden;*/ … … 242 285 243 286 .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; 246 295 } 247 296 … … 278 327 } 279 328 280 .submit input, .submit input:focus, .button {329 .submit input, .submit input:focus, .button, .button:focus { 281 330 background: url( images/fade-butt.png ); 282 331 border: 3px double #999; … … 294 343 } 295 344 345 .button, .button:focus { 346 padding: 0.15em; 347 } 348 349 * html .button { 350 padding: 0; 351 } 352 296 353 .submit, .editform th, #postcustomsubmit { 297 354 text-align: right; … … 309 366 width: 33%; 310 367 text-align: right; 368 font-size: 1.3em; 369 font-weight: normal; 311 370 } 312 371 … … 327 386 } 328 387 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; 331 402 border: 1px solid #2580B2; 332 403 margin: 1em 5% 10px; … … 346 417 clear: both; 347 418 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%; 349 429 } 350 430 351 431 .wrap h2 { 352 margin: . 8em 0 .5em;432 margin: .4em 0 .5em; 353 433 clear: both; 354 434 } 355 435 356 table .vers, table .name { 436 * html .wrap h2 { 437 margin-top: 1em; 438 } 439 440 table .vers { 357 441 text-align: center; 358 442 } 359 443 444 textarea.all-options, input.all-options { 445 width: 250px; 446 } 447 448 input.disabled, textarea.disabled { 449 background: #ccc; 450 } 451 360 452 #adminmenu { 361 background: # 6da6d1;453 background: #83B4D8; 362 454 border-top: 3px solid #448abd; 363 455 margin: 0; 364 padding: .2em .2em .2em 2em; 365 } 456 padding: .2em .2em .3em 2em; 457 } 458 366 459 367 460 #adminmenu .current, #submenu .current { 368 461 font-weight: bold; 462 text-decoration: none; 369 463 } 370 464 … … 375 469 margin: 0; 376 470 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 { 381 475 background: #ddeaf4; 382 476 color: #333; … … 390 484 } 391 485 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 { 393 495 background: #0d324f; 394 496 border-bottom: none; 395 497 margin: 0; 396 498 padding: 3px 2em 0 3em; 499 height: 25px; 500 } 501 502 #minisub { 503 height: 6px; 397 504 } 398 505 … … 408 515 color: #fff; 409 516 font-size: 12px; 410 padding: .3em .4em . 33em;517 padding: .3em .4em .4em; 411 518 } 412 519 … … 417 524 418 525 #submenu li { 419 line-height: 1 70%;526 line-height: 180%; 420 527 } 421 528 … … 425 532 } 426 533 427 #titlediv, #guiddiv { 428 margin: 0 8px 0 0; 429 padding: 0px; 430 } 431 432 #postdiv { 534 #postdiv, #titlediv, #guiddiv { 433 535 margin: 0 8px 0 0; 434 536 padding: 0px; … … 445 547 } 446 548 549 #postdivrich #content { 550 padding: .7em; 551 line-height: 140%; 552 } 553 447 554 #titlediv input, #guiddiv input { 448 555 margin: 0px; 449 556 width: 100%; 450 }451 452 #quicktags {453 margin-left: -1px;454 557 } 455 558 … … 462 565 } 463 566 464 #deletepost:hover {567 input.delete:hover { 465 568 background: #ce0000; 466 569 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; 467 599 } 468 600 … … 486 618 #quicktags #ed_code { 487 619 font-family: "Courier New", Courier, mono; 620 margin-bottom: 3px; 488 621 } 489 622 490 623 #title { 491 font-size: 1.5em; 624 font-size: 1.7em; 625 padding: 4px; 492 626 } 493 627 … … 515 649 clear: both; 516 650 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; 517 668 } 518 669 519 670 #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; 522 674 margin: 5em auto; 523 padding: 1.5em;524 width: 25em;675 padding: 20px 50px 0; 676 width: 325px; 525 677 } 526 678 527 679 #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 { 530 695 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; 534 715 text-align: center; 535 716 } 536 717 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: "."; 543 735 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; 557 739 } 558 740 559 741 #login ul li { 560 display: inline; 561 margin-left: 1.4em; 742 float: left; 743 font-size: 12px; 744 padding: 5px 0; 562 745 text-align: center; 563 746 } 564 747 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; 568 771 } 569 772 570 773 #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; 572 800 } 573 801 … … 614 842 float: right; 615 843 width: 170px; 616 } 617 618 #templateside h3, #postcustom p { 844 overflow: hidden; 845 } 846 847 #templateside h3, #postcustom p.submit { 619 848 margin: 0; 620 849 } … … 663 892 #zeitgeist { 664 893 background: #eee; 665 border: 1px solid # 69c;894 border: 1px solid #c5c5c5; 666 895 float: right; 667 896 font-size: 90%; … … 677 906 } 678 907 908 * html #zeitgeist h2 { 909 padding-top: 10px; 910 } 911 679 912 #zeitgeist h2 { 680 913 margin-top: .4em; … … 712 945 .alternate.active .name { 713 946 background: #8B8; 947 } 948 949 #namediv, #emaildiv, #uridiv { 950 float: left; 951 } 952 953 #ajax-response { 954 padding: .5em; 714 955 } 715 956 … … 800 1041 } 801 1042 802 #categorydiv div div { 1043 #categorydiv ul { 1044 list-style: none; 1045 padding: 0; 1046 margin-left: 10px; 1047 } 1048 1049 #categorychecklist { 803 1050 height: 12em; 804 1051 overflow: auto; 1052 margin-top: 8px; 1053 } 1054 1055 #categorychecklist li { 1056 margin: 0; 1057 padding: 0; 805 1058 } 806 1059 807 1060 #ajaxcat input { 808 1061 border: 1px solid #ccc; 1062 } 1063 1064 #your-profile #rich_editing { 1065 border: none; 1066 background: #fff; 809 1067 } 810 1068 … … 813 1071 float: left; 814 1072 width: 40%; 815 padding: .5em 2em ;816 margin: 1em ;1073 padding: .5em 2em 1em; 1074 margin: 1em 1em 1em 0; 817 1075 } 818 1076 … … 849 1107 } 850 1108 1109 #moremeta fieldset.dbx-box-closed { 1110 background: url(images/box-butt.gif) no-repeat bottom; 1111 padding-bottom: 9px; 1112 } 1113 851 1114 /* handles */ 852 1115 … … 869 1132 } 870 1133 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 871 1185 /* handle cursors */ 872 1186 .dbx-handle-cursor { 873 1187 cursor: move; 874 1188 } 875 1189 876 1190 /* toggle images */ 877 1191 a.dbx-toggle, a.dbx-toggle:visited { … … 903 1217 height: 22px; 904 1218 width: 22px; 1219 top: 3px; 1220 right: 5px; 905 1221 background-position: 0 -3px; 906 1222 } … … 909 1225 height: 22px; 910 1226 width: 22px; 1227 top: 3px; 1228 right: 5px; 911 1229 background-position: 0 -28px; 912 1230 } … … 924 1242 } 925 1243 926 #newcat { width: 120px; margin-right: 5px; } 927 input#catadd { background: #a4a4a4; 1244 #newcat { 1245 width: 120px; 1246 margin-right: 5px; 1247 } 1248 1249 input #catadd { 1250 background: #a4a4a4; 928 1251 border-bottom: 1px solid #898989; 929 1252 border-left: 1px solid #bcbcbc; … … 938 1261 margin-bottom: 2px; 939 1262 text-align: center; 940 width: 37px; } 1263 width: 37px; 1264 } 1265 941 1266 #howto { 942 1267 font-size: 11px; … … 944 1269 display: block; 945 1270 } 1271 946 1272 #jaxcat { 947 1273 margin: 0; 948 1274 padding: 0; 949 1275 } 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 1309 a.page-numbers { 1310 border: 1px solid #ccc; 1311 } 1312 1313 a.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 39 39 var aInputs = document.getElementsByTagName('input'); 40 40 41 for (var i = 0; i < aInputs.length; i++) { 41 for (var i = 0; i < aInputs.length; i++) { 42 42 aInputs[i].onclick = aInputs[i].onkeyup = upit; 43 43 } -
trunk/wp-atom.php
r3503 r4431 6 6 } 7 7 8 header('Content-type: application/atom+xml; charset=' . get_ settings('blog_charset'), true);8 header('Content-type: application/atom+xml; charset=' . get_option('blog_charset'), true); 9 9 $more = 1; 10 10 11 11 ?> 12 <?php echo '<?xml version="1.0" encoding="'.get_ settings('blog_charset').'"?'.'>'; ?>12 <?php echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?> 13 13 <feed version="0.3" 14 14 xmlns="http://purl.org/atom/ns#" … … 36 36 <?php the_category_rss('rdf') ?> 37 37 <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') ) : ?> 39 39 <content type="<?php bloginfo('html_type'); ?>" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content> 40 40 <?php endif; ?> … … 42 42 <?php do_action('atom_entry'); ?> 43 43 </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; } } } ?> 45 45 </feed> -
trunk/wp-blog-header.php
r3503 r4431 5 5 if ( strstr( $_SERVER['PHP_SELF'], 'wp-admin') ) $path = ''; 6 6 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 › Error"); 8 10 } 9 11 -
trunk/wp-comments-post.php
r3503 r4431 13 13 } elseif ( 'closed' == $status->comment_status ) { 14 14 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.') ); 16 16 } elseif ( 'draft' == $status->post_status ) { 17 17 do_action('comment_on_draft', $comment_post_ID); … … 25 25 26 26 // 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(); 28 if ( $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); 32 32 else : 33 33 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.') ); 35 35 endif; 36 36 37 37 $comment_type = ''; 38 38 39 if ( get_ settings('require_name_email') && !$user_ID ) {39 if ( get_option('require_name_email') && !$user->ID ) { 40 40 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).') ); 42 42 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.') ); 44 44 } 45 45 46 46 if ( '' == $comment_content ) 47 die( __('Error: please type a comment.') );47 wp_die( __('Error: please type a comment.') ); 48 48 49 49 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'user_ID'); 50 50 51 wp_new_comment( $commentdata );51 $comment_id = wp_new_comment( $commentdata ); 52 52 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); 54 if ( !$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); 57 58 endif; 58 59 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); 60 62 61 wp_redirect( $location);63 wp_redirect($location); 62 64 63 65 ?> -
trunk/wp-commentsrss2.php
r3503 r4431 6 6 } 7 7 8 header('Content-type: text/xml;charset=' . get_ settings('blog_charset'), true);8 header('Content-type: text/xml;charset=' . get_option('blog_charset'), true); 9 9 10 echo '<?xml version="1.0" encoding="'.get_ settings('blog_charset').'"?'.'>';10 echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; 11 11 ?> 12 12 <!-- generator="wordpress/<?php echo $wp_version ?>" --> … … 32 32 comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID, 33 33 $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' 36 36 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') ); 38 38 } else { // if no post id passed in, we'll just ue the last 10 comments. 39 39 $comments = $wpdb->get_results("SELECT comment_ID, comment_author, comment_author_email, 40 40 comment_author_url, comment_date, comment_date_gmt, comment_content, comment_post_ID, 41 41 $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' 43 43 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') ); 45 45 } 46 46 // this line is WordPress' motor, do not delete it. 47 47 if ($comments) { 48 48 foreach ($comments as $comment) { 49 $GLOBALS['comment'] =& $comment; 49 50 // Some plugins may need to know the metadata 50 51 // associated with this comment's post: … … 57 58 $title = apply_filters('the_title_rss', $title); 58 59 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()); 61 62 } ?></title> 62 63 <link><?php comment_link() ?></link> … … 78 79 </item> 79 80 <?php 80 } 81 } 81 82 } 82 83 } -
trunk/wp-config-sample.php
-
Property
svn:eol-style
changed from
CRLFtonative
-
Property
svn:eol-style
changed from
-
trunk/wp-content/plugins/hello.php
r3503 r4431 42 42 $lyrics = explode("\n", $lyrics); 43 43 // 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) ] ); 45 45 46 46 // This just echoes the chosen line, we'll position it later -
trunk/wp-content/themes/classic/comments-popup.php
r3503 r4431 7 7 <html xmlns="http://www.w3.org/1999/xhtml"> 8 8 <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> 10 10 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'); ?>" /> 12 12 <style type="text/css" media="screen"> 13 13 @import url( <?php bloginfo('stylesheet_url'); ?> ); … … 18 18 <body id="commentspopup"> 19 19 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> 21 21 22 22 <h2 id="comments"><?php _e("Comments"); ?></h2> 23 23 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> 25 25 26 26 <?php if ('open' == $post->ping_status) { ?> 27 <p><?php _e("The <a cronym 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> 28 28 <?php } ?> 29 29 30 30 <?php 31 31 // 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(); 33 extract($commenter); 35 34 $comments = get_approved_comments($id); 36 35 $commentstatus = get_post($id); … … 57 56 <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> 58 57 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"> 60 59 <p> 61 60 <input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" /> … … 72 71 <p> 73 72 <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="28" tabindex="3" /> 74 <label for="url"><?php _e("<a cronym title=\"Uniform Resource Identifier\">URI</acronym>"); ?></label>73 <label for="url"><?php _e("<abbr title=\"Universal Resource Locator\">URL</abbr>"); ?></label> 75 74 </p> 76 75 … … 104 103 <script type="text/javascript"> 105 104 <!-- 106 document.onkeypress = function esc(e) { 105 document.onkeypress = function esc(e) { 107 106 if(typeof(e) == "undefined") { e=event; } 108 107 if (e.keyCode == 27) { self.close(); } -
trunk/wp-content/themes/classic/comments.php
r3503 r4431 28 28 <p><?php comments_rss_link(__('<abbr title="Really Simple Syndication">RSS</abbr> feed for comments on this post.')); ?> 29 29 <?php if ( pings_open() ) : ?> 30 <a href="<?php trackback_url() ?>" rel="trackback"><?php _e('TrackBack <abbr title="Uni form Resource Identifier">URI</abbr>'); ?></a>30 <a href="<?php trackback_url() ?>" rel="trackback"><?php _e('TrackBack <abbr title="Universal Resource Locator">URL</abbr>'); ?></a> 31 31 <?php endif; ?> 32 32 </p> -
trunk/wp-content/themes/classic/header.php
r3503 r4431 6 6 7 7 <title><?php bloginfo('name'); ?><?php wp_title(); ?></title> 8 8 9 9 <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats please --> 10 10 … … 16 16 <link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" /> 17 17 <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" /> 18 18 19 19 <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" /> 20 20 <?php wp_get_archives('type=monthly&format=link'); ?> -
trunk/wp-content/themes/classic/index.php
r3503 r4431 6 6 7 7 <?php the_date('','<h2>','</h2>'); ?> 8 8 9 9 <div class="post" id="post-<?php the_ID(); ?>"> 10 10 <h3 class="storytitle"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3> 11 11 <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div> 12 12 13 13 <div class="storycontent"> 14 14 <?php the_content(__('(more...)')); ?> 15 15 </div> 16 16 17 17 <div class="feedback"> 18 18 <?php wp_link_pages(); ?> -
trunk/wp-content/themes/classic/sidebar.php
r3503 r4431 4 4 5 5 <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:')); ?> 13 9 <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'); ?>"> 16 12 <div> 17 13 <input type="text" name="s" id="s" size="15" /><br /> -
trunk/wp-content/themes/default/archive.php
r3503 r4431 6 6 7 7 <?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()) { ?> 9 9 <h2 class="pagetitle">Archive for the '<?php echo single_cat_title(); ?>' Category</h2> 10 10 11 11 <?php /* If this is a daily archive */ } elseif (is_day()) { ?> 12 12 <h2 class="pagetitle">Archive for <?php the_time('F jS, Y'); ?></h2> 13 13 14 14 <?php /* If this is a monthly archive */ } elseif (is_month()) { ?> 15 15 <h2 class="pagetitle">Archive for <?php the_time('F, Y'); ?></h2> … … 17 17 <?php /* If this is a yearly archive */ } elseif (is_year()) { ?> 18 18 <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 23 20 <?php /* If this is an author archive */ } elseif (is_author()) { ?> 24 21 <h2 class="pagetitle">Author Archive</h2> … … 39 36 <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> 40 37 <small><?php the_time('l, F jS, Y') ?></small> 41 38 42 39 <div class="entry"> 43 40 <?php the_content() ?> 44 41 </div> 45 42 46 43 <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p> 47 44 48 45 </div> 49 46 50 47 <?php endwhile; ?> 51 48 … … 54 51 <div class="alignright"><?php previous_posts_link('Next Entries »') ?></div> 55 52 </div> 56 53 57 54 <?php else : ?> 58 55 … … 61 58 62 59 <?php endif; ?> 63 60 64 61 </div> 65 62 -
trunk/wp-content/themes/default/archives.php
r3503 r4431 18 18 <h2>Archives by Subject:</h2> 19 19 <ul> 20 <?php wp_list_cat s(); ?>20 <?php wp_list_categories(); ?> 21 21 </ul> 22 22 23 </div> 23 </div> 24 24 25 25 <?php get_footer(); ?> -
trunk/wp-content/themes/default/attachment.php
r3503 r4431 2 2 3 3 <div id="content" class="widecolumn"> 4 4 5 5 <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 6 6 7 7 <div class="navigation"> 8 8 <div class="alignleft"> </div> … … 13 13 <div class="post" id="post-<?php the_ID(); ?>"> 14 14 <h2><a href="<?php echo get_permalink($post->post_parent); ?>" rev="attachment"><?php echo get_the_title($post->post_parent); ?></a> » <a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2> 15 <div class="entry text">15 <div class="entry"> 16 16 <p class="<?php echo $classname; ?>"><?php echo $attachment_link; ?><br /><?php echo basename($post->guid); ?></p> 17 17 18 18 <?php the_content('<p class="serif">Read the rest of this entry »</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 22 22 <p class="postmetadata alt"> 23 23 <small> … … 30 30 and is filed under <?php the_category(', ') ?>. 31 31 You can follow any responses to this entry through the <?php comments_rss_link('RSS 2.0'); ?> feed. 32 32 33 33 <?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) { 34 34 // Both Comments and Pings are open ?> 35 35 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 37 37 <?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) { 38 38 // Only Pings are Open ?> 39 39 Responses are currently closed, but you can <a href="<?php trackback_url(true); ?> " rel="trackback">trackback</a> from your own site. 40 40 41 41 <?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) { 42 42 // Comments are open, Pings are not ?> 43 43 You can skip to the end and leave a response. Pinging is currently not allowed. 44 44 45 45 <?php } elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) { 46 46 // Neither Comments, nor Pings are open ?> 47 Both comments and pings are currently closed. 48 47 Both comments and pings are currently closed. 48 49 49 <?php } edit_post_link('Edit this entry.','',''); ?> 50 50 51 51 </small> 52 52 </p> 53 53 54 54 </div> 55 55 </div> 56 56 57 57 <?php comments_template(); ?> 58 58 59 59 <?php endwhile; else: ?> 60 60 61 61 <p>Sorry, no attachments matched your criteria.</p> 62 62 63 63 <?php endif; ?> 64 64 65 65 </div> 66 66 -
trunk/wp-content/themes/default/comments-popup.php
r3503 r4431 7 7 <html xmlns="http://www.w3.org/1999/xhtml"> 8 8 <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> 10 10 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'); ?>" /> 12 12 <style type="text/css" media="screen"> 13 13 @import url( <?php bloginfo('stylesheet_url'); ?> ); … … 18 18 <body id="commentspopup"> 19 19 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> 21 21 22 22 <h2 id="comments">Comments</h2> 23 23 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> 25 25 26 26 <?php if ('open' == $post->ping_status) { ?> 27 <p>The <a cronym 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> 28 28 <?php } ?> 29 29 30 30 <?php 31 31 // 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(); 33 extract($commenter); 35 34 $comments = get_approved_comments($id); 36 35 $post = get_post($id); … … 57 56 <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> 58 57 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"> 60 59 <p> 61 60 <input type="text" name="author" id="author" class="textarea" value="<?php echo $comment_author; ?>" size="28" tabindex="1" /> … … 72 71 <p> 73 72 <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="28" tabindex="3" /> 74 <label for="url"><a cronym title="Uniform Resource Identifier">URI</acronym></label>73 <label for="url"><abbr title="Universal Resource Locator">URL</abbr></label> 75 74 </p> 76 75 … … 104 103 <script type="text/javascript"> 105 104 <!-- 106 document.onkeypress = function esc(e) { 105 document.onkeypress = function esc(e) { 107 106 if(typeof(e) == "undefined") { e=event; } 108 107 if (e.keyCode == 27) { self.close(); } -
trunk/wp-content/themes/default/comments.php
r3503 r4431 6 6 if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) { // and it doesn't match the cookie 7 7 ?> 8 8 9 9 <p class="nocomments">This post is password protected. Enter the password to view comments.<p> 10 10 11 11 <?php 12 12 return; … … 40 40 </li> 41 41 42 <?php /* Changes every other comment to a different class */ 42 <?php /* Changes every other comment to a different class */ 43 43 if ('alt' == $oddcomment) $oddcomment = ''; 44 44 else $oddcomment = 'alt'; … … 53 53 <?php if ('open' == $post->comment_status) : ?> 54 54 <!-- If comments are open, but there are no comments. --> 55 55 56 56 <?php else : // comments are closed ?> 57 57 <!-- If comments are closed. --> 58 58 <p class="nocomments">Comments are closed.</p> 59 59 60 60 <?php endif; ?> 61 61 <?php endif; ?> -
trunk/wp-content/themes/default/footer.php
r3503 r4431 2 2 <hr /> 3 3 <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. --> 4 5 <p> 5 6 <?php bloginfo('name'); ?> is proudly powered by -
trunk/wp-content/themes/default/functions.php
r3503 r4431 22 22 23 23 function 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')); 25 25 } 26 26 … … 51 51 52 52 function 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')); 54 54 } 55 55 … … 58 58 if ( false === $color ) 59 59 return 'white'; 60 60 61 61 return $color; 62 62 } 63 63 64 64 function 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')); 66 66 } 67 67 … … 94 94 95 95 if ( isset($_REQUEST['toggledisplay']) ) { 96 if ( false === get_ settings('kubrick_header_display') )96 if ( false === get_option('kubrick_header_display') ) 97 97 update_option('kubrick_header_display', 'none'); 98 98 else … … 101 101 } 102 102 } else { 103 103 104 104 if ( isset($_REQUEST['headerimage']) ) { 105 105 if ( '' == $_REQUEST['headerimage'] ) … … 108 108 update_option('kubrick_header_image', $_REQUEST['headerimage']); 109 109 } 110 110 111 111 if ( isset($_REQUEST['fontcolor']) ) { 112 112 if ( '' == $_REQUEST['fontcolor'] ) … … 115 115 update_option('kubrick_header_color', $_REQUEST['fontcolor']); 116 116 } 117 117 118 118 if ( isset($_REQUEST['fontdisplay']) ) { 119 119 if ( '' == $_REQUEST['fontdisplay'] || 'inline' == $_REQUEST['fontdisplay'] ) … … 124 124 } 125 125 //print_r($_REQUEST); 126 header("Location:themes.php?page=functions.php&saved=true");126 wp_redirect("themes.php?page=functions.php&saved=true"); 127 127 die; 128 128 } … … 136 136 <script type="text/javascript" src="../wp-includes/js/colorpicker.js"></script> 137 137 <script type='text/javascript'> 138 // <![CDATA[ 138 139 function pickColor(color) { 139 140 ColorPicker_targetInput.value = color; … … 240 241 } 241 242 addLoadEvent(kInit); 243 // ]]> 242 244 </script> 243 245 <style type='text/css'> … … 269 271 font-size: 1.2em; 270 272 text-align: center; 271 } 273 } 272 274 #kubrick-header #header { 273 275 text-decoration: none; … … 352 354 <br /> 353 355 <div id="nonJsForm"> 354 <form method=" POST">356 <form method="post" action=""> 355 357 <div class="zerosize"><input type="submit" name="defaultsubmit" value="Save" /></div> 356 358 <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 /> … … 358 360 <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 /> 359 361 <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" /> 361 363 <input type="submit" name="defaults" value="Use Defaults" /> 362 364 <input type="submit" class="defbutton" name="submitform" value=" Save " /> … … 372 374 <input type="button" name="revert" value="Revert" onclick="kRevert()" /> 373 375 <input type="button" value="Advanced" onclick="toggleAdvanced()" /> 374 <input type="submit" name="submitform" class="defbutton" value="Save" onclick="cp.hidePopup('prettyplease')" />375 376 <input type="hidden" name="action" value="save" /> 376 377 <input type="hidden" name="fontdisplay" id="fontdisplay" value="<?php echo kubrick_header_display(); ?>" /> … … 379 380 <input type="hidden" name="lowercolor" id="lowercolor" value="<?php echo kubrick_lower_color(); ?>" /> 380 381 <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 »'); ?>" onclick="cp.hidePopup('prettyplease')" /></p> 381 383 </form> 382 384 <div id="colorPickerDiv" style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;visibility:hidden;"> </div> 383 385 <div id="advanced"> 384 <form id="jsAdvanced" style="display:none;" >386 <form id="jsAdvanced" style="display:none;" action=""> 385 387 <label for="advfontcolor">Font Color (CSS): </label><input type="text" id="advfontcolor" onchange="advUpdate(this.value, 'fontcolor')" value="<?php echo kubrick_header_color(); ?>" /><br /> 386 388 <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 14 14 15 15 <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 19 if ( !$withcomments && !is_single() ) { 20 ?> 22 21 #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbg.jpg") repeat-y top; border: none; } 23 22 <?php } else { // No sidebar ?> 24 23 #page { background: url("<?php bloginfo('stylesheet_directory'); ?>/images/kubrickbgwide.jpg") repeat-y top; border: none; } 25 24 <?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;}28 25 29 /* Because the template is slightly different, size-wise, with images, this needs to be set here30 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 will38 get cropped off of the image. */39 /*40 #headerimg { background: url('<?php bloginfo('stylesheet_directory'); ?>/images/personalheader.jpg') no-repeat top;}41 */42 26 </style> 43 27 … … 50 34 <div id="header"> 51 35 <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> 53 37 <div class="description"><?php bloginfo('description'); ?></div> 54 38 </div> -
trunk/wp-content/themes/default/index.php
r3503 r4431 4 4 5 5 <?php if (have_posts()) : ?> 6 6 7 7 <?php while (have_posts()) : the_post(); ?> 8 8 9 9 <div class="post" id="post-<?php the_ID(); ?>"> 10 10 <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2> 11 11 <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small> 12 12 13 13 <div class="entry"> 14 14 <?php the_content('Read the rest of this entry »'); ?> 15 15 </div> 16 16 17 17 <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p> 18 18 </div> 19 19 20 20 <?php endwhile; ?> 21 21 … … 24 24 <div class="alignright"><?php previous_posts_link('Next Entries »') ?></div> 25 25 </div> 26 26 27 27 <?php else : ?> 28 28 -
trunk/wp-content/themes/default/links.php
r3503 r4431 14 14 </ul> 15 15 16 </div> 16 </div> 17 17 18 18 <?php get_footer(); ?> -
trunk/wp-content/themes/default/page.php
r3503 r4431 6 6 <div class="post" id="post-<?php the_ID(); ?>"> 7 7 <h2><?php the_title(); ?></h2> 8 <div class="entry text">8 <div class="entry"> 9 9 <?php the_content('<p class="serif">Read the rest of this page »</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 13 13 </div> 14 14 </div> -
trunk/wp-content/themes/default/search.php
r3503 r4431 6 6 7 7 <h2 class="pagetitle">Search Results</h2> 8 8 9 9 <div class="navigation"> 10 10 <div class="alignleft"><?php next_posts_link('« Previous Entries') ?></div> … … 14 14 15 15 <?php while (have_posts()) : the_post(); ?> 16 16 17 17 <div class="post"> 18 18 <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> 19 19 <small><?php the_time('l, F jS, Y') ?></small> 20 20 21 21 <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p> 22 22 </div> 23 23 24 24 <?php endwhile; ?> 25 25 … … 28 28 <div class="alignright"><?php previous_posts_link('Next Entries »') ?></div> 29 29 </div> 30 30 31 31 <?php else : ?> 32 32 … … 35 35 36 36 <?php endif; ?> 37 37 38 38 </div> 39 39 -
trunk/wp-content/themes/default/searchform.php
r3503 r4431 1 1 <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" /> 3 3 <input type="submit" id="searchsubmit" value="Search" /> 4 4 </div> -
trunk/wp-content/themes/default/sidebar.php
r3503 r4431 1 1 <div id="sidebar"> 2 2 <ul> 3 3 4 4 <li> 5 5 <?php include (TEMPLATEPATH . '/searchform.php'); ?> … … 16 16 <?php /* If this is a category archive */ } elseif (is_category()) { ?> 17 17 <p>You are currently browsing the archives for the <?php single_cat_title(''); ?> category.</p> 18 18 19 19 <?php /* If this is a yearly archive */ } elseif (is_day()) { ?> 20 20 <p>You are currently browsing the <a href="<?php bloginfo('home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives 21 21 for the day <?php the_time('l, F jS, Y'); ?>.</p> 22 22 23 23 <?php /* If this is a monthly archive */ } elseif (is_month()) { ?> 24 24 <p>You are currently browsing the <a href="<?php bloginfo('home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives … … 28 28 <p>You are currently browsing the <a href="<?php bloginfo('home'); ?>/"><?php echo bloginfo('name'); ?></a> weblog archives 29 29 for the year <?php the_time('Y'); ?>.</p> 30 30 31 31 <?php /* If this is a monthly archive */ } elseif (is_search()) { ?> 32 32 <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> 34 34 35 35 <?php /* If this is a monthly archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?> … … 47 47 </li> 48 48 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>'); ?> 54 50 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 58 54 <li><h2>Meta</h2> 59 55 <ul> … … 67 63 </li> 68 64 <?php } ?> 69 65 70 66 </ul> 71 67 </div> -
trunk/wp-content/themes/default/single.php
r3503 r4431 2 2 3 3 <div id="content" class="widecolumn"> 4 4 5 5 <?php if (have_posts()) : while (have_posts()) : the_post(); ?> 6 6 7 7 <div class="navigation"> 8 8 <div class="alignleft"><?php previous_post_link('« %link') ?></div> 9 9 <div class="alignright"><?php next_post_link('%link »') ?></div> 10 10 </div> 11 11 12 12 <div class="post" id="post-<?php the_ID(); ?>"> 13 13 <h2><a href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a></h2> 14 15 <div class="entry text">14 15 <div class="entry"> 16 16 <?php the_content('<p class="serif">Read the rest of this entry »</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 20 20 <p class="postmetadata alt"> 21 21 <small> … … 28 28 and is filed under <?php the_category(', ') ?>. 29 29 You can follow any responses to this entry through the <?php comments_rss_link('RSS 2.0'); ?> feed. 30 30 31 31 <?php if (('open' == $post-> comment_status) && ('open' == $post->ping_status)) { 32 32 // Both Comments and Pings are open ?> 33 33 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 35 35 <?php } elseif (!('open' == $post-> comment_status) && ('open' == $post->ping_status)) { 36 36 // Only Pings are Open ?> 37 37 Responses are currently closed, but you can <a href="<?php trackback_url(true); ?> " rel="trackback">trackback</a> from your own site. 38 38 39 39 <?php } elseif (('open' == $post-> comment_status) && !('open' == $post->ping_status)) { 40 40 // Comments are open, Pings are not ?> 41 41 You can skip to the end and leave a response. Pinging is currently not allowed. 42 42 43 43 <?php } elseif (!('open' == $post-> comment_status) && !('open' == $post->ping_status)) { 44 44 // Neither Comments, nor Pings are open ?> 45 Both comments and pings are currently closed. 46 45 Both comments and pings are currently closed. 46 47 47 <?php } edit_post_link('Edit this entry.','',''); ?> 48 48 49 49 </small> 50 50 </p> 51 51 52 52 </div> 53 53 </div> 54 54 55 55 <?php comments_template(); ?> 56 56 57 57 <?php endwhile; else: ?> 58 58 59 59 <p>Sorry, no posts matched your criteria.</p> 60 60 61 61 <?php endif; ?> 62 62 63 63 </div> 64 64 -
trunk/wp-content/themes/default/style.css
r3503 r4431 3 3 Theme URI: http://wordpress.org/ 4 4 Description: The default WordPress theme based on the famous <a href="http://binarybonsai.com/kubrick/">Kubrick</a>. 5 Version: 1. 55 Version: 1.6 6 6 Author: Michael Heilemann 7 7 Author URI: http://binarybonsai.com/ … … 15 15 The CSS, XHTML and design is released under GPL: 16 16 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 24 18 */ 25 19 … … 30 24 font-size: 62.5%; /* Resets 1em to 10px */ 31 25 font-family: 'Lucida Grande', Verdana, Arial, Sans-Serif; 32 background -color: #d5d6d7;26 background: #d5d6d7 url('images/kubrickbgcolor.jpg'); 33 27 color: #333; 34 28 text-align: center; … … 42 36 43 37 #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 } 46 46 47 47 #content { … … 60 60 line-height: 1.6em; 61 61 } 62 62 63 63 .narrowcolumn .postmetadata { 64 64 text-align: center; … … 72 72 73 73 #footer { 74 background-color: #eee; 74 background: #eee url('images/kubrickfooter.jpg') no-repeat top; 75 border: none; 75 76 } 76 77 … … 133 134 font: 0.9em 'Lucida Grande', Verdana, Arial, Sans-Serif; 134 135 } 135 136 136 137 .commentlist li { 137 138 font-weight: bold; … … 165 166 color: #777; 166 167 } 167 168 168 169 code { 169 170 font: 1.1em 'Courier New', Courier, Fixed; … … 185 186 text-decoration: underline; 186 187 } 187 188 188 189 #wp-calendar #prev a { 189 190 font-size: 9pt; … … 209 210 /* Begin Structure */ 210 211 body { 211 margin: 0 ;212 margin: 0 0 20px 0; 212 213 padding: 0; 213 214 } … … 220 221 border: 1px solid #959596; 221 222 } 222 223 223 224 #header { 224 padding: 0;225 margin: 0 auto;226 height: 200px;227 width: 100%;228 225 background-color: #73a0c5; 226 margin: 0 0 0 1px; 227 padding: 0; 228 height: 200px; 229 width: 758px; 229 230 } 230 231 … … 247 248 width: 450px; 248 249 } 249 250 250 251 .post { 251 252 margin: 0 0 40px; … … 282 283 283 284 #footer { 284 padding: 0 0 0 1px;285 padding: 0; 285 286 margin: 0 auto; 286 287 width: 760px; … … 340 341 will of course center the image. This is much better than using 341 342 align="center", being much more futureproof (and valid) */ 342 343 343 344 img.centered { 344 345 display: block; … … 346 347 margin-right: auto; 347 348 } 348 349 349 350 img.alignright { 350 351 padding: 4px; … … 362 363 float: right; 363 364 } 364 365 365 366 .alignleft { 366 367 float: left … … 406 407 list-style-image: none; 407 408 } 408 409 409 410 #sidebar ul, #sidebar ul ol { 410 411 margin: 0; … … 450 451 451 452 #sidebar #searchform #s { 452 width: 1 15px;453 width: 108px; 453 454 padding: 2px; 454 455 } -
trunk/wp-feed.php
r3503 r4431 6 6 } 7 7 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 } 8 do_feed(); 36 9 37 10 ?> -
trunk/wp-includes/cache.php
r3503 r4431 48 48 } 49 49 50 define('CACHE_SERIAL_HEADER', "<?php\n/ /");51 define('CACHE_SERIAL_FOOTER', " \n?".">");50 define('CACHE_SERIAL_HEADER', "<?php\n/*"); 51 define('CACHE_SERIAL_FOOTER', "*/\n?".">"); 52 52 53 53 class WP_Object_Cache { … … 65 65 var $warm_cache_hits = 0; 66 66 var $cache_misses = 0; 67 var $secret = ''; 67 68 68 69 function acquire_lock() { … … 104 105 if ( ! $this->acquire_lock() ) 105 106 return false; 106 107 107 108 $this->rm_cache_dir(); 108 109 $this->cache = array (); 109 110 $this->dirty_objects = array (); 110 111 $this->non_existant_objects = array (); 111 112 112 113 $this->release_lock(); 113 114 … … 143 144 } 144 145 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'; 146 147 if (!file_exists($cache_file)) { 147 148 $this->non_existant_objects[$group][$id] = true; … … 159 160 } 160 161 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)))); 162 163 if (false === $this->cache[$group][$id]) 163 164 $this->cache[$group][$id] = ''; … … 172 173 173 174 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 } 174 183 } 175 184 … … 182 191 foreach ($dogs as $catt) 183 192 $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 }194 193 } 195 194 } else … … 249 248 if ($file == '.' or $file == '..') 250 249 continue; 251 250 252 251 if (@ is_dir($dir . DIRECTORY_SEPARATOR . $file)) 253 252 $stack[] = $dir . DIRECTORY_SEPARATOR . $file; … … 333 332 $ids = array_unique($ids); 334 333 foreach ($ids as $id) { 335 $cache_file = $group_dir. md5($id.DB_PASSWORD).'.php';334 $cache_file = $group_dir.$this->hash($id).'.php'; 336 335 337 336 // Remove the cache file if the key is not set. … … 343 342 344 343 $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; 346 345 $fd = @fopen($temp_file, 'w'); 347 346 if ( false === $fd ) { … … 355 354 @ unlink($temp_file); 356 355 else 357 $errors++; 356 $errors++; 358 357 } 359 358 @ chmod($cache_file, $file_perms); … … 364 363 365 364 $this->release_lock(); 366 365 367 366 if ( $errors ) 368 367 return false; … … 401 400 return; 402 401 402 if ( ! defined('ENABLE_CACHE') ) 403 return; 404 403 405 // Disable the persistent cache if safe_mode is on. 404 406 if ( ini_get('safe_mode') && ! defined('ENABLE_CACHE') ) … … 422 424 $this->expiration_time = CACHE_EXPIRATION_TIME; 423 425 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); 425 432 } 426 433 } -
trunk/wp-includes/capabilities.php
r3503 r4431 7 7 var $role_names = array(); 8 8 var $role_key; 9 var $use_db = true; 9 10 10 11 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 } 15 25 16 26 if ( empty($this->roles) ) 17 27 return; 18 28 29 $this->role_objects = array(); 30 $this->role_names = array(); 19 31 foreach ($this->roles as $role => $data) { 20 32 $this->role_objects[$role] = new WP_Role($role, $this->roles[$role]['capabilities']); … … 30 42 'name' => $display_name, 31 43 'capabilities' => $capabilities); 32 update_option($this->role_key, $this->roles); 44 if ( $this->use_db ) 45 update_option($this->role_key, $this->roles); 33 46 $this->role_objects[$role] = new WP_Role($role, $capabilities); 34 47 $this->role_names[$role] = $display_name; 35 48 return $this->role_objects[$role]; 36 49 } 37 50 38 51 function remove_role($role) { 39 52 if ( ! isset($this->role_objects[$role]) ) 40 53 return; 41 54 42 55 unset($this->role_objects[$role]); 43 56 unset($this->role_names[$role]); 44 57 unset($this->roles[$role]); 45 58 46 update_option($this->role_key, $this->roles); 59 if ( $this->use_db ) 60 update_option($this->role_key, $this->roles); 47 61 } 48 62 49 63 function add_cap($role, $cap, $grant = true) { 50 64 $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); 52 67 } 53 68 54 69 function remove_cap($role, $cap) { 55 70 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); 57 73 } 58 74 … … 71 87 { 72 88 return isset($this->role_names[$role]); 73 } 89 } 74 90 } 75 91 … … 122 138 123 139 function WP_User($id, $name = '') { 124 global $ table_prefix;140 global $wpdb; 125 141 126 142 if ( empty($id) && empty($name) ) … … 145 161 146 162 $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'; 148 169 $this->caps = &$this->{$this->cap_key}; 149 170 if ( ! is_array($this->caps) ) … … 151 172 $this->get_role_caps(); 152 173 } 153 174 154 175 function get_role_caps() { 155 176 global $wp_roles; 156 177 157 178 if ( ! isset($wp_roles) ) 158 179 $wp_roles = new WP_Roles(); … … 164 185 //Build $allcaps from role caps, overlay user's $caps 165 186 $this->allcaps = array(); 166 foreach( $this->roles as $role) {187 foreach( (array) $this->roles as $role) { 167 188 $role = $wp_roles->get_role($role); 168 189 $this->allcaps = array_merge($this->allcaps, $role->capabilities); … … 170 191 $this->allcaps = array_merge($this->allcaps, $this->caps); 171 192 } 172 193 173 194 function add_role($role) { 174 195 $this->caps[$role] = true; … … 177 198 $this->update_user_level_from_caps(); 178 199 } 179 200 180 201 function remove_role($role) { 181 202 if ( empty($this->roles[$role]) || (count($this->roles) <= 1) ) … … 185 206 $this->get_role_caps(); 186 207 } 187 208 188 209 function set_role($role) { 189 foreach($this->roles as $oldrole) 210 foreach($this->roles as $oldrole) 190 211 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 } 193 218 update_usermeta($this->id, $this->cap_key, $this->caps); 194 219 $this->get_role_caps(); … … 204 229 } 205 230 } 206 231 207 232 function update_user_level_from_caps() { 208 global $ table_prefix;233 global $wpdb; 209 234 $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 213 238 function add_cap($cap, $grant = true) { 214 239 $this->caps[$cap] = $grant; … … 221 246 update_usermeta($this->id, $this->cap_key, $this->caps); 222 247 } 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 224 257 //has_cap(capability_or_role_name) or 225 258 //has_cap('edit_post', post_id) … … 227 260 if ( is_numeric($cap) ) 228 261 $cap = $this->translate_level_to_cap($cap); 229 262 230 263 $args = array_slice(func_get_args(), 1); 231 264 $args = array_merge(array($cap, $this->id), $args); … … 254 287 255 288 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; 256 347 // edit_post breaks down to edit_posts, edit_published_posts, or 257 348 // edit_others_posts … … 260 351 //echo "post ID: {$args[0]}<br/>"; 261 352 $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 } 262 357 $post_author_data = get_userdata($post->post_author); 263 358 //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br/>"; … … 267 362 if ($post->post_status == 'publish') 268 363 $caps[] = 'edit_published_posts'; 269 else if ($post->post_status == 'static')270 $caps[] = 'edit_pages';271 364 else 272 365 // If the post is draft... 273 366 $caps[] = 'edit_posts'; 274 367 } else { 275 if ($post->post_status == 'static') {276 $caps[] = 'edit_pages';277 break;278 }279 280 368 // The user is trying to edit someone else's post. 281 369 $caps[] = 'edit_others_posts'; … … 283 371 if ($post->post_status == 'publish') 284 372 $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'; 285 399 } 286 400 break; 287 401 case 'read_post': 288 402 $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 290 408 if ( 'private' != $post->post_status ) { 291 409 $caps[] = 'read'; 292 break; 293 } 294 410 break; 411 } 412 295 413 $author_data = get_userdata($user_id); 296 414 $post_author_data = get_userdata($post->post_author); … … 300 418 $caps[] = 'read_private_posts'; 301 419 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; 302 435 default: 303 436 // If no meta caps match, return the original cap. … … 310 443 // Capability checking wrapper around the global $current_user object. 311 444 function current_user_can($capability) { 312 global $current_user;445 $current_user = wp_get_current_user(); 313 446 314 447 $args = array_slice(func_get_args(), 1); … … 349 482 } 350 483 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 delete385 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 it403 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 comments409 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 else418 return false;419 }420 421 484 ?> -
trunk/wp-includes/class-snoopy.php
r3503 r4431 40 40 { 41 41 /**** Public variables ****/ 42 42 43 43 /* user definable vars */ 44 44 … … 49 49 var $proxy_user = ""; // proxy user to use 50 50 var $proxy_pass = ""; // proxy password to use 51 51 52 52 var $agent = "Snoopy v1.2.3"; // agent we masquerade as 53 53 var $referer = ""; // referer info to pass … … 67 67 // NOTE: this currently does not respect 68 68 // dates, domains or paths. 69 69 70 70 var $user = ""; // user for http authentication 71 71 var $pass = ""; // password for http authentication 72 72 73 73 // http accept types 74 74 var $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; 75 75 76 76 var $results = ""; // where the content is put 77 77 78 78 var $error = ""; // error messages sent here 79 79 var $response_code = ""; // response code returned from server 80 80 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) 82 82 var $read_timeout = 0; // timeout on read operations, in seconds 83 83 // supported only since PHP 4 Beta 4 … … 101 101 // as these functions are not stable 102 102 // as of this Snoopy release. 103 104 /**** Private variables ****/ 105 103 104 /**** Private variables ****/ 105 106 106 var $_maxlinelen = 4096; // max line length (headers) 107 107 108 108 var $_httpmethod = "GET"; // default http request method 109 109 var $_httpversion = "HTTP/1.0"; // default http request version … … 115 115 var $_frameurls = array(); // frame src urls 116 116 var $_framedepth = 0; // increments on frame depth 117 117 118 118 var $_isproxy = false; // set if using a proxy server 119 119 var $_fp_timeout = 30; // timeout for socket connection … … 130 130 function fetch($URI) 131 131 { 132 132 133 133 //preg_match("|^([^:]+)://([^:/]+)(:[\d]+)*(.*)|",$URI,$URI_PARTS); 134 134 $URI_PARTS = parse_url($URI); … … 141 141 if (empty($URI_PARTS["path"])) 142 142 $URI_PARTS["path"] = ''; 143 143 144 144 switch(strtolower($URI_PARTS["scheme"])) 145 145 { … … 161 161 $this->_httprequest($path, $fp, $URI, $this->_httpmethod); 162 162 } 163 163 164 164 $this->_disconnect($fp); 165 165 … … 184 184 $frameurls = $this->_frameurls; 185 185 $this->_frameurls = array(); 186 186 187 187 while(list(,$frameurl) = each($frameurls)) 188 188 { … … 195 195 break; 196 196 } 197 } 197 } 198 198 } 199 199 else … … 201 201 return false; 202 202 } 203 return true; 203 return true; 204 204 break; 205 205 case "https": … … 255 255 break; 256 256 } 257 } 258 return true; 257 } 258 return true; 259 259 break; 260 260 default: … … 263 263 return false; 264 264 break; 265 } 265 } 266 266 return true; 267 267 } … … 281 281 { 282 282 unset($postdata); 283 283 284 284 $postdata = $this->_prepare_post_body($formvars, $formfiles); 285 285 286 286 $URI_PARTS = parse_url($URI); 287 287 if (!empty($URI_PARTS["user"])) … … 313 313 $this->_httprequest($path, $fp, $URI, $this->_submit_method, $this->_submit_type, $postdata); 314 314 } 315 315 316 316 $this->_disconnect($fp); 317 317 … … 320 320 /* url was redirected, check if we've hit the max depth */ 321 321 if($this->maxredirs > $this->_redirectdepth) 322 { 322 { 323 323 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 326 326 // only follow redirect if it's on this site, or offsiteok is true 327 327 if(preg_match("|^http://".preg_quote($this->host)."|i",$this->_redirectaddr) || $this->offsiteok) … … 342 342 $frameurls = $this->_frameurls; 343 343 $this->_frameurls = array(); 344 344 345 345 while(list(,$frameurl) = each($frameurls)) 346 { 346 { 347 347 if($this->_framedepth < $this->maxframes) 348 348 { … … 353 353 break; 354 354 } 355 } 356 355 } 356 357 357 } 358 358 else … … 360 360 return false; 361 361 } 362 return true; 362 return true; 363 363 break; 364 364 case "https": … … 387 387 /* url was redirected, check if we've hit the max depth */ 388 388 if($this->maxredirs > $this->_redirectdepth) 389 { 389 { 390 390 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"]); 392 392 393 393 // only follow redirect if it's on this site, or offsiteok is true … … 411 411 412 412 while(list(,$frameurl) = each($frameurls)) 413 { 413 { 414 414 if($this->_framedepth < $this->maxframes) 415 415 { … … 420 420 break; 421 421 } 422 } 423 return true; 422 } 423 return true; 424 424 break; 425 425 426 426 default: 427 427 // not a valid protocol … … 429 429 return false; 430 430 break; 431 } 431 } 432 432 return true; 433 433 } … … 443 443 { 444 444 if ($this->fetch($URI)) 445 { 445 { 446 446 if($this->lastredirectaddr) 447 447 $URI = $this->lastredirectaddr; … … 471 471 function fetchform($URI) 472 472 { 473 473 474 474 if ($this->fetch($URI)) 475 { 475 { 476 476 477 477 if(is_array($this->results)) … … 482 482 else 483 483 $this->results = $this->_stripform($this->results); 484 484 485 485 return true; 486 486 } … … 488 488 return false; 489 489 } 490 491 490 491 492 492 /*======================================================================*\ 493 493 Function: fetchtext … … 500 500 { 501 501 if($this->fetch($URI)) 502 { 502 { 503 503 if(is_array($this->results)) 504 504 { … … 524 524 { 525 525 if($this->submit($URI,$formvars, $formfiles)) 526 { 526 { 527 527 if($this->lastredirectaddr) 528 528 $URI = $this->lastredirectaddr; … … 558 558 { 559 559 if($this->submit($URI,$formvars, $formfiles)) 560 { 560 { 561 561 if($this->lastredirectaddr) 562 562 $URI = $this->lastredirectaddr; … … 582 582 } 583 583 584 584 585 585 586 586 /*======================================================================*\ … … 594 594 } 595 595 596 596 597 597 /*======================================================================*\ 598 598 Function: set_submit_normal … … 605 605 } 606 606 607 608 607 608 609 609 610 610 /*======================================================================*\ 611 611 Private functions 612 612 \*======================================================================*/ 613 614 613 614 615 615 /*======================================================================*\ 616 616 Function: _striplinks … … 621 621 622 622 function _striplinks($document) 623 { 623 { 624 624 preg_match_all("'<\s*a\s.*?href\s*=\s* # find <a href= 625 625 ([\"\'])? # find single or double quote … … 627 627 # quote, otherwise match up to next space 628 628 'isx",$document,$links); 629 629 630 630 631 631 // catenate the non-empty matches from the conditional subpattern … … 635 635 if(!empty($val)) 636 636 $match[] = $val; 637 } 638 637 } 638 639 639 while(list($key,$val) = each($links[3])) 640 640 { 641 641 if(!empty($val)) 642 642 $match[] = $val; 643 } 644 643 } 644 645 645 // return the links 646 646 return $match; … … 655 655 656 656 function _stripform($document) 657 { 657 { 658 658 preg_match_all("'<\/?(FORM|INPUT|SELECT|TEXTAREA|(OPTION))[^<>]*>(?(2)(.*(?=<\/?(option|select)[^<>]*>[\r\n]*)|(?=[\r\n]*))|(?=[\r\n]*))'Usi",$document,$elements); 659 659 660 660 // catenate the matches 661 661 $match = implode("\r\n",$elements[0]); 662 662 663 663 // return the links 664 664 return $match; 665 665 } 666 666 667 668 667 668 669 669 /*======================================================================*\ 670 670 Function: _striptext … … 676 676 function _striptext($document) 677 677 { 678 678 679 679 // I didn't use preg eval (//e) since that is only available in PHP 4.0. 680 680 // so, list your entities one by one here. I included some of the 681 681 // more common ones. 682 682 683 683 $search = array("'<script[^>]*?>.*?</script>'si", // strip out javascript 684 684 "'<[\/\!]*?[^<>]*?>'si", // strip out html tags … … 729 729 "ß", 730 730 ); 731 731 732 732 $text = preg_replace($search,$replace,$document); 733 733 734 734 return $text; 735 735 } … … 745 745 function _expandlinks($links,$URI) 746 746 { 747 747 748 748 preg_match("/^[^\?]+/",$URI,$match); 749 749 … … 753 753 $match_root = 754 754 $match_part["scheme"]."://".$match_part["host"]; 755 755 756 756 $search = array( "|^http://".preg_quote($this->host)."|i", 757 757 "|^(\/)|i", … … 760 760 "|/[^\/]+/\.\./|" 761 761 ); 762 762 763 763 $replace = array( "", 764 764 $match_root."/", … … 766 766 "/", 767 767 "/" 768 ); 769 768 ); 769 770 770 $expandedLinks = preg_replace($search,$replace,$links); 771 771 … … 780 780 $URI the full URI 781 781 $body body contents to send if any (POST) 782 Output: 783 \*======================================================================*/ 784 782 Output: 783 \*======================================================================*/ 784 785 785 function _httprequest($url,$fp,$URI,$http_method,$content_type="",$body="") 786 786 { … … 788 788 if($this->passcookies && $this->_redirectaddr) 789 789 $this->setcookies(); 790 790 791 791 $URI_PARTS = parse_url($URI); 792 792 if(empty($url)) 793 793 $url = "/"; 794 $headers = $http_method." ".$url." ".$this->_httpversion."\r\n"; 794 $headers = $http_method." ".$url." ".$this->_httpversion."\r\n"; 795 795 if(!empty($this->agent)) 796 796 $headers .= "User-Agent: ".$this->agent."\r\n"; … … 806 806 $headers .= "Referer: ".$this->referer."\r\n"; 807 807 if(!empty($this->cookies)) 808 { 808 { 809 809 if(!is_array($this->cookies)) 810 810 $this->cookies = (array)$this->cookies; 811 811 812 812 reset($this->cookies); 813 813 if ( count($this->cookies) > 0 ) { … … 832 832 $headers .= "\r\n"; 833 833 } 834 if(!empty($body)) 834 if(!empty($body)) 835 835 $headers .= "Content-length: ".strlen($body)."\r\n"; 836 if(!empty($this->user) || !empty($this->pass)) 836 if(!empty($this->user) || !empty($this->pass)) 837 837 $headers .= "Authorization: Basic ".base64_encode($this->user.":".$this->pass)."\r\n"; 838 838 839 839 //add proxy auth headers 840 if(!empty($this->proxy_user)) 840 if(!empty($this->proxy_user)) 841 841 $headers .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode($this->proxy_user . ':' . $this->proxy_pass)."\r\n"; 842 842 843 843 844 844 $headers .= "\r\n"; 845 845 846 846 // set the read timeout if needed 847 847 if ($this->read_timeout > 0) 848 848 socket_set_timeout($fp, $this->read_timeout); 849 849 $this->timed_out = false; 850 850 851 851 fwrite($fp,$headers.$body,strlen($headers.$body)); 852 852 853 853 $this->_redirectaddr = false; 854 854 unset($this->headers); 855 855 856 856 while($currentHeader = fgets($fp,$this->_maxlinelen)) 857 857 { … … 861 861 return false; 862 862 } 863 863 864 864 if($currentHeader == "\r\n") 865 865 break; 866 866 867 867 // if a header begins with Location: or URI:, set the redirect 868 868 if(preg_match("/^(Location:|URI:)/i",$currentHeader)) … … 884 884 $this->_redirectaddr = $matches[2]; 885 885 } 886 886 887 887 if(preg_match("|^HTTP/|",$currentHeader)) 888 888 { … … 890 890 { 891 891 $this->status= $status[1]; 892 } 892 } 893 893 $this->response_code = $currentHeader; 894 894 } 895 895 896 896 $this->headers[] = $currentHeader; 897 897 } … … 911 911 return false; 912 912 } 913 913 914 914 // check if there is a a redirect meta tag 915 915 916 916 if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) 917 917 918 918 { 919 $this->_redirectaddr = $this->_expandlinks($match[1],$URI); 919 $this->_redirectaddr = $this->_expandlinks($match[1],$URI); 920 920 } 921 921 … … 933 933 else 934 934 $this->results = $results; 935 935 936 936 return true; 937 937 } … … 943 943 $URI the full URI 944 944 $body body contents to send if any (POST) 945 Output: 946 \*======================================================================*/ 947 945 Output: 946 \*======================================================================*/ 947 948 948 function _httpsrequest($url,$URI,$http_method,$content_type="",$body="") 949 949 { … … 951 951 $this->setcookies(); 952 952 953 $headers = array(); 954 953 $headers = array(); 954 955 955 $URI_PARTS = parse_url($URI); 956 956 if(empty($url)) 957 957 $url = "/"; 958 958 // GET ... header not needed for curl 959 //$headers[] = $http_method." ".$url." ".$this->_httpversion; 959 //$headers[] = $http_method." ".$url." ".$this->_httpversion; 960 960 if(!empty($this->agent)) 961 961 $headers[] = "User-Agent: ".$this->agent; … … 970 970 $headers[] = "Referer: ".$this->referer; 971 971 if(!empty($this->cookies)) 972 { 972 { 973 973 if(!is_array($this->cookies)) 974 974 $this->cookies = (array)$this->cookies; 975 975 976 976 reset($this->cookies); 977 977 if ( count($this->cookies) > 0 ) { … … 996 996 $headers[] = "Content-type: $content_type"; 997 997 } 998 if(!empty($body)) 998 if(!empty($body)) 999 999 $headers[] = "Content-length: ".strlen($body); 1000 if(!empty($this->user) || !empty($this->pass)) 1000 if(!empty($this->user) || !empty($this->pass)) 1001 1001 $headers[] = "Authorization: BASIC ".base64_encode($this->user.":".$this->pass); 1002 1002 1003 1003 for($curr_header = 0; $curr_header < count($headers); $curr_header++) { 1004 1004 $safer_header = strtr( $headers[$curr_header], "\"", " " ); 1005 1005 $cmdline_params .= " -H \"".$safer_header."\""; 1006 1006 } 1007 1007 1008 1008 if(!empty($body)) 1009 1009 $cmdline_params .= " -d \"$body\""; 1010 1010 1011 1011 if($this->read_timeout > 0) 1012 1012 $cmdline_params .= " -m ".$this->read_timeout; 1013 1013 1014 1014 $headerfile = tempnam($temp_dir, "sno"); 1015 1015 1016 1016 $safer_URI = strtr( $URI, "\"", " " ); // strip quotes from the URI to avoid shell access 1017 1017 exec(escapeshellcmd($this->curl_path." -D \"$headerfile\"".$cmdline_params." \"".$safer_URI."\""),$results,$return); 1018 1018 1019 1019 if($return) 1020 1020 { … … 1022 1022 return false; 1023 1023 } 1024 1025 1024 1025 1026 1026 $results = implode("\r\n",$results); 1027 1027 1028 1028 $result_headers = file("$headerfile"); 1029 1029 1030 1030 $this->_redirectaddr = false; 1031 1031 unset($this->headers); 1032 1032 1033 1033 for($currentHeader = 0; $currentHeader < count($result_headers); $currentHeader++) 1034 1034 { 1035 1035 1036 1036 // if a header begins with Location: or URI:, set the redirect 1037 1037 if(preg_match("/^(Location: |URI: )/i",$result_headers[$currentHeader])) … … 1053 1053 $this->_redirectaddr = $matches[2]; 1054 1054 } 1055 1055 1056 1056 if(preg_match("|^HTTP/|",$result_headers[$currentHeader])) 1057 1057 $this->response_code = $result_headers[$currentHeader]; … … 1061 1061 1062 1062 // check if there is a a redirect meta tag 1063 1063 1064 1064 if(preg_match("'<meta[\s]*http-equiv[^>]*?content[\s]*=[\s]*[\"\']?\d+;[\s]*URL[\s]*=[\s]*([^\"\']*?)[\"\']?>'i",$results,$match)) 1065 1065 { 1066 $this->_redirectaddr = $this->_expandlinks($match[1],$URI); 1066 $this->_redirectaddr = $this->_expandlinks($match[1],$URI); 1067 1067 } 1068 1068 … … 1082 1082 1083 1083 unlink("$headerfile"); 1084 1084 1085 1085 return true; 1086 1086 } … … 1090 1090 Purpose: set cookies for a redirection 1091 1091 \*======================================================================*/ 1092 1092 1093 1093 function setcookies() 1094 1094 { … … 1100 1100 } 1101 1101 1102 1102 1103 1103 /*======================================================================*\ 1104 1104 Function: _check_timeout … … 1124 1124 Input: $fp file pointer 1125 1125 \*======================================================================*/ 1126 1126 1127 1127 function _connect(&$fp) 1128 1128 { … … 1130 1130 { 1131 1131 $this->_isproxy = true; 1132 1132 1133 1133 $host = $this->proxy_host; 1134 1134 $port = $this->proxy_port; … … 1139 1139 $port = $this->port; 1140 1140 } 1141 1141 1142 1142 $this->status = 0; 1143 1143 1144 1144 if($fp = fsockopen( 1145 1145 $host, … … 1177 1177 Input: $fp file pointer 1178 1178 \*======================================================================*/ 1179 1179 1180 1180 function _disconnect($fp) 1181 1181 { … … 1183 1183 } 1184 1184 1185 1185 1186 1186 /*======================================================================*\ 1187 1187 Function: _prepare_post_body … … 1191 1191 Output: post body 1192 1192 \*======================================================================*/ 1193 1193 1194 1194 function _prepare_post_body($formvars, $formfiles) 1195 1195 { … … 1200 1200 if (count($formvars) == 0 && count($formfiles) == 0) 1201 1201 return; 1202 1202 1203 1203 switch ($this->_submit_type) { 1204 1204 case "application/x-www-form-urlencoded": … … 1216 1216 case "multipart/form-data": 1217 1217 $this->_mime_boundary = "Snoopy".md5(uniqid(microtime())); 1218 1218 1219 1219 reset($formvars); 1220 1220 while(list($key,$val) = each($formvars)) { … … 1231 1231 } 1232 1232 } 1233 1233 1234 1234 reset($formfiles); 1235 1235 while (list($field_name, $file_names) = each($formfiles)) { … … 1239 1239 1240 1240 $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 } 1242 1244 fclose($fp); 1243 1245 $base_name = basename($file_name); -
trunk/wp-includes/classes.php
r3503 r4431 1 1 <?php 2 2 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 single110 // 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 screen231 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 variables274 $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 month315 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 post410 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 match422 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 stuff449 450 if ((empty($q['cat'])) || ($q['cat'] == '0') ||451 // Bypass cat checks if fetching specific posts452 ( $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 must459 // always mean 'everything /except/ this one'. We should be able to do460 // 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 URIs484 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 nicename506 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 stuff518 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 URIs542 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 slash548 } else {549 $q['author_name'] = $q['author_name'][count($q['author_name'])-2];#there was a trailling slash550 }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 by564 if (empty($q['orderby'])) {565 $q['orderby']='date '.$q['order'];566 } else {567 // Used to filter values568 $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 safety579 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 they589 //can edit the post, we let them through590 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 else607 $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 any614 // 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 // Paging619 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 that644 // 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 dated679 $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 started715 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 loop724 $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 constructor803 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_spam818 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_spam840 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&move=true&ids='.$id_list.'">'. __('Move suspect comments to moderation queue »') . '</a></p>';850 851 }852 $head = '<div class="wrap"><h2>' . __('Check Comments Results:') . '</h2>';853 854 $foot .= '<p><a href="options-discussion.php">' . __('« Return to Discussion Options page.') . '</a></p></div>';855 856 return $head . $body . $foot;857 } // End function display_edit_form858 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 else935 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 else955 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 permalink1019 // 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 else1081 $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 for1165 // that tag, otherwise add the new tag, pattern, and query to the end of1166 // 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_rules1301 * 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 // Post1312 $post_rewrite = $this->generate_rewrite_rules($this->permalink_structure);1313 $post_rewrite = apply_filters('post_rewrite_rules', $post_rewrite);1314 1315 // Date1316 $date_rewrite = $this->generate_rewrite_rules($this->get_date_permastruct());1317 $date_rewrite = apply_filters('date_rewrite_rules', $date_rewrite);1318 1319 // Root1320 $root_rewrite = $this->generate_rewrite_rules($this->root . '/');1321 $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite);1322 1323 // Comments1324 $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 // Search1328 $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 // Categories1333 $category_rewrite = $this->generate_rewrite_rules($this->get_category_permastruct());1334 $category_rewrite = apply_filters('category_rewrite_rules', $category_rewrite);1335 1336 // Authors1337 $author_rewrite = $this->generate_rewrite_rules($this->get_author_permastruct());1338 $author_rewrite = apply_filters('author_rewrite_rules', $author_rewrite);1339 1340 // Pages1341 $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 conditions1392 // 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); // Deprecated1413 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 1461 3 class 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(); 1465 8 1466 9 var $query_vars; … … 1470 13 var $matched_query; 1471 14 var $did_permalink = false; 15 16 function add_query_var($qv) { 17 $this->public_query_vars[] = $qv; 18 } 1472 19 1473 20 function parse_request($extra_query_vars = '') { … … 1476 23 $this->query_vars = array(); 1477 24 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); 1482 29 1483 30 // Process PATH_INFO, REQUEST_URI, and 404 for permalinks. … … 1491 38 $this->did_permalink = true; 1492 39 1493 $pathinfo = $_SERVER['PATH_INFO']; 40 if ( isset($_SERVER['PATH_INFO']) ) 41 $pathinfo = $_SERVER['PATH_INFO']; 42 else 43 $pathinfo = ''; 1494 44 $pathinfo_array = explode('?', $pathinfo); 1495 $pathinfo = $pathinfo_array[0];45 $pathinfo = str_replace("%", "%25", $pathinfo_array[0]); 1496 46 $req_uri = $_SERVER['REQUEST_URI']; 1497 47 $req_uri_array = explode('?', $req_uri); 1498 48 $req_uri = $req_uri_array[0]; 1499 49 $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 = ''; 1502 55 $home_path = trim($home_path, '/'); 1503 56 … … 1505 58 // front. For path info requests, this leaves us with the requesting 1506 59 // filename, if any. For 404 requests, this leaves us with the 1507 // requested permalink. 60 // requested permalink. 1508 61 $req_uri = str_replace($pathinfo, '', $req_uri); 1509 62 $req_uri = trim($req_uri, '/'); … … 1544 97 // Got a match. 1545 98 $this->matched_rule = $match; 1546 99 1547 100 // Trim the query of everything up to the '?'. 1548 101 $query = preg_replace("!^.+\?!", '', $query); … … 1553 106 1554 107 // Parse the query. 1555 parse_str($query, $ query_vars);108 parse_str($query, $perma_query_vars); 1556 109 1557 110 // If we're processing a 404 request, clear the error var … … 1574 127 if (isset($error)) 1575 128 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 1580 133 $this->did_permalink = false; 1581 134 } … … 1586 139 for ($i=0; $i<count($this->public_query_vars); $i += 1) { 1587 140 $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]; 1590 143 elseif (isset($GLOBALS[$wpvar])) 1591 144 $this->query_vars[$wpvar] = $GLOBALS[$wpvar]; … … 1594 147 elseif (!empty($_GET[$wpvar])) 1595 148 $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]; 1600 158 } 1601 159 1602 160 if ( isset($error) ) 1603 161 $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)); 1604 166 } 1605 167 1606 168 function send_headers() { 1607 global $current_user;1608 169 @header('X-Pingback: '. get_bloginfo('pingback_url')); 1609 170 if ( is_user_logged_in() ) … … 1611 172 if ( !empty($this->query_vars['error']) && '404' == $this->query_vars['error'] ) { 1612 173 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')); 1613 177 } else if ( empty($this->query_vars['feed']) ) { 1614 178 @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); … … 1624 188 1625 189 // 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'])); 1627 192 else $client_etag = false; 1628 193 … … 1631 196 $client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0; 1632 197 1633 // Make a timestamp for our most recent modification... 198 // Make a timestamp for our most recent modification... 1634 199 $wp_modified_timestamp = strtotime($wp_last_modified); 1635 200 … … 1641 206 } 1642 207 } 208 209 do_action_ref_array('send_headers', array(&$this)); 1643 210 } 1644 211 1645 212 function build_query_string() { 1646 213 $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] ) { 1650 216 $this->query_string .= (strlen($this->query_string) < 1) ? '' : '&'; 1651 217 $this->query_string .= $wpvar . '=' . rawurlencode($this->query_vars[$wpvar]); … … 1653 219 } 1654 220 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 } 1663 227 } 1664 228 … … 1682 246 1683 247 function init() { 1684 get_currentuserinfo();248 wp_get_current_user(); 1685 249 } 1686 250 1687 251 function query_posts() { 1688 252 $this->build_query_string(); 1689 query_posts($this->query_ string);253 query_posts($this->query_vars); 1690 254 } 1691 255 … … 1699 263 $wp_query->set_404(); 1700 264 status_header( 404 ); 265 nocache_headers(); 1701 266 } elseif( is_404() != true ) { 1702 267 status_header( 200 ); … … 1711 276 $this->handle_404(); 1712 277 $this->register_globals(); 278 do_action_ref_array('wp', array(&$this)); 1713 279 } 1714 280 … … 1718 284 } 1719 285 286 class 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 364 function 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 373 class 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 471 class 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 517 class 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(' ', $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 536 class 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 624 class 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(' ', $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 .= ' ('. $category->category_count .')'; 639 if ( $args['show_last_update'] ) { 640 $format = 'Y-m-d'; 641 $output .= ' ' . gmdate($format, $category->last_update_timestamp); 642 } 643 $output .= "</option>\n"; 644 645 return $output; 646 } 647 } 648 649 class 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 1720 712 ?> -
trunk/wp-includes/default-filters.php
r3503 r4431 25 25 add_filter('pre_comment_author_url', 'clean_url'); 26 26 27 add_filter('pre_comment_content', 'stripslashes', 1);28 27 add_filter('pre_comment_content', 'wp_rel_nofollow', 15); 29 28 add_filter('pre_comment_content', 'balanceTags', 30); 30 add_filter('pre_comment_content', 'addslashes', 50);31 29 32 30 add_filter('pre_comment_author_name', 'wp_filter_kses'); … … 41 39 add_filter('comment_email', 'antispambot'); 42 40 41 add_filter('comment_flood_filter', 'wp_throttle_comment_flood', 10, 3); 42 43 43 add_filter('comment_url', 'clean_url'); 44 44 45 45 add_filter('comment_text', 'convert_chars'); 46 46 add_filter('comment_text', 'make_clickable'); 47 add_filter('comment_text', 'force_balance_tags', 25); 47 48 add_filter('comment_text', 'wpautop', 30); 48 49 add_filter('comment_text', 'convert_smilies', 20); 49 50 50 51 add_filter('comment_excerpt', 'convert_chars'); 52 53 // Categories 54 add_filter('pre_category_name', 'strip_tags'); 55 add_filter('pre_category_name', 'trim'); 56 add_filter('pre_category_name', 'wp_filter_kses'); 57 add_filter('pre_category_name', 'wp_specialchars', 30); 58 add_filter('pre_category_description', 'wp_filter_kses'); 59 60 //Links 61 add_filter('pre_link_name', 'strip_tags'); 62 add_filter('pre_link_name', 'trim'); 63 add_filter('pre_link_name', 'wp_filter_kses'); 64 add_filter('pre_link_name', 'wp_specialchars', 30); 65 add_filter('pre_link_description', 'wp_filter_kses'); 66 add_filter('pre_link_notes', 'wp_filter_kses'); 67 add_filter('pre_link_url', 'strip_tags'); 68 add_filter('pre_link_url', 'trim'); 69 add_filter('pre_link_url', 'clean_url'); 70 add_filter('pre_link_image', 'strip_tags'); 71 add_filter('pre_link_image', 'trim'); 72 add_filter('pre_link_image', 'clean_url'); 73 add_filter('pre_link_rss', 'strip_tags'); 74 add_filter('pre_link_rss', 'trim'); 75 add_filter('pre_link_rss', 'clean_url'); 76 add_filter('pre_link_target', 'strip_tags'); 77 add_filter('pre_link_target', 'trim'); 78 add_filter('pre_link_target', 'wp_filter_kses'); 79 add_filter('pre_link_target', 'wp_specialchars', 30); 80 add_filter('pre_link_rel', 'strip_tags'); 81 add_filter('pre_link_rel', 'trim'); 82 add_filter('pre_link_rel', 'wp_filter_kses'); 83 add_filter('pre_link_rel', 'wp_specialchars', 30); 84 85 // Users 86 add_filter('pre_user_display_name', 'strip_tags'); 87 add_filter('pre_user_display_name', 'trim'); 88 add_filter('pre_user_display_name', 'wp_filter_kses'); 89 add_filter('pre_user_display_name', 'wp_specialchars', 30); 90 add_filter('pre_user_first_name', 'strip_tags'); 91 add_filter('pre_user_first_name', 'trim'); 92 add_filter('pre_user_first_name', 'wp_filter_kses'); 93 add_filter('pre_user_first_name', 'wp_specialchars', 30); 94 add_filter('pre_user_last_name', 'strip_tags'); 95 add_filter('pre_user_last_name', 'trim'); 96 add_filter('pre_user_last_name', 'wp_filter_kses'); 97 add_filter('pre_user_last_name', 'wp_specialchars', 30); 98 add_filter('pre_user_nickname', 'strip_tags'); 99 add_filter('pre_user_nickname', 'trim'); 100 add_filter('pre_user_nickname', 'wp_filter_kses'); 101 add_filter('pre_user_nickname', 'wp_specialchars', 30); 102 add_filter('pre_user_description', 'trim'); 103 add_filter('pre_user_description', 'wp_filter_kses'); 104 add_filter('pre_user_url', 'strip_tags'); 105 add_filter('pre_user_url', 'trim'); 106 add_filter('pre_user_url', 'clean_url'); 107 add_filter('pre_user_email', 'trim'); 108 add_filter('pre_user_email', 'sanitize_email'); 51 109 52 110 // Places to balance tags on input … … 73 131 add_filter('the_title_rss', 'strip_tags'); 74 132 add_filter('the_title_rss', 'ent2ncr', 8); 133 add_filter('the_title_rss', 'wp_specialchars'); 75 134 add_filter('the_content_rss', 'ent2ncr', 8); 76 135 add_filter('the_excerpt_rss', 'convert_chars'); 77 136 add_filter('the_excerpt_rss', 'ent2ncr', 8); 78 137 add_filter('comment_author_rss', 'ent2ncr', 8); 79 add_filter('comment_text_rss', ' htmlspecialchars');138 add_filter('comment_text_rss', 'wp_specialchars'); 80 139 add_filter('comment_text_rss', 'ent2ncr', 8); 81 140 add_filter('bloginfo_rss', 'ent2ncr', 8); 82 141 add_filter('the_author', 'ent2ncr', 8); 83 142 143 // Misc filters 144 add_filter('option_ping_sites', 'privacy_ping_filter'); 145 add_filter('option_blog_charset', 'wp_specialchars'); 146 add_filter('mce_plugins', '_mce_load_rtl_plugin'); 147 add_filter('mce_buttons', '_mce_add_direction_buttons'); 148 84 149 // Actions 85 add_action('publish_post', 'generic_ping');86 150 add_action('wp_head', 'rsd_link'); 87 151 add_action('wp_head', 'locale_stylesheet'); 152 add_action('publish_future_post', 'wp_publish_post', 10, 1); 153 add_action('wp_head', 'noindex', 1); 154 add_action('wp_head', 'wp_print_scripts'); 155 if(!defined('DOING_CRON')) 156 add_action('init', 'wp_cron'); 157 add_action('do_feed_rdf', 'do_feed_rdf', 10, 1); 158 add_action('do_feed_rss', 'do_feed_rss', 10, 1); 159 add_action('do_feed_rss2', 'do_feed_rss2', 10, 1); 160 add_action('do_feed_atom', 'do_feed_atom', 10, 1); 161 add_action('do_pings', 'do_all_pings', 10, 1); 162 add_action('do_robots', 'do_robots'); 163 add_action('sanitize_comment_cookies', 'sanitize_comment_cookies'); 164 add_action('admin_print_scripts', 'wp_print_scripts', 20); 165 add_action('mce_options', '_mce_set_direction'); 88 166 ?> -
trunk/wp-includes/functions.php
r3503 r4431 1 1 <?php 2 2 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 } 3 require_once(dirname(__FILE__).'/compat.php'); 17 4 18 5 function mysql2date($dateformatstring, $mysqlstring, $translate = true) { 19 global $ month, $weekday, $month_abbrev, $weekday_abbrev;6 global $wp_locale; 20 7 $m = $mysqlstring; 21 8 if ( empty($m) ) { … … 23 10 } 24 11 $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; 25 15 26 16 if ( -1 == $i || false == $i ) 27 17 $i = 0; 28 18 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)); 34 26 $dateformatstring = ' '.$dateformatstring; 35 27 $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring); … … 37 29 $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring); 38 30 $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); 39 33 40 34 $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1); … … 52 46 case 'mysql': 53 47 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))); 55 49 return $d; 56 50 break; 57 51 case 'timestamp': 58 52 if ( $gmt ) $d = time(); 59 else $d = time() + (get_ settings('gmt_offset') * 3600);53 else $d = time() + (get_option('gmt_offset') * 3600); 60 54 return $d; 61 55 break; … … 64 58 65 59 function date_i18n($dateformatstring, $unixtimestamp) { 66 global $ month, $weekday, $month_abbrev, $weekday_abbrev;60 global $wp_locale; 67 61 $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)); 73 69 $dateformatstring = ' '.$dateformatstring; 74 70 $dateformatstring = preg_replace("/([^\\\])D/", "\\1".backslashit($dateweekday_abbrev), $dateformatstring); … … 76 72 $dateformatstring = preg_replace("/([^\\\])l/", "\\1".backslashit($dateweekday), $dateformatstring); 77 73 $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 78 77 $dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring)-1); 79 78 } 80 79 $j = @date($dateformatstring, $i); 81 80 return $j; 82 }81 } 83 82 84 83 function get_weekstartend($mysqlstring, $start_of_week) { … … 90 89 $i = 86400; 91 90 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')) { 96 95 $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); 99 98 100 99 $day = $day - 86400; … … 109 108 function get_lastpostdate($timezone = 'server') { 110 109 global $cache_lastpostdate, $pagenow, $wpdb; 111 $add_seconds_blog = get_ settings('gmt_offset') * 3600;110 $add_seconds_blog = get_option('gmt_offset') * 3600; 112 111 $add_seconds_server = date('Z'); 113 $now = current_time('mysql', 1);114 112 if ( !isset($cache_lastpostdate[$timezone]) ) { 115 113 switch(strtolower($timezone)) { 116 114 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"); 118 116 break; 119 117 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"); 121 119 break; 122 120 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"); 124 122 break; 125 123 } … … 133 131 function get_lastpostmodified($timezone = 'server') { 134 132 global $cache_lastpostmodified, $pagenow, $wpdb; 135 $add_seconds_blog = get_ settings('gmt_offset') * 3600;133 $add_seconds_blog = get_option('gmt_offset') * 3600; 136 134 $add_seconds_server = date('Z'); 137 $now = current_time('mysql', 1);138 135 if ( !isset($cache_lastpostmodified[$timezone]) ) { 139 136 switch(strtolower($timezone)) { 140 137 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"); 142 139 break; 143 140 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"); 145 142 break; 146 143 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"); 148 145 break; 149 146 } … … 159 156 } 160 157 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 to179 // 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 against184 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 rules189 $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 options192 if ( empty($rewrite) )193 return 0;194 195 // $url cleanup by Mark Jaquith196 // This fixes things like #anchors, ?query=strings, missing 'www.',197 // added 'www.', or added 'index.php/' that will mess up our WP_Query198 // and return a false negative199 200 // Get rid of the #anchor201 $url_split = explode('#', $url);202 $url = $url_split[0];203 204 // Get rid of URI ?query=string205 $url_split = explode('?', $url);206 $url = $url_split[0];207 208 // Add 'www.' if it is absent and should be there209 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 be213 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 permalinks217 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.com222 $url = str_replace(get_settings('home'), '', $url);223 } else {224 // Chop off /path/to/blog225 $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 slashes231 $url = trim($url, '/');232 233 $request = $url;234 235 // Done with cleanup236 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 it241 // 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 else257 return 0;258 }259 }260 return 0;261 }262 263 264 158 function 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 165 function 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 174 function 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; 269 181 } 270 182 271 183 /* Options functions */ 272 184 273 function get_ settings($setting) {185 function get_option($setting) { 274 186 global $wpdb; 275 187 … … 293 205 // If home is not set use siteurl. 294 206 if ( 'home' == $setting && '' == $value ) 295 return get_ settings('siteurl');207 return get_option('siteurl'); 296 208 297 209 if ( 'siteurl' == $setting || 'home' == $setting || 'category_base' == $setting ) … … 301 213 } 302 214 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 else313 $user = get_userdata($user);314 315 if ( isset( $user->{$wpdb->prefix . $option} ) ) // Blog specific316 return $user->{$wpdb->prefix . $option};317 elseif ( isset( $user->{$option} ) ) // User specific and cross-blog318 return $user->{$option};319 else // Blog global320 return get_option( $option );321 }322 323 215 function form_option($option) { 324 echo htmlspecialchars( get_option($option), ENT_QUOTES);216 echo wp_specialchars( get_option($option), 1 ); 325 217 } 326 218 … … 365 257 } 366 258 367 if ( is_array($newvalue) || is_object($newvalue) )368 $newvalue =serialize($newvalue);259 $_newvalue = $newvalue; 260 $newvalue = maybe_serialize($newvalue); 369 261 370 262 wp_cache_set($option_name, $newvalue, 'options'); … … 374 266 $wpdb->query("UPDATE $wpdb->options SET option_value = '$newvalue' WHERE option_name = '$option_name'"); 375 267 if ( $wpdb->rows_affected == 1 ) { 376 do_action("update_option_{$option_name}", $oldvalue, $ newvalue);268 do_action("update_option_{$option_name}", $oldvalue, $_newvalue); 377 269 return true; 378 270 } 379 271 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 );387 272 } 388 273 … … 395 280 return; 396 281 397 if ( is_array($value) || is_object($value) ) 398 $value = serialize($value); 282 $value = maybe_serialize($value); 399 283 400 284 wp_cache_set($name, $value, 'options'); … … 418 302 } 419 303 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; 304 function 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; 823 312 } 824 313 825 314 function gzip_compression() { 826 if ( !get_ settings('gzipcompression') ) return false;315 if ( !get_option('gzipcompression') ) return false; 827 316 828 317 if ( extension_loaded('zlib') ) { 829 318 ob_start('ob_gzhandler'); 830 319 } 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 $timetotal838 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 servers854 $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 itself859 $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 ping862 $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 lines868 $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 Trackback880 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'");919 320 } 920 321 … … 930 331 $link_text = $matches[4][$i]; 931 332 $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; 933 334 $links_summary .= "\n".$link_number.' '.$link_url; 934 335 } … … 991 392 fclose($fp); 992 393 } 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 }1014 394 } 1015 395 … … 1091 471 } 1092 472 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 1100 473 preg_match('/.*([0-9]{3}).*/', $response, $return); 1101 474 $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 1102 480 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;1147 481 } 1148 482 … … 1156 490 } 1157 491 1158 // Filters: these are the core of WP's plugin architecture1159 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 else1167 $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 else1201 $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 priority1214 if ( isset($wp_filter[$tag]["$priority"]) ) {1215 foreach($wp_filter[$tag]["$priority"] as $filter) {1216 // uncomment if we want to match function AND accepted_args1217 // 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 filters1233 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 content1245 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 else1252 $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 else1270 $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 1342 492 function update_post_cache(&$posts) { 1343 493 global $post_cache; … … 1391 541 if ( empty($dogs) ) 1392 542 return; 1393 543 1394 544 foreach ($dogs as $catt) 1395 545 $category_cache[$catt->post_id][$catt->category_id] = &get_category($catt->category_id); … … 1397 547 1398 548 function 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; 1400 550 global $wpdb; 1401 551 … … 1408 558 $post_id_array[] = $posts[$i]->ID; 1409 559 $post_cache[$posts[$i]->ID] = &$posts[$i]; 1410 $comment_count_cache[$posts[$i]->ID] = $posts[$i]->comment_count;1411 560 } 1412 561 … … 1414 563 1415 564 update_post_category_cache($post_id_list); 565 566 update_postmeta_cache($post_id_list); 567 } 568 569 function 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(); 1416 580 1417 581 // Get post-meta info 1418 582 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) ) { 1419 583 // Change from flat structure to hierarchical: 1420 $post_meta_cache = array(); 584 if ( !isset($post_meta_cache) ) 585 $post_meta_cache = array(); 586 1421 587 foreach ($meta_list as $metarow) { 1422 $mpid = $metarow['post_id'];588 $mpid = (int) $metarow['post_id']; 1423 589 $mkey = $metarow['meta_key']; 1424 590 $mval = $metarow['meta_value']; … … 1438 604 function update_category_cache() { 1439 605 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 too1693 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 else1722 $version ='';1723 if ( preg_match("|Status:(.*)|i", $theme_data, $status) )1724 $status = $status[1];1725 else1726 $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 directory1756 $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 to1855 // a new theme directory and the theme header is not updated. Whichever1856 // 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, move1862 // 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 else1983 $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 else2010 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 else2017 $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, while2023 // 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};)/","&" , 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;2038 606 } 2039 607 … … 2051 619 $ret = ''; 2052 620 if ( is_array(func_get_arg(0)) ) { 2053 if ( @func_num_args() < 2 )621 if ( @func_num_args() < 2 || '' == @func_get_arg(1) ) 2054 622 $uri = $_SERVER['REQUEST_URI']; 2055 623 else 2056 624 $uri = @func_get_arg(1); 2057 625 } else { 2058 if ( @func_num_args() < 3 )626 if ( @func_num_args() < 3 || '' == @func_get_arg(2) ) 2059 627 $uri = $_SERVER['REQUEST_URI']; 2060 628 else 2061 629 $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 = ''; 2062 642 } 2063 643 … … 2071 651 $query = $parts[1]; 2072 652 } 2073 } 2074 else if ( strstr($uri, '/') ) { 653 } else if ( !empty($protocol) || strstr($uri, '/') ) { 2075 654 $base = $uri . '?'; 2076 655 $query = ''; … … 2095 674 } 2096 675 } 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 2098 679 return trim($ret, '?'); 2099 680 } 2100 681 2101 function remove_query_arg($key, $query) { 682 /* 683 remove_query_arg: Returns a modified querystring by removing 684 a single key or an array of keys. 685 Omitting oldquery_or_uri uses the $_SERVER value. 686 687 Parameters: 688 remove_query_arg(removekey, [oldquery_or_uri]) or 689 remove_query_arg(removekeyarray, [oldquery_or_uri]) 690 */ 691 692 function 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 } 2102 698 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);2112 699 } 2113 700 … … 2150 737 function wp($query_vars = '') { 2151 738 global $wp; 2152 739 2153 740 $wp->main($query_vars); 2154 741 } … … 2179 766 } 2180 767 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; 768 function 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"); 2283 773 } 2284 774 … … 2288 778 } 2289 779 780 function bool_from_yn($yn) { 781 if ($yn == 'Y') return 1; 782 return 0; 783 } 784 785 function 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 804 function do_feed_rdf() { 805 load_template(ABSPATH . 'wp-rdf.php'); 806 } 807 808 function do_feed_rss() { 809 load_template(ABSPATH . 'wp-rss.php'); 810 } 811 812 function 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 820 function do_feed_atom() { 821 load_template(ABSPATH . 'wp-atom.php'); 822 } 823 824 function 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 835 function 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 843 function wp_nonce_url($actionurl, $action = -1) { 844 return wp_specialchars(add_query_arg('_wpnonce', wp_create_nonce($action), $actionurl)); 845 } 846 847 function wp_nonce_field($action = -1) { 848 echo '<input type="hidden" name="_wpnonce" value="' . wp_create_nonce($action) . '" />'; 849 wp_referer_field(); 850 } 851 852 function 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 861 function wp_original_referer_field() { 862 echo '<input type="hidden" name="_wp_original_http_referer" value="' . wp_specialchars(stripslashes($_SERVER['REQUEST_URI'])) . '" />'; 863 } 864 865 function 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 872 function wp_get_original_referer() { 873 if ( !empty($_REQUEST['_wp_original_http_referer']) ) 874 return $_REQUEST['_wp_original_http_referer']; 875 return false; 876 } 877 878 function 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. 906 function 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 941 function 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 993 function 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 1048 function 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: "%s"?'), '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: "%s"?'), 'get_catname'); 1058 $trans['update']['category'] = array(__('Are you sure you want to edit this category: "%s"?'), 'get_catname'); 1059 1060 $trans['delete']['comment'] = array(__('Are you sure you want to delete this comment: "%s"?'), 'use_id'); 1061 $trans['unapprove']['comment'] = array(__('Are you sure you want to unapprove this comment: "%s"?'), 'use_id'); 1062 $trans['approve']['comment'] = array(__('Are you sure you want to approve this comment: "%s"?'), 'use_id'); 1063 $trans['update']['comment'] = array(__('Are you sure you want to edit this comment: "%s"?'), '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: "%s"?'), 'use_id'); 1069 $trans['update']['bookmark'] = array(__('Are you sure you want to edit this bookmark: "%s"?'), '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: "%s"?'), 'get_the_title'); 1074 $trans['update']['page'] = array(__('Are you sure you want to edit this page: "%s"?'), 'get_the_title'); 1075 1076 $trans['edit']['plugin'] = array(__('Are you sure you want to edit this plugin file: "%s"?'), 'use_id'); 1077 $trans['activate']['plugin'] = array(__('Are you sure you want to activate this plugin: "%s"?'), 'use_id'); 1078 $trans['deactivate']['plugin'] = array(__('Are you sure you want to deactivate this plugin: "%s"?'), '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: "%s"?'), 'get_the_title'); 1082 $trans['update']['post'] = array(__('Are you sure you want to edit this post: "%s"?'), '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: "%s"?'), 'get_author_name'); 1088 $trans['update']['profile'] = array(__('Are you sure you want to modify the profile for: "%s"?'), '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: "%s"?'), 'use_id'); 1093 $trans['edit']['theme'] = array(__('Are you sure you want to edit this theme file: "%s"?'), 'use_id'); 1094 $trans['switch']['theme'] = array(__('Are you sure you want to switch to this theme: "%s"?'), '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 1112 function 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 1140 function 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 › Error'); 1147 1148 if ( strstr($_SERVER['PHP_SELF'], 'wp-admin') ) 1149 $admin_dir = ''; 1150 else 1151 $admin_dir = 'wp-admin/'; 1152 2290 1153 ?> 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 1174 function _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 1183 function _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 1192 function _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 62 62 */ 63 63 function readint() { 64 $stream = $this->STREAM->read(4);65 64 if ($this->BYTEORDER == 0) { 66 65 // low endian 67 $unpacked = unpack('V',$stream); 68 return array_shift($unpacked); 66 return array_shift(unpack('V', $this->STREAM->read(4))); 69 67 } else { 70 68 // big endian 71 $unpacked = unpack('N',$stream); 72 return array_shift($unpacked); 69 return array_shift(unpack('N', $this->STREAM->read(4))); 73 70 } 74 71 } … … 98 95 function gettext_reader($Reader, $enable_cache = true) { 99 96 // If there isn't a StreamReader, turn on short circuit mode. 100 if (! $Reader ) {97 if (! $Reader || isset($Reader->error) ) { 101 98 $this->short_circuit = true; 102 99 return; … … 106 103 $this->enable_cache = $enable_cache; 107 104 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 109 106 $MAGIC1 = (int) - 1794895138; 110 107 // $MAGIC2 = (int)0xde120495; //bug … … 113 110 $this->STREAM = $Reader; 114 111 $magic = $this->readint(); 115 if ($magic == $MAGIC1) {112 if ($magic == ($MAGIC1 & 0xFFFFFFFF)) { // to make sure it works for 64-bit platforms 116 113 $this->BYTEORDER = 0; 117 } elseif ($magic == $MAGIC2) {114 } elseif ($magic == ($MAGIC2 & 0xFFFFFFFF)) { 118 115 $this->BYTEORDER = 1; 119 116 } else { … … 283 280 $header = $this->get_translation_string(0); 284 281 } 285 if (eregi("plural-forms: ( .*)\n", $header, $regs))282 if (eregi("plural-forms: ([^\n]*)\n", $header, $regs)) 286 283 $expr = $regs[1]; 287 284 else … … 309 306 310 307 eval("$string"); 311 if ($plural >= $total) $plural = 0;308 if ($plural >= $total) $plural = $total - 1; 312 309 return $plural; 313 310 } -
trunk/wp-includes/js/colorpicker.js
r3503 r4431 140 140 function AnchorPosition_getWindowOffsetLeft (el) { 141 141 return AnchorPosition_getPageOffsetLeft(el)-document.body.scrollLeft; 142 } 142 } 143 143 function AnchorPosition_getPageOffsetTop (el) { 144 144 var ot=el.offsetTop; … … 435 435 this.visible = false; 436 436 this.autoHideEnabled = false; 437 437 438 438 this.contents = ""; 439 439 this.url=""; … … 557 557 this.show(linkname); 558 558 } 559 559 560 560 // This function runs when you move your mouse over a color block, if you have a newer browser 561 561 function ColorPicker_highlightColor(c) { … … 580 580 var divname = arguments[0]; 581 581 } 582 582 583 583 if (divname != "") { 584 584 var cp = new PopupWindow(divname); … … 591 591 // Object variables 592 592 cp.currentValue = "#FFFFFF"; 593 593 594 594 // Method Mappings 595 595 cp.writeDiv = ColorPicker_writeDiv; -
trunk/wp-includes/js/dbx.js
r3503 r4431 1 // DBX2.0 1:: Docking Boxes (dbx)1 // DBX2.05 :: Docking Boxes (dbx) 2 2 // ***************************************************** 3 3 // DOM scripting by brothercake -- http://www.brothercake.com/ 4 4 // GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html 5 5 //****************************************************** 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;}}});}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');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 12 12 return "#" + r + g + b; 13 13 }, 14 fade_all : function ( )14 fade_all : function (dur) 15 15 { 16 16 var a = document.getElementsByTagName("*"); … … 22 22 { 23 23 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]); 25 25 } 26 26 } … … 32 32 if (!from || from=="#") from = "#FFFF33"; 33 33 if (!to) to = this.get_bgcolor(id); 34 34 35 35 var frames = Math.round(fps * (duration / 1000)); 36 36 var interval = duration / frames; 37 37 var delay = interval; 38 38 var frame = 0; 39 39 40 40 if (from.length < 7) from += from.substr(1,3); 41 41 if (to.length < 7) to += to.substr(1,3); 42 42 43 43 var rf = parseInt(from.substr(1,2),16); 44 44 var gf = parseInt(from.substr(3,2),16); … … 47 47 var gt = parseInt(to.substr(3,2),16); 48 48 var bt = parseInt(to.substr(5,2),16); 49 49 50 50 var r,g,b,h; 51 51 while (frame < frames) … … 55 55 b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames)); 56 56 h = this.make_hex(r,g,b); 57 57 58 58 setTimeout("Fat.set_bgcolor('"+id+"','"+h+"')", delay); 59 59 -
trunk/wp-includes/js/quicktags.js
r3503 r4431 206 206 return false; // tag not found 207 207 } 208 } 208 } 209 209 210 210 function edCloseAllTags() { -
trunk/wp-includes/js/tinymce/langs/en.js
r3503 r4431 1 1 // UK lang variables 2 2 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.'; 3 tinyMCE.addToLang('',{ 4 bold_desc : 'Bold (Ctrl+B)', 5 italic_desc : 'Italic (Ctrl+I)', 6 underline_desc : 'Underline (Ctrl+U)', 7 striketrough_desc : 'Strikethrough', 8 justifyleft_desc : 'Align left', 9 justifycenter_desc : 'Align center', 10 justifyright_desc : 'Align right', 11 justifyfull_desc : 'Align full', 12 bullist_desc : 'Unordered list', 13 numlist_desc : 'Ordered list', 14 outdent_desc : 'Outdent', 15 indent_desc : 'Indent', 16 undo_desc : 'Undo (Ctrl+Z)', 17 redo_desc : 'Redo (Ctrl+Y)', 18 link_desc : 'Insert/edit link', 19 unlink_desc : 'Unlink', 20 image_desc : 'Insert/edit image', 21 cleanup_desc : 'Cleanup messy code', 22 focus_alert : 'A editor instance must be focused before using this command.', 23 edit_confirm : 'Do you want to use the WYSIWYG mode for this textarea?', 24 insert_link_title : 'Insert/edit link', 25 insert : 'Insert', 26 update : 'Update', 27 cancel : 'Cancel', 28 insert_link_url : 'Link URL', 29 insert_link_target : 'Target', 30 insert_link_target_same : 'Open link in the same window', 31 insert_link_target_blank : 'Open link in a new window', 32 insert_image_title : 'Insert/edit image', 33 insert_image_src : 'Image URL', 34 insert_image_alt : 'Image description', 35 help_desc : 'Help', 36 bold_img : "bold.gif", 37 italic_img : "italic.gif", 38 underline_img : "underline.gif", 39 clipboard_msg : 'Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?', 40 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.' 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 1 10 /* 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; 11 tinyMCE.importPluginLanguagePack('autosave', 'en,tr,sv,cs,he,nb,hu,de,da,ru,ru_KOI8-R,ru_UTF-8,nn,fi,cy,es,is,pl,pt_br'); 12 13 var 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 46 window.onbeforeunload = TinyMCE_AutoSavePlugin._beforeUnloadHandler; 47 48 tinyMCE.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 1 10 /* 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');11 tinyMCE.importPluginLanguagePack('directionality', 'en,tr,sv,fr_ca,zh_cn,cs,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,pl,nl,fr,pt_br'); 3 12 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 }; 13 var 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 } 12 90 }; 13 91 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 } 92 tinyMCE.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 14 var 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 26 tinyMCE.addPlugin("inlinepopups", TinyMCE_InlinePopupsPlugin); 27 28 // Patch openWindow, closeWindow TinyMCE functions 29 30 TinyMCE_Engine.prototype.orgOpenWindow = TinyMCE_Engine.prototype.openWindow; 31 32 TinyMCE_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 82 TinyMCE_Engine.prototype.orgCloseWindow = TinyMCE_Engine.prototype.closeWindow; 83 84 TinyMCE_Engine.prototype.closeWindow = function(win) { 85 if (mcWindows.selectedWindow != null) 86 mcWindows.selectedWindow.close(); 87 else 88 this.orgCloseWindow(win); 89 }; 90 91 TinyMCE_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 105 function 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 126 TinyMCE_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 139 TinyMCE_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 151 TinyMCE_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 190 TinyMCE_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 197 TinyMCE_Windows.prototype.cancelEvent = function(e) { 198 if (this.isMSIE) { 199 e.returnValue = false; 200 e.cancelBubble = true; 201 } else 202 e.preventDefault(); 203 }; 204 205 TinyMCE_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 245 TinyMCE_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 327 TinyMCE_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 364 TinyMCE_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 437 TinyMCE_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 509 function TinyMCE_Window() { 510 }; 511 512 TinyMCE_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 520 TinyMCE_Window.prototype.minimize = function() { 521 }; 522 523 TinyMCE_Window.prototype.maximize = function() { 524 525 }; 526 527 TinyMCE_Window.prototype.startResize = function() { 528 mcWindows.action = "resize"; 529 }; 530 531 TinyMCE_Window.prototype.startMove = function(e) { 532 mcWindows.action = "move"; 533 }; 534 535 TinyMCE_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 565 TinyMCE_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 613 function debug(msg) { 614 document.getElementById('debug').value += msg + "\n"; 615 } 616 617 TinyMCE_Window.prototype.onMouseUp = function(e) { 618 mcWindows.action = "none"; 619 }; 620 621 TinyMCE_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 637 TinyMCE_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 659 var mcWindows = new TinyMCE_Windows(); 660 661 // Initialize windows 662 mcWindows.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 13 function 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 32 MCWindows.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 43 MCWindows.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 55 MCWindows.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 96 MCWindows.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 103 MCWindows.prototype.cancelEvent = function(e) { 104 if (this.isMSIE) { 105 e.returnValue = false; 106 e.cancelBubble = true; 107 } else 108 e.preventDefault(); 109 }; 110 111 MCWindows.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 143 MCWindows.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 202 MCWindows.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 265 MCWindows.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 337 function MCWindow() { 338 }; 339 340 MCWindow.prototype.focus = function() { 341 this.winElement.style.zIndex = mcWindows.zindex++; 342 mcWindows.selectedWindow = this; 343 }; 344 345 MCWindow.prototype.minimize = function() { 346 }; 347 348 MCWindow.prototype.maximize = function() { 349 350 }; 351 352 MCWindow.prototype.startResize = function() { 353 mcWindows.action = "resize"; 354 }; 355 356 MCWindow.prototype.startMove = function(e) { 357 mcWindows.action = "move"; 358 }; 359 360 MCWindow.prototype.close = function() { 361 document.body.removeChild(this.winElement); 362 mcWindows.windows[this.name] = null; 363 }; 364 365 MCWindow.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 413 MCWindow.prototype.onMouseUp = function(e) { 414 mcWindows.action = "none"; 415 }; 416 417 MCWindow.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 433 MCWindow.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 455 var mcWindows = new MCWindows(); -
trunk/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
r3503 r4431 1 1 /* 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": 2 tinyMCE.importPluginLanguagePack('wordpress', 'en'); 3 4 var 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": 83 68 var flag = ""; 84 69 var template = new Array(); … … 88 73 if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { 89 74 flag = getAttrib(focusElm, 'class'); 90 75 91 76 if (flag != 'mce_plugin_wordpress_more') // Not a wordpress 92 77 return true; 93 78 94 79 action = "update"; 95 80 } 96 81 97 82 html = '' 98 83 + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ' 99 84 + ' width="100%" height="10px" ' 100 85 + 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />'; 101 tinyMCE.exec Command("mceInsertContent",true,html);86 tinyMCE.execInstanceCommand(editor_id, 'mceInsertContent', false, html); 102 87 tinyMCE.selectedInstance.repaint(); 103 88 return true; 104 case "mcewordpresspage": 89 90 case "wpPage": 105 91 var flag = ""; 106 92 var template = new Array(); 107 93 var altPage = tinyMCE.getLang('lang_wordpress_more_alt'); 108 94 109 95 // Is selection a image 110 96 if (focusElm != null && focusElm.nodeName.toLowerCase() == "img") { 111 97 flag = getAttrib(focusElm, 'name'); 112 98 113 99 if (flag != 'mce_plugin_wordpress_page') // Not a wordpress 114 100 return true; 115 101 116 102 action = "update"; 117 103 } 118 104 119 105 html = '' 120 106 + '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" ' … … 124 110 tinyMCE.selectedInstance.repaint(); 125 111 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| )*</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('&', '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 368 tinyMCE.addPlugin("wordpress", TinyMCE_wordpressPlugin); 369 370 /* This little hack protects our More and Page placeholders from the removeformat command */ 371 tinyMCE.orgExecCommand = tinyMCE.execCommand; 372 tinyMCE.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 }; 384 wpInstTriggerSave = 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, "(", "(", "gi"); 441 htm = tinyMCE.regexpReplace(htm, ")", ")", "gi"); 442 htm = tinyMCE.regexpReplace(htm, ";", ";", "gi"); 443 htm = tinyMCE.regexpReplace(htm, """, """, "gi"); 444 htm = tinyMCE.regexpReplace(htm, "^", "^", "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 } 130 459 } 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'), '&'); 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 & in the html. 202 content = content.replace(new RegExp('&', 'g'), '&'); 203 content = content.replace(new RegExp('&nbsp;', 'g'), ' '); 204 205 // Remove anonymous, empty paragraphs. 206 content = content.replace(new RegExp('<p>(\\s| )*</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; 460 tinyMCE.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 } 230 469 } 231 470 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; 471 function 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 } 251 561 } 252 562 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('&', '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 563 function edToggle(A, B) { 564 A.className = 'edButtonFore'; 565 B.className = 'edButtonBack'; 566 567 B.onclick = A.onclick; 568 A.onclick = null; 285 569 } 570 571 function 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('^((?: )*)\\s', 'mg'), '$1 '); 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 1 1 // EN lang variables 2 2 3 if (navigator.userAgent.indexOf('Mac OS') != -1) { 4 // Mac OS browsers use Ctrl to hit accesskeys 5 var metaKey = 'Ctrl'; 6 } 7 else { 8 var metaKey = 'Alt'; 9 } 10 3 11 tinyMCE.addToLang('',{ 4 wordpress_more_button : 'Split post with More tag ( Alt-t)',12 wordpress_more_button : 'Split post with More tag (' + metaKey + '+t)', 5 13 wordpress_page_button : 'Split post with Page tag', 14 wordpress_adv_button : 'Show/Hide Advanced Toolbar (' + metaKey + '+b)', 6 15 wordpress_more_alt : 'More...', 7 wordpress_page_alt : '...page...' 16 wordpress_page_alt : '...page...', 17 help_button_title : 'Help (' + metaKey + '+h)', 18 bold_desc : 'Bold (Ctrl+B)', 19 italic_desc : 'Italic (Ctrl+I)', 20 underline_desc : 'Underline (Ctrl+U)', 21 link_desc : 'Insert/edit link (' + metaKey + '+a)', 22 unlink_desc : 'Unlink (' + metaKey + '+s)', 23 image_desc : 'Insert/edit image (' + metaKey + '+m)', 24 striketrough_desc : 'Strikethrough (' + metaKey + '+k)', 25 justifyleft_desc : 'Align left (' + metaKey + '+f)', 26 justifycenter_desc : 'Align center (' + metaKey + '+c)', 27 justifyright_desc : 'Align right (' + metaKey + '+r)', 28 justifyfull_desc : 'Align full (' + metaKey + '+j)', 29 bullist_desc : 'Unordered list (' + metaKey + '+l)', 30 numlist_desc : 'Ordered list (' + metaKey + '+o)', 31 outdent_desc : 'Outdent (' + metaKey + '+w)', 32 indent_desc : 'Indent List/Blockquote (' + metaKey + '+q)' 8 33 }); -
trunk/wp-includes/js/tinymce/plugins/wordpress/wordpress.css
r3503 r4431 20 20 background-position: right top; 21 21 } 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 26 body { 27 background: #fff; 28 font: 1em/1.3em Georgia, "Times New Roman", Times, serif; 29 padding: .5em; 30 } 31 32 td { 33 font-size: 10px; 34 } 35 36 pre { 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 /* 58 a { 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 5 5 <script language="javascript" type="text/javascript" src="../../utils/mctabs.js"></script> 6 6 <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" /> 8 8 </head> 9 9 <body id="about" onload="tinyMCEPopup.executeOnLoad('init();');" style="display: none"> … … 22 22 <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> 23 23 by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances.</p> 24 <p>Copyright © 200 5, <a href="http://www.moxiecode.com" target="_blank">Moxiecode Systems AB</a>, All rights reserved.</p>24 <p>Copyright © 2003-2006, <a href="http://www.moxiecode.com" target="_blank">Moxiecode Systems AB</a>, All rights reserved.</p> 25 25 <p>For more information about this software visit the <a href="http://tinymce.moxiecode.com" target="_blank">TinyMCE website</a>.</p> 26 26 -
trunk/wp-includes/js/tinymce/themes/advanced/anchor.htm
r3503 r4431 4 4 <script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script> 5 5 <script language="javascript" type="text/javascript" src="jscripts/anchor.js"></script> 6 <base target="_self" /> 6 7 </head> 7 8 <body onload="tinyMCEPopup.executeOnLoad('init();');" style="display: none"> -
trunk/wp-includes/js/tinymce/themes/advanced/charmap.htm
r3503 r4431 5 5 <script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script> 6 6 <script language="javascript" type="text/javascript" src="jscripts/charmap.js"></script> 7 <base target="_self" /> 7 8 </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"> 9 10 <table align="center" border="0" cellspacing="0" cellpadding="2"> 10 11 <tr> -
trunk/wp-includes/js/tinymce/themes/advanced/color_picker.htm
r3503 r4431 4 4 <script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script> 5 5 <script language="javascript" type="text/javascript" src="jscripts/color_picker.js"></script> 6 <base target="_self" /> 6 7 </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"> 8 9 <div align="center"> 9 10 <script language="javascript" type="text/javascript">renderColorMap();</script> -
trunk/wp-includes/js/tinymce/themes/advanced/css/editor_content.css
r3503 r4431 2 2 /* You can extend this CSS by adding your own CSS file with the the content_css option */ 3 3 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 { 4 body, td, pre { 13 5 font-family: Verdana, Arial, Helvetica, sans-serif; 14 6 font-size: 10px; 15 7 } 16 8 17 pre { 18 font-family: Verdana, Arial, Helvetica, sans-serif; 19 font-size: 10px; 9 body { 10 background-color: #FFFFFF; 20 11 } 21 12 … … 48 39 } 49 40 */ 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 36 36 37 37 .input_noborder { 38 border: 0 px solid #808080;39 } 40 41 #insert {38 border: 0; 39 } 40 41 #insert, .updateButton { 42 42 font-weight: bold; 43 43 width: 90px; 44 44 height: 21px; 45 border: 0 px;45 border: 0; 46 46 background-image: url('../images/insert_button_bg.gif'); 47 47 cursor: pointer; … … 52 52 width: 90px; 53 53 height: 21px; 54 border: 0 px;54 border: 0; 55 55 background-image: url('../images/cancel_button_bg.gif'); 56 56 cursor: pointer; … … 85 85 td.charmapOver { 86 86 background-color: #CCCCCC; 87 cursor: arrow;87 cursor: default; 88 88 } 89 89 … … 121 121 border-right: 1px solid; 122 122 border-color: #F0F0EE; 123 cursor: arrow;123 cursor: default; 124 124 } 125 125 126 126 .mceButtonOver { 127 127 border: 1px solid #0A246A; 128 cursor: arrow;128 cursor: default; 129 129 background-color: #B6BDD2; 130 130 } 131 131 132 132 .mceButtonDown { 133 cursor: arrow;133 cursor: default; 134 134 border: 1px solid #0A246A; 135 135 background-color: #8592B5; … … 145 145 border-right: 1px solid; 146 146 border-color: #F0F0EE; 147 cursor: arrow;147 cursor: default; 148 148 } 149 149 … … 163 163 .tabs ul { 164 164 margin: 0; 165 padding: 0 px 0px0;165 padding: 0 0 0; 166 166 list-style: none; 167 167 } … … 171 171 background: url("../images/xp/tab_bg.gif") no-repeat left top; 172 172 margin: 0; 173 margin-left: 0 px;173 margin-left: 0; 174 174 margin-right: 2px; 175 175 padding: 0 0 0 10px; … … 186 186 display: block; 187 187 background: url("../images/xp/tab_end.gif") no-repeat right top; 188 padding: 0px 10px 0 px 0px;188 padding: 0px 10px 0 0; 189 189 } 190 190 … … 236 236 font-family: Verdana, Arial; 237 237 font-size: 10px; 238 padding: 0 px;239 margin: 0 px;238 padding: 0; 239 margin: 0; 240 240 padding: 4px; 241 241 } … … 296 296 h1, h2, h3, h4 { 297 297 color: #2B6FB6; 298 margin: 0 px;299 padding: 0 px;298 margin: 0; 299 padding: 0; 300 300 padding-top: 5px; 301 301 } … … 303 303 h3 { 304 304 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; 305 313 } 306 314 … … 318 326 } 319 327 */ 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 2 2 3 3 .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; 57 11 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;71 12 } 72 13 73 14 .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; 76 17 font-weight: normal; 77 18 margin-top: 3px; 78 padding: 0 px;19 padding: 0; 79 20 display: inline; 80 21 vertical-align: top; 81 background-color: #F0F0EE 22 background-color: #F0F0EE; 82 23 } 83 24 … … 99 40 background: #F0F0EE; 100 41 border: 1px solid #cccccc; 101 padding: 0 px;102 margin: 0 px;42 padding: 0; 43 margin: 0; 103 44 } 104 45 … … 106 47 font-family: 'MS Sans Serif', sans-serif, Verdana, Arial; 107 48 background: #FFFFFF; 108 padding: 0 px;109 margin: 0 px;49 padding: 0; 50 margin: 0; 110 51 } 111 52 … … 118 59 .mceToolbarTop { 119 60 border-bottom: 1px solid #cccccc; 61 padding-bottom: 1px; 120 62 } 121 63 … … 177 119 display: none; 178 120 border: 1px dotted gray; 179 margin: 0px; 180 padding: 0px; 181 } 121 margin: 0; 122 padding: 0; 123 } 124 125 /* Button CSS rules */ 126 127 a.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 135 a.mceButtonDisabled img { 136 border: 0 !important; 137 } 138 139 a.mceButtonNormal img, a.mceButtonSelected img { 140 border: 1px solid #F0F0EE !important; 141 } 142 143 a.mceButtonSelected img { 144 border: 1px solid #6779AA !important; 145 background-color: #D4D5D8; 146 } 147 148 a.mceButtonNormal img:hover, a.mceButtonSelected img:hover { 149 border: 1px solid #0A246A !important; 150 cursor: default; 151 background-color: #B6BDD2; 152 } 153 154 a.mceButtonDisabled img { 155 -moz-opacity:0.3; 156 opacity: 0.3; 157 border: 1px solid #F0F0EE !important; 158 cursor: default; 159 } 160 161 a.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 205 span.mceMenuButton img, span.mceMenuButtonSelected img { 206 border: 1px solid #F0F0EE; 207 margin-left: 1px; 208 } 209 210 span.mceMenuButtonSelected img { 211 border: 1px solid #6779AA; 212 background-color: #B6BDD2; 213 } 214 215 span.mceMenuButtonSelected img.mceMenuButton { 216 border: 1px solid #F0F0EE; 217 background-color: transparent; 218 } 219 220 span.mceMenuButton img.mceMenuButton, span.mceMenuButtonSelected img.mceMenuButton { 221 border-left: 0; 222 margin-left: 0; 223 } 224 225 span.mceMenuButton:hover img, span.mceMenuButtonSelected:hover img { 226 border: 1px solid #0A246A; 227 background-color: #B6BDD2; 228 } 229 230 span.mceMenuButton:hover img.mceMenuButton, span.mceMenuButtonSelected:hover img.mceMenuButton { 231 border-left: 0; 232 } 233 234 span.mceMenuButtonFocus img { 235 border: 1px solid gray; 236 border-right: 0; 237 margin-left: 1px; 238 background-color: #F5F4F2; 239 } 240 241 span.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 326 span.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 333 span.mceMenuCheckItem { 334 padding-left: 20px; 335 } 336 337 span.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 1 10 /* 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")+'"> </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+=" » ";}}pathElm.innerHTML='<a href="#" accesskey="x"></a>'+tinyMCE.getLang('lang_theme_path')+": "+html+' ';}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');}}}; 11 tinyMCE.importThemeLanguagePack('advanced'); 12 13 var 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="<' + lookup[x][0] + '>">' + 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") + '"> </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 += " » "; 816 } 817 } 818 819 pathElm.innerHTML = '<a href="#" accesskey="x"></a>' + tinyMCE.getLang('lang_theme_path') + ": " + html + ' '; 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 1408 tinyMCE.addTheme("advanced", TinyMCE_AdvancedTheme); 1409 1410 // Add default buttons maps for advanced theme and all internal plugins 1411 tinyMCE.addButtonMap(TinyMCE_AdvancedTheme._buttonMap); -
trunk/wp-includes/js/tinymce/themes/advanced/image.htm
r3503 r4431 3 3 <title>{$lang_insert_image_title}</title> 4 4 <script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script> 5 <script language="javascript" type="text/javascript" src="../../utils/mctabs.js"></script> 5 6 <script language="javascript" type="text/javascript" src="../../utils/form_utils.js"></script> 6 7 <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" /> 29 9 </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"> 35 21 <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> 40 23 <td><table border="0" cellspacing="0" cellpadding="0"> 41 24 <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> 43 26 <td id="srcbrowsercontainer"> </td> 44 27 </tr> … … 50 33 var html = ""; 51 34 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();">'; 54 37 html += '<option value="">---</option>'; 55 38 … … 64 47 <!-- /Image list --> 65 48 <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> 68 51 </tr> 69 52 <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"> 72 55 <option value="">{$lang_insert_image_align_default}</option> 73 56 <option value="baseline">{$lang_insert_image_align_baseline}</option> … … 83 66 </tr> 84 67 <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"> 87 70 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> 93 72 </tr> 94 73 <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> 97 76 </tr> 98 77 <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> 101 80 </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> 106 84 </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> 110 98 </form> 111 99 </body> -
trunk/wp-includes/js/tinymce/themes/advanced/jscripts/about.js
r3503 r4431 1 1 function init() { 2 var inst; 3 2 4 tinyMCEPopup.resizeToInnerSize(); 5 inst = tinyMCE.selectedInstance; 3 6 4 7 // Give FF some time … … 21 24 html += '<tbody>'; 22 25 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]); 25 28 26 29 html += '<tr>'; … … 47 50 48 51 function 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(); 53 54 54 55 return { -
trunk/wp-includes/js/tinymce/themes/advanced/jscripts/anchor.js
r3503 r4431 27 27 function insertAnchor() { 28 28 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; 30 30 31 31 tinyMCEPopup.execCommand("mceBeginUndoLevel"); … … 45 45 name = name.replace(/\"/g, '"'); 46 46 name = name.replace(/</g, '<'); 47 name = name.replace(/>/g, '&g r;');47 name = name.replace(/>/g, '>'); 48 48 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>'; 50 54 51 55 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 52 67 tinyMCE.handleVisualAid(inst.getBody(), true, inst.visualAid, inst); 53 68 } -
trunk/wp-includes/js/tinymce/themes/advanced/jscripts/charmap.js
r3503 r4431 171 171 ['þ', 'þ', true, 'thorn'], 172 172 ['ÿ', 'ÿ', true, 'y - diaeresis'], 173 //['Α', 'Α', true, 'Alpha'],173 ['Α', 'Α', true, 'Alpha'], 174 174 ['Β', 'Β', true, 'Beta'], 175 175 ['Γ', 'Γ', true, 'Gamma'], … … 280 280 html += '' 281 281 + '<td width="' + tdWidth + '" height="' + tdHeight + '" class="charmap"' 282 + ' onmouseover="t inyMCE.switchClass(this,\'charmapOver\');'282 + ' onmouseover="this.className=\'charmapOver\';' 283 283 + 'previewChar(\'' + charmap[i][1].substring(1,charmap[i][1].length) + '\',\'' + charmap[i][0].substring(1,charmap[i][0].length) + '\',\'' + charmap[i][3] + '\');"' 284 + ' onmouseout="t inyMCE.restoreClass(this,\'charmapOver\');"'284 + ' onmouseout="this.className=\'charmap\';"' 285 285 + ' 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] + '">' 286 286 + charmap[i][1] … … 300 300 301 301 function insertChar(chr) { 302 tinyMCEPopup.execCommand('mceInsertContent', false, ' \&#' + chr + ';');302 tinyMCEPopup.execCommand('mceInsertContent', false, '&#' + chr + ';'); 303 303 304 304 // Refocus in window 305 305 if (tinyMCEPopup.isWindow) 306 306 window.focus(); 307 308 tinyMCEPopup.close(); 307 309 } 308 310 -
trunk/wp-includes/js/tinymce/themes/advanced/jscripts/color_picker.js
r3503 r4431 100 100 + '</td></tr>' 101 101 + '</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>' 103 104 + '</td></tr>' 104 105 + '</table>'; -
trunk/wp-includes/js/tinymce/themes/advanced/jscripts/image.js
r3503 r4431 9 9 10 10 function 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; 20 19 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(); 24 23 } 25 24 … … 38 37 formObj.src.value = tinyMCE.getWindowArg('src'); 39 38 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'); 45 44 formObj.insert.value = tinyMCE.getLang('lang_' + tinyMCE.getWindowArg('action'), 'Insert', true); 46 45 … … 68 67 var formObj = document.forms[0]; 69 68 70 //if (formObj.width.value == "")71 //formObj.width.value = preloadImg.width;69 if (formObj.width.value == "") 70 formObj.width.value = preloadImg.width; 72 71 73 //if (formObj.height.value == "")74 //formObj.height.value = preloadImg.height;72 if (formObj.height.value == "") 73 formObj.height.value = preloadImg.height; 75 74 } 76 75 -
trunk/wp-includes/js/tinymce/themes/advanced/jscripts/link.js
r3503 r4431 11 11 tinyMCEPopup.resizeToInnerSize(); 12 12 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'; 14 18 15 19 var formObj = document.forms[0]; … … 26 30 document.forms[0].insert.value = tinyMCE.getLang('lang_' + tinyMCE.getWindowArg('action'), 'Insert', true); 27 31 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); 30 34 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 } 34 41 35 42 // Auto select link in list … … 45 52 46 53 function 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; 53 59 54 // Make anchors absolute55 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; 57 63 58 if (target == '_self')59 target = '';64 if (target == '_self') 65 target = ''; 60 66 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(); 64 70 } -
trunk/wp-includes/js/tinymce/themes/advanced/jscripts/source_editor.js
r3503 r4431 6 6 // Fixes some charcode issues 7 7 function 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'); 12 9 html = html.replace(new RegExp('<\/(p|ol|ul|li|table|tr|td|blockquote|object)>', 'gi'),'</$1>\n'); 13 10 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');*/ 15 12 return html; 16 13 } … … 21 18 document.forms[0].htmlSource.value = fixContent(tinyMCE.getContent(tinyMCE.getWindowArg('editor_id'))); 22 19 resizeInputs(); 23 setWrap('off');24 20 } 25 21 26 22 function 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 } 29 34 } 30 35 … … 52 57 53 58 function renderWordWrap() { 54 if (tinyMCE.isMSIE )59 if (tinyMCE.isMSIE || tinyMCE.isGecko) 55 60 document.write('<input type="checkbox" name="wraped" id="wraped" onclick="toggleWordWrap(this);" class="wordWrapCode" /><label for="wraped">{$lang_theme_code_wordwrap}</label>'); 56 61 } -
trunk/wp-includes/js/tinymce/themes/advanced/langs/en.js
r3503 r4431 3 3 tinyMCE.addToLang('',{ 4 4 theme_style_select : '-- Styles --', 5 theme_code_desc : 'Edit HTML Source (Alt+e)',5 theme_code_desc : 'Edit HTML Source', 6 6 theme_code_title : 'HTML Source Editor', 7 7 theme_code_wordwrap : 'Word wrap', -
trunk/wp-includes/js/tinymce/themes/advanced/link.htm
r3503 r4431 3 3 <title>{$lang_insert_link_title}</title> 4 4 <script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script> 5 <script language="javascript" type="text/javascript" src="../../utils/mctabs.js"></script> 5 6 <script language="javascript" type="text/javascript" src="../../utils/form_utils.js"></script> 6 7 <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" /> 29 9 </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"> 35 22 <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"> </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"> </td> 28 </tr> 29 </table></td> 46 30 </tr> 47 31 <!-- Link list --> … … 50 34 var html = ""; 51 35 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;">'; 54 38 html += '<option value="">---</option>'; 55 39 … … 64 48 <!-- /Link list --> 65 49 <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"> 68 52 <option value="_self">{$lang_insert_link_target_same}</option> 69 53 <option value="_blank">{$lang_insert_link_target_blank}</option> … … 89 73 </tr> 90 74 <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> 93 77 </tr> 94 78 <tr id="styleSelectRow"> 95 <td>< !--{$lang_class_name}:</td>79 <td><label for="styleSelect">{$lang_class_name}</label></td> 96 80 <td> 97 81 <select id="styleSelect" name="styleSelect"> 98 82 <option value="" selected>{$lang_theme_style_select}</option> 99 83 </select></td> 100 <td align="right"> </td>101 <td align="right"> --></td>102 84 </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> 111 98 </form> 112 99 </body> -
trunk/wp-includes/js/tinymce/themes/advanced/source_editor.htm
r3503 r4431 5 5 <script language="javascript" type="text/javascript" src="../../tiny_mce_popup.js"></script> 6 6 <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" /> 29 8 </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"> 31 10 <form name="source" onsubmit="saveContent();" action="#"> 32 11 <div style="float: left" class="title">{$lang_theme_code_title}</div> … … 36 15 </div> 37 16 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> 39 18 40 19 <div class="mceActionPanel"> 41 20 <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" /> 43 22 </div> 44 23 45 24 <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" /> 47 26 </div> 48 27 </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 4 function TinyMCE_Engine() { 11 5 this.majorVersion = "2"; 12 this.minorVersion = "0 ";13 this.releaseDate = "200 5-12-01";6 this.minorVersion = "0.6.1"; 7 this.releaseDate = "2006-05-04"; 14 8 15 9 this.instances = new Array(); 16 this.s tickyClassesLookup= new Array();10 this.switchClassCache = new Array(); 17 11 this.windowArgs = new Array(); 18 12 this.loadedFiles = new Array(); 13 this.pendingFiles = new Array(); 14 this.loadingIndex = 0; 19 15 this.configs = new Array(); 20 16 this.currentConfig = 0; … … 33 29 this.isNS71 = ua.indexOf('Netscape/7.1') != -1; 34 30 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; 35 37 36 38 // Fake MSIE on Opera and if Opera fakes IE, Gecko or Safari cancel those … … 45 47 }; 46 48 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 49 TinyMCE_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() { 261 305 if (tinyMCE.isMSIE) { 262 306 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); 265 309 } 266 310 } else { … … 268 312 tinyMCE.addEvent(window, "unload", function () {tinyMCE.triggerSave(true, true);}); 269 313 } 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) 297 392 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; 385 557 386 558 // Default to false … … 392 564 skip_callback = false; 393 565 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(/</g, '<'); 757 content = content.replace(/>/g, '>'); 758 content = content.replace(/"/g, '"'); 759 content = content.replace(/&/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('<>', '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 = " "; 1180 else 1181 elm.innerHTML = " "; 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 !