本文整理匯總了PHP中Video::findOne方法的典型用法代碼示例。如果您正苦於以下問題:PHP Video::findOne方法的具體用法?PHP Video::findOne怎麽用?PHP Video::findOne使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Video
的用法示例。
在下文中一共展示了Video::findOne方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: showTeamBox
/**
* @param $match Match
* @param $team Team
* @param $team1votes
* @param $votesCount
*/
private function showTeamBox($match, $team, $team1votes, $votesCount)
{
$video = Video::findOne('matchid = ? and teamid = ? and type = ?',
[$match->matchid, $team->teamid, 1]);
$canVote = $this->canVote;
$team1per = 50;
if ($votesCount != 0) {
$team1per = round($team1votes / $votesCount * 100);
}
$team2 = ($match->team1id == $team->teamid) ? $match->getTeam2() : $match->getTeam1();
$isGray = ($match->isPublished() && $match->getWinner() && $match->getWinner() != $team->teamid);
?>
<div class="teambox">
<div class="votecount"><?=$team1votes?> votos (<?=$team1per?>%)</div>
<? if ($canVote) { ?>
<? if (TwitterAuth::isLogged()) { ?>
<? if (!$match->hasVoted()) { ?>
<form method="post" action="<?=HTMLResponse::getRoute()?>">
<button type="submit" class="vote">Votar</button>
<input type="hidden" name="teamid" value="<?=$team->teamid?>">
<input type="hidden" name="matchid" value="<?=$match->matchid?>">
</form>
<? } else if ($match->hasVoted() == $team->teamid) { ?>
<form method="post" action="<?=HTMLResponse::getRoute()?>">
<div class="login">
<button type="submit">Quitar voto</button>
<a target="_blank" class="twitter-share-button"
href="https://twitter.com/intent/tweet?text=<?=urlencode("¡He votado que #".$team->getHashtag()." ganará a #".$team2->getHashtag()." en la @LCE_Pokemon! http://lce.wz.tl")?>">
¡Twittear!</a>
</div>
<input type="hidden" name="unteamid" value="<?=$team->teamid?>">
<input type="hidden" name="unmatchid" value="<?=$match->matchid?>">
</form>
<? } ?>
<? } else { ?>
<a href="<?= HTMLResponse::getRoute() ?>?authenticate=1" class="login">¡Usa Twitter para votar!</a>
<? } ?>
<? } else { ?>
<? if (TwitterAuth::isLogged()) { ?>
<? if (!$match->isPublished() || !$match->getWinner()) { ?>
<? if ($match->hasVoted() == $team->teamid) { ?>
<span class="login">Has votado por este equipo</span>
<? } ?>
<? } else if ($video) { ?>
<a class="login" href="<?=htmlentities($video->link)?>" target="_blank">
Ver combate
</a>
<? } ?>
<? } else if (!$match->isPublished()) { ?>
<a href="<?= HTMLResponse::getRoute() ?>?authenticate=1" class="login">¡Entra para ver tus votos!</a>
<? } else if ($video) { ?>
<a class="login" href="<?=htmlentities($video->link)?>" target="_blank">
Ver combate
</a>
<? } ?>
<? } ?>
<a href="/<?=$this->season->getLink()?>/equipos/<?=$team->getLink()?>/"><img class="<?=$isGray?'_grayscale':''?>" src="/<?=$team->getImageLink(200, 150)?>"></a>
</div>
<?
}
示例2: showFriendlyMatches
private function showFriendlyMatches() {
$csrf = $_SESSION['csrf'];
$opponents = Model::indexBy($this->season->getTeams(), 'teamid');
$postCsrf = HTMLResponse::fromPOST('friendlycsrf', '');
if ($postCsrf == $csrf && $this->team->isManager()) {
$url = HTMLResponse::fromPOST('friendlyurl');
$opponentsId = HTMLResponse::fromPOST('friendlyopponentsid');
$publishDate = HTMLResponse::fromPOST('friendlydate');
$publishTime = HTMLResponse::fromPOST('friendlytime');
if (!strlen($publishDate)) $publishDate = date('Y-m-d');
if (!strlen($publishTime)) $publishTime = date('H').':00';
$possibleOpponents = Model::pluck($this->season->getTeams(), 'teamid');
$regex = '/^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/';
$timeRegex = "'^[0-9]{2}:[0-9]{2}$'";
$dateRegex = "'^[0-9]{4}\\-[0-9]{2}\\-[0-9]{2}$'";
$removeId = HTMLResponse::fromPOST('removeid');
if ($removeId) {
/** @var Video $video */
if ($video = Video::findOne('seasonid = ? and type = ? and videoid = ? and teamid = ?',
[$this->season->seasonid, 3, $removeId, $this->team->teamid])) {
$video->delete();
HTMLResponse::exitWithRoute(HTMLResponse::getRoute());
}
}
if (!strlen($opponentsId) || !strlen($publishTime) || !strlen($publishDate) || !strlen($url)) {
$this->design->addJavaScript("
$(function() { alert(\"No has rellenado todos los datos\"); })
", false);
} else {
if ($opponentsId != $this->team->teamid && in_array($opponentsId, $possibleOpponents)) {
if (!preg_match($regex, $url)) {
$this->design->addJavaScript("
$(function() { alert(\"El enlace que has puesto no es un enlace de YouTube válido\"); })
", false);
} else {
if (!preg_match($timeRegex, $publishTime)) {
$this->design->addJavaScript("
$(function() { alert(\"La hora que has puesto tiene un formato inválido (ha de ser 08:06)\"); })
", false);
} else {
if (!preg_match($dateRegex, $publishDate)) {
$this->design->addJavaScript("
$(function() { alert(\"La fecha que has puesto tiene un formato inválido (ha de ser 2099-12-31)\"); })
", false);
} else {
$video = Video::create();
$video->dateline = time();
$video->publishdate = $publishDate;
$video->publishtime = $publishTime;
$video->link = $url;
$video->opponentid = $opponentsId * 1;
$video->teamid = $this->team->teamid;
$video->type = 3;
$video->seasonid = $this->season->seasonid;
$video->save();
HTMLResponse::exitWithRoute(HTMLResponse::getRoute());
}
}
}
}
}
}
$videos = Video::find('seasonid = ? and teamid = ? and type = ? order by publishdate asc, publishtime asc',
[$this->season->seasonid, $this->team->teamid, 3]);
if ($videos || $this->team->isManager()) {
?>
<h2>Combates amistosos</h2>
<? if ($this->team->isManager()) { ?>
<form action="<?=HTMLResponse::getRoute()?>" method="post">
<? } ?>
<table>
<thead>
<tr>
<td>Fecha</td>
<td>Hora</td>
<td>Oponentes</td>
<td>Vídeo</td>
</tr>
</thead>
<? foreach($videos as $video) {
if (!$this->team->isManager() &&
($video->publishdate > date('Y-m-d') ||
($video->publishdate == date('Y-m-d') && $video->publishtime > date('H:i')))) {
continue;
}
?>
<tr>
<td><?= $video->publishdate ?></td>
<td><?= $video->publishtime ?></td>
<td>
<a href="/<?=$this->season->getLink()?>/equipos/<?=$opponents[$video->opponentid]->getLink()?>/">
//.........這裏部分代碼省略.........
示例3: foreach
if (date('H') * 1 == 17 && date('i') * 1 < 15) {
// 17:00 - 17:15
// Videos
foreach (Season::find('1=1') as $season) {
$weeksCount = $season->getWeeksCount();
for ($week = 1; $week <= $weeksCount; $week++) {
if ($season->getWeekDate($week) == $date) {
$weekName = $season->getWeekName($week);
$matches = Match::find('seasonid = ? and week = ?', [$season->seasonid, $week]);
foreach ($matches as $match) {
/** @var Team $team1 */
$team1 = $match->getTeam1();
/** @var Team $team2 */
$team2 = $match->getTeam2();
$video1 = Video::findOne('matchid = ? and teamid = ? and type = ?', [$match->matchid, $team1->teamid, 1]);
$video2 = Video::findOne('matchid = ? and teamid = ? and type = ?', [$match->matchid, $team2->teamid, 1]);
if ($video1 || $video2) {
$msg = "{$weekName} {$season->name}: #" . $team1->getHashtag() . " VS #" . $team2->getHashtag();
$msg .= " @{$team1->username} VS @{$team2->username}";
if ($video1) {
$msg .= " {$video1->link}";
}
if ($video2) {
$msg .= " {$video2->link}";
}
echo "-> {$msg}\n";
TwitterAuth::botSendTweet($msg);
sleep(1);
}
}
}