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


PHP Posts::getReservationsSection方法代码示例

本文整理汇总了PHP中app\Posts::getReservationsSection方法的典型用法代码示例。如果您正苦于以下问题:PHP Posts::getReservationsSection方法的具体用法?PHP Posts::getReservationsSection怎么用?PHP Posts::getReservationsSection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Posts的用法示例。


在下文中一共展示了Posts::getReservationsSection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getPendingReservationsHTML

    static function getPendingReservationsHTML($UserID, $sameUser, &$YouHave = null)
    {
        global $Database, $currentUser;
        $YouHave = $sameUser ? 'You have' : 'This user has';
        $PrivateSection = $sameUser ? Users::PROFILE_SECTION_PRIVACY_LEVEL['staff'] : '';
        $cols = "id, season, episode, preview, label, posted, reserved_by";
        $PendingReservations = $Database->where('reserved_by', $UserID)->where('deviation_id IS NULL')->get('reservations', null, $cols);
        $PendingRequestReservations = $Database->where('reserved_by', $UserID)->where('deviation_id IS NULL')->get('requests', null, "{$cols}, reserved_at, true as requested_by");
        $TotalPending = count($PendingReservations) + count($PendingRequestReservations);
        $hasPending = $TotalPending > 0;
        $HTML = '';
        if (Permission::sufficient('staff') || $sameUser) {
            $pendingCountReadable = $hasPending > 0 ? "<strong>{$TotalPending}</strong>" : 'no';
            $posts = CoreUtils::makePlural('reservation', $TotalPending);
            $gamble = $TotalPending < 4 && $sameUser ? ' <button id="suggestion" class="btn orange typcn typcn-lightbulb">Suggestion</button>' : '';
            $HTML .= <<<HTML
<section class='pending-reservations'>
<h2>{$PrivateSection}Pending reservations{$gamble}</h2>
\t\t\t\t<span>{$YouHave} {$pendingCountReadable} pending {$posts}
HTML;
            if ($hasPending) {
                $HTML .= " which ha" . ($TotalPending !== 1 ? 've' : 's') . "n't been marked as finished yet";
            }
            $HTML .= ".";
            if ($sameUser) {
                $HTML .= " Please keep in mind that the global limit is 4 at any given time. If you reach the limit, you can't reserve any more images until you finish or cancel some of your pending reservations.";
            }
            $HTML .= "</span>";
            if ($hasPending) {
                /** @var $Posts Post[] */
                $Posts = array_merge(Posts::getReservationsSection($PendingReservations, RETURN_ARRANGED)['unfinished'], array_filter(array_values(Posts::getRequestsSection($PendingRequestReservations, RETURN_ARRANGED)['unfinished'])));
                usort($Posts, function (Post $a, Post $b) {
                    $a = strtotime($a->posted);
                    $b = strtotime($b->posted);
                    return -($a < $b ? -1 : ($a === $b ? 0 : 1));
                });
                $LIST = '';
                foreach ($Posts as $Post) {
                    unset($_);
                    $postLink = $Post->toLink($_);
                    $postAnchor = $Post->toAnchor(null, $_);
                    $label = !empty($Post->label) ? "<span class='label'>{$Post->label}</span>" : '';
                    $is_request = isset($Post->rq);
                    $reservation_time_known = !empty($Post->reserved_at);
                    $posted = Time::tag($is_request && $reservation_time_known ? $Post->reserved_at : $Post->posted);
                    $PostedAction = $is_request && !$reservation_time_known ? 'Posted' : 'Reserved';
                    $contestable = $Post->isOverdue() ? Posts::CONTESTABLE : '';
                    $LIST .= <<<HTML
<li>
<div class='image screencap'>
\t<a href='{$postLink}'><img src='{$Post->preview}'></a>
</div>
{$label}
<em>{$PostedAction} under {$postAnchor} {$posted}</em>{$contestable}
<div>
\t<a href='{$postLink}' class='btn blue typcn typcn-arrow-forward'>View</a>
\t<button class='red typcn typcn-user-delete cancel'>Cancel</button>
</div>
</li>
HTML;
                }
                $HTML .= "<ul>{$LIST}</ul>";
            }
            $HTML .= "</section>";
        }
        return $HTML;
    }
开发者ID:ponydevs,项目名称:MLPVC-RR,代码行数:67,代码来源:Users.php

示例2: array

         Response::dbError();
     }
     Logs::action('episodes', array('action' => 'del', 'season' => $Episode->season, 'episode' => $Episode->episode, 'twoparter' => $Episode->twoparter, 'title' => $Episode->title, 'airs' => $Episode->airs));
     $CGDb->where('name', "s{$Episode->season}e{$Episode->episode}")->delete('tags');
     Response::success('Episode deleted successfuly', array('upcoming' => Episodes::getSidebarUpcoming(NOWRAP)));
     break;
 case "requests":
 case "reservations":
     $only = $action === 'requests' ? ONLY_REQUESTS : ONLY_RESERVATIONS;
     $posts = Posts::get($Episode, $only);
     switch ($only) {
         case ONLY_REQUESTS:
             $rendered = Posts::getRequestsSection($posts);
             break;
         case ONLY_RESERVATIONS:
             $rendered = Posts::getReservationsSection($posts);
             break;
     }
     Response::done(array('render' => $rendered));
     break;
 case "vote":
     if (isset($_REQUEST['detail'])) {
         $VoteCountQuery = $Database->rawQuery("SELECT count(*) as value, vote as label\n\t\t\t\tFROM episodes__votes v\n\t\t\t\tWHERE season = ? && episode = ?\n\t\t\t\tGROUP BY v.vote\n\t\t\t\tORDER BY v.vote ASC", array($Episode->season, $Episode->episode));
         $VoteCounts = array('labels' => array(), 'datasets' => array(array('data' => array())));
         foreach ($VoteCountQuery as $row) {
             $VoteCounts['labels'][] = $row['label'];
             $VoteCounts['datasets'][0]['data'][] = $row['value'];
         }
         Response::done(array('data' => $VoteCounts));
     } else {
         if (isset($_REQUEST['html'])) {
开发者ID:ponydevs,项目名称:MLPVC-RR,代码行数:31,代码来源:episode.php


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