From 3bb71a6ba88c42744652d793ae767cf0c79388bd Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 22 Aug 2021 09:20:40 +0000 Subject: infrastructure to provide an app install widget for modules and make the bookmark app use it --- Zotlabs/Lib/Apps.php | 37 +++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Bookmarks.php | 7 ++----- 2 files changed, 39 insertions(+), 5 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index 30c108cc1..d7d225e9a 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -575,6 +575,30 @@ class Apps { )); } + + /** + * @brief Render a simple app install button with app name and description. + * + * @param string $app app name + * @return string + */ + static public function app_render_install($app) { + + $papp = self::get_papp($app); + + if (!$papp) { + return EMPTY_STR; + } + + $papp_encoded = self::papp_encode($papp); + + return replace_macros(get_markup_template('app_install.tpl'), [ + '$papp' => $papp, + '$papp_encoded' => $papp_encoded, + '$install' => t('Install') + ]); + } + static public function app_install($uid,$app) { if(! is_array($app)) { @@ -1357,4 +1381,17 @@ class Apps { return chunk_split(base64_encode(json_encode($papp)),72,"\n"); } + static public function get_papp($app) { + + $r = q("select * from app where app_id = '%s' and app_channel = 0 limit 1", + dbesc(hash('whirlpool', $app)) + ); + + if ($r) { + $papp = self::app_encode($r[0]); + return $papp; + } + + return false; + } } diff --git a/Zotlabs/Module/Bookmarks.php b/Zotlabs/Module/Bookmarks.php index 000e2893f..ea34754da 100644 --- a/Zotlabs/Module/Bookmarks.php +++ b/Zotlabs/Module/Bookmarks.php @@ -74,10 +74,7 @@ class Bookmarks extends \Zotlabs\Web\Controller { if(! Apps::system_app_installed(local_channel(), 'Bookmarks')) { //Do not display any associated widgets at this point App::$pdl = ''; - - $o = '' . t('Bookmarks App') . ' (' . t('Not Installed') . '):
'; - $o .= t('Bookmark links from posts and manage them'); - return $o; + return Apps::app_render_install('Bookmarks'); } require_once('include/menu.php'); @@ -89,7 +86,7 @@ class Bookmarks extends \Zotlabs\Web\Controller { $o .= '
'; - $o .= '

' . t('My Bookmarks') . '

'; + $o .= '

' . t('Bookmarks') . '

'; $x = menu_list(local_channel(),'',MENU_BOOKMARK); -- cgit v1.2.3