r39633 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r39632‎ | r39633 | r39634 >
Date:02:59, 19 August 2008
Author:dale
Status:old
Tags:
Comment:
updated interface components improved compatibility with SMW 1.2
Modified paths:
  • /trunk/extensions/MetavidWiki/includes/MV_Index.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_Navigator.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_Overlay.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_VideoPlayer.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_Title.php (modified) (history)
  • /trunk/extensions/MetavidWiki/languages/MV_Messages.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_data_proxy.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/sample_page.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/includes/MV_Index.php
@@ -104,7 +104,7 @@
105105 //set up select vars:
106106 $conds=$vars=array();
107107 $from_tables ='';
108 - $do_cat_lookup=false;
 108+ $do_cat_lookup=$do_smw_lookup=false;
109109 //
110110 //set mvd_type if empty:
111111 if($mvd_type==null)$mvd_type='all';
@@ -113,6 +113,7 @@
114114 $vars= array('mv_page_id as id', 'mvd_type', 'wiki_title', 'stream_id', 'start_time', 'end_time');
115115 //add in base from:
116116 $from_tables.= $dbr->tableName('mv_mvd_index');
 117+ $conds = array('stream_id'=>$stream_id);
117118 //print_r($smw_properties);
118119 if($smw_properties!=''){
119120 if(!is_array($smw_properties))
@@ -121,9 +122,36 @@
122123 if($prop_name=='category'){
123124 $do_cat_lookup=true;
124125 }else{
125 - //if(SMW_VERSION >=1.2){
126 - // $getSMWTags=true;
127 - //}else{
 126+ if(SMW_VERSION >=1.2){
 127+
 128+ //the following is too slow to use but gennerally works:
 129+ //has to be rewritten with sub-queries or something more elaborate
 130+ //for now just do lookup after the fact
 131+ $do_smw_lookup=true;
 132+ /*$esc_p = mysql_real_escape_string($prop_name);
 133+ $vars[] = $esc_p.'.`smw_title` AS `'.
 134+ $esc_p.'` ';
 135+ $from_tables.=' ,'.
 136+ ' ' . $dbr->tableName('smw_rels2') . ' as `'.$esc_p.'_rels2`'.
 137+ ' JOIN `smw_ids` AS `'.$esc_p.'_pname` '.
 138+ ' ON ( '.
 139+ ' `'.$esc_p.'_rels2`.`p_id` = `'.$esc_p.'_pname`.`smw_id`
 140+ AND `'.$esc_p.'_pname`.`smw_title` LIKE CONVERT( _utf8 '.
 141+ $dbr->addQuotes($esc_p).
 142+ ' USING latin1 ) COLLATE latin1_general_ci '.
 143+ ' ) ' .
 144+ ' LEFT JOIN `smw_ids` AS `'.$esc_p.'stext` ' .
 145+ ' ON ( '.
 146+ ' `'.$esc_p.'_rels2`.`s_id` = `'.$esc_p.'stext`.`smw_id` '.
 147+ ' ) ' .
 148+ 'LEFT JOIN `smw_ids` AS `'.mysql_real_escape_string($prop_name).'` '.
 149+ ' ON ( '.
 150+ ' `'.$esc_p.'_rels2`.`o_id` = `'.mysql_real_escape_string($prop_name).'`.`smw_id`'.
 151+ ' ) ';
 152+ $conds[]=' `'.$esc_p.'stext`.`smw_title` = `mv_mvd_index`.`wiki_title` ';
 153+ break;
 154+ */
 155+ }else{
128156 $vars[] = mysql_real_escape_string($prop_name).'.object_title as '.mysql_real_escape_string($prop_name);
129157 $from_tables.=' ' .
130158 ' LEFT JOIN '. $dbr->tableName('smw_relations') .
@@ -132,11 +160,10 @@
133161 ' = ' . mysql_real_escape_string($prop_name) . '.subject_id'.
134162 ' AND '. mysql_real_escape_string($prop_name).'.relation_title'.
135163 ' = ' . $dbr->addQuotes($prop_name) . ')';
136 - //}
 164+ }
137165 }
138166 }
139 - }
140 - $conds = array('stream_id'=>$stream_id);
 167+ }
141168 if($mvd_type!='all'){
142169 $mvd_type=(is_object($mvd_type))?get_object_vars($mvd_type):$mvd_type;
143170 if(is_array($mvd_type)){
@@ -174,6 +201,7 @@
175202 __METHOD__,
176203 $options);
177204 //print $dbr->lastQuery();
 205+ //die;
178206
179207 $ret_ary=array();
180208 $from_tables=$vars=$options=array();
@@ -189,18 +217,25 @@
190218 }
191219 }
192220
193 - //not very fast:
194 - /*if($getSMWTags){
195 - foreach($ret_ary as $row){
196 - $smwStore =& smwfGetStore();
 221+ //slow epecialy for lots of query results but join Query is crazy complicated for SMW >= 1.2
 222+ //(and I have not been able to construct it without hitting exessive number of rows in the EXPLIN)
 223+ if($do_smw_lookup){
 224+ $smwStore =& smwfGetStore();
 225+ foreach($ret_ary as & $row){
197226 $rowTitle = Title::newFromText($row->wiki_title, MV_NS_MVD);
198 - //print "Title: ".$title->getDBKey() . "\n";
199 - $smwProps = $smwStore->getSemanticData($rowTitle);
200 - foreach($smwProps as $smwProp){
201 - print "val: " . $smwProp->getValue();
202 - }
 227+ foreach($smw_properties as $propKey){
 228+ $propTitle = Title::newFromText($propKey, SMW_NS_PROPERTY);
 229+ $smwProps = $smwStore->getPropertyValues($rowTitle,$propTitle );
 230+ //just a temp hack .. we need to think about this abstraction a bit...
 231+ if(count($smwProps)!=0){
 232+ $v = current($smwProps);
 233+ $row->$propKey=$v->getXSDValue();
 234+ }
 235+ }
203236 }
204 - }*/
 237+ }
 238+ //print_r($ret_ary);
 239+ //die;
205240
206241 if($do_cat_lookup){
207242 $from_tables = $dbr->tableName('categorylinks');
Index: trunk/extensions/MetavidWiki/includes/MV_Title.php
@@ -23,7 +23,7 @@
2424 var $start_time=null;
2525 var $end_time=null;
2626 var $id = null;
27 -
 27+ var $view_count=null;
2828
2929 var $hasMVDType = false;
3030 var $dispVideoPlayerTime=false;
@@ -319,8 +319,7 @@
320320 list($vWidth, $vHeight) = explode('x',$size);
321321 }else{
322322 list($vWidth, $vHeight, $na) = MV_StreamImage::getSizeType($size);
323 - }
324 -
 323+ }
325324
326325 $stream_web_url = $this->getWebStreamURL($mvDefaultVideoQualityKey);
327326 //print "lookign for q: $mvDefaultFlashQualityKey ";
@@ -339,7 +338,9 @@
340339 $o.='thumbnail="'.$this->getStreamImageURL($size, null, $force_server).'" '.
341340 'roe="'.$roe_url.'" '.
342341 'show_meta_link="false" ';
 342+
343343 $o.= ($autoplay)?' autoplay="true" ':'';
 344+
344345 $o.='style="width:'.htmlspecialchars($vWidth).'px;height:'.htmlspecialchars($vHeight).'px" '.
345346 'controls="true" embed_link="true" >';
346347
@@ -360,6 +361,21 @@
361362 return wfMsg('mv_error_stream_missing');
362363 }
363364 }
 365+ function getViewCount(){
 366+ if($this->view_count==null){
 367+ $dbr = & wfGetDB(DB_READ);
 368+ $vars = array('COUNT(1) as hit_count');
 369+ $conds = array( 'stream_id ='.$dbr->addQuotes($this->getStreamId()),
 370+ 'start_time >= '. $this->getStartTimeSeconds(),
 371+ 'end_time <= '. $this->getEndTimeSeconds() );
 372+ $this->view_count =$dbr->selectField('mv_clipview_digest',
 373+ $vars,
 374+ $conds,
 375+ __METHOD__
 376+ );
 377+ }
 378+ return $this->view_count;
 379+ }
364380 function getTitleDesc(){
365381 if($this->type_marker){
366382 $title_str = wfMsg('mv_data_page_title',
Index: trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_Navigator.php
@@ -47,16 +47,17 @@
4848 $smw_properties=array('speech_by','bill','category'),
4949 $options=array('LIMIT'=>1, 'ORDER BY'=>$orderby)
5050 );
51 - //print "SHOULD GET $pntype for $stream_time_req";
52 - //print_r($mvd_rows);
53 - //die;
 51+ //print "SHOULD GET $pntype for $stream_time_req";
 52+ reset($mvd_rows);
5453 if(count($mvd_rows)!=0){
5554 $row = current($mvd_rows);
5655 $prev_end = $row->end_time;
5756 $stime_req = seconds2ntp($row->start_time) . '/' . seconds2ntp($row->end_time);
5857 $streamTitle = Title::newFromText($stream_name .'/'. $stime_req, MV_NS_STREAM);
59 - if(trim($row->speech_by)!=''){
60 - $o.=wfMsg('mv_'.$pntype.'_speech', $sk->makeKnownLinkObj($streamTitle, $row->speech_by));
 58+ $tool_tip ='';
 59+ if(trim($row->speech_by)!=''){
 60+ $o.=wfMsg('mv_'.$pntype.'_speech', $sk->makeKnownLinkObj($streamTitle, $row->speech_by));
 61+ $tool_tip.= 'Speech By: '. $row->speech_by;
6162 }else if(trim($row->bill)!=''){
6263 $o.=wfMsg('mv_'.$pntype.'_bill', $sk->makeKnownLinkObj($streamTitle, $row->bill));
6364 }else if(count($row->category)!=0){
Index: trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_Overlay.php
@@ -299,12 +299,14 @@
300300 $template_key = strtolower($mvdTile->getMvdTypeKey());
301301 //$wgOut->addHTML('looking at: ' . strtolower($template_key));
302302 $sk = &$wgUser->getSkin();
303 - $pre_text_html = $post_text_html='';
 303+ $pre_text_html = $post_text_html='';
 304+ $smw_text_html='';
304305 switch($template_key){
305306 case 'ht_en':
306307 case 'anno_en':
307308 $smw_attr = $this->get_and_strip_semantic_tags($text);
308309 foreach($smw_attr as $smw_key=>$smw_attr_val){
 310+ //do special display for given values:
309311 switch($smw_key){
310312 case 'speech_by':
311313 case 'spoken_by':
@@ -320,21 +322,20 @@
321323 if($mvd_page!='')
322324 $pre_text_html.='<img border="0" src="'.htmlspecialchars($mvgScriptPath).'/skins/images/button_play.png">'.'</a>';
323325 $pre_text_html.='</p>';
324 - break;
325 - default:
326 - //@@todo we should just use semantic mediaWikis info box with some custom style .
327 - $smwKeyTitle=Title::newFromText($smw_key);
328 - $valueTitle = Title::newFromText($smw_attr_val);
329 - $post_text_html.=$smwKeyTitle->getText(). ' '. $sk->makeLinkObj($valueTitle);
330 - break;
 326+ break;
331327 }
 328+ //@@todo we should just use semantic mediaWikis info box with some custom style .
 329+ $smwKeyTitle=Title::newFromText($smw_key);
 330+ $valueTitle = Title::newFromText($smw_attr_val);
 331+ if($template_key=='anno_en')
 332+ $smw_text_html.=$smwKeyTitle->getText(). ': '. $sk->makeLinkObj($valueTitle).'<br>';
332333 }
333334 $pre_text_html.='<p class="text">';
334335 if($mvd_page!=''){
335336 $pre_text_html.='<span class="mvd_menu_header">'.$this->get_mvd_menu($mvd_page).'</span>';
336337 }
337 - $pre_text_html.='<span class="description">';
338 -
 338+ $pre_text_html.='<span class="description"><br>';
 339+ $pre_text_html.=$smw_text_html;
339340 //for ht_en add spoken by add name to start of text:
340341 if( $template_key=='ht_en'){
341342 //if we have the person title add them to start of the text output:
@@ -342,8 +343,7 @@
343344 //have to prepend it cuz of <p> insertion for first paragraph
344345 $text='[['.$pTitle->getText().']]: '.trim($text);
345346 }
346 - }
347 -
 347+ }
348348 $post_text_html.='</span></p>';
349349 break;
350350 default:
Index: trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_VideoPlayer.php
@@ -10,15 +10,66 @@
1111 */
1212 if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
1313 class MV_VideoPlayer extends MV_Component{
14 - var $name = 'MV_VideoPlayer';
 14+ var $name = 'MV_VideoPlayer';
 15+ var $embed_id = 'embed_vid';
1516 function getHTML(){
1617 global $wgOut;
1718 if($this->getReqStreamName()!=null){
1819 $wgOut->addHTML($this->embed_html());
 20+ //add link helpers
 21+ $wgOut->addHTML($this->link_helpers_html());
1922 }else{
2023 $wgOut->addHTML('no stream selected');
2124 }
2225 }
 26+ function link_helpers_html(){
 27+ global $wgUser;
 28+ $o='';
 29+ $sk = & $wgUser->getSkin();
 30+ $mvTitle= & $this->mv_interface->article->mvTitle;
 31+ $file_list = $mvTitle->mvStream->getFileList();
 32+ $o.='<div id="videoMeta">
 33+ <p class="options">';
 34+ //get file list:
 35+ global $mvDefaultVideoQualityKey, $mvDefaultFlashQualityKey;
 36+ if(count($file_list)!=0){
 37+ $coma='';
 38+ $o.='<span class="download">Download Segment:';
 39+ $ogg_stream_url = $mvTitle->getWebStreamURL($mvDefaultVideoQualityKey);
 40+ if($ogg_stream_url!=''){
 41+ $o.=$coma.' <a href="'.htmlspecialchars($ogg_stream_url).'">
 42+ Web Ogg
 43+ </a>';
 44+ $coma=', ';
 45+ }
 46+ $ogg_hq_url = $mvTitle->getWebStreamURL('mv_ogg_high_quality');
 47+ if($ogg_hq_url!=''){
 48+ $o.=$coma.' <a href="'.htmlspecialchars($ogg_hq_url).'">
 49+ High Quality Ogg
 50+ </a>';
 51+ $coma=', ';
 52+ }
 53+ $flash_stream_url = $mvTitle->getWebStreamURL($mvDefaultFlashQualityKey);
 54+ if($flash_stream_url!=''){
 55+ $o.=$coma.' <a href="'.htmlspecialchars($ogg_stream_url).'">
 56+ Flash Video
 57+ </a>';
 58+ $coma=', ';
 59+ }
 60+ $o.='</span>';
 61+ $o.='<span class="download"><a href="javascript:">More Download Options</a></span>';
 62+ }
 63+ $o.='<span class="embed"><a href="javascript:hideShowEmbedCode();">Embed Video</a></span>'.
 64+ '</p>';
 65+ //about file:
 66+ $o.='<p class="about_file">
 67+ <span class="views">Views:'.htmlspecialchars($mvTitle->getViewCount()).'</span>
 68+ <span class="duration">Duration: '.htmlspecialchars($mvTitle->getSegmentDurationNTP()).'</span>
 69+ <span class="comments">na</span>
 70+ </p>
 71+ </div>';
 72+ return $o;
 73+ }
2374 function embed_html(){
2475 global $mvDefaultVideoPlaybackRes;
2576 $out='';
@@ -28,7 +79,7 @@
2980 $mvTitle->dispVideoPlayerTime=true;
3081 $vid_size = (isset($this->mv_interface->smwProperties['playback_resolution']))?
3182 $this->mv_interface->smwProperties['playback_resolution']:'';
32 - return $mvTitle->getEmbedVideoHtml('embed_vid', $vid_size);
 83+ return $mvTitle->getEmbedVideoHtml($this->embed_id, $vid_size);
3384 }
3485 function render_menu(){
3586 return 'embed video';
Index: trunk/extensions/MetavidWiki/languages/MV_Messages.php
@@ -255,8 +255,8 @@
256256 'mv_bad_tool_request' => 'bad tool line should be form: tool_name|tool_display_name',
257257 'mv_update_layers' => 'update layers view',
258258
259 - 'mv_prev_speech' => 'Previous speech: $1',
260 - 'mv_next_speech' => 'Next speech: $1',
 259+ 'mv_prev_speech' => 'Previous Speech: $1',
 260+ 'mv_next_speech' => 'Next Speech: $1',
261261 'mv_prev_bill' => 'Previous bill: $1',
262262 'mv_next_bill' => 'Next bill: $1',
263263 'mv_prev_cat' => 'Previous category: $1',
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -30,6 +30,14 @@
3131 var _global = this;
3232 var mv_init_done=false;
3333
 34+/*
 35+ * its best if you just require all your external data sources to serve up json data.
 36+ * mv_proxy is not such a good idea from security standpoint but if you know what your doing
 37+ * ie mv_data_proxy should not be hosted on domain as with any other web services running...
 38+ * you can enable it here )
 39+*/
 40+var MV_ENABLE_DATA_PROXY=false;
 41+
3442 //get mv_embed location if it has not been set
3543 if(!mv_embed_path){
3644 getMvEmbedPath();
@@ -2463,7 +2471,7 @@
24642472 });
24652473 }else{
24662474 //check if MV_embed path matches document.URL then we can use the local proxy:
2467 - if(parseUri(document.URL).host == parseUri(mv_embed_path).host ){
 2475+ if(parseUri(document.URL).host == parseUri(mv_embed_path).host && MV_ENABLE_DATA_PROXY){
24682476 js_log('use mv_embed_proxy : ' + parseUri(document.URL).host + ' == '+ parseUri(mv_embed_path).host);
24692477 //alert("do ajax req:" +req_url);
24702478 $j.ajax({
@@ -2479,14 +2487,14 @@
24802488 }else{
24812489 //get data via DOM injection of proxy request with callback
24822490 global_req_cb.push(callback);
2483 - if(!mv_json_response){
 2491+ if(!mv_json_response && MV_ENABLE_DATA_PROXY){
24842492 //@@todo should remove this functionality from mv_data_proxy
24852493 //and require sites serve up data as javascript with a callback
24862494 req_url =req_url.replace(/&/g,'__amp__');
24872495 loadExternalJs(mv_embed_path+'mv_data_proxy.php?url='+req_url+
24882496 '&cb=mv_jsdata_cb&cb_inx='+(global_req_cb.length-1) );
24892497 }else{
2490 - //response type is mv_json_response don't hit mv_data_proxy
 2498+ //response type is mv_json_response or proxy dissabled
24912499 loadExternalJs(req_url+'&cb=mv_jsdata_cb&cb_inx='+(global_req_cb.length-1));
24922500 }
24932501 }
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_data_proxy.php
@@ -8,7 +8,8 @@
99 */
1010
1111 //NOTE THIS IS DISABLED BY DEFAULT simply comment out the line below to enable;
12 -die('note mv_data_proxy is disabled by default');
 12+die('note mv_data_proxy is disabled by default, see var mv_data_proxy in mv_embed.js for more info');
 13+
1314 if(isset($_POST['url'])){
1415 $req_url = $_POST['url'];
1516 }else{
Index: trunk/extensions/MetavidWiki/skins/mv_embed/sample_page.php
@@ -114,7 +114,7 @@
115115 ?>
116116 <table border="1" cellpadding="6" width="600">
117117 <? foreach($sample_embed as $key=>$aval){
118 - if($key>3)continue;
 118+ if($key!=3)continue;
119119 ?>
120120 <tr>
121121 <td><?=$aval['tag']?></td>

Status & tagging log