Esempio n. 1
0
 /**
  * Replace link with embedded content, if supported.
  *
  * @param array $matches
  * @return string
  */
 private function callback(array $matches)
 {
     // Check if we ignore it.
     if (preg_match('/class="[^"]*nomediaplugin/i', $matches[0])) {
         return $matches[0];
     }
     // Get name.
     $name = trim($matches[2]);
     if (empty($name) or strpos($name, 'http') === 0) {
         $name = '';
         // Use default name.
     }
     // Split provided URL into alternatives.
     $urls = filter_jwplayer_split_alternatives($matches[1], $width, $height);
     $result = $this->renderer->embed_alternatives($urls, $name, $width, $height);
     // If something was embedded, return it, otherwise return original.
     if ($result !== '') {
         return $result;
     } else {
         return $matches[0];
     }
 }
Esempio n. 2
0
 /**
  * Replace link with embedded content, if supported.
  *
  * @param array $matches
  * @return string
  */
 private function callback(array $matches)
 {
     // Check if we ignore it.
     if (preg_match('/class="[^"]*nomediaplugin/i', $matches[0])) {
         return $matches[0];
     }
     // Get name.
     $name = trim($matches[2]);
     if (empty($name) or strpos($name, 'http') === 0) {
         $name = '';
         // Use default name.
     }
     // Prepare options.
     $options = array();
     // Get <a> tag attributes.
     // Escape any unescaped & characters.
     $escapedmatch = preg_replace('/&(?!(?:apos|quot|[gl]t|amp);|#)/', '&amp;', $matches[0]);
     $doc = new DOMDocument();
     $doc->strictErrorChecking = false;
     // Load HTML as a DOMDocument.
     $doc->loadHTML($escapedmatch);
     if ($atag = simplexml_import_dom($doc)->body[0]->a[0]) {
         // Make sure xml is valid xml if not do nothing.
         $options['htmlattributes'] = $atag->attributes();
     }
     // Split provided URL into alternatives.
     $urls = filter_jwplayer_split_alternatives($matches[1], $width, $height);
     $result = $this->renderer->embed_alternatives($urls, $name, $width, $height, $options);
     // If something was embedded, return it, otherwise return original.
     if ($result !== '') {
         return $result;
     } else {
         return $matches[0];
     }
 }