r32730 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r32729‎ | r32730 | r32731 >
Date:01:27, 3 April 2008
Author:dale
Status:old
Tags:
Comment:
semantic queries now support "pod-cast" rss output for video media
Modified paths:
  • /trunk/extensions/MetavidWiki/includes/specials/MV_SpecialExport.php (modified) (history)
  • /trunk/extensions/MetavidWiki/maintenance/metavid_gov_templates.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_allpages.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/maintenance/metavid_gov_templates.php
@@ -172,7 +172,7 @@
173173 $template_body .= "{{ #if: {{{" . $name . "|}}}| [[$name:={{{" . $name . "}}}| ]] |}}";
174174 }
175175 //$template_body.='<span style="width:40%;float:left;">';
176 - $template_body.='<span style="float:right">{{navimg|xsize=50|ysize=50|image=Crystal_Clear_mimetype_video_search.png|link=Special:MediaSearch/person/{{PAGENAME}} }}</span>';
 176+ $template_body.='<span style="float:right">{{navimg|xsize=50|ysize=50|image=Crystal_Clear_mimetype_video_search.png|link=Special:MediaSearch/person/{{PAGENAME}} }}</span>';
177177 //ask for speeches media~
178178 $template_body.="\n".'{{#ask: [[Speech_by::{{PAGENAME}}]]
179179 |?Category | ?Bill
Index: trunk/extensions/MetavidWiki/includes/specials/MV_SpecialExport.php
@@ -24,11 +24,13 @@
2525 function doExportCat($par = null){$MvSpecialExport = new MV_SpecialExport('category',$par);}
2626 function doExportSeq($par = null){$MvSpecialExport = new MV_SpecialExport('sequence',$par);}
2727 function doExportSearch($par = null){$MvSpecialExport = new MV_SpecialExport('search',$par);}
 28+function doExportAsk($par =null){$MvSpecialExport = new MV_SpecialExport('ask',$par);}
2829
2930 SpecialPage::addPage( new SpecialPage('MvVideoFeed','',true,'doExportCat',false) );
3031 SpecialPage::addPage( new SpecialPage('MvExportStream','',true,'doExportStream',false) );
3132 SpecialPage::addPage( new SpecialPage('MvExportSequence','',true,'doExportSeq',false) );
3233 SpecialPage::addPage( new SpecialPage('MvExportSearch','',true,'doExportSearch',false) );
 34+SpecialPage::addPage( new SpecialPage('MvExportAsk','',true,'doExportAsk',false) );
3335
3436 //extend supported feed types:
3537 $wgFeedClasses['cmml']='CmmlFeed';
@@ -83,10 +85,12 @@
8486 $this->seq_title = $this->par;
8587 $this->get_sequence_xspf();
8688 break;
 89+ case 'ask':
 90+ $this->get_ask_feed();
 91+ break;
8792 }
88 - //@@todo cleaner exit?
8993 if($error_page==''){
90 - exit();
 94+ $wgOut->disable();
9195 }else{
9296 $wgOut->addHTML($error_page);
9397 }
@@ -268,6 +272,38 @@
269273 }
270274 if($encap)print '</cmml_set>';
271275 }
 276+ //this is dependent on semantic wiki ASK functionality
 277+ function get_ask_feed(){
 278+ global $wgSitename, $wgTitle;
 279+ //check for semantic wiki:
 280+ if(!defined('SMW_VERSION')){
 281+ return new WikiError( "Export Ask is dependent on semantic media wiki" );
 282+ }
 283+ //bootstrap off of SMWAskPage:
 284+ $SMWAskPage = new SMWAskPage();
 285+ $SMWAskPage->extractQueryParameters($this->par);
 286+
 287+ //print 'query string: ' . $SMWAskPage->m_querystring . "\n<br>";
 288+ //print 'm_params: ' . print_r($SMWAskPage->m_params) . "\n<br>";
 289+ //print 'print outs: ' .print_r($SMWAskPage->m_printouts) . "\n<br>";
 290+ //set up the feed:
 291+ $this->feed = new mvRSSFeed(
 292+ $wgSitename . ' - ' .wfMsg('mediasearch'). ' : '. strip_tags($SMWAskPage->m_querystring), //title
 293+ strip_tags($SMWAskPage->m_querystring), //description
 294+ $wgTitle->getFullUrl() //link
 295+ );
 296+ $this->feed->outHeader();
 297+
 298+ $queryobj = SMWQueryProcessor::createQuery($SMWAskPage->m_querystring, $SMWAskPage->m_params, false, '', $SMWAskPage->m_printouts);
 299+ $res = smwfGetStore()->getQueryResult($queryobj);
 300+ $row = $res->getNext();
 301+ while ( $row !== false ) {
 302+ $wikititle = $row[0]->getNextObject();
 303+ $this->feed->outPutItem($wikititle->getTitle());
 304+ $row = $res->getNext();
 305+ }
 306+ $this->feed->outFooter();
 307+ }
272308 // @@todo integrate cache query (similar to SpecialRecentChanges::rcOutputFeed ))
273309 function get_category_feed(){
274310 global $wgSitename, $wgRequest, $wgOut, $wgCategoryPagingLimit;
@@ -398,9 +434,11 @@
399435 global $wgOut;
400436 $mvTitle = new MV_Title($wikiTitle);
401437 $mStreamTitle = Title::makeTitle(MV_NS_STREAM, ucfirst($mvTitle->getStreamName()) . '/'.$mvTitle->getTimeRequest());
 438+
 439+ //only output media RSS item if its valid media:
 440+ if(!$mvTitle->validRequestTitle())return ;
402441
403 - //@@todo this should be done cleaner/cached
404 - //@@todo we need absolute links
 442+ //@@todo this should be cached
405443 $thumb_ref = $mvTitle->getStreamImageURL('320x240');
406444 if($desc_html==''){
407445 $article = new Article($wikiTitle);
@@ -424,7 +462,7 @@
425463 $time_desc = ($mvTitle->getTimeDesc())?$mvTitle->getTimeDesc():'';
426464 ?>
427465 <item>
428 - <link><?=mvRSSFeed::xmlEncode($wikiTitle->getFullUrl())?></link>
 466+ <link><?=mvRSSFeed::xmlEncode($mStreamTitle->getFullUrl())?></link>
429467 <title><?=mvRSSFeed::xmlEncode(
430468 $mvTitle->getStreamNameText() . ' ' . $time_desc)?></title>
431469 <description><?=$desc_xml?></description>
Index: trunk/extensions/MetavidWiki/skins/mv_allpages.js
@@ -5,7 +5,7 @@
66 var base_roe_url = wgServer + wgScript + '?title=Special:MvExportStream&feed_format=roe&stream_name=';
77 var gMvd={};
88 function mv_setup_allpage(){
9 - js_log("mv embed done loading now setup all page");
 9+ js_log("mv embed done loading now setup 'all page'");
1010 //make sure we have jQuery and any base requried libs:
1111 mvJsLoader.doLoad(mvEmbed.lib_jquery, function(){
1212 _global['$j'] = jQuery.noConflict();
@@ -19,8 +19,44 @@
2020 mv_setup_search_ac();
2121 mv_do_mvd_link_rewrite();
2222 mv_setup_allpage_flag=true;
 23+ mv_page_specific_rewrites();
2324 }
2425 });
 26+ });
 27+}
 28+function mv_page_specific_rewrites(){
 29+ var mvAskTitle = 'Special:MvExportAsk';
 30+ var rssImg = '<img border="0" src="'+wgScriptPath+'/extensions/MetavidWiki/skins/images/feed-icon-28x28.png"/>';
 31+ var msg_video_rss = 'video rss';
 32+ //add in rss-media feed link if on Special:Ask page
 33+ if(wgPageName=='Special:Ask'){
 34+ js_log("url : " + document.location);
 35+ var sURL = parseUri(document.location);
 36+ var podLink=wgArticlePath.replace('$1', mvAskTitle);
 37+ if(sURL.queryKey['title']){
 38+ //pass along all url params (update the title)
 39+ podLink+='?';
 40+ for(i in sURL.queryKey){
 41+ if(i !='title')podLink+=i+'='+sURL.queryKey[i];
 42+ }
 43+ }else{
 44+ // /title/askparam format
 45+ var pInx =sURL.relative.indexOf(wgPageName);
 46+ if(pInx!==false){
 47+ podLink+= sURL.relative.substring(pInx+wgPageName.length);
 48+ }
 49+ }
 50+ //@@todo add to javascript msg system
 51+ $j('#bodyContent').before('<span style="float: right;"><a title="'+
 52+ msg_video_rss+'" href="'+podLink+'">'+ rssImg + '</a></span>');
 53+ }
 54+ //if we have an inline query add a search link
 55+ $j('.smwtable').each(function(){
 56+ var pLink = $j('#'+this.id+' .smwfooter a').attr('href').replace('Special:Ask',mvAskTitle );
 57+ var colspan = $j('.smwfooter .sortbottom').attr('colspan');
 58+ var pHTML = '<a title="'+msg_video_rss+'" href="'+pLink+'">'+rssImg+'</a>';
 59+ js_log("plink: "+pLink + ' colspan:'+ colspan + ' ph:'+pHTML);
 60+ $j('#'+this.id+' tbody').prepend('<tr><td colspan="'+colspan+'">'+pHTML+'</td></tr>');
2561 });
2662 }
2763 function mv_do_mvd_link_rewrite(){

Status & tagging log