4 * Description: Add "View Source" link to item context
6 * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
9 use Friendica\Core\Hook;
11 use Friendica\Model\Item;
12 use Friendica\Database\DBA;
14 function viewsrc_install() {
15 Hook::register('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu');
16 Hook::register('page_end', 'addon/viewsrc/viewsrc.php', 'viewsrc_page_end');
20 function viewsrc_uninstall() {
21 Hook::unregister('item_photo_menu', 'addon/viewsrc/viewsrc.php', 'viewsrc_item_photo_menu');
22 Hook::unregister('page_end', 'addon/viewsrc/viewsrc.php', 'viewsrc_page_end');
26 function viewsrc_page_end(&$a, &$o){
27 DI::page()['htmlhead'] .= <<< EOS
30 $('a[href*="/viewsrc/"]').each(function() {
31 $(this).colorbox($(this).attr('href'));
38 function viewsrc_item_photo_menu(&$a, &$b)
44 if (local_user() != $b['item']['uid']) {
45 $item = Item::selectFirstForUser(local_user(), ['id'], ['uid' => local_user(), 'guid' => $b['item']['guid']]);
46 if (!DBA::isResult($item)) {
50 $item_id = $item['id'];
52 $item_id = $b['item']['id'];
55 $b['menu'] = array_merge([DI::l10n()->t('View Source') => DI::baseUrl()->get() . '/viewsrc/'. $item_id], $b['menu']);
57 //if((! local_user()) || (local_user() != $b['item']['uid']))
60 //$b['menu'] = array_merge(array(DI::l10n()->t('View Source') => $a->getBaseURL() . '/viewsrc/'. $b['item']['id']), $b['menu']);