当前位置: 首页>>代码示例>>PHP>>正文


PHP Video::findOne方法代码示例

本文整理汇总了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">&iexcl;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">&iexcl;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>
        <?
    }
开发者ID:xJakub,项目名称:LCE,代码行数:71,代码来源:Season_Index.php

示例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()?>/">
//.........这里部分代码省略.........
开发者ID:xJakub,项目名称:LCE,代码行数:101,代码来源:Team_Index.php

示例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);
                    }
                }
            }
开发者ID:xJakub,项目名称:LCE,代码行数:31,代码来源:bot.php


注:本文中的Video::findOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。