[ Index ] |
|
Code source de WordPress 2.1.2 |
1 <?php require_once ('admin.php'); cache_javascript_headers(); ?> 2 addLoadEvent( function() { 3 theFileList = { 4 currentImage: {ID: 0}, 5 nonce: '', 6 tab: '', 7 postID: 0, 8 9 initializeVars: function() { 10 this.urlData = document.location.href.split('?'); 11 this.params = this.urlData[1].toQueryParams(); 12 this.postID = this.params['post_id']; 13 this.tab = this.params['tab']; 14 this.style = this.params['style']; 15 this.ID = this.params['ID']; 16 if ( !this.style ) 17 this.style = 'default'; 18 var nonceEl = $('nonce-value'); 19 if ( nonceEl ) 20 this.nonce = nonceEl.value; 21 if ( this.ID ) { 22 this.grabImageData( this.ID ); 23 this.imageView( this.ID ); 24 } 25 }, 26 27 initializeLinks: function() { 28 if ( this.ID ) 29 return; 30 $$('a.file-link').each( function(i) { 31 var id = i.id.split('-').pop(); 32 i.onclick = function(e) { theFileList[ 'inline' == theFileList.style ? 'imageView' : 'editView' ](id, e); } 33 } ); 34 }, 35 36 grabImageData: function(id) { 37 if ( id == this.currentImage.ID ) 38 return; 39 var thumbEl = $('attachment-thumb-url-' + id); 40 if ( thumbEl ) { 41 this.currentImage.thumb = ( 0 == id ? '' : thumbEl.value ); 42 this.currentImage.thumbBase = ( 0 == id ? '' : $('attachment-thumb-url-base-' + id).value ); 43 } else { 44 this.currentImage.thumb = false; 45 } 46 this.currentImage.src = ( 0 == id ? '' : $('attachment-url-' + id).value ); 47 this.currentImage.srcBase = ( 0 == id ? '' : $('attachment-url-base-' + id).value ); 48 this.currentImage.page = ( 0 == id ? '' : $('attachment-page-url-' + id).value ); 49 this.currentImage.title = ( 0 == id ? '' : $('attachment-title-' + id).value ); 50 this.currentImage.description = ( 0 == id ? '' : $('attachment-description-' + id).value ); 51 var widthEl = $('attachment-width-' + id); 52 if ( widthEl ) { 53 this.currentImage.width = ( 0 == id ? '' : widthEl.value ); 54 this.currentImage.height = ( 0 == id ? '' : $('attachment-height-' + id).value ); 55 } else { 56 this.currentImage.width = false; 57 this.currentImage.height = false; 58 } 59 this.currentImage.isImage = ( 0 == id ? 0 : $('attachment-is-image-' + id).value ); 60 this.currentImage.ID = id; 61 }, 62 63 imageView: function(id, e) { 64 this.prepView(id); 65 var h = ''; 66 67 h += "<div id='upload-file'>" 68 if ( this.ID ) { 69 var params = $H(this.params); 70 params.ID = ''; 71 params.action = ''; 72 h += "<a href='" + this.urlData[0] + '?' + params.toQueryString() + "' title='<?php echo attribute_escape(__('Browse your files')); ?>' class='back'><?php echo attribute_escape(__('« Back')); ?></a>"; 73 } else { 74 h += "<a href='#' onclick='return theFileList.cancelView();' title='<?php echo attribute_escape(__('Browse your files')); ?>' class='back'><?php echo attribute_escape(__('« Back')) ?></a>"; 75 } 76 h += "<div id='file-title'>" 77 if ( 0 == this.currentImage.isImage ) 78 h += "<h2><a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='<?php echo attribute_escape(__('Direct link to file')); ?>'>" + this.currentImage.title + "</a></h2>"; 79 else 80 h += "<h2>" + this.currentImage.title + "</h2>"; 81 h += " — <span>"; 82 h += "<a href='#' onclick='return theFileList.editView(" + id + ");'><?php echo attribute_escape(__('Edit')); ?></a>" 83 h += "</span>"; 84 h += '</div>' 85 h += "<div id='upload-file-view' class='alignleft'>"; 86 if ( 1 == this.currentImage.isImage ) { 87 h += "<a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='<?php echo attribute_escape(__('Direct link to file')); ?>'>"; 88 h += "<img src='" + ( this.currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />"; 89 h += "</a>"; 90 } else 91 h += ' '; 92 h += "</div>"; 93 94 h += "<form name='uploadoptions' id='uploadoptions' class='alignleft'>"; 95 h += "<table>"; 96 var display = []; 97 var checked = 'display-title'; 98 if ( 1 == this.currentImage.isImage ) { 99 checked = 'display-full'; 100 if ( this.currentImage.thumb ) { 101 display.push("<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' /> <?php echo attribute_escape(__('Thumbnail')); ?></label><br />"); 102 checked = 'display-thumb'; 103 } 104 display.push("<label for='display-full'><input type='radio' name='display' id='display-full' value='full' /> <?php echo attribute_escape(__('Full size')); ?></label>"); 105 } else if ( this.currentImage.thumb ) { 106 display.push("<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' /> <?php echo attribute_escape(__('Icon')); ?></label>"); 107 } 108 if ( display.length ) { 109 display.push("<br /><label for='display-title'><input type='radio' name='display' id='display-title' value='title' /> <?php echo attribute_escape(__('Title')); ?></label>"); 110 h += "<tr><th style='padding-bottom:.5em'><?php echo attribute_escape(__('Show:')); ?></th><td style='padding-bottom:.5em'>"; 111 $A(display).each( function(i) { h += i; } ); 112 h += "</td></tr>"; 113 } 114 115 h += "<tr><th><?php echo attribute_escape(__('Link to:')); ?></th><td>"; 116 h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' checked='checked'/> <?php echo attribute_escape(__('File')); ?></label><br />"; 117 h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> <?php echo attribute_escape(__('Page')); ?></label><br />"; 118 h += "<label for='link-none'><input type='radio' name='link' id='link-none' value='none' /> <?php echo attribute_escape(__('None')); ?></label>"; 119 h += "</td></tr>"; 120 121 h += "<tr><td colspan='2'><p class='submit'>"; 122 h += "<input type='button' class='button' name='send' onclick='theFileList.sendToEditor(" + id + ")' value='<?php echo attribute_escape(__('Send to editor »')); ?>' />"; 123 h += "</p></td></tr></table>"; 124 h += "</form>"; 125 126 h += "</div>"; 127 128 new Insertion.Top('upload-content', h); 129 var displayEl = $(checked); 130 if ( displayEl ) 131 displayEl.checked = true; 132 133 if (e) Event.stop(e); 134 return false; 135 }, 136 137 editView: function(id, e) { 138 this.prepView(id); 139 var h = ''; 140 141 var action = 'upload.php?style=' + this.style + '&tab=upload'; 142 if ( this.postID ) 143 action += '&post_id=' + this.postID; 144 145 h += "<form id='upload-file' method='post' action='" + action + "'>"; 146 if ( this.ID ) { 147 var params = $H(this.params); 148 params.ID = ''; 149 params.action = ''; 150 h += "<a href='" + this.urlData[0] + '?' + params.toQueryString() + "' title='<?php echo attribute_escape(__('Browse your files')); ?>' class='back'><?php echo attribute_escape(__('« Back')); ?></a>"; 151 } else { 152 h += "<a href='#' onclick='return theFileList.cancelView();' title='<?php echo attribute_escape(__('Browse your files')); ?>' class='back'><?php echo attribute_escape(__('« Back')); ?></a>"; 153 } 154 h += "<div id='file-title'>" 155 if ( 0 == this.currentImage.isImage ) 156 h += "<h2><a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='<?php echo attribute_escape(__('Direct link to file')); ?>'>" + this.currentImage.title + "</a></h2>"; 157 else 158 h += "<h2>" + this.currentImage.title + "</h2>"; 159 h += " — <span>"; 160 h += "<a href='#' onclick='return theFileList.imageView(" + id + ");'><?php echo attribute_escape(__('Insert')); ?></a>" 161 h += "</span>"; 162 h += '</div>' 163 h += "<div id='upload-file-view' class='alignleft'>"; 164 if ( 1 == this.currentImage.isImage ) { 165 h += "<a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='<?php echo wp_specialchars(__('Direct link to file')); ?>'>"; 166 h += "<img src='" + ( this.currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />"; 167 h += "</a>"; 168 } else 169 h += ' '; 170 h += "</div>"; 171 172 173 h += "<table><col /><col class='widefat' /><tr>" 174 h += "<th scope='row'><label for='url'><?php echo attribute_escape(__('URL')); ?></label></th>"; 175 h += "<td><input type='text' id='url' class='readonly' value='" + this.currentImage.srcBase + this.currentImage.src + "' readonly='readonly' /></td>"; 176 h += "</tr><tr>"; 177 h += "<th scope='row'><label for='post_title'><?php echo attribute_escape(__('Title')); ?></label></th>"; 178 h += "<td><input type='text' id='post_title' name='post_title' value='" + this.currentImage.title + "' /></td>"; 179 h += "</tr><tr>"; 180 h += "<th scope='row'><label for='post_content'><?php echo attribute_escape(__('Description')); ?></label></th>"; 181 h += "<td><textarea name='post_content' id='post_content'>" + this.currentImage.description + "</textarea></td>"; 182 h += "</tr><tr id='buttons' class='submit'><td colspan='2'><input type='button' id='delete' name='delete' class='delete alignleft' value='<?php echo attribute_escape(__('Delete File')); ?>' onclick='theFileList.deleteFile(" + id + ");' />"; 183 h += "<input type='hidden' name='from_tab' value='" + this.tab + "' />"; 184 h += "<input type='hidden' name='action' id='action-value' value='save' />"; 185 h += "<input type='hidden' name='ID' value='" + id + "' />"; 186 h += "<input type='hidden' name='_wpnonce' value='" + this.nonce + "' />"; 187 h += "<div class='submit'><input type='submit' value='<?php echo attribute_escape(__('Save »')); ?>' /></div>"; 188 h += "</td></tr></table></form>"; 189 190 new Insertion.Top('upload-content', h); 191 if (e) Event.stop(e); 192 return false; 193 }, 194 195 prepView: function(id) { 196 this.cancelView( true ); 197 var filesEl = $('upload-files'); 198 if ( filesEl ) 199 filesEl.hide(); 200 var navEl = $('current-tab-nav'); 201 if ( navEl ) 202 navEl.hide(); 203 this.grabImageData(id); 204 }, 205 206 cancelView: function( prep ) { 207 if ( !prep ) { 208 var filesEl = $('upload-files'); 209 if ( filesEl ) 210 Element.show(filesEl); 211 var navEl = $('current-tab-nav'); 212 if ( navEl ) 213 Element.show(navEl); 214 } 215 if ( !this.ID ) 216 this.grabImageData(0); 217 var div = $('upload-file'); 218 if ( div ) 219 Element.remove(div); 220 return false; 221 }, 222 223 sendToEditor: function(id) { 224 this.grabImageData(id); 225 var link = ''; 226 var display = ''; 227 var h = ''; 228 229 link = $A(document.forms.uploadoptions.elements.link).detect( function(i) { return i.checked; } ).value; 230 displayEl = $A(document.forms.uploadoptions.elements.display).detect( function(i) { return i.checked; } ) 231 if ( displayEl ) 232 display = displayEl.value; 233 else if ( 1 == this.currentImage.isImage ) 234 display = 'full'; 235 236 if ( 'none' != link ) 237 h += "<a href='" + ( 'file' == link ? ( this.currentImage.srcBase + this.currentImage.src ) : ( this.currentImage.page + "' rel='attachment wp-att-" + this.currentImage.ID ) ) + "' title='" + this.currentImage.title + "'>"; 238 if ( display && 'title' != display ) 239 h += "<img src='" + ( 'thumb' == display ? ( this.currentImage.thumbBase + this.currentImage.thumb ) : ( this.currentImage.srcBase + this.currentImage.src ) ) + "' alt='" + this.currentImage.title + "' />"; 240 else 241 h += this.currentImage.title; 242 if ( 'none' != link ) 243 h += "</a>"; 244 245 var win = window.opener ? window.opener : window.dialogArguments; 246 if ( !win ) 247 win = top; 248 tinyMCE = win.tinyMCE; 249 if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') ) { 250 tinyMCE.selectedInstance.getWin().focus(); 251 tinyMCE.execCommand('mceInsertContent', false, h); 252 } else 253 win.edInsertContent(win.edCanvas, h); 254 if ( !this.ID ) 255 this.cancelView(); 256 return false; 257 }, 258 259 deleteFile: function(id) { 260 if ( confirm("<?php printf(js_escape(__("Are you sure you want to delete the file '%s'?\nClick ok to delete or cancel to go back.")), '" + this.currentImage.title + "'); ?>") ) { 261 $('action-value').value = 'delete'; 262 $('upload-file').submit(); 263 return true; 264 } 265 return false; 266 } 267 268 }; 269 theFileList.initializeVars(); 270 theFileList.initializeLinks(); 271 } );
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 30 19:41:27 2007 | par Balluche grâce à PHPXref 0.7 |