2
0
Fork 0
ussr-hubzilla-addons/link/link.php

67 lines
2.4 KiB
PHP
Raw Permalink Normal View History

2020-03-21 18:30:30 +00:00
<?php
/**
* Name: Link
* Description: Using short links on whole hub
2023-11-26 07:16:19 +00:00
* Version: 0.87
2020-03-21 18:30:30 +00:00
* Author: ivan zlax <@zlax@ussr.win>
* Maintainer: ivan zlax <@zlax@ussr.win>
*/
use Zotlabs\Lib\Apps;
use Zotlabs\Extend\Hook;
use Zotlabs\Extend\Route;
2020-03-21 18:30:30 +00:00
function link_load() {
2020-04-04 20:18:26 +00:00
Route::register('addon/link/Mod_Link.php','link');
if (get_config('link','linkonhub'))
2020-04-07 18:00:00 +00:00
register_hook('dropdown_extras', 'addon/link/link.php', 'dropdown_link');
2020-04-07 18:40:30 +00:00
if (get_config('link','hideasides'))
register_hook('page_header', 'addon/link/link.php', 'hideasides_header');
2020-04-04 20:18:26 +00:00
set_config('link','linkenabled',1);
}
2020-03-21 18:30:30 +00:00
function link_unload() {
2020-04-04 20:18:26 +00:00
Route::unregister('addon/link/Mod_Link.php','link');
2020-04-07 18:00:00 +00:00
unregister_hook('dropdown_extras', 'addon/link/link.php', 'dropdown_link');
2020-04-07 18:40:30 +00:00
unregister_hook('page_header', 'addon/link/link.php', 'hideasides_header');
2020-04-04 20:18:26 +00:00
del_config('link','linkenabled');
}
2020-11-07 13:02:21 +00:00
function link_plugin_admin(&$a) {
2020-04-04 20:18:26 +00:00
$t = get_markup_template( "admin.tpl", "addon/link/" );
2020-11-07 13:02:21 +00:00
$a = replace_macros($t, array(
2020-04-04 20:18:26 +00:00
'$submit' => t('Submit'),
2020-04-07 18:40:30 +00:00
'$hideasides' => array('hideasides', t('Hide side panels on the link page'), get_config('link', 'hideasides')),
2020-04-04 20:18:26 +00:00
'$linkonhub' => array('linkonhub', t('Show "Link on Hub" in the dropdown menu'), get_config('link', 'linkonhub')),
));
}
2020-11-07 13:02:21 +00:00
function link_plugin_admin_post() {
2020-04-04 20:18:26 +00:00
set_config('link','linkonhub',trim($_POST['linkonhub']));
2020-04-07 18:40:30 +00:00
set_config('link','hideasides',trim($_POST['hideasides']));
2020-04-04 20:18:26 +00:00
if (get_config('link','linkonhub'))
2020-04-07 18:00:00 +00:00
register_hook('dropdown_extras', 'addon/link/link.php', 'dropdown_link');
2020-04-04 20:18:26 +00:00
else
2020-04-07 18:00:00 +00:00
unregister_hook('dropdown_extras', 'addon/link/link.php', 'dropdown_link');
2020-04-07 18:40:30 +00:00
if (get_config('link','hideasides'))
register_hook('page_header', 'addon/link/link.php', 'hideasides_header');
else
unregister_hook('page_header', 'addon/link/link.php', 'hideasides_header');
2020-04-04 20:18:26 +00:00
info( t('Settings updated.') . EOL );
2020-03-31 17:45:31 +00:00
}
2023-11-26 07:16:19 +00:00
function dropdown_link(&$extras) {
2020-04-04 20:18:26 +00:00
$arr = $extras;
$item_id = $extras['item']['item_id'];
$arr['dropdown_extras'] .= '<a class="dropdown-item" href="'.z_root().'/link/'.$item_id.'" title="'.t('Link on Hub').'" class="u-url"><i class="generic-icons-nav fa fa-fw fa-link"></i>'.t('Link on Hub').'</a>';
$extras = $arr;
}
2020-04-07 18:40:30 +00:00
2023-11-26 07:16:19 +00:00
function hideasides_header(&$b) {
2020-04-07 18:40:30 +00:00
$querystr = stristr(App::$query_string, '/', true);
if ($querystr == "link") {
2023-11-26 07:16:19 +00:00
$addScriptTag = "<style>#region_1 { display: none !important; } #region_3 { display: none !important; }</style>\r\n";
2020-04-07 18:40:30 +00:00
App::$page['htmlhead'] .= $addScriptTag;
}
}