Index: trunk/phase3/js2/mwEmbed/libAddMedia/searchLibs/mediaWikiSearch.js |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | //inherit the cp settings for |
17 | 17 | }, |
18 | 18 | //returns a rObj by title |
19 | | - getRObjByTitle:function( title , callback){ |
| 19 | + addByTitle:function( title , callback){ |
20 | 20 | var _this = this; |
21 | 21 | var reqObj = { |
22 | 22 | 'action':'query', |
— | — | @@ -28,15 +28,8 @@ |
29 | 29 | do_api_req( { |
30 | 30 | 'data':reqObj, |
31 | 31 | 'url':this.cp.api_url |
32 | | - }, function(data){ |
33 | | - _this.clearResults(); |
34 | | - //get results with rObj callback |
35 | | - _this.addResults(data); |
36 | | - //should only be one value: |
37 | | - for(var i in _this.resultsObj){ |
38 | | - callback( _this.resultsObj[i] ); |
39 | | - break; |
40 | | - } |
| 32 | + }, function(data){ |
| 33 | + callback( _this.addSingleResult(data) ); |
41 | 34 | } |
42 | 35 | ); |
43 | 36 | }, |
— | — | @@ -82,7 +75,7 @@ |
83 | 76 | 'rvprop':'content' |
84 | 77 | }, |
85 | 78 | 'url':_this.cp.api_url |
86 | | - },function(data){ |
| 79 | + },function(data){ |
87 | 80 | _this.clearResults(); |
88 | 81 | _this.addResults(data); |
89 | 82 | if(callback) |
— | — | @@ -130,7 +123,11 @@ |
131 | 124 | _this.loading = false; |
132 | 125 | }); |
133 | 126 | }, |
134 | | - addResults:function( data ){ |
| 127 | + //same as below but returns your rObj for convience |
| 128 | + addSingleResult:function( data ){ |
| 129 | + return this.addResults(data, true); |
| 130 | + }, |
| 131 | + addResults:function( data, returnFirst ){ |
135 | 132 | js_log("f:addResults"); |
136 | 133 | var _this = this |
137 | 134 | //check if we have |
— | — | @@ -158,6 +155,7 @@ |
159 | 156 | if( !page.imageinfo ) |
160 | 157 | continue; |
161 | 158 | var rObj = { |
| 159 | + 'id' : page_id, |
162 | 160 | 'titleKey' : page.title, |
163 | 161 | 'link' : page.imageinfo[0].descriptionurl, |
164 | 162 | 'title' : page.title.replace(/File:|.jpg|.png|.svg|.ogg|.ogv|.oga/ig, ''), |
— | — | @@ -174,22 +172,25 @@ |
175 | 173 | 'meta':{ |
176 | 174 | 'categories':page.categories |
177 | 175 | } |
178 | | - }; |
179 | | - |
| 176 | + }; |
180 | 177 | //attempt to parse out some stuff from the teplate: |
181 | 178 | var desc = rObj.desc.match(/\|Description=(([^\n]*\n)*)\|Source=/) |
182 | 179 | if( desc && desc[1] ){ |
183 | 180 | rObj.desc = $j.trim( desc[1] ); |
184 | | - } |
185 | | - |
| 181 | + } |
186 | 182 | //likely a audio clip if no poster and type application/ogg |
187 | 183 | //@@todo we should return audio/ogg for the mime type or some other way to specify its "audio" |
188 | 184 | if( ! rObj.poster && rObj.mime == 'application/ogg' ){ |
189 | 185 | rObj.mime = 'audio/ogg'; |
190 | | - } |
| 186 | + } |
| 187 | + //add to the resultObj |
| 188 | + this.resultsObj[page_id] = rObj; |
191 | 189 | |
192 | | - this.resultsObj[page_id]= rObj; |
| 190 | + //if returnFirst flag: |
| 191 | + if(returnFirst) |
| 192 | + return this.resultsObj[page_id]; |
193 | 193 | |
| 194 | + |
194 | 195 | this.num_results++; |
195 | 196 | //for(var i in this.resultsObj[page_id]){ |
196 | 197 | // js_log('added: '+ i +' '+ this.resultsObj[page_id][i]); |
Index: trunk/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js |
— | — | @@ -33,7 +33,10 @@ |
34 | 34 | "results_from" : "Results from <a href=\"$1\" target=\"_new\" >$2<\/a>", |
35 | 35 | "missing_desc_see_soruce" : "This asset is missing a description. Please see the [$1 orginal source] and help describe it.", |
36 | 36 | "rsd_config_error" : "Add media wizard configuration error : $1", |
37 | | - "uploaded_itmes" : "Uploaded Items:" |
| 37 | + "uploaded_itmes" : "Uploaded Items:", |
| 38 | + |
| 39 | + "your_recent_uploads" : "Your Recent Uploads", |
| 40 | + "upload_a_file": "Upload a New File" |
38 | 41 | }); |
39 | 42 | var default_remote_search_options = { |
40 | 43 | 'profile':'mediawiki_edit', |
— | — | @@ -590,10 +593,20 @@ |
591 | 594 | //load this_wiki search system to grab the rObj |
592 | 595 | _this.loadSearchLib(cp, function(){ |
593 | 596 | //do basic layout form on left upload "bin" on right |
594 | | - $j('#tab-upload').html('<table>' + |
| 597 | + $j('#tab-upload').html('<table cellspacing="10">' + |
595 | 598 | '<tr>' + |
596 | | - '<td style="width:350px;padding:10px" id="upload_form">' + mv_get_loading_img() +'</td>' + |
597 | | - '<td valign="top" id="upload_bin"></td>' + |
| 599 | + '<td valign="top" style="width:350px;">' + |
| 600 | + '<h4>' + gM('upload_a_file') + '</h4>' + |
| 601 | + '<div id="upload_form">' + |
| 602 | + mv_get_loading_img() + |
| 603 | + '</div>' + |
| 604 | + '</td>' + |
| 605 | + '<td valign="top" id="upload_bin_cnt">' + |
| 606 | + '<h4>' + gM('your_recent_uploads') + '</h4>' + |
| 607 | + '<div id="upload_bin">' + |
| 608 | + mv_get_loading_img() + |
| 609 | + '</div>'+ |
| 610 | + '</td>' + |
598 | 611 | '</tr>' + |
599 | 612 | '</table>'); |
600 | 613 | |
— | — | @@ -605,7 +618,7 @@ |
606 | 619 | _this.drawOutputResults(); |
607 | 620 | }); |
608 | 621 | }else{ |
609 | | - $j('#upload_bin').empty(); |
| 622 | + $j('#upload_bin_cnt').empty(); |
610 | 623 | } |
611 | 624 | |
612 | 625 | //deal with the api form upload form directly: |
— | — | @@ -618,9 +631,12 @@ |
619 | 632 | 'style="position:absolute;top:0px;left:0px;bottom:5px;right:4px;background-color:#FFF;">' + |
620 | 633 | mv_get_loading_img('position:absolute;top:30px;left:30px') + |
621 | 634 | '</div>'); |
622 | | - cp.sObj.getRObjByTitle( wTitle, function( rObj ){ |
| 635 | + cp.sObj.addByTitle( wTitle, function( rObj ){ |
623 | 636 | $j( _this.target_container ).find('#temp_edit_loader').remove(); |
624 | | - //append the image to the upload bin |
| 637 | + //redraw (with added result if new) |
| 638 | + _this.drawOutputResults(); |
| 639 | + //pull up recource editor: |
| 640 | + _this.resourceEdit( rObj, $j('#res_upload_' + rObj.id).get(0) ); |
625 | 641 | }); |
626 | 642 | //return false to close progress window: |
627 | 643 | return false; |
— | — | @@ -916,20 +932,21 @@ |
917 | 933 | //@@todo we could load the id with the content provider id to find the object faster... |
918 | 934 | getResourceFromId:function( rid ){ |
919 | 935 | //js_log('getResourceFromId:' + rid ); |
920 | | - //strip out /res/ if preset: |
| 936 | + //strip out /res/ if preset: |
921 | 937 | rid = rid.replace(/res_/, ''); |
922 | | - for(var cp_id in this.content_providers){ |
923 | | - cp = this.content_providers[ cp_id ]; |
924 | | - if(rid.indexOf( cp_id ) != -1){ |
925 | | - rid = rid.replace( cp_id + '_',''); |
926 | | - if( cp['sObj']){ |
927 | | - for(var rInx in cp.sObj.resultsObj){ |
928 | | - if( rInx == rid ) |
929 | | - return cp.sObj.resultsObj[rInx]; |
930 | | - }; |
931 | | - } |
932 | | - } |
933 | | - } |
| 938 | + js_log("looking at: " + rid); |
| 939 | + p = rid.split('_'); |
| 940 | + var cp_id = p[0]; |
| 941 | + var rid = p[1]; |
| 942 | + if(cp_id == 'upload') |
| 943 | + cp_id = 'this_wiki'; |
| 944 | + |
| 945 | + var cp = this.content_providers[cp_id]; |
| 946 | + |
| 947 | + if(cp['sObj'] && cp.sObj.resultsObj[rid]){ |
| 948 | + return cp.sObj.resultsObj[rid]; |
| 949 | + } |
| 950 | + |
934 | 951 | js_log("ERROR: could not find " + rid); |
935 | 952 | return false; |
936 | 953 | }, |