Beispiel #1
0
 /**
  * Format log entry details
  *
  * @param array $MainEntry Main log entry
  * @param array $data      Data to process (sub-log entry)
  *
  * @return array
  */
 static function formatEntryDetails($MainEntry, $data)
 {
     global $Database, $CGDb;
     $details = array();
     $reftype = $MainEntry['reftype'];
     switch ($reftype) {
         case "rolechange":
             /** @var $target User */
             $target = $Database->where('id', $data['target'])->getOne('users');
             $details = array(array('Target user', $target->getProfileLink()), array('Old group', Permission::ROLES_ASSOC[$data['oldrole']]), array('New group', Permission::ROLES_ASSOC[$data['newrole']]));
             break;
         case "episodes":
             $details[] = array('Action', self::$ACTIONS[$data['action']]);
             $details[] = array('Name', (new Episode($data))->formatTitle());
             if ($data['season'] === 0) {
                 $details[] = array('Overall', "#{$data['episode']}");
             }
             if (!empty($data['airs'])) {
                 $details[] = array('Air date', Time::tag($data['airs'], Time::TAG_EXTENDED, Time::TAG_STATIC_DYNTIME));
             }
             $details[] = array('Two parts', !empty($data['twoparter']));
             break;
         case "episode_modify":
             $link = $data['target'];
             $EpData = Episodes::parseID($data['target']);
             if (!empty($EpData)) {
                 $Episode = Episodes::getActual($EpData['season'], $EpData['episode'], Episodes::ALLOW_MOVIES);
                 if (!empty($Episode)) {
                     $link = "<a href='" . $Episode->formatURL() . "'>" . $Episode->formatTitle(AS_ARRAY, 'id') . "</a>";
                 }
             }
             $details[] = array('Episode', $link);
             if (empty($Episode)) {
                 $details[] = array('Still exists', false);
             }
             unset($data['entryid'], $data['target']);
             $newOld = self::_arrangeNewOld($data);
             if (!empty($newOld['airs'])) {
                 $newOld['airs']['old'] = Time::tag($newOld['airs']['old'], Time::TAG_EXTENDED, Time::TAG_STATIC_DYNTIME);
                 $newOld['airs']['new'] = Time::tag($newOld['airs']['new'], Time::TAG_EXTENDED, Time::TAG_STATIC_DYNTIME);
             }
             if (isset($newOld['title']['old']) && isset($newOld['title']['new'])) {
                 $details[] = array('Title', self::charDiff($newOld['title']['old'], $newOld['title']['new']));
                 unset($newOld['title']);
             }
             foreach ($newOld as $thing => $ver) {
                 $details[] = array("Old {$thing}", $ver['old']);
                 $details[] = array("New {$thing}", $ver['new']);
             }
             break;
         case "userfetch":
             $details[] = array('User', Users::get($data['userid'])->getProfileLink());
             break;
         case "banish":
         case "un-banish":
             $details[] = array('User', Users::get($data['target'])->getProfileLink());
             $details[] = array('Reason', CoreUtils::escapeHTML($data['reason']));
             break;
         case "post_lock":
             $Post = $Database->where('id', $data['id'])->getOne("{$data['type']}s");
             self::_genericPostInfo($Post, $data, $details);
             break;
         case "color_modify":
             $details[] = array('Appearance', self::_getAppearanceLink($data['ponyid']));
             $details[] = array('Reason', CoreUtils::escapeHTML($data['reason']));
             break;
         case "req_delete":
             $details[] = array('Request ID', $data['id']);
             $typeNames = array('chr' => 'Character', 'obj' => 'Object', 'bg' => 'Background');
             $details[] = array('Description', CoreUtils::escapeHTML($data['label']));
             $details[] = array('Type', $typeNames[$data['type']]);
             $IDstr = "S{$data['season']}E{$data['episode']}";
             $details[] = array('Episode', "<a href='/episode/{$IDstr}'>{$IDstr}</a>");
             $details[] = array('Posted', Time::tag($data['posted'], Time::TAG_EXTENDED, Time::TAG_STATIC_DYNTIME));
             if (!empty($data['requested_by'])) {
                 $details[] = array('Requested by', Users::get($data['requested_by'])->getProfileLink());
             }
             if (!empty($data['reserved_by'])) {
                 $details[] = array('Reserved by', Users::get($data['reserved_by'])->getProfileLink());
             }
             $details[] = array('Finished', !empty($data['deviation_id']));
             if (!empty($data['deviation_id'])) {
                 $details[] = array('Deviation', self::_link("http://fav.me/{$data['deviation_id']}"));
                 $details[] = array('Approved', $data['lock']);
             }
             break;
         case "img_update":
             $Post = $Database->where('id', $data['id'])->getOne("{$data['thing']}s");
             $data['type'] = $data['thing'];
             self::_genericPostInfo($Post, $data, $details);
             $details[] = array('Old image', "<a href='{$data['oldfullsize']}' target='_blank'>Full size</a><div><img src='{$data['oldpreview']}'></div>");
             $details[] = array('New image', "<a href='{$data['newfullsize']}' target='_blank'>Full size</a><div><img src='{$data['newpreview']}'></div>");
             break;
         case "res_overtake":
             $Post = $Database->where('id', $data['id'])->getOne("{$data['type']}s");
             self::_genericPostInfo($Post, $data, $details);
             $details[] = array('Previous reserver', Users::get($data['reserved_by'])->getProfileLink());
             $details[] = array('Previously reserved at', Time::tag($data['reserved_at'], Time::TAG_EXTENDED, Time::TAG_STATIC_DYNTIME));
             $diff_text = '';
             $diff = Time::difference(strtotime($MainEntry['timestamp']), strtotime($data['reserved_at']));
             foreach (array_keys(Time::$IN_SECONDS) as $unit) {
                 if (empty($diff[$unit])) {
                     continue;
                 }
                 $diff_text .= CoreUtils::makePlural($unit, $diff[$unit], PREPEND_NUMBER) . ' ';
             }
             $details[] = array('In progress for', rtrim($diff_text));
             break;
         case "appearances":
             $details[] = array('Action', self::$ACTIONS[$data['action']]);
             $PonyGuide = empty($data['ishuman']);
             $details[] = array('Guide', $PonyGuide ? 'Pony' : 'EQG');
             $details[] = array('ID', self::_getAppearanceLink($data['id']));
             $details[] = array('Label', $data['label']);
             if (!empty($data['order'])) {
                 $details[] = array('Ordering index', $data['order']);
             }
             if (!empty($data['notes'])) {
                 $details[] = array('Notes', '<div>' . nl2br($data['notes']) . '</div>');
             }
             if (!empty($data['cm_favme'])) {
                 $details[] = array('CM Submission', self::_link("http://fav.me/{$data['cm_favme']}"));
                 $details[] = array('CM Orientation', CGUtils::$CM_DIR[$data['cm_dir']]);
                 if (!empty($data['cm_preview'])) {
                     $details[] = array('Custom CM Preview', "<img src='" . CoreUtils::aposEncode($data['cm_preview']) . "'>");
                 }
             }
             if (!empty($data['usetemplate'])) {
                 $details[] = array('Template applied', true);
             }
             $details[] = array('Private', !empty($data['private']));
             if (!empty($data['added'])) {
                 $details[] = array('Added', Time::tag($data['added'], Time::TAG_EXTENDED, Time::TAG_STATIC_DYNTIME));
             }
             break;
         case "res_transfer":
             $Post = $Database->where('id', $data['id'])->getOne("{$data['type']}s");
             self::_genericPostInfo($Post, $data, $details);
             $details[] = array('New reserver', Users::get($data['to'])->getProfileLink());
             break;
         case "cg_modify":
             $details[] = array('Appearance', self::_getAppearanceLink($data['ponyid']));
             $CG = $CGDb->where('groupid', $data['groupid'])->getOne('colorgroups');
             if (empty($CG)) {
                 $details[] = array('Color group ID', '#' . $data['groupid']);
                 $details[] = array('Still exists', false);
             } else {
                 $details[] = array('Group', "{$CG['label']} (#{$data['groupid']})");
             }
             if (isset($data['newlabel'])) {
                 $details[] = array('Label', self::charDiff($data['oldlabel'] ?? '', $data['newlabel']));
             }
             if (isset($data['newcolors'])) {
                 $details[] = array('Colors', self::charDiff($data['oldcolors'] ?? '', $data['newcolors'], 'block'));
             }
             break;
         case "cgs":
             $details[] = array('Action', self::$ACTIONS[$data['action']]);
             $details[] = array('Color group ID', '#' . $data['groupid']);
             $details[] = array('Label', $data['label']);
             $details[] = array('Appearance', self::_getAppearanceLink($data['ponyid']));
             if (isset($data['order'])) {
                 $details[] = array('Ordering index', $data['order']);
             }
             break;
         case "cg_order":
             $details[] = array('Appearance', self::_getAppearanceLink($data['ponyid']));
             $details[] = array('Order', self::charDiff($data['oldgroups'], $data['newgroups'], 'block'));
             break;
         case "appearance_modify":
             $details[] = array('Appearance', self::_getAppearanceLink($data['ponyid']));
             $changes = JSON::decode($data['changes']);
             $newOld = self::_arrangeNewOld($changes);
             if (isset($newOld['label']['new'])) {
                 $details[] = array('Label', self::charDiff($newOld['label']['old'], $newOld['label']['new'], 'block'));
             }
             if (isset($newOld['notes']['new']) || isset($newOld['notes']['old'])) {
                 $details[] = array('Notes', self::charDiff($newOld['notes']['old'] ?? '', $newOld['notes']['new'] ?? '', 'block smaller'));
             }
             if (isset($newOld['cm_favme']['old'])) {
                 $details[] = array('Old CM Submission', self::_link('http://fav.me/' . $newOld['cm_favme']['old']));
             } else {
                 if (isset($newOld['cm_favme']['new'])) {
                     $details[] = array('Old CM Submission', null);
                 }
             }
             if (isset($newOld['cm_favme']['new'])) {
                 $details[] = array('New CM Submission', self::_link('http://fav.me/' . $newOld['cm_favme']['new']));
             } else {
                 if (isset($newOld['cm_favme']['old'])) {
                     $details[] = array('New CM Submission', null);
                 }
             }
             $olddir = isset($newOld['cm_dir']['old']) ? CGUtils::$CM_DIR[$newOld['cm_dir']['old']] : '';
             $newdir = isset($newOld['cm_dir']['new']) ? CGUtils::$CM_DIR[$newOld['cm_dir']['new']] : '';
             if ($olddir || $newdir) {
                 $details[] = array('CM Orientation', self::charDiff($olddir, $newdir, 'inline', new FineDiff\Granularity\Paragraph()));
             }
             if (isset($newOld['private']['new'])) {
                 $details[] = array('<span class="typcn typcn-lock-' . ($newOld['private']['new'] ? 'closed' : 'open') . '"></span> ' . ($newOld['private']['new'] ? 'Marked private' : 'No longer private'), self::SKIP_VALUE, self::KEYCOLOR_INFO);
             }
             if (isset($newOld['cm_preview']['new'])) {
                 $details[] = array('New Custom CM Preview', "<img src='" . CoreUtils::aposEncode($newOld['cm_preview']['new']) . "'>");
             } else {
                 if (isset($newOld['cm_preview']['old'])) {
                     $details[] = array('New Custom CM Preview', null);
                 }
             }
             break;
         case "da_namechange":
             $User = Users::get($data['id'], 'id', 'name');
             $newIsCurrent = $User->name === $data['new'];
             $details[] = array('User', $User->getProfileLink());
             if ($newIsCurrent) {
                 $details[] = array('Old name', $data['old']);
             } else {
                 $details[] = array('Name', Logs::charDiff($data['old'], $data['new']));
             }
             break;
         case "video_broken":
             $IDstr = "S{$data['season']}E{$data['episode']}";
             $details[] = array('Episode', "<a href='/episode/{$IDstr}'>{$IDstr}</a>");
             $url = VideoProvider::getEmbed(new EpisodeVideo(array('provider' => $data['provider'], 'id' => $data['id'])), VideoProvider::URL_ONLY);
             $details[] = array('Link', "<a href='{$url}'>{$url}</a>");
             break;
         default:
             $details[] = array('<span class="typcn typcn-warning"></span> Couldn\'t process details', 'No data processor defined for this entry type', self::KEYCOLOR_ERROR);
             $details[] = array('Raw details', '<pre>' . var_export($data, true) . '</pre>');
             break;
     }
     return array('details' => $details);
 }
Beispiel #2
0
			<h2><?=$sameUser? Users::PROFILE_SECTION_PRIVACY_LEVEL['public']:''?>Vectors waiting for approval</h2>
<?  if ($sameUser){ ?>
			<p>After you finish an image and submit it to the group gallery, an admin will check your vector and may ask you to fix some issues on your image, if any. After an image is accepted to the gallery, it can be marked as "approved", which gives it a green check mark, indicating that it's most likely free of any errors.</p>
<?  } ?>
			<p><?="$YouHave ".(!$AwaitCount?'no':"<strong>$AwaitCount</strong>")?> image<?=$AwaitCount!==1?'s':''?> waiting to be submited to and/or approved by the group<?=
				!$AwaitCount
					? '.'
					: ", listed below.".(
						$sameUser
						? "Please submit $them to the group gallery as soon as possible to have $them spot-checked for any issues. As stated in the rules, the goal is to add finished images to the group gallery, making $them easier to find for everyone.".(
							$AwaitCount>10
							? " You seem to have a large number of images that have not been approved yet, please submit them to the group soon if you haven't already."
							: ''
						)
						:''
					).'</p><p>You can click the <strong class="color-green"><span class="typcn typcn-tick"></span> Check</strong> button below the '.CoreUtils::makePlural('image',$AwaitCount).' in case we forgot to click it ourselves after accepting it.'?></p>
<?  if ($AwaitCount){ ?>
			<ul id="awaiting-deviations"><?
		foreach ($AwaitingApproval as $Post){
			$deviation = DeviantArt::getCachedSubmission($Post->deviation_id);
			$url = "http://{$deviation['provider']}/{$deviation['id']}";
			unset($_);
			$postLink = $Post->toLink($_);
			$postAnchor = $Post->toAnchor(null, $_);
			$checkBtn = Permission::sufficient('member') ? "<button class='green typcn typcn-tick check'>Check</button>" : '';

			echo <<<HTML
<li id="{$Post->getID()}">
	<div class="image deviation">
		<a href="$url" target="_blank">
			<img src="{$deviation['preview']}" alt="{$deviation['title']}">
Beispiel #3
0
 function testMakePlural()
 {
     $result = CoreUtils::makePlural('apple', 2);
     self::assertEquals('apples', $result);
     $result = CoreUtils::makePlural('apple', 1);
     self::assertEquals('apple', $result);
     $result = CoreUtils::makePlural('apple', 2, true);
     self::assertEquals('2 apples', $result);
     $result = CoreUtils::makePlural('apple', 1, true);
     self::assertEquals('1 apple', $result);
     $result = CoreUtils::makePlural('staff member', 2, true);
     self::assertEquals('2 staff members', $result);
 }
Beispiel #4
0
     $Posts = $Database->rawQuery("SELECT 'request' as type, id, deviation_id FROM requests WHERE deviation_id IN ({$list}) && lock = false\n\t\tUNION ALL\n\t\tSELECT 'reservation' as type, id, deviation_id FROM reservations WHERE deviation_id IN ({$list}) && lock = false");
     if (empty($Posts)) {
         Response::success('There were no posts in need of marking as approved');
     }
     $approved = 0;
     foreach ($Posts as $p) {
         if (CoreUtils::isDeviationInClub($p['deviation_id']) !== true) {
             continue;
         }
         Posts::approve($p['type'], $p['id']);
         $approved++;
     }
     if ($approved === 0) {
         Response::success('There were no posts in need of marking as approved');
     }
     Response::success('Marked ' . CoreUtils::makePlural('post', $approved, PREPEND_NUMBER) . ' as approved. To see which ones, check the <a href="/admin/logs/1?type=post_lock&by=you">list of posts you\'ve approved</a>.', array('reload' => true));
 } else {
     if ($data === 'add-reservation') {
         if (!Permission::sufficient('staff')) {
             Response::fail();
         }
         $_POST['allow_overwrite_reserver'] = true;
         $insert = Posts::checkRequestFinishingImage();
         if (empty($insert['reserved_by'])) {
             $insert['reserved_by'] = $currentUser->id;
         }
         $epdata = (new Input('epid', 'epid', array(Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_MISSING => 'Episode identifier is missing', Input::ERROR_INVALID => 'Episode identifier (@value) is invalid'))))->out();
         $epdata = Episodes::getActual($epdata['season'], $epdata['episode']);
         if (empty($epdata)) {
             Response::fail('The specified episode does not exist');
         }
Beispiel #5
0
     if (empty($Tag)) {
         Response::fail("This tag does not exist");
     }
 }
 $data = array();
 switch ($action) {
     case 'get':
         Response::done($Tag);
     case 'del':
         $AppearanceID = Appearances::validateAppearancePageID();
         $tid = !empty($Tag['synonym_of']) ? $Tag['synonym_of'] : $Tag['tid'];
         $Uses = $CGDb->where('tid', $tid)->get('tagged', null, 'ponyid');
         $UseCount = count($Uses);
         if (!isset($_POST['sanitycheck'])) {
             if ($UseCount > 0) {
                 Response::fail('<p>This tag is currently used on ' . CoreUtils::makePlural('appearance', $UseCount, PREPEND_NUMBER) . '</p><p>Deleting will <strong class="color-red">permanently remove</strong> the tag from those appearances!</p><p>Are you <em class="color-red">REALLY</em> sure about this?</p>', array('confirm' => true));
             }
         }
         if (!$CGDb->where('tid', $Tag['tid'])->delete('tags')) {
             Response::dbError();
         }
         if (!empty(CGUtils::GROUP_TAG_IDS_ASSOC[$Tag['tid']])) {
             Appearances::getSortReorder($EQG);
         }
         foreach ($Uses as $use) {
             Appearances::updateIndex($use['ponyid']);
         }
         Response::success('Tag deleted successfully', isset($AppearanceID) && $Tag['type'] === 'ep' ? array('needupdate' => true, 'eps' => Appearances::getRelatedEpisodesHTML($AppearanceID, $EQG)) : null);
         break;
     case 'unsynon':
         if (empty($Tag['synonym_of'])) {
Beispiel #6
0
 static function getAppearancesSectionHTML(Episode $Episode) : string
 {
     global $CGDb, $Color;
     $HTML = '';
     $EpTagIDs = Episodes::getTagIDs($Episode);
     if (!empty($EpTagIDs)) {
         $TaggedAppearances = $CGDb->rawQuery("SELECT p.id, p.label, p.private\n\t\t\t\tFROM tagged t\n\t\t\t\tLEFT JOIN appearances p ON t.ponyid = p.id\n\t\t\t\tWHERE t.tid IN (" . implode(',', $EpTagIDs) . ") && p.ishuman = ?\n\t\t\t\tORDER BY p.label", array($Episode->isMovie));
         if (!empty($TaggedAppearances)) {
             $hidePreviews = UserPrefs::get('ep_noappprev');
             $pages = CoreUtils::makePlural('page', count($TaggedAppearances));
             $HTML .= "<section class='appearances'><h2>Related <a href='/cg'>{$Color} Guide</a> {$pages}</h2>";
             $LINKS = '<ul>';
             $isStaff = Permission::sufficient('staff');
             foreach ($TaggedAppearances as $p) {
                 $safeLabel = Appearances::getSafeLabel($p);
                 if (Appearances::isPrivate($p, true)) {
                     $preview = "<span class='typcn typcn-" . ($isStaff ? 'lock-closed' : 'time') . " color-" . ($isStaff ? 'orange' : 'darkblue') . "'></span> ";
                 } else {
                     if ($hidePreviews) {
                         $preview = '';
                     } else {
                         $preview = Appearances::getPreviewURL($p);
                         $preview = "<img src='{$preview}' class='preview'>";
                     }
                 }
                 $LINKS .= "<li><a href='/cg/v/{$p['id']}-{$safeLabel}'>{$preview}{$p['label']}</a></li>";
             }
             $HTML .= "{$LINKS}</ul></section>";
         }
     }
     return $HTML;
 }
Beispiel #7
0
    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;
    }
Beispiel #8
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;
    }
Beispiel #9
0
$Users = $Database->orderBy('name', 'asc')->get('users');
if (!empty($Users)) {
    $Arranged = array();
    foreach ($Users as $u) {
        if (!isset($Arranged[$u->role])) {
            $Arranged[$u->role] = array();
        }
        $Arranged[$u->role][] = $u;
    }
    foreach (array_reverse(Permission::ROLES) as $r => $v) {
        if (empty($Arranged[$r])) {
            continue;
        }
        /** @var $users \App\Models\User[] */
        $users = $Arranged[$r];
        $group = CoreUtils::makePlural(Permission::ROLES_ASSOC[$r], count($users), true);
        $groupInitials = '[' . Permission::labelInitials($r) . ']';
        $usersStr = array();
        foreach ($users as $u) {
            $usersStr[] = $u->getProfileLink();
        }
        $usersStr = implode(', ', $usersStr);
        echo <<<HTML
<section>
\t<h2>{$group} {$groupInitials}</h2>
\t{$usersStr}
</section>
HTML;
    }
}
?>