Index: trunk/extensions/MetavidWiki/skins/mv_embed/libRemoteMediaSearch/mv_remote_media_search.js |
— | — | @@ -505,6 +505,8 @@ |
506 | 506 | }, |
507 | 507 | checkImportResource:function( rObj, cir_callback){ |
508 | 508 | //@@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; |
509 | 511 | rObj.target_resource_title = rObj.titleKey.replace(/File:|Image:/,''); |
510 | 512 | |
511 | 513 | //check if we can embed the content locally per a domain name check: |
— | — | @@ -516,16 +518,17 @@ |
517 | 519 | if( local_host.indexOf( ld ) != -1) |
518 | 520 | local_embed_ref=true; |
519 | 521 | } |
520 | | - } |
521 | | - |
| 522 | + } |
| 523 | + //locally embeddalbe jump to callback: |
522 | 524 | if( local_embed_ref ){ |
523 | 525 | 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 | + |
530 | 533 | do_api_req( reqObj, this.local_wiki_api_url, function(data){ |
531 | 534 | var found_title = false; |
532 | 535 | for(var i in data.query.pages){ |
— | — | @@ -1096,7 +1099,13 @@ |
1097 | 1100 | //make sure we have pages to idoerate: |
1098 | 1101 | if(data.query && data.query.pages){ |
1099 | 1102 | 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 | + |
1101 | 1110 | this.resultsObj[page_id]={ |
1102 | 1111 | 'titleKey':page.title, |
1103 | 1112 | 'link':page.imageinfo[0].descriptionurl, |