Ticket #5722: flash-uploader-awesome-2.patch
File flash-uploader-awesome-2.patch, 98.2 KB (added by , 17 years ago) |
---|
-
wp-includes/macros.php
1 <?php 2 3 /* 4 5 An API for creating macro tags that support attributes and enclosed content, such as: 6 7 [macro /] 8 [macro foo="bar" baz="bing" /] 9 [macro foo="bar"]content[/macro] 10 11 tag and attrbute parsing regexp code based on the Textpattern tag parser. 12 13 To apply macro tags to content: 14 15 $out = do_macro($content); 16 17 Simplest example of a macro tag using the API: 18 19 // [footag foo="bar"] 20 function footag_func($atts) { 21 return "foo = {$atts[foo]}"; 22 } 23 add_macro('footag', 'footag_func'); 24 25 Example with nice attribute defaults: 26 27 // [bartag foo="bar"] 28 function bartag_func($atts) { 29 extract(macro_atts(array( 30 'foo' => 'no foo', 31 'baz' => 'default baz', 32 ), $atts)); 33 34 return "foo = {$foo}"; 35 } 36 add_macro('bartag', 'bartag_func'); 37 38 Example with enclosed content: 39 40 // [baztag]content[/baztag] 41 function baztag_func($atts, $content='') { 42 return "content = $content"; 43 } 44 add_macro('baztag', 'baztag_func'); 45 46 */ 47 48 $macro_tags = array(); 49 50 function add_macro($tag, $func) { 51 global $macro_tags; 52 53 if ( is_callable($func) ) 54 $macro_tags[$tag] = $func; 55 } 56 57 function remove_macro($tag) { 58 global $macro_tags; 59 60 unset($macro_tags[$tag]); 61 } 62 63 function remove_all_macros() { 64 global $macro_tags; 65 66 $macro_tags = array(); 67 } 68 69 function do_macro($content) { 70 global $macro_tags; 71 72 if (empty($macro_tags) || !is_array($macro_tags)) 73 return $content; 74 75 $tagnames = array_keys($macro_tags); 76 $tagregexp = join( '|', array_map('preg_quote', $tagnames) ); 77 78 $pattern = '/\[('.$tagregexp.')\b(.*?)(?:(\/))?\](?:(.+?)\[\/\1\])?/s'; 79 80 return preg_replace_callback($pattern, 'do_macro_tag', $content); 81 } 82 83 function do_macro_tag($m) { 84 global $macro_tags; 85 86 $tag = $m[1]; 87 $attr = macro_parse_atts($m[2]); 88 89 if ( isset($m[4]) ) { 90 // enclosing tag - extra parameter 91 return call_user_func($macro_tags[$tag], $attr, $m[4]); 92 } else { 93 // self-closing tag 94 return call_user_func($macro_tags[$tag], $attr); 95 } 96 } 97 98 function macro_parse_atts($text) { 99 $atts = array(); 100 $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)/'; 101 if ( preg_match_all($pattern, $text, $match, PREG_SET_ORDER) ) { 102 foreach ($match as $m) { 103 if (!empty($m[1])) 104 $atts[strtolower($m[1])] = stripcslashes($m[2]); 105 elseif (!empty($m[3])) 106 $atts[strtolower($m[3])] = stripcslashes($m[4]); 107 elseif (!empty($m[5])) 108 $atts[strtolower($m[5])] = stripcslashes($m[6]); 109 } 110 } 111 return $atts; 112 } 113 114 function macro_atts($pairs, $atts) { 115 $out = array(); 116 foreach($pairs as $name => $default) { 117 if ( array_key_exists($name, $atts) ) 118 $out[$name] = $atts[$name]; 119 else 120 $out[$name] = $default; 121 } 122 return $out; 123 } 124 125 add_macro('thumbs', 'thumbs_macro'); 126 127 function thumbs_macro($attr) { 128 global $post; 129 130 // Allow plugins/themes to override the default thumbs template. 131 $output = apply_filters('post_thumbs', '', $attr); 132 if ( $output != '' ) 133 return $output; 134 135 $attachments = get_children("post_parent=$post->ID&post_type=attachment&orderby=\"menu_order ASC, ID ASC\""); 136 /* 137 foreach ( $attachments as $id => $attachment ) { 138 $meta = get_post_custom($id); 139 if ( $meta ) foreach ( $meta as $k => $v ) 140 $attachments[$id]->$k = $v; 141 if ( isset($attachments[$id]->_wp_attachment_metadata[0]) ) 142 $attachments[$id]->meta = unserialize($attachments[$id]->_wp_attachment_metadata[0]); 143 } 144 */ 145 146 $output = " 147 <style type='text/css'> 148 .thumbs { 149 width: 450px; 150 left: 50%; 151 margin: auto; 152 } 153 .thumbs div { 154 float: left; 155 margin-top: 10px; 156 text-align: center; 157 width: 33%; } 158 .thumbs img { 159 border: 3px solid #cfcfcf; 160 } 161 </style> 162 <div class='thumbs'> 163 "; 164 165 if ( !empty($attachments) ) foreach ( $attachments as $id => $attachment ) { 166 $src = wp_get_attachment_thumb_url($id); 167 $href = get_attachment_link($id); 168 $output .= " 169 <div> 170 <a href='$href'><img src='$src' alt='$attachment->post_title' /></a> 171 </div> 172 "; 173 if ( ++$i % 3 == 0 ) 174 $output .= '<br style="clear: both" />'; 175 } 176 177 $output .= " 178 </div> 179 "; 180 181 return $output; 182 } 183 184 add_filter('the_content', 'do_macro'); 185 186 ?> 187 No newline at end of file -
wp-includes/js/swfupload/swfupload.js
1 /** 2 * SWFUpload v2.0 by Jacob Roberts, Nov 2007, http://www.swfupload.org, http://linebyline.blogspot.com 3 * -------- -------- -------- -------- -------- -------- -------- -------- 4 * SWFUpload is (c) 2006 Lars Huring and Mammon Media and is released under the MIT License: 5 * http://www.opensource.org/licenses/mit-license.php 6 * 7 * See Changelog.txt for version history 8 * 9 * Development Notes: 10 * * This version of SWFUpload requires Flash Player 9.0.28 and should autodetect the correct flash version. 11 * * In Linux Flash Player 9 setting the post file variable name does not work. It is always set to "Filedata". 12 * * There is a lot of repeated code that could be refactored to single functions. Feel free. 13 * * It's dangerous to do "circular calls" between Flash and JavaScript. I've taken steps to try to work around issues 14 * by having the event calls pipe through setTimeout. However you should still avoid calling in to Flash from 15 * within the event handler methods. Especially the "startUpload" event since it cannot use the setTimeout hack. 16 */ 17 18 19 /* *********** */ 20 /* Constructor */ 21 /* *********** */ 22 23 var SWFUpload = function (init_settings) { 24 this.initSWFUpload(init_settings); 25 }; 26 27 SWFUpload.prototype.initSWFUpload = function (init_settings) { 28 // Remove background flicker in IE (read this: http://misterpixel.blogspot.com/2006/09/forensic-analysis-of-ie6.html) 29 // This doesn't have anything to do with SWFUpload but can help your UI behave better in IE. 30 try { 31 document.execCommand('BackgroundImageCache', false, true); 32 } catch (ex1) { 33 } 34 35 36 try { 37 this.customSettings = {}; // A container where developers can place their own settings associated with this instance. 38 this.settings = {}; 39 this.eventQueue = []; 40 this.movieName = "SWFUpload_" + SWFUpload.movieCount++; 41 this.movieElement = null; 42 43 // Setup global control tracking 44 SWFUpload.instances[this.movieName] = this; 45 46 // Load the settings. Load the Flash movie. 47 this.initSettings(init_settings); 48 this.loadFlash(); 49 50 this.displayDebugInfo(); 51 52 } catch (ex2) { 53 this.debug(ex2); 54 } 55 } 56 57 /* *************** */ 58 /* Static thingies */ 59 /* *************** */ 60 SWFUpload.instances = {}; 61 SWFUpload.movieCount = 0; 62 SWFUpload.QUEUE_ERROR = { 63 QUEUE_LIMIT_EXCEEDED : -100, 64 FILE_EXCEEDS_SIZE_LIMIT : -110, 65 ZERO_BYTE_FILE : -120, 66 INVALID_FILETYPE : -130 67 }; 68 SWFUpload.UPLOAD_ERROR = { 69 HTTP_ERROR : -200, 70 MISSING_UPLOAD_URL : -210, 71 IO_ERROR : -220, 72 SECURITY_ERROR : -230, 73 UPLOAD_LIMIT_EXCEEDED : -240, 74 UPLOAD_FAILED : -250, 75 SPECIFIED_FILE_ID_NOT_FOUND : -260, 76 FILE_VALIDATION_FAILED : -270, 77 FILE_CANCELLED : -280, 78 UPLOAD_STOPPED : -290 79 }; 80 SWFUpload.FILE_STATUS = { 81 QUEUED : -1, 82 IN_PROGRESS : -2, 83 ERROR : -3, 84 COMPLETE : -4, 85 CANCELLED : -5 86 }; 87 88 89 /* ***************** */ 90 /* Instance Thingies */ 91 /* ***************** */ 92 // init is a private method that ensures that all the object settings are set, getting a default value if one was not assigned. 93 94 SWFUpload.prototype.initSettings = function (init_settings) { 95 // Upload backend settings 96 this.addSetting("upload_url", init_settings.upload_url, ""); 97 this.addSetting("file_post_name", init_settings.file_post_name, "Filedata"); 98 this.addSetting("post_params", init_settings.post_params, {}); 99 100 // File Settings 101 this.addSetting("file_types", init_settings.file_types, "*.*"); 102 this.addSetting("file_types_description", init_settings.file_types_description, "All Files"); 103 this.addSetting("file_size_limit", init_settings.file_size_limit, "1024"); 104 this.addSetting("file_upload_limit", init_settings.file_upload_limit, "0"); 105 this.addSetting("file_queue_limit", init_settings.file_queue_limit, "0"); 106 107 // Flash Settings 108 this.addSetting("flash_url", init_settings.flash_url, "swfupload.swf"); 109 this.addSetting("flash_width", init_settings.flash_width, "1px"); 110 this.addSetting("flash_height", init_settings.flash_height, "1px"); 111 this.addSetting("flash_color", init_settings.flash_color, "#FFFFFF"); 112 113 // Debug Settings 114 this.addSetting("debug_enabled", init_settings.debug, false); 115 116 // Event Handlers 117 this.flashReady_handler = SWFUpload.flashReady; // This is a non-overrideable event handler 118 this.swfUploadLoaded_handler = this.retrieveSetting(init_settings.swfupload_loaded_handler, SWFUpload.swfUploadLoaded); 119 120 this.fileDialogStart_handler = this.retrieveSetting(init_settings.file_dialog_start_handler, SWFUpload.fileDialogStart); 121 this.fileQueued_handler = this.retrieveSetting(init_settings.file_queued_handler, SWFUpload.fileQueued); 122 this.fileQueueError_handler = this.retrieveSetting(init_settings.file_queue_error_handler, SWFUpload.fileQueueError); 123 this.fileDialogComplete_handler = this.retrieveSetting(init_settings.file_dialog_complete_handler, SWFUpload.fileDialogComplete); 124 125 this.uploadStart_handler = this.retrieveSetting(init_settings.upload_start_handler, SWFUpload.uploadStart); 126 this.uploadProgress_handler = this.retrieveSetting(init_settings.upload_progress_handler, SWFUpload.uploadProgress); 127 this.uploadError_handler = this.retrieveSetting(init_settings.upload_error_handler, SWFUpload.uploadError); 128 this.uploadSuccess_handler = this.retrieveSetting(init_settings.upload_success_handler, SWFUpload.uploadSuccess); 129 this.uploadComplete_handler = this.retrieveSetting(init_settings.upload_complete_handler, SWFUpload.uploadComplete); 130 131 this.debug_handler = this.retrieveSetting(init_settings.debug_handler, SWFUpload.debug); 132 133 // Other settings 134 this.customSettings = this.retrieveSetting(init_settings.custom_settings, {}); 135 }; 136 137 // loadFlash is a private method that generates the HTML tag for the Flash 138 // It then adds the flash to the "target" or to the body and stores a 139 // reference to the flash element in "movieElement". 140 SWFUpload.prototype.loadFlash = function () { 141 var html, target_element, container; 142 143 // Make sure an element with the ID we are going to use doesn't already exist 144 if (document.getElementById(this.movieName) !== null) { 145 return false; 146 } 147 148 // Get the body tag where we will be adding the flash movie 149 try { 150 target_element = document.getElementsByTagName("body")[0]; 151 if (typeof(target_element) === "undefined" || target_element === null) { 152 this.debug('Could not find the BODY element. SWFUpload failed to load.'); 153 return false; 154 } 155 } catch (ex) { 156 return false; 157 } 158 159 // Append the container and load the flash 160 container = document.createElement("div"); 161 container.style.width = this.getSetting("flash_width"); 162 container.style.height = this.getSetting("flash_height"); 163 164 target_element.appendChild(container); 165 container.innerHTML = this.getFlashHTML(); // Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers) 166 }; 167 168 // Generates the embed/object tags needed to embed the flash in to the document 169 SWFUpload.prototype.getFlashHTML = function () { 170 var html = ""; 171 172 // Create Mozilla Embed HTML 173 if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { 174 // Build the basic embed html 175 html = '<embed type="application/x-shockwave-flash" src="' + this.getSetting("flash_url") + '" width="' + this.getSetting("flash_width") + '" height="' + this.getSetting("flash_height") + '"'; 176 html += ' id="' + this.movieName + '" name="' + this.movieName + '" '; 177 html += 'bgcolor="' + this.getSetting("flash_color") + '" quality="high" menu="false" flashvars="'; 178 179 html += this.getFlashVars(); 180 181 html += '" />'; 182 183 // Create IE Object HTML 184 } else { 185 186 // Build the basic Object tag 187 html = '<object id="' + this.movieName + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.getSetting("flash_width") + '" height="' + this.getSetting("flash_height") + '">'; 188 html += '<param name="movie" value="' + this.getSetting("flash_url") + '">'; 189 190 html += '<param name="bgcolor" value="' + this.getSetting("flash_color") + '" />'; 191 html += '<param name="quality" value="high" />'; 192 html += '<param name="menu" value="false" />'; 193 194 html += '<param name="flashvars" value="' + this.getFlashVars() + '" />'; 195 html += '</object>'; 196 } 197 198 return html; 199 }; 200 201 // This private method builds the parameter string that will be passed 202 // to flash. 203 SWFUpload.prototype.getFlashVars = function () { 204 // Build a string from the post param object 205 var param_string = this.buildParamString(); 206 207 // Build the parameter string 208 var html = ""; 209 html += "movieName=" + encodeURIComponent(this.movieName); 210 html += "&uploadURL=" + encodeURIComponent(this.getSetting("upload_url")); 211 html += "¶ms=" + encodeURIComponent(param_string); 212 html += "&filePostName=" + encodeURIComponent(this.getSetting("file_post_name")); 213 html += "&fileTypes=" + encodeURIComponent(this.getSetting("file_types")); 214 html += "&fileTypesDescription=" + encodeURIComponent(this.getSetting("file_types_description")); 215 html += "&fileSizeLimit=" + encodeURIComponent(this.getSetting("file_size_limit")); 216 html += "&fileUploadLimit=" + encodeURIComponent(this.getSetting("file_upload_limit")); 217 html += "&fileQueueLimit=" + encodeURIComponent(this.getSetting("file_queue_limit")); 218 html += "&debugEnabled=" + encodeURIComponent(this.getSetting("debug_enabled")); 219 220 return html; 221 }; 222 223 SWFUpload.prototype.getMovieElement = function () { 224 if (typeof(this.movieElement) === "undefined" || this.movieElement === null) { 225 this.movieElement = document.getElementById(this.movieName); 226 227 // Fix IEs "Flash can't callback when in a form" issue (http://www.extremefx.com.ar/blog/fixing-flash-external-interface-inside-form-on-internet-explorer) 228 // Removed because Revision 6 always adds the flash to the body (inside a containing div) 229 // If you insist on adding the Flash file inside a Form then in IE you have to make you wait until the DOM is ready 230 // and run this code to make the form's ID available from the window object so Flash and JavaScript can communicate. 231 //if (typeof(window[this.movieName]) === "undefined" || window[this.moveName] !== this.movieElement) { 232 // window[this.movieName] = this.movieElement; 233 //} 234 } 235 236 return this.movieElement; 237 }; 238 239 SWFUpload.prototype.buildParamString = function () { 240 var post_params = this.getSetting("post_params"); 241 var param_string_pairs = []; 242 var i, value, name; 243 244 // Retrieve the user defined parameters 245 if (typeof(post_params) === "object") { 246 for (name in post_params) { 247 if (post_params.hasOwnProperty(name)) { 248 if (typeof(post_params[name]) === "string") { 249 param_string_pairs.push(encodeURIComponent(name) + "=" + encodeURIComponent(post_params[name])); 250 } 251 } 252 } 253 } 254 255 return param_string_pairs.join("&"); 256 }; 257 258 // Saves a setting. If the value given is undefined or null then the default_value is used. 259 SWFUpload.prototype.addSetting = function (name, value, default_value) { 260 if (typeof(value) === "undefined" || value === null) { 261 this.settings[name] = default_value; 262 } else { 263 this.settings[name] = value; 264 } 265 266 return this.settings[name]; 267 }; 268 269 // Gets a setting. Returns empty string if not found. 270 SWFUpload.prototype.getSetting = function (name) { 271 if (typeof(this.settings[name]) === "undefined") { 272 return ""; 273 } else { 274 return this.settings[name]; 275 } 276 }; 277 278 // Gets a setting, if the setting is undefined then return the default value 279 // This does not affect or use the interal setting object. 280 SWFUpload.prototype.retrieveSetting = function (value, default_value) { 281 if (typeof(value) === "undefined" || value === null) { 282 return default_value; 283 } else { 284 return value; 285 } 286 }; 287 288 289 // It loops through all the settings and displays 290 // them in the debug Console. 291 SWFUpload.prototype.displayDebugInfo = function () { 292 var key, debug_message = ""; 293 294 debug_message += "----- SWFUPLOAD SETTINGS ----\nID: " + this.moveName + "\n"; 295 296 debug_message += this.outputObject(this.settings); 297 298 debug_message += "----- SWFUPLOAD SETTINGS END ----\n"; 299 debug_message += "\n"; 300 301 this.debug(debug_message); 302 }; 303 SWFUpload.prototype.outputObject = function (object, prefix) { 304 var output = "", key; 305 306 if (typeof(prefix) !== "string") { 307 prefix = ""; 308 } 309 if (typeof(object) !== "object") { 310 return ""; 311 } 312 313 for (key in object) { 314 if (object.hasOwnProperty(key)) { 315 if (typeof(object[key]) === "object") { 316 output += (prefix + key + ": { \n" + this.outputObject(object[key], "\t" + prefix) + prefix + "}" + "\n"); 317 } else { 318 output += (prefix + key + ": " + object[key] + "\n"); 319 } 320 } 321 } 322 323 return output; 324 }; 325 326 /* ***************************** 327 -- Flash control methods -- 328 Your UI should use these 329 to operate SWFUpload 330 ***************************** */ 331 332 SWFUpload.prototype.selectFile = function () { 333 var movie_element = this.getMovieElement(); 334 if (movie_element !== null && typeof(movie_element.SelectFile) === "function") { 335 try { 336 movie_element.SelectFile(); 337 } 338 catch (ex) { 339 this.debug("Could not call SelectFile: " + ex); 340 } 341 } else { 342 this.debug("Could not find Flash element"); 343 } 344 345 }; 346 347 SWFUpload.prototype.selectFiles = function () { 348 var movie_element = this.getMovieElement(); 349 if (movie_element !== null && typeof(movie_element.SelectFiles) === "function") { 350 try { 351 movie_element.SelectFiles(); 352 } 353 catch (ex) { 354 this.debug("Could not call SelectFiles: " + ex); 355 } 356 } else { 357 this.debug("Could not find Flash element"); 358 } 359 360 }; 361 362 363 /* Start the upload. If a file_id is specified that file is uploaded. Otherwise the first 364 * file in the queue is uploaded. If no files are in the queue then nothing happens. 365 * This call uses setTimeout since Flash will be calling back in to JavaScript 366 */ 367 SWFUpload.prototype.startUpload = function (file_id) { 368 var self = this; 369 var movie_element = this.getMovieElement(); 370 if (movie_element !== null && typeof(movie_element.StartUpload) === "function") { 371 setTimeout( 372 function () { 373 try { 374 movie_element.StartUpload(file_id); 375 } 376 catch (ex) { 377 self.debug("Could not call StartUpload: " + ex); 378 } 379 }, 0 380 ); 381 } else { 382 this.debug("Could not find Flash element"); 383 } 384 385 }; 386 387 /* Cancels a the file upload. You must specify a file_id */ 388 SWFUpload.prototype.cancelUpload = function (file_id) { 389 var movie_element = this.getMovieElement(); 390 if (movie_element !== null && typeof(movie_element.CancelUpload) === "function") { 391 try { 392 movie_element.CancelUpload(file_id); 393 } 394 catch (ex) { 395 this.debug("Could not call CancelUpload: " + ex); 396 } 397 } else { 398 this.debug("Could not find Flash element"); 399 } 400 401 }; 402 403 // Stops the current upload. The file is re-queued. If nothing is currently uploading then nothing happens. 404 SWFUpload.prototype.stopUpload = function () { 405 var movie_element = this.getMovieElement(); 406 if (movie_element !== null && typeof(movie_element.StopUpload) === "function") { 407 try { 408 movie_element.StopUpload(); 409 } 410 catch (ex) { 411 this.debug("Could not call StopUpload: " + ex); 412 } 413 } else { 414 this.debug("Could not find Flash element"); 415 } 416 417 }; 418 419 /* ************************ 420 * Settings methods 421 * These methods change the settings inside SWFUpload 422 * They shouldn't need to be called in a setTimeout since they 423 * should not call back from Flash to JavaScript (except perhaps in a Debug call) 424 * and some need to return data so setTimeout won't work. 425 */ 426 427 /* Gets the file statistics object. It looks like this (where n = number): 428 { 429 files_queued: n, 430 complete_uploads: n, 431 upload_errors: n, 432 uploads_cancelled: n, 433 queue_errors: n 434 } 435 */ 436 SWFUpload.prototype.getStats = function () { 437 var movie_element = this.getMovieElement(); 438 if (movie_element !== null && typeof(movie_element.GetStats) === "function") { 439 try { 440 return movie_element.GetStats(); 441 } 442 catch (ex) { 443 this.debug("Could not call GetStats"); 444 } 445 } else { 446 this.debug("Could not find Flash element"); 447 } 448 }; 449 SWFUpload.prototype.setStats = function (stats_object) { 450 var movie_element = this.getMovieElement(); 451 if (movie_element !== null && typeof(movie_element.SetStats) === "function") { 452 try { 453 movie_element.SetStats(stats_object); 454 } 455 catch (ex) { 456 this.debug("Could not call SetStats"); 457 } 458 } else { 459 this.debug("Could not find Flash element"); 460 } 461 }; 462 463 SWFUpload.prototype.setCredentials = function(name, password) { 464 var movie_element = this.getMovieElement(); 465 if (movie_element !== null && typeof(movie_element.SetCredentials) === "function") { 466 try { 467 return movie_element.SetCredentials(name, password); 468 } 469 catch (ex) { 470 this.debug("Could not call SetCredentials"); 471 } 472 } else { 473 this.debug("Could not find Flash element"); 474 } 475 }; 476 477 SWFUpload.prototype.getFile = function (file_id) { 478 var movie_element = this.getMovieElement(); 479 if (typeof(file_id) === "number") { 480 if (movie_element !== null && typeof(movie_element.GetFileByIndex) === "function") { 481 try { 482 return movie_element.GetFileByIndex(file_id); 483 } 484 catch (ex) { 485 this.debug("Could not call GetFileByIndex"); 486 } 487 } else { 488 this.debug("Could not find Flash element"); 489 } 490 } else { 491 if (movie_element !== null && typeof(movie_element.GetFile) === "function") { 492 try { 493 return movie_element.GetFile(file_id); 494 } 495 catch (ex) { 496 this.debug("Could not call GetFile"); 497 } 498 } else { 499 this.debug("Could not find Flash element"); 500 } 501 } 502 }; 503 504 SWFUpload.prototype.addFileParam = function (file_id, name, value) { 505 var movie_element = this.getMovieElement(); 506 if (movie_element !== null && typeof(movie_element.AddFileParam) === "function") { 507 try { 508 return movie_element.AddFileParam(file_id, name, value); 509 } 510 catch (ex) { 511 this.debug("Could not call AddFileParam"); 512 } 513 } else { 514 this.debug("Could not find Flash element"); 515 } 516 }; 517 518 SWFUpload.prototype.removeFileParam = function (file_id, name) { 519 var movie_element = this.getMovieElement(); 520 if (movie_element !== null && typeof(movie_element.RemoveFileParam) === "function") { 521 try { 522 return movie_element.RemoveFileParam(file_id, name); 523 } 524 catch (ex) { 525 this.debug("Could not call AddFileParam"); 526 } 527 } else { 528 this.debug("Could not find Flash element"); 529 } 530 531 }; 532 533 SWFUpload.prototype.setUploadURL = function (url) { 534 var movie_element = this.getMovieElement(); 535 if (movie_element !== null && typeof(movie_element.SetUploadURL) === "function") { 536 try { 537 this.addSetting("upload_url", url); 538 movie_element.SetUploadURL(this.getSetting("upload_url")); 539 } 540 catch (ex) { 541 this.debug("Could not call SetUploadURL"); 542 } 543 } else { 544 this.debug("Could not find Flash element in setUploadURL"); 545 } 546 }; 547 548 SWFUpload.prototype.setPostParams = function (param_object) { 549 var movie_element = this.getMovieElement(); 550 if (movie_element !== null && typeof(movie_element.SetPostParams) === "function") { 551 try { 552 this.addSetting("post_params", param_object); 553 movie_element.SetPostParams(this.getSetting("post_params")); 554 } 555 catch (ex) { 556 this.debug("Could not call SetPostParams"); 557 } 558 } else { 559 this.debug("Could not find Flash element in SetPostParams"); 560 } 561 }; 562 563 SWFUpload.prototype.setFileTypes = function (types, description) { 564 var movie_element = this.getMovieElement(); 565 if (movie_element !== null && typeof(movie_element.SetFileTypes) === "function") { 566 try { 567 this.addSetting("file_types", types); 568 this.addSetting("file_types_description", description); 569 movie_element.SetFileTypes(this.getSetting("file_types"), this.getSetting("file_types_description")); 570 } 571 catch (ex) { 572 this.debug("Could not call SetFileTypes"); 573 } 574 } else { 575 this.debug("Could not find Flash element in SetFileTypes"); 576 } 577 }; 578 579 SWFUpload.prototype.setFileSizeLimit = function (file_size_limit) { 580 var movie_element = this.getMovieElement(); 581 if (movie_element !== null && typeof(movie_element.SetFileSizeLimit) === "function") { 582 try { 583 this.addSetting("file_size_limit", file_size_limit); 584 movie_element.SetFileSizeLimit(this.getSetting("file_size_limit")); 585 } 586 catch (ex) { 587 this.debug("Could not call SetFileSizeLimit"); 588 } 589 } else { 590 this.debug("Could not find Flash element in SetFileSizeLimit"); 591 } 592 }; 593 594 SWFUpload.prototype.setFileUploadLimit = function (file_upload_limit) { 595 var movie_element = this.getMovieElement(); 596 if (movie_element !== null && typeof(movie_element.SetFileUploadLimit) === "function") { 597 try { 598 this.addSetting("file_upload_limit", file_upload_limit); 599 movie_element.SetFileUploadLimit(this.getSetting("file_upload_limit")); 600 } 601 catch (ex) { 602 this.debug("Could not call SetFileUploadLimit"); 603 } 604 } else { 605 this.debug("Could not find Flash element in SetFileUploadLimit"); 606 } 607 }; 608 609 SWFUpload.prototype.setFileQueueLimit = function (file_queue_limit) { 610 var movie_element = this.getMovieElement(); 611 if (movie_element !== null && typeof(movie_element.SetFileQueueLimit) === "function") { 612 try { 613 this.addSetting("file_queue_limit", file_queue_limit); 614 movie_element.SetFileQueueLimit(this.getSetting("file_queue_limit")); 615 } 616 catch (ex) { 617 this.debug("Could not call SetFileQueueLimit"); 618 } 619 } else { 620 this.debug("Could not find Flash element in SetFileQueueLimit"); 621 } 622 }; 623 624 SWFUpload.prototype.setFilePostName = function (file_post_name) { 625 var movie_element = this.getMovieElement(); 626 if (movie_element !== null && typeof(movie_element.SetFilePostName) === "function") { 627 try { 628 this.addSetting("file_post_name", file_post_name); 629 movie_element.SetFilePostName(this.getSetting("file_post_name")); 630 } 631 catch (ex) { 632 this.debug("Could not call SetFilePostName"); 633 } 634 } else { 635 this.debug("Could not find Flash element in SetFilePostName"); 636 } 637 }; 638 639 SWFUpload.prototype.setDebugEnabled = function (debug_enabled) { 640 var movie_element = this.getMovieElement(); 641 if (movie_element !== null && typeof(movie_element.SetDebugEnabled) === "function") { 642 try { 643 this.addSetting("debug_enabled", debug_enabled); 644 movie_element.SetDebugEnabled(this.getSetting("debug_enabled")); 645 } 646 catch (ex) { 647 this.debug("Could not call SetDebugEnabled"); 648 } 649 } else { 650 this.debug("Could not find Flash element in SetDebugEnabled"); 651 } 652 }; 653 654 /* ******************************* 655 Internal Event Callers 656 Don't override these! These event callers ensure that your custom event handlers 657 are called safely and in order. 658 ******************************* */ 659 660 /* This is the callback method that the Flash movie will call when it has been loaded and is ready to go. 661 Calling this or showUI() "manually" will bypass the Flash Detection built in to SWFUpload. 662 Use a ui_function setting if you want to control the UI loading after the flash has loaded. 663 */ 664 SWFUpload.prototype.flashReady = function () { 665 // Check that the movie element is loaded correctly with its ExternalInterface methods defined 666 var movie_element = this.getMovieElement(); 667 if (movie_element === null || typeof(movie_element.StartUpload) !== "function") { 668 this.debug("ExternalInterface methods failed to initialize."); 669 return; 670 } 671 672 var self = this; 673 if (typeof(self.flashReady_handler) === "function") { 674 this.eventQueue[this.eventQueue.length] = function() { self.flashReady_handler(); }; 675 setTimeout(function () { self.executeNextEvent();}, 0); 676 } else { 677 this.debug("flashReady_handler event not defined"); 678 } 679 }; 680 681 /* 682 Event Queue. Rather can call events directly from Flash they events are 683 are placed in a queue and then executed. This ensures that each event is 684 executed in the order it was called which is not guarenteed when calling 685 setTimeout. Out of order events was especially problematic in Safari. 686 */ 687 SWFUpload.prototype.executeNextEvent = function () { 688 var f = this.eventQueue.shift(); 689 if (typeof(f) === "function") { 690 f(); 691 } 692 } 693 694 /* This is a chance to do something before the browse window opens */ 695 SWFUpload.prototype.fileDialogStart = function () { 696 var self = this; 697 if (typeof(self.fileDialogStart_handler) === "function") { 698 this.eventQueue[this.eventQueue.length] = function() { self.fileDialogStart_handler(); }; 699 setTimeout(function () { self.executeNextEvent();}, 0); 700 } else { 701 this.debug("fileDialogStart event not defined"); 702 } 703 }; 704 705 706 /* Called when a file is successfully added to the queue. */ 707 SWFUpload.prototype.fileQueued = function (file) { 708 var self = this; 709 if (typeof(self.fileQueued_handler) === "function") { 710 this.eventQueue[this.eventQueue.length] = function() { self.fileQueued_handler(file); }; 711 setTimeout(function () { self.executeNextEvent();}, 0); 712 } else { 713 this.debug("fileQueued event not defined"); 714 } 715 }; 716 717 718 /* Handle errors that occur when an attempt to queue a file fails. */ 719 SWFUpload.prototype.fileQueueError = function (file, error_code, message) { 720 var self = this; 721 if (typeof(self.fileQueueError_handler) === "function") { 722 this.eventQueue[this.eventQueue.length] = function() { self.fileQueueError_handler(file, error_code, message); }; 723 setTimeout(function () { self.executeNextEvent();}, 0); 724 } else { 725 this.debug("fileQueueError event not defined"); 726 } 727 }; 728 729 /* Called after the file dialog has closed and the selected files have been queued. 730 You could call startUpload here if you want the queued files to begin uploading immediately. */ 731 SWFUpload.prototype.fileDialogComplete = function (num_files_selected) { 732 var self = this; 733 if (typeof(self.fileDialogComplete_handler) === "function") { 734 this.eventQueue[this.eventQueue.length] = function() { self.fileDialogComplete_handler(num_files_selected); }; 735 setTimeout(function () { self.executeNextEvent();}, 0); 736 } else { 737 this.debug("fileDialogComplete event not defined"); 738 } 739 }; 740 741 /* Gets called when a file upload is about to be started. Return true to continue the upload. Return false to stop the upload. 742 If you return false then uploadError and uploadComplete are called (like normal). 743 744 This is a good place to do any file validation you need. 745 */ 746 SWFUpload.prototype.uploadStart = function (file) { 747 var self = this; 748 if (typeof(self.fileDialogComplete_handler) === "function") { 749 this.eventQueue[this.eventQueue.length] = function() { self.returnUploadStart(self.uploadStart_handler(file)); }; 750 setTimeout(function () { self.executeNextEvent();}, 0); 751 } else { 752 this.debug("uploadStart event not defined"); 753 } 754 }; 755 756 /* Note: Internal use only. This function returns the result of uploadStart to 757 flash. Since returning values in the normal way can result in Flash/JS circular 758 call issues we split up the call in a Timeout. This is transparent from the API 759 point of view. 760 */ 761 SWFUpload.prototype.returnUploadStart = function (return_value) { 762 var movie_element = this.getMovieElement(); 763 if (movie_element !== null && typeof(movie_element.ReturnUploadStart) === "function") { 764 try { 765 movie_element.ReturnUploadStart(return_value); 766 } 767 catch (ex) { 768 this.debug("Could not call ReturnUploadStart"); 769 } 770 } else { 771 this.debug("Could not find Flash element in returnUploadStart"); 772 } 773 }; 774 775 776 777 /* Called during upload as the file progresses. Use this event to update your UI. */ 778 SWFUpload.prototype.uploadProgress = function (file, bytes_complete, bytes_total) { 779 var self = this; 780 if (typeof(self.uploadProgress_handler) === "function") { 781 this.eventQueue[this.eventQueue.length] = function() { self.uploadProgress_handler(file, bytes_complete, bytes_total); }; 782 setTimeout(function () { self.executeNextEvent();}, 0); 783 } else { 784 this.debug("uploadProgress event not defined"); 785 } 786 }; 787 788 /* Called when an error occurs during an upload. Use error_code and the SWFUpload.UPLOAD_ERROR constants to determine 789 which error occurred. The uploadComplete event is called after an error code indicating that the next file is 790 ready for upload. For files cancelled out of order the uploadComplete event will not be called. */ 791 SWFUpload.prototype.uploadError = function (file, error_code, message) { 792 var self = this; 793 if (typeof(this.uploadError_handler) === "function") { 794 this.eventQueue[this.eventQueue.length] = function() { self.uploadError_handler(file, error_code, message); }; 795 setTimeout(function () { self.executeNextEvent();}, 0); 796 } else { 797 this.debug("uploadError event not defined"); 798 } 799 }; 800 801 /* This gets called when a file finishes uploading and the server-side upload script has completed and returned a 200 802 status code. Any text returned by the server is available in server_data. 803 **NOTE: The upload script MUST return some text or the uploadSuccess and uploadComplete events will not fire and the 804 upload will become 'stuck'. */ 805 SWFUpload.prototype.uploadSuccess = function (file, server_data) { 806 var self = this; 807 if (typeof(self.uploadSuccess_handler) === "function") { 808 this.eventQueue[this.eventQueue.length] = function() { self.uploadSuccess_handler(file, server_data); }; 809 setTimeout(function () { self.executeNextEvent();}, 0); 810 } else { 811 this.debug("uploadSuccess event not defined"); 812 } 813 }; 814 815 /* uploadComplete is called when the file is uploaded or an error occurred and SWFUpload is ready to make the next upload. 816 If you want the next upload to start to automatically you can call startUpload() from this event. */ 817 SWFUpload.prototype.uploadComplete = function (file) { 818 var self = this; 819 if (typeof(self.uploadComplete_handler) === "function") { 820 this.eventQueue[this.eventQueue.length] = function() { self.uploadComplete_handler(file); }; 821 setTimeout(function () { self.executeNextEvent();}, 0); 822 } else { 823 this.debug("uploadComplete event not defined"); 824 } 825 }; 826 827 /* Called by SWFUpload JavaScript and Flash functions when debug is enabled. By default it writes messages to the 828 internal debug console. You can override this event and have messages written where you want. */ 829 SWFUpload.prototype.debug = function (message) { 830 var self = this; 831 if (typeof(self.debug_handler) === "function") { 832 this.eventQueue[this.eventQueue.length] = function() { self.debug_handler(message); }; 833 setTimeout(function () { self.executeNextEvent();}, 0); 834 } else { 835 this.eventQueue[this.eventQueue.length] = function() { self.debugMessage(message); }; 836 setTimeout(function () { self.executeNextEvent();}, 0); 837 } 838 }; 839 840 841 /* ********************************** 842 Default Event Handlers. 843 These event handlers are used by default if an overriding handler is 844 not defined in the SWFUpload settings object. 845 846 JS Note: even though these are defined on the SWFUpload object (rather than the prototype) they 847 are attached (read: copied) to a SWFUpload instance and 'this' is given the proper context. 848 ********************************** */ 849 850 /* This is a special event handler that has no override in the settings. Flash calls this when it has 851 been loaded by the browser and is ready for interaction. You should not override it. If you need 852 to do something with SWFUpload has loaded then use the swfupload_loaded_handler setting. 853 */ 854 SWFUpload.flashReady = function () { 855 try { 856 this.debug("Flash called back and is ready."); 857 858 if (typeof(this.swfUploadLoaded_handler) === "function") { 859 this.swfUploadLoaded_handler(); 860 } 861 } catch (ex) { 862 this.debug(ex); 863 } 864 }; 865 866 /* This is a chance to something immediately after SWFUpload has loaded. 867 Like, hide the default/degraded upload form and display the SWFUpload form. */ 868 SWFUpload.swfUploadLoaded = function () { 869 }; 870 871 /* This is a chance to do something before the browse window opens */ 872 SWFUpload.fileDialogStart = function () { 873 }; 874 875 876 /* Called when a file is successfully added to the queue. */ 877 SWFUpload.fileQueued = function (file) { 878 }; 879 880 881 /* Handle errors that occur when an attempt to queue a file fails. */ 882 SWFUpload.fileQueueError = function (file, error_code, message) { 883 try { 884 switch (error_code) { 885 case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: 886 this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 887 break; 888 case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: 889 this.debug("Error Code: Zero Byte File, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 890 break; 891 case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED: 892 this.debug("Error Code: Upload limit reached, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 893 break; 894 case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE: 895 this.debug("Error Code: File extension is not allowed, Message: " + message); 896 break; 897 default: 898 this.debug("Error Code: Unhandled error occured. Errorcode: " + error_code); 899 } 900 } catch (ex) { 901 this.debug(ex); 902 } 903 }; 904 905 /* Called after the file dialog has closed and the selected files have been queued. 906 You could call startUpload here if you want the queued files to begin uploading immediately. */ 907 SWFUpload.fileDialogComplete = function (num_files_selected) { 908 }; 909 910 /* Gets called when a file upload is about to be started. Return true to continue the upload. Return false to stop the upload. 911 If you return false then the uploadError callback is called and then uploadComplete (like normal). 912 913 This is a good place to do any file validation you need. 914 915 This is the only function that cannot be called on a setTimeout because it must return a value to Flash. 916 You SHOULD NOT make any calls in to Flash (e.i, changing settings, getting stats, etc). Flash Player bugs prevent 917 calls in to Flash from working reliably. 918 */ 919 SWFUpload.uploadStart = function (file) { 920 return true; 921 }; 922 923 // Called during upload as the file progresses 924 SWFUpload.uploadProgress = function (file, bytes_complete, bytes_total) { 925 this.debug("File Progress: " + file.id + ", Bytes: " + bytes_complete + ". Total: " + bytes_total); 926 }; 927 928 /* This gets called when a file finishes uploading and the upload script has completed and returned a 200 status code. Any text returned by the 929 server is available in server_data. The upload script must return some text or uploadSuccess will not fire (neither will uploadComplete). */ 930 SWFUpload.uploadSuccess = function (file, server_data) { 931 this.debug("Upload Success: " + file.id + ", Server: " + server_data); 932 }; 933 934 /* This is called last. The file is uploaded or an error occurred and SWFUpload is ready to make the next upload. 935 If you want to automatically start the next file just call startUpload from here. 936 */ 937 SWFUpload.uploadComplete = function (file) { 938 this.debug("Upload Complete: " + file.id); 939 }; 940 941 // Called by SWFUpload JavaScript and Flash functions when debug is enabled. 942 // Override this method in your settings to call your own debug message handler 943 SWFUpload.debug = function (message) { 944 if (this.getSetting("debug_enabled")) { 945 this.debugMessage(message); 946 } 947 }; 948 949 /* Called when an upload occurs during upload. For HTTP errors 'message' will contain the HTTP STATUS CODE */ 950 SWFUpload.uploadError = function (file, errcode, msg) { 951 try { 952 switch (errcode) { 953 case SWFUpload.UPLOAD_ERROR.SPECIFIED_FILE_ID_NOT_FOUND: 954 this.debug("Error Code: File ID specified for upload was not found, Message: " + msg); 955 break; 956 case SWFUpload.UPLOAD_ERROR.HTTP_ERROR: 957 this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + msg); 958 break; 959 case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL: 960 this.debug("Error Code: No backend file, File name: " + file.name + ", Message: " + msg); 961 break; 962 case SWFUpload.UPLOAD_ERROR.IO_ERROR: 963 this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + msg); 964 break; 965 case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR: 966 this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + msg); 967 break; 968 case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: 969 this.debug("Error Code: Upload limit reached, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg); 970 break; 971 case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED: 972 this.debug("Error Code: Upload Initialization exception, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg); 973 break; 974 case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED: 975 this.debug("Error Code: uploadStart callback returned false, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg); 976 break; 977 case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: 978 this.debug("Error Code: The file upload was cancelled, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg); 979 break; 980 case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: 981 this.debug("Error Code: The file upload was stopped, File name: " + file.name + ", File size: " + file.size + ", Message: " + msg); 982 break; 983 default: 984 this.debug("Error Code: Unhandled error occured. Errorcode: " + errcode); 985 } 986 } catch (ex) { 987 this.debug(ex); 988 } 989 }; 990 991 992 993 /* ********************************** 994 Debug Console 995 The debug console is a self contained, in page location 996 for debug message to be sent. The Debug Console adds 997 itself to the body if necessary. 998 999 The console is automatically scrolled as messages appear. 1000 1001 You can override this console (to use FireBug's console for instance) by setting the debug event method to your own function 1002 that handles the debug message 1003 ********************************** */ 1004 SWFUpload.prototype.debugMessage = function (message) { 1005 var exception_message, exception_values; 1006 1007 if (typeof(message) === "object" && typeof(message.name) === "string" && typeof(message.message) === "string") { 1008 exception_message = ""; 1009 exception_values = []; 1010 for (var key in message) { 1011 exception_values.push(key + ": " + message[key]); 1012 } 1013 exception_message = exception_values.join("\n"); 1014 exception_values = exception_message.split("\n"); 1015 exception_message = "EXCEPTION: " + exception_values.join("\nEXCEPTION: "); 1016 SWFUpload.Console.writeLine(exception_message); 1017 } else { 1018 SWFUpload.Console.writeLine(message); 1019 } 1020 }; 1021 1022 SWFUpload.Console = {}; 1023 SWFUpload.Console.writeLine = function (message) { 1024 var console, documentForm; 1025 1026 try { 1027 console = document.getElementById("SWFUpload_Console"); 1028 1029 if (!console) { 1030 documentForm = document.createElement("form"); 1031 document.getElementsByTagName("body")[0].appendChild(documentForm); 1032 1033 console = document.createElement("textarea"); 1034 console.id = "SWFUpload_Console"; 1035 console.style.fontFamily = "monospace"; 1036 console.setAttribute("wrap", "off"); 1037 console.wrap = "off"; 1038 console.style.overflow = "auto"; 1039 console.style.width = "700px"; 1040 console.style.height = "350px"; 1041 console.style.margin = "5px"; 1042 documentForm.appendChild(console); 1043 } 1044 1045 console.value += message + "\n"; 1046 1047 console.scrollTop = console.scrollHeight - console.clientHeight; 1048 } catch (ex) { 1049 alert("Exception: " + ex.name + " Message: " + ex.message); 1050 } 1051 }; -
wp-includes/js/swfupload/plugins/swfupload.documentready.js
Property changes on: wp-includes/js/swfupload/swfupload.js ___________________________________________________________________ Name: svn:executable + * Cannot display: file marked as a binary type. svn:mime-type = application/octet-stream Property changes on: wp-includes/js/swfupload/swfupload_f9.swf ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + application/octet-stream
1 /* 2 DocumentReady Plug-in 3 4 This plugin loads SWFUpload as soon as the document is ready. You should not load SWFUpload inside window.onload using this plugin. 5 You can also chain other functions by calling SWFUpload.DocumentReady(your function). 6 7 Warning: Embedded Ads or other scripts that overwrite window.onload or use their own document ready functions may interfer with this plugin. You 8 should not set window.onload when using this plugin. 9 10 Usage Example: 11 12 var swfu = new SWFUpload(your settings object); 13 SWFUpload.DocumentReady(function () { alert('Document Ready!'; }); 14 15 */ 16 17 var SWFUpload; 18 if (typeof(SWFUpload) === "function") { 19 // Override iniSWFUpload so SWFUpload gets inited when the document is ready rather than immediately 20 SWFUpload.prototype.initSWFUpload = function (old_initSWFUpload) { 21 return function (init_settings) { 22 var self = this; 23 if (typeof(old_initSWFUpload) === "function") { 24 SWFUpload.DocumentReady(function () { 25 old_initSWFUpload.call(self, init_settings); 26 }); 27 } 28 } 29 30 }(SWFUpload.prototype.initSWFUpload); 31 32 33 // The DocumentReady function adds the passed in function to 34 // the functions that will be executed when the document is ready/loaded 35 SWFUpload.DocumentReady = function (fn) { 36 // Add the function to the chain 37 SWFUpload.DocumentReady.InternalOnloadChain = function (previous_link_fn) { 38 return function () { 39 if (typeof(previous_link_fn) === "function") { 40 previous_link_fn(); 41 } 42 fn(); 43 }; 44 }(SWFUpload.DocumentReady.InternalOnloadChain); 45 }; 46 SWFUpload.DocumentReady.InternalOnloadChain = null; 47 SWFUpload.DocumentReady.Onload = function () { 48 // Execute the onload function chain 49 if (typeof(SWFUpload.DocumentReady.InternalOnloadChain) === "function") { 50 SWFUpload.DocumentReady.InternalOnloadChain(); 51 } 52 }; 53 SWFUpload.DocumentReady.SetupComplete = false; 54 55 56 /* ******************************************** 57 This portion of the code gets executed as soon it is loaded. 58 It binds the proper event for executing JavaScript is 59 early as possible. This is a per browser function and so 60 some browser sniffing is used. 61 62 This solution still has the "exposed" issue (See the Global Delegation section at http://peter.michaux.ca/article/553 ) 63 64 Base solution from http://dean.edwards.name/weblog/2006/06/again/ and http://dean.edwards.name/weblog/2005/09/busted/ 65 ******************************************** */ 66 if (!SWFUpload.DocumentReady.SetupComplete) { 67 // for Internet Explorer (using conditional comments) 68 /*@cc_on @*/ 69 /*@if (@_win32) 70 document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>"); 71 var script = document.getElementById("__ie_onload"); 72 script.onreadystatechange = function() { 73 if (this.readyState == "complete") { 74 SWFUpload.DocumentReady.Onload(); // call the onload handler 75 } 76 }; 77 SWFUpload.DocumentReady.SetupComplete = true; 78 /*@end @*/ 79 } 80 81 if (!SWFUpload.DocumentReady.SetupComplete && /WebKit/i.test(navigator.userAgent)) { // sniff 82 var _timer = setInterval(function() { 83 if (/loaded|complete/.test(document.readyState)) { 84 clearInterval(_timer); 85 SWFUpload.DocumentReady.Onload(); // call the onload handler 86 } 87 }, 10); 88 SWFUpload.DocumentReady.SetupComplete = true; 89 } 90 91 /* for Mozilla */ 92 if (!SWFUpload.DocumentReady.SetupComplete && document.addEventListener) { 93 document.addEventListener("DOMContentLoaded", SWFUpload.DocumentReady.Onload, false); 94 SWFUpload.DocumentReady.SetupComplete = true; 95 } 96 97 /* for other browsers */ 98 if (!SWFUpload.DocumentReady.SetupComplete) { 99 window.onload = SWFUpload.DocumentReady.Onload; 100 SWFUpload.DocumentReady.SetupComplete = true; 101 } 102 } 103 No newline at end of file -
wp-includes/js/swfupload/plugins/swfupload.queue.js
Property changes on: wp-includes/js/swfupload/plugins/swfupload.documentready.js ___________________________________________________________________ Name: svn:executable + *
1 /* 2 Queue Plug-in 3 4 Features: 5 cancelQueue method for cancelling the entire queue. 6 All queued files are uploaded when startUpload() is called. 7 If false is returned from uploadComplete then the queue upload is stopped. If false is not returned (strict comparison) then the queue upload is continued. 8 9 */ 10 11 var SWFUpload; 12 if (typeof(SWFUpload) === "function") { 13 SWFUpload.queue = {}; 14 15 SWFUpload.prototype.initSettings = function (old_initSettings) { 16 return function (init_settings) { 17 if (typeof(old_initSettings) === "function") { 18 old_initSettings.call(this, init_settings); 19 } 20 21 this.customSettings.queue_cancelled_flag = false; 22 23 this.addSetting("user_upload_complete_handler", init_settings.upload_complete_handler, SWFUpload.uploadComplete); 24 this.uploadComplete_handler = SWFUpload.queue.uploadComplete; 25 }; 26 }(SWFUpload.prototype.initSettings); 27 28 SWFUpload.prototype.cancelQueue = function () { 29 var stats = this.getStats(); 30 this.customSettings.queue_cancelled_flag = false; 31 32 if (stats.in_progress > 0) { 33 this.customSettings.queue_cancelled_flag = true; 34 } 35 36 while(stats.files_queued > 0) { 37 this.cancelUpload(); 38 stats = this.getStats(); 39 } 40 }; 41 42 SWFUpload.queue.uploadComplete = function (file) { 43 var user_upload_complete_handler = this.getSetting("user_upload_complete_handler"); 44 var continue_upload = true; 45 if (typeof(user_upload_complete_handler) === "function") { 46 continue_upload = (user_upload_complete_handler.call(this, file) === false) ? false : true; 47 } 48 49 if (continue_upload) { 50 var stats = this.getStats(); 51 if (stats.files_queued > 0 && this.customSettings.queue_cancelled_flag === false) { 52 this.startUpload(); 53 } else { 54 this.customSettings.queue_cancelled_flag = false; 55 } 56 } 57 }; 58 } 59 No newline at end of file -
wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js
Property changes on: wp-includes/js/swfupload/plugins/swfupload.queue.js ___________________________________________________________________ Name: svn:executable + * Property changes on: wp-includes/js/swfupload/plugins/swfupload.detectionkit.js ___________________________________________________________________ Name: svn:executable + *
1 /* 2 SWFUpload Graceful Degradation Plug-in 3 4 This plugin allows SWFUpload to display only if it is loaded successfully. Otherwise a default form is left displayed. 5 6 Usage: 7 8 To use this plugin create two HTML containers. Each should have an ID defined. One container should hold the SWFUpload UI. The other should hold the degraded UI. 9 10 The SWFUpload container should have its CSS "display" property set to "none". 11 12 If SWFUpload loads successfully the SWFUpload container will be displayed ("display" set to "block") and the 13 degraded container will be hidden ("display" set to "none"). 14 15 Use the settings "swfupload_element_id" and "degraded_element_id" to indicate your container IDs. The default values are "swfupload_container" and "degraded_container". 16 17 */ 18 19 var SWFUpload; 20 if (typeof(SWFUpload) === "function") { 21 SWFUpload.gracefulDegradation = {}; 22 SWFUpload.prototype.initSettings = function (old_initSettings) { 23 return function (init_settings) { 24 if (typeof(old_initSettings) === "function") { 25 old_initSettings.call(this, init_settings); 26 } 27 28 this.addSetting("swfupload_element_id", init_settings.swfupload_element_id, "swfupload_container"); 29 this.addSetting("degraded_element_id", init_settings.degraded_element_id, "degraded_container"); 30 this.addSetting("user_swfUploadLoaded_handler", init_settings.swfupload_loaded_handler, SWFUpload.swfUploadLoaded); 31 32 this.swfUploadLoaded_handler = SWFUpload.gracefulDegradation.swfUploadLoaded; 33 }; 34 }(SWFUpload.prototype.initSettings); 35 36 SWFUpload.gracefulDegradation.swfUploadLoaded = function () { 37 var swfupload_container_id, swfupload_container, degraded_container_id, degraded_container, user_swfUploadLoaded_handler; 38 try { 39 swfupload_element_id = this.getSetting("swfupload_element_id"); 40 degraded_element_id = this.getSetting("degraded_element_id"); 41 42 // Show the UI container 43 swfupload_container = document.getElementById(swfupload_element_id); 44 if (swfupload_container !== null) { 45 swfupload_container.style.display = "block"; 46 47 // Now take care of hiding the degraded UI 48 degraded_container = document.getElementById(degraded_element_id); 49 if (degraded_container !== null) { 50 degraded_container.style.display = "none"; 51 } 52 } 53 } catch (ex) { 54 this.debug(ex); 55 } 56 57 user_swfUploadLoaded_handler = this.getSetting("user_swfUploadLoaded_handler"); 58 if (typeof(user_swfUploadLoaded_handler) === "function") { 59 user_swfUploadLoaded_handler.apply(this); 60 } 61 }; 62 63 } -
wp-includes/js/swfupload/plugins/swfupload.cookies.js
Property changes on: wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js ___________________________________________________________________ Name: svn:executable + *
1 /* 2 Cookie Plug-in 3 4 This plug in automatically gets all the cookies for this site and adds them to the post_params. 5 Cookies are loaded only on initialization. The refreshCookies function can be called to update the post_params. 6 The cookies will override any other post params with the same name. 7 */ 8 9 var SWFUpload; 10 if (typeof(SWFUpload) === "function") { 11 SWFUpload.prototype.initSettings = function (old_initSettings) { 12 return function (init_settings) { 13 if (typeof(old_initSettings) === "function") { 14 old_initSettings.call(this, init_settings); 15 } 16 17 this.refreshCookies(false); // The false parameter must be sent since SWFUpload has not initialzed at this point 18 }; 19 }(SWFUpload.prototype.initSettings); 20 21 // refreshes the post_params and updates SWFUpload. The send_to_flash parameters is optional and defaults to True 22 SWFUpload.prototype.refreshCookies = function (send_to_flash) { 23 if (send_to_flash !== false) send_to_flash = true; 24 25 // Get the post_params object 26 var post_params = this.getSetting("post_params"); 27 28 // Get the cookies 29 var i, cookie_array = document.cookie.split(';'), ca_length = cookie_array.length, c, eq_index, name, value; 30 for(i = 0; i < ca_length; i++) { 31 c = cookie_array[i]; 32 33 // Left Trim spaces 34 while (c.charAt(0) == " ") { 35 c = c.substring(1, c.length); 36 } 37 eq_index = c.indexOf("="); 38 if (eq_index > 0) { 39 name = c.substring(0, eq_index); 40 value = c.substring(eq_index+1); 41 post_params[name] = value; 42 } 43 } 44 45 if (send_to_flash) { 46 this.setPostParams(post_params); 47 } 48 }; 49 50 } -
wp-includes/js/swfupload/handlers.js
Property changes on: wp-includes/js/swfupload/plugins/swfupload.cookies.js ___________________________________________________________________ Name: svn:executable + *
1 function fileDialogStart() { 2 jQuery("#media-upload-error").empty(); 3 } 4 5 // progress and success handlers for multimedia multi uploads 6 function fileQueuedMultimedia(fileObj) { 7 // Create a progress bar containing the filename 8 jQuery('#multimedia-items').append('<div id="multimedia-item-' + fileObj.id + '" class="multimedia-item"><span class="filename original">' + fileObj.name + '</span><div class="progress"><div class="bar"></div></div></div>'); 9 10 // Disable the submit button 11 jQuery('#insert-multimedia').attr('disabled', 'disabled'); 12 } 13 14 function uploadProgressMultimedia(fileObj, bytesDone, bytesTotal) { 15 // Lengthen the progress bar 16 jQuery('#multimedia-item-' + fileObj.id + ' .bar').width(620*bytesDone/bytesTotal); 17 } 18 19 function uploadSuccessMultimedia(fileObj, serverData) { 20 // if async-upload returned an error message, place it in the multimedia item div and return 21 if ( serverData.match('media-upload-error') ) { 22 jQuery('#multimedia-item-' + fileObj.id).html(serverData); 23 return; 24 } 25 26 // Move the progress bar to 100% 27 jQuery('#multimedia-item-' + fileObj.id + ' .bar').remove(); 28 29 // Append the HTML returned by the server -- thumbnail and form inputs 30 jQuery('#multimedia-item-' + fileObj.id).append(serverData); 31 32 // Clone the thumbnail as a "pinkynail" -- a tiny image to the left of the filename 33 jQuery('#multimedia-item-' + fileObj.id + ' .thumbnail').clone().attr('className', 'pinkynail').prependTo('#multimedia-item-' + fileObj.id); 34 35 // Replace the original filename with the new (unique) one assigned during upload 36 jQuery('#multimedia-item-' + fileObj.id + ' .filename.original').replaceWith(jQuery('#multimedia-item-' + fileObj.id + ' .filename.new')); 37 38 // Bind toggle function to a new mask over the progress bar area 39 jQuery('#multimedia-item-' + fileObj.id + ' .progress').clone().empty().addClass('clickmask').bind('click', function(){jQuery(this).siblings('.slidetoggle').slideToggle(150);jQuery(this).siblings('.toggle').toggle();}).appendTo('#multimedia-item-' + fileObj.id); 40 41 // Also bind toggle to the links 42 jQuery('#multimedia-item-' + fileObj.id + ' a.toggle').bind('click', function(){jQuery(this).siblings('.slidetoggle').slideToggle(150);jQuery(this).parent().eq(0).children('.toggle').toggle();jQuery(this).siblings('a.toggle').focus();return false;}); 43 44 // Bind AJAX to the new Delete button 45 jQuery('#multimedia-item-' + fileObj.id + ' a.delete').bind('click',function(){jQuery.ajax({url:'admin-ajax.php',type:'post',data:{id:this.id.replace(/del/,''),action:'delete-post',_ajax_nonce:this.href.replace(/^.*wpnonce=/,'')}});jQuery(this).parents(".multimedia-item").eq(0).slideToggle(300, function(){jQuery(this).remove();});return false;}); 46 } 47 48 function uploadCompleteMultimedia(fileObj) { 49 // If no more uploads queued, enable the submit button 50 if ( swfu.getStats().files_queued == 0 ) 51 jQuery('#insert-multimedia').attr('disabled', ''); 52 } 53 54 55 // progress and success handlers for single image upload 56 57 function uploadLoadedImage() { 58 jQuery('#image-alt').attr('disabled', true); 59 jQuery('#image-url').attr('disabled', true); 60 jQuery('#image-title').attr('disabled', true); 61 jQuery('#image-add').attr('disabled', true); 62 } 63 64 function fileQueuedImage(fileObj) { 65 jQuery('#flash-upload-ui').append('<div id="image-progress"><p class="filename">' + fileObj.name + '</p><div class="progress"><div class="bar"></div></div></div>'); 66 } 67 68 function uploadProgressImage(fileObj, bytesDone, bytesTotal) { 69 jQuery('#image-progress .bar').width(450*bytesDone/bytesTotal); 70 } 71 72 function uploadSuccessImage(fileObj, serverData) { 73 if ( serverData.match('media-upload-error') ) { 74 jQuery('#media-upload-error').replaceWith(serverData); 75 jQuery('#image-progress').replaceWith(''); 76 } 77 else { 78 jQuery('#media-upload-error').replaceWith(''); 79 jQuery('#flash-upload-ui').replaceWith(serverData); 80 } 81 } 82 83 // wp-specific error handlers 84 85 // generic message 86 function wpQueueError(message) { 87 jQuery('#media-upload-error').show().text(message); 88 } 89 90 // file-specific message 91 function wpFileError(fileObj, message) { 92 jQuery('#media-upload-error-' + fileObj.id).show().text(message); 93 } 94 95 function fileQueueError(fileObj, error_code, message) { 96 // Handle this error separately because we don't want to create a FileProgress element for it. 97 if ( error_code == SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED ) { 98 wpQueueError(swfuploadL10n.queue_limit_exceeded); 99 } 100 else if ( error_code == SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT ) { 101 wpQueueError(swfuploadL10n.file_exceeds_size_limit); 102 } 103 else if ( error_code == SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE ) { 104 wpQueueError(swfuploadL10n.zero_byte_file); 105 } 106 else if ( error_code == SWFUpload.QUEUE_ERROR.INVALID_FILETYPE ) { 107 wpQueueError(swfuploadL10n.invalid_filetype); 108 } 109 else { 110 wpQueueError(swfuploadL10n.default_error); 111 } 112 113 /* 114 switch(error_code) { 115 case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED: 116 117 alert("You have attempted to queue too many files.\n" + (message == 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file."))); 118 return; 119 break; 120 case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: 121 alert("The file you selected is too big."); 122 this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 123 return; 124 break; 125 case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: 126 alert("The file you selected is empty. Please select another file."); 127 this.debug("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 128 return; 129 break; 130 case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE: 131 alert("The file you choose is not an allowed file type."); 132 this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 133 return; 134 break; 135 default: 136 alert("An error occurred in the upload. Try again later."); 137 this.debug("Error Code: " + error_code + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 138 return; 139 break; 140 } 141 } catch (e) {} 142 */ 143 } 144 145 function fileQueued(fileObj) { 146 try { 147 var txtFileName = document.getElementById("txtFileName"); 148 txtFileName.value = fileObj.name; 149 } catch (e) { } 150 151 } 152 153 function fileDialogComplete(num_files_queued) { 154 try { 155 if (num_files_queued > 0) { 156 this.startUpload(); 157 } 158 } catch (ex) { 159 this.debug(ex); 160 } 161 } 162 163 function uploadProgress(fileObj, bytesLoaded, bytesTotal) { 164 165 try { 166 var percent = Math.ceil((bytesLoaded / bytesTotal) * 100) 167 168 fileObj.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file 169 var progress = new FileProgress(fileObj, this.customSettings.progress_target); 170 progress.SetProgress(percent); 171 progress.SetStatus("Uploading..."); 172 } catch (e) { } 173 } 174 175 function uploadSuccess(fileObj, server_data) { 176 try { 177 fileObj.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file 178 var progress = new FileProgress(fileObj, this.customSettings.progress_target); 179 progress.SetComplete(); 180 progress.SetStatus("Complete."); 181 progress.ToggleCancel(false); 182 183 if (server_data === " ") { 184 this.customSettings.upload_successful = false; 185 } else { 186 this.customSettings.upload_successful = true; 187 document.getElementById("hidFileID").value = server_data; 188 } 189 190 } catch (e) { } 191 } 192 193 function uploadComplete(fileObj) { 194 try { 195 if (this.customSettings.upload_successful) { 196 document.getElementById("btnBrowse").disabled = "true"; 197 uploadDone(); 198 } else { 199 fileObj.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file 200 var progress = new FileProgress(fileObj, this.customSettings.progress_target); 201 progress.SetError(); 202 progress.SetStatus("File rejected"); 203 progress.ToggleCancel(false); 204 205 var txtFileName = document.getElementById("txtFileName"); 206 txtFileName.value = ""; 207 //validateForm(); 208 209 alert("There was a problem with the upload.\nThe server did not accept it."); 210 } 211 } catch (e) { } 212 } 213 214 function uploadError(fileObj, error_code, message) { 215 216 // first the file specific error 217 if ( error_code == SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL ) { 218 wpFileError(fileObj, swfuploadL10n.missing_upload_url); 219 } 220 else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED ) { 221 wpFileError(fileObj, swfuploadL10n.upload_limit_exceeded); 222 } 223 else { 224 wpFileError(fileObj, swfuploadL10n.default_error); 225 } 226 227 /* 228 // Handle this error separately because we don't want to create a FileProgress element for it. 229 switch(error_code) { 230 case SWFUpload.UPLOAD_ERROR.MISSING_UPLOAD_URL: 231 alert("There was a configuration error. You will not be able to upload a resume at this time."); 232 jQuery('#media-upload-error-'+fileObj.id+',.media-upload-error').append 233 this.debug("Error Code: No backend file, File name: " + file.name + ", Message: " + message); 234 return; 235 break; 236 case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: 237 alert("You may only upload 1 file."); 238 this.debug("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 239 return; 240 break; 241 case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: 242 case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: 243 break; 244 default: 245 alert("An error occurred in the upload. Try again later."); 246 this.debug("Error Code: " + error_code + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 247 return; 248 break; 249 } 250 */ 251 252 // not sure if this is needed 253 fileObj.id = "singlefile"; // This makes it so FileProgress only makes a single UI element, instead of one for each file 254 var progress = new FileProgress(fileObj, this.customSettings.progress_target); 255 progress.SetError(); 256 progress.ToggleCancel(false); 257 258 // now the general upload status 259 if ( error_code == SWFUpload.UPLOAD_ERROR.HTTP_ERROR ) { 260 wpQueueError(swfuploadL10n.http_error); 261 } 262 else if ( error_code == SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED ) { 263 wpQueueError(swfuploadL10n.upload_failed); 264 } 265 else if ( error_code == SWFUpload.UPLOAD_ERROR.IO_ERROR ) { 266 wpQueueError(swfuploadL10n.io_error); 267 } 268 else if ( error_code == SWFUpload.UPLOAD_ERROR.SECURITY_ERROR ) { 269 wpQueueError(swfuploadL10n.security_error); 270 } 271 else if ( error_code == SWFUpload.UPLOAD_ERROR.FILE_CANCELLED ) { 272 wpQueueError(swfuploadL10n.security_error); 273 } 274 275 276 277 /* 278 switch(error_code) { 279 case SWFUpload.UPLOAD_ERROR.HTTP_ERROR: 280 progress.SetStatus("Upload Error"); 281 this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + message); 282 break; 283 case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED: 284 progress.SetStatus("Upload Failed."); 285 this.debug("Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); 286 break; 287 case SWFUpload.UPLOAD_ERROR.IO_ERROR: 288 progress.SetStatus("Server (IO) Error"); 289 this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + message); 290 break; 291 case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR: 292 progress.SetStatus("Security Error"); 293 this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + message); 294 break; 295 case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: 296 progress.SetStatus("Upload Cancelled"); 297 this.debug("Error Code: Upload Cancelled, File name: " + file.name + ", Message: " + message); 298 break; 299 case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: 300 progress.SetStatus("Upload Stopped"); 301 this.debug("Error Code: Upload Stopped, File name: " + file.name + ", Message: " + message); 302 break; 303 } 304 } catch (e) {} 305 */ 306 307 } 308 309 310 /* ******************************************************** 311 * Utility for displaying the file upload information 312 * This is not part of SWFUpload, just part of the demo 313 * ******************************************************** */ 314 function FileProgress(fileObj, target_id) { 315 this.file_progress_id = fileObj.id; 316 317 this.fileProgressElement = document.getElementById(this.file_progress_id); 318 if (!this.fileProgressElement) { 319 this.fileProgressElement = document.createElement("div"); 320 this.fileProgressElement.className = "progressContainer"; 321 this.fileProgressElement.id = this.file_progress_id; 322 323 var progressCancel = document.createElement("a"); 324 progressCancel.className = "progressCancel"; 325 progressCancel.href = "#"; 326 progressCancel.style.visibility = "hidden"; 327 progressCancel.appendChild(document.createTextNode(" ")); 328 329 var progressText = document.createElement("div"); 330 progressText.className = "progressName"; 331 progressText.appendChild(document.createTextNode(fileObj.name)); 332 333 var progressBar = document.createElement("div"); 334 progressBar.className = "progressBarInProgress"; 335 336 var progressStatus = document.createElement("div"); 337 progressStatus.className = "progressBarStatus"; 338 progressStatus.innerHTML = " "; 339 340 this.fileProgressElement.appendChild(progressCancel); 341 this.fileProgressElement.appendChild(progressText); 342 this.fileProgressElement.appendChild(progressStatus); 343 this.fileProgressElement.appendChild(progressBar); 344 345 document.getElementById(target_id).appendChild(this.fileProgressElement); 346 347 } 348 349 } 350 FileProgress.prototype.SetStart = function() { 351 this.fileProgressElement.className = "progressContainer"; 352 this.fileProgressElement.childNodes[3].className = "progressBarInProgress"; 353 this.fileProgressElement.childNodes[3].style.width = ""; 354 } 355 356 FileProgress.prototype.SetProgress = function(percentage) { 357 this.fileProgressElement.className = "progressContainer green"; 358 this.fileProgressElement.childNodes[3].className = "progressBarInProgress"; 359 this.fileProgressElement.childNodes[3].style.width = percentage + "%"; 360 } 361 FileProgress.prototype.SetComplete = function() { 362 this.fileProgressElement.className = "progressContainer blue"; 363 this.fileProgressElement.childNodes[3].className = "progressBarComplete"; 364 this.fileProgressElement.childNodes[3].style.width = ""; 365 366 367 } 368 FileProgress.prototype.SetError = function() { 369 this.fileProgressElement.className = "progressContainer red"; 370 this.fileProgressElement.childNodes[3].className = "progressBarError"; 371 this.fileProgressElement.childNodes[3].style.width = ""; 372 } 373 FileProgress.prototype.SetCancelled = function() { 374 this.fileProgressElement.className = "progressContainer"; 375 this.fileProgressElement.childNodes[3].className = "progressBarError"; 376 this.fileProgressElement.childNodes[3].style.width = ""; 377 } 378 FileProgress.prototype.SetStatus = function(status) { 379 this.fileProgressElement.childNodes[2].innerHTML = status; 380 } 381 382 FileProgress.prototype.ToggleCancel = function(show, upload_obj) { 383 this.fileProgressElement.childNodes[0].style.visibility = show ? "visible" : "hidden"; 384 if (upload_obj) { 385 var file_id = this.file_progress_id; 386 this.fileProgressElement.childNodes[0].onclick = function() { upload_obj.cancelUpload(file_id); return false; }; 387 } 388 } 389 No newline at end of file -
wp-includes/script-loader.php
Property changes on: wp-includes/js/swfupload/handlers.js ___________________________________________________________________ Name: svn:executable + *
84 84 $this->add( 'suggest', '/wp-includes/js/jquery/suggest.js', array('dimensions'), '1.1'); 85 85 $this->add( 'schedule', '/wp-includes/js/jquery/jquery.schedule.js', array('jquery'), '20'); 86 86 $this->add( 'thickbox', '/wp-includes/js/thickbox/thickbox.js', array('jquery'), '3.1'); 87 $this->add( 'swfupload', '/wp-includes/js/swfupload/swfupload.js', false, '2.0.2'); 88 $this->add( 'swfupload-degrade', '/wp-includes/js/swfupload/plugins/swfupload.graceful_degradation.js', array('swfupload'), '2.0.2'); 89 $this->add( 'swfupload-queue', '/wp-includes/js/swfupload/plugins/swfupload.queue.js', array('swfupload'), '2.0.2'); 90 $this->add( 'swfupload-handlers', '/wp-includes/js/swfupload/handlers.js', array('swfupload'), '2.0.2'); 91 // these error messages came from the sample swfupload js, they might need changing. 92 $this->localize( 'swfupload-handlers', 'swfuploadL10n', array( 93 'queue_limit_exceeded' => 'You have attempted to queue too many files.', 94 'file_exceeds_size_limit' => 'The file you have selected is too big.', 95 'zero_byte_file' => 'The file you selected is empty. Please select another file.', 96 'invalid_filetype' => 'The file you choose is not an allowed file type.', 97 'default_error' => 'An error occurred in the upload. Please try again later.', 98 'missing_upload_url' => 'There was a configuration error. Please contact the server administrator.', 99 'upload_limit_exceeded' => 'You may only upload 1 file.', 100 'http_error' => 'HTTP error.', 101 'upload_failed' => 'Upload failed.', 102 'io_error' => 'IO error.', 103 'security_error' => 'Security error.', 104 'file_cancelled' => 'File cancelled.', 105 'upload_stopped' => 'Upload stopped.', 106 107 ) ); 87 108 88 109 $this->add( 'jquery-ui-tabs', '/wp-includes/js/jquery/ui.tabs.js', array('jquery'), '3' ); 89 110 -
wp-settings.php
256 256 require (ABSPATH . WPINC . '/taxonomy.php'); 257 257 require (ABSPATH . WPINC . '/update.php'); 258 258 require (ABSPATH . WPINC . '/canonical.php'); 259 require (ABSPATH . WPINC . '/macros.php'); 259 260 260 261 if (strpos($_SERVER['PHP_SELF'], 'install.php') === false) { 261 262 // Used to guarantee unique hash cookies -
wp-admin/includes/template.php
745 745 return $size . $units[$power]; 746 746 } 747 747 748 function wp_ import_upload_form( $action) {748 function wp_max_upload_size() { 749 749 $u_bytes = wp_convert_hr_to_bytes( ini_get( 'upload_max_filesize' ) ); 750 750 $p_bytes = wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ); 751 $bytes = apply_filters( 'import_upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); 751 $bytes = apply_filters( 'upload_size_limit', min($u_bytes, $p_bytes), $u_bytes, $p_bytes ); 752 return $bytes; 753 } 754 755 function wp_import_upload_form( $action ) { 756 $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); 752 757 $size = wp_convert_bytes_to_hr( $bytes ); 753 758 ?> 754 759 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo attribute_escape($action) ?>"> -
wp-admin/includes/media.php
14 14 $image_url = attribute_escape( @$values['image-url'] ); 15 15 $image_title = attribute_escape( @$values['image-title'] ); 16 16 $image_align = @$values['image-url']; 17 17 $post_id = $_GET['post_id']; 18 18 19 ?> 19 20 <div id="media-upload-header"> 20 21 <h3>Add Image</h3> … … 24 25 <li class="last"><?php _e('Flickr'); ?></li> 25 26 </ul> 26 27 </div> 27 <?php if ($error) { ?> 28 <div id="media-upload-error"> 29 <?php echo $error->get_error_message(); ?> 30 </div> 31 <?php } ?> 28 <div id="media-upload-error"> 29 <?php if ($error) { 30 echo $error->get_error_message(); 31 } ?> 32 </div> 33 <script type="text/javascript"> 34 <!-- 35 36 jQuery(document).ready(function(){ 37 var swfu = new SWFUpload({ 38 upload_url : "<?php echo get_option('siteurl').'/wp-admin/async-upload.php'; ?>", 39 flash_url : "<?php echo get_option('siteurl').'/wp-includes/js/swfupload/swfupload_f9.swf'; ?>", 40 file_post_name: "async-upload", 41 swfupload_element_id : "flash-upload-ui", // id of the element displayed when swfupload is available 42 degraded_element_id : "html-upload-ui", // when swfupload is unavailable 43 //file_types : "*.jpg;*.gif;*.png", 44 file_size_limit : "<?php echo wp_max_upload_size(); ?> B", 45 post_params : { 46 "post_id" : "<?php echo $post_id; ?>", 47 "auth_cookie" : "<?php echo $_COOKIE[AUTH_COOKIE]; ?>", 48 "type" : "image", 49 }, 50 swfupload_loaded_handler : uploadLoadedImage, 51 upload_progress_handler : uploadProgressImage, 52 upload_success_handler : uploadSuccessImage, 53 upload_error_handler: uploadError, 54 file_queued_handler : fileQueuedImage, 55 file_queue_error_handler : fileQueueError, 56 file_dialog_complete_handler : fileDialogComplete, 57 58 custom_settings : { 59 progressTarget : "flash-upload-ui", 60 cancelButtonId : "btnCancel2" 61 }, 62 63 debug: false, 64 65 }); 66 67 document.getElementById("flash-browse-button").onclick = function () { swfu.selectFile(); }; 68 }); 69 //--> 70 </script> 32 71 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($action_url); ?>" id="image-upload" class="media-upload-form"> 33 <p><label for="image-file"><?php _e('Choose image'); ?></label> 72 <p id="flash-upload-ui"> 73 <label for="flash-browse-button"><?php _e('Choose image'); ?></label> 74 <input id="flash-browse-button" type="button" value="<?php _e('Browse'); ?>" /> 75 <label for="image-file" class="form-help"><?php _e('Only PNG, JPG, GIF'); ?></label></p> 76 <p id="html-upload-ui"><label for="image-file"><?php _e('Choose image'); ?></label> 34 77 <input type="file" name="image-file" id="image-file" /> 35 78 <label for="image-file" class="form-help"><?php _e('Only PNG, JPG, GIF'); ?></label></p> 36 79 <p><label for="image-alt" class="required"><?php _e('<alt> (required)'); ?></label> … … 57 100 <button name="image-add" id="image-add" class="button-ok" value="1"><?php _e('Add Image'); ?></button> 58 101 <a href="#" onclick="return top.tb_remove();" id="image-cancel" class="button-cancel"><?php _e('Cancel'); ?></a> 59 102 </p> 60 <input type="hidden" name="p arent_post_id" value="<?php echo attribute_escape('parent_post_id'); ?>" />103 <input type="hidden" name="post_id" value="<?php echo attribute_escape($post_id); ?>" /> 61 104 <?php wp_nonce_field( 'inlineuploading' ); ?> 62 105 </form> 63 106 <?php … … 69 112 return new wp_error( 'upload_not_allowed', __('You are not allowed to upload files.') ); 70 113 } 71 114 72 check_admin_referer('inlineuploading');73 74 115 if ( empty($_POST['image-add']) ) { 75 116 // no button click, we're just displaying the form 76 117 wp_iframe( 'image_upload_form', get_option('siteurl') . '/wp-admin/media-upload.php?type=image' ); 77 118 } 78 119 else { 79 120 // Add Image button was clicked 80 $id = image_upload_post(); 121 check_admin_referer('inlineuploading'); 122 123 // if the async flash uploader was used, the attachment has already been inserted and its ID is passed in post. 124 // otherwise this is a regular form post and we still have to handle the upload and create the attachment. 125 if ( !empty($_POST['attachment_id']) ) { 126 $id = intval($_POST['attachment_id']); 127 // store the title and alt into the attachment post 128 wp_update_post(array( 129 'ID' => $id, 130 'post_title' => $_POST['image-title'], 131 'post_content' => $_POST['image-alt'], 132 )); 133 } 134 else { 135 $id = image_upload_post(); 136 } 81 137 82 138 // if the input was invalid, redisplay the form with its current values 83 139 if ( is_wp_error($id) ) … … 88 144 } 89 145 } 90 146 147 // this returns html to include in the single image upload form when the async flash upload has finished 148 // i.e. show a thumb of the image, and include the attachment id as a hidden input 149 function async_image_callback($id) { 150 $thumb_url = wp_get_attachment_thumb_url($id); 151 if ( empty($thumb_url) ) 152 $thumb_url = wp_mime_type_icon($id); 153 154 if ($thumb_url) { 155 $out = '<p><input type="hidden" name="attachment_id" id="attachment_id" value="'.intval($id).'" />' 156 . '<img src="'.wp_get_attachment_thumb_url($id).'" class="pinkynail" /> ' 157 . basename(wp_get_attachment_url($id)).'</p>'; 158 } 159 else { 160 $out = '<p><input type="hidden" name="attachment_id" id="attachment_id" value="'.intval($id).'" />' 161 . basename(wp_get_attachment_url($id)).'</p>'; 162 } 163 164 $post = get_post($id); 165 $title = addslashes($post->post_title); 166 $alt = addslashes($post->post_content); 167 168 // populate the input fields with post data (which in turn comes from exif/iptc) 169 $out .= <<<EOF 170 <script type="text/javascript"> 171 <!-- 172 jQuery('#image-alt').val('{$alt}').attr('disabled', false); 173 jQuery('#image-title').val('{$title}').attr('disabled', false); 174 jQuery('#image-url').attr('disabled', false); 175 jQuery('#image-add').attr('disabled', false); 176 --> 177 </script> 178 EOF; 179 180 return $out; 181 } 182 183 add_filter('async_upload_image', 'async_image_callback'); 184 185 91 186 function image_send_to_editor($id, $alt, $title, $align, $url='') { 92 187 93 188 $img_src = wp_get_attachment_url($id); … … 97 192 if ( isset($meta['width'], $meta['height']) ) 98 193 $hwstring = ' width="'.intval($meta['width']).'" height="'.intval($meta['height']).'"'; 99 194 100 $html = '<img src="'.attribute_escape($img_src).'" alt="'.attribute_escape($alt).'" title="'.attribute_escape($title).'"'.$hwstring.' class="align-'.attribute_escape($align).'" />';195 $html = '<img src="'.attribute_escape($img_src).'" rel="attachment wp-att-'.attribute_escape($id).'" alt="'.attribute_escape($alt).'" title="'.attribute_escape($title).'"'.$hwstring.' class="align-'.attribute_escape($align).'" />'; 101 196 102 197 if ( $url ) 103 198 $html = '<a href="'.attribute_escape($url).'">'.$html.'</a>'; … … 152 247 if ( !is_wp_error($id) ) 153 248 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); 154 249 250 return $id; 251 } 252 253 // this handles the file upload POST itself, creating the attachment post 254 function media_handle_upload($file_id, $post_id, $post_data = array()) { 255 $overrides = array('test_form'=>false); 256 $file = wp_handle_upload($_FILES[$file_id], $overrides); 257 258 if ( isset($file['error']) ) 259 return new wp_error( 'upload_error', $file['error'] ); 260 261 $url = $file['url']; 262 $type = $file['type']; 263 $file = $file['file']; 264 $title = preg_replace('/\.[^.]+$/', '', basename($file)); 265 $content = ''; 266 267 // use image exif/iptc data for title and caption defaults if possible 268 if ( $image_meta = @wp_read_image_metadata($file) ) { 269 if ( trim($image_meta['title']) ) 270 $title = $image_meta['title']; 271 if ( trim($image_meta['caption']) ) 272 $content = $image_meta['caption']; 273 } 274 275 // Construct the attachment array 276 $attachment = array_merge( array( 277 'post_mime_type' => $type, 278 'guid' => $url, 279 'post_parent' => $post_id, 280 'post_title' => $title, 281 'post_content' => $content, 282 ), $post_data ); 283 284 // Save the data 285 $id = wp_insert_attachment($attachment, $file, $post_parent); 286 if ( !is_wp_error($id) ) { 287 wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); 288 } 289 155 290 return $id; 156 291 157 wp_redirect( get_option('siteurl') . "/wp-admin/upload.php?style=$style&tab=browse&action=view&ID=$id&post_id=$post_id");158 159 292 } 160 293 294 161 295 // wrap iframe content (produced by $content_func) in a doctype, html head/body etc 162 296 // any additional function args will be passed to content_func 163 297 function wp_iframe($content_func /* ... */) { … … 194 328 function media_buttons() { // just a placeholder for now 195 329 global $post_ID, $temp_ID; 196 330 $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID); 197 $uploading_iframe_src = wp_nonce_url("media-upload.php?type=image&&post_id=$uploading_iframe_ID", 'inlineuploading'); 198 $uploading_iframe_src = apply_filters('uploading_iframe_src', $uploading_iframe_src); 331 $image_upload_iframe_src = wp_nonce_url("media-upload.php?type=image&post_id=$uploading_iframe_ID", 'inlineuploading'); 332 $image_upload_iframe_src = apply_filters('image_upload_iframe_src', $image_upload_iframe_src); 333 $multimedia_upload_iframe_src = wp_nonce_url("media-upload.php?type=multimedia&post_id=$uploading_iframe_ID", 'inlineuploading'); 334 $multimedia_upload_iframe_src = apply_filters('multimedia_upload_iframe_src', $multimedia_upload_iframe_src); 199 335 $out = <<<EOF 200 <a href="{$uploading_iframe_src}&TB_iframe=true&height=500&width=460" class="thickbox"> 336 <a href="{$multimedia_upload_iframe_src}&TB_iframe=true&height=500&width=640" class="thickbox">Multimedia</a> 337 <a href="{$image_upload_iframe_src}&TB_iframe=true&height=500&width=460" class="thickbox"> 201 338 <img src="./images/media-buttons.gif" alt="" /> 202 339 </a> 203 340 EOF; … … 225 362 wp_admin_css('css/media'); 226 363 } 227 364 365 add_action('media_upload_multimedia', 'multimedia_upload_handler'); 228 366 add_action('media_upload_image', 'image_upload_handler'); 229 367 add_action('admin_head_image_upload_form', 'media_admin_css'); 230 368 369 function multimedia_upload_handler() { 370 if ( !current_user_can('upload_files') ) { 371 return new wp_error( 'upload_not_allowed', __('You are not allowed to upload files.') ); 372 } 373 374 if ( empty($_POST) ) { 375 // no button click, we're just displaying the form 376 wp_iframe( 'multimedia_upload_form' ); 377 } elseif ( empty($_POST['upload-button']) ) { 378 // Insert multimedia button was clicked 379 check_admin_referer('multimedia-form'); 380 381 if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) { 382 $post = $_post = get_post($attachment_id, ARRAY_A); 383 $post['post_content'] = $attachment['post_content']; 384 $post['post_title'] = $attachment['post_title']; 385 if ( $post != $_post ) 386 wp_update_post($post); 387 388 if ( $taxonomies = get_object_taxonomies('attachment') ) foreach ( $taxonomies as $t ) 389 if ( isset($attachment[$t]) ) 390 wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false); 391 } 392 393 media_send_to_editor('[thumbs]'); 394 } else { 395 // Upload File button was clicked 396 397 $id = media_handle_upload('async-upload', $_REQUEST['post_id']); 398 399 wp_iframe( 'multimedia_upload_form' ); 400 } 401 } 402 403 function get_multimedia_items( $post_id ) { 404 $attachments = get_children("post_parent=$post_id&post_type=attachment&orderby=\"menu_order ASC, ID ASC\""); 405 406 if ( empty($attachments) ) 407 return ''; 408 409 foreach ( $attachments as $id => $attachment ) { 410 $output .= "\n<div id='multimedia-item-$id' class='multimedia-item preloaded'><div id='media-upload-error-$id'></div><span class='filename'></span><div class='progress'><div class='bar'></div></div>"; 411 $output .= get_multimedia_item($id); 412 $output .= " <div class='progress clickmask'></div>\n</div>"; 413 } 414 415 return $output; 416 } 417 418 function get_multimedia_item( $attachment_id ) { 419 $thumb_url = wp_get_attachment_thumb_url( $attachment_id ); 420 if ( empty($thumb_url) ) 421 $thumb_url = wp_mime_type_icon( $attachment_id ); 422 423 $title_label = __('Title'); 424 $description_label = __('Description'); 425 $tags_label = __('Tags'); 426 427 $toggle_on = __('Describe »'); 428 $toggle_off = __('Describe «'); 429 430 $post = get_post($attachment_id); 431 432 $filename = basename($post->guid); 433 $title = attribute_escape($post->post_title); 434 $description = attribute_escape($post->post_content); 435 if ( $_tags = get_the_tags($attachment_id) ) { 436 foreach ( $_tags as $tag ) 437 $tags[] = $tag->name; 438 $tags = attribute_escape(join(', ', $tags)); 439 } 440 441 $delete_href = wp_nonce_url("post.php?action=delete-post&post=$attachment_id", 'delete-post_' . $attachment_id); 442 $delete = __('Delete'); 443 444 $item = " 445 <a class='toggle describe-toggle-on' href='#'>$toggle_on</a> 446 <a class='toggle describe-toggle-off' href='#'>$toggle_off</a> 447 <span class='filename new'>$filename</span> 448 <div class='slidetoggle describe'> 449 <img class='thumbnail' src='$thumb_url' alt='' /> 450 <fieldset> 451 <p><label for='attachments[$attachment_id][post_title]'>$title_label</label><input type='text' id='attachments[$attachment_id][post_title]' name='attachments[$attachment_id][post_title]' value='$title' /></p> 452 <p><label for='attachments[$attachment_id][post_content]'>$description_label</label><input type='text' id='attachments[$attachment_id][post_content]' name='attachments[$attachment_id][post_content]' value='$description' /></p> 453 "; 454 455 if ( $taxonomies = get_object_taxonomies('attachment') ) foreach ( $taxonomies as $t ) { 456 $tax = get_taxonomy($t); 457 $t_title = !empty($tax->title) ? $tax->title : $t; 458 if ( false === $terms = get_object_term_cache( $attachment_id, $t ) ) 459 $_terms = wp_get_object_terms($attachment_id, $t); 460 if ( $_terms ) { 461 foreach ( $_terms as $term ) 462 $terms[] = $term->name; 463 $terms = join(', ', $terms); 464 } else 465 $terms = ''; 466 $item .= "<p><label for='attachments[$attachment_id][$t]'>$t_title</label><input type='text' id='attachments[$attachment_id][$t]' name='attachments[$attachment_id][$t]' value='$terms' /></p>\n"; 467 } 468 469 $item .= " 470 </fieldset> 471 <p><a id='del$attachment_id' class='delete' href='$delete_href'>$delete</a></p> 472 </div> 473 "; 474 475 return $item; 476 } 477 478 function multimedia_upload_form( $error = null ) { 479 $flash_action_url = get_option('siteurl') . '/wp-admin/async-upload.php?type=multimedia'; 480 $form_action_url = get_option('siteurl') . '/wp-admin/media-upload.php?type=multimedia'; 481 482 $post_id = intval($_REQUEST['post_id']); 483 484 ?> 485 <div id="media-upload-header"> 486 <h3>Add Images</h3> 487 </div> 488 <div id="media-upload-error"> 489 <?php if ($error) { ?> 490 <?php echo $error->get_error_message(); ?> 491 <?php } ?> 492 </div> 493 <script type="text/javascript"> 494 <!-- 495 jQuery(function($){ 496 swfu = new SWFUpload({ 497 upload_url : "<?php echo attribute_escape( $flash_action_url ); ?>", 498 flash_url : "<?php echo get_option('siteurl').'/wp-includes/js/swfupload/swfupload_f9.swf'; ?>", 499 file_post_name: "async-upload", 500 file_types: "*.*", 501 post_params : { 502 "post_id" : "<?php echo $post_id; ?>", 503 "auth_cookie" : "<?php echo $_COOKIE[AUTH_COOKIE]; ?>", 504 "type" : "multimedia" 505 }, 506 swfupload_element_id : "flash-upload-ui", // id of the element displayed when swfupload is available 507 degraded_element_id : "html-upload-ui", // when swfupload is unavailable 508 //upload_start_handler : uploadStart, 509 upload_progress_handler : uploadProgressMultimedia, 510 //upload_error_handler : uploadError, 511 upload_success_handler : uploadSuccessMultimedia, 512 upload_complete_handler : uploadCompleteMultimedia, 513 file_dialog_start_handler : fileDialogStart, 514 file_queued_handler : fileQueuedMultimedia, 515 file_queue_error_handler : fileQueueError, 516 file_dialog_complete_handler : fileDialogComplete, 517 518 debug: false, 519 }); 520 $("#flash-browse-button").bind( "click", function(){swfu.selectFiles();}); 521 $("#insert-multimedia").bind( "click", function(){jQuery(this).parents('form').get(0).submit();}); 522 $(".multimedia-item.preloaded").each(function(){uploadSuccessMultimedia({id:this.id.replace(/[^0-9]/g, '')},'');jQuery('#insert-multimedia').attr('disabled', '');}); 523 $("a.delete").bind('click',function(){$.ajax({url:'admin-ajax.php',type:'post',data:{id:this.id.replace(/del/,''),action:'delete-post',_ajax_nonce:this.href.replace(/^.*wpnonce=/,'')}});$(this).parents(".multimedia-item").eq(0).slideToggle(300, function(){$(this).remove();});return false;}); 524 }); 525 //--> 526 </script> 527 <p id="flash-upload-ui" style="display:none"> 528 <input id="flash-browse-button" type="button" value="<?php _e('Choose Files'); ?>" /> 529 <label for="image-file" class="form-help"><?php _e('Only PNG, JPG, GIF'); ?></label> 530 </p> 531 532 <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form"> 533 534 <div id="html-upload-ui"> 535 <p><label for="async-upload"><?php _e('Choose image'); ?></label> 536 <input type="file" name="async-upload" id="async-upload" /> 537 <label for="image-file" class="form-help"><?php _e('Only PNG, JPG, GIF'); ?></label> 538 </p> 539 <p> 540 <button id="upload-button" name="upload-button" value="1" class="button-ok"><?php _e('Add Image'); ?></button> 541 <a href="#" onclick="return top.tb_remove();" id="image-cancel" class="button-cancel"><?php _e('Cancel'); ?></a> 542 </p> 543 <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" /> 544 <br style="clear:both" /> 545 </div> 546 547 548 549 <div id="multimedia-items"> 550 551 <?php echo get_multimedia_items($post_id); ?> 552 553 </div> 554 555 <p class="submit"> 556 <a href="#" onclick="return top.tb_remove();" id="image-cancel" class="button-cancel"><?php _e('Cancel'); ?></a> 557 <input type="button" class="submit" id="insert-multimedia" value="<?php _e('Insert thumbs into post'); ?>" disabled="disabled" /> 558 </p> 559 560 <?php wp_nonce_field('multimedia-form'); ?> 561 562 </form> 563 564 <?php 565 } 566 567 add_action('admin_head_multimedia_upload_form', 'media_admin_css'); 568 add_filter('async_upload_multimedia', 'get_multimedia_item'); 569 add_filter('media_upload_multimedia', 'multimedia_upload_handler'); 570 571 // Any 'attachment' taxonomy will be included in the description input form for the multi uploader 572 // Example: 573 //register_taxonomy('attachment_people', 'attachment', array('title' => 'People')); 574 231 575 ?> 576 No newline at end of file -
wp-admin/includes/upgrade.php
43 43 44 44 $user = new WP_User($user_id); 45 45 $user->set_role('administrator'); 46 $user->set_role('owner'); 46 47 47 48 wp_install_defaults($user_id); 48 49 … … 197 198 198 199 if ( $wp_current_db_version < 6124 ) 199 200 upgrade_230_old_tables(); 201 202 if ( $wp_current_db_version < 6591 ) 203 upgrade_owner(); 200 204 201 205 maybe_disable_automattic_widgets(); 202 206 … … 709 713 $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat'); 710 714 } 711 715 716 function upgrade_owner() { 717 populate_roles_owner(); 718 populate_owner(); 719 } 720 712 721 function upgrade_old_slugs() { 713 722 // upgrade people who were using the Redirect Old Slugs plugin 714 723 global $wpdb; -
wp-admin/async-upload.php
1 <?php 2 3 /* This accepts file uploads from swfupload or other asynchronous upload methods. 4 5 */ 6 7 if ( defined('ABSPATH') ) 8 require_once( ABSPATH . 'wp-config.php'); 9 else 10 require_once('../wp-config.php'); 11 12 // Flash often fails to send cookies with the POST or upload, so we need to pass it in GET or POST instead 13 if ( empty($_COOKIE[AUTH_COOKIE]) && !empty($_REQUEST['auth_cookie']) ) 14 $_COOKIE[AUTH_COOKIE] = $_REQUEST['auth_cookie']; 15 unset($current_user); 16 require_once('admin.php'); 17 18 header('Content-Type: text/plain'); 19 $id = media_handle_upload('async-upload', $_REQUEST['post_id']); 20 if (is_wp_error($id)) { 21 echo '<div id="media-upload-error">'.wp_specialchars($id->get_error_message()).'</div>'; 22 exit; 23 } 24 25 $type = $_REQUEST['type']; 26 echo apply_filters("async_upload_{$type}", $id); 27 28 ?> 29 No newline at end of file -
wp-admin/media-upload.php
1 1 <?php 2 2 require_once('admin.php'); 3 wp_enqueue_script('swfupload'); 4 wp_enqueue_script('swfupload-degrade'); 5 wp_enqueue_script('swfupload-queue'); 6 wp_enqueue_script('swfupload-handlers'); 3 7 4 8 @header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset')); 5 9 -
wp-admin/css/media.css
41 41 display:block; 42 42 font-weight: bold; 43 43 margin-bottom: 0.5em; 44 margin: 0 0 0.5em 0; 44 45 } 45 46 46 47 .media-upload-form label.form-help { … … 58 59 } 59 60 60 61 .media-upload-form fieldset { 62 width: 100%; 61 63 border: none; 62 64 text-align: justify; 63 margin-bottom: 1em; 65 margin: 0 0 1em 0; 66 padding: 0; 64 67 } 65 68 66 69 .media-upload-form button.button-ok { … … 83 86 /* specific to the image upload form */ 84 87 .media-upload-form fieldset#image-align label { 85 88 display: inline; 86 padding: 0 28px; 89 padding: 0 0 0 28px; 90 margin: 0 0; 87 91 } 88 92 89 93 #image-align-none-label { … … 100 104 101 105 #image-align-right-label { 102 106 background: url(../images/align-right.png) no-repeat center left; 107 } 108 109 .pinkynail { 110 max-width: 40px; 111 max-height: 40px; 112 } 113 114 #multimedia-items { 115 border: 1px solid #c0c0c0; 116 border-bottom: none; 117 width: 623px; 118 } 119 .multimedia-item { 120 border-bottom: 1px solid #d0d0d0; 121 width: 623px; 122 position: relative; 123 } 124 span.filename { 125 position: absolute; 126 left: 46px; 127 top: 0px; 128 line-height: 36px; 129 z-index: 2; 130 } 131 .progress { 132 width: 623px; 133 height: 36px; 134 } 135 .bar { 136 width: 0px; 137 height: 36px; 138 background-color: #e8e8e8; 139 border-right: 3px solid #99d; 140 } 141 .multimedia-item .thumbnail { 142 143 } 144 .multimedia-item .pinkynail { 145 position: absolute; 146 top: 3px; 147 left: 3px; 148 max-width: 40px; 149 max-height: 40px; 150 } 151 .describe { 152 display: none; 153 border-top: 1px solid #d0d0d0; 154 padding: 5px; 155 } 156 .describe fieldset { 157 width: 470px; 158 float: right; 159 } 160 .describe img { 161 float: left; 162 } 163 .describe input[type="text"], .describe textarea { 164 width: 450px; 165 } 166 .describe label { 167 padding-right: 1em; 168 } 169 170 a.delete { 171 clear: both; 172 } 173 .describe-toggle-on, .describe-toggle-off { 174 line-height: 36px; 175 z-index: 2; 176 position: absolute; 177 top: 0px; 178 right: 20px; 179 } 180 .describe-toggle-off { 181 display: none; 182 } 183 .clickmask { 184 background: transparent; 185 position: absolute; 186 top: 0px; 187 left: 0px; 188 cursor: pointer; 189 border: none; 190 z-index: 10; 103 191 } 192 No newline at end of file