function getExportUrl() { $exportTitle = Title::MakeTitle(NS_SPECIAL, 'MvExportSequence/' . $this->seqTitle->getDBkey()); $export_url = $exportTitle->getFullURL(); if ($this->oldid != '') { $ss = strpos($export_url, '?') === false ? '?' : '&'; $export_url .= $ss . 'oldid=' . htmlspecialchars($this->oldid); } return $export_url; }
protected function feedItem($row) { $title = Title::MakeTitle(intval($row->page_namespace), $row->page_title); if ($title) { $date = $row->rev_timestamp; $comments = $title->getTalkPage()->getFullURL(); $revision = Revision::newFromRow($row); return new FeedItem($title->getPrefixedText(), $this->feedItemDesc($revision), $title->getFullURL(), $date, $this->feedItemAuthor($revision), $comments); } else { return null; } }
function getHTML() { global $wgOut, $wgTitle, $wgRequest; $article =& $this->mv_interface->article; $title = Title::MakeTitle(NS_SPECIAL, 'MvExportSequence/' . $article->mTitle->getDBKey()); $title_url = $title->getFullURL(); $oldid = $wgRequest->getVal('oldid'); if (isset($oldid)) { //@@ugly hack .. but really this whole sequencer needs a serious rewrite) $ss = strpos($title_url, '?') === false ? '?' : '&'; $title_url .= $ss . 'oldid=' . $oldid; } //'<playlist id="mv_pl">'. //@@todo look at mv_interface context to get what to display in tool box: $wgOut->addHTML('' . '<div style="position:absolute;width:320px;height:270px;" id="mv_video_container">' . '<div style="display:none;" id="mv_pl_url">' . $title_url . '</div>' . '</div>' . "\n"); }
protected function feedItem($row) { $title = Title::MakeTitle(intval($row->rc_namespace), $row->rc_title); if ($title) { $date = $row->rc_timestamp; $comments = $title->getTalkPage()->getFullURL(); return new FeedItem($title->getPrefixedText(), $this->feedItemDesc($row), $title->getFullURL(), $date, $this->feedItemAuthor($row), $comments); } else { return NULL; } }
function get_search_feed(){ global $wgSitename, $wgOut; //set up search obj: $sms = new MV_SpecialMediaSearch(); //setup filters: $sms->setUpFilters(); //do the search: $sms->doSearch(); //get the search page title: $msTitle = Title::MakeTitle(NS_SPECIAL, 'MediaSearch'); $this->feed = new mvRSSFeed( $wgSitename . ' - ' .wfMsg('mediasearch'). ' : '. strip_tags($sms->getFilterDesc()), //title strip_tags($sms->getFilterDesc()), //description $msTitle->getFullUrl().'?'.$sms->get_httpd_filters_query() //link ); $this->feed->outHeader(); $MV_Overlay = new MV_Overlay(); //for each search result: foreach ($sms->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++; //get Stream title for mvd match: $mvTitle = new MV_Title($mvd->wiki_title); $stremTitle = Title::MakeTitle(MV_NS_STREAM, $mvTitle->getStreamName().'/'.$mvTitle->getTimeRequest() ); $this->feed->outPutItem($stremTitle, $MV_Overlay->getMVDhtml($mvd, $absolute_links=true)); } } } $this->feed->outFooter(); }
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; }
function getTopSearches() { $dbr = wfGetDB(DB_READ); $o = ''; $options = array(); /*$result = $dbr->select('mv_search_digest', '`query_key`, COUNT(1) as `hit_count`', "`time` >= '$start_time' ", __METHOD__, array('GROUP BY' => 'query_key', 'ORDER BY `hit_count` ASC', 'LIMIT 0,'.$this->params['num_results']) );*/ /*$sql="SELECT `mv_search_digest`.`query_key`, COUNT(1) as `hit_count`, `mv_query_key_lookup`.`filters` FROM `mv_search_digest` LEFT JOIN `mv_query_key_lookup` ON (`mv_search_digest`.`query_key` = `mv_query_key_lookup`.`query_key`) WHERE `time` >= '{$this->getStartTime()}' GROUP BY `mv_search_digest`.`query_key` LIMIT 0, {$this->params[num_results]}";*/ // $from_tables $vars = array($dbr->tableName('mv_search_digest') . '.query_key', 'COUNT(1) as `hit_count`', $dbr->tableName('mv_query_key_lookup') . '.filters'); $from_tables = $dbr->tableName('mv_search_digest') . ' JOIN' . $dbr->tableName('mv_query_key_lookup') . ' ON ( ' . $dbr->tableName('mv_search_digest') . '.query_key = ' . $dbr->tableName('mv_query_key_lookup') . '.query_key ' . ' ) '; $conds = '`time` >= ' . $dbr->addQuotes($this->getStartTime()); $options['GROUP BY'] = $dbr->tableName('mv_search_digest') . '.query_key'; $options['ORDER BY'] = '`hit_count` DESC'; $options['LIMIT'] = $this->params['num_results']; $result = $dbr->select($from_tables, $vars, $conds, __METHOD__, $options); if ($dbr->numRows($result) == 0) { return ''; } else { // @@todo probably should try to abstract out formating.. // but will need to wait until we have a few more test cases to do a productive abstraction if ($this->params['format'] == 'ul_list') { $class_attr = $this->params['class'] != '' ? ' class="' . htmlspecialchars($this->params['class']) . '"' : ''; $o .= '<ul' . $class_attr . '>'; } $mvms = new MV_SpecialMediaSearch(); $sTitle = Title::MakeTitle(NS_SPECIAL, 'MediaSearch'); while ($row = $dbr->fetchObject($result)) { $title_desc = htmlspecialchars($row->hit_count) . ' ' . wfMsg('mv_date_' . $this->params['time_range']); $mvms->loadFiltersFromSerialized($row->filters); $o .= '<li><a title="' . $title_desc . '" href="' . $sTitle->escapeLocalURL($mvms->get_httpd_filters_query() . '&tl=1') . '">' . $mvms->getFilterDesc($query_key = true) . '</li>'; } if ($this->params['format'] == 'ul_list') { $o .= '</ul>'; } } return $o; }
function imageLinks() { global $wgUser, $wgOut; $wgOut->addHTML('<h2 id="filelinks">' . wfMsg('imagelinks') . "</h2>\n"); $dbr =& wfGetDB(DB_SLAVE); $page = $dbr->tableName('page'); $imagelinks = $dbr->tableName('imagelinks'); $sql = "SELECT page_namespace,page_title FROM {$imagelinks},{$page} WHERE il_to=" . $dbr->addQuotes($this->mTitle->getDBkey()) . " AND il_from=page_id"; $sql = $dbr->limitResult($sql, 500, 0); $res = $dbr->query($sql, "ImagePage::imageLinks"); if (0 == $dbr->numRows($res)) { $wgOut->addHtml('<p>' . wfMsg("nolinkstoimage") . "</p>\n"); return; } $wgOut->addHTML('<p>' . wfMsg('linkstoimage') . "</p>\n<ul>"); $sk = $wgUser->getSkin(); while ($s = $dbr->fetchObject($res)) { $name = Title::MakeTitle($s->page_namespace, $s->page_title); $link = $sk->makeKnownLinkObj($name, ""); $wgOut->addHTML("<li>{$link}</li>\n"); } $wgOut->addHTML("</ul>\n"); }
function toHTML() { global $wgLang, $mvDefaultAspectRatio; $sk = $this->getSkin(); $attribs = Sanitizer::mergeAttributes(array('class' => 'gallery', 'cellspacing' => '0', 'cellpadding' => '0'), $this->mAttribs); $s = Xml::openElement('table', $attribs); if ($this->mCaption) { $s .= "\n\t<caption>" . htmlspecialchars($this->mCaption) . "</caption>"; } $params = array('width' => $this->mWidths, 'height' => $this->mHeights); $i = 0; $this->already_named_resource = array(); foreach ($this->mImages as $pair) { $nt = $pair[0]; $text = $pair[1]; # Give extensions a chance to select the file revision for us $time = false; wfRunHooks('BeforeGalleryFindFile', array(&$this, &$nt, &$time)); $img = wfFindFile($nt, array('time' => $time)); if ($nt->getNamespace() == MV_NS_MVD || $nt->getNamespace() == MV_NS_STREAM || $nt->getNamespace() == MV_NS_SEQUENCE) { // @@todo fix sequence embed // $vpad = floor( ( 1.25*$this->mHeights - $thumb->height ) /2 ) - 2; $mvTitle = new MV_Title($nt); // remap MVD namespace links into the Stream view (so contextual metadata is present) if ($nt->getNamespace() == MV_NS_MVD) { $nt = Title::MakeTitle(MV_NS_STREAM, ucfirst($mvTitle->getStreamName()) . '/' . $mvTitle->getTimeRequest()); } $vidH = round($this->mWidths * $mvDefaultAspectRatio); $vidRes = $this->mWidths . 'x' . $vidH; // print "img url: " . $mvTitle->getStreamImageURL(); $thumbhtml = "\n\t\t\t" . '<div class="thumb" style="padding: 4px 0; width: ' . htmlspecialchars($this->mWidths + 5) . 'px;">' . '<div style="margin-left: auto; margin-right: auto; width: ' . htmlspecialchars($this->mWidths) . 'px;">' . $sk->makeKnownLinkObj($nt, '<img title="' . htmlspecialchars($mvTitle->getStreamNameText()) . '"' . ' width="160" height="120" src="' . $mvTitle->getStreamImageURL('160x120') . '">') . '</div>' . '</div>' . '<span class="gallerytext" style="float:left">' . $sk->makeKnownLinkObj($nt, $mvTitle->getStreamNameText() . ' ' . $mvTitle->getTimeDesc()) . '</span>' . '</div>'; $nb = ''; $textlink = ''; } else { if ($nt->getNamespace() != NS_IMAGE || !$img) { # We're dealing with a non-image, spit out the name and be done with it. $thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . htmlspecialchars($nt->getText()) . '</div>'; } elseif ($this->mHideBadImages && wfIsBadImage($nt->getDBkey(), $this->getContextTitle())) { # The image is blacklisted, just show it as a text link. $thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . $sk->makeKnownLinkObj($nt, htmlspecialchars($nt->getText())) . '</div>'; } elseif (!($thumb = $img->transform($params))) { # Error generating thumbnail. $thumbhtml = "\n\t\t\t" . '<div style="height: ' . ($this->mHeights * 1.25 + 2) . 'px;">' . htmlspecialchars($img->getLastError()) . '</div>'; } else { $vpad = floor((1.25 * $this->mHeights - $thumb->height) / 2) - 2; $thumbhtml = "\n\t\t\t" . '<div class="thumb" style="padding: ' . htmlspecialchars($vpad) . 'px 0; width: ' . htmlspecialchars($this->mWidths + 30) . 'px;">' . '<div style="margin-left: auto; margin-right: auto; width: ' . htmlspecialchars($this->mWidths) . 'px;">' . $thumb->toHtml(array('desc-link' => true)) . '</div></div>'; // Call parser transform hook if ($this->mParser && $img->getHandler()) { $img->getHandler()->parserTransformHook($this->mParser, $img); } } if ($this->mShowBytes) { if ($img) { $nb = wfMsgExt('nbytes', array('parsemag', 'escape'), $wgLang->formatNum($img->getSize())); } else { $nb = wfMsgHtml('filemissing'); } $nb = "{$nb}<br />\n"; } else { $nb = ''; } $textlink = $this->mShowFilename ? $sk->makeKnownLinkObj($nt, htmlspecialchars($wgLang->truncate($nt->getText(), 20))) . "<br />\n" : ''; } # ATTENTION: The newline after <div class="gallerytext"> is needed to accommodate htmltidy which # in version 4.8.6 generated crackpot html in its absence, see: # http://bugzilla.wikimedia.org/show_bug.cgi?id=1765 -Ævar if ($i % $this->mPerRow == 0) { $s .= "\n\t<tr>"; } $s .= "\n\t\t" . '<td><div class="gallerybox" style="width: ' . ($this->mWidths + 10) . 'px;">' . $thumbhtml . "\n\t\t\t" . '<div class="gallerytext">' . "\n" . $textlink . htmlspecialchars($text) . $nb . "\n\t\t\t</div>" . "\n\t\t</div></td>"; if ($i % $this->mPerRow == $this->mPerRow - 1) { $s .= "\n\t</tr>"; } ++$i; } if ($i % $this->mPerRow != 0) { $s .= "\n\t</tr>"; } $s .= "\n</table>"; return $s; }
function wfNotifyTwitterOnNAB($aid) { $t = Title::newfromID($aid); if (!$t) { // could have been deleted return true; } $r = Revision::newFromTitle($t); if (!$r) { return true; } $text = $r->getText(); if (MyTwitter::hasBadTemplate($text)) { return true; } // find new cats - like kittens! $newcats = array(); preg_match_all("@\\[\\[Category:[^\\]]*\\]\\]@", $text, $matches); $newcats = array(); if (sizeof($matches[0]) > 0) { $newcats = $matches[0]; } foreach ($newcats as $cat) { // make it a title object $cat = str_replace("[[Category:", "", $cat); $cat = str_replace("]]", "", $cat); $cat = Title::makeTitle(NS_CATEGORY, $cat); wfNotifyTwitter($cat, $t); } $cat = Title::MakeTitle(NS_CATEGORY, "New Article Boost"); wfNotifyTwitter($cat, $t); return true; }
function getMwTitle() { return Title::MakeTitle(MV_NS_MVD, $this->wiki_title); }
protected function feedItem($row) { $title = Title::MakeTitle($row->page_namespace, $row->page_title); if ($title) { $date = $row->pending_since; $comments = $title->getTalkPage()->getFullURL(); $curRev = Revision::newFromTitle($title); return new FeedItem($title->getPrefixedText(), FeedUtils::formatDiffRow($title, $row->stable, $curRev->getId(), $row->pending_since, $curRev->getComment()), $title->getFullURL(), $date, $curRev->getUserText(), $comments); } else { return null; } }
function expand_wt($mvd_id) { global $wgOut, $mvgIP; global $mvDefaultSearchVideoPlaybackRes; require_once $mvgIP . '/includes/MV_Index.php'; require_once $mvgIP . '/includes/MV_Title.php'; require_once $mvgIP . '/includes/MV_MetavidInterface/MV_Overlay.php'; $mvd = MvIndex::getMVDbyId($mvd_id); if (count($mvd) != 0) { $mvTitle = new MvTitle($mvd->wiki_title); //validate title and load stream ref: if ($mvTitle->validRequestTitle()) { list($vWidth, $vHeight) = explode('x', $mvDefaultSearchVideoPlaybackRes); $embedHTML = '<span style="float:left;width:' . ($vWidth + 20) . 'px">' . $mvTitle->getEmbedVideoHtml($mvd_id, $mvDefaultSearchVideoPlaybackRes) . '</span>'; $wgOut->clearHTML(); $title = Title::MakeTitle(MV_NS_MVD, $mvd->wiki_title); $article = new Article($title); $MvOverlay = new MV_Overlay(); $MvOverlay->parse_format_text($article->getContent(), $mvTitle); $bgcolor = $MvOverlay->getMvdBgColor($mvd); $pageHTML = $wgOut->getHTML(); //encasulate page html: $pageHTML = '<span style="padding-top:10px;float:left;width:450px">' . $pageHTML . '</span>'; return $embedHTML . $pageHTML . '<div style="clear: both;"/>'; } else { return wfMsg('mvBadMVDtitle'); } } else { return wfMsg('mv_error_mvd_not_found'); } //$title = Title::MakeTitle(MV_NS_MVD, $wiki_title); //$article = new Article($title); //output table with embed left, and content right //return $wgOut->parse($article->getContent()); }
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; }
/** * outputs basic stream paging (this could be done client side) * */ function stream_paging_links($return_set = 'both') { global $wgUser, $mvDefaultStreamViewLength, $mvgScriptPath; $sk = $wgUser->getSkin(); $prev_link = $next_link = ''; // check if their is prev available: $mvTitle = $this->mv_interface->article->mvTitle; if ($return_set == 'both' || $return_set == 'prev') { if ($mvTitle->getStartTimeSeconds() > 0) { $prev_time_start = $mvTitle->getStartTimeSeconds() - $mvDefaultStreamViewLength; if ($prev_time_start < 0) { $prev_time_start = 0; } $prev_time_end = $mvTitle->getEndTimeSeconds() - $mvDefaultStreamViewLength; if ($prev_time_end < $mvDefaultStreamViewLength) { $prev_time_end = $mvDefaultStreamViewLength; } $newTitle = Title::MakeTitle(MV_NS_STREAM, $mvTitle->getStreamName() . '/' . seconds2npt($prev_time_start) . '/' . seconds2npt($prev_time_end)); $prev_link = $sk->makeKnownLinkObj($newTitle, '<img style="index:5" border="0" src="' . htmlspecialchars($mvgScriptPath) . '/skins/images/results_previous.png">', $this->getStateReq()); } } if ($return_set == 'both' || $return_set == 'next') { if ($mvTitle->getDuration() != $mvTitle->getEndTimeSeconds()) { $next_time_start = $mvTitle->getEndTimeSeconds(); $next_time_end = $mvTitle->getEndTimeSeconds() + $mvDefaultStreamViewLength; if ($next_time_end > $mvTitle->getDuration()) { $next_time_end = $mvTitle->getDuration(); } $newTitle = Title::MakeTitle(MV_NS_STREAM, $mvTitle->getStreamName() . '/' . seconds2npt($next_time_start) . '/' . seconds2npt($next_time_end)); $next_link = $sk->makeKnownLinkObj($newTitle, '<img style="index:5" border="0" src="' . htmlspecialchars($mvgScriptPath) . '/skins/images/results_next.png">', $this->getStateReq()); } } if ($return_set == 'both') { return $prev_link . ' ' . $next_link; } if ($return_set == 'prev') { return $prev_link; } if ($return_set == 'next') { return $next_link; } }
function getImageSection() { global $wgUser, $wgTitle; $sk = $wgUser->getSkin(); $s = $this->show_mv_links ? $this->getRssLinks() : ''; if ($this->showGallery && !$this->gallery->isEmpty()) { $title = Title::MakeTitle(NS_SPECIAL, 'MediaSearch'); $query = 'f[0][t]=' . urlencode('category') . '&f[0][v]=' . $wgTitle->getDBkey(); $search_link = $sk->makeKnownLinkObj($title, wfMsg('mv_search_category') . ":" . $wgTitle->getText(), $query); return "<div id=\"mw-category-media\">\n" . $s . '<h2>' . wfMsg('category-media-header', htmlspecialchars($this->title->getText())) . "</h2>\n" . wfMsgExt('category-media-count', array('parse'), $this->gallery->count()) . wfMsg('mv_cat_search_note', $search_link) . $this->gallery->toHTML() . "\n</div>"; } else { return ''; } }
function doSeqReplace(&$input, &$argv, &$parser) { global $wgTitle, $wgUser, $wgRequest, $markerList; $sk = $wgUser->getSkin(); $title = Title::MakeTitle(NS_SPECIAL, 'MvExportSequence/' . $wgTitle->getDBKey()); $title_url = $title->getFullURL(); $oldid = $wgRequest->getVal('oldid'); if (isset($oldid)) { //@@ugly hack .. but really this whole sequencer needs a serious rewrite) $ss = strpos($title_url, '?') === false ? '?' : '&'; $title_url .= $ss . 'oldid=' . $oldid; } $vidtag = '<div id="file" class="fullImageLink"><playlist'; $vidtag .= ' width="400" height="300" src="' . $title_url . '">'; $vidtag .= '</playlist></div><hr>'; $marker = "xx-marker" . count($markerList) . "-xx"; $markerList[] = $vidtag; return $marker; }
/** * @param integer $namespace (Default NS_MAIN) * @param string $from list all pages from this name (default FALSE) * @param string $to list all pages to this name (default FALSE) */ function showChunk($namespace = NS_MAIN, $from = false, $to = false) { global $wgOut, $wgUser, $wgContLang, $wgLang; $sk = $wgUser->getSkin(); $fromList = $this->getNamespaceKeyAndText($namespace, $from); $toList = $this->getNamespaceKeyAndText($namespace, $to); $namespaces = $wgContLang->getNamespaces(); $n = 0; if (!$fromList || !$toList) { $out = wfMsgWikiHtml('allpagesbadtitle'); } elseif (!in_array($namespace, array_keys($namespaces))) { // Show errormessage and reset to NS_MAIN $out = wfMsgExt('allpages-bad-ns', array('parseinline'), $namespace); $namespace = NS_MAIN; } else { list($namespace, $fromKey, $from) = $fromList; list($namespace2, $toKey, $to) = $toList; $dbr = wfGetDB(DB_SLAVE); $conds = array('page_namespace' => $namespace, 'page_title >= ' . $dbr->addQuotes($fromKey)); if ($toKey !== "") { $conds[] = 'page_title <= ' . $dbr->addQuotes($toKey); } $res = $dbr->select('page', array('page_namespace', 'page_title', 'page_is_redirect'), $conds, __METHOD__, array('ORDER BY' => 'page_title', 'LIMIT' => $this->maxPerPage + 1, 'USE INDEX' => 'name_title')); if ($res->numRows() > 0) { $out = Xml::openElement('table', array('class' => 'mw-allpages-table-chunk')); while ($n < $this->maxPerPage && ($s = $res->fetchObject())) { $t = Title::makeTitle($s->page_namespace, $s->page_title); if ($t) { $link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '') . $sk->linkKnown($t, htmlspecialchars($t->getText())) . ($s->page_is_redirect ? '</div>' : ''); } else { $link = '[[' . htmlspecialchars($s->page_title) . ']]'; } if ($n % 3 == 0) { $out .= '<tr>'; } $out .= "<td width=\"33%\">{$link}</td>"; $n++; if ($n % 3 == 0) { $out .= "</tr>\n"; } } if ($n % 3 != 0) { $out .= "</tr>\n"; } $out .= Xml::closeElement('table'); } else { $out = ''; } } if ($this->including()) { $out2 = ''; } else { if ($from == '') { // First chunk; no previous link. $prevTitle = null; } else { # Get the last title from previous chunk $dbr = wfGetDB(DB_SLAVE); $res_prev = $dbr->select('page', 'page_title', array('page_namespace' => $namespace, 'page_title < ' . $dbr->addQuotes($from)), __METHOD__, array('ORDER BY' => 'page_title DESC', 'LIMIT' => $this->maxPerPage, 'OFFSET' => $this->maxPerPage - 1)); # Get first title of previous complete chunk if ($dbr->numrows($res_prev) >= $this->maxPerPage) { $pt = $dbr->fetchObject($res_prev); $prevTitle = Title::makeTitle($namespace, $pt->page_title); } else { # The previous chunk is not complete, need to link to the very first title # available in the database $options = array('LIMIT' => 1); if (!$dbr->implicitOrderby()) { $options['ORDER BY'] = 'page_title'; } $reallyFirstPage_title = $dbr->selectField('page', 'page_title', array('page_namespace' => $namespace), __METHOD__, $options); # Show the previous link if it s not the current requested chunk if ($from != $reallyFirstPage_title) { $prevTitle = Title::makeTitle($namespace, $reallyFirstPage_title); } else { $prevTitle = null; } } } $self = $this->getTitle(); $nsForm = $this->namespaceForm($namespace, $from, $to); $out2 = Xml::openElement('table', array('class' => 'mw-allpages-table-form')) . '<tr> <td>' . $nsForm . '</td> <td class="mw-allpages-nav">' . $sk->link($self, wfMsgHtml('allpages'), array(), array(), 'known'); # Do we put a previous link ? if (isset($prevTitle) && ($pt = $prevTitle->getText())) { $query = array('from' => $prevTitle->getText()); if ($namespace) { $query['namespace'] = $namespace; } $prevLink = $sk->linkKnown($self, htmlspecialchars(wfMsg('prevpage', $pt)), array(), $query); $out2 = $wgLang->pipeList(array($out2, $prevLink)); } if ($n == $this->maxPerPage && ($s = $res->fetchObject())) { # $s is the first link of the next chunk $t = Title::MakeTitle($namespace, $s->page_title); $query = array('from' => $t->getText()); if ($namespace) { $query['namespace'] = $namespace; } $nextLink = $sk->linkKnown($self, htmlspecialchars(wfMsg('nextpage', $t->getText())), array(), $query); $out2 = $wgLang->pipeList(array($out2, $nextLink)); } $out2 .= "</td></tr></table>"; } $wgOut->addHTML($out2 . $out); if (isset($prevLink) or isset($nextLink)) { $wgOut->addHTML('<hr /><p class="mw-allpages-nav">'); if (isset($prevLink)) { $wgOut->addHTML($prevLink); } if (isset($prevLink) && isset($nextLink)) { $wgOut->addHTML(wfMsgExt('pipe-separator', 'escapenoentities')); } if (isset($nextLink)) { $wgOut->addHTML($nextLink); } $wgOut->addHTML('</p>'); } }
/** * * Returns an array of titles that have links to the given * title (presumably an image). All returned articles will be in the * NS_MAIN namespace and will also not be in a excluded category. * */ function getLinkedArticles($title) { global $wgMemc; $cachekey = wfMemcKey("ImageHelper_linked", $title->getArticleID()); $result = $wgMemc->get($cachekey); if ($result) { return $result; } $imageTitle = $title->getDBkey(); $dbr = wfGetDB(DB_SLAVE); $page = $dbr->tableName('page'); $imagelinks = $dbr->tableName('imagelinks'); $sql = "SELECT page_namespace,page_title,page_id FROM {$imagelinks},{$page} WHERE il_to=" . $dbr->addQuotes($imageTitle) . " AND il_from=page_id"; $sql = $dbr->limitResult($sql, 500, 0); $res = $dbr->query($sql, __METHOD__); $articles = array(); $templates = wfMsgForContent('ih_categories_ignore'); $templates = split("\n", $templates); $templates = str_replace("http://www.wikihow.com/Category:", "", $templates); $templates = array_flip($templates); // make the array associative. while ($s = $dbr->fetchObject($res)) { //check if in main namespace if ($s->page_namespace != NS_MAIN) { continue; } //check if in category exclusion list $title = Title::MakeTitle($s->page_namespace, $s->page_title); $cats = $title->getParentCategories(); if (is_array($cats) && sizeof($cats) > 0) { $keys = array_keys($cats); $found = false; for ($i = 0; $i < sizeof($keys) && !$found; $i++) { $t = Title::newFromText($keys[$i]); if (isset($templates[urldecode($t->getPartialURL())])) { //this article is in a category we don't want to show $found = true; break; } } if ($found) { continue; } } if ($s->page_title != $imageTitle) { $articles[] = $title; } } $wgMemc->set($cachekey, $articles); return $articles; }
/** * @param integer $namespace (Default NS_MAIN) * @param string $from list all pages from this name (default FALSE) */ function showChunk($namespace = NS_MAIN, $from, $including = false) { global $wgOut, $wgUser, $wgContLang; $sk = $wgUser->getSkin(); $fromList = $this->getNamespaceKeyAndText($namespace, $from); $namespaces = $wgContLang->getNamespaces(); $align = $wgContLang->isRtl() ? 'left' : 'right'; $n = 0; if (!$fromList) { $out = wfMsgWikiHtml('allpagesbadtitle'); } elseif (!in_array($namespace, array_keys($namespaces))) { // Show errormessage and reset to NS_MAIN $out = wfMsgExt('allpages-bad-ns', array('parseinline'), $namespace); $namespace = NS_MAIN; } else { list($namespace, $fromKey, $from) = $fromList; $dbr = wfGetDB(DB_SLAVE); $res = $dbr->select('page', array('page_namespace', 'page_title', 'page_is_redirect'), array('page_namespace' => $namespace, 'page_title >= ' . $dbr->addQuotes($fromKey)), __METHOD__, array('ORDER BY' => 'page_title', 'LIMIT' => $this->maxPerPage + 1, 'USE INDEX' => 'name_title')); $out = '<table style="background: inherit;" border="0" width="100%">'; while ($n < $this->maxPerPage && ($s = $dbr->fetchObject($res))) { $t = Title::makeTitle($s->page_namespace, $s->page_title); if ($t) { $link = ($s->page_is_redirect ? '<div class="allpagesredirect">' : '') . $sk->makeKnownLinkObj($t, htmlspecialchars($t->getText()), false, false) . ($s->page_is_redirect ? '</div>' : ''); } else { $link = '[[' . htmlspecialchars($s->page_title) . ']]'; } if ($n % 3 == 0) { $out .= '<tr>'; } $out .= "<td width=\"33%\">{$link}</td>"; $n++; if ($n % 3 == 0) { $out .= '</tr>'; } } if ($n % 3 != 0) { $out .= '</tr>'; } $out .= '</table>'; } if ($including) { $out2 = ''; } else { if ($from == '') { // First chunk; no previous link. $prevTitle = null; } else { # Get the last title from previous chunk $dbr = wfGetDB(DB_SLAVE); $res_prev = $dbr->select('page', 'page_title', array('page_namespace' => $namespace, 'page_title < ' . $dbr->addQuotes($from)), __METHOD__, array('ORDER BY' => 'page_title DESC', 'LIMIT' => $this->maxPerPage, 'OFFSET' => $this->maxPerPage - 1)); # Get first title of previous complete chunk if ($dbr->numrows($res_prev) >= $this->maxPerPage) { $pt = $dbr->fetchObject($res_prev); $prevTitle = Title::makeTitle($namespace, $pt->page_title); } else { # The previous chunk is not complete, need to link to the very first title # available in the database $options = array('LIMIT' => 1); if (!$dbr->implicitOrderby()) { $options['ORDER BY'] = 'page_title'; } $reallyFirstPage_title = $dbr->selectField('page', 'page_title', array('page_namespace' => $namespace), __METHOD__, $options); # Show the previous link if it s not the current requested chunk if ($from != $reallyFirstPage_title) { $prevTitle = Title::makeTitle($namespace, $reallyFirstPage_title); } else { $prevTitle = null; } } } $nsForm = $this->namespaceForm($namespace, $from); $out2 = '<table style="background: inherit;" width="100%" cellpadding="0" cellspacing="0" border="0">'; $out2 .= '<tr valign="top"><td>' . $nsForm; $out2 .= '</td><td align="' . $align . '" style="font-size: smaller; margin-bottom: 1em;">' . $sk->makeKnownLink($wgContLang->specialPage("Allpages"), wfMsgHtml('allpages')); $self = SpecialPage::getTitleFor('Allpages'); # Do we put a previous link ? if (isset($prevTitle) && ($pt = $prevTitle->getText())) { $q = 'from=' . $prevTitle->getPartialUrl() . ($namespace ? '&namespace=' . $namespace : ''); $prevLink = $sk->makeKnownLinkObj($self, wfMsgHTML('prevpage', $pt), $q); $out2 .= ' | ' . $prevLink; } if ($n == $this->maxPerPage && ($s = $dbr->fetchObject($res))) { # $s is the first link of the next chunk $t = Title::MakeTitle($namespace, $s->page_title); $q = 'from=' . $t->getPartialUrl() . ($namespace ? '&namespace=' . $namespace : ''); $nextLink = $sk->makeKnownLinkObj($self, wfMsgHtml('nextpage', $t->getText()), $q); $out2 .= ' | ' . $nextLink; } $out2 .= "</td></tr></table><hr />"; } $wgOut->addHtml($out2 . $out); if (isset($prevLink) or isset($nextLink)) { $wgOut->addHtml('<hr /><p style="font-size: smaller; float: ' . $align . '">'); if (isset($prevLink)) { $wgOut->addHTML($prevLink); } if (isset($prevLink) && isset($nextLink)) { $wgOut->addHTML(' | '); } if (isset($nextLink)) { $wgOut->addHTML($nextLink); } $wgOut->addHTML('</p>'); } }
/** */ function dumpReplayEntry($row) { $title = Title::MakeTitle($row->rc_namespace, $row->rc_title); switch ($row->rc_type) { case RC_EDIT: case RC_NEW: # Edit $dbr =& wfGetDB(DB_MASTER); $out = " <edit>\n"; $out .= " <title>" . xmlsafe($title->getPrefixedText()) . "</title>\n"; # Get previous edit timestamp if ($row->rc_last_oldid) { $s = $dbr->selectRow('old', array('old_timestamp'), array('old_id' => $row->rc_last_oldid)); $out .= " <lastedit>" . wfTimestamp2ISO8601($s->old_timestamp) . "</lastedit>\n"; } else { $out .= " <newpage/>\n"; } if ($row->rc_this_oldid) { $s = $dbr->selectRow('old', array('old_id as id', 'old_timestamp as timestamp', 'old_user as user', 'old_user_text as user_text', 'old_comment as comment', 'old_text as text', 'old_flags as flags'), array('old_id' => $row->rc_this_oldid)); $out .= revision2xml($s, true, false); } else { $s = $dbr->selectRow('cur', array('cur_id as id', 'cur_timestamp as timestamp', 'cur_user as user', 'cur_user_text as user_text', 'cur_restrictions as restrictions', 'cur_comment as comment', 'cur_text as text'), array('cur_id' => $row->rc_cur_id)); $out .= revision2xml($s, true, true); } $out .= " </edit>\n"; break; case RC_LOG: $dbr =& wfGetDB(DB_MASTER); $s = $dbr->selectRow('logging', array('log_type', 'log_action', 'log_timestamp', 'log_user', 'log_namespace', 'log_title', 'log_comment'), array('log_timestamp' => $row->rc_timestamp, 'log_user' => $row->rc_user)); $ts = wfTimestamp2ISO8601($row->rc_timestamp); $target = Title::MakeTitle($s->log_namespace, $s->log_title); $out = " <log>\n"; $out .= " <type>" . xmlsafe($s->log_type) . "</type>\n"; $out .= " <action>" . xmlsafe($s->log_action) . "</action>\n"; $out .= " <timestamp>" . $ts . "</timestamp>\n"; $out .= " <contributor><username>" . xmlsafe($row->rc_user_text) . "</username></contributor>\n"; $out .= " <target>" . xmlsafe($target->getPrefixedText()) . "</target>\n"; $out .= " <comment>" . xmlsafe($s->log_comment) . "</comment>\n"; $out .= " </log>\n"; break; case RC_MOVE: case RC_MOVE_OVER_REDIRECT: $target = Title::MakeTitle($row->rc_moved_to_ns, $row->rc_moved_to_title); $out = " <move>\n"; $out .= " <title>" . xmlsafe($title->getPrefixedText()) . "</title>\n"; $out .= " <target>" . xmlsafe($target->getPrefixedText()) . "</target>\n"; if ($row->rc_type == RC_MOVE_OVER_REDIRECT) { $out .= " <override/>\n"; } $ts = wfTimestamp2ISO8601($row->rc_timestamp); $out .= " <id>{$row->rc_cur_id}</id>\n"; $out .= " <timestamp>{$ts}</timestamp>\n"; if ($row->rc_user_text) { $u = "<username>" . xmlsafe($row->rc_user_text) . "</username>"; $u .= "<id>{$row->rc_user}</id>"; } else { $u = "<ip>" . xmlsafe($row->rc_user_text) . "</ip>"; } $out .= " <contributor>{$u}</contributor>\n"; $out .= " </move>\n"; } return $out; }
/** * Override for custom handling. If the titles/links are ok, just do * feedItemDesc() */ function feedResult($row) { if (!isset($row->title)) { return null; } $title = Title::MakeTitle(intval($row->namespace), $row->title); if ($title) { $date = isset($row->timestamp) ? $row->timestamp : ''; $comments = ''; if ($title) { $talkpage = $title->getTalkPage(); $comments = $talkpage->getFullURL(); } return new FeedItem($title->getPrefixedText(), $this->feedItemDesc($row), $title->getFullURL(), $date, $this->feedItemAuthor($row), $comments); } else { return null; } }
function feedUrl() { $title = Title::MakeTitle(NS_SPECIAL, $this->getName()); return $title->getFullURL(); }
function outPutItem($wikiTitle, $desc_html = '') { global $wgOut, $wgUser; $sk = $wgUser->getSkin(); $mvTitle = new MV_Title($wikiTitle); $mStreamTitle = Title::makeTitle(MV_NS_STREAM, ucfirst($mvTitle->getStreamName()) . '/' . $mvTitle->getTimeRequest()); // only output media RSS item if its valid media: if (!$mvTitle->doesStreamExist()) { return; } // @@todo this should be cached $thumb_ref = $mvTitle->getFullStreamImageURL('320x240', null, '', true); if ($desc_html == '') { $article = new Article($wikiTitle); $wgOut->clearHTML(); $wgOut->addWikiText($article->getContent()); $desc_html = $wgOut->getHTML(); $wgOut->clearHTML(); } //get the parent meta if allowed: global $mvGetParentMeta; $pmvd = false; if ($mvGetParentMeta && strtolower($mvTitle->getMvdTypeKey()) == 'ht_en') { $pmvd = MV_Index::getParentAnnotativeLayers($mvTitle); if ($pmvd->wiki_title) { $pMvTitle = new MV_Title($pmvd->wiki_title); $pAnnoStreamTitle = Title::MakeTitle(MV_NS_STREAM, $pMvTitle->getNearStreamName(0)); } } $desc_xml = '<![CDATA[ <center class="mv_rss_view_only"> <a href="' . htmlspecialchars($mStreamTitle->getFullUrl()) . '"><img src="' . $thumb_ref . '" border="0" /></a> </center> <br />' . $desc_html . ']]>'; $stream_url = $mvTitle->getWebStreamURL(); $talkpage = $wikiTitle->getTalkPage(); $type_desc = $mvTitle->getMvdTypeKey() ? wfMsg($mvTitle->getMvdTypeKey()) : ''; $time_desc = $mvTitle->getTimeDesc() ? $mvTitle->getTimeDesc() : ''; ?> <item> <link> <?php echo mvRSSFeed::xmlEncode($mStreamTitle->getFullUrl()); ?> </link> <title><?php echo mvRSSFeed::xmlEncode($mvTitle->getStreamNameText() . ' ' . $time_desc); ?> </title> <description> <?php echo $desc_xml; ?> </description> <?php global $mvDefaultVideoQualityKey, $mvVidQualityMsgKeyType, $mvDefaultVideoHighQualityKey, $mvDefaultFlashQualityKey; //check a few different types in order of prefrence: if ($stream_url = $mvTitle->getWebStreamURL($mvDefaultVideoHighQualityKey)) { $mk = $mvDefaultVideoHighQualityKey; } elseif ($stream_url = $mvTitle->getWebStreamURL($mvDefaultVideoQualityKey)) { $mk = $mvDefaultVideoQualityKey; } elseif ($stream_url = $mvTitle->getWebStreamURL($mvDefaultFlashQualityKey)) { $mk = $mvDefaultFlashQualityKey; } if ($stream_url) { echo '<enclosure name="' . wfMsg($mk) . '" type="video/ogg" ' . 'url="' . mvRSSFeed::xmlEncode($stream_url) . '"/>'; } ?> <comments> <?php echo mvRSSFeed::xmlEncode($talkpage->getFullUrl()); ?> </comments> <?php $person = ''; if ($pmvd && $pmvd->Speech_by) { $personTitle = Title::newFromText($pmvd->Speech_by); ?> <media:person label="<?php echo $personTitle->getText(); ?> " url="<?php echo mvRSSFeed::xmlEncode($personTitle->getFullURL()); ?> " /> <?php } //handle any parent clip tag info: if ($pmvd) { ?> <media:parent_clip url="<?php echo mvRSSFeed::xmlEncode($pAnnoStreamTitle->getFullUrl()); ?> " /> <?php if ($pmvd->Bill) { $bTitle = Title::newFromText($pmvd->Bill); ?> <media:bill label="<?php echo $bTitle->getText(); ?> " url="<?php echo mvRSSFeed::xmlEncode($bTitle->getFullURL()); ?> " /> <?php } if ($pmvd->category) { foreach ($pmvd->category as $cat_titlekey) { $cTitle = $cTitle = Title::MakeTitle(NS_CATEGORY, $cat_titlekey); ?> <media:category label="<?php echo $cTitle->getText(); ?> " url="<?php echo mvRSSFeed::xmlEncode($cTitle->getFullUrl()); ?> " /> <?php } } } ?> <media:thumbnail url="<?php echo mvRSSFeed::xmlEncode($thumb_ref); ?> " /> <media:roe_embed url="<?php echo mvRSSFeed::xmlEncode($mvTitle->getROEURL()); ?> " /> <media:group> <?php global $mvDefaultFlashQualityKey, $mvVidQualityMsgKeyType, $mvDefaultFlashQualityKey; //add in media group: $vid_types = array($mvDefaultVideoQualityKey, 'mv_ogg_high_quality', $mvDefaultFlashQualityKey); foreach ($vid_types as $vid_key) { $stream_url = $mvTitle->getWebStreamURL($vid_key); if ($stream_url !== false && isset($mvVidQualityMsgKeyType[$vid_key])) { ?> <media:content blip:role="<?php echo mvRSSFeed::xmlEncode($vid_key); ?> " expression="full" type="<?php echo mvRSSFeed::xmlEncode($mvVidQualityMsgKeyType[$vid_key]); ?> " url="<?php echo htmlentities($stream_url); ?> "></media:content> <?php } } ?> </media:group> </item> <? }
function videoLinks() { global $wgUser, $wgOut; $wgOut->addHTML(Xml::element('h2', array('id' => 'filelinks'), wfMsg('imagelinks')) . "\n"); $dbr = wfGetDB(DB_SLAVE); $page = $dbr->tableName('page'); $templatelinks = $dbr->tableName('templatelinks'); $sql = "SELECT page_namespace,page_title FROM {$templatelinks},{$page} WHERE tl_title=" . $dbr->addQuotes($this->mTitle->getDBkey()) . " AND tl_namespace = " . NS_VIDEO . " AND tl_from=page_id"; $sql = $dbr->limitResult($sql, 500, 0); $res = $dbr->query($sql, "VideoPage::videoLinks"); if (0 == $dbr->numRows($res)) { $wgOut->addHtml('<p>' . wfMsg("nolinkstoimage") . "</p>\n"); return; } $wgOut->addHTML('<p>' . wfMsg('linkstoimage') . "</p>\n<ul>"); $sk = $wgUser->getSkin(); while ($s = $dbr->fetchObject($res)) { $name = Title::MakeTitle($s->page_namespace, $s->page_title); $link = $sk->makeKnownLinkObj($name, ""); $wgOut->addHTML("<li>{$link}</li>\n"); } $wgOut->addHTML("</ul>\n"); }