shareable design elements
This commit is contained in:
parent
6e4f7383f1
commit
03bbbdaf10
@ -159,6 +159,14 @@ function bb_parse_app($match) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bb_parse_element($match) {
|
||||||
|
$j = json_decode(base64url_decode($match[1]),true);
|
||||||
|
if($j) {
|
||||||
|
$o = EOL . '<a href="' . z_root() . '" foo="baz" onclick="importElement(\'' . $match[1] . '\'); return false;" >' . t('Install design element: ') . $j['pagetitle'] . '</a>' . EOL;
|
||||||
|
}
|
||||||
|
return $o;
|
||||||
|
}
|
||||||
|
|
||||||
function bb_qr($match) {
|
function bb_qr($match) {
|
||||||
return '<img class="zrl" src="' . z_root() . '/photo/qr?f=&qr=' . urlencode($match[1]) . '" alt="' . t('QR code') . '" title="' . htmlspecialchars($match[1],ENT_QUOTES,'UTF-8') . '" />';
|
return '<img class="zrl" src="' . z_root() . '/photo/qr?f=&qr=' . urlencode($match[1]) . '" alt="' . t('QR code') . '" title="' . htmlspecialchars($match[1],ENT_QUOTES,'UTF-8') . '" />';
|
||||||
}
|
}
|
||||||
@ -700,6 +708,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
|
|||||||
$Text = preg_replace_callback("/\[app\](.*?)\[\/app\]/ism",'bb_parse_app', $Text);
|
$Text = preg_replace_callback("/\[app\](.*?)\[\/app\]/ism",'bb_parse_app', $Text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(strpos($Text,'[/element]') !== false) {
|
||||||
|
$Text = preg_replace_callback("/\[element\](.*?)\[\/element\]/ism",'bb_parse_element', $Text);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// html5 video and audio
|
// html5 video and audio
|
||||||
if (strpos($Text,'[/video]') !== false) {
|
if (strpos($Text,'[/video]') !== false) {
|
||||||
|
@ -152,6 +152,23 @@ function editblock_content(&$a) {
|
|||||||
if(($itm[0]['author_xchan'] === $ob) || ($itm[0]['owner_xchan'] === $ob))
|
if(($itm[0]['author_xchan'] === $ob) || ($itm[0]['owner_xchan'] === $ob))
|
||||||
$o .= '<br /><br /><a class="block-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Block') . '</a><br />';
|
$o .= '<br /><br /><a class="block-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Block') . '</a><br />';
|
||||||
|
|
||||||
|
|
||||||
|
$x = array(
|
||||||
|
'type' => 'block',
|
||||||
|
'title' => $itm[0]['title'],
|
||||||
|
'body' => $itm[0]['body'],
|
||||||
|
'term' => $itm[0]['term'],
|
||||||
|
'created' => $itm[0]['created'],
|
||||||
|
'edited' => $itm[0]['edited'],
|
||||||
|
'mimetype' => $itm[0]['mimetype'],
|
||||||
|
'pagetitle' => $page_title,
|
||||||
|
'mid' => $itm[0]['mid']
|
||||||
|
);
|
||||||
|
|
||||||
|
$o .= EOL . EOL . t('Share') . EOL . '<textarea onclick="this.select();" class="shareable_element_text" >[element]' . base64url_encode(json_encode($x)) . '[/element]</textarea>' . EOL . EOL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -145,6 +145,23 @@ function editlayout_content(&$a) {
|
|||||||
if(($itm[0]['author_xchan'] === $ob) || ($itm[0]['owner_xchan'] === $ob))
|
if(($itm[0]['author_xchan'] === $ob) || ($itm[0]['owner_xchan'] === $ob))
|
||||||
$o .= '<br /><br /><a class="layout-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Layout') . '</a><br />';
|
$o .= '<br /><br /><a class="layout-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Layout') . '</a><br />';
|
||||||
|
|
||||||
|
|
||||||
|
$x = array(
|
||||||
|
'type' => 'layout',
|
||||||
|
'title' => $itm[0]['title'],
|
||||||
|
'body' => $itm[0]['body'],
|
||||||
|
'term' => $itm[0]['term'],
|
||||||
|
'created' => $itm[0]['created'],
|
||||||
|
'edited' => $itm[0]['edited'],
|
||||||
|
'mimetype' => $itm[0]['mimetype'],
|
||||||
|
'pagetitle' => $page_title,
|
||||||
|
'mid' => $itm[0]['mid']
|
||||||
|
);
|
||||||
|
|
||||||
|
$o .= EOL . EOL . t('Share') . EOL . '<textarea onclick="this.select();" class="shareable_element_text" >[element]' . base64url_encode(json_encode($x)) . '[/element]</textarea>' . EOL . EOL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -185,6 +185,21 @@ function editwebpage_content(&$a) {
|
|||||||
if(($itm[0]['author_xchan'] === $ob) || ($itm[0]['owner_xchan'] === $ob))
|
if(($itm[0]['author_xchan'] === $ob) || ($itm[0]['owner_xchan'] === $ob))
|
||||||
$o .= '<br /><br /><a class="page-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Webpage') . '</a><br />';
|
$o .= '<br /><br /><a class="page-delete-link" href="item/drop/' . $itm[0]['id'] . '" >' . t('Delete Webpage') . '</a><br />';
|
||||||
|
|
||||||
|
|
||||||
|
$x = array(
|
||||||
|
'type' => 'webpage',
|
||||||
|
'title' => $itm[0]['title'],
|
||||||
|
'body' => $itm[0]['body'],
|
||||||
|
'term' => $itm[0]['term'],
|
||||||
|
'created' => $itm[0]['created'],
|
||||||
|
'edited' => $itm[0]['edited'],
|
||||||
|
'mimetype' => $itm[0]['mimetype'],
|
||||||
|
'pagetitle' => $page_title,
|
||||||
|
'mid' => $itm[0]['mid']
|
||||||
|
);
|
||||||
|
|
||||||
|
$o .= EOL . EOL . t('Share') . EOL . '<textarea onclick="this.select();" class="shareable_element_text" >[element]' . base64url_encode(json_encode($x)) . '[/element]</textarea>' . EOL . EOL;
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,13 @@ function impel_init(&$a) {
|
|||||||
|
|
||||||
$ret = array('success' => false);
|
$ret = array('success' => false);
|
||||||
|
|
||||||
if(! $local_user())
|
if(! local_user())
|
||||||
json_return_and_die($ret);
|
json_return_and_die($ret);
|
||||||
|
|
||||||
|
logger('impel: ' . print_r($_REQUEST,true), LOGGER_DATA);
|
||||||
|
|
||||||
$elm = $_REQUEST['element'];
|
$elm = $_REQUEST['element'];
|
||||||
$x = base64_urldecode($elm);
|
$x = base64url_decode($elm);
|
||||||
if(! $x)
|
if(! $x)
|
||||||
json_return_and_die($ret);
|
json_return_and_die($ret);
|
||||||
|
|
||||||
@ -20,7 +22,7 @@ function impel_init(&$a) {
|
|||||||
json_return_and_die($ret);
|
json_return_and_die($ret);
|
||||||
|
|
||||||
|
|
||||||
$channel = get_channel();
|
$channel = $a->get_channel();
|
||||||
|
|
||||||
$arr = array();
|
$arr = array();
|
||||||
|
|
||||||
@ -28,14 +30,17 @@ function impel_init(&$a) {
|
|||||||
case 'webpage':
|
case 'webpage':
|
||||||
$arr['item_restrict'] = ITEM_WEBPAGE;
|
$arr['item_restrict'] = ITEM_WEBPAGE;
|
||||||
$namespace = 'WEBPAGE';
|
$namespace = 'WEBPAGE';
|
||||||
|
$installed_type = t('webpage');
|
||||||
break;
|
break;
|
||||||
case 'block':
|
case 'block':
|
||||||
$arr['item_restrict'] = ITEM_BUILDBLOCK;
|
$arr['item_restrict'] = ITEM_BUILDBLOCK;
|
||||||
$namespace = 'BUILDBLOCK';
|
$namespace = 'BUILDBLOCK';
|
||||||
|
$installed_type = t('block');
|
||||||
break;
|
break;
|
||||||
case 'layout':
|
case 'layout':
|
||||||
$arr['item_restrict'] = ITEM_PDL;
|
$arr['item_restrict'] = ITEM_PDL;
|
||||||
$namespace = 'PDL';
|
$namespace = 'PDL';
|
||||||
|
$installed_type = t('layout');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
logger('mod_impel: unrecognised element type' . print_r($j,true));
|
logger('mod_impel: unrecognised element type' . print_r($j,true));
|
||||||
@ -46,8 +51,10 @@ function impel_init(&$a) {
|
|||||||
$arr['title'] = $j['title'];
|
$arr['title'] = $j['title'];
|
||||||
$arr['body'] = $j['body'];
|
$arr['body'] = $j['body'];
|
||||||
$arr['term'] = $j['term'];
|
$arr['term'] = $j['term'];
|
||||||
|
$arr['created'] = datetime_convert('UTC','UTC', $j['created']);
|
||||||
|
$arr['edited'] = datetime_convert('UTC','UTC',$j['edited']);
|
||||||
$arr['owner_xchan'] = get_observer_hash();
|
$arr['owner_xchan'] = get_observer_hash();
|
||||||
$arr['author_xchan'] = (($j['author_xchan']) ? $j['author_xchan'] : $get_observer_hash());
|
$arr['author_xchan'] = (($j['author_xchan']) ? $j['author_xchan'] : get_observer_hash());
|
||||||
$arr['mimetype'] = (($j['mimetype']) ? $j['mimetype'] : 'text/bbcode');
|
$arr['mimetype'] = (($j['mimetype']) ? $j['mimetype'] : 'text/bbcode');
|
||||||
|
|
||||||
if(! $j['mid'])
|
if(! $j['mid'])
|
||||||
@ -63,9 +70,6 @@ function impel_init(&$a) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$channel = get_channel();
|
|
||||||
|
|
||||||
// Verify ability to use html or php!!!
|
// Verify ability to use html or php!!!
|
||||||
|
|
||||||
$execflag = false;
|
$execflag = false;
|
||||||
@ -82,19 +86,21 @@ function impel_init(&$a) {
|
|||||||
|
|
||||||
$remote_id = 0;
|
$remote_id = 0;
|
||||||
|
|
||||||
$z = q("select * from item_id where $sid = '%s' and service = '%s' and uid = %d limit 1",
|
$z = q("select * from item_id where sid = '%s' and service = '%s' and uid = %d limit 1",
|
||||||
dbesc($pagetitle),
|
dbesc($pagetitle),
|
||||||
dbesc($namespace),
|
dbesc($namespace),
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
$i = q("select id from item where mid = '%s' and $uid = %d limit 1",
|
$i = q("select id from item where mid = '%s' and uid = %d limit 1",
|
||||||
dbesc($arr['mid']),
|
dbesc($arr['mid']),
|
||||||
intval(local_user())
|
intval(local_user())
|
||||||
);
|
);
|
||||||
if($z && $i) {
|
if($z && $i) {
|
||||||
$remote_id = $z[0]['id'];
|
$remote_id = $z[0]['id'];
|
||||||
$arr['id'] = $i[0]['id'];
|
$arr['id'] = $i[0]['id'];
|
||||||
$x = item_store_update($arr,$execflag);
|
// don't update if it has the same timestamp as the original
|
||||||
|
if($arr['edited'] > $i[0]['edited'])
|
||||||
|
$x = item_store_update($arr,$execflag);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$x = item_store($arr,$execflag);
|
$x = item_store($arr,$execflag);
|
||||||
@ -102,12 +108,14 @@ function impel_init(&$a) {
|
|||||||
if($x['success'])
|
if($x['success'])
|
||||||
$item_id = $x['item_id'];
|
$item_id = $x['item_id'];
|
||||||
|
|
||||||
$channel = get_channel();
|
|
||||||
|
|
||||||
update_remote_id($channel,$item_id,$arr['item_restrict'],$pagetitle,$namespace,$remote_id,$arr['mid']);
|
update_remote_id($channel,$item_id,$arr['item_restrict'],$pagetitle,$namespace,$remote_id,$arr['mid']);
|
||||||
|
|
||||||
|
|
||||||
$ret['success'] = true;
|
$ret['success'] = true;
|
||||||
|
|
||||||
|
info( sprintf( t('%s element installed'), $installed_type));
|
||||||
|
|
||||||
json_return_and_die(true);
|
json_return_and_die(true);
|
||||||
|
|
||||||
}
|
}
|
@ -898,7 +898,10 @@ function updateConvItems(mode,data) {
|
|||||||
"impel",
|
"impel",
|
||||||
{ "element" : elem }
|
{ "element" : elem }
|
||||||
);
|
);
|
||||||
return false;
|
if(timer) clearTimeout(timer);
|
||||||
|
timer = setTimeout(NavUpdate,10);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function preview_post() {
|
function preview_post() {
|
||||||
|
@ -2528,3 +2528,8 @@ blockquote {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.shareable_element_text {
|
||||||
|
height: 300px;
|
||||||
|
width: 300px;
|
||||||
|
}
|
Reference in New Issue
Block a user