r37365 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37364‎ | r37365 | r37366 >
Date:05:21, 9 July 2008
Author:dale
Status:old
Tags:
Comment:
* search digest table updates (be sure to run mv_update.php)
* #mvData:TOPSEARCHES & #mvData:POPULARCLIPS magic Functions active with arbitrary granularity for view count summaries.
* style and layout fixes.
* clip view counts per mvd_page in search results
Modified paths:
  • /branches/MetavidWiki-exp/MetavidWiki/MV_CongressDynamicData.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_DefaultSettings.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_GlobalFunctions.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_Hooks.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_Index.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_MagicWords.php (added) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_Stream.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/MV_Title.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/languages/MV_Messages.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/maintenance/mv_update.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/sample_page.php (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/skins/mv_search.js (modified) (history)
  • /branches/MetavidWiki-exp/MetavidWiki/skins/mv_stream.js (modified) (history)
  • /branches/MetavidWiki-exp/skins/mvpcf.php (modified) (history)
  • /branches/MetavidWiki-exp/skins/mvpcf/style.css (modified) (history)

Diff [purge]

Index: branches/MetavidWiki-exp/skins/mvpcf.php
@@ -89,7 +89,7 @@
9090 <?php $this->get_search_html(); ?>
9191 </div><!--searchSplash-->
9292 </div><!--frontPageTop-->
93 - <div id="frontPageContent">
 93+ <div id="frontPageContent" class="bodyContent">
9494 <!-- start content -->
9595 <?php $this->html('bodytext') ?>
9696 <?php if($this->data['catlinks']) { ?><div id="catlinks"><?php $this->html('catlinks') ?></div><?php } ?>
@@ -334,7 +334,7 @@
335335 <a name="top" id="top"></a>
336336 <?php if($this->data['sitenotice']) { ?><div id="siteNotice"><?php $this->html('sitenotice') ?></div><?php } ?>
337337 <h1 class="firstHeading"><?php $this->data['displaytitle']!=""?$this->html('title'):$this->text('title') ?></h1>
338 - <div id="bodyContent">
 338+ <div id="bodyContent" class="bodyContent">
339339 <?php if($this->data['tagline']){?><h3 id="siteSub"><?php $this->msg('tagline') ?></h3><? } ?>
340340 <div id="contentSub"><?php $this->html('subtitle') ?></div>
341341 <?php if($this->data['undelete']) { ?><div id="contentSub2"><?php $this->html('undelete') ?></div><?php } ?>
Index: branches/MetavidWiki-exp/skins/mvpcf/style.css
@@ -18,15 +18,15 @@
1919 body {
2020 margin: 0;
2121 padding: 0;
22 - font-family: Helvetica, Arial, sans-serif;
23 - font-size: .75em;
 22+ font-family: Helvetica, Arial, sans-serif;
2423 color: #474747;
25 - background: white;
 24+ background: white;
 25+ font-size:0.75em;
2626 }
2727 body#frontPage {background: #eef6ff;}
 28+.bodyContent{
 29+}
2830
29 -#bodyContent{
30 -}
3131
3232 a:link {color: #2060c1; text-decoration: underline;}
3333 a:visited {color: #2060c1; text-decoration: underline;}
@@ -40,7 +40,7 @@
4141 h3 {font-size: 16px;}
4242 h4 {font-size: 14px;}
4343 h5 {font-size: 13px; text-align: center;}
44 -h5.search_results_header {margin: 8px 0;}
 44+h5.search_results_header {margin: 8px 0; font-weight:normal;}
4545 h6 {font-size: 13px; color: #6c6c6c; padding: 5px 5px 0px 0px; text-transform: uppercase;}
4646
4747 #metaLogin {background: white; text-align: right; padding: 10px 10px 0px 10px;}
@@ -49,10 +49,11 @@
5050 /*
5151 ** the personal toolbar
5252 */
53 -#p-personal {position: absolute;left: 0;top: 0; z-index: 0;}
54 -#p-personal {width: 100%;white-space: nowrap;padding: 0;margin: 0;border: none;background: none;
 53+#p-personal {position: absolute;left: 0;top: 0; z-index: 0;
 54+ width: 100%;white-space: nowrap;padding: 0;margin: 0;border: none;background: none;
5555 overflow: visible;
5656 line-height: 1.2em;
 57+ font-size:12px;
5758 }
5859 #p-personal h5 { display: none;}
5960 #p-personal .portlet,
@@ -78,6 +79,7 @@
7980 width: 100%;white-space: nowrap;padding: 0;margin: 0;border: none;background: none;
8081 overflow: visible;
8182 line-height: 1.2em;
 83+ font-size:12px;
8284 }
8385
8486 #p-cactions h5 { display: none;}
@@ -104,6 +106,7 @@
105107 position:static;
106108 top: 20px;
107109 float:left;
 110+ font-size:13px;
108111 }
109112 #footer #p-cactions ul, #footer #p-navigation ul, #footer #p-tb ul, #footer #p-footer ul{
110113 text-align: left;
@@ -132,8 +135,7 @@
133136 }
134137 #p-personal li.active {
135138 font-weight: bold;
136 -}
137 -
 139+}
138140 #content {
139141 width: 915px;
140142 margin: 0 auto;
@@ -169,37 +171,37 @@
170172 display:none;
171173 }
172174
173 -#frontPageContent ul.popularSearches {
 175+ul.popularSearches {
174176 list-style: none;
175177 margin: 10px 0 30px 0;
176178 padding: 0;
177179 text-align: left;
178180 }
179 -#frontPageContent ul.popularSearches li {
 181+ul.popularSearches li {
180182 display: inline;
181183 font-size: 14px;
182184 margin: 0 10px 0 0;
183185 }
184 -
185 -#frontPageContent ul.popularClips {
 186+ul.popularClips {
186187 list-style: none;
187188 margin: 10px 0;
188 - padding: 0;
 189+ padding: 0;
 190+ width:780px;
189191 }
190 -#frontPageContent ul.popularClips li {
 192+ul.popularClips li {
191193 width: 161px;
192194 float: left;
193195 display: inline;
194196 text-align: center;
195197 margin: 0 28px 0 0;
196198 }
197 -#frontPageContent ul.popularClips li img {display: block;}
 199+ul.popularClips li img {display: block;}
198200
199 -#frontPageContent ul.popularClips li span.title {display: block; font-weight: bold; margin: 3px 0;}
200 -#frontPageContent ul.popularClips li span.description {display: block; margin: 3px 0;}
201 -#frontPageContent ul.popularClips li span.keywords {display: block; margin: 3px 0;}
 201+ul.popularClips li span.title {display: block; font-weight: bold; margin: 3px 0;}
 202+ul.popularClips li span.description {display: block; margin: 3px 0;}
 203+ul.popularClips li span.keywords {display: block; margin: 3px 0;}
202204
203 -#frontPageContent ul.popularSearches li.last_li, #frontPageContent ul.popularClips li.last_li {margin: 0;}
 205+ul.popularSearches li.last_li, ul.popularClips li.last_li {margin: 0;}
204206
205207
206208 /*Ajax search suggestions*/
@@ -467,7 +469,7 @@
468470
469471 p.see_more {padding: 5px 0; margin: 0;}
470472
471 -span.by {display: block; padding-bottom: 10px;}
 473+span.by {display: block; padding-bottom: 3px;}
472474 span.cats {padding-right: 20px;}
473475
474476
Index: branches/MetavidWiki-exp/MetavidWiki/maintenance/mv_update.php
@@ -9,6 +9,7 @@
1010
1111 # Attempt to connect to the database as a privileged user
1212 # This will vomit up an error if there are permissions problems
 13+
1314 $wgDatabase = new $dbclass( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1 );
1415
1516
@@ -18,27 +19,62 @@
1920
2021 //install the new search index tables:
2122 if(!$wgDatabase->tableExists('mv_search_digest')){
22 - $sql ='CREATE TABLE `mv_search_digest` (
23 - `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
24 - `query` VARCHAR( 64 ) NOT NULL ,
25 - `time` INT( 11 ) NOT NULL ,
26 - INDEX ( `query` , `time` )
27 - ) ENGINE = MYISAM';
28 - $wgDatabase->query($sql);
 23+ $wgDatabase->query('CREATE TABLE IF NOT EXISTS `mv_search_digest` (
 24+ `id` int(11) NOT NULL auto_increment,
 25+ `query_key` varchar(128) character set utf8 collate utf8_unicode_ci NOT NULL,
 26+ `time` int(11) NOT NULL,
 27+ PRIMARY KEY (`id`),
 28+ KEY `query` (`query_key`,`time`)
 29+) ENGINE=MyISAM');
2930 }
30 -if(!$wgDatabase->tableExists('mv_page_digest')){
31 - $sql=' CREATE TABLE `mv_mvd_digest` (
32 - `id` INT( 11 ) NOT NULL ,
33 - `mvd_page_id` VARCHAR( 11 ) NOT NULL ,
34 - `time` INT( 11 ) NOT NULL ,
35 - PRIMARY KEY ( `id` ) ,
36 - INDEX ( `mvd_page_id` , `time` )
37 - ) ENGINE = MYISAM ';
38 - $wgDatabase->query($sql);
 31+if(!$wgDatabase->tableExists('mv_clipview_digest')){
 32+ $wgDatabase->query(" CREATE TABLE IF NOT EXISTS `mv_clipview_digest` (
 33+ `id` int(11) NOT NULL auto_increment,
 34+ `query_key` int(33) NOT NULL,
 35+ `stream_id` int(11) unsigned NOT NULL,
 36+ `start_time` int(10) unsigned NOT NULL default '0',
 37+ `end_time` int(10) unsigned NOT NULL,
 38+ `view_date` int(11) NOT NULL,
 39+ PRIMARY KEY (`id`),
 40+ KEY `stream_id` (`stream_id`,`start_time`,`end_time`,`view_date`),
 41+ KEY `query_key` (`query_key`)
 42+) ENGINE=MyISAM ;");
3943 }
 44+if(!$wgDatabase->tableExists('mv_query_key_lookup')){
 45+ $wgDatabase->query("CREATE TABLE IF NOT EXISTS `mv_query_key_lookup` (
 46+ `query_key` varchar(128) NOT NULL,
 47+ `filters` text NOT NULL,
 48+ PRIMARY KEY (`query_key`)
 49+) ENGINE=MyISAM ;");
 50+}
4051
 52+if(!$wgDatabase->fieldExists('mv_mvd_index', 'view_count')){
 53+ $wgDatabase->query("ALTER TABLE `mv_mvd_index` ADD `view_count` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `end_time`");
 54+}
 55+//add view_count index:
 56+if(!$wgDatabase->indexExists('view_count')){
 57+ $wgDatabase->query("ALTER TABLE `mv_mvd_index` ADD INDEX ( `view_count` )");
 58+}
 59+/*modify mvd_table index structure for more "cardinality"/faster queries*/
 60+if($wgDatabase->indexExists('mvd_type')){
 61+ $wgDatabase->query("ALTER TABLE `mv_mvd_index` DROP INDEX `mvd_type`");
 62+}
 63+if($wgDatabase->indexExists('stream_id')){
 64+ $wgDatabase->query("ALTER TABLE `mv_mvd_index` DROP INDEX `stream_id`");
 65+}
 66+if($wgDatabase->indexExists('stream_time_start')){
 67+ $wgDatabase->query("ALTER TABLE `mv_mvd_index` DROP INDEX `stream_time_start`");
 68+}
 69+//add missing indexes:
 70+if(!$wgDatabase->indexExists('mvd_stream_index')){
 71+ print "rebuilding mvd index ... this may take \"some time\"\n";
 72+ $wgDatabase->query(" ALTER TABLE `mv_mvd_index` ADD INDEX `mvd_stream_index` ( `stream_id` , `start_time` , `end_time` )");
 73+}
 74+if(!$wgDatabase->indexExists('mvd_type_index')){
 75+ $wgDatabase->query(" ALTER TABLE `mv_mvd_index` ADD INDEX `mvd_type_index` (`mvd_type`, `stream_id`)");
 76+}
4177
42 -if(!$wgDatabase->fieldExists($mvIndexTableName, 'page_id')){
 78+if(!$wgDatabase->fieldExists($mvIndexTableName, 'mv_page_id')){
4379 print "$mvIndexTableName missing `page_id`...adding\n ";
4480 $page_id_added=true;
4581 //add page_id
@@ -83,8 +119,9 @@
84120 //now add UNIQUE to mv_mvd_index
85121 print "ADD PRIMARY to mv_page_id ...";
86122 $wgDatabase->query("ALTER TABLE `$mvIndexTableName` ADD PRIMARY KEY(`mv_page_id`)");
87 - print "done\n";
88 -
 123+ print "done\n";
89124 }
90125
 126+print "done with db tables update check\n";
 127+
91128 ?>
\ No newline at end of file
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_GlobalFunctions.php
@@ -53,6 +53,7 @@
5454 $wgAutoloadClasses['MV_StreamFile']=dirname(__FILE__) . '/MV_StreamFile.php';
5555 $wgAutoloadClasses['MV_StreamImage'] = dirname(__FILE__) . '/MV_StreamImage.php';
5656 $wgAutoloadClasses['MV_ParserCache'] = dirname(__FILE__) . '/MV_ParserCache.php';
 57+$wgAutoloadClasses['MV_MagicWords'] = dirname(__FILE__) . '/MV_MagicWords.php';
5758
5859 $markerList = array();
5960
@@ -112,6 +113,11 @@
113114 $wgHooks['CustomEditor'][] = 'mvCustomEditor';
114115 $wgParser->setHook( 'sequence', 'mvSeqTag' );
115116
 117+ /*$wgHooks['LanguageGetMagic'][] = 'mvMagicParserFunction_Magic';
 118+ $wgParser->setFunctionHook( 'example', 'mvMagicParserFunction_Render' );
 119+ */
 120+ $wgParser->setFunctionHook( 'mvData', 'mvMagicParserFunction_Render' );
 121+
116122 //$wgHooks['BeforePageDisplay'][] = 'mvDoSpecialPage';
117123 //$wgHooks['ArticleViewHeader'][] = 'mvArticleViewOpts';
118124 /**********************************************/
@@ -122,10 +128,41 @@
123129 'author' => 'Michael Dale',
124130 'version' => 'alpha 0.1',
125131 'url' => 'http://metavid.org',
126 - 'description' => 'Video Metadata Editor, Clip Sequencer and Media Search<br />' .
 132+ 'description' => 'Video Metadata Editor & Media Search<br />' .
127133 '[http://metavid.ucsc.edu/wiki/index.php/MetaVidWiki_Software More about MetaVidWiki Software]'
128134 );
129135 }
 136+
 137+# Define a setup function
 138+# Add a hook to initialise the magic word
 139+$wgHooks['LanguageGetMagic'][] = 'mvMagicParserFunction_Magic';
 140+
 141+function mvMagicParserFunction_Magic( &$magicWords, $langCode ) {
 142+ $magicWords['mvData'] = array( 0, 'mvData' );
 143+ return true;
 144+}
 145+
 146+function mvMagicParserFunction_Render( &$parser ) {
 147+ //gennerate arg_list array without parser param
 148+ $arg_list = array_slice(func_get_args(), 1);
 149+ $mvMagicWords = new MV_MagicWords($arg_list);
 150+ return array($mvMagicWords->renderMagic(), 'noparse'=>true, 'isHTML'=>true);
 151+}
 152+/*function mvMagicParserFunction_Magic( &$magicWords, $langCode ) {
 153+ # Add the magic word
 154+ # The first array element is case sensitive, in this case it is not case sensitive
 155+ # All remaining elements are synonyms for our parser function
 156+ $magicWords['example'] = array( 0, 'example' );
 157+ # unless we return true, other parser functions extensions won't get loaded.
 158+ return true;
 159+}
 160+
 161+function mvMagicParserFunction_Render( &$parser, $param1 = '', $param2 = '' ) {
 162+ $arg_list = func_get_args();
 163+ $mvMagic = new MV_MagicWords($arg_list);
 164+ return $mvMagic->renderMagic();
 165+}*/
 166+
130167 /**********************************************/
131168 /***** Header modifications *****/
132169 /**********************************************/
@@ -559,6 +596,27 @@
560597 //(@@todo clean up skin.php to enable better tab controls)
561598 //$title->mNamespace= NS_SPECIAL;
562599
 600+ //add a hit to the digest if enabled:
 601+ //@@todo (maybe in the future use javascript to confirm they acutally "watched" the clip)
 602+ global $mvEnableClipViewDigest, $wgRequest;
 603+ //don't log views without end times (default stream view)
 604+ if($mvEnableClipViewDigest && $mvTitle->end_time!=null && $wgRequest->getVal('tl')!='1'){
 605+ $dbw =& wfGetDB(DB_WRITE);
 606+ $dbw->insert('mv_clipview_digest', array(
 607+ 'stream_id' =>$mvTitle->getStreamId(),
 608+ 'start_time'=>$mvTitle->getStartTimeSeconds(),
 609+ 'end_time' =>$mvTitle->getEndTimeSeconds(),
 610+ 'query_key' =>$mvTitle->getStreamId().$mvTitle->getStartTimeSeconds().$mvTitle->getEndTimeSeconds(),
 611+ 'view_date' =>time()
 612+ )
 613+ );
 614+ //also increment the mvd_page if we find a match:
 615+ $dbw->update('mv_mvd_index', array('`view_count`=`view_count`+1'),
 616+ array( 'stream_id'=>$mvTitle->getStreamId(),
 617+ 'start_time'=>$mvTitle->getStartTimeSeconds(),
 618+ 'end_time' =>$mvTitle->getEndTimeSeconds()
 619+ ));
 620+ }
563621 //@@todo check if the requested title is already just the stream name:
564622 $streamTitle = Title::newFromText( $mvTitle->getStreamName(), MV_NS_STREAM);
565623 //print " new title: " . $streamTitle . "\n";
@@ -567,6 +625,7 @@
568626 mvMissingStreamPage($mvTitle->stream_name);
569627 }
570628 }
 629+
571630 /*
572631 * global MV_Stream server
573632 * @@todo cache this function
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_Stream.php
@@ -59,6 +59,7 @@
6060 function setMvTitle(&$mvTitle){
6161 $this->mvTitle=$mvTitle;
6262 }
 63+
6364 /*connivance function*/
6465 function doesStreamExist(){
6566 return $this->db_load_stream();
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_MagicWords.php
@@ -0,0 +1,212 @@
 2+<?php
 3+/*
 4+ * MV_MagicWords.php Created on May 16, 2007
 5+ *
 6+ * All Metavid Wiki code is Released under the GPL2
 7+ * for more info visit http:/metavid.ucsc.edu/code
 8+ *
 9+ * @author Michael Dale
 10+ * @email dale@ucsc.edu
 11+ * @url http://metavid.ucsc.edu
 12+ *
 13+ * magic words has all parser rewrite keys functions
 14+ * format is {{#mvData:magicTypeKey|format=format|num_results=#}} etc
 15+ */
 16+class MV_MagicWords{
 17+ var $args = array();
 18+
 19+ //list of valid arguments and their default value:
 20+ var $params = array ('format'=>'ul_list', 'num_results'=>5, 'time_range'=>'last_week','class'=>'');
 21+
 22+ function __construct($arg_list){
 23+ $this->proccessArgs($arg_list);
 24+ }
 25+ function proccessArgs($arg_list){
 26+ $this->magicTypeKey=$arg_list[0];
 27+ foreach(array_slice($arg_list, 1) as $inx=>$arg){
 28+ if(strpos($arg,'=')===false){
 29+ //get param via index order (not as reliable as param=value mode)
 30+ switch($inx){
 31+ case '0':$this->params['format']=$arg;break;
 32+ case '1':$this->params['num_results']=$arg;break;
 33+ }
 34+ }else{
 35+ list($arg_type, $arg_value) = split('=',$arg);
 36+ //make sure the arg_type is a valid argument
 37+ if(isset($this->params[$arg_type])){
 38+ $this->params[$arg_type] = $arg_value;
 39+ }
 40+ }
 41+ }
 42+ }
 43+ function renderMagic(){
 44+ switch($this->magicTypeKey){
 45+ case 'TOPSEARCHES':
 46+ return $this->getTopSearches();
 47+ break;
 48+ case 'POPULARCLIPS':
 49+ return $this->getTopClips();
 50+ break;
 51+ default:
 52+ return "error: unknown mvData function: <b>{$this->magicTypeKey}</b> <br>";
 53+ break;
 54+ }
 55+ }
 56+ function getStartTime(){
 57+ $start_time=0;
 58+ //be sure to define 'mv_date_last_week' in messeges
 59+ switch($this->params['time_range']){
 60+ case 'last_week':$start_time=time()-(7*24*60*60);break;
 61+ }
 62+ //round to nearest previus hour:
 63+ $round_sec = 60*60;
 64+ if($start_time!=0){
 65+ $start_time = floor($start_time/$round_sec)*$round_sec;
 66+ }
 67+ return $start_time;
 68+ }
 69+ //gets the top few clip ranges
 70+ function getTopClips(){
 71+ $dbr = & wfGetDB(DB_READ);
 72+ $result = $dbr->select('mv_clipview_digest', '`query_key`,`stream_id`,`start_time`, `end_time`, COUNT(1) as `hit_count`',
 73+ 'view_date >=\''.$this->getStartTime().'\'',
 74+ __METHOD__,
 75+ array('GROUP BY' => 'query_key', 'ORDER BY'=>'`hit_count` ASC',
 76+ 'LIMIT'=>($this->params['num_results']))
 77+ );
 78+ if($dbr->numRows($result)==0){
 79+ return '';
 80+ }else{
 81+ if($this->params['format']=='ul_list'){
 82+ $class_attr=($this->params['class']!='')?' class="'.$this->params['class'].'"':'';
 83+ $o.='<ul'.$class_attr.'>';
 84+ }
 85+ global $wgUser;
 86+ $sk = $wgUser->getSkin();
 87+ while($row = $dbr->fetchObject( $result )){
 88+ $o.='<li>';
 89+ $person_ht=$bill_ht=$category_ht='';
 90+ //first make link and stream title:
 91+ $mvStream = MV_Stream::newStreamByID($row->stream_id);
 92+ $nt = $mvStream->getStreamName().'/'.seconds2ntp($row->start_time)
 93+ . '/'.seconds2ntp($row->end_time);
 94+ $mvTitle = new MV_Title($nt, MV_NS_STREAM);
 95+
 96+ $mvStreamTitle = Title :: MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName($extra_range='0'));
 97+
 98+
 99+ //output the image:
 100+ $o.= $sk->makeKnownLinkObj($mvStreamTitle,
 101+ '<img alt="image for '.$mvTitle->getStreamNameText().' '.
 102+ $mvTitle->getTimeDesc().'" src="'.$mvTitle->getStreamImageURL('small').
 103+ '"/>',
 104+ 'tl=1' );
 105+
 106+ if(isset($mvStream->date_start_time)){
 107+ $parts = split('_',$mvStream->getStreamName());
 108+ if(count($parts)>=3){
 109+ $title_span = ucfirst($parts[0].' ');
 110+ }else{
 111+ $title_span = $mvStream->getStreamName();
 112+ }
 113+ $title_span.=date('F jS, Y');
 114+ }else{
 115+ $title_span = $mvTitle->getStreamNameText() . $mvTitle->getTimeDesc();
 116+ }
 117+ $o.='<span class="title">'.
 118+ $sk->makeKnownLinkObj($mvStreamTitle,
 119+ $title_span,
 120+ 'tl=1') .
 121+ '</span>';
 122+
 123+ //try to get metadata from anno_en first.
 124+ //@@todo maybe the following metadata grabbing could be abstracted to a single function in mv_index
 125+ $mvd_result = MV_Index::getMVDInRange(
 126+ $row->stream_id,
 127+ $row->start_time,
 128+ $row->end_time,
 129+ $mvd_type='anno_en',
 130+ $getText=true,
 131+ $smw_properties=array('Speech_by', 'Bill'),
 132+ $limit='LIMIT 0,1'
 133+ );
 134+ if($dbr->numRows($mvd_result)!=0){
 135+ $mvd_row = $dbr->fetchObject($mvd_result);
 136+ if($mvd_row->Speech_by){
 137+ $ptitle = Title::MakeTitle(NS_MAIN, $mvd_row->Speech_by);
 138+ $o.='<span class="keywords">Person:'.
 139+ $sk->makeKnownLinkObj($ptitle, $ptitle->getText()).
 140+ '</span>';
 141+ }
 142+ if($mvd_row->Bill){
 143+ $btitle = Title::MakeTitle(NS_MAIN, $mvd_row->Bill);
 144+ $o.='<span class="keywords">Bill:'.
 145+ $sk->makeKnownLinkObj($btitle).'
 146+ </span>';
 147+ }
 148+ global $wgContLang;
 149+ $mvdNStxt = $wgContLang->getNsText(MV_NS_MVD);
 150+ //grab categories:
 151+ $cl_res = $dbr->select('categorylinks', 'cl_to',
 152+ array('cl_sortkey'=>$mvdNStxt.':'.str_replace('_',' ',$mvd_row->wiki_title)),
 153+ 'getTopClips::Categories',
 154+ 'LIMIT 0, 5');
 155+ if($dbr->numRows($cl_res)!=0){
 156+ $o.='<span class="keywords">Categories: ';
 157+ while($cl_row= $dbr->fetchObject($cl_res) ){
 158+ $cTitle = Title::MakeTitle(NS_CATEGORY, $cl_row->cl_to);
 159+ $o.=$sk->makeKnownLinkObj($cTitle, $cTitle->getText());
 160+ }
 161+ $o.='</span>';
 162+ }
 163+
 164+ }
 165+ $o.='</li>';
 166+
 167+ }
 168+ $o.='</ul><div style="clear:both"></div>';
 169+ }
 170+ return $o;
 171+ }
 172+ //get the top few search results this is a ~slow~ query ...
 173+ //@@todo we should only run it every 2 hours or something..
 174+ function getTopSearches(){
 175+ $dbr =& wfGetDB(DB_READ);
 176+ $o='';
 177+ /*$result = $dbr->select('mv_search_digest', '`query_key`, COUNT(1) as `hit_count`', "`time` >= '$start_time' ",
 178+ __METHOD__,
 179+ array('GROUP BY' => 'query_key', 'ORDER BY `hit_count` ASC',
 180+ 'LIMIT 0,'.$this->params['num_results']) );*/
 181+ $sql="SELECT `mv_search_digest`.`query_key`, COUNT(1) as `hit_count`, `mv_query_key_lookup`.`filters`
 182+ FROM `mv_search_digest`
 183+ LEFT JOIN `mv_query_key_lookup` ON (`mv_search_digest`.`query_key` = `mv_query_key_lookup`.`query_key`)
 184+ WHERE `time` >= '{$this->getStartTime()}' GROUP BY `mv_search_digest`.`query_key`
 185+ LIMIT 0, {$this->params[num_results]}";
 186+ $result = $dbr->query($sql);
 187+ if($dbr->numRows($result)==0){
 188+ return '';
 189+ }else{
 190+ //@@todo probably should try to abstract out formating..
 191+ //but will need to wait until we have a few more test cases to do a productive abstraction
 192+ if($this->params['format']=='ul_list'){
 193+ $class_attr=($this->params['class']!='')?' class="'.$this->params['class'].'"':'';
 194+ $o.='<ul'.$class_attr.'>';
 195+ }
 196+ $mvms=new MV_SpecialMediaSearch();
 197+ $sTitle=Title::MakeTitle(NS_SPECIAL, 'MediaSearch');
 198+ while($row = $dbr->fetchObject( $result )){
 199+ $title_desc = $row->hit_count.' '.wfMsg('mv_date_'.$this->params['time_range']);
 200+ $mvms->loadFiltersFromSerialized($row->filters);
 201+ $o.='<li><a title="'.$title_desc.'" href="'.$sTitle->escapeLocalURL($mvms->get_httpd_filters_query().'&tl=1' ).'">'.
 202+ $mvms->getFilterDesc($query_key=true) .
 203+ '</li>';
 204+ }
 205+ if($this->params['format']=='ul_list'){
 206+ $o.='</ul>';
 207+ }
 208+ }
 209+ return $o;
 210+ }
 211+}
 212+
 213+?>
\ No newline at end of file
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_DefaultSettings.php
@@ -36,12 +36,12 @@
3737 //@@todo we should clean this up!... into a semantic maping array or object
3838 //if you want to include spoken by relation in search results:
3939
40 -//keeps tracks of search queries
 40+//enable dissable varius digest data collection
4141 $mvEnableSearchDigest = true;
 42+$mvEnableClipViewDigest= true;
4243 //keeps track of popular pages in given categories over time
4344 $mvDigestCategories = array('Interst_Group', 'Bill', 'Person');
4445
45 -
4646 $mvSpokenByInSearchResult = true;
4747 //if you want to include category lookup in search results:
4848 $mvCategoryInSearchResult = true;
@@ -137,13 +137,15 @@
138138 ######
139139 # the metavid table names:
140140 #######
 141+//@@todo we should just switch over to mediaWiki db helpers and write in table names
 142+//(medaiWiki can then handle table name rewriting)
141143 $mvStreamTable = 'mv_streams';
142144 $mvStreamFilesTable = 'mv_stream_files';
143145 $mvIndexTableName = 'mv_mvd_index';
144146 $mvStreamImageTable = 'mv_stream_images';
145147 $mvUrlCacheTable = 'mv_url_cache';
146 -$mvPageDigestTable = 'mv_page_digest';
147 -$mvSearchDigestTable = 'mv_search_digest';
 148+$mvPageDigestTable = 'mv_page_digest';
 149+$mvSearchDigestTable= 'mv_search_digest';
148150
149151 //whether to count found results (can take lots of time on big result sets)
150152 $mvDo_SQL_CALC_FOUND_ROWS = true;
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_Index.php
@@ -115,10 +115,10 @@
116116 $sql_from=" FROM {$dbr->tableName($mvIndexTableName)} ";
117117 if($smw_properties!=''){
118118 $smw_properties = (is_string($smw_properties))?array($smw_properties):$smw_properties;
119 - foreach($smw_properties as $prop_name){
 119+ foreach($smw_properties as $prop_name){
120120 $sql_sel.=", `$prop_name`.`object_title` as `$prop_name`";
121121 $sql_from.="LEFT JOIN `smw_relations` as `$prop_name` ON (`mv_mvd_index`.`mv_page_id`=`$prop_name`.`subject_id` " .
122 - "AND `$prop_name`.`relation_title`='$prop_name') ";
 122+ "AND `$prop_name`.`relation_title`='$prop_name') ";
123123 }
124124 }
125125 $sql = $sql_sel . $sql_from;
@@ -278,12 +278,12 @@
279279 $join_streams_with_low_ogg_sql = "JOIN `$mvStreamFilesTable` ON (`$mvIndexTableName`.`stream_id` = `$mvStreamFilesTable`.`stream_id` AND `$mvStreamFilesTable`.`file_desc_msg`='mv_ogg_low_quality') ";
280280 //only run the top range query if we have no secondary query
281281 if($toplq_cat!='' && $ftq==''){
282 - //@@todo unify top query with ranged query ... kind of tricky
 282+ //@@todo unify top query with rannged query ... kind of tricky
283283
284284 //@@todo we should only look in annotative layer for top level queries? ...
285285 //@@todo paging for top level queries? ... 200 hit limit is probably ok
286286
287 - $sql = "SELECT `mv_page_id` as `id`, `$mvIndexTableName`.`stream_id`,`start_time`,`end_time`, `wiki_title`, $searchindexTable.`si_text` as `text`
 287+ $sql = "SELECT `mv_page_id` as `id`, `$mvIndexTableName`.`stream_id`,``start_time`,`end_time`,`view_count`, `wiki_title`, $searchindexTable.`si_text` as `text`
288288 FROM `$mvIndexTableName`
289289 $date_range_join
290290 JOIN $categoryTable ON `$mvIndexTableName`.`mv_page_id` = $categoryTable.`cl_from`
@@ -299,7 +299,7 @@
300300 $top_result = $dbr->query($sql, 'MV_Index:doFiltersQuery_topQ');
301301 if($dbr->numRows($top_result)==0)return array();
302302 //set up ranges sql query
303 - $sql="SELECT $selOpt `mv_page_id` as `id`, `$mvIndexTableName`.`stream_id`,`start_time`,`end_time`, `wiki_title`, $searchindexTable.`si_text` as `text` ";
 303+ $sql="SELECT $selOpt `mv_page_id` as `id`, `$mvIndexTableName`.`stream_id`,`start_time`,`end_time`,`view_count`, `wiki_title`, $searchindexTable.`si_text` as `text` ";
304304 if($mvSpokenByInSearchResult)$sql.=",`smw_relations`.`object_title` as `spoken_by` ";
305305 $sql.="FROM `$mvIndexTableName` " .
306306 $join_streams_with_low_ogg_sql .
@@ -333,7 +333,7 @@
334334 }else{
335335 //add the top query to the base query:
336336 $ftq.=$toplq;
337 - $sql = "SELECT $selOpt `mv_page_id` as `id`,`$mvIndexTableName`.`stream_id`,`start_time`,`end_time`, `wiki_title`, $searchindexTable.`si_text` AS `text` ";
 337+ $sql = "SELECT $selOpt `mv_page_id` as `id`,`$mvIndexTableName`.`stream_id`,`start_time`,`end_time`, `view_count`,`wiki_title`, $searchindexTable.`si_text` AS `text` ";
338338 if($mvSpokenByInSearchResult)$sql.=",`smw_relations`.`object_title` as `spoken_by` ";
339339 $sql.="FROM `$mvIndexTableName`
340340 JOIN $searchindexTable ON `$mvIndexTableName`.`mv_page_id` = $searchindexTable.`si_page`
@@ -372,6 +372,7 @@
373373 $sql.="LIMIT {$this->offset}, {$this->limit} ";
374374 }
375375 //echo "SQL:".$sql." \n";
 376+ //die;
376377 $result = $dbr->query($sql, 'MV_Index:doFiltersQuery_base');
377378
378379 $this->numResults=$dbr->numRows($result);
@@ -418,9 +419,7 @@
419420 unset($stream_set[$k]);
420421 }
421422 }
422 - }
423 -
424 -
 423+ }
425424 //do category & bill lookup for search result ranges
426425 if($mvCategoryInSearchResult || $mvBillInSearchResult){
427426 $sql="SELECT {$dbr->tableName('categorylinks')}.`cl_to`, `mv_mvd_index`.`stream_id`,
@@ -458,8 +457,11 @@
459458 }
460459 }
461460 }
462 - }
463 - }
 461+ }
 462+ }
 463+ //print "<pre>";
 464+ //print_r($ret_ary);
 465+ //die;
464466 return $ret_ary;
465467 }
466468 function numResultsFound(){
Index: branches/MetavidWiki-exp/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php
@@ -136,7 +136,11 @@
137137 </form>
138138 </div>";
139139 return $o;
140 - }
 140+ }
 141+ function loadFiltersFromSerialized($sval){
 142+ $this->filters = unserialize($sval);
 143+ }
 144+
141145 function setupFilters($defaultType='empty', $opt=null){
142146 global $wgRequest;
143147
@@ -217,12 +221,22 @@
218222 global $mvEnableSearchDigest,$mvSearchDigestTable;
219223 $mvIndex = new MV_Index();
220224 //do search digest
221 - if($mvEnableSearchDigest){
 225+ global $wgRequest;
 226+ if($mvEnableSearchDigest && $wgRequest->getVal('tl')!='1') {
222227 $dbw =& wfGetDB(DB_WRITE);
223 - //@@todo non-blocking insert... is that even supported in mysql/php?
 228+ $dbr =& wfGetDB(DB_READ);
 229+ //@@todo non-blocking insert... is that supported in mysql/php?
224230 $dbw->insert($mvSearchDigestTable,
225 - array('query'=>$this->unified_term_search, 'time'=>time()),
226 - 'Database::searchDigestInsert' );
 231+ array('query_key'=>$this->getFilterDesc($query_key=true),'time'=>time()),
 232+ 'Database::searchDigestInsert' );
 233+ //make sure the query key exists and is updated
 234+ //@@todo I think we can do a INSERT IF non found here?
 235+ $res = $dbr->select('mv_query_key_lookup', array('filters'),
 236+ array('query_key'=>$this->getFilterDesc($query_key=true)));
 237+ if( $dbr->numRows($res)==0){
 238+ $dbr->insert('mv_query_key_lookup', array('query_key'=>$this->getFilterDesc($query_key=true),
 239+ 'filters'=>serialize($this->filters)));
 240+ }
227241 }
228242 $this->results = $mvIndex->doFiltersQuery($this->filters);
229243 $this->num = $mvIndex->numResults();
@@ -356,13 +370,13 @@
357371 </span>
358372 <div class="result_description">
359373 <h4>'.$head_link.'</h4>
360 - <p>Matching Phrase:' .$this->termHighlight($mvd->text, implode('|', $this->getTerms()), 2, 150).' </p>
 374+ <p>Matching Phrase:' .$this->termHighlight($mvd->text, implode('|', $this->getTerms()), 1, 100).' </p>
361375 <span class="by">'.$mvd_cnt_links.'</span>
362376 <span class="by">'.$mvd_cat_links.'</span>
363377 <span class="by">'.$mvd_bill_links.'</span>
364378 </div>
365379 <div class="result_meta">
366 - <span class="views">Views: NYA</span>
 380+ <span class="views">Views: '.$mvd->view_count.'</span>
367381 <span class="duration">'.wfMsg('mv_duration_label').':'.$mvTitle->getSegmentDurationNTP($short_time=true).'</span>
368382 <span class="comments">Comments: NYA</span>
369383 <span class="playinline"><a href="javascript:mv_pl(\'' . $mvd->id . '\')">'
@@ -853,21 +867,28 @@
854868 $o.='</div>';
855869 return $o;
856870 }
 871+ function getSearchLink(){
 872+ return SpecialPage::getTitleFor( 'MediaSearch' ) .
 873+ $this->get_httpd_filters_query();
 874+ }
857875 /*
858876 * returns human readable description of filters
859877 */
860 - function getFilterDesc(){
 878+ function getFilterDesc($query_key=false){
861879 $o=$a='';
 880+ $bo=($query_key)?'':'<b>';
 881+ $bc=($query_key)?'':'</b>';
862882 foreach($this->filters as $inx=>$f){
863 - if($inx!=0)$a=wfMsg('mv_search_'.$f['a']).' ';
864 - if($f['t']=='date_range'){ //handle special case of date range:
865 - $o.=' '.$a.wfMsg('mv_'.$f['t']).' '.wfMsg('mv_time_separator', '<b>'.$f['vs'].'</b>','<b>'.$f['ve'].'</b>');
866 - }else{
867 - $o.=' '.$a.wfMsg('mv_'.$f['t']).' <b>'. str_replace('_',' ',$f['v']).'</b> ';
 883+ if($inx!=0)$a=' '.wfMsg('mv_search_'.$f['a']).' ';
 884+ $o.=($query_key)?$a:$a.wfMsg('mv_'.$f['t']).' ';
 885+ if($f['t']=='date_range'){ //handle special case of date range:
 886+ $o.=wfMsg('mv_time_separator', $bo.$f['vs'].$bc, $bo.$f['ve'].$bc);
 887+ }else{
 888+ $o.=$bo. str_replace('_',' ',$f['v']).$bc;
868889 }
869890 }
870891 return $o;
871 - }
 892+ }
872893 function get_ref_person($inx = '', $person_name = MV_MISSING_PERSON_IMG, $disp = false) {
873894 if($disp) {
874895 $tname = 'f[' . $inx . '][v]';
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_Title.php
@@ -89,7 +89,7 @@
9090 function getStreamNameText($sn=''){
9191 if($sn=='')$sn = $this->stream_name;
9292 return ucfirst(str_replace('_', ' ',$sn));
93 - }
 93+ }
9494 /*
9595 * makes title like db key:
9696 */
@@ -198,6 +198,7 @@
199199 }
200200 return $this->stream_name . '/'.$start_ntp . $end_ntp;
201201 }
 202+
202203 function getTimeDesc(){
203204 if($this->getStartTime() && $this->getEndTime()){
204205 return wfMsg('mv_time_separator', $this->getStartTime(), $this->getEndTime());
Index: branches/MetavidWiki-exp/MetavidWiki/includes/MV_Hooks.php
@@ -137,7 +137,7 @@
138138 * by processing the given title request/namespace
139139 */
140140 function mvDoMvPage (&$title, &$article, $doOutput=true){
141 - global $wgOut;
 141+ global $wgOut;
142142 if($title->getNamespace() == NS_CATEGORY){
143143 $article = new MV_CategoryPage($title);
144144 } elseif ($title->getNamespace() == MV_NS_SEQUENCE){
Index: branches/MetavidWiki-exp/MetavidWiki/languages/MV_Messages.php
@@ -186,6 +186,7 @@
187187 'mv_search_date_range' => 'Date range',
188188 'mv_stream_name' => 'stream name',
189189 'mv_date_range' => 'date range',
 190+ 'mv_date_last_week' => 'Last Week',
190191
191192 'mv_category_results' => 'Category Results',
192193 'mv_people_results' => 'People Results',
Index: branches/MetavidWiki-exp/MetavidWiki/skins/mv_search.js
@@ -74,7 +74,7 @@
7575 case 'date_range':
7676 $j('#mvs_'+inx+'_tc').html(global_loading_txt);
7777 var load_js_set = { 'Date.fromString':'jquery/plugins/date.js',
78 - '$j.fn.datePicker':'jquery/plugins/jquery.datePicker.js'};
 78+ '$j.fn.datePicker':'jquery/plugins/mv_setup_searchjquery.datePicker.js'};
7979 if(embedTypes.msie6){
8080 js_log('using IE v6 need iframe as well');
8181 load_js_set['$j.fn.bgIframe'] = 'jquery/plugins/jquery.bgiframe.js';
Index: branches/MetavidWiki-exp/MetavidWiki/skins/mv_stream.js
@@ -719,7 +719,7 @@
720720 if(disp){
721721 //based on the embed type give space for controls:
722722 //@@todo pull pix_offset from players code
723 - switch(embedTypes.getPlayerLib()){
 723+ /*switch(embedTypes.getPlayerLib()){
724724 case 'java':
725725 case 'generic':
726726 var pix_offset= 30;
@@ -729,7 +729,9 @@
730730 case 'oggplay':
731731 var pix_offset=55;
732732 break;
733 - }
 733+ }*/
 734+ //give room for all players:
 735+ var pix_offset=55;
734736 js_log("set con space: " + org_height_vid_contain+parseInt(pix_offset));
735737 $j('#MV_VideoPlayer').css({'height':(org_height_vid_contain+parseInt(pix_offset))+'px'});
736738 $j('#MV_StreamMeta,#MV_Tools').css({'top':(org_top_tool_contain+parseInt(pix_offset))+'px'});
Index: branches/MetavidWiki-exp/MetavidWiki/skins/mv_embed/sample_page.php
@@ -24,7 +24,7 @@
2525 thumbnail="http://metavid.ucsc.edu/wiki/index.php?action=ajax&rs=mv_frame_server&stream_name=senate_proceeding_08-01-07&t=0:27:16&size=small"
2626 src="http://128.114.20.64/media/senate_proceeding_08-01-07.ogg.anx?t=0:27:16/0:27:32"
2727 roe="http://localhost/mvw-exp/index.php?title=Special:MvExportStream&feed_format=roe&stream_name=senate_proceeding_08-01-07&t=0:27:16/0:27:32"
28 -show_meta_link="false" autoplay="true" style="width:160px;height:120px" controls="true" embed_link="true" />';
 28+show_meta_link="false" autoplay="false" style="width:160px;height:120px" controls="true" embed_link="true" />';
2929 $sample_embed[0]['desc']=' auto play test (similar embed syntax to the metavidWiki site)';
3030
3131 /*$sample_embed[0]['tag']='<video id="v0" src="sample.ogg" thumbnail="sample.jpg"></video>';
Index: branches/MetavidWiki-exp/MetavidWiki/MV_CongressDynamicData.php
@@ -68,12 +68,6 @@
6969 }
7070
7171
72 -
73 -
74 -
75 -
76 -
77 -
7872 # Define a setup function
7973 $wgExtensionFunctions[] = 'wfCongressVidParserFunction_Setup';
8074 # Add a hook to initialise the magic word

Status & tagging log