remove js, add php hook
This commit is contained in:
parent
b220e2b7a6
commit
01d81c6f21
|
@ -101,8 +101,8 @@ class Link extends \Zotlabs\Web\Controller {
|
||||||
);
|
);
|
||||||
|
|
||||||
if($x) {
|
if($x) {
|
||||||
// not yet ready for prime time
|
// not yet ready for prime time
|
||||||
// \App::$poi = $x[0];
|
// \App::$poi = $x[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
//if the item is to be moderated redirect to /moderate
|
//if the item is to be moderated redirect to /moderate
|
||||||
|
@ -169,7 +169,6 @@ class Link extends \Zotlabs\Web\Controller {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0);
|
$static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0);
|
||||||
|
|
||||||
$simple_update = (($update) ? " AND item_unseen = 1 " : '');
|
$simple_update = (($update) ? " AND item_unseen = 1 " : '');
|
||||||
|
@ -347,7 +346,6 @@ class Link extends \Zotlabs\Web\Controller {
|
||||||
$items = array();
|
$items = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch($module_format) {
|
switch($module_format) {
|
||||||
|
|
||||||
case 'html':
|
case 'html':
|
||||||
|
@ -394,7 +392,6 @@ class Link extends \Zotlabs\Web\Controller {
|
||||||
// a much simpler interface
|
// a much simpler interface
|
||||||
call_hooks('atom_feed', $atom);
|
call_hooks('atom_feed', $atom);
|
||||||
|
|
||||||
|
|
||||||
if($items) {
|
if($items) {
|
||||||
$type = 'html';
|
$type = 'html';
|
||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
|
|
|
@ -9,6 +9,6 @@ hub.domain/link/item
|
||||||
|
|
||||||
where an item is the numeric value of an object from the database.
|
where an item is the numeric value of an object from the database.
|
||||||
|
|
||||||
It is possible to use /admin/addons/link settings page for enabling or disabling of showing "Link on Hub" button (currently used temporarily javascript code for the integrating with wall-item-menu, which does not support page updates, it will be fixed later)
|
It is possible to use /admin/addons/link settings page for enabling or disabling of showing "Link on Hub" in the dropdown menu.
|
||||||
|
|
||||||
Based on Zotlabs/Module/Display.php
|
Based on Zotlabs/Module/Display.php
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/**
|
/**
|
||||||
* Name: Link
|
* Name: Link
|
||||||
* Description: Using short links on whole hub
|
* Description: Using short links on whole hub
|
||||||
* Version: 0.05
|
* Version: 0.55
|
||||||
* Author: ivan zlax <@zlax@ussr.win>
|
* Author: ivan zlax <@zlax@ussr.win>
|
||||||
* Maintainer: ivan zlax <@zlax@ussr.win>
|
* Maintainer: ivan zlax <@zlax@ussr.win>
|
||||||
*/
|
*/
|
||||||
|
@ -14,13 +14,13 @@ use Zotlabs\Extend\Route;
|
||||||
function link_load() {
|
function link_load() {
|
||||||
Route::register('addon/link/Mod_Link.php','link');
|
Route::register('addon/link/Mod_Link.php','link');
|
||||||
if (get_config('link','linkonhub'))
|
if (get_config('link','linkonhub'))
|
||||||
register_hook('page_end', 'addon/link/link.php', 'link_active');
|
Hook::register('dropdown_extras', 'addon/link/link.php', 'dropdown_link', 1, 5000);
|
||||||
set_config('link','linkenabled',1);
|
set_config('link','linkenabled',1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function link_unload() {
|
function link_unload() {
|
||||||
Route::unregister('addon/link/Mod_Link.php','link');
|
Route::unregister('addon/link/Mod_Link.php','link');
|
||||||
unregister_hook('page_end', 'addon/link/link.php', 'link_active');
|
Hook::unregister('dropdown_extras', 'addon/link/link.php', 'dropdown_link');
|
||||||
del_config('link','linkenabled');
|
del_config('link','linkenabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,21 +28,22 @@ function link_plugin_admin(&$a,&$o) {
|
||||||
$t = get_markup_template( "admin.tpl", "addon/link/" );
|
$t = get_markup_template( "admin.tpl", "addon/link/" );
|
||||||
$o = replace_macros($t, array(
|
$o = replace_macros($t, array(
|
||||||
'$submit' => t('Submit'),
|
'$submit' => t('Submit'),
|
||||||
'$linkonhub' => array('linkonhub', t('Show "Link on Hub" button'), get_config('link', 'linkonhub'), t('Currently used temporarily javascript code for the integrating with wall-item-menu (will be fixed later)')),
|
'$linkonhub' => array('linkonhub', t('Show "Link on Hub" in the dropdown menu'), get_config('link', 'linkonhub')),
|
||||||
));
|
));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function link_plugin_admin_post(&$a) {
|
function link_plugin_admin_post(&$a) {
|
||||||
set_config('link','linkonhub',trim($_POST['linkonhub']));
|
set_config('link','linkonhub',trim($_POST['linkonhub']));
|
||||||
info( t('Settings updated.') . EOL);
|
|
||||||
if (get_config('link','linkonhub'))
|
if (get_config('link','linkonhub'))
|
||||||
register_hook('page_end', 'addon/link/link.php', 'link_active');
|
Hook::register('dropdown_extras', 'addon/link/link.php', 'dropdown_link', 1, 5000);
|
||||||
else
|
else
|
||||||
unregister_hook('page_end', 'addon/link/link.php', 'link_active');
|
Hook::unregister('dropdown_extras', 'addon/link/link.php', 'dropdown_link');
|
||||||
|
info( t('Settings updated.') . EOL );
|
||||||
}
|
}
|
||||||
|
|
||||||
function link_active(&$a,&$b) {
|
function dropdown_link(&$extras) {
|
||||||
// Javascript code for "Link on Hub" button insert - it is not good, it is temporarily, works not good
|
$arr = $extras;
|
||||||
$b .= "\n<script>window.buttonsnotedited = true; setInterval(addButtons, 1000); function addButtons() { if (window.buttonsnotedited == true) { if (loadingPage == false) { let visibleitems = document.querySelectorAll('.btn-group [aria-labelledby]'); for (currentitem of visibleitems) { if (currentitem.getAttribute('aria-labelledby').substr(0,15) == 'wall-item-menu-') currentitem.querySelector('[title=\"Link to Source\"]').outerHTML += '<a class=\"dropdown-item\" href=\"/link/' + currentitem.getAttribute('aria-labelledby').substr(15) + '\" title=\"Link on Hub\"><i class=\"generic-icons-nav fa fa-fw fa-external-link\"></i>Link on Hub</a>';} window.buttonsnotedited = false; } } }</script>\n";
|
$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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue