r44701 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44700‎ | r44701 | r44702 >
Date:03:15, 17 December 2008
Author:dale
Status:deferred
Tags:
Comment:
updates to remote media search
Modified paths:
  • /trunk/extensions/MetavidWiki/maintenance/metavid2mvWiki.inc.php (modified) (history)
  • /trunk/extensions/MetavidWiki/maintenance/metavid2mvWiki.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/external_media_wizard.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libRemoteMediaSearch/mv_remote_media_search.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mv_playlist.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mv_sequencer.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/mv_sequence.css (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/archive_org_logo_80.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/archive_org_tab.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/cc-flickr.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/combined_tab.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/logo.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/metavid_tab.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/tab-bg.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/wiki_commons_logo_80.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/wiki_commons_tab.png (added) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/styles.css (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/maintenance/metavid2mvWiki.php
@@ -13,7 +13,7 @@
1414 * this is the script we will use to migrate the existing metavid db the mv wiki db
1515 */
1616 $cur_path = $IP = dirname( __FILE__ );
17 -// include commandLine.inc from the mediaWiki maintance dir:
 17+// include commandLine.inc from the mediaWiki maintenance dir:
1818 require_once ( '../../../maintenance/commandLine.inc' );
1919 require_once ( 'metavid2mvWiki.inc.php' );
2020
Index: trunk/extensions/MetavidWiki/maintenance/metavid2mvWiki.inc.php
@@ -692,7 +692,8 @@
693693 }
694694 $max = 0;
695695 $mapk = null;
696 - // print_r($point);
 696+ print_r($matches);
 697+ die;
697698 foreach ( $point as $k => $v ) {
698699 if ( $v > $max ) {
699700 $mapk = $matches[1][$k];
Index: trunk/extensions/MetavidWiki/skins/external_media_wizard.js
@@ -20,12 +20,12 @@
2121 var body_elm = document.getElementsByTagName("body")[0];
2222 body_elm.innerHTML = body_elm.innerHTML + ''+
2323 '<div id="modalbox" style="background:#DDD;border:3px solid #666666;'+
24 - 'height:90%;left:10%;position:fixed;top:5%;width:80%;z-index:100;">'+
 24+ 'top:30px;left:100px;right:100px;bottom:30px;position:fixed;z-index:100;">'+
2525
2626 'loading external media wizard<blink>...</blink>'+
2727
2828 '</div>'+
29 - '<div style="background:#000;cursor:wait;height:100%;left:0;position:fixed;'+
 29+ '<div id="mv_overlay" style="background:#000;cursor:wait;height:100%;left:0;position:fixed;'+
3030 'top:0;width:100%;z-index:5;filter:alpha(opacity=60);-moz-opacity: 0.6;'+
3131 'opacity: 0.6;"/>';
3232 //inject mv_embed
@@ -45,7 +45,8 @@
4646 }else{
4747 mv_do_remote_search({
4848 'target_id':'modalbox',
49 - 'profile':'mediawiki_edit'
 49+ 'profile':'mediawiki_edit',
 50+ 'default_query':wgTitle
5051 });
5152 }
5253 }
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mv_sequencer.js
@@ -132,11 +132,12 @@
133133 'html': getMsg('loading_txt'),
134134 'js':function( this_seq ){
135135 //load the search interface with sequence tool targets
136 - mvJsLoader.doLoad({'mediaWikiRemoteSearch':'libRemoteMediaSearch/mv_remote_media_search.js'}, function(){
 136+ mvJsLoader.doLoad({'remoteSearchDriver':'libRemoteMediaSearch/mv_remote_media_search.js'}, function(){
137137 this_seq.mySearch = new remoteSearchDriver({
138138 'profile':'sequence',
139139 'p_seq':this_seq,
140 - 'target_id':'cliplib_ic'
 140+ 'target_id':'cliplib_ic',
 141+ 'instance_name': this.instance_name + '.mySearch'
141142 });
142143 });
143144 }
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mv_playlist.js
@@ -113,8 +113,7 @@
114114 //pulls up the video editor inline
115115 doEditor:function(){
116116 //black out the page:
117 - $j('body').append('<div id="mv_overlay"/> '+
118 - '<div id="modalbox" class="modal_editor">');
 117+ $j('body').append('<div id="modalbox" class="modal_editor">' + '<div id="mv_overlay"/> ');
119118
120119 $j('#modalbox').html('loading editor<blink>...</blink>');
121120 var _this=this;
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/tab-bg.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/tab-bg.png
___________________________________________________________________
Added: svn:mime-type
122121 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/cc-flickr.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/cc-flickr.png
___________________________________________________________________
Added: svn:mime-type
123122 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/archive_org_tab.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/archive_org_tab.png
___________________________________________________________________
Added: svn:mime-type
124123 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/archive_org_logo_80.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/archive_org_logo_80.png
___________________________________________________________________
Added: svn:mime-type
125124 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/metavid_tab.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/metavid_tab.png
___________________________________________________________________
Added: svn:mime-type
126125 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/logo.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/logo.png
___________________________________________________________________
Added: svn:mime-type
127126 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/wiki_commons_tab.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/wiki_commons_tab.png
___________________________________________________________________
Added: svn:mime-type
128127 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/wiki_commons_logo_80.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/wiki_commons_logo_80.png
___________________________________________________________________
Added: svn:mime-type
129128 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/combined_tab.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/remote_search/combined_tab.png
___________________________________________________________________
Added: svn:mime-type
130129 + application/octet-stream
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/mv_sequence.css
@@ -108,13 +108,6 @@
109109 top:0px;
110110 z-index:-1;
111111 }
112 -.mv_clip_box_result{
113 - padding:10px;
114 - float:left;
115 -}
116 -.mv_clip_list_result{
117 - padding:10px;
118 -}
119112 .mv_storyboard_container{
120113 position:absolute;
121114 z-index:0;
Index: trunk/extensions/MetavidWiki/skins/mv_embed/skins/mvpcf/styles.css
@@ -488,5 +488,65 @@
489489 .ui-resizable-w { z-index:5; position:absolute; cursor: w-resize; width: 15px;height:19px; top: 0px; bottom: 0px; left: 0px;}
490490 .ui-dragSpan {filter: alpha(opacity=70); -moz-opacity: .7; background-color:#AAF; position:absolute; left: 10px; right:10px;height:19px; }
491491
 492+#remote search css:
 493+ul.rsd_cp_tabs {
 494+ border-bottom:1px solid #CCCCCC;
 495+ display:inline;
 496+ list-style-image:none;
 497+ list-style-position:outside;
 498+ list-style-type:none;
 499+ margin:0;
 500+ padding:0;
 501+}
 502+ul.rsd_cp_tabs li.rsd_selected {
 503+ background:#FFFFFF none repeat scroll 0 0;
 504+ border-bottom:0;
 505+ padding-bottom:1px;
 506+ padding-top:12px;
 507+}
 508+ul.rsd_cp_tabs li {
 509+ display:inline;
 510+ margin:0;
 511+ padding:10px 0 0;
 512+ background:#F7F7F7 url(remote_search/tab-bg.png) repeat-x scroll left bottom;
 513+ border:1px solid #777;
 514+ padding-bottom:0;
 515+ margin-left:7px;
 516+ cursor:pointer;
 517+}
 518+.rsd_results_container{
 519+ position:absolute;
 520+ left:2px;
 521+ right:2px;
 522+ top:100px;
 523+ bottom:2px;
 524+ z-index:-1;
 525+ overflow:auto;
 526+}
 527+#rsd_results {
 528+ border-top:0;
 529+ border:1px solid #777;
 530+ position:relative;
 531+ background:#FFF;
492532
493 -
 533+ position:absolute;
 534+ left:2px;
 535+ right:2px;
 536+ top:66px;
 537+ bottom:2px;
 538+ z-index:-1;
 539+ overflow:auto;
 540+}
 541+.mv_clip_box_result{
 542+ padding:10px;
 543+ float:left;
 544+ border: thin solid #BBB;
 545+}
 546+.mv_clip_list_result{
 547+ padding:10px;
 548+}
 549+#rds_results_bar{
 550+ margin:4px;
 551+ background:#DEF;
 552+ height:22px;
 553+}
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -120,10 +120,10 @@
121121 //@@todo integrate msg serving into CMS
122122 function getMsg( key , args ) {
123123 if ( key in gMsg ) {
124 - if(typeof args == 'object'){
 124+ if(typeof args == 'object'){
125125 for(var v in args){
126 - gMsg[key] = gMsg[key].replace('/\$'+v+'/', args[v]);
127 - }
 126+ gMsg[key] = gMsg[key].replace('\$'+v, args[v]);
 127+ }
128128 }else if(typeof args =='string'){
129129 gMsg[key] = gMsg[key].replace(/\$1/, args);
130130 }
@@ -1091,7 +1091,8 @@
10921092 mvJsLoader.doLoad({
10931093 'mvBaseRemoteSearch':'libRemoteMediaSearch/mv_remote_media_search.js'
10941094 }, function(){
1095 - var mvrs = new remoteSearchDriver( initObj );
 1095+ initObj['instance_name']= 'rsdMVRS';
 1096+ rsdMVRS = new remoteSearchDriver( initObj );
10961097 });
10971098 });
10981099 }
@@ -2961,8 +2962,8 @@
29622963 }else{
29632964 //get data via DOM injection with callback
29642965 global_req_cb.push(callback);
2965 - //prepend json_ to feed_format
2966 - if(req_url.indexOf("feed_format=")!=-1)
 2966+ //prepend json_ to feed_format if not already requesting json format
 2967+ if( req_url.indexOf("feed_format=")!=-1 && req_url.indexOf("feed_format=json")==-1)
29672968 req_url = req_url.replace(/feed_format=/, 'feed_format=json_');
29682969
29692970 loadExternalJs(req_url+'&cb=mv_jsdata_cb&cb_inx='+(global_req_cb.length-1));
@@ -3047,6 +3048,9 @@
30483049 return false;
30493050 }
30503051 function loadExternalCss(url){
 3052+ if( url.indexOf('?')==-1 ){
 3053+ url+='?'+mv_embed_urid;
 3054+ }
30513055 js_log('load css: ' + url);
30523056 var e = document.createElement("link");
30533057 e.href = url;
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libRemoteMediaSearch/mv_remote_media_search.js
@@ -8,7 +8,11 @@
99 and archive.org
1010 */
1111
12 -gMsg['mv_media_search']= 'Media Search';
 12+gMsg['mv_media_search'] = 'Media Search';
 13+gMsg['rsd_box_layout'] = 'Box layout';
 14+gMsg['rsd_list_layout'] = 'List Layout';
 15+gMsg['rsd_results_desc']= 'Results <b>$0</b> of <b>$1</b>';
 16+gMsg['rsd_layout'] = 'Layout:';
1317
1418 var default_remote_search_options = {
1519 'profile':'mediawiki_edit',
@@ -16,54 +20,83 @@
1721
1822 'default_provider_id':'all', //all or one of the content_providers ids
1923
 24+ 'instance_name': null, //a globally accessible callback instance name
 25+ 'default_query':'', //default search query
2026 //specific to sequence profile
21 - 'p_seq':null
 27+ 'p_seq':null
2228 }
2329 var remoteSearchDriver = function(initObj){
2430 return this.init( initObj );
2531 }
2632 remoteSearchDriver.prototype = {
 33+ results_cleared:false,
2734 //here we define the set of possible media content providers:
2835 main_search_options:{
2936 'selprovider':{
30 - 'title': 'Select Provider'
 37+ 'title': 'Select Providers'
3138 },
3239 'advanced_search':{
3340 'title': 'Advanced Options'
3441 }
3542 },
36 - content_providers:{
37 - //@@todo seed this via the include call (can be exported to seperate library
38 - // once we get the script loader integrated)
 43+ content_providers:{
 44+ /*content_providers documentation:
 45+ @enabled: whether the search provider can be selected
 46+ @checked: whether the search provideer will show up as seletable tab (todo: user prefrence)
 47+ @d: if the current cp should be displayed (only one should be the default)
 48+ @title: the title of the search provider
 49+ @desc: can use html... todo: need to localize
 50+ @api_url: the url to query against given the library type:
 51+ @lib: the search library to use corresponding to the
 52+ search object ie: 'mediaWiki' = new mediaWikiSearchSearch()
 53+ @local : if the content provider assets need to be imported or not.
 54+ */
3955 'this_wiki':{
 56+ 'enabled':0,
 57+ 'checked':0,
 58+ 'd' :0,
 59+ 'title' :'The Current Wiki',
 60+ 'desc' : '(should be updated with the proper text)',
 61+ 'api_url': wgScriptPath + '/api.php',
 62+ 'lib' :'mediaWiki',
 63+ 'local' :true
 64+ },
 65+ 'wiki_commons':{
4066 'enabled':1,
4167 'checked':1,
42 - 'title':'The Current Wiki',
43 - 'desc': '(should be updated with the proper text)'
 68+ 'd' :0,
 69+ 'title' :'Wikipedia Commons',
 70+ 'desc' : 'Wikimedia Commons is a media file repository making available public domain '+
 71+ 'and freely-licensed educational media content (images, sound and video clips) to all.',
 72+ 'api_url':'http://commons.wikimedia.org/w/api.php',
 73+ 'lib' :'mediaWiki',
 74+ 'search_title':false, //disable title search
 75+ 'local' :true
4476 },
45 - 'wiki_commons':{
 77+ 'metavid':{
4678 'enabled':1,
47 - 'checked':1,
48 - 'title':'Wikipedia Commons',
49 - 'desc': 'Wikimedia Commons is a media file repository making available public domain '+
50 - 'and freely-licensed educational media content (images, sound and video clips) to all.',
51 - 'logo': 'http://upload.wikimedia.org/wikipedia/commons/thumb/7/79/Wiki-commons.png/80px-Wiki-commons.png'
 79+ 'checked':1,
 80+ 'd' :1,
 81+ 'title' :'Metavid.org',
 82+ 'desc' : 'Metavid hosts thousands of hours of US house and senate floor proceedings',
 83+ 'api_url':'http://localhost/wiki/index.php?title=Special:MvExportSearch',
 84+ 'lib' : 'metavid',
 85+ 'local' :false
5286 },
5387 'archive_org':{
54 - 'enabled':1,
55 - 'checked':1,
 88+ 'enabled':0,
 89+ 'checked':0,
 90+ 'd' :0,
5691 'title' : 'Archive.org',
57 - 'desc' : 'The Internet Archive, a digital library of cultural artifacts in digital form',
58 - 'logo' : 'http://www.archive.org/images/logo.jpg'
59 - },
60 - 'metavid':{
61 - 'enabled':1,
62 - 'checked':1,
63 - 'title':'Metavid.org',
64 - 'desc': 'Metavid hosts thousands of hours of US house and senate floor proccedings',
65 - 'logo': 'http://metavid.org/w/skins/mvpcf/images/logo.png'
 92+ 'desc' : 'The Internet Archive, a digital library of cultural artifacts',
 93+ 'lib' : 'archive',
 94+ 'local' : false
6695 }
6796 },
 97+ //some default layout values:
 98+ thumb_width : 80,
 99+ result_display_mode : 'box', //box or list or preview
 100+
68101 init:function( initObj ){
69102 js_log('remoteSearchDriver:init');
70103 for( var i in default_remote_search_options ) {
@@ -81,64 +114,62 @@
82115 var out = '<div class="rsd_control_container" style="width:100%">' +
83116 '<table style="width:100%">' +
84117 '<tr>'+
85 - '<td style="width:100px">'+
 118+ '<td style="width:110px">'+
86119 '<h3> Media Search </h3>'+
87120 '</td>'+
88121 '<td style="width:190px">'+
89 - '<input type="text" tabindex="1" value="" maxlength="512" id="q" name="q" '+
 122+ '<input type="text" tabindex="1" value="' + this.default_query + '" maxlength="512" id="rsd_q" name="rsd_q" '+
90123 'size="20" autocomplete="off"/>'+
91124 '</td>'+
92 - '<td style="width:110px">'+
 125+ '<td style="width:115px">'+
93126 '<input type="submit" value="' + getMsg('mv_media_search') + '" tabindex="2" '+
94127 ' id="rms_search_button"/>'+
95128 '</td>'+
96129 '<td>';
97 - for(var i in this.main_search_options){
98 - var mso = this.main_search_options[i];
99 - out += '<a src="#" id="mso_'+i+'" >' + mso.title + '</a><br>';
100 - }
101 - out+= '</td>'+
 130+ out += '<a src="#" id="mso_selprovider" >Select Providers</a><br>';
 131+ out += '<a src="#" id="mso_cancel" >Cancel</a><br>';
 132+ out += '</td>'+
102133 '</tr>'+
103134 '</table>';
104 - js_log('out: ' + out);
105 - //set up the content provider selection div (do this first to get the default cp)
106 - var cpsdiv = '<div id="cps_options">'+
107 - '<table style="background:transparent"><tr>';
108 -
109 - for( var i in this.content_providers ){
110 - var cp = this.content_providers[i];
111 -
112 - var checked_attr = ( cp.checked ) ? 'checked':'';
113 -
114 - cpsdiv+='<td '+
115 - ' title="' + cp.title + '" '+
 135+ js_log('out: ' + out);
 136+
 137+ out+='<div id="rsd_options_bar" style="display:none;width:100%;height:0px;background:#BBB">';
 138+ //set up the content provider selection div (do this first to get the default cp)
 139+ out+= '<div id="cps_options">';
 140+ for( var cp_id in this.content_providers ){
 141+ var cp = this.content_providers[cp_id];
 142+ var checked_attr = ( cp.checked ) ? 'checked':'';
 143+ out+='<div title="' + cp.title + '" '+
116144 ' style="float:left;cursor:pointer;">'+
117 - '<input class="mv_cps_input" type="checkbox" name="mv_cps" '+ checked_attr+'>'+
118 - '</td>'+
119 - '<td>';
120 - if( cp.logo ){
121 - cpsdiv+= '<img src="' + cp.logo + '">';
122 - }else{
123 - cpsdiv+= cp.title
124 - }
125 - cpsdiv+='</td>';
126 - }
127 - cpsdiv+='<tr><td><a id="mso_selprovider_close" href="#">'+getMsg('close')+'</a></td></tr></table></div>';
128 -
129 - out+='<div id="rsd_options_bar" style="display:none;width:100%;height:0px;background:#BBB">'+
130 - cpsdiv +
131 - '</div>';
132 - out+='<div class="rsd_result_bar" style="width:100%;border-top:solid thin black;background:#66F"/>';
 145+ '<input class="mv_cps_input" type="checkbox" name="mv_cps" '+ checked_attr+'>';
 146+
 147+ out+= '<img alt="'+cp.title+'" src="' + mv_embed_path + 'skins/' + mv_skin_name + '/remote_search/' + cp_id + '_tab.png">';
 148+ out+='</div>';
 149+ }
 150+ out+='<div style="clear:both"/><a id="mso_selprovider_close" href="#">'+getMsg('close')+'</a></div>';
 151+ out+='</div>';
133152 //close up the control container:
134153 out+='</div>';
135 - //outout the results placeholder:
136 - out+='<div class="rmd_results" style="width:100%;height:100%;overflow:auto;" />';
 154+ //search provider tabs based on "checked" and "enabled" and "combined tab"
 155+ out+='<div id="rsd_results_container">';
 156+ out+='</div>';
137157 $j('#'+ this.target_id ).html( out );
 158+ //draw the tabs:
 159+ this.drawTabs();
 160+ //run the default search:
 161+ this.runSearch();
138162 },
139163 add_interface_bindings:function(){
140164 var _this = this;
141 - js_log("add_interface_bindings:");
 165+ js_log("add_interface_bindings:");
142166 //setup for this.main_search_options:
 167+ $j('#mso_cancel').click(function(){
 168+ $j('#modalbox').fadeOut("normal",function(){
 169+ $j(this).remove();
 170+ $j('#mv_overlay').remove();
 171+ });
 172+ });
 173+
143174 $j('#mso_selprovider,#mso_selprovider_close').click(function(){
144175 if($j('#rsd_options_bar:hidden').length !=0 ){
145176 $j('#rsd_options_bar').animate({
@@ -153,69 +184,135 @@
154185 $j(this).hide();
155186 })
156187 }
 188+ });
 189+ //setup bindings for search tabs:
 190+ $j('.rsd_cp_tabs li').click(function(){
 191+ _this.selectTab( $j(this).attr('id').replace(/rsd_tab_/, '') );
157192 });
 193+
158194 //setup binding for search provider check box:
159195 //search button:
160196 $j('#rms_search_button').click(function(){
161197 _this.runSearch();
162198 });
163199 },
164 - runSearch:function(){
165 - //get a remote search object for each search provider:
166 - for(var i in
167 - }
168 -}
169 -
170 -var mvBaseRemoteSearch = function(initObj) {
171 - return this.init(initObj);
172 -};
173 -mvBaseRemoteSearch.prototype = {
174 - //default values:
175 - thumb_width:80,
176 -
177 - completed_req:0,
178 - num_req:0,
179 -
180 - result_display_mode:'box', //box or list or preview
181 - resultsObj:{},
182 - //init the object:
183 - init:function( initObj ){
184 - js_log('mvBaseRemoteSearch:init');
185 - for(var i in initObj){
186 - this[i] = initObj[i];
 200+ runSearch: function(){
 201+ var _this = this;
 202+ //set loading div:
 203+ $j('#rsd_results').append('<div style="postion:absolute;top:0px;left:0px;height:100%;width:100%;'+
 204+ '-moz-opacity:.50; filter:alpha(opacity=50); opacity:.50;z-index:100">' +
 205+ '<img style="padding:10px;" src="'+
 206+ mv_embed_path + 'skins/' + mv_skin_name + '/images/loading_ani.gif">'+
 207+ '</div>');
 208+ //get a remote search object for each search provider and run the search
 209+ for(var cp_id in this.content_providers){
 210+ cp = this.content_providers[ cp_id ];
 211+ //only run the search for default item (unless combined is selected)
 212+ if( !cp.d || this.disp_item == 'combined' )
 213+ continue;
 214+ //check if we need to update:
 215+ if(typeof cp.sObj != 'undefined'){
 216+ if(cp.sObj.last_query == $j('#rsd_q').val())
 217+ continue;
 218+ }
 219+ //else we need to run the search:
 220+ var iObj = {'cp':cp, 'rsd':this};
 221+ eval('cp.sObj = new '+cp.lib+'Search(iObj);');
 222+ if(!cp.sObj)
 223+ js_log('Error: could not find search lib for ' + cp_id);
 224+ //do search:
 225+ cp.sObj.getSearchResults();
187226 }
 227+ this.checkResultsDone();
 228+ },
 229+ checkResultsDone: function(){
 230+ var _this = this;
 231+ var loading_done = true;
 232+ for(var cp_id in this.content_providers){
 233+ cp = this.content_providers[ cp_id ];
 234+ if(typeof cp['sObj'] != 'undefined'){
 235+ if( cp.sObj.loading )
 236+ loading_done=false;
 237+ }
 238+ }
 239+ if(loading_done){
 240+ this.drawOutputResults();
 241+ }else{
 242+ setTimeout( _this.instance_name + '.checkResultsDone()', 250);
 243+ }
 244+ },
 245+ drawTabs: function(){
 246+ //add the tabs to the rsd_results container:
 247+ var o= '<ul class="rsd_cp_tabs" >';
 248+ o+='<li id="rsd_tab_combined" ><img src="' + mv_embed_path + 'skins/'+mv_skin_name+ '/remote_search/combined_tab.png"></li>';
 249+ for(var cp_id in this.content_providers){
 250+ var cp = this.content_providers[cp_id];
 251+ if( cp.enabled && cp.checked){
 252+ var class_attr = (cp.d)?'class="rsd_selected"':'';
 253+ o+='<li id="rsd_tab_'+cp_id+'" ' + class_attr + '><img src="' + mv_embed_path + 'skins/' + mv_skin_name + '/remote_search/' + cp_id + '_tab.png">';
 254+ }
 255+ }
 256+ o+='</ul>';
 257+ //outout the resource results holder
 258+ o+='<div id="rsd_results" />';
 259+ $j('#rsd_results_container').html(o);
 260+ },
 261+ drawOutputResults: function(){
 262+ js_log('f:drawOutputResults');
 263+ var _this = this;
 264+ var o='';
 265+ $j('#rsd_results').empty();
 266+ //output the results bar / controls
 267+ _this.setResultBarControl();
188268
189 - var _this = this;
190 - if(this['target_submit']){
191 - $j('#'+this['target_submit']).click(function(){
192 - js_log('doSearch REQ');
193 - _this.getSearchResults();
194 - });
 269+ //output all the results (hide based on tab selection)
 270+ for(var cp_id in this.content_providers){
 271+ cp = this.content_providers[ cp_id ];
 272+ //output results based on display mode & input:
 273+ if(typeof cp['sObj'] != 'undefined'){
 274+ $j.each(cp.sObj.resultsObj, function(rInx, resultItem){
 275+ var disp = ( cp.d ) ? '' : 'display:none;';
 276+ if( _this.result_display_mode == 'box' ){
 277+ o+='<div id="mv_result_' + rInx + '" class="mv_clip_box_result res_' + cp_id +'" style="' + disp + 'width:' +
 278+ _this.thumb_width + 'px;height:'+ parseInt(_this.thumb_width) +'px">';
 279+ o+='<img style="width:' + _this.thumb_width + 'px;" src="' + resultItem.poster + '">';
 280+ o+='</div>';
 281+ }else if(_this.result_display_mode == 'list'){
 282+ o+='<div id="mv_result_' + rInx + '" class="mv_clip_list_result res_' + cp_id +'" style="' + disp + 'width:90%">';
 283+ o+='<img style="float:left;width:' + _this.thumb_width + 'px;" src="' + resultItem.poster + '">';
 284+ o+= cp.sObj.specialFormatDesc( resultItem.desc ) ;
 285+ o+='</div>';
 286+ o+='<div style="clear:both" />';
 287+ }
 288+ });
 289+ }
195290 }
196 -
197 - //set up bindings for interface components
198 - //if(this['target_input'])
199 - //@@todo autocomplete for titles
200 -
201 - //if(this['target_results')
202 - //@@todo error checking
203 -
204 - //check if we are in metavid Temporal semantic media search mode
205 - //add an "advanced search" button
206 -
207 - //add in controls: (find a better place for these / use css)
208 - //this seems highly verbose do do a simple control
 291+ js_log('should add to rsd:' + o);
 292+ //put in the new output:
 293+ $j('#rsd_results').append( o );
 294+ },
 295+ setResultBarControl:function( ){
 296+ var _this = this;
209297 var box_dark_url = mv_embed_path + 'skins/' + mv_skin_name + '/images/box_layout_icon_dark.png';
210298 var box_light_url = mv_embed_path + 'skins/' + mv_skin_name + '/images/box_layout_icon.png';
211299 var list_dark_url = mv_embed_path + 'skins/' + mv_skin_name + '/images/list_layout_icon_dark.png';
212300 var list_light_url = mv_embed_path + 'skins/' + mv_skin_name + '/images/list_layout_icon.png';
213301
214 - $j('#'+this.target_submit).after('<img id="msc_box_layout" ' +
215 - 'src = "' + ( (_this.result_display_mode=='box')?box_dark_url:box_light_url ) + '" ' +
216 - 'style="width:20px;height:20px;cursor:pointer;"> ' +
217 - '<img id="msc_list_layout" '+
218 - 'src = "' + ( (_this.result_display_mode=='list')?list_dark_url:list_light_url ) + '" '+
219 - 'style="width:20px;height:20px;cursor:pointer;">'
 302+
 303+ $j('#rsd_results').append('<div id="rds_results_bar">'+
 304+ '<span style="position:relative;top:-5px;font-style:italic;">'+
 305+ getMsg('rsd_layout')+' '+
 306+ '</span>'+
 307+ '<img id="msc_box_layout" ' +
 308+ 'title = "' + getMsg('rsd_box_layout') + '" '+
 309+ 'src = "' + ( (_this.result_display_mode=='box')?box_dark_url:box_light_url ) + '" ' +
 310+ 'style="width:20px;height:20px;cursor:pointer;"> ' +
 311+ '<img id="msc_list_layout" '+
 312+ 'title = "' + getMsg('rsd_list_layout') + '" '+
 313+ 'src = "' + ( (_this.result_display_mode=='list')?list_dark_url:list_light_url ) + '" '+
 314+ 'style="width:20px;height:20px;cursor:pointer;">'+
 315+ '<span style="position:absolute;right:5px;">'+ getMsg('rsd_results_desc', new Array('1 - 20', '420'))+'</span>'+
 316+ '</div>'
220317 );
221318
222319 $j('#msc_box_layout').hover(function(){
@@ -237,59 +334,133 @@
238335 $j('#msc_box_layout').attr("src", box_light_url);
239336 _this.setDispMode('list');
240337 });
241 -
242 - //or if we are in plain mediaWiki mode:
243 - return this;
244338 },
 339+ selectTab:function( selected_cp_id ){
 340+ js_log('select tab: ' + selected_cp_id);
 341+ this.disp_item =selected_cp_id;
 342+ //set display to unselected:
 343+ for(var cp_id in this.content_providers){
 344+ cp = this.content_providers[ cp_id ];
 345+ if( (selected_cp_id == 'combined' && cp.checked ) || selected_cp_id == cp_id){
 346+ cp.d = 1;
 347+ }else{
 348+ cp.d = 0;
 349+ }
 350+ }
 351+ //redraw tabs
 352+ this.drawTabs();
 353+ //update the search results:
 354+ this.runSearch();
 355+ },
245356 setDispMode:function(mode){
246357 js_log('setDispMode:' + mode);
247 - this.result_display_mode=mode;
248 - //reformat the results:
249 - this.formatOutputResults();
250 - },
251 - //check request done used for when we have multiple requests to check before formating results.
252 - checkRequestDone:function(){
253 - //display output if done:
254 - this.completed_req++;
255 - if(this.completed_req == this.num_req){
256 - this.formatOutputResults();
 358+ this.result_display_mode=mode;
 359+ //run /update search display:
 360+ this.drawOutputResults();
 361+ }
 362+}
 363+//default values:
 364+// tag_name@{attribute}
 365+var rsd_default_rss_item_mapping = {
 366+ 'poster' : 'media:thumbnail@url',
 367+ 'roe_url' : 'media:roe_embed@url',
 368+ 'link' : 'link',
 369+ 'desc' : 'description'
 370+}
 371+var mvBaseRemoteSearch = function(initObj) {
 372+ return this.init(initObj);
 373+};
 374+mvBaseRemoteSearch.prototype = {
 375+
 376+ completed_req:0,
 377+ num_req:0,
 378+
 379+ resultsObj:{},
 380+ //init the object:
 381+ init:function( initObj ){
 382+ js_log('mvBaseRemoteSearch:init');
 383+ for(var i in initObj){
 384+ this[i] = initObj[i];
257385 }
258 - },
259 - formatOutputResults:function(){
260 - js_log('f:formatOutputResults');
261 - //debugger;
262 - var o='';
263 - //output results based on display mode:
264 - for( var rInx in this.resultsObj ){
265 - var resultItem = this.resultsObj[rInx];
266 - if( this.result_display_mode == 'box' ){
267 - o+='<div id="mv_result_' + rInx + '" class="mv_clip_box_result" style="width:' + this.thumb_width + 'px;">';
268 - o+='<img style="width:' + this.thumb_width + 'px;" src="' + resultItem.poster + '">';
269 - o+='</div>';
270 - }else if(this.result_display_mode == 'list'){
271 - o+='<div id="mv_result_' + rInx + '" class="mv_clip_list_result" style="width:90%">';
272 - o+='<img style="float:left;width:' + this.thumb_width + 'px;" src="' + resultItem.poster + '">';
273 - o+= pageObj.revisions[0]['*'];
274 - o+='</div>';
275 - o+='<div style="clear:both" />';
276 - }
 386+ return this;
 387+ },
 388+ /*
 389+ * Parses and adds video rss based input format
 390+ * @data XML data to parse
 391+ * @provider_url the source url (used to gennerate absolute links)
 392+ */
 393+ addRSSData:function( data , provider_url ){
 394+ var _this = this;
 395+ var http_host = '';
 396+ var http_path = '';
 397+ if(provider_url){
 398+ pUrl = parseUri( provider_url );
 399+ http_host = pUrl.protocol +'://'+ pUrl.authority;
 400+ http_path = pUrl.directory;
277401 }
278 - js_log('set : ' +this.target_results + ' to ' + o);
279 - //debugger;
280 - $j('#'+this.target_results).html(o);
281 - }
 402+ items = data.getElementsByTagName('item');
 403+ $j.each(data.getElementsByTagName('item'), function(inx, item){
 404+ var rObj ={};
 405+ for(var i in rsd_default_rss_item_mapping){
 406+ var selector = rsd_default_rss_item_mapping[i].split('@');
 407+
 408+ var tag_name = selector[0];
 409+ var attr_name = null;
 410+
 411+ if( selector[1] )
 412+ attr_name = selector[1];
 413+
 414+ //grab the first match
 415+ var node = item.getElementsByTagName( tag_name )[0];
 416+ //js_log('node: ' + node + ' nv:' + $j(node).html() + ' nv[0]'+ node.innerHTML +
 417+ //' cn' + node.childNodes[0].nodeValue );
 418+
 419+ if( node!=null && attr_name == null ){
 420+ if( node.childNodes[0] != null){
 421+ rObj[i] = node.textContent;
 422+ }
 423+ }
 424+
 425+ if( node!=null && attr_name != null)
 426+ rObj[i] = $j(node).attr( attr_name );
 427+ }
 428+ //make relative urls absolute:
 429+ var url_param = new Array('src', 'poster');
 430+ for(var j=0; j < url_param.length; j++){
 431+ var p = url_param[j];
 432+ if(typeof rObj[p] != 'undefined'){
 433+ if( rObj[p].substr(0,1)=='/' ){
 434+ rObj[p] = http_host + rObj[p];
 435+ }
 436+ if( parseUri( rObj[i] ).host == rObj[p]){
 437+ rObj[p] = http_host + http_path + rObj[p];
 438+ }
 439+ }
 440+ }
 441+ _this.resultsObj[inx] = rObj;
 442+ });
 443+ },
 444+ /*
 445+ * by default just retun the desc unmodified
 446+ */
 447+ specialFormatDesc:function( desc_html) {
 448+ return desc_html;
 449+ }
282450 }
283 -
284451 /*
285452 * api modes (implementations should call these objects which inherit the mvBaseRemoteSearch
286453 */
287 -var metavidRemoteSearch = function(initObj) {
 454+var metavidSearch = function(initObj) {
288455 return this.init(initObj);
289456 };
290 -metavidRemoteSearch.prototype = {
291 - init:function(initObj){
292 - var baseSearch = new mvBaseRemoteSearch(initObj);
293 - //inherit:
 457+metavidSearch.prototype = {
 458+ rObj:{ //set up the default request paramaters
 459+ 'order':'recent',
 460+ 'feed_format':'rss'
 461+ },
 462+ init:function( initObj ){
 463+ //init base class and inherit:
 464+ var baseSearch = new mvBaseRemoteSearch( initObj );
294465 for(var i in baseSearch){
295466 if(typeof this[i] =='undefined'){
296467 this[i] = baseSearch[i];
@@ -297,16 +468,47 @@
298469 this['parent_'+i] = baseSearch[i];
299470 }
300471 }
301 - }
 472+ },
 473+ getSearchResults:function(){
 474+ var _this = this;
 475+ //start loading:
 476+ _this.loading= 1;
 477+ js_log('metavidSearch::getSearchResults()');
 478+ //proccess all options
 479+ url = this.cp.api_url;
 480+ //add on the req_param
 481+ for(var i in this.rObj){
 482+ url += '&' + i + '=' + this.rObj[i];
 483+ }
 484+ //do basic query:
 485+ url += '&f[0][t]=match&f[0][v]=' + $j('#rsd_q').val();
 486+ do_request(url, function(data){
 487+ //should have an xml rss data object:
 488+ _this.addRSSData( data , url );
 489+ //done loading:
 490+ _this.loading=0;
 491+ });
 492+ },
 493+ addRSSData:function(data, url){
 494+ this.parent_addRSSData(data, url);
 495+ //special metavid rss feed proccessing: strip mv_rss_view_only
 496+
 497+ },
 498+ /*
 499+ * special format description output.
 500+ */
 501+ specialFormatDesc:function( desc_html ){
 502+ return desc_html;
 503+ }
302504 }
303505
304 -var mediaWikiRemoteSearch = function(initObj) {
305 - return this.init(initObj);
 506+var mediaWikiSearch = function( initObj ) {
 507+ return this.init( initObj );
306508 };
307 -mediaWikiRemoteSearch.prototype = {
308 - init:function(initObj){
309 - var baseSearch = new mvBaseRemoteSearch(initObj);
310 - //inherit:
 509+mediaWikiSearch.prototype = {
 510+ init:function( initObj ){
 511+ //init base class and inherit:
 512+ var baseSearch = new mvBaseRemoteSearch( initObj );
311513 for(var i in baseSearch){
312514 if(typeof this[i] =='undefined'){
313515 this[i] = baseSearch[i];
@@ -316,39 +518,36 @@
317519 }
318520 },
319521 getSearchResults:function(){
320 - js_log('f:getSearchResults for:' + $j('#'+this.target_input).val() );
321 - //set results div to "loading"
322 - $j('#'+this.target_results).html( getMsg('loading_txt') );
 522+ var _this = this;
 523+ this.loading=true;
 524+ js_log('f:getSearchResults for:' + $j('#'+this.target_input).val() );
323525 //empty out the current results:
324526 this.resultsObj={};
325 - //do two queries against the Image / File / MVD namespace:
326 - //construct search request:
327 - var req_url =this.p_seq.plObj.interface_url.replace(/index\.php/, 'api.php');
 527+ //do two queries against the Image / File / MVD namespace:
328528 //build the image request object:
329529 var rObj = {
330530 'action':'query',
331531 'generator':'search',
332532 'gsrsearch': encodeURIComponent( $j('#'+this.target_input).val() ),
333 - 'gsrnamespace':6, //(only search images)
 533+ 'gsrnamespace':6, //(only search the "file" namespace (audio, video, images)
334534 'gsrwhat':'title',
335535 'prop':'imageinfo|revisions|categories',
336536 'iiprop':'url',
337537 'iiurlwidth':'80',
338538 'rvprop':'content'
339 - };
340 - var _this = this;
 539+ };
341540 //set up the number of request:
342541 this.completed_req=0;
343542 this.num_req=2;
344543 //setup the number of requests result flag:
345 - do_api_req( rObj, req_url, function(data){
 544+ do_api_req( rObj, this.cp.api_url , function(data){
346545 //parse the return data
347 - _this.addMediaWikiAPIResults( data);
 546+ _this.addResults( data);
348547 _this.checkRequestDone();
349548 });
350549 //also do a request for page titles (would be nice if api could query both at the same time)
351550 rObj['gsrwhat']='text';
352 - do_api_req( rObj, req_url, function(data){
 551+ do_api_req( rObj, this.cp.api_url , function(data){
353552 //parse the return data
354553 _this.addResults( data);
355554 _this.checkRequestDone();
@@ -358,13 +557,12 @@
359558 //make sure we have pages to idoerate:
360559 if(data.query && data.query.pages){
361560 for(var page_id in data.query.pages){
362 - var page = data.query.pages[ page_id ];
363 -
364 - this.resultsObj['ref'][page_id]={
 561+ var page = data.query.pages[ page_id ];
 562+ this.resultsObj[page_id]={
365563 'uri':page.title,
366564 'poster':page.imageinfo.thumburl,
367565 'src':page.imageinfo.url,
368 - 'desc':page.revisions['*'],
 566+ 'desc':page.revisions[0]['*'],
369567 'meta':{
370568 'categories':page.categories
371569 }
@@ -373,5 +571,13 @@
374572 }else{
375573 js_log('no results:' + data);
376574 }
 575+ },
 576+ //check request done used for when we have multiple requests to check before formating results.
 577+ checkRequestDone:function(){
 578+ //display output if done:
 579+ this.completed_req++;
 580+ if(this.completed_req == this.num_req){
 581+ this.loading = 0;
 582+ }
377583 }
378584 }
\ No newline at end of file

Status & tagging log