r46851 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46850‎ | r46851 | r46852 >
Date:16:14, 5 February 2009
Author:dale
Status:deferred
Tags:
Comment:
optimized recent speeches output
added edit hooks to clip-edit button in sequencer
Modified paths:
  • /trunk/extensions/MetavidWiki/includes/MV_MagicWords.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_Stream.php (modified) (history)
  • /trunk/extensions/MetavidWiki/maintenance/metavid2mvWiki.inc.php (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)

Diff [purge]

Index: trunk/extensions/MetavidWiki/maintenance/metavid2mvWiki.inc.php
@@ -705,11 +705,11 @@
706706 include_once( 'scrape_and_insert.inc.php' );
707707 $mvScrape = new MV_BaseScraper();
708708
709 - //get all people from the people category
 709+ //get all people from the congress people category
710710 $result = $dbr->select( 'categorylinks', 'cl_sortkey', array (
711711 'cl_to' => 'Person',
712 - '`cl_sortkey` LIKE \'%' . mysql_escape_string( $val
713 - ) . '%\' COLLATE latin1_general_ci' ), __METHOD__, array (
 712+ /*'`cl_sortkey` LIKE \'%' . mysql_escape_string( $val
 713+ ) . '%\' COLLATE latin1_general_ci' ), __METHOD__, array (*/
714714 'LIMIT' => $result_limit
715715 ) );
716716 $out = '';
Index: trunk/extensions/MetavidWiki/includes/MV_Stream.php
@@ -234,9 +234,7 @@
235235 $dbw->delete('mv_clipview_digest', array('stream_id'=> $this->id ));
236236 //remove any images
237237 $dbw->delete('mv_stream_images', array('stream_id' => $this->id));
238 - //remove pointers to any files:
239 - $dbw->delete('mv_stream_images', array('stream_id' => $this->id));
240 - //remove mv_streams
 238+ //remove pointers to any files:
241239 $dbw->delete( 'mv_stream_files', array( 'stream_id' => $this->id ));
242240 }
243241 function updateStreamDB() {
Index: trunk/extensions/MetavidWiki/includes/MV_MagicWords.php
@@ -121,11 +121,11 @@
122122 function getRecentSpeeches(){
123123 $dbr = & wfGetDB( DB_READ );
124124 //do a query for speeches:
125 - $vars = array( 'query_key', 'stream_id', 'start_time', 'end_time');
126 - $conds = array( 'view_date >=' . $dbr->addQuotes( $this->getStartTime() ) );
127 - $options = array( 'GROUP BY' => 'stream_id', 'ORDER BY' => '`stream_id` DESC ',
 125+ $vars = array( '*' );
 126+ $conds = array();
 127+ $options = array( 'ORDER BY' => '`date_start_time` DESC ',
128128 'LIMIT' => intval( $this->params['num_results'] ) );
129 - $result = $dbr->select( 'mv_clipview_digest',
 129+ $result = $dbr->select( 'mv_streams',
130130 $vars,
131131 $conds,
132132 __METHOD__,
@@ -136,7 +136,10 @@
137137 } else {
138138 $outItems = Array();
139139 while ( $row = $dbr->fetchObject( $result ) ) {
140 - $o = $this->getItemOutput($row);
 140+ $row->stream_id = $row->id;
 141+ $row->end_time = $row->duration;
 142+ //get the first speech in that day:
 143+ $o = $this->getItemOutput($row, array('use_mvd_time'=>true));
141144 if($o)
142145 $outItems[]=$o;
143146 }
@@ -170,76 +173,50 @@
171174 }
172175
173176 }
174 - function getItemOutput( $row ){
 177+ function getItemOutput( $row, $opt=array() ){
175178 global $wgUser;
176179 $sk = $wgUser->getSkin();
 180+ //set defaults:
 181+ $person_ht = $bill_ht = $category_ht = $o= '';
177182
178 - $person_ht = $bill_ht = $category_ht = $o= '';
179 - // first make link and stream title:
180 - $mvStream = MV_Stream::newStreamByID( $row->stream_id );
181 - if( ! $mvStream->doesStreamExist() ){
182 - return false;
 183+ if(!isset($row->start_time)){
 184+ $row->start_time=0;
183185 }
184 - $nt = $mvStream->getStreamName() . '/' . seconds2ntp( $row->start_time )
185 - . '/' . seconds2ntp( $row->end_time );
186 - $mvTitle = new MV_Title( $nt, MV_NS_STREAM );
187 -
188 - $mvStreamTitle = Title :: MakeTitle( MV_NS_STREAM, $mvTitle->getNearStreamName( $extra_range = '0' ) );
189 -
190 -
191 - // output the image:
192 - $o .= $sk->makeKnownLinkObj( $mvStreamTitle,
193 - '<img alt="image for ' . $mvTitle->getStreamNameText() . ' ' .
194 - $mvTitle->getTimeDesc() . '" src="' . $mvTitle->getStreamImageURL( 'small' ) .
195 - '"/>',
196 - 'tl=1' );
197 -
198 - $title_span = '';
199 - if ( isset( $mvStream->date_start_time ) ) {
200 - $parts = split( '_', $mvStream->getStreamName() );
201 - if ( count( $parts ) >= 3 ) {
202 - $title_span = ucfirst( $parts[0] . ' ' );
203 - } else {
204 - $title_span = $mvStream->getStreamName();
205 - }
206 - $title_span .= date( 'F jS, Y', $mvStream->date_start_time );
207 - } else {
208 - $title_span = $mvTitle->getStreamNameText() . $mvTitle->getTimeDesc();
 186+ if(!isset($row->end_time)){
 187+ $row->end_time=60*20;
209188 }
210 - $o .= '<span class="title">' .
211 - $sk->makeKnownLinkObj( $mvStreamTitle,
212 - $title_span,
213 - 'tl=1' ) .
214 - '</span>';
215 - // try to get metadata from anno_en first.
216 - // @@todo maybe the following metadata grabbing could be abstracted to a single function in mv_index
 189+ $mvd_out_html ='';
217190 $mvd_rows = MV_Index::getMVDInRange(
218 - $row->stream_id,
219 - $row->start_time,
220 - $row->end_time,
221 - $mvd_type = 'anno_en',
222 - $getText = true,
223 - $smw_properties = array( 'Speech_by', 'Bill', 'category' ),
224 - $options = array( 'limit' => 1 )
 191+ $row->stream_id,
 192+ $row->start_time,
 193+ $row->end_time,
 194+ $mvd_type = 'anno_en',
 195+ $getText = true,
 196+ $smw_properties = array( 'Speech_by', 'Bill', 'category' ),
 197+ $options = array( 'limit' => 1 )
225198 );
226199 if ( count( $mvd_rows ) != 0 ) {
227 - reset( $mvd_rows );
 200+ reset( $mvd_rows );
228201 $mvd_row = current( $mvd_rows );
 202+ if( isset($opt['use_mvd_time']) && $opt['use_mvd_time'] ){
 203+ $row->start_time = $mvd_row->start_time;
 204+ $row->end_time = $mvd_row->end_time;
 205+ }
229206 // print_r($mvd_rows);
230207 // print "type of: " . gettype($mvd_row);
231208 if ( isset( $mvd_row->Speech_by ) ) {
232209 if ( trim( $mvd_row->Speech_by ) != '' ) {
233210 $ptitle = Title::MakeTitle( NS_MAIN, $mvd_row->Speech_by );
234 - $o .= '<span class="keywords">' .
235 - $sk->makeKnownLinkObj( $ptitle, $ptitle->getText() ) .
 211+ $mvd_out_html .= '<span class="keywords">' .
 212+ $sk->makeKnownLinkObj( $ptitle, $ptitle->getText() ) .
236213 '</span>';
237214 }
238215 }
239216 if ( isset( $mvd_row->Bill ) ) {
240217 if ( trim( $mvd_row->Bill ) != '' ) {
241218 $btitle = Title::MakeTitle( NS_MAIN, $mvd_row->Bill );
242 - $o .= '<br><span class="keywords">Bill:' .
243 - $sk->makeKnownLinkObj( $btitle ) . '
 219+ $mvd_out_html .= '<br><span class="keywords">Bill:' .
 220+ $sk->makeKnownLinkObj( $btitle ) . '
244221 </span>';
245222 }
246223 }
@@ -255,12 +232,56 @@
256233 $coma='';
257234 while($cl_row= $dbr->fetchObject($cl_res) ){
258235 $cTitle = Title::MakeTitle(NS_CATEGORY, $cl_row->cl_to);
259 - $o.=$coma.$sk->makeKnownLinkObj($cTitle, $cTitle->getText());
 236+ $mvd_out_html.=$coma.$sk->makeKnownLinkObj($cTitle, $cTitle->getText());
260237 $coma=', ';
261238 }
262 - $o.='</span>';
 239+ $mvd_out_html.='</span>';
263240 }*/
264241 }
 242+
 243+
 244+ // first make link and stream title:
 245+ $mvStream = MV_Stream::newStreamByID( $row->stream_id );
 246+ if( ! $mvStream->doesStreamExist() ){
 247+ return false;
 248+ }
 249+ //limit our output range to < 20 min
 250+ if( ($row->end_time - $row->start_time) > 20*60)
 251+ $row->end_time = $row->start_time + 20*60;
 252+
 253+ $nt = $mvStream->getStreamName() . '/' . seconds2ntp( $row->start_time )
 254+ . '/' . seconds2ntp( $row->end_time );
 255+ $mvTitle = new MV_Title( $nt, MV_NS_STREAM );
 256+
 257+ $mvStreamTitle = Title :: MakeTitle( MV_NS_STREAM, $mvTitle->getNearStreamName( $extra_range = '0' ) );
 258+
 259+
 260+ // output the image:
 261+ $o .= $sk->makeKnownLinkObj( $mvStreamTitle,
 262+ '<img alt="image for ' . $mvTitle->getStreamNameText() . ' ' .
 263+ $mvTitle->getTimeDesc() . '" src="' . $mvTitle->getStreamImageURL( 'small' ) .
 264+ '"/>',
 265+ 'tl=1' );
 266+
 267+ $title_span = '';
 268+ if ( isset( $mvStream->date_start_time ) ) {
 269+ $parts = split( '_', $mvStream->getStreamName() );
 270+ if ( count( $parts ) >= 3 ) {
 271+ $title_span = ucfirst( $parts[0] . ' ' );
 272+ } else {
 273+ $title_span = $mvStream->getStreamName();
 274+ }
 275+ $title_span .= date( 'F jS, Y', $mvStream->date_start_time );
 276+ } else {
 277+ $title_span = $mvTitle->getStreamNameText() . $mvTitle->getTimeDesc();
 278+ }
 279+ $o .= '<span class="title">' .
 280+ $sk->makeKnownLinkObj( $mvStreamTitle,
 281+ $title_span,
 282+ 'tl=1' ) .
 283+ '</span>';
 284+ //add mvd_annotative output:
 285+ $o.=$mvd_out_html;
265286 return $o;
266287 }
267288 function formatOutputItems($outItems){
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libSequencer/mv_sequencer.js
@@ -10,7 +10,7 @@
1111 *
1212 *
1313 * mv_sequencer.js
14 - * is a basic embedable sequencer.
 14+ * is a basic embeddable sequencer.
1515 * extends the playlist with drag/drop/sortable/add/remove functionality
1616 * editing of annotative content (mostly for wiki)
1717 * enables more dynamic layouts
@@ -922,10 +922,10 @@
923923 'time':0
924924 });
925925 //render out edit button
926 - track_html+='<div onClick="'+this.instance_name+'.editClip('+track_id+','+j+')" class="clip_edit_button clip_edit_base"/>';
 926+ track_html+='<div class="clip_edit_button clip_edit_base"/>';
927927
928928 //render out transition edit box
929 - track_html+='<div style="" id="tb_' + base_id + '" class="clip_trans_box"/>';
 929+ track_html+='<div id="tb_' + base_id + '" style="" class="clip_trans_box"/>';
930930
931931 //render out adjustment text
932932 track_html+='<div id="' + base_id + '_adj' + '" class="mv_adj_text" style="top:'+ (this.track_clipThumb_height+10 )+'px;">'+
@@ -936,7 +936,7 @@
937937 track_html+='</span>';
938938
939939 }
940 - //do per display type rendering:
 940+ //do timeline_mode rendering:
941941 if(this.timeline_mode == 'time'){
942942 clip.left_px = Math.round( cur_clip_time/this.timeline_scale);
943943 clip.width_px = Math.round( Math.round( clip.getDuration() )/this.timeline_scale);
@@ -980,6 +980,16 @@
981981 $j(this).removeClass("clip_edit_base").addClass("clip_edit_over");
982982 },function(){
983983 $j(this).removeClass("clip_edit_over").addClass("clip_edit_base");
 984+ }).click(function(){
 985+ //get the clip (siblings with mv_clip_thumb class)
 986+ var cur_clip_elm = $j(this).siblings('.mv_clip_thumb');
 987+ //select the clip (add mv_selected_clip if not already selected)
 988+ if( ! $j( cur_clip_elm ).hasClass("mv_selected_clip") ){
 989+ $j( cur_clip_elm ).addClass('mv_selected_clip');
 990+ $j('#' + $j( cur_clip_elm ).parent().attr("id") + '_adj').fadeIn("fast");
 991+ }
 992+ //invoke the edit resource selected resource tab:
 993+ this_seq.doEditSelectedClip();
984994 });
985995
986996 //apply onClick edit controls:
Index: trunk/extensions/MetavidWiki/skins/mv_embed/mv_embed.js
@@ -2571,7 +2571,7 @@
25722572 var this_id = (this.pc!=null)?this.pc.pp.id:this.id;
25732573
25742574 var _this=this;
2575 - var out='<span style="color:white"><blockquote style="background-color:black">';
 2575+ var out='<span style="color:#FFF;background-color:black;"><blockquote>';
25762576 var _this=this;
25772577 //js_log('selected src'+ _this.media_element.selected_source.url);
25782578 $j.each(this.media_element.getPlayableSources(), function(index, source)

Status & tagging log