示例#1
0
 /**
  * Returns an image url parsed from a page
  * @param Title $backgroundPageTitle
  * @return string|false if unavailable 
  */
 private static function getBackgroundUrl($backgroundText)
 {
     $patternForFile = '/^\\[\\[File:([^\\]\\|]+).*\\]\\]/m';
     $matchesForFile = array();
     if (preg_match($patternForFile, $backgroundText, $matchesForFile)) {
         $fileKey = $matchesForFile[1];
         $file = wfFindFile($fileKey);
         if ($file && WpWikiplace::isExtensionValidForBackground($file->getExtension())) {
             return $file->getFullUrl();
         }
     }
     /** @todo Remove the background by url feature */
     $patternForUrl = '/^(https?\\:\\/\\/[\\w\\-%\\.\\/\\?\\&]*\\.(jpe?g|png|gif))/im';
     $matchesForUrl = array();
     if (preg_match($patternForUrl, $backgroundText, $matchesForUrl)) {
         return $matchesForUrl[1];
     }
     return false;
 }