diff --git a/retriever/retriever.php b/retriever/retriever.php index bcc0963a..37715126 100644 --- a/retriever/retriever.php +++ b/retriever/retriever.php @@ -840,12 +840,10 @@ function retriever_transform_images(array &$item, array $resource) { /** * @brief Displays the retriever configuration page for a contact. Alternatively, if the user clicked the "help" button, display the help content. - * - * @param App $a The App object */ -function retriever_content(App $a) { +function retriever_content() { if (!DI::userSession()->getLocalUserId()) { - $a->page['content'] .= "

Please log in

"; + DI::page()['content'] .= "

Please log in

"; return; } if (isset(DI::args()->getArgv()[1]) and DI::args()->getArgv()[1] === 'help') { @@ -854,7 +852,7 @@ function retriever_content(App $a) { $feeds[$i]['url'] = DI::baseUrl() . '/retriever/' . $feeds[$i]['id']; } $template = Renderer::getMarkupTemplate('/help.tpl', 'addon/retriever/'); - $a->page['content'] .= Renderer::replaceMacros($template, array( + DI::page()['content'] .= Renderer::replaceMacros($template, array( '$config' => DI::baseUrl() . '/settings/addon', '$allow_images' => DI::config()->get('retriever', 'allow_images'), '$feeds' => $feeds)); @@ -895,12 +893,12 @@ function retriever_content(App $a) { } } DBA::update('retriever_rule', ['data' => json_encode($retriever_rule['data'])], ['id' => intval($retriever_rule["id"])], ['data' => '']); - $a->page['content'] .= "

Settings Updated"; + DI::page()['content'] .= "

Settings Updated"; if (!empty($_POST["retriever_retrospective"])) { apply_retrospective($retriever_rule, $_POST["retriever_retrospective"]); - $a->page['content'] .= " and retrospectively applied to " . $_POST["retriever_retrospective"] . " posts"; + DI::page()['content'] .= " and retrospectively applied to " . $_POST["retriever_retrospective"] . " posts"; } - $a->page['content'] .= ".

"; + DI::page()['content'] .= ".

"; } $template = Renderer::getMarkupTemplate('/rule-config.tpl', 'addon/retriever/'); @@ -1011,12 +1009,11 @@ function retriever_post_remote_hook(array &$item) { /** * @brief Hook for adding per-user retriever settings to the user's settings page * - * @param App $a The App object (by ref) - * @param string $s HTML string to which to append settings content (by ref) + * @param array $data Hook data array */ -function retriever_addon_settings(App &$a, string &$s) { - $all_photos = DI::config()->get(DI::userSession()->getLocalUserId(), 'retriever', 'all_photos'); - $oembed = DI::config()->get(DI::userSession()->getLocalUserId(), 'retriever', 'oembed'); +function retriever_addon_settings(array &$data) { + $all_photos = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'retriever', 'all_photos'); + $oembed = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'retriever', 'oembed'); $template = Renderer::getMarkupTemplate('/settings.tpl', 'addon/retriever/'); $config = array('$submit' => DI::l10n()->t('Save Settings'), '$title' => DI::l10n()->t('Retriever Settings'), @@ -1030,26 +1027,31 @@ function retriever_addon_settings(App &$a, string &$s) { DI::l10n()->t('Resolve OEmbed'), $oembed, DI::l10n()->t('Check this to attempt to retrieve embedded content for all posts')); - $s .= Renderer::replaceMacros($template, $config); + $html = Renderer::replaceMacros($template, $config); + $data = [ + 'addon' => 'retriever', + 'title' => DI::l10n()->t('Retriever Settings'), + 'html' => $html, + ]; } /** * @brief Hook for processing post results from user's settings page * - * @param App $a The App object * @param array $post Posted content + * @return void */ -function retriever_addon_settings_post(App $a, array $post) { +function retriever_addon_settings_post(array $post) { if ($post['retriever_all_photos']) { - DI::config()->set(DI::userSession()->getLocalUserId(), 'retriever', 'all_photos', $post['retriever_all_photos']); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'retriever', 'all_photos', $post['retriever_all_photos']); } else { - DI::config()->delete(DI::userSession()->getLocalUserId(), 'retriever', 'all_photos'); + DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'retriever', 'all_photos'); } if ($post['retriever_oembed']) { - DI::config()->set(DI::userSession()->getLocalUserId(), 'retriever', 'oembed', $post['retriever_oembed']); + DI::pConfig()->set(DI::userSession()->getLocalUserId(), 'retriever', 'oembed', $post['retriever_oembed']); } else { - DI::config()->delete(DI::userSession()->getLocalUserId(), 'retriever', 'oembed'); + DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'retriever', 'oembed'); } } diff --git a/retriever/templates/settings.tpl b/retriever/templates/settings.tpl index 3151fd72..f6437be9 100644 --- a/retriever/templates/settings.tpl +++ b/retriever/templates/settings.tpl @@ -1,16 +1,5 @@ - -

{{$title}}

-
-