/** * get content warning approved * @responseParam integer contentWarningApproved [0/1] */ public function getContentWarningApproved() { wfProfileIn(__METHOD__); $contentWarningApproved = 0; if ($this->wg->User->isLoggedIn()) { $userId = $this->wg->User->getId(); $memKey = $this->getMemKeyContentWarning($userId); $contentWarningApproved = $this->wg->Memc->get($memKey); if (empty($contentWarningApproved)) { $contentWarningApproved = intval(wfGetWikiaPageProp(WPP_CONTENT_WARNING, $userId)); $this->wg->Memc->set($memKey, $contentWarningApproved, 60 * 60 * 12); } } wfProfileOut(__METHOD__); $this->contentWarningApproved = intval($contentWarningApproved); }
public function setImageNameFromProps() { $pageId = Title::newFromText($this->pageName)->getArticleId(); $this->imageName = wfGetWikiaPageProp(self::WIKI_HERO_IMAGE_PROP_ID, $pageId); $this->initializeImagePaths($this->cropPosition); }
public function swapBoards($boardId1, $boardId2) { $orderId1 = wfGetWikiaPageProp(WPP_WALL_ORDER_INDEX, $boardId1); $orderId2 = wfGetWikiaPageProp(WPP_WALL_ORDER_INDEX, $boardId2); if (empty($orderId1) || empty($orderId2)) { return false; } wfSetWikiaPageProp(WPP_WALL_ORDER_INDEX, $boardId1, $orderId2); wfSetWikiaPageProp(WPP_WALL_ORDER_INDEX, $boardId2, $orderId1); }
/** * Move prop in page_wikia_props table to new article * @param integer $type * @param integer $oldArticleId * @param integer $newArticleId */ public function moveWikiaPageProp($type, $oldArticleId, $newArticleId) { $prop = wfGetWikiaPageProp($type, $oldArticleId); if (!empty($prop)) { wfDeleteWikiaPageProp($type, $oldArticleId); wfSetWikiaPageProp($type, $newArticleId, $prop); } }
protected function getPropVal($prop) { wfProfileIn(__METHOD__); $key = $this->getPropCacheKey(); // check local memory cache if (array_key_exists($prop, $this->propsCache)) { wfProfileOut(__METHOD__); return $this->propsCache[$prop]; } wfProfileIn(__METHOD__ . "_1"); // check memcache $cache = $this->getCache(); $fromcache = $cache->get($key); if (!empty($fromcache)) { $this->propsCache = $fromcache; } if ($this->propsCache === false) { $this->propsCache = array(); } //we have it memc if (array_key_exists($prop, $this->propsCache)) { wfProfileOut(__METHOD__ . "_1"); wfProfileOut(__METHOD__); return $this->propsCache[$prop]; } //we don't lets add it $this->propsCache[$prop] = wfGetWikiaPageProp($prop, $this->getId()); $cache->set($key, $this->propsCache); wfProfileOut(__METHOD__ . "_1"); wfProfileOut(__METHOD__); return $this->propsCache[$prop]; }
/** * If this song is on takedown list... replace the lyrics content with a message about why * it is gone. This will replace the content of all <lyrics> tags on the page (also <lyricfind> * and <gracenotelyrics> tags for support of legacy pages). * * @param Parser $parser * @param $text a string containing the wikitext (this is _not_ a Text object). * @param strip_state (undocumented) */ public static function onParserBeforeStrip(Parser $parser, &$text, &$strip_state) { $removedProp = wfGetWikiaPageProp(WPP_LYRICFIND_MARKED_FOR_REMOVAL, $parser->getTitle()->getArticleID()); $isMarkedAsRemoved = !empty($removedProp); if ($isMarkedAsRemoved) { // Replace just the lyrics boxes if any are found. If none are found, hide the whole page. $NO_LIMIT = -1; $numReplacements = 0; $text = preg_replace("/<(lyrics|lyricfind|gracenotelyrics)>(.*?)<\\/(lyrics|lyricfind|gracenotelyrics)>/is", "<lyrics>{{lyricfind_takedown}}</lyrics>", $text, $NO_LIMIT, $numReplacements); } return true; }
private function read() { wfProfileIn(__METHOD__); $this->isEnabled = 0; $oTitle = Title::newFromText($this->sTitle); if (is_object($oTitle) && $oTitle instanceof Title) { $oTitle->exists(); $this->pageId = $oTitle->getArticleID(); if (empty($this->pageId)) { wfProfileOut(__METHOD__); return false; } } else { wfProfileOut(__METHOD__); return false; } $this->isEnabled = $this->memc->get($this->getMemcKey()); // if memc was empty if ($this->isEnabled === false) { wfDebug(__METHOD__ . " - memcache miss for #{$this->pageId}\n"); $this->isEnabled = wfGetWikiaPageProp(WPP_PLACES_CATEGORY_GEOTAGGED, $this->pageId); $this->memc->set($this->getMemcKey(), $this->isEnabled, self::CACHE_TTL); } else { wfDebug(__METHOD__ . " - memcache hit for #{$this->pageId}\n"); } wfProfileOut(__METHOD__); return true; }
protected function getWikiaProp($propName, $articleId) { return wfGetWikiaPageProp($propName, $articleId, $this->dbVersion); }
/** * get properties for page, maybe it should be cached? * * @access public * @static * * @return Array */ public static function getProps($page_id) { wfProfileIn(__METHOD__); $return = array(); $types = self::getPropsList(); foreach ($types as $key => $value) { $return[$key] = (int) wfGetWikiaPageProp($value, $page_id); } wfProfileOut(__METHOD__); wfDebug(__METHOD__ . ": getting props for {$page_id}\n"); return $return; }
function getSong($artist, $song = "", $doHyphens = true, $ns = NS_MAIN, $isOuterRequest = true, $debug = false, &$lyricsTagFound = false, $allowFullLyrics = false) { wfProfileIn(__METHOD__); wfDebug("LWSOAP: inside " . __METHOD__ . "\n"); if ($isOuterRequest) { $id = requestStarted(__METHOD__, "{$artist}|{$song}"); } $lyricsTagFound = false; $debugSuffix = "_debug"; $artist = rawurldecode($artist); $song = rawurldecode($song); // Trick to show debug output. Just add the debugSuffix to the end of the song name, and debug output will be displayed. if (strlen($song) >= strlen($debugSuffix) && substr($song, 0 - strlen($debugSuffix)) == $debugSuffix) { $song = substr($song, 0, strlen($song) - strlen($debugSuffix)); // remove debug-suffix $debug = true; } //GLOBAL $debug; // Do NOT do this. This will effectively un-set the local var. if ($debug) { // Testing the UTF8 issues with incoming values. print "ARTIST: {$artist}\n"; print "ENCODE: " . utf8_encode($artist) . "\n"; print "DECODE: " . utf8_decode($artist) . "\n"; } $LW_NS_STRING = "LyricWiki"; // TODO: FIXME: There MUST be a more programattic way to get this :P if ($artist == $LW_NS_STRING) { $artist = $song; $song = ""; $ns = NS_PROJECT; print !$debug ? "" : "LyricWiki page was explicitly requested. Now looking for \"{$artist}\" in the LyricWiki namespace."; } $origArtist = $artist; // for logging the failed requests, record the original name before we start messing with it $origSong = $song; $lookedFor = ""; // which titles we looked for. Used in SOAP failures - TODO: REFACTOR TO BE AN ARRAY... SRSLY. $artist = trim(html_entity_decode($artist)); $song = trim(html_entity_decode($song)); $artist = preg_replace("/(\\s)+/", "\\1", $artist); // removes multiple spaces in a row $song = preg_replace("/(\\s)+/", "\\1", $song); if ($artist == "-") { // surprisingly common. If this is the artist, the whole artist and song tend to be in the song. $artist = ""; $song = str_replace(" - ", ":", $song); } $defaultLyrics = "Not found"; $defaultUrl = "http://lyrics.wikia.com"; $nsString = $ns == NS_PROJECT ? $LW_NS_STRING . ":" : ""; $urlRoot = "http://lyrics.wikia.com/"; // may differ from default URL, should contain a slash after it. $instrumental = "Instrumental"; $DENIED_NOTICE = "Unfortunately, due to licensing restrictions from some of the major music publishers we can no longer return lyrics through the LyricWiki API (where this application gets some or all of its lyrics).\n"; $DENIED_NOTICE .= "\nThe lyrics for this song can be found at the following URL:\n"; $DENIED_NOTICE_SUFFIX = "\n\n\n(Please note: this is not the fault of the developer who created this application, but is a restriction imposed by the music publishers themselves.)"; //$TRUNCATION_NOTICE = "Our licenses prevent us from returning the full lyrics to this song via the API. For full lyrics, please visit: $urlRoot"."$nsString$artist:$song"; $retVal = array('artist' => $artist, 'song' => $song, 'lyrics' => $defaultLyrics, 'url' => $defaultUrl, 'page_namespace' => '', 'page_id' => '', 'isOnTakedownList' => false); global $SHUT_DOWN_API; if ($SHUT_DOWN_API) { $retVal = array('artist' => $artist, 'song' => $song, 'lyrics' => $defaultLyrics, 'url' => 'http://lyrics.wikia.com', 'page_namespace' => '', 'page_id' => '', 'isOnTakedownList' => false); global $SHUT_DOWN_API_REASON; $retVal['lyrics'] = $SHUT_DOWN_API_REASON; } else { // WARNING: This may cause some unexpected results if these artists ever become actual pages. // These are "artists" which are very commonly accuring non-artists. IE: Baby Einstein is a collection of classical music, Apple Inc. is just apple's (video?) podcasts $nonArtists = array("baby einstein", "apple inc.", "soundtrack", "various", "various artists", "the howard stern show", "frequence3.fr", "frequence3", "http://www.radiofg.com", "radio paradise", "webex", "brought to you by santrex.net", "3fm", "no artist", "thank you for using starplayr"); // Lots of files are getting requested for some reason. if (strlen($song) >= 4) { $ending = strtolower(substr($song, -4)); if ($ending == ".php" || $ending == ".png") { $song = ""; // not a valid song. } } global $wgRequest; $lowerSong = strtolower($song); $lowerArtist = strtolower($artist); if (($artist == "" || $song == "" || 0 < preg_match("/^\\?+\$/", $artist)) && strpos("{$artist}{$song}", ":") === false && $ns != NS_PROJECT) { // NOTE: For now we leave the 'defaultLyrics' message for players that handle this explicitly as not being a match. print !$debug ? "" : "Title doesn't appear to be a valid song title. Artist: \"{$artist}\" Song: \"{$song}\"\n"; } else { if ($song == "unknown" || ($lowerArtist == "unknown" || $lowerArtist == "artist") && $lowerSong == "unknown" || 0 < preg_match("/^Track [0-9]+\$/i", $song) || strtolower($song) == "favicon.png") { // If the song is "unkown" (all lowercase) this is usually just a default failure. If they are looking for a song named "Unknown", and they use the caps, it will get through (unless the band name also happens to be "Unknown") print !$debug ? "" : "Found title which is a commonly-passed-in error title (usually bad metadata on song files).\n"; // NOTE: For now we leave the 'defaultLyrics' message for players that handle this explicitly as not being a match. } else { if (in_array($lowerArtist, $nonArtists)) { // These are "artists" which are very commonly accuring non-artists. IE: Baby Einstein is a collection of classical music, Apple Inc. is just apple's (video?) podcasts print !$debug ? "" : "Found a 'non-artist' which is often a radio station, podcast, etc..\n"; // NOTE: For now we leave the 'defaultLyrics' message for players that handle this explicitly as not being a match. } else { // TODO: SHOULDN'T MOST OF THE REWRITES BELOW BE IN lw_getTitle() INSTEAD OF HERE?? // Attempt to interpret hyphen-delimited title/artist/ablum strings correctly. $lastHyphen = false; // if this isn't false and there is no result, then the whole thing will be tried again using hyphenSong as the song. if ($doHyphens) { // can be turned off so that a second pass can be made without this hyphen trick if it doesn't work the first time. $song = str_replace("_", " ", $song); // just so that we can use one strrpos on just one format $HYPHEN_DELIM = " - "; $lastHyphen = strrpos($song, $HYPHEN_DELIM); if ($lastHyphen !== false) { $hyphenSong = $origSong; // in case there are no responses, this will be fed back into the same function but with this hyphen trick turned off $song = substr($song, $lastHyphen + strlen($HYPHEN_DELIM)); print !$debug ? "" : "Hyphens trimmed to new title: \"{$artist}:{$song}\"\n"; } } // Wiki technical-restrictions. See: http://www.lyricwiki.org/LyricWiki:Page_names#Technical_Restrictions print !$debug ? "" : "Before substitutions: \"{$artist}:{$song}\"\n"; $transArray = array("<" => "Less Than", ">" => "Greater Than", "#" => "Number ", "{" => "(", "}" => ")"); $song = strtr($song, $transArray); $artist = strtr($artist, $transArray); if (strpos($song, "[") !== false) { $song = preg_replace("/\\s*\\[.*/i", "", $song); } if (strpos($artist, "[") !== false) { $artist = preg_replace("/\\s*\\[.*/i", "", $artist); } print !$debug ? "" : "After substitutions: \"{$artist}:{$song}\"\n"; // Strip the "featuring" artists. $index = strpos(strtolower($artist), " ft."); $index = $index === false ? strpos(strtolower($artist), " feat.") : $index; $index = $index === false ? strpos(strtolower($artist), " featuring") : $index; $index = $index === false ? strpos(strtolower($artist), " ft ") : $index; if ($index !== false) { $artist = substr($artist, 0, $index); } // Strip the "featuring" from song names - SWC 20070912 $index = strpos(strtolower($song), " ft."); $index = $index === false ? strpos(strtolower($song), " feat.") : $index; $index = $index === false ? strpos(strtolower($song), " featuring") : $index; $index = $index === false ? strpos(strtolower($song), " ft ") : $index; if ($index !== false) { $song = substr($song, 0, $index); } // Format the title (flexible for variously formated inputs). $isUTF = utf8_compliant("{$artist}:{$song}"); print !$debug ? "" : "Formatting \"{$artist}:{$song}\"\n"; print !$debug ? "" : "utf8_compliant: " . utf8_compliant("{$artist}:{$song}") . "\n"; $title = lw_getTitle($artist, $song, !$isUTF); // if isUTF, skips the utf8 encoding (that is only for the values from the db... from the URL they should be fine already). print !$debug ? "" : "utf8_compliant: " . utf8_compliant("{$title}") . " - {$title}\n"; print !$debug ? "" : "Looking for \"{$title}\"\n"; // If the song was not found... use some tricks to try to find it. - SWC 20061209 if (!lw_pageExists($title, $ns)) { $lookedFor .= "{$title}\n"; print !$debug ? "" : "Not found...\n"; /** ATTEMPT: IMPLIED REDIRECTS **/ // If the artist has a redirect on their own page, that generally means that all songs belong to that finalized name... // so try to grab the song using that version of the artist's name. $artistTitle = lw_getTitle($artist); // leaves the original version in tact $finalName = $artistTitle; // NOTE: This is intentionally ONLY in NS_MAIN rather than '$ns'. Artist redirects should all be done in the main namespace. $page = lw_getPage($artistTitle, $finalName, $debug, NS_MAIN); // this is done for the side-effects of setting finalName. print !$debug ? "" : "found:\n{$page}"; if ($finalName != $artistTitle) { print !$debug ? "" : "Artist redirect found to \"{$finalName}\". Applying to song \"{$song}\".\n"; // If the redirect is just to different capitalization, then use the special // caps instead of letting lw_getTitle() overwrite this capitalization-change. if (strtolower($finalName) == strtolower($artistTitle)) { $title = "{$finalName}:" . lw_getTitle($song, "", false); // 'false' is to prevent re-utf8_encoding the strings } else { $title = lw_getTitle($finalName, $song, false); // 'false' is to prevent re-utf8_encoding the strings } print !$debug ? "" : "Title \"{$title}\"\n"; } $lookedFor .= "{$title}\n"; if (!lw_pageExists($title, $ns)) { print !$debug ? "" : "Not found...\n"; /** ATTEMPT: REMOVE TRAILING PARENTHESES **/ // If the song was still not found... chop off any trailing parentheses and try again. - SWC 20070101 print !$debug ? "" : "{$title} not found.\n"; $finalSong = preg_replace("/\\s*\\(.*\$/", "", $song); if ($song != $finalSong) { $title = lw_getTitle($finalName, $finalSong); print !$debug ? "" : "Looking without parentheses for \"{$title}\"\n"; } } else { print !$debug ? "" : "{$title} found.\n"; } $lookedFor .= "{$title}\n"; if (!lw_pageExists($title, $ns)) { print !$debug ? "" : "Not found...\n"; /** ATTEMPT: ORIGINAL SONG CAPITALIZATION - SWC 20110609 **/ // If the title wasn't found from any previous tricks, try the original song capitalization that was passed in (with the possibly-rewritten artist name). // NOTE: lw_pageExists() caches results, so re-looking up the same one if capitalization is the same, is not a problem... however, if that ends up being // a lot of overhead at some point, we could make it only try this again if the new $title is not in $lookedFor already. if ($isOuterRequest) { $title = "{$finalName}:" . utf8_encode($song); // not lw_getTitle so that original capitalization survives } else { $title = "{$finalName}:{$song}"; // this was an inner (eg: recursive) request. encoding was already done. } print !$debug ? "" : "Looking with original song capitalization for \"{$title}\"\n"; } else { print !$debug ? "" : "{$title} found.\n"; } } $lookedFor .= "{$title}\n"; if (lw_pageExists($title, $ns, $debug)) { $finalName = $page_id = ""; $content = lw_getPage($title, $finalName, $debug, $ns, $page_id); // LYR-7 - if pages are on LyricFind takedown list, remove their content here. $pageRemovedProp = wfGetWikiaPageProp(WPP_LYRICFIND_MARKED_FOR_REMOVAL, $page_id); if (!empty($pageRemovedProp)) { // Overwrite with the same content that normal takedowns used before LF API (this lets the // Community easily update the text since it's a template). $content = "{{lyricfind_takedown}}"; } // Parse the lyrics from the content. $matches = array(); if (0 < preg_match("/<(gracenotelyrics|lyrics?)>(.*)<.(gracenotelyrics|lyrics?)>/si", $content, $matches) || 0 < preg_match("/<(gracenotelyrics|lyrics?)>(.*)/si", $content, $matches)) { $content = $matches[2]; // Grabs lyrics if they are inside of lyrics tags. // Sometimes when people convert to the new lyrics tags, they forget to delete the spaces at the beginning of the lines. if (0 < preg_match("/(\n [^\n]*)+/si", $content, $matches)) { //$content = $matches[0]; $content = str_replace("\n ", "\n", $content); } // In case the page uses the instrumental template but uses it inside of lyrics tags. if (0 < preg_match("/\\{\\{instrumental\\}\\}/si", $content, $matches)) { $content = $instrumental; } $lyricsTagFound = true; } else { if (0 < preg_match("/(\n [^\n]*)+/si", $content, $matches)) { $content = $matches[0]; // Grabs lyrics if they use the space-at-the-beginning-of-the-line format. $content = str_replace("\n ", "\n", $content); $lyricsTagFound = true; } else { if (0 < preg_match("/\\{\\{instrumental\\}\\}/si", $content, $matches)) { $content = $instrumental; $lyricsTagFound = true; } else { if (strlen(trim($content)) > 0) { $lyricsTagFound = false; // TODO: Log the page which didn't parse here for purposes of fixing poorly formatted pages. // NOTE: at the moment, getAlbum() depends on this result still being wikitext and parses it. This dependency will be removed when the code is refactored so that the fuzzy title-matching is not in THIS function. } } } } $content = trim($content); $url = $urlRoot . $nsString . str_replace("%3A", ":", urlencode($finalName)); // %3A as ":" is for readability. $retVal['artist'] = $artist; $retVal['song'] = $song; $retVal['lyrics'] = $content; $retVal['url'] = $url; // Additional data to help with tracking the hits (formerly for Gracenote royalty payments, now we use LF API instead). $retVal['page_namespace'] = $ns; $retVal['page_id'] = $page_id; // Set the artist and song to the artist and song which were actually found (not what was passed in). $index = strpos($finalName, ":"); if ($index !== false) { $retVal['artist'] = str_replace("_", " ", substr($finalName, 0, $index)); $retVal['song'] = str_replace("_", " ", substr($finalName, $index + 1)); } } if ($retVal['lyrics'] == '' || $retVal['lyrics'] == $defaultLyrics) { $url = $urlRoot . "index.php?title={$nsString}" . str_replace("%3A", ":", urlencode($title)); // %3A as ":" is for readability. $retVal['url'] = "{$url}&action=edit"; $retVal['artist'] = $origArtist; $retVal['song'] = $origSong; // Log the looked-for-but-not-found lyrics here. Make sure the logging keeps track of the total number of times // a song was looked for so that we can find the most desired lyrics and fill them in. $origArtistSql = str_replace("'", "\\'", $origArtist); $origSongSql = str_replace("'", "\\'", $origSong); $lookedForSql = str_replace("'", "\\'", trim($lookedFor)); // \n-delimited list of titles looked for by the API which weren't found. // This section doesn't appear to do anything at the moment. The artist and title still have bad-encoding even though lookedFor is encoded properly (lookedFor is a blob - does that matter?). if (!utf8_compliant("{$origArtistSql}")) { $origArtistSql = utf8_encode($origArtistSql); } if (!utf8_compliant("{$origSongSql}")) { $origSongSql = utf8_encode($origSongSql); } logSoapFailure($origArtistSql, $origSongSql, $lookedForSql); } // If there was no result, give it another try without the hyphen trick. if ($retVal['lyrics'] == $defaultLyrics && $lastHyphen !== false) { // this logic should be kept even if isOuterRequest is false print !$debug ? "" : "Trying again but assuming hyphens are part of the song name...\n"; $retVal = getSong($origArtist, $hyphenSong, false, $ns, false, $debug); // the first false stops the hyphen trick from being tried again, the second false indicates that this is a recursive call } // Done looking for matches, there is either a match or not at this point. // Do cleanup tasks like recording stats & truncating lyrics for copyright reasons. // Fallback search is done afterwards. if ($isOuterRequest) { // Record whether a successful result was served. Log this to get a good percentage of how many requests are made and what percentage are handled. if (!$SHUT_DOWN_API) { // SWC 20090501 - Shut this down to reduce database load. I don't generally track the success rate right now, so it's pretty flat around 50%. // Can re-enable this later if we actually start paying attention to this again. // SWC 20101017 - Rewriting this to use memcached. Should be fast enough now. include_once __DIR__ . "/soap_stats.php"; // for tracking success/failure $resultFound = $retVal['lyrics'] != $defaultLyrics; $reqType = $wgRequest->getVal("fullApiAuth", "") == "" ? LW_API_TYPE_WEB : LW_API_TYPE_MOBILE; lw_soapStats_logHit($resultFound, $reqType); } // SWC 20101209 - Now we allow our own apps to get full lyrics, but the request has to be cryptographically signed so that others can't do the same thing. // NOTE: The value of the fullApiAuth param for the request must be the md5 hash of the concatenation of wgFullLyricWikiApiToken, the artist, and the song. $fullApiAuth = $wgRequest->getVal("fullApiAuth"); if (!empty($fullApiAuth)) { global $wgFullLyricWikiApiToken; print !$debug ? "" : "Comparing token against artist: {$artist}\n"; print !$debug ? "" : "Comparing token against song: {$song}\n"; $expectedSig = md5($wgFullLyricWikiApiToken . "{$origArtist}{$origSong}"); if ($expectedSig == $fullApiAuth) { $allowFullLyrics = true; } } // Determine if this result was from the takedown list (must be done before truncating to a snippet, below). $retVal['isOnTakedownList'] = 0 < preg_match("/\\{\\{(gracenote|lyricfind)[ _]takedown\\}\\}/", $retVal['lyrics']); // SWC 20090802 - Neuter the actual lyrics :( - return an explanation with a link to the LyricWiki page. // SWC 20091021 - Gil has determined that up to 17% of the lyrics can be returned as fair-use - we'll stick with 1/7th (about 14.3%) of the characters for safety. if (!$allowFullLyrics) { if ($retVal['lyrics'] != $defaultLyrics && $retVal['lyrics'] != $instrumental && $retVal['lyrics'] != "") { $urlLink = "\n\n<a href='" . $retVal['url'] . "'>" . $retVal['artist'] . ":" . $retVal['song'] . "</a>"; $lyrics = $retVal['lyrics']; if (mb_strlen($lyrics) < 50) { if ($lyrics == "{{lyricfind_takedown}}") { // TODO: INJECT THE ACTUAL RESULT OF THE TEMPLATE IN HERE INSTEAD!! $lyrics = "We don't currently have a license for these lyrics. Please try again in a few days!"; } else { $lyrics = "[...]"; } } else { $lyrics = mb_substr($lyrics, 0, max(0, round(mb_strlen($lyrics) / 7)), 'UTF-8') . "[...]"; } //$lyrics .= "\n\n\n\n$TRUNCATION_NOTICE".$retVal['url']."$urlLink"; // we'll let apps decide how to handle this. // We now return the truncated version instead of just a flat-out denial. $retVal['lyrics'] = $lyrics; //$retVal['lyrics'] = $DENIED_NOTICE . $retVal['url'] . $urlLink . $DENIED_NOTICE_SUFFIX; } } // Make encoding work with UTF8 - NOTE: We do not apply this again to a result that the doHyphens/lastHyphen trick grabbed because that has already been encoded. $retVal['artist'] = utf8_encode($retVal['artist']); $retVal['song'] = utf8_encode($retVal['song']); $retVal['lyrics'] = utf8_encode($retVal['lyrics']); } } } } // If configured to do so, fallback to full wiki search. if ($wgRequest->getBool('fallbackSearch') && $retVal['lyrics'] == $defaultLyrics) { $retVal['searchResults'] = lw_getSearchResults("{$artist} {$song}"); } } // end of the "if shut_down_api else" if ($isOuterRequest) { $retVal['isOnTakedownList'] = $retVal['isOnTakedownList'] ? "1" : "0"; // turn it into a string requestFinished($id); } $retVal['lyrics'] = removeWikitextFromLyrics($retVal['lyrics']); wfProfileOut(__METHOD__); return $retVal; }