remove some code duplication
This commit is contained in:
parent
17bd39fcd4
commit
233e4e1363
@ -3,7 +3,7 @@
|
||||
require_once("include/oembed.php");
|
||||
require_once('include/event.php');
|
||||
require_once('include/zot.php');
|
||||
|
||||
require_once('include/hubloc.php');
|
||||
|
||||
function tryoembed($match) {
|
||||
$url = ((count($match)==2)?$match[1]:$match[2]);
|
||||
@ -19,15 +19,7 @@ function tryoembed($match) {
|
||||
function tryzrlaudio($match) {
|
||||
|
||||
$link = $match[1];
|
||||
$m = @parse_url($link);
|
||||
$zrl = false;
|
||||
if($m['host']) {
|
||||
$r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
|
||||
dbesc($m['host'])
|
||||
);
|
||||
if($r)
|
||||
$zrl = true;
|
||||
}
|
||||
$zrl = is_matrix_url($link);
|
||||
if($zrl)
|
||||
$link = zid($link);
|
||||
return '<audio src="' . $link . '" controls="controls" ><a href="' . $link . '">' . $link . '</a></audio>';
|
||||
@ -35,15 +27,7 @@ function tryzrlaudio($match) {
|
||||
|
||||
function tryzrlvideo($match) {
|
||||
$link = $match[1];
|
||||
$m = @parse_url($link);
|
||||
$zrl = false;
|
||||
if($m['host']) {
|
||||
$r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
|
||||
dbesc($m['host'])
|
||||
);
|
||||
if($r)
|
||||
$zrl = true;
|
||||
}
|
||||
$zrl = is_matrix_url($link);
|
||||
if($zrl)
|
||||
$link = zid($link);
|
||||
return '<video controls="controls" src="' . $link . '" style="width:100%; max-width:' . get_app()->videowidth . 'px"><a href="' . $link . '">' . $link . '</a></video>';
|
||||
|
@ -23,15 +23,8 @@ function bookmark_add($channel,$sender,$taxonomy,$private,$opts = null) {
|
||||
$iarr['mitem_desc'] = $taxonomy['term'];
|
||||
$iarr['mitem_flags'] = (($ischat) ? MENU_ITEM_CHATROOM : 0);
|
||||
|
||||
$m = @parse_url($taxonomy['url']);
|
||||
$zrl = false;
|
||||
if($m['host']) {
|
||||
$r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
|
||||
dbesc($m['host'])
|
||||
);
|
||||
if($r)
|
||||
$zrl = true;
|
||||
}
|
||||
require_once('include/hubloc.php');
|
||||
$zrl = is_matrix_url($taxonomy['url']);
|
||||
|
||||
if($zrl)
|
||||
$iarr['mitem_flags'] |= MENU_ITEM_ZID;
|
||||
|
@ -1,5 +1,17 @@
|
||||
<?php /** @file */
|
||||
|
||||
function is_matrix_url($url) {
|
||||
$m = @parse_url($url);
|
||||
if($m['host']) {
|
||||
$r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
|
||||
dbesc($m['host'])
|
||||
);
|
||||
if($r)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function prune_hub_reinstalls() {
|
||||
|
@ -189,15 +189,8 @@ function add_source_route($iid,$hash) {
|
||||
|
||||
|
||||
function red_zrl_callback($matches) {
|
||||
$m = @parse_url($matches[2]);
|
||||
$zrl = false;
|
||||
if($m['host']) {
|
||||
$r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
|
||||
dbesc($m['host'])
|
||||
);
|
||||
if($r)
|
||||
$zrl = true;
|
||||
}
|
||||
require_once('include/hubloc.php');
|
||||
$zrl = is_matrix_url($matches[2]);
|
||||
|
||||
$t = strip_zids($matches[2]);
|
||||
if($t !== $matches[2]) {
|
||||
@ -236,15 +229,8 @@ function red_unescape_codeblock($m) {
|
||||
|
||||
|
||||
function red_zrlify_img_callback($matches) {
|
||||
$m = @parse_url($matches[2]);
|
||||
$zrl = false;
|
||||
if($m['host']) {
|
||||
$r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
|
||||
dbesc($m['host'])
|
||||
);
|
||||
if($r)
|
||||
$zrl = true;
|
||||
}
|
||||
require_once('include/hubloc.php');
|
||||
$zrl = is_matrix_url($matches[2]);
|
||||
|
||||
$t = strip_zids($matches[2]);
|
||||
if($t !== $matches[2]) {
|
||||
|
@ -29,18 +29,10 @@ function oembed_fetch_url($embedurl){
|
||||
$txt = "";
|
||||
|
||||
if (in_array($ext, $noexts)) {
|
||||
$m = @parse_url($embedurl);
|
||||
$zrl = false;
|
||||
if($m['host']) {
|
||||
$r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
|
||||
dbesc($m['host'])
|
||||
);
|
||||
if($r)
|
||||
$zrl = true;
|
||||
}
|
||||
if($zrl) {
|
||||
$embedurl = zid($embedurl);
|
||||
}
|
||||
require_once('include/hubloc.php');
|
||||
$zrl = is_matrix_url($embedurl);
|
||||
if($zrl)
|
||||
$embedurl = zid($embedurl);
|
||||
}
|
||||
else {
|
||||
// try oembed autodiscovery
|
||||
|
@ -1 +1 @@
|
||||
2014-07-13.735
|
||||
2014-07-14.736
|
||||
|
Reference in New Issue
Block a user