forked from friendica/friendica-addons
more overdue adaptations
This commit is contained in:
parent
f783b4857d
commit
2cf1076d5c
2 changed files with 23 additions and 32 deletions
|
@ -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.
|
* @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()) {
|
if (!DI::userSession()->getLocalUserId()) {
|
||||||
$a->page['content'] .= "<p>Please log in</p>";
|
DI::page()['content'] .= "<p>Please log in</p>";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (isset(DI::args()->getArgv()[1]) and DI::args()->getArgv()[1] === 'help') {
|
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'];
|
$feeds[$i]['url'] = DI::baseUrl() . '/retriever/' . $feeds[$i]['id'];
|
||||||
}
|
}
|
||||||
$template = Renderer::getMarkupTemplate('/help.tpl', 'addon/retriever/');
|
$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',
|
'$config' => DI::baseUrl() . '/settings/addon',
|
||||||
'$allow_images' => DI::config()->get('retriever', 'allow_images'),
|
'$allow_images' => DI::config()->get('retriever', 'allow_images'),
|
||||||
'$feeds' => $feeds));
|
'$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' => '']);
|
DBA::update('retriever_rule', ['data' => json_encode($retriever_rule['data'])], ['id' => intval($retriever_rule["id"])], ['data' => '']);
|
||||||
$a->page['content'] .= "<p><b>Settings Updated";
|
DI::page()['content'] .= "<p><b>Settings Updated";
|
||||||
if (!empty($_POST["retriever_retrospective"])) {
|
if (!empty($_POST["retriever_retrospective"])) {
|
||||||
apply_retrospective($retriever_rule, $_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'] .= ".</p></b>";
|
DI::page()['content'] .= ".</p></b>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$template = Renderer::getMarkupTemplate('/rule-config.tpl', 'addon/retriever/');
|
$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
|
* @brief Hook for adding per-user retriever settings to the user's settings page
|
||||||
*
|
*
|
||||||
* @param App $a The App object (by ref)
|
* @param array $data Hook data array
|
||||||
* @param string $s HTML string to which to append settings content (by ref)
|
|
||||||
*/
|
*/
|
||||||
function retriever_addon_settings(App &$a, string &$s) {
|
function retriever_addon_settings(array &$data) {
|
||||||
$all_photos = DI::config()->get(DI::userSession()->getLocalUserId(), 'retriever', 'all_photos');
|
$all_photos = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'retriever', 'all_photos');
|
||||||
$oembed = DI::config()->get(DI::userSession()->getLocalUserId(), 'retriever', 'oembed');
|
$oembed = DI::pConfig()->get(DI::userSession()->getLocalUserId(), 'retriever', 'oembed');
|
||||||
$template = Renderer::getMarkupTemplate('/settings.tpl', 'addon/retriever/');
|
$template = Renderer::getMarkupTemplate('/settings.tpl', 'addon/retriever/');
|
||||||
$config = array('$submit' => DI::l10n()->t('Save Settings'),
|
$config = array('$submit' => DI::l10n()->t('Save Settings'),
|
||||||
'$title' => DI::l10n()->t('Retriever Settings'),
|
'$title' => DI::l10n()->t('Retriever Settings'),
|
||||||
|
@ -1030,26 +1027,31 @@ function retriever_addon_settings(App &$a, string &$s) {
|
||||||
DI::l10n()->t('Resolve OEmbed'),
|
DI::l10n()->t('Resolve OEmbed'),
|
||||||
$oembed,
|
$oembed,
|
||||||
DI::l10n()->t('Check this to attempt to retrieve embedded content for all posts'));
|
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
|
* @brief Hook for processing post results from user's settings page
|
||||||
*
|
*
|
||||||
* @param App $a The App object
|
|
||||||
* @param array $post Posted content
|
* @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']) {
|
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 {
|
else {
|
||||||
DI::config()->delete(DI::userSession()->getLocalUserId(), 'retriever', 'all_photos');
|
DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'retriever', 'all_photos');
|
||||||
}
|
}
|
||||||
if ($post['retriever_oembed']) {
|
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 {
|
else {
|
||||||
DI::config()->delete(DI::userSession()->getLocalUserId(), 'retriever', 'oembed');
|
DI::pConfig()->delete(DI::userSession()->getLocalUserId(), 'retriever', 'oembed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,5 @@
|
||||||
<span id="settings_retriever_inflated" class="settings-block fakelink" style="display: block;" onclick="openClose('settings_retriever_expanded'); openClose('settings_retriever_inflated');">
|
<p><a href="{{$help}}">Get Help</a></p>
|
||||||
<h3>{{$title}}</h3>
|
|
||||||
</span>
|
|
||||||
<div id="settings_retriever_expanded" class="settings-block" style="display: none;">
|
|
||||||
<span class="fakelink" onclick="openClose('settings_retriever_expanded'); openClose('settings_retriever_inflated');">
|
|
||||||
<h3>{{$title}}</h3>
|
|
||||||
</span>
|
|
||||||
<p>
|
|
||||||
<a href="{{$help}}">Get Help</a>
|
|
||||||
</p>
|
|
||||||
{{if $allow_images}}
|
{{if $allow_images}}
|
||||||
{{include file="field_checkbox.tpl" field=$allphotos}}
|
{{include file="field_checkbox.tpl" field=$allphotos}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{include file="field_checkbox.tpl" field=$oembed}}
|
{{include file="field_checkbox.tpl" field=$oembed}}
|
||||||
<input type="submit" value="{{$submit}}">
|
|
||||||
</div>
|
|
||||||
|
|
Loading…
Reference in a new issue