本文整理汇总了PHP中Media::toString方法的典型用法代码示例。如果您正苦于以下问题:PHP Media::toString方法的具体用法?PHP Media::toString怎么用?PHP Media::toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Media
的用法示例。
在下文中一共展示了Media::toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getURLs
public function getURLs($id)
{
$infix = Media::toString($this->media);
if ($infix === null) {
throw new BadMediaException();
}
return [self::URL_MEDIA => 'https://myanimelist.net/' . $infix . '/' . $id, self::URL_RECS => 'https://myanimelist.net/' . $infix . '/' . $id . '/dummy/userrecs'];
}
示例2: work
public static function work(&$controllerContext, &$viewContext)
{
$viewContext->viewName = 'user-list';
$viewContext->meta->title = $viewContext->user->name . ' — List (' . Media::toString($viewContext->media) . ') — ' . Config::$title;
$viewContext->meta->description = $viewContext->user->name . '\'s ' . Media::toString($viewContext->media) . ' list.';
WebMediaHelper::addTablesorter($viewContext);
WebMediaHelper::addCustom($viewContext);
$viewContext->list = $viewContext->user->getMixedUserMedia($viewContext->media);
$viewContext->private = $viewContext->user->isUserMediaPrivate($viewContext->media);
}
示例3: work
public static function work(&$controllerContext, &$viewContext)
{
$viewContext->viewName = 'user-list';
$viewContext->meta->title = 'MALgraph - ' . $viewContext->user->name . ' - list (' . Media::toString($viewContext->media) . ')';
$viewContext->meta->description = $viewContext->user->name . '’s ' . Media::toString($viewContext->media) . ' list on MALgraph, an online tool that extends your MyAnimeList profile.';
$viewContext->meta->keywords = array_merge($viewContext->meta->keywords, ['profile', 'list', 'achievements', 'ratings', 'history', 'favorites', 'suggestions', 'recommendations']);
WebMediaHelper::addTablesorter($viewContext);
WebMediaHelper::addCustom($viewContext);
$viewContext->list = $viewContext->user->getMixedUserMedia($viewContext->media);
$viewContext->private = $viewContext->user->isUserMediaPrivate($viewContext->media);
}
示例4: work
public static function work(&$controllerContext, &$viewContext)
{
$viewContext->viewName = 'user-favorites';
$viewContext->meta->title = 'MALgraph - ' . $viewContext->user->name . ' - favorites (' . Media::toString($viewContext->media) . ')';
$viewContext->meta->description = $viewContext->user->name . '’s ' . Media::toString($viewContext->media) . ' favorites on MALgraph, an online tool that extends your MyAnimeList profile.';
$viewContext->meta->keywords = array_merge($viewContext->meta->keywords, ['profile', 'list', 'achievements', 'ratings', 'history', 'favorites', 'suggestions', 'recommendations']);
WebMediaHelper::addHighcharts($viewContext);
WebMediaHelper::addTablesorter($viewContext);
WebMediaHelper::addInfobox($viewContext);
WebMediaHelper::addEntries($viewContext);
WebMediaHelper::addCustom($viewContext);
$list = $viewContext->user->getMixedUserMedia($viewContext->media);
$listNonPlanned = UserMediaFilter::doFilter($list, UserMediaFilter::nonPlanned());
$favCreators = MediaCreatorDistribution::fromEntries($listNonPlanned);
$favGenres = MediaGenreDistribution::fromEntries($listNonPlanned);
$favYears = MediaYearDistribution::fromEntries($listNonPlanned);
$favDecades = MediaDecadeDistribution::fromEntries($listNonPlanned);
$favTypes = MediaTypeDistribution::fromEntries($listNonPlanned);
$viewContext->favCreators = $favCreators;
$viewContext->favGenres = $favGenres;
$viewContext->favYears = $favYears;
$viewContext->favDecades = $favDecades;
$viewContext->favTypes = $favTypes;
$distMeanScore = [];
$distTimeSpent = [];
foreach ([$favCreators, $favGenres, $favDecades, $favYears] as $dist) {
$meanScore = [];
$timeSpent = [];
foreach ($dist->getGroupsKeys(AbstractDistribution::IGNORE_NULL_KEY) as $safeKey => $key) {
$meanScore[$safeKey] = 0;
$timeSpent[$safeKey] = 0;
$subEntries = $dist->getGroupEntries($key);
$scoreCount = 0;
foreach ($subEntries as $entry) {
$timeSpent[$safeKey] += $entry->finished_duration;
$meanScore[$safeKey] += $entry->score;
$scoreCount += $entry->score > 0;
}
$meanScore[$safeKey] /= max(1, $scoreCount);
}
$distMeanScore[get_class($dist)] = $meanScore;
$distTimeSpent[get_class($dist)] = $timeSpent;
}
$viewContext->creatorScores = $distMeanScore[get_class($favCreators)];
$viewContext->genreScores = $distMeanScore[get_class($favGenres)];
$viewContext->yearScores = $distMeanScore[get_class($favYears)];
$viewContext->decadeScores = $distMeanScore[get_class($favDecades)];
$viewContext->creatorTimeSpent = $distTimeSpent[get_class($favCreators)];
$viewContext->genreTimeSpent = $distTimeSpent[get_class($favGenres)];
$viewContext->typePercentages = TextHelper::roundPercentages($favTypes->getGroupsSizes());
$viewContext->genreValues = DistributionEvaluator::evaluate($favGenres);
$viewContext->creatorValues = DistributionEvaluator::evaluate($favCreators);
}
示例5: work
public static function work(&$controllerContext, &$viewContext)
{
$viewContext->viewName = 'user-favorites';
$viewContext->meta->title = $viewContext->user->name . ' — Favorites (' . Media::toString($viewContext->media) . ') — ' . Config::$title;
$viewContext->meta->description = $viewContext->user->name . '\'s ' . Media::toString($viewContext->media) . ' favorites.';
WebMediaHelper::addHighcharts($viewContext);
WebMediaHelper::addTablesorter($viewContext);
WebMediaHelper::addInfobox($viewContext);
WebMediaHelper::addEntries($viewContext);
WebMediaHelper::addCustom($viewContext);
$list = $viewContext->user->getMixedUserMedia($viewContext->media);
$listNonPlanned = UserMediaFilter::doFilter($list, UserMediaFilter::nonPlanned());
$favCreators = MediaCreatorDistribution::fromEntries($listNonPlanned);
$favGenres = MediaGenreDistribution::fromEntries($listNonPlanned);
$favYears = MediaYearDistribution::fromEntries($listNonPlanned);
$favDecades = MediaDecadeDistribution::fromEntries($listNonPlanned);
$favTypes = MediaTypeDistribution::fromEntries($listNonPlanned);
$viewContext->favCreators = $favCreators;
$viewContext->favGenres = $favGenres;
$viewContext->favYears = $favYears;
$viewContext->favDecades = $favDecades;
$viewContext->favTypes = $favTypes;
$distMeanScore = [];
$distTimeSpent = [];
foreach ([$favCreators, $favGenres, $favDecades, $favYears] as $dist) {
$meanScore = [];
$timeSpent = [];
foreach ($dist->getGroupsKeys(AbstractDistribution::IGNORE_NULL_KEY) as $safeKey => $key) {
$meanScore[$safeKey] = 0;
$timeSpent[$safeKey] = 0;
$subEntries = $dist->getGroupEntries($key);
$scoreCount = 0;
foreach ($subEntries as $entry) {
$timeSpent[$safeKey] += $entry->finished_duration;
$meanScore[$safeKey] += $entry->score;
$scoreCount += $entry->score > 0;
}
$meanScore[$safeKey] /= max(1, $scoreCount);
}
$distMeanScore[get_class($dist)] = $meanScore;
$distTimeSpent[get_class($dist)] = $timeSpent;
}
$viewContext->creatorScores = $distMeanScore[get_class($favCreators)];
$viewContext->genreScores = $distMeanScore[get_class($favGenres)];
$viewContext->yearScores = $distMeanScore[get_class($favYears)];
$viewContext->decadeScores = $distMeanScore[get_class($favDecades)];
$viewContext->creatorTimeSpent = $distTimeSpent[get_class($favCreators)];
$viewContext->genreTimeSpent = $distTimeSpent[get_class($favGenres)];
$viewContext->typePercentages = TextHelper::roundPercentages($favTypes->getGroupsSizes());
$viewContext->genreValues = DistributionEvaluator::evaluate($favGenres);
$viewContext->creatorValues = DistributionEvaluator::evaluate($favCreators);
}
示例6: work
public static function work(&$controllerContext, &$viewContext)
{
$viewContext->viewName = 'user-history';
$viewContext->meta->title = 'MALgraph - ' . $viewContext->user->name . ' - history (' . Media::toString($viewContext->media) . ')';
$viewContext->meta->description = $viewContext->user->name . '’s ' . Media::toString($viewContext->media) . ' activity history on MALgraph, an online tool that extends your MyAnimeList profile.';
$viewContext->meta->keywords = array_merge($viewContext->meta->keywords, ['profile', 'list', 'achievements', 'ratings', 'history', 'favorites', 'suggestions', 'recommendations']);
WebMediaHelper::addHighcharts($viewContext);
WebMediaHelper::addInfobox($viewContext);
WebMediaHelper::addEntries($viewContext);
WebMediaHelper::addCustom($viewContext);
$list = $viewContext->user->getMixedUserMedia($viewContext->media);
$listFinished = UserMediaFilter::doFilter($list, UserMediaFilter::finished());
$monthlyHistoryGroups = [];
$unknownEntries = [];
$max = 0;
foreach ($listFinished as $entry) {
$key = $entry->end_date;
list($year, $month, $day) = array_map('intval', explode('-', $key));
if (!$year or !$month) {
$unknownEntries[] = $entry;
continue;
}
if (!isset($monthlyHistoryGroups[$year])) {
$monthlyHistoryGroups[$year] = [];
}
if (!isset($monthlyHistoryGroups[$year][$month])) {
$monthlyHistoryGroups[$year][$month] = [];
}
$monthlyHistoryGroups[$year][$month][] = $entry;
$max = max($max, count($monthlyHistoryGroups[$year][$month]));
}
krsort($monthlyHistoryGroups, SORT_NUMERIC);
foreach ($monthlyHistoryGroups as &$group) {
ksort($group, SORT_NUMERIC);
}
unset($group);
$viewContext->monthlyHistoryMax = $max;
$viewContext->monthlyHistoryGroups = $monthlyHistoryGroups;
$viewContext->monthlyHistoryUnknownEntries = $unknownEntries;
$dailyHistory = $viewContext->user->getHistory($viewContext->media);
$dailyHistoryGroups = [];
foreach ($dailyHistory as $historyEntry) {
$key = date('Y-m-d', strtotime($historyEntry->timestamp));
if (!isset($dailyHistoryGroups[$key])) {
$dailyHistoryGroups[$key] = [];
}
$dailyHistoryGroups[$key][] = $historyEntry;
}
krsort($dailyHistoryGroups);
$viewContext->dailyHistoryGroups = $dailyHistoryGroups;
$viewContext->isPrivate = $viewContext->user->isUserMediaPrivate($viewContext->media);
}
示例7: process
public function process(array $documents, &$context)
{
Database::delete('usermedia', ['user_id' => $context->user->id]);
$context->user->cool = false;
foreach (Media::getConstList() as $media) {
$key = $media == Media::Anime ? self::URL_ANIMELIST : self::URL_MANGALIST;
$isPrivate = strpos($documents[$key]->content, 'This list has been made private by the owner') !== false;
$key = $media == Media::Anime ? self::URL_ANIMEINFO : self::URL_MANGAINFO;
$doc = $documents[$key];
$dom = self::getDOM($doc);
$xpath = new DOMXPath($dom);
if ($xpath->query('//myinfo')->length == 0) {
throw new BadProcessorDocumentException($doc, 'myinfo block is missing');
}
if (strpos($doc->content, '</myanimelist>') === false) {
throw new BadProcessorDocumentException($doc, 'list is only partially downloaded');
}
$nodes = $xpath->query('//anime | //manga');
$data = [];
foreach ($nodes as $root) {
$mediaMalId = Strings::makeInteger(self::getNodeValue($xpath, 'series_animedb_id | series_mangadb_id', $root));
$score = Strings::makeInteger(self::getNodeValue($xpath, 'my_score', $root));
$startDate = Strings::makeDate(self::getNodeValue($xpath, 'my_start_date', $root));
$finishDate = Strings::makeDate(self::getNodeValue($xpath, 'my_finish_date', $root));
$status = Strings::makeEnum(self::getNodeValue($xpath, 'my_status', $root), [1 => UserListStatus::Completing, 2 => UserListStatus::Finished, 3 => UserListStatus::OnHold, 4 => UserListStatus::Dropped, 6 => UserListStatus::Planned], UserListStatus::Unknown);
$finishedEpisodes = null;
$finishedChapters = null;
$finishedVolumes = null;
switch ($media) {
case Media::Anime:
$finishedEpisodes = Strings::makeInteger(self::getNodeValue($xpath, 'my_watched_episodes', $root));
break;
case Media::Manga:
$finishedChapters = Strings::makeInteger(self::getNodeValue($xpath, 'my_read_chapters', $root));
$finishedVolumes = Strings::makeInteger(self::getNodeValue($xpath, 'my_read_volumes', $root));
break;
default:
throw new BadMediaException();
}
$data[] = ['user_id' => $context->user->id, 'mal_id' => $mediaMalId, 'media' => $media, 'score' => $score, 'start_date' => $startDate, 'end_date' => $finishDate, 'finished_episodes' => $finishedEpisodes, 'finished_chapters' => $finishedChapters, 'finished_volumes' => $finishedVolumes, 'status' => $status];
}
Database::insert('usermedia', $data);
$dist = RatingDistribution::fromEntries(ReflectionHelper::arraysToClasses($data));
$daysSpent = Strings::makeFloat(self::getNodeValue($xpath, '//user_days_spent_watching'));
$user =& $context->user;
$user->{Media::toString($media) . '_days_spent'} = $daysSpent;
$user->{Media::toString($media) . '_private'} = $isPrivate;
$user->cool |= ($dist->getRatedCount() >= 50 and $dist->getStandardDeviation() >= 1.5);
R::store($user);
}
}
示例8: work
public static function work(&$controllerContext, &$viewContext)
{
$viewContext->viewName = 'user-history';
$viewContext->meta->title = $viewContext->user->name . ' — History (' . Media::toString($viewContext->media) . ') — ' . Config::$title;
$viewContext->meta->description = $viewContext->user->name . '\'s ' . Media::toString($viewContext->media) . ' history.';
WebMediaHelper::addHighcharts($viewContext);
WebMediaHelper::addInfobox($viewContext);
WebMediaHelper::addEntries($viewContext);
WebMediaHelper::addCustom($viewContext);
$list = $viewContext->user->getMixedUserMedia($viewContext->media);
$listFinished = UserMediaFilter::doFilter($list, UserMediaFilter::finished());
$monthlyHistoryGroups = [];
$unknownEntries = [];
$max = 0;
foreach ($listFinished as $entry) {
$key = $entry->end_date;
list($year, $month, $day) = array_map('intval', explode('-', $key));
if (!$year or !$month) {
$unknownEntries[] = $entry;
continue;
}
if (!isset($monthlyHistoryGroups[$year])) {
$monthlyHistoryGroups[$year] = [];
}
if (!isset($monthlyHistoryGroups[$year][$month])) {
$monthlyHistoryGroups[$year][$month] = [];
}
$monthlyHistoryGroups[$year][$month][] = $entry;
$max = max($max, count($monthlyHistoryGroups[$year][$month]));
}
krsort($monthlyHistoryGroups, SORT_NUMERIC);
foreach ($monthlyHistoryGroups as &$group) {
ksort($group, SORT_NUMERIC);
}
unset($group);
$viewContext->monthlyHistoryMax = $max;
$viewContext->monthlyHistoryGroups = $monthlyHistoryGroups;
$viewContext->monthlyHistoryUnknownEntries = $unknownEntries;
$dailyHistory = $viewContext->user->getHistory($viewContext->media);
$dailyHistoryGroups = [];
foreach ($dailyHistory as $historyEntry) {
$key = date('Y-m-d', strtotime($historyEntry->timestamp));
if (!isset($dailyHistoryGroups[$key])) {
$dailyHistoryGroups[$key] = [];
}
$dailyHistoryGroups[$key][] = $historyEntry;
}
krsort($dailyHistoryGroups);
$viewContext->dailyHistoryGroups = $dailyHistoryGroups;
$viewContext->isPrivate = $viewContext->user->isUserMediaPrivate($viewContext->media);
}
示例9: work
public static function work(&$controllerContext, &$viewContext)
{
$viewContext->viewName = 'user-ratings';
$viewContext->meta->title = 'MALgraph - ' . $viewContext->user->name . ' - rating statistics (' . Media::toString($viewContext->media) . ')';
$viewContext->meta->description = $viewContext->user->name . '’s ' . Media::toString($viewContext->media) . ' rating statistics on MALgraph, an online tool that extends your MyAnimeList profile.';
$viewContext->meta->keywords = array_merge($viewContext->meta->keywords, ['profile', 'list', 'achievements', 'ratings', 'history', 'favorites', 'suggestions', 'recommendations']);
WebMediaHelper::addHighcharts($viewContext);
WebMediaHelper::addFarbtastic($viewContext);
WebMediaHelper::addInfobox($viewContext);
WebMediaHelper::addEntries($viewContext);
WebMediaHelper::addCustom($viewContext);
$list = $viewContext->user->getMixedUserMedia($viewContext->media);
$list = UserMediaFilter::doFilter($list, UserMediaFilter::nonPlanned());
$viewContext->ratingDistribution = RatingDistribution::fromEntries($list);
$viewContext->ratingTimeDistribution = RatingTimeDistribution::fromEntries($list);
$listNoMovies = UserMediaFilter::doFilter($list, UserMediaFilter::nonMovie());
$viewContext->lengthDistribution = MediaLengthDistribution::fromEntries($listNoMovies);
$f = explode('-', $viewContext->user->join_date);
if (count($f) != 3) {
$viewContext->earliestTimeKnown = null;
$viewContext->meanTime = null;
} else {
list($year, $month, $day) = $f;
$earliest = mktime(0, 0, 0, $month, $day, $year);
$totalTime = 0;
foreach ($list as $mixedUserMedia) {
$totalTime += $mixedUserMedia->finished_duration;
foreach ([$mixedUserMedia->start_date, $mixedUserMedia->end_date] as $k) {
$f = explode('-', $k);
if (count($f) != 3) {
continue;
}
$year = intval($f[0]);
$month = intval($f[1]);
$day = intval($f[2]);
if (!$year or !$month or !$day) {
continue;
}
$time = mktime(0, 0, 0, $month, $day, $year);
if ($time < $earliest) {
$earliest = $time;
}
}
}
$viewContext->earliestTimeKnown = $earliest;
$viewContext->meanTime = $totalTime / max(1, (time() - $earliest) / (24.0 * 3600.0));
}
}
示例10: work
public static function work(&$controllerContext, &$viewContext)
{
$viewContext->viewName = 'user-ratings';
$viewContext->meta->title = $viewContext->user->name . ' — Ratings (' . Media::toString($viewContext->media) . ') — ' . Config::$title;
$viewContext->meta->description = $viewContext->user->name . '\'s ' . Media::toString($viewContext->media) . ' ratings.';
WebMediaHelper::addHighcharts($viewContext);
WebMediaHelper::addFarbtastic($viewContext);
WebMediaHelper::addInfobox($viewContext);
WebMediaHelper::addEntries($viewContext);
WebMediaHelper::addCustom($viewContext);
$list = $viewContext->user->getMixedUserMedia($viewContext->media);
$list = UserMediaFilter::doFilter($list, UserMediaFilter::nonPlanned());
$viewContext->ratingDistribution = RatingDistribution::fromEntries($list);
$viewContext->ratingTimeDistribution = RatingTimeDistribution::fromEntries($list);
$listNoMovies = UserMediaFilter::doFilter($list, UserMediaFilter::nonMovie());
$viewContext->lengthDistribution = MediaLengthDistribution::fromEntries($listNoMovies);
$f = explode('-', $viewContext->user->join_date);
if (count($f) != 3) {
$viewContext->earliestTimeKnown = null;
$viewContext->meanTime = null;
} else {
list($year, $month, $day) = $f;
$earliest = mktime(0, 0, 0, $month, $day, $year);
$totalTime = 0;
foreach ($list as $mixedUserMedia) {
$totalTime += $mixedUserMedia->finished_duration;
foreach ([$mixedUserMedia->start_date, $mixedUserMedia->end_date] as $k) {
$f = explode('-', $k);
if (count($f) != 3) {
continue;
}
$year = intval($f[0]);
$month = intval($f[1]);
$day = intval($f[2]);
if (!$year or !$month or !$day) {
continue;
}
$time = mktime(0, 0, 0, $month, $day, $year);
if ($time < $earliest) {
$earliest = $time;
}
}
}
$viewContext->earliestTimeKnown = $earliest;
$viewContext->meanTime = $totalTime / max(1, (time() - $earliest) / (24.0 * 3600.0));
}
}
示例11: url
/**
* This method constructs the URL that is going to be used in layouts,
* views, etc.
*/
public static function url()
{
$args = func_get_args();
$userName = array_shift($args);
$media = array_shift($args);
$urlParts = static::getUrlParts();
$bestPart = array_shift($urlParts);
while (empty($bestPart) and !empty($urlParts)) {
$bestPart = array_shift($urlParts);
}
$url = '/' . $userName;
$url .= '/' . $bestPart;
if (!empty(static::getMediaAvailability())) {
$url .= ',' . Media::toString($media);
}
return UrlHelper::absoluteUrl($url);
}
示例12: __construct
public function __construct(array $columns)
{
foreach ($columns as $key => $value) {
$this->{$key} = $value;
}
if ($this->media == Media::Manga) {
$this->duration = 10;
}
if (isset($this->finished_episodes) and $this->media == Media::Anime) {
$this->finished_duration = $this->duration * $this->finished_episodes;
} elseif (isset($this->finished_chapters) and $this->media == Media::Manga) {
$this->finished_duration = $this->duration * $this->finished_chapters;
}
if (empty($this->title)) {
$this->title = 'Unknown ' . Media::toString($this->media) . ' entry #' . $this->mal_id;
}
$this->mal_link = 'https://myanimelist.net/' . Media::toString($this->media) . '/' . $this->mal_id;
}
示例13: AnimeProcessor
<?php
require_once __DIR__ . '/../src/core.php';
$mediaProcessors = [Media::Anime => new AnimeProcessor(), Media::Manga => new MangaProcessor()];
$mediaIds = [];
foreach (Database::getAllDbNames() as $dbName) {
Database::attachDatabase($dbName);
$query = 'SELECT um.mal_id, um.media FROM usermedia um' . ' GROUP BY um.media, um.mal_id' . ' HAVING NOT EXISTS(' . 'SELECT null FROM media m' . ' WHERE m.mal_id = um.mal_id AND m.media = um.media' . ') ORDER BY um.mal_id';
$localMediaIds = array_map(function ($row) {
$row = ReflectionHelper::arrayToClass($row);
return TextHelper::serializeMediaId($row);
}, R::getAll($query));
$mediaIds = array_merge($mediaIds, $localMediaIds);
}
$mediaIds = array_unique($mediaIds);
$pad = strlen(count($mediaIds));
$done = 0;
$exitCode = 0;
foreach ($mediaIds as $mediaId) {
try {
++$done;
list($media, $malId) = TextHelper::deserializeMediaId($mediaId);
printf("(%0{$pad}d/%d) Processing %s #%d" . PHP_EOL, $done, count($mediaIds), Media::toString($media), $malId);
$mediaProcessors[$media]->process($malId);
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
$exitCode = 1;
}
}
exit($exitCode);
示例14: printf
## Table of contents
EOF;
printf(PHP_EOL);
foreach (Media::getConstList() as $media) {
printf('### %s ' . PHP_EOL, ucfirst(Media::toString($media)));
foreach ($achList[$media] as $groupData) {
printf('* [%s / %s](#%s)' . PHP_EOL, ucfirst(Media::toString($media)), $groupData->{'wiki-title'}, md5($media . $groupData->{'wiki-title'}));
}
printf(PHP_EOL);
}
printf(PHP_EOL);
foreach (Media::getConstList() as $media) {
printf('## %s achievements' . PHP_EOL, ucfirst(Media::toString($media)));
foreach ($achList[$media] as $groupData) {
printf('<div id="%s"></div>' . PHP_EOL, md5($media . $groupData->{'wiki-title'}));
printf('### %s / %s ' . PHP_EOL, ucfirst(Media::toString($media)), $groupData->{'wiki-title'});
if (isset($groupData->{'wiki-desc'})) {
printf($groupData->{'wiki-desc'});
}
printf(PHP_EOL);
printf(PHP_EOL);
printf('<table>');
foreach ($groupData->achievements as $achievement) {
printf('<tr><td>');
if (isset($achievement->path)) {
$url = '/media/img/ach/' . $achievement->path;
printf('![%s](%s)' . PHP_EOL, $achievement->id, UrlHelper::absoluteUrl($url));
}
printf('</td><td>');
printf('**%s** ' . PHP_EOL, $achievement->title);
printf('%s' . PHP_EOL, $achievement->desc);
示例15: QueueItem
$mediaIds[] = TextHelper::serializeMediaId($entry);
}
}
}
$mediaQueue->enqueueMultiple(array_map(function ($mediaId) {
return new QueueItem($mediaId);
}, $mediaIds));
$logger->log('ok');
});
$mediaIds = [];
foreach (Media::getConstList() as $media) {
$entries = Model_Media::getOldest($media, 100);
foreach ($entries as $entry) {
$mediaAge = time() - strtotime($entry->processed);
if ($mediaAge > Config::$mediaQueueMinWait) {
$mediaIds[] = TextHelper::serializeMediaId($entry);
}
}
}
$mediaQueue->enqueueMultiple(array_map(function ($mediaId) {
return new QueueItem($mediaId);
}, $mediaIds));
#process media
processQueue($mediaQueue, Config::$mediaPerCronRun, Config::$mediaQueueMaxAttempts, $logger, function ($key) use($mediaProcessors, $logger) {
list($media, $malId) = TextHelper::deserializeMediaId($key);
$logger->log('Processing %s #%d... ', Media::toString($media), $malId);
#process the media
$mediaProcessors[$media]->process($malId);
$logger->log('ok');
});
});