aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-05-08 19:12:52 -0700
committerredmatrix <git@macgirvin.com>2016-05-08 19:12:52 -0700
commit2a14c7112834d4127f78ce177534045efe3c34a1 (patch)
treed622f1e7ffca9286b61d4fcc1a39903221b0fb4a
parent5ac262bd610097b0e756003c39bc9fad4df7c321 (diff)
downloadvolse-hubzilla-2a14c7112834d4127f78ce177534045efe3c34a1.tar.gz
volse-hubzilla-2a14c7112834d4127f78ce177534045efe3c34a1.tar.bz2
volse-hubzilla-2a14c7112834d4127f78ce177534045efe3c34a1.zip
convert media embed functions that deal with rewriting specific corporate services to addon hooks
-rw-r--r--doc/hooklist.bb8
-rw-r--r--include/text.php29
2 files changed, 13 insertions, 24 deletions
diff --git a/doc/hooklist.bb b/doc/hooklist.bb
index 9331873b4..bb1bffcf0 100644
--- a/doc/hooklist.bb
+++ b/doc/hooklist.bb
@@ -70,6 +70,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/bbcode]bbcode[/zrl]
Called when converting bbcode to HTML
+[zrl=[baseurl]/help/hook/bb_translate_video]bb_translate_video[/zrl]
+ Called when extracting embedded services from bbcode video elements (rarely used)
+
[zrl=[baseurl]/help/hook/channel_remove]channel_remove[/zrl]
Called when removing a channel
@@ -242,8 +245,11 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/hostxrd]hostxrd[/zrl]
Called when generating .well-known/hosts-meta for "old webfinger" (used by Diaspora protocol)
+[zrl=[baseurl]/help/hook/html2bb_video]html2bb_video[/zrl]
+ Called when using the html2bbcode translation to handle embedded media
+
[zrl=[baseurl]/help/hook/html2bbcode]html2bbcode[/zrl]
- Called when using the html2bbcode tranlsation
+ Called when using the html2bbcode translation
[zrl=[baseurl]/help/hook/identity_basic_export]identity_basic_export[/zrl]
Called when exporting a channel's basic information for backup or transfer
diff --git a/include/text.php b/include/text.php
index a3826de49..a2c0a3209 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1895,32 +1895,15 @@ function cleardiv() {
function bb_translate_video($s) {
-
- $matches = null;
- $r = preg_match_all("/\[video\](.*?)\[\/video\]/ism",$s,$matches,PREG_SET_ORDER);
- if($r) {
- foreach($matches as $mtch) {
- if((stristr($mtch[1],'youtube')) || (stristr($mtch[1],'youtu.be')))
- $s = str_replace($mtch[0],'[youtube]' . $mtch[1] . '[/youtube]',$s);
- elseif(stristr($mtch[1],'vimeo'))
- $s = str_replace($mtch[0],'[vimeo]' . $mtch[1] . '[/vimeo]',$s);
- }
- }
- return $s;
+ $arr = array('string' => $s);
+ call_hooks('bb_translate_video',$arr);
+ return $arr['string'];
}
function html2bb_video($s) {
-
- $s = preg_replace('#<object[^>]+>(.*?)https?://www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+)(.*?)</object>#ism',
- '[youtube]$2[/youtube]', $s);
-
- $s = preg_replace('#<iframe[^>](.*?)https?://www.youtube.com/embed/([A-Za-z0-9\-_=]+)(.*?)</iframe>#ism',
- '[youtube]$2[/youtube]', $s);
-
- $s = preg_replace('#<iframe[^>](.*?)https?://player.vimeo.com/video/([0-9]+)(.*?)</iframe>#ism',
- '[vimeo]$2[/vimeo]', $s);
-
- return $s;
+ $arr = array('string' => $s);
+ call_hooks('html2bb_video',$arr);
+ return $arr['string'];
}
/**