r45046 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r45045‎ | r45046 | r45047 >
Date:08:06, 26 December 2008
Author:dale
Status:deferred
Tags:
Comment:
minor fixes to resource import
Modified paths:
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libRemoteMediaSearch/mv_remote_media_search.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/skins/mv_embed/libRemoteMediaSearch/mv_remote_media_search.js
@@ -505,6 +505,8 @@
506506 },
507507 checkImportResource:function( rObj, cir_callback){
508508 //@@todo get the localized File/Image namespace name or do a general {NS}:Title aproch
 509+ var cp = rObj.pSobj.cp;
 510+ var _this = this;
509511 rObj.target_resource_title = rObj.titleKey.replace(/File:|Image:/,'');
510512
511513 //check if we can embed the content locally per a domain name check:
@@ -516,16 +518,17 @@
517519 if( local_host.indexOf( ld ) != -1)
518520 local_embed_ref=true;
519521 }
520 - }
521 -
 522+ }
 523+ //locally embeddalbe jump to callback:
522524 if( local_embed_ref ){
523525 cir_callback( rObj );
524 - }else{
525 - var _this = this;
526 - var cp = rObj.pSobj.cp;
527 -
528 - //first check if the resource is not already on this wiki
529 - reqObj={'action':'query', titles: _this.cFileNS + ':' + rObj.target_resource_title};
 526+ }else{
 527+ //not a local domain update target resource name with the prefix:
 528+ rObj.target_resource_title = cp.resource_prefix +rObj.target_resource_title;
 529+
 530+ //check if the resource is not already on this wiki
 531+ reqObj={'action':'query', 'titles': _this.cFileNS + ':' + rObj.target_resource_title};
 532+
530533 do_api_req( reqObj, this.local_wiki_api_url, function(data){
531534 var found_title = false;
532535 for(var i in data.query.pages){
@@ -1096,7 +1099,13 @@
10971100 //make sure we have pages to idoerate:
10981101 if(data.query && data.query.pages){
10991102 for(var page_id in data.query.pages){
1100 - var page = data.query.pages[ page_id ];
 1103+ var page = data.query.pages[ page_id ];
 1104+ //make sure the page is not a redirect
 1105+ if(page.revisions[0]['*'].indexOf('#REDIRECT')===0){
 1106+ //skip page is redirect
 1107+ continue;
 1108+ }
 1109+
11011110 this.resultsObj[page_id]={
11021111 'titleKey':page.title,
11031112 'link':page.imageinfo[0].descriptionurl,

Status & tagging log