function getUnifiedResultsHTML($show_sidebar = true) { global $wgUser, $wgStylePath, $wgRequest, $wgContLang; global $mvDefaultClipRange; $sk = $wgUser->getSkin(); $o = ''; $o .= '<h5 class="search_results_header">' . wfMsg('mv_results_for', $this->getFilterDesc()) . '</h5>'; $o .= '<div id="resultsArea"> <ul id="metaResults">'; if (count($this->results) == 0) { $o .= '<h2><span class="mw-headline">' . wfMsg('mv_search_no_results') . '</span></h2>'; // close $o .= '</ul></div>'; return $o; } // num of results if ($this->numResultsFound) { $re = $this->limit + $this->offset > $this->numResultsFound ? $this->numResultsFound : $this->limit + $this->offset; $rs = $this->offset == 0 ? 1 : $this->offset; $o .= '<li class="results">' . wfMsg('mv_results_found', $rs, $re, number_format($this->numResultsFound)) . '</li>'; } // check order $prevnext = ''; // pagging if ($this->numResultsFound > $this->limit) { $prevnext = mvViewPrevNext($this->offset, $this->limit, SpecialPage::getTitleFor('MediaSearch'), $this->get_httpd_filters_query(), $this->num < $this->limit); $o .= '<li class="prevnext">' . $prevnext . '</li>'; } $br = '<br />'; $enddash = ''; $sTitle = Title::MakeTitle(NS_SPECIAL, 'MvExportSearch'); // force host for script (should be a better way to do this) if (!isset($_SERVER['HTTP_HOST'])) { $_SERVER['HTTP_HOST'] = 'metavid.org'; } // make miro link: $o .= '<li class="subscribe"><a href="http://subscribe.getMiro.com/?url1=' . 'http%3A%2F%2F' . $_SERVER['HTTP_HOST'] . urlencode($sTitle->getFullUrl($this->get_httpd_filters_query())) . '" ' . 'title="Subscribe with Miro"><img src="' . $wgStylePath . '/mvpcf/images/button_subscribe.png" alt="Miro Video Player" border="0" /></a></li>'; // make rss link: $o .= '<li class="rss">'; $o .= $sk->makeKnownLinkObj($sTitle, 'RSS', $this->get_httpd_filters_query()); $o .= '</li>'; $o .= '<br />'; foreach (array('relevant', 'recent', 'viewed') as $type) { if ($this->order == $type) { $o .= $enddash . '<li class="relevant">' . wfMsg('mv_most_' . $type) . '</li>'; } else { $q_req = $this->get_httpd_filters_query(); if ($wgRequest->getVal('limit') != '' || $wgRequest->getVal('order') != '') { $q_req .= '&' . http_build_query(array('limit' => $this->limit, 'offset' => $this->offset)); } $q_req .= '&order=' . $type; $o .= $enddash . '<li class="relevant">' . $sk->makeKnownLinkObj(SpecialPage::getTitleFor('MediaSearch'), wfMsg('mv_most_' . $type), $q_req) . '</li>'; } $br = ''; $enddash = ' - '; } $o .= '</ul>'; // output results: // collect categories and people for sidebarbucket $sideBarLinkBucket = array('person' => array(), 'category' => array(), 'bill' => array()); $o .= ' <ul id="results">'; //setup the MV_index: $mvIndex = new MV_Index(); foreach ($this->results as $inx => &$mvd) { $mvTitle = new MV_Title($mvd->wiki_title); //get parent meta if requested: global $mvGetParentMeta; $pmeta_out = ''; if ($mvGetParentMeta && strtolower($mvTitle->getMvdTypeKey()) == 'ht_en') { $pmvd = $mvIndex->getParentAnnotativeLayers($mvTitle); if ($pmvd->wiki_title) { $pMvTitle = new MV_Title($pmvd->wiki_title); $pAnnoStreamLink = Title::MakeTitle(MV_NS_STREAM, $pMvTitle->getNearStreamName(0)); $clip_desc_txt = 'Segment'; if ($pmvd->Speech_by) { $personTitle = Title::newFromText($pmvd->Speech_by); $clip_desc_txt = 'Speech By ' . $personTitle->getText(); } $pmeta_out .= 'This ' . $sk->makeKnownLinkObj($pAnnoStreamLink, seconds2Description($mvTitle->getSegmentDuration(), true, true)) . ' clip is part of a larger ' . $sk->makeKnownLinkObj($pAnnoStreamLink, seconds2Description($pMvTitle->getSegmentDuration(), true, true)) . ' Speech'; if ($pmvd->category) { $pmeta_out .= '<br />Covering: '; $coma = ''; foreach ($pmvd->category as $cat_titlekey) { $cTitle = $cTitle = Title::MakeTitle(NS_CATEGORY, $cat_titlekey); $pmeta_out .= $coma . $sk->makeKnownLinkObj($cTitle, $cTitle->getText()); $coma = ', '; assoc_array_increment($sideBarLinkBucket, 'category', $cat_titlekey); } } if ($pmvd->Bill) { $pmeta_out .= '<br />Bill: '; $bTitle = Title::newFromText($pmvd->Bill); $pmeta_out .= $sk->makeKnownLinkObj($bTitle, $bTitle->getText()); assoc_array_increment($sideBarLinkBucket, 'bill', $pmvd->Bill); } } } $mvd_cnt_links = ''; if (isset($mvd->spoken_by)) { $ptitle = Title::MakeTitle(NS_MAIN, $mvd->spoken_by); $mvd_cnt_links .= wfMsg('mv_search_spoken_by') . ': ' . $sk->makeKnownLinkObj($ptitle); $mvd_cnt_links .= '<br />'; assoc_array_increment($sideBarLinkBucket, 'person', $mvd->spoken_by); } $mvd_cat_links = $mvd_bill_links = ''; $coma = ''; if (isset($mvd->categories)) { foreach ($mvd->categories as $cat_id => $na) { $cTitle = Title::MakeTitle(NS_CATEGORY, $cat_id); if ($mvd_cat_links == '') { $mvd_cat_links .= wfMsg('mv_search_categories') . ': '; } $mvd_cat_links .= $coma . $sk->makeKnownLinkObj($cTitle, $cTitle->getText()); $coma = ', '; assoc_array_increment($sideBarLinkBucket, 'category', $cat_id); } } $coma = ''; if (isset($mvd->bills)) { foreach ($mvd->bills as $bill_id => $na) { $bTitle = Title::newFromText($bill_id); if ($mvd_bill_links == '') { $mvd_bill_links .= wfMsg('mv_search_bills') . ': '; } $mvd_bill_links .= $coma . $sk->makeKnownLinkObj($bTitle, $bTitle->getText()); $coma = ', '; assoc_array_increment($sideBarLinkBucket, 'bill', $bill_id); } } // link directly to the current range: //if the clip length is < $mvDefaultClipLength get range: global $mvDefaultClipLength; if ($mvTitle->getSegmentDuration() < $mvDefaultClipLength) { $mvStreamTitle = Title::MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName($mvDefaultClipRange)); } else { $mvStreamTitle = Title::MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName(0)); } // $mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() ); $o .= '<li class="result"> <span class="vid_img" id="mvimg_' . htmlspecialchars($mvd->id) . '"> ' . $sk->makeKnownLinkObj($mvStreamTitle, '<img alt="image for ' . htmlspecialchars($mvTitle->getStreamNameText()) . ' ' . $mvTitle->getTimeDesc() . '" src="' . $mvTitle->getStreamImageURL('small', $req_time = null, $foce_server = '', $direct_link = false) . '"/>') . ' </span> <div class="result_description"> <h4>' . $sk->makeKnownLinkObj($mvStreamTitle, $mvTitle->getStreamNameText() . ' :: ' . $mvTitle->getTimeDesc()) . '</h4> <p>Matching Phrase:' . $this->termHighlight($mvd->text, implode('|', $this->getTerms()), 1, 100) . ' </p> <span class="by">' . $mvd_cnt_links . '</span> <span class="by">' . $mvd_cat_links . '</span> <span class="by">' . $mvd_bill_links . '</span> </div> <div class="result_meta"> <span class="views">Views: ' . htmlspecialchars($mvd->view_count) . '</span> <span class="duration">' . wfMsg('mv_duration_label') . ':' . htmlspecialchars($mvTitle->getSegmentDurationNTP($short_time = true)) . '</span> <span class="playinline"><a href="javascript:mv_pl(\'' . htmlspecialchars($mvd->id) . '\')">' . wfMsg('mv_play_inline') . '</a></span> </div>'; if ($pmeta_out != '') { $o .= '<div class="parent_meta">' . $pmeta_out . '</div>'; } $o .= '</li>'; } $o .= '</ul>'; // add in prev-next at bottom too: if ($this->numResultsFound > $this->limit) { $o .= '<li class="prevnext">' . $prevnext . '</li>'; } $o .= '</div>'; if (!$show_sidebar) { return $o; } /*search sidebar*/ $perSectionCount = 3; $o .= '<div id="searchSideBar"> <div id="searchSideBarTop"> </div> <div class="suggestionsBox" id="searchSideBarInner">'; // look for people matches max of 3 $first_block = ' first_block'; $matches = 0; $person_out_ary = array(); $person_out = MV_SpecialMediaSearch::auto_complete_person($this->unified_term_search, 3, 'person_html', $matches, $person_out_ary); if ($person_out != '' || count($sideBarLinkBucket['person']) != 0) { // for now don't include({$matches}) $o .= "<div class=\"block{$first_block}\">\n\t\t\t\t\t\t\t\t<h6>" . wfMsg('mv_people_results') . "</h6>\n\t\t\t\t\t\t\t</div>"; $o .= '<div class="block wide_block">'; $o .= $person_out; if (isset($sideBarLinkBucket['person'])) { $pAry =& $sideBarLinkBucket['person']; arsort($pAry); $i = 0; foreach ($pAry as $person_name => $count) { if (in_array($person_name, $person_out_ary)) { continue; } if ($i == $perSectionCount) { break; } $o .= MV_SpecialMediaSearch::format_ac_line($person_name, '', '', MV_SpecialMediaSearch::getPersonImageURL($person_name), $format = 'person_html'); $i++; } } $o .= '</div>'; $first_block = ''; } // get categories $category_out = MV_SpecialMediaSearch::auto_complete_search_categories($this->unified_term_search, 3, 'block_html', $matches); if ($category_out != '' || count($sideBarLinkBucket['category']) != 0) { $o .= '<div class="block' . htmlspecialchars($first_block) . '\\"> <h6>' . wfMsg('mv_category_results') . '</h6> </div>'; $o .= '<div class="block wide_block">' . $category_out; if (isset($sideBarLinkBucket['category'])) { $cAry =& $sideBarLinkBucket['category']; arsort($cAry); $i = 0; $catNStxt = $wgContLang->getNsText(NS_CATEGORY); foreach ($cAry as $cat_name => $count) { if ($i == $perSectionCount) { break; } $o .= MV_SpecialMediaSearch::format_ac_line($cat_name, '', $catNStxt . ':', 'no_image', $format = 'block_html'); $i++; } } $o .= '</div>'; $first_block = ''; } // get bills: $bill_out = MV_SpecialMediaSearch::auto_complete_category('Bill', $this->unified_term_search, 3, 'block_html', $matches); if ($bill_out != '' || count($sideBarLinkBucket['bill']) != 0) { global $wgContLang; $o .= '<div class=\\"block ' . htmlspecialchars($first_block) . '"> <h6>' . wfMsg('mv_bill_results') . '</h6> </div>'; $o .= '<div class="block wide_block">' . $bill_out; if ($sideBarLinkBucket['bill']) { $bAry =& $sideBarLinkBucket['bill']; arsort($bAry); $i = 0; foreach ($bAry as $bill_name => $count) { if ($i == $perSectionCount) { break; } $o .= MV_SpecialMediaSearch::format_ac_line($bill_name, '', '', 'no_image', $format = 'block_html'); $i++; } } $o .= '</div>'; $first_block = ''; } // intrest out is just simple title matching (for now) $intrest_out = MV_SpecialMediaSearch::auto_complete_category('Interest_Group', $this->unified_term_search, 3, 'block_html', $matches); if ($intrest_out != '') { $o .= "<div class=\"block{$first_block}\">\n\t\t\t\t\t\t\t\t<h6>" . wfMsg('mv_intrest_group_results') . "</h6>\n\t\t\t\t\t\t\t</div>"; $o .= '<div class="block wide_block">' . $intrest_out . '</div>'; $first_block = ''; } $o .= '</div><!--searchSideBarInner--> </div>'; $o .= '<div style="clear:both;"></div>'; return $o; }
function getResultsHTML() { global $mvgIP, $wgOut, $mvgScriptPath, $mvgContLang, $wgUser, $wgParser; $sk =& $wgUser->getSkin(); $o = ''; if ($this->outputContainer) { $o .= '<div id="mv_search_results_container">'; } //for each stream range: if (count($this->results) == 0) { $o .= '<h2><span class="mw-headline">' . wfMsg('mv_search_no_results') . '</span></h2>'; if ($this->outputContainer) { $o .= '</div>'; } return $o; } else { if ($this->outputInlineHeader) { $o .= '<h2> <span class="mw-headline">' . wfMsg('mv_media_matches') . '</span> </h2>'; $title = Title::MakeTitle(NS_SPECIAL, 'MediaSearch'); $o .= $sk->makeKnownLinkObj($title, wfMsg('mv_advaced_search'), $this->get_httpd_filters_query()); } } //media pagging: $prevnext = mvViewPrevNext($this->offset, $this->limit, SpecialPage::getTitleFor('MediaSearch'), $this->get_httpd_filters_query(), $this->num < $this->limit); $o .= "<br /><span id=\"mv_search_pagging\">{$prevnext}</span>\n"; //add the rss link: $sTitle = Title::MakeTitle(NS_SPECIAL, 'MvExportSearch'); $o .= '<span style="float:right;">'; $o .= $sk->makeKnownLinkObj($sTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/feed-icon-28x28.png">', $this->get_httpd_filters_query()); $o .= '</span>'; //add the results bar: $o .= $this->getResultsBar(); //print_r($this->results); foreach ($this->results as $stream_id => &$stream_set) { $matches = 0; $stream_out = $mvTitle = ''; foreach ($stream_set as &$srange) { $cat_html = $mvd_out = ''; $range_match = 0; foreach ($srange['rows'] as $inx => &$mvd) { $matches++; $mvTitle = new MV_Title($mvd->wiki_title); //retrieve only the first article: //$title = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title); //$article = new Article($title); $bgcolor = MV_Overlay::getMvdBgColor($mvd); //output indent if not the first and count more than one if (count($srange['rows']) != 1 && $inx != 0) { $mvd_out .= ' '; } //'<img src="'. $mvgScriptPath . '/skins/images/film.png">' //$mvd_out .= '<div class="mv_rtdesc" title="' . wfMsg('mv_expand_play') . '" '. // '> '; $mvd_out .= '<img style="float:left;width:84px;cursor:pointer;border:solid #' . $bgcolor . '" ' . ' onclick="mv_ex(\'' . $mvd->id . '\')" width="80" height="60" src="' . $mvTitle->getStreamImageURL('icon') . '">'; $mvd_out .= '</div>'; $mvd_out .= '<b>' . $mvTitle->getTimeDesc() . '</b> '; $mvd_cnt_links = ''; if (isset($mvd->spoken_by)) { $ptitle = Title::MakeTitle(NS_MAIN, $mvd->spoken_by); $mvd_cnt_links .= wfMsg('mv_search_spoken_by') . ': ' . $sk->makeKnownLinkObj($ptitle); $mvd_cnt_links .= '<br>'; } if ($this->outputSeqLinks == true) { $mvd_cnt_links .= ' <a href="javascript:mv_add_to_seq({mvclip:\'' . $mvTitle->getStreamName() . '/' . $mvTitle->getTimeRequest() . '\',' . 'src:\'' . $mvTitle->getWebStreamURL() . '\',' . 'img_url:\'' . $mvTitle->getStreamImageURL() . '\'})">' . '<img style="cursor:pointer;" ' . 'title="' . wfMsg('mv_seq_add_end') . '" ' . 'src="' . $mvgScriptPath . '/skins/mv_embed/images/application_side_expand.png">' . wfMsg('mv_seq_add_end') . '</a>'; } $mvd_cnt_links .= '<a title="' . wfMsg('mv_expand_play') . '" href="javascript:mv_ex(\'' . $mvd->id . '\')">' . '<img id="mv_img_ex_' . $mvd->id . '" src="' . $mvgScriptPath . '/skins/images/closed.png">' . '<span id="mv_watch_clip_' . $mvd->id . '">' . wfMsg('mv_watch_clip') . '</span>' . '<span style="display:none;" id="mv_close_clip_' . $mvd->id . '">' . wfMsg('mv_close_clip') . '</span>' . '</a>' . ' '; //output control links: //make stream title link: $mvStreamTitle = Title::MakeTitle(MV_NS_STREAM, $mvTitle->getNearStreamName()); //$mvTitle->getStreamName() .'/'.$mvTitle->getStartTime() .'/'. $mvTitle->getEndTime() ); $mvd_cnt_links .= $sk->makeKnownLinkObj($mvStreamTitle, '<img border="1" src="' . $mvgScriptPath . '/skins/images/run_mv_stream.png"> ' . wfMsg('mv_improve_transcript'), '', '', '', '', ' title="' . wfMsg('mv_view_in_stream_interface') . '" '); $mvd_cnt_links .= '<br>'; //$title = MakeTitle::() //don't inclue link to wiki page (too confusing) //$mvd_out .=' '; $mvdTitle = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title); //$mvd_out .= $sk->makeKnownLinkObj($mvdTitle, '<img border="0" src="' . $mvgScriptPath . '/skins/images/run_mediawiki.png">', '', '', '', '', ' title="' . wfMsg('mv_view_wiki_page') . '" '); $mvd_out .= '<span id="mvr_desc_' . $mvd->id . '">'; if (!isset($mvd->toplq)) { $mvd->toplq = false; } //output short desc send partial regEx: if (!$mvd->toplq) { $mvd_out .= $this->termHighlight($mvd->text, implode('|', $this->getTerms())); } else { if ($mvdTitle->exists() && !isset($mvd->text)) { //grab the article text: $curRevision = Revision::newFromTitle($mvdTitle); $wikiText = $curRevision->getText(); } else { $wikiText =& $mvd->text; } //@@todo parse category info if present $cat_html = ''; //run via parser to add in Category info: $parserOptions = ParserOptions::newFromUser($wgUser); $parserOptions->setEditSection(false); $parserOptions->setTidy(true); $title = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title); $parserOutput = $wgParser->parse($wikiText, $title, $parserOptions); $cats = $parserOutput->getCategories(); foreach ($cats as $catkey => $title_str) { $catTitle = Title::MakeTitle(NS_CATEGORY, $catkey); $cat_html .= ' ' . $sk->makeKnownLinkObj($catTitle); } //add category pre-text: //if ($cat_html != '') //$mvd_out.= wfMsg('Categories') . ':' . $cat_html; $mvd_out .= $cat_html; $mvd_out .= count($srange['rows']) - 1 == 1 ? wfMsg('mv_match_text_one') : wfMsg('mv_match_text', count($srange['rows']) - 1); //$wgOut->addCategoryLinks( $parserOutput->getCategories() ); //$cat_html = $sk->getCategories(); //empty out the categories //$wgOut->mCategoryLinks = array(); } $mvd_out .= '</span>'; $mvd_out .= '<br>' . $mvd_cnt_links; $mvd_out .= '<div style="display:block;clear:both;padding-top:4px;padding-bottom:4px;"/>'; $mvd_out .= '<div id="mvr_' . $mvd->id . '" style="display:none;background:#' . $bgcolor . ';" ></div>'; } $stream_out .= $mvd_out; /*if(count($srange['rows'])!=1){ $stream_out .= ' ' . $cat_html . ' In range:' . seconds2ntp($srange['s']) . ' to ' . seconds2ntp($srange['e']) . wfMsg('mv_match_text', count($srange['rows'])).'<br />' . "\n"; $stream_out .= $mvd_out; }else{ $stream_out .= $mvd_out; }*/ } $nsary = $mvgContLang->getNamespaces(); //output stream name and mach count /*$o.='<br /><img class="mv_stream_play_button" name="'.$nsary[MV_NS_STREAM].':' . $mvTitle->getStreamName() . '" align="left" src="'.$mvgScriptPath.'/skins/mv_embed/images/vid_play_sm.png">'; */ $o .= '<h3>' . $mvTitle->getStreamNameText(); $o .= $matches == 1 ? wfMsg('mv_match_text_one') : wfMsg('mv_match_text', $matches); $o .= '</h3>'; $o .= '<div id="mv_stream_' . $stream_id . '">' . $stream_out . '</div>'; } if ($this->outputContainer) { $o .= '</div>'; } return $o; }