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

67 lines
2.4 KiB
PHP
Raw Normal View History

2020-03-21 18:30:30 +00:00
<?php
/**
* Name: Link
* Description: Using short links on whole hub
2020-04-07 20:29:33 +00:00
* Version: 0.70
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');
}
function link_plugin_admin(&$a,&$o) {
2020-04-04 20:18:26 +00:00
$t = get_markup_template( "admin.tpl", "addon/link/" );
$o = replace_macros($t, array(
'$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')),
));
}
function link_plugin_admin_post(&$a) {
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
}
2020-04-07 20:29:33 +00:00
function dropdown_link($a, &$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
function hideasides_header($a, &$b) {
$querystr = stristr(App::$query_string, '/', true);
if ($querystr == "link") {
$addScriptTag = "<style>#region_1 { display: none; } #region_3 { display: none; }</style>\r\n";
App::$page['htmlhead'] .= $addScriptTag;
}
}