aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php123
1 files changed, 90 insertions, 33 deletions
diff --git a/include/text.php b/include/text.php
index 664d5f83d..deb5a4c90 100644
--- a/include/text.php
+++ b/include/text.php
@@ -98,12 +98,20 @@ function z_input_filter($channel_id,$s,$type = 'text/bbcode') {
return escape_tags($s);
if($type == 'text/plain')
return escape_tags($s);
+
+ $a = get_app();
+ if($a->is_sys) {
+ return $s;
+ }
+
$r = q("select account_id, account_roles, channel_pageflags from account left join channel on channel_account_id = account_id where channel_id = %d limit 1",
intval($channel_id)
);
- if($r && (($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE))) {
- if(local_channel() && (get_account_id() == $r[0]['account_id'])) {
- return $s;
+ if($r) {
+ if(($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) {
+ if(local_channel() && (get_account_id() == $r[0]['account_id'])) {
+ return $s;
+ }
}
}
@@ -1034,9 +1042,9 @@ function list_smilies() {
'<img class="smiley" src="' . $a->get_baseurl() . '/images/smiley-facepalm.gif" alt=":facepalm" />',
'<img class="smiley" src="' . $a->get_baseurl() . '/images/like.gif" alt=":like" />',
'<img class="smiley" src="' . $a->get_baseurl() . '/images/dislike.gif" alt=":dislike" />',
- '<a href="http://getzot.com"><strong>red<img class="smiley" src="' . $a->get_baseurl() . '/images/rm-16.png" alt="' . urlencode('red#matrix') . '" />matrix</strong></a>',
- '<a href="http://getzot.com"><strong>red<img class="smiley" src="' . $a->get_baseurl() . '/images/rm-16.png" alt="' . urlencode('red#') . '" />matrix</strong></a>',
- '<a href="http://getzot.com"><strong>red<img class="smiley" src="' . $a->get_baseurl() . '/images/rm-16.png" alt="r#" />matrix</strong></a>'
+ '<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . $a->get_baseurl() . '/images/rm-32.png" alt="' . urlencode('red#matrix') . '" />matrix</strong></a>',
+ '<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . $a->get_baseurl() . '/images/rm-32.png" alt="' . urlencode('red#') . '" />matrix</strong></a>',
+ '<a href="http://getzot.com"><strong>red<img class="smiley bb_rm-logo" src="' . $a->get_baseurl() . '/images/rm-32.png" alt="r#" />matrix</strong></a>'
);
@@ -1177,9 +1185,28 @@ function unobscure(&$item) {
$item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
if($item['body'])
$item['body'] = crypto_unencapsulate(json_decode_plus($item['body']),$key);
+ if(get_config('system','item_cache')) {
+ q("update item set title = '%s', body = '%s', item_flags = %d where id = %d",
+ dbesc($item['title']),
+ dbesc($item['body']),
+ intval($item['item_flags'] - ITEM_OBSCURED),
+ intval($item['id'])
+ );
+ }
}
}
+function unobscure_mail(&$item) {
+ if(array_key_exists('mail_flags',$item) && ($item['mail_flags'] & MAIL_OBSCURED)) {
+ $key = get_config('system','prvkey');
+ if($item['title'])
+ $item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
+ if($item['body'])
+ $item['body'] = crypto_unencapsulate(json_decode_plus($item['body']),$key);
+ }
+}
+
+
function theme_attachments(&$item) {
$arr = json_decode_plus($item['attach']);
@@ -1258,15 +1285,19 @@ function format_categories(&$item,$writeable) {
return $s;
}
-// Add any hashtags which weren't mentioned in the message body, e.g. community tags
-
+/**
+ * @brief Add any hashtags which weren't mentioned in the message body, e.g. community tags
+ *
+ * @param[in] array &$item
+ * @return string HTML link of hashtag
+ */
function format_hashtags(&$item) {
-
$s = '';
- $terms = get_terms_oftype($item['term'],TERM_HASHTAG);
+
+ $terms = get_terms_oftype($item['term'], TERM_HASHTAG);
if($terms) {
foreach($terms as $t) {
- $term = htmlspecialchars($t['term'],ENT_COMPAT,'UTF-8',false) ;
+ $term = htmlspecialchars($t['term'], ENT_COMPAT, 'UTF-8', false) ;
if(! trim($term))
continue;
if(strpos($item['body'], $t['url']))
@@ -1278,6 +1309,7 @@ function format_hashtags(&$item) {
$s .= '#<a href="' . zid($t['url']) . '" >' . $term . '</a>';
}
}
+
return $s;
}
@@ -1301,6 +1333,7 @@ function format_mentions(&$item) {
$s .= '@<a href="' . zid($t['url']) . '" >' . $term . '</a>';
}
}
+
return $s;
}
@@ -1346,8 +1379,12 @@ function generate_named_map($location) {
function prepare_body(&$item,$attach = false) {
+ if(get_config('system','item_cache') && $item['html'])
+ return $item['html'];
+
call_hooks('prepare_body_init', $item);
+
unobscure($item);
$s = prepare_text($item['body'],$item['mimetype']);
@@ -1415,6 +1452,12 @@ function prepare_body(&$item,$attach = false) {
$prep_arr = array('item' => $item, 'html' => $s);
call_hooks('prepare_body_final', $prep_arr);
+ if(get_config('system','item_cache'))
+ q("update item set html = '%s' where id = %d",
+ dbesc($prep_arr['html']),
+ intval($item['id'])
+ );
+
return $prep_arr['html'];
}
@@ -1581,18 +1624,20 @@ function layout_select($channel_id, $current = '') {
intval($channel_id),
intval(ITEM_PDL)
);
+
if($r) {
- $o = t('Select a page layout: ');
- $o .= '<select name="layout_mid" id="select-layout_mid" >';
- $empty_selected = (($current === '') ? ' selected="selected" ' : '');
- $o .= '<option value="" ' . $empty_selected . '>' . t('default') . '</option>';
+ $empty_selected = (($current === false) ? ' selected="selected" ' : '');
+ $options .= '<option value="" ' . $empty_selected . '>' . t('default') . '</option>';
foreach($r as $rr) {
$selected = (($rr['mid'] == $current) ? ' selected="selected" ' : '');
- $o .= '<option value="' . $rr['mid'] . '"' . $selected . '>' . $rr['sid'] . '</option>';
+ $options .= '<option value="' . $rr['mid'] . '"' . $selected . '>' . $rr['sid'] . '</option>';
}
- $o .= '</select>';
}
+ $o = replace_macros(get_markup_template('field_select_raw.tpl'), array(
+ '$field' => array('layout_mid', t('Page layout'), $selected, t('You can create your own with the layouts tool'), $options)
+ ));
+
return $o;
}
@@ -1606,25 +1651,33 @@ function mimetype_select($channel_id, $current = 'text/bbcode') {
'text/plain'
);
- $r = q("select account_id, account_roles, channel_pageflags from account left join channel on account_id = channel_account_id where
- channel_id = %d limit 1",
- intval($channel_id)
- );
+ $a = get_app();
+ if($a->is_sys) {
+ $x[] = 'application/x-php';
+ }
+ else {
+ $r = q("select account_id, account_roles, channel_pageflags from account left join channel on account_id = channel_account_id where
+ channel_id = %d limit 1",
+ intval($channel_id)
+ );
- if($r) {
- if(($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) {
- if(local_channel() && get_account_id() == $r[0]['account_id'])
- $x[] = 'application/x-php';
- }
+ if($r) {
+ if(($r[0]['account_roles'] & ACCOUNT_ROLE_ALLOWCODE) || ($r[0]['channel_pageflags'] & PAGE_ALLOWCODE)) {
+ if(local_channel() && get_account_id() == $r[0]['account_id']) {
+ $x[] = 'application/x-php';
+ }
+ }
+ }
}
- $o = t('Page content type: ');
- $o .= '<select name="mimetype" id="mimetype-select">';
foreach($x as $y) {
- $select = (($y == $current) ? ' selected="selected" ' : '');
- $o .= '<option name="' . $y . '"' . $select . '>' . $y . '</option>';
+ $selected = (($y == $current) ? ' selected="selected" ' : '');
+ $options .= '<option name="' . $y . '"' . $selected . '>' . $y . '</option>';
}
- $o .= '</select>';
+
+ $o = replace_macros(get_markup_template('field_select_raw.tpl'), array(
+ '$field' => array('mimetype', t('Page content type'), $selected, '', $options)
+ ));
return $o;
}
@@ -2065,7 +2118,11 @@ function json_decode_plus($s) {
return $x;
}
-
+/**
+ * @brief Creates navigation menu for webpage, layout, blocks, menu sites.
+ *
+ * @return string
+ */
function design_tools() {
$channel = get_app()->get_channel();
@@ -2080,7 +2137,7 @@ function design_tools() {
$who = $channel['channel_address'];
return replace_macros(get_markup_template('design_tools.tpl'), array(
- '$title' => t('Design'),
+ '$title' => t('Design Tools'),
'$who' => $who,
'$sys' => $sys,
'$blocks' => t('Blocks'),