Status editor hook

This commit is contained in:
M. Dent 2018-09-29 20:22:27 +02:00
parent cc9ca8bbff
commit ff20370d0b
20 changed files with 66 additions and 18 deletions

View File

@ -122,7 +122,7 @@ class Article_edit extends \Zotlabs\Web\Controller {
'bbcode' => (($mimetype == 'text/bbcode') ? true : false) 'bbcode' => (($mimetype == 'text/bbcode') ? true : false)
); );
$editor = status_editor($a, $x); $editor = status_editor($a, $x, false, 'Article_edit');
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array( $o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
'$title' => t('Edit Article'), '$title' => t('Edit Article'),

View File

@ -132,7 +132,7 @@ class Articles extends Controller {
$x['title'] = $_REQUEST['title']; $x['title'] = $_REQUEST['title'];
if($_REQUEST['body']) if($_REQUEST['body'])
$x['body'] = $_REQUEST['body']; $x['body'] = $_REQUEST['body'];
$editor = status_editor($a,$x); $editor = status_editor($a,$x,false,'Articles');
} }
else { else {

View File

@ -109,7 +109,7 @@ class Blocks extends \Zotlabs\Web\Controller {
if($_REQUEST['pagetitle']) if($_REQUEST['pagetitle'])
$x['pagetitle'] = $_REQUEST['pagetitle']; $x['pagetitle'] = $_REQUEST['pagetitle'];
$editor = status_editor($a,$x); $editor = status_editor($a,$x,false,'Blocks');
$r = q("select iconfig.iid, iconfig.k, iconfig.v, mid, title, body, mimetype, created, edited from iconfig $r = q("select iconfig.iid, iconfig.k, iconfig.v, mid, title, body, mimetype, created, edited from iconfig

View File

@ -122,7 +122,7 @@ class Card_edit extends \Zotlabs\Web\Controller {
'bbcode' => (($mimetype == 'text/bbcode') ? true : false) 'bbcode' => (($mimetype == 'text/bbcode') ? true : false)
); );
$editor = status_editor($a, $x); $editor = status_editor($a, $x, false, 'Card_edit');
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array( $o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
'$title' => t('Edit Card'), '$title' => t('Edit Card'),

View File

@ -133,7 +133,7 @@ class Cards extends Controller {
if($_REQUEST['body']) if($_REQUEST['body'])
$x['body'] = $_REQUEST['body']; $x['body'] = $_REQUEST['body'];
$editor = status_editor($a, $x); $editor = status_editor($a, $x, false, 'Cards');
} }
else { else {
$editor = ''; $editor = '';

View File

@ -168,7 +168,7 @@ class Channel extends Controller {
'reset' => t('Reset form') 'reset' => t('Reset form')
); );
$o .= status_editor($a,$x); $o .= status_editor($a,$x,false,'Channel');
} }
} }

View File

@ -81,7 +81,7 @@ class Display extends \Zotlabs\Web\Controller {
); );
$o = '<div id="jot-popup">'; $o = '<div id="jot-popup">';
$o .= status_editor($a,$x); $o .= status_editor($a,$x,false,'Display');
$o .= '</div>'; $o .= '</div>';
} }

View File

@ -132,7 +132,7 @@ class Editblock extends \Zotlabs\Web\Controller {
'bbcode' => (($mimetype == 'text/bbcode') ? true : false) 'bbcode' => (($mimetype == 'text/bbcode') ? true : false)
); );
$editor = status_editor($a, $x); $editor = status_editor($a, $x, false, 'Editblock');
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array( $o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
'$title' => t('Edit Block'), '$title' => t('Edit Block'),

View File

@ -131,7 +131,7 @@ class Editlayout extends \Zotlabs\Web\Controller {
'profile_uid' => intval($owner), 'profile_uid' => intval($owner),
); );
$editor = status_editor($a, $x); $editor = status_editor($a, $x, false, 'Editlayout');
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array( $o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
'$title' => t('Edit Layout'), '$title' => t('Edit Layout'),

View File

@ -102,7 +102,7 @@ class Editpost extends \Zotlabs\Web\Controller {
'bbcode' => true 'bbcode' => true
); );
$editor = status_editor($a, $x); $editor = status_editor($a, $x, false, 'Editpost');
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array( $o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
'$title' => t('Edit post'), '$title' => t('Edit post'),

View File

@ -160,7 +160,7 @@ class Editwebpage extends \Zotlabs\Web\Controller {
'bbcode' => (($mimetype == 'text/bbcode') ? true : false) 'bbcode' => (($mimetype == 'text/bbcode') ? true : false)
); );
$editor = status_editor($a, $x); $editor = status_editor($a, $x, false, 'Editwebpage');
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array( $o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
'$title' => t('Edit Webpage'), '$title' => t('Edit Webpage'),

View File

@ -138,7 +138,7 @@ class Hq extends \Zotlabs\Web\Controller {
[ [
'$no_messages' => (($target_item) ? false : true), '$no_messages' => (($target_item) ? false : true),
'$no_messages_label' => [ t('Welcome to Hubzilla!'), t('You have got no unseen posts...') ], '$no_messages_label' => [ t('Welcome to Hubzilla!'), t('You have got no unseen posts...') ],
'$editor' => status_editor($a,$x) '$editor' => status_editor($a,$x,false,'Hq')
] ]
); );

View File

@ -141,7 +141,7 @@ class Layouts extends \Zotlabs\Web\Controller {
if($_REQUEST['pagetitle']) if($_REQUEST['pagetitle'])
$x['pagetitle'] = $_REQUEST['pagetitle']; $x['pagetitle'] = $_REQUEST['pagetitle'];
$editor = status_editor($a,$x); $editor = status_editor($a,$x,false,'Layouts');
$r = q("select iconfig.iid, iconfig.v, mid, title, body, mimetype, created, edited, item_type from iconfig $r = q("select iconfig.iid, iconfig.v, mid, title, body, mimetype, created, edited, item_type from iconfig
left join item on iconfig.iid = item.id left join item on iconfig.iid = item.id

View File

@ -196,7 +196,7 @@ class Network extends \Zotlabs\Web\Controller {
$x['pretext'] = $deftag; $x['pretext'] = $deftag;
$status_editor = status_editor($a,$x); $status_editor = status_editor($a,$x,false,'Network');
$o .= $status_editor; $o .= $status_editor;
$static = channel_manual_conv_update(local_channel()); $static = channel_manual_conv_update(local_channel());

View File

@ -81,7 +81,7 @@ class Pubstream extends \Zotlabs\Web\Controller {
); );
$o = '<div id="jot-popup">'; $o = '<div id="jot-popup">';
$o .= status_editor($a,$x); $o .= status_editor($a,$x,false,'Pubstream');
$o .= '</div>'; $o .= '</div>';
} }

View File

@ -138,7 +138,7 @@ class Rpost extends \Zotlabs\Web\Controller {
'jotnets' => true 'jotnets' => true
); );
$editor = status_editor($a,$x); $editor = status_editor($a,$x,false,'Rpost');
$o .= replace_macros(get_markup_template('edpost_head.tpl'), array( $o .= replace_macros(get_markup_template('edpost_head.tpl'), array(
'$title' => t('Edit post'), '$title' => t('Edit post'),

View File

@ -208,7 +208,7 @@ class Webpages extends Controller {
if(! $r) if(! $r)
$x['pagetitle'] = 'home'; $x['pagetitle'] = 'home';
$editor = status_editor($a,$x); $editor = status_editor($a,$x,false,'Webpages');
$pages = null; $pages = null;

31
doc/hook/status_editor.bb Normal file
View File

@ -0,0 +1,31 @@
[h2]status_editor[/h2]
Replace the default status_editor (jot).
Allow plugins to replace the default status editor in a context dependent manner.
It is fed an array of ['editor_html' => '', 'x' => $x, 'popup' => $popup, 'module' => $module].
All calls to the status_editor at the time of the creation of this hook have been updated
to set $module at invocation. This allows addon developers to have a context dependent editor
based on the Hubzilla module/addon.
Calls to status_editor() are in the form of:
status_editor($a, $x, $popup, $module).
Future module/addon developers are encouraged to set $popup and $module when invoking the
status_editor.
[code]
$hook_info = ['editor_html' => '', 'x' => $x, 'popup' => $popup, 'module' => $module];
call_hooks('status_editor',$hook_info);
if ($hook_info['editor_html'] == '') {
return hz_status_editor($a, $x, $popup);
} else {
return $hook_info['editor_html'];
}
[/code]
see: include/conversation.php

View File

@ -595,6 +595,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/smilie]smilie[/zrl] [zrl=[baseurl]/help/hook/smilie]smilie[/zrl]
Called when translating emoticons Called when translating emoticons
[zrl=[baseurl]/help/hook/status_editor]status_editor[/zrl]
Called when generating the status_editor.
[zrl=[baseurl]/help/hook/stream_item]stream_item[/zrl] [zrl=[baseurl]/help/hook/stream_item]stream_item[/zrl]
Called for each item which is rendered for viewing via conversation() Called for each item which is rendered for viewing via conversation()

View File

@ -1232,13 +1232,27 @@ function format_like($cnt, $arr, $type, $id) {
return $o; return $o;
} }
/**
* Wrapper to allow addons to replace the status editor if desired.
*/
function status_editor($a, $x, $popup = false, $module='') {
$hook_info = ['editor_html' => '', 'x' => $x, 'popup' => $popup, 'module' => $module];
call_hooks('status_editor',$hook_info);
if ($hook_info['editor_html'] == '') {
return hz_status_editor($a, $x, $popup);
} else {
return $hook_info['editor_html'];
}
}
/** /**
* This is our general purpose content editor. * This is our general purpose content editor.
* It was once nicknamed "jot" and you may see references to "jot" littered throughout the code. * It was once nicknamed "jot" and you may see references to "jot" littered throughout the code.
* They are referring to the content editor or components thereof. * They are referring to the content editor or components thereof.
*/ */
function status_editor($a, $x, $popup = false) { function hz_status_editor($a, $x, $popup = false) {
$o = ''; $o = '';