/**
  * Embeds video of the chosen service
  * @param Parser $parser Instance of running Parser.
  * @param String $service Which online service has the video.
  * @param String $id Identifier of the chosen service
  * @param String $width Width of video (optional)
  * @param String $desc description to show (optional)
  * @param String $align alignment of the video (optional)
  * @return String Encoded representation of input params (to be processed later)
  */
 public static function parserFunction_ev($parser, $service = null, $id = null, $width = null, $align = null, $desc = null)
 {
     global $wgScriptPath;
     // Initialize things once
     if (!self::$initialized) {
         self::VerifyWidthMinAndMax();
         self::$initialized = true;
     }
     // Get the name of the host
     if ($service === null || $id === null) {
         return self::errMissingParams($service, $id);
     }
     $service = trim($service);
     $id = trim($id);
     $desc = $parser->recursiveTagParse($desc);
     $entry = self::getServiceEntry($service);
     if (!$entry) {
         return self::errBadService($service);
     }
     if (!self::sanitizeWidth($entry, $width)) {
         return self::errBadWidth($width);
     }
     $height = self::getHeight($entry, $width);
     $hasalign = $align !== null || $align == 'auto';
     if ($hasalign) {
         $align = trim($align);
         if (!self::validateAlignment($align)) {
             return self::errBadAlignment($align);
         }
         $desc = self::getDescriptionMarkup($desc);
     }
     // If the service has an ID pattern specified, verify the id number
     if (!self::verifyID($entry, $id)) {
         return self::errBadID($service, $id);
     }
     $url = null;
     // If service is Yandex -> use own parser
     if ($service == 'yandex' || $service == 'yandexvideo') {
         $url = self::getYandex($id);
         $url = htmlspecialchars_decode($url);
     }
     // if the service has it's own custom extern declaration, use that instead
     if (array_key_exists('extern', $entry) && ($clause = $entry['extern']) != NULL) {
         if ($service == 'screen9') {
             $clause = self::parseScreen9Id($id, $width, $height);
             if ($clause == null) {
                 return self::errBadScreen9Id();
             }
         } else {
             $clause = wfMsgReplaceArgs($clause, array($wgScriptPath, $id, $width, $height, $url));
         }
         if ($hasalign) {
             $clause = self::generateAlignExternClause($clause, $align, $desc, $width, $height);
         }
         return array($clause, 'noparse' => true, 'isHTML' => true);
     }
     // Build URL and output embedded flash object
     $url = wfMsgReplaceArgs($entry['url'], array($id, $width, $height));
     $clause = "";
     // If service is RuTube -> use own parser
     if ($service == 'rutube') {
         $url = self::getRuTube($id);
     }
     if ($hasalign) {
         $clause = self::generateAlignClause($url, $width, $height, $align, $desc);
     } else {
         $clause = self::generateNormalClause($url, $width, $height);
     }
     return array($clause, 'noparse' => true, 'isHTML' => true);
 }
 function wfEmbedVideoLanguageGetMagic(&$magicWords)
 {
     EmbedVideo::parserFunctionMagic($magicWords);
     return true;
 }
Ejemplo n.º 3
0
 /**
  * Embeds video of the chosen service
  * @param Parser $parser Instance of running Parser.
  * @param String $service Which online service has the video.
  * @param String $id Identifier of the chosen service
  * @param String $width Width of video (optional)
  * @param String $desc description to show (optional, unused)
  * @param String $align alignment of the video (optional, unused)
  * @return String Encoded representation of input params (to be processed later)
  */
 public static function parserFunction_ev($parser, $service = null, $id = null, $width = null, $align = null, $desc = null)
 {
     global $wgScriptPath;
     # Initialize things once
     if (!EmbedVideo::$initialized) {
         EmbedVideo::VerifyWidthMinAndMax();
         $parser->disableCache();
         EmbedVideo::$initialized = true;
     }
     # Get the name of the host
     if ($service === null || $id === null) {
         return EmbedVideo::errMissingParams($service, $id);
     }
     $service = trim($service);
     $id = trim($id);
     $desc = $parser->recursiveTagParse($desc);
     $entry = EmbedVideo::getServiceEntry($service);
     if (!$entry) {
         return EmbedVideo::errBadService($service);
     }
     if (!EmbedVideo::sanitizeWidth($entry, $width)) {
         return EmbedVideo::errBadWidth($width);
     }
     $height = EmbedVideo::getHeight($entry, $width);
     $hasalign = $align !== null;
     if ($hasalign) {
         $desc = EmbedVideo::getDescriptionMarkup($desc);
     }
     # If the service has an ID pattern specified, verify the id number
     if (!EmbedVideo::verifyID($entry, $id)) {
         return EmbedVideo::errBadID($service, $id);
     }
     # if the service has it's own custom extern declaration, use that instead
     if (array_key_exists('extern', $entry) && ($clause = $entry['extern']) != null) {
         $clause = wfMsgReplaceArgs($clause, array($wgScriptPath, $id, $width, $height));
         if ($hasalign) {
             $clause = EmbedVideo::generateAlignExternClause($clause, $align, $desc, $width, $height);
         }
         return array($clause, 'noparse' => true, 'isHTML' => true);
     }
     # Build URL and output embedded flash object
     $url = wfMsgReplaceArgs($entry['url'], array($id, $width, $height));
     $clause = "";
     if ($hasalign) {
         $clause = EmbedVideo::generateAlignClause($url, $width, $height, $align, $desc);
     } else {
         $clause = EmbedVideo::generateNormalClause($url, $width, $height);
     }
     return array($clause, 'noparse' => true, 'isHTML' => true);
 }