Beispiel #1
0
use App\Permission;
use App\Posts;
use App\Response;
use App\VideoProvider;
/** @var $Episode Episode */
if (!POST_REQUEST) {
    Episodes::loadPage();
}
CSRFProtection::protect();
if (empty($data)) {
    CoreUtils::notFound();
}
$data = explode('/', $data);
$action = array_splice($data, 0, 1)[0] ?? null;
$data = implode('/', $data);
$EpData = Episodes::parseID(!empty($data) ? $data : $_POST['epid'] ?? null);
if (!empty($EpData)) {
    $Episode = Episodes::getActual($EpData['season'], $EpData['episode'], Episodes::ALLOW_MOVIES);
    if (empty($Episode)) {
        Response::fail("There's no episode with this season & episode number");
    }
    $isMovie = $Episode->isMovie;
} else {
    if ($action !== 'add') {
        CoreUtils::notFound();
    }
}
switch ($action) {
    case "get":
        Response::done(array('ep' => $Episode, 'epid' => $Episode->formatTitle(AS_ARRAY, 'id'), 'caneditid' => $Episode->getPostCount() === 0));
        break;
Beispiel #2
0
 private static function _genericPostInfo(Post $Post, array $data, array &$details)
 {
     $label = CoreUtils::capitalize($data['type']) . " #{$data['id']}";
     if (!empty($Post)) {
         $label = $Post->toAnchor($label);
     }
     $details[] = array('Post', $label);
     if (empty($Post)) {
         $details[] = array('Still exists', false);
     }
     $EpID = (new Episode($Post))->formatTitle(AS_ARRAY, 'id');
     $EpData = Episodes::parseID($EpID);
     $Episode = Episodes::getActual($EpData['season'], $EpData['episode'], Episodes::ALLOW_MOVIES);
     $details[] = array('Posted under', !empty($Episode) ? "<a href='" . $Episode->formatURL() . "'>{$EpID}</a>" : $EpID . ' (now deleted/moved)');
     if (!empty($Post)) {
         $details[] = array(($data['type'] === 'request' ? 'Requested' : 'Reserved') . ' by', Users::get($data['type'] === 'request' ? $Post->requested_by : $Post->reserved_by)->getProfileLink());
         if ($data['type'] === 'request') {
             if (!empty($Post->reserved_by)) {
                 $details[] = array('Reserved by', Users::get($Post->reserved_by)->getProfileLink());
             } else {
                 $details[] = array('Reserved', false);
             }
         }
     }
 }
Beispiel #3
0
    /**
     * Returns the HTML of the "Appears in # episodes" section of appearance pages
     *
     * @param array $Appearance
     * @param bool  $allowMovies
     *
     * @return string
     */
    static function getRelatedEpisodesHTML($Appearance, $allowMovies = false)
    {
        global $CGDb;
        $EpTagsOnAppearance = $CGDb->rawQuery("SELECT t.tid\n\t\t\tFROM tagged tt\n\t\t\tLEFT JOIN tags t ON tt.tid = t.tid\n\t\t\tWHERE tt.ponyid = ? &&  t.type = 'ep'", array($Appearance['id']));
        if (!empty($EpTagsOnAppearance)) {
            foreach ($EpTagsOnAppearance as $k => $row) {
                $EpTagsOnAppearance[$k] = $row['tid'];
            }
            $EpAppearances = $CGDb->rawQuery("SELECT DISTINCT name FROM tags WHERE tid IN (" . implode(',', $EpTagsOnAppearance) . ") ORDER BY name");
            if (empty($EpAppearances)) {
                return '';
            }
            $List = '';
            foreach ($EpAppearances as $tag) {
                $name = strtoupper($tag['name']);
                $EpData = Episodes::parseID($name);
                $Ep = Episodes::getActual($EpData['season'], $EpData['episode'], $allowMovies);
                $List .= (empty($Ep) ? self::expandEpisodeTagName($name) : "<a href='{$Ep->formatURL()}'>" . $Ep->formatTitle() . '</a>') . ', ';
            }
            $List = rtrim($List, ', ');
            $N_episodes = CoreUtils::makePlural($Appearance['ishuman'] ? 'movie' : 'episode', count($EpAppearances), PREPEND_NUMBER);
            $hide = '';
        } else {
            $N_episodes = 'no episodes';
            $List = '';
            $hide = 'style="display:none"';
        }
        return <<<HTML
\t<section id="ep-appearances" {$hide}>
\t\t<h2><span class='typcn typcn-video'></span>Appears in {$N_episodes}</h2>
\t\t<p>{$List}</p>
\t</section>
HTML;
    }