Add filter hooks and the ability to add buttons to the default status editor

This commit is contained in:
DM42.Net (Matt Dent) 2019-02-01 00:12:45 -05:00
parent 76582a60b5
commit 708d288121
5 changed files with 41 additions and 6 deletions

View File

@ -0,0 +1,5 @@
[h2]jot_header_tpl_filter[/h2]
Allows addon developers to modify the values of replacements fed into jot-header.tpl
cxref: include/conversation.php

View File

@ -0,0 +1,5 @@
[h2]jot_tpl_filter[/h2]
Allows addon developers to alter the macro replacements prior to being fed into jot.tpl
cxref: include/conversation.php

View File

@ -370,6 +370,12 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/jot_tool]jot_tool[/zrl]
Deprecated and possibly obsolete. Allows one to add action buttons to the post editor.
[zrl=[baseurl]/help/hook/jot_tpl_filter]jot_tpl_filter[/zrl]
Called to filter template vars before replacement in jot.tpl.
[zrl=[baseurl]/help/hook/jot_header_tpl_filter]jot_header_tpl_filter[/zrl]
Called to filter template vars before replacement in jot_header.tpl.
[zrl=[baseurl]/help/hook/legal_webbie]legal_webbie[/zrl]
Called to validate a channel address

View File

@ -1328,7 +1328,7 @@ function hz_status_editor($a, $x, $popup = false) {
$tpl = get_markup_template('jot-header.tpl');
App::$page['htmlhead'] .= replace_macros($tpl, array(
$tplmacros = [
'$baseurl' => z_root(),
'$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'),
'$pretext' => ((x($x,'pretext')) ? $x['pretext'] : ''),
@ -1349,7 +1349,10 @@ function hz_status_editor($a, $x, $popup = false) {
'$nocomment_disabled' => t('Comments disabled'),
'$auto_save_draft' => $feature_auto_save_draft,
'$reset' => $reset
));
];
call_hooks('jot_header_tpl_filter',$tplmacros);
App::$page['htmlhead'] .= replace_macros($tpl, $tplmacros);
$tpl = get_markup_template('jot.tpl');
@ -1389,7 +1392,7 @@ function hz_status_editor($a, $x, $popup = false) {
$sharebutton = (x($x,'button') ? $x['button'] : t('Share'));
$placeholdtext = (x($x,'content_label') ? $x['content_label'] : $sharebutton);
$o .= replace_macros($tpl, array(
$tplmacros = [
'$return_path' => ((x($x, 'return_path')) ? $x['return_path'] : App::$query_string),
'$action' => z_root() . '/item',
'$share' => $sharebutton,
@ -1463,9 +1466,15 @@ function hz_status_editor($a, $x, $popup = false) {
'$bbcode' => ((x($x, 'bbcode')) ? $x['bbcode'] : false),
'$parent' => ((array_key_exists('parent',$x) && $x['parent']) ? $x['parent'] : 0),
'$reset' => $reset,
'$is_owner' => ((local_channel() && (local_channel() == $x['profile_uid'])) ? true : false)
));
'$is_owner' => ((local_channel() && (local_channel() == $x['profile_uid'])) ? true : false),
'$custommoretoolsdropdown' => '',
'$custommoretoolsbuttons' => '',
'$customsubmitright' => []
];
call_hooks('jot_tpl_filter',$tplmacros);
$o .= replace_macros($tpl, $tplmacros);
if ($popup === true) {
$o = '<div id="jot-popup" style="display:none">' . $o . '</div>';
}

View File

@ -137,8 +137,11 @@
<i id="profile-nocomment" class="fa fa-comments jot-icons"></i>
</button>
{{/if}}
{{if $custommoretoolsbuttons}}
{{$custommoretoolsbuttons}}
{{/if}}
</div>
{{if $writefiles || $weblink || $setloc || $clearloc || $feature_expire || $feature_encrypt || $feature_voting}}
{{if $writefiles || $weblink || $setloc || $clearloc || $feature_expire || $feature_encrypt || $feature_voting || $custommoretoolsdropdown}}
<div class="btn-group d-lg-none">
<button type="button" id="more-tools" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<i id="more-tools-icon" class="fa fa-cog jot-icons"></i>
@ -176,6 +179,8 @@
{{if $feature_nocomment}}
<a class="dropdown-item" href="#" onclick="toggleNoComment(); return false;"><i id="profile-nocomment-sub" class="fa fa-comments"></i>&nbsp;{{$nocommenttitlesub}}</a>
{{/if}}
<hr />
{{$custommoretoolsdropdown}}
</div>
</div>
{{/if}}
@ -186,6 +191,11 @@
</div>
</div>
<div id="profile-jot-submit-right" class="btn-group float-right">
{{foreach $customsubmitright as $csr}}
<button class="btn btn-outline-secondary btn-sm" {{$csr.buttonparams}} title="{{$csr.preview}}">
{{$csr.buttoncontent}}
</button>
{{/foreach}}
{{if $preview}}
<button class="btn btn-outline-secondary btn-sm" onclick="preview_post();return false;" title="{{$preview}}">
<i class="fa fa-eye jot-icons" ></i>