本文整理汇总了PHP中Wikia::Log方法的典型用法代码示例。如果您正苦于以下问题:PHP Wikia::Log方法的具体用法?PHP Wikia::Log怎么用?PHP Wikia::Log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wikia
的用法示例。
在下文中一共展示了Wikia::Log方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateBacklinkText
static function updateBacklinkText()
{
wfProfileIn(__METHOD__);
$dbr = wfGetDb(DB_MASTER);
$rowCount = count(self::$backlinkRows);
if ($rowCount == 0) {
wfProfileOut(__METHOD__);
return true;
}
$deleteSql = 'DELETE FROM `' . self::TABLE_NAME . '` WHERE source_page_id IN (' . implode(', ', self::$sourceArticleIds) . ');';
$insertSql = "INSERT IGNORE INTO `" . self::TABLE_NAME . "` (`source_page_id`, `target_page_id`, `backlink_text`, `count` ) VALUES ";
$rowCounter = 0;
foreach (self::$backlinkRows as $signature => $count) {
// $signature is incomplete sql value set "(1234,1234,'foo', "
$insertSql .= $signature . "{$count})";
$insertSql .= ++$rowCounter == $rowCount ? ';' : ', ';
}
try {
$dbr->begin();
$dbr->query($deleteSql, __METHOD__);
$dbr->query($insertSql, __METHOD__);
$dbr->commit(__METHOD__);
} catch (Exception $e) {
$dbr->rollback();
Wikia::Log(__METHOD__, 'Transaction', $e);
}
wfProfileOut(__METHOD__);
return true;
}
示例2: moreLikeThis
/**
* Utilizes Solr's MoreLikeThis component to return similar pages
* @see WikiaSearchTest::testMoreLikeThis
* @param WikiaSearchConfig $searchConfig
* @return WikiaSearchResultSet
*/
private function moreLikeThis(WikiaSearchConfig $searchConfig)
{
$query = $searchConfig->getQuery(WikiaSearchConfig::QUERY_RAW);
$streamBody = $searchConfig->getStreamBody();
$streamUrl = $searchConfig->getStreamUrl();
if (!($query || $streamBody || $streamUrl)) {
throw new Exception("A query, url, or stream is required.");
}
$mlt = $this->client->createMoreLikeThis();
$mlt->setMltFields(implode(',', $searchConfig->getMltFields()))->setFields($searchConfig->getRequestedFields())->addParam('mlt.match.include', 'false')->setStart($searchConfig->getStart())->setRows($searchConfig->getRows())->setDocumentClass('WikiaSearchResult');
if ($searchConfig->getInterestingTerms() == 'list') {
$mlt->setInterestingTerms('list');
}
if ($searchConfig->getMltFilterQuery()) {
$mlt->addFilterQuery(array('query' => $searchConfig->getMltFilterQuery(), 'key' => 'mltfilterquery'));
}
if ($query !== null) {
$mlt->setQuery($query);
} else {
if ($streamBody) {
$mlt->addParam('stream.body', $streamBody);
} else {
if ($streamUrl) {
$mlt->addParam('stream.url', $streamUrl);
}
}
}
try {
$mltResult = $this->client->moreLikeThis($mlt);
} catch (Exception $e) {
$mltResult = F::build('Solarium_Result_Select_Empty');
Wikia::Log(__METHOD__, '', $e);
}
$results = F::build('WikiaSearchResultSet', array($mltResult, $searchConfig));
return $results;
}
示例3: getSuggestedVideos
public function getSuggestedVideos()
{
$searchConfig = F::build('WikiaSearchConfig');
$searchConfig->setCityId(WikiaSearch::VIDEO_WIKI_ID)->setStart(0)->setSize(20);
$relatedVideosParams = array('video_wiki_only' => true, 'start' => 0, 'size' => 20);
$sTitle = $this->request->getVal('pageTitle');
$articleId = 0;
if (!empty($sTitle)) {
$oTitle = Title::newFromText($sTitle);
if (!empty($oTitle) && $oTitle->exists()) {
$articleId = $oTitle->getArticleId();
}
}
if ($articleId > 0) {
$searchConfig->setPageId($articleId);
}
$search = F::build('WikiaSearch');
/* @var $search WikiaSearch */
$resultCount = 0;
if ($this->wg->ContLang->mCode == 'en') {
// we can't use MoreLikeThis outside of English because we can't reconcile different language fields
// if we were given a title, then search against that title; if not, then search against the wiki's name, minus the term "wiki"
$searchResultSet = $search->getRelatedVideos($searchConfig);
if ($searchResultSet->getResultsFound() == 0 && $searchConfig->getPageId() && $this->request->getVal('debug') != 1) {
// if nothing for specify article, do general search
$searchConfig->setPageId(false);
$solariumResultSet = $search->getRelatedVideos($searchConfig);
}
$resultCount = $searchResultSet->getResultsNum();
}
if ($resultCount == 0) {
$searchConfig->setQuery(!empty($sTitle) ? $sTitle : preg_replace('/ wiki\\b/i', '', $this->wg->SiteName))->setVideoSearch(true)->setPageId(false);
$searchResultSet = $search->doSearch($searchConfig);
$resultCount = $searchResultSet->getResultsNum();
}
Wikia::Log(__METHOD__, '', $resultCount);
$rvService = F::build('RelatedVideosService');
/* @var $rvService RelatedVideosService */
$currentVideos = $rvService->getRVforArticleId($articleId);
// reorganize array to index by video title
$currentVideosByTitle = array();
foreach ($currentVideos as $vid) {
$currentVideosByTitle[$vid['title']] = $vid;
}
$response = array();
foreach ($searchResultSet as $document) {
$globalTitle = F::build('GlobalTitle', explode('_', $document['id']), 'newFromId');
if (!empty($globalTitle)) {
$title = $globalTitle->getText();
if (isset($currentVideosByTitle[$title])) {
// don't suggest videos that are already in RelatedVideos
continue;
}
$response[$document['url']] = $document->getFields();
$rvService->inflateWithVideoData($document->getFields(), $globalTitle, $this->getVal('videoWidth', 160), $this->getVal('videoHeight', 90));
} else {
unset($response[$document['url']]);
}
}
$this->setVal('suggested_videos', $response);
}
示例4: isMissing
/** isVisible inhereted */
function isMissing()
{
if ($this->missing === null) {
/* Wikia Change Start @author marzjan */
$fileExists = $this->repo->fileExists($this->getVirtualUrl(), FileRepo::FILES_ONLY);
$info = 'URI: ' . (empty($_SERVER["REQUEST_URI"]) ? 'N/A' : $_SERVER["REQUEST_URI"]) . ' - REF: ' . (empty($_SERVER['HTTP_REFERER']) ? 'N/A' : $_SERVER['HTTP_REFERER']);
Wikia::Log(__METHOD__, false, "[{$info}] Setting fileExists to " . ($fileExists ? 'true' : 'false') . " for '" . $this->getVirtualUrl() . "'");
/* Wikia Change End */
$this->missing = !$fileExists;
}
return $this->missing;
}
示例5: getVideoDetail
/**
* get video detail
* @param array $videoInfo [ array( 'title' => title, 'addedAt' => addedAt , 'addedBy' => addedBy ) ]
* @param array $options
* [ array( 'thumbWidth' => int, 'thumbHeight' => int, 'postedInArticles' => int, 'getThumbnail' => bool, 'thumbOptions' => array ) ]
* Keys:
* thumbWidth - the width of the thumbnail to return (required)
* thumbHeight - the height of the thumbnail to return (required)
* getThumbnail - whether to return a fully formed html thumbnail of the video or not
* thumbOptions - the option of the thumbnail to return
* postedInArticles - the number of "posted in" article details to return
* @return array $videoDetail
*/
public function getVideoDetail($videoInfo, $options)
{
wfProfileIn(__METHOD__);
$videoDetail = array();
/** @var Title $title */
$title = $videoInfo['title'];
/** @var LocalFile|WikiaLocalFileShared $file */
$file = WikiaFileHelper::getVideoFileFromTitle($title);
if ($file) {
// get thumbnail
$thumb = $file->transform(['width' => $options['thumbWidth'], 'height' => $options['thumbHeight']]);
$thumbUrl = $thumb->getUrl();
// get user
if (empty($videoInfo['addedBy'])) {
$userName = '';
$userUrl = '';
} else {
$user = User::newFromId($videoInfo['addedBy']);
$userName = User::isIP($user->getName()) ? wfMessage('oasis-anon-user')->text() : $user->getName();
$userUrl = $user->getUserPage()->getFullURL();
}
$thumbnail = '';
if (!empty($options['getThumbnail'])) {
$thumbOptions = empty($options['thumbOptions']) ? [] : $options['thumbOptions'];
if (empty($thumbOptions['alt'])) {
$thumbOptions['alt'] = htmlspecialchars($title->getText());
}
$thumbnail = $thumb->toHtml($thumbOptions);
}
// get article list
if (empty($options['postedInArticles'])) {
$isTruncated = 0;
$truncatedList = array();
} else {
$mediaQuery = new ArticlesUsingMediaQuery($title);
$articleList = $mediaQuery->getArticleList();
list($truncatedList, $isTruncated) = WikiaFileHelper::truncateArticleList($articleList, $options['postedInArticles']);
}
// video details
$videoDetail = array('title' => $title->getDBKey(), 'fileTitle' => $title->getText(), 'description' => $this->getVideoDescription($file), 'fileUrl' => $title->getFullURL(), 'thumbUrl' => $thumbUrl, 'userName' => $userName, 'userUrl' => $userUrl, 'truncatedList' => $truncatedList, 'isTruncated' => $isTruncated, 'timestamp' => empty($videoInfo['addedAt']) ? '' : $videoInfo['addedAt'], 'duration' => (double) $file->getMetadataDuration(), 'viewsTotal' => empty($videoInfo['viewsTotal']) ? 0 : $videoInfo['viewsTotal'], 'provider' => $file->getProviderName(), 'embedUrl' => $file->getHandler()->getEmbedUrl(), 'videoId' => $file->getVideoId(), 'thumbnail' => $thumbnail, 'regionalRestrictions' => $file->getRegionalRestrictions());
} else {
Wikia::Log(__METHOD__, false, "No file found for '" . $videoInfo['title'] . "'");
}
wfProfileOut(__METHOD__);
return $videoDetail;
}
示例6: deleteBatch
/**
* Given a set of page IDs, deletes by query
* @param array $documentIds
* @return bool true
*/
public function deleteBatch(array $documentIds = array(), $verbosity = self::REINDEX_DEFAULT)
{
$updateHandler = $this->client->createUpdate();
foreach ($documentIds as $id) {
$updateHandler->addDeleteQuery(WikiaSearch::valueForField('id', $id));
}
$updateHandler->addCommit();
try {
$this->client->update($updateHandler);
$confirmationString = implode(' ', $documentIds) . ' ' . count($documentIds) . " document(s) deleted\n";
if ($verbosity == self::REINDEX_VERBOSE) {
echo $confirmationString;
}
} catch (Exception $e) {
$id = rand(1000, 9999);
Wikia::Log(__METHOD__, $id, $e);
if ($verbosity == self::REINDEX_VERBOSE) {
echo "There was an error deleting from the index. Please search for {$id} in the logs.\n";
}
}
return true;
}