private function getBlacklist() { wfProfileIn(__METHOD__); static $blacklist = null; if (is_null($blacklist)) { $lines = getMessageForContentAsArray(self::BLACKLIST_MESSAGE); $blacklist = []; if (!empty($lines)) { foreach ($lines as $line) { $image = Title::newFromText(trim($line, "* "), NS_FILE); if (!empty($image)) { $blacklist[$image->getPrefixedText()] = 1; } } wfDebug(__METHOD__ . ": blacklist loaded\n"); } else { wfDebug(__METHOD__ . ": blacklist is empty\n"); } } wfProfileOut(__METHOD__); return $blacklist; }
/** * @author Inez Korczynski <*****@*****.**> */ private function getLines($message_key) { global $wgCat; $revision = Revision::newFromTitle(Title::newFromText($message_key, NS_MEDIAWIKI)); if(is_object($revision)) { if(trim($revision->getText()) != '') { $temp = getMessageForContentAsArray($message_key); if(count($temp) > 0) { wfDebugLog('lyricsminimal', sprintf('Get LOCAL %s, which contains %s lines', $message_key, count($temp))); $lines = $temp; } } } if(empty($lines)) { if(isset($wgCat['id'])) { $temp = getMessageForContentAsArray('shared-' . $message_key . '-' . $wgCat['id']); if(count($temp) > 0) { wfDebugLog('lyricsminimal', sprintf('Get %s, which contains %s lines', 'shared-' . $message_key . '-' . $wgCat['id'], count($temp))); $lines = $temp; } } } if(empty($lines)) { $lines = getMessageForContentAsArray($message_key); wfDebugLog('lyricsminimal', sprintf('Get %s, which contains %s lines', $message_key, count($lines))); } return $lines; }
/** * @brief Gets an array of sample avatars * * @desc Method based on Masthead::getDefaultAvatars() * * @param string $thumb a thumb * * @return array multidimensional array with default avatars defined on messaging.wikia.com * * @author Andrzej 'nAndy' Łukaszewski */ private function getDefaultAvatars($thumb = '') { wfProfileIn(__METHOD__); // parse message only once per request if (empty($thumb) && is_array($this->defaultAvatars) && count($this->defaultAvatars) > 0) { wfProfileOut(__METHOD__); return $this->defaultAvatars; } $this->defaultAvatars = array(); $images = getMessageForContentAsArray('blog-avatar-defaults'); if (is_array($images)) { foreach ($images as $image) { $hash = FileRepo::getHashPathForLevel($image, 2); $this->defaultAvatars[] = array('name' => $image, 'url' => $this->defaultAvatarPath . $thumb . $hash . $image); } } wfProfileOut(__METHOD__); return $this->defaultAvatars; }
/** * getDefaultAvatars -- get avatars stored in mediawiki message and return as * array * * @param $thumb String -- if defined will be added as part of base path * default empty string "" * * @author Piotr Molski <*****@*****.**> * @author Krzysztof Krzyżaniak <*****@*****.**> * * @return array -- array with default avatars defined on messaging.wikia.com */ public function getDefaultAvatars($thumb = "") { /** * parse message only once per request */ if ($thumb == "" && is_array($this->mDefaultAvatars) && count($this->mDefaultAvatars) > 0) { return $this->mDefaultAvatars; } wfProfileIn(__METHOD__); $this->mDefaultAvatars = array(); $images = getMessageForContentAsArray('blog-avatar-defaults'); if (is_array($images)) { foreach ($images as $image) { $hash = FileRepo::getHashPathForLevel($image, 2); $this->mDefaultAvatars[] = $this->mDefaultPath . $thumb . $hash . $image; } } wfProfileOut(__METHOD__); return $this->mDefaultAvatars; }
/** * @author Inez Korczynski <*****@*****.**> */ public static function getCategoryList() { wfProfileIn(__METHOD__); global $wgCat; $cat['text'] = isset($wgCat['name']) ? $wgCat['name'] : ''; $cat['href'] = isset($wgCat['url']) ? $wgCat['url'] : ''; $message_key = 'shared-Monaco-category-list'; $nodes = array(); if (!isset($wgCat['id']) || null == ($lines = getMessageForContentAsArray($message_key . '-' . $wgCat['id']))) { wfDebugLog('monaco', $message_key . '-' . $wgCat['id'] . ' - seems to be empty'); if (null == ($lines = getMessageForContentAsArray($message_key))) { wfDebugLog('monaco', $message_key . ' - seems to be empty'); wfProfileOut(__METHOD__); return $nodes; } } foreach ($lines as $line) { $depth = strrpos($line, '*'); if ($depth === 0) { $cat = parseItem($line); } else { if ($depth === 1) { $nodes[] = parseItem($line); } } } wfProfileOut(__METHOD__); return array('nodes' => $nodes, 'cat' => $cat); }
/** * isEmptyOrFirstDefault -- check if the user has set none or uses the first of the default avatars */ public static function isEmptyOrFirstDefault($userName) { wfProfileIn(__METHOD__); global $wgStylePath; if (class_exists('Masthead')) { $avatarUrl = Masthead::newFromUserName($userName)->mUser->getGlobalAttribute(AVATAR_USER_OPTION_NAME); $images = getMessageForContentAsArray('blog-avatar-defaults'); $firstDefaultImage = $images[0]; if (empty($avatarUrl) || substr($avatarUrl, -strlen($firstDefaultImage)) === $firstDefaultImage) { wfProfileOut(__METHOD__); return true; } } else { $avatarUrl = self::getAvatarUrl($userName); $avatarDefaultUrlStart = "{$wgStylePath}/oasis/images/generic_avatar"; if ($avatarUrl === '' || strpos($avatarUrl, $avatarDefaultUrlStart) === 0) { wfProfileOut(__METHOD__); return true; } } wfProfileOut(__METHOD__); return false; }