| 123456789101112131415161718192021222324 |
- <?php
-
- App::uses('TextHelper', 'View/Helper/');
-
- class TextExtendedHelper extends TextHelper {
-
- private $embedRegexp = array(
- "/<a href=\"(?:http:\\/\\/|https:\\/\\/)?(?:www\\.)?(?:youtube\\.com|youtu\\.be)\\/(?:watch\\?v=)?([^\\&\"]+).*\".*>.*<\\/a>/",
- "/<a href=\"(?:http:\\/\\/|https:\\/\\/)?(?:www\\.)?(?:vimeo\\.com)\\/([^\\&\"]+).*\".*>.*<\\/a>/",
- "/<a href=\"(?:http:\\/\\/|https:\\/\\/)?(?:www\\.)?(?:dailymotion\\.com|dai\\.ly)\\/([^\\&\"]+).*\".*>.*<\\/a>/"
- );
-
- private $embedIframe = array(
- '<center><iframe width="480" height="270" src="http://www.youtube.com/embed/$1?modestbranding=1&rel=0&wmode=transparent&theme=light&color=white" frameborder="0" allowfullscreen></iframe></center>',
- '<center><iframe src="//player.vimeo.com/video/$1" width="480" height="270" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></center>',
- '<center><iframe frameborder="0" width="480" height="270" src="http://www.dailymotion.com/embed/video/$1?logo=0&foreground=ffffff&highlight=1bb4c6&background=000000" allowfullscreen></iframe></center>'
- );
-
- public function autoLink($text, $htmlOptions = array()) {
- $text = parent::autoLink($text, $htmlOptions);
- return preg_replace($this->embedRegexp, $this->embedIframe, $text);
- }
-
- }
|