adapt to latest release

This commit is contained in:
Matthew Exon 2023-12-26 13:25:19 +01:00
parent 7cf4adaf53
commit 1d75a40d63

View file

@ -740,7 +740,7 @@ function retrieve_images(array &$item) {
if (!$url) {
continue;
}
if (strpos($url, DI::baseUrl()->get(true)) === FALSE) {
if (strpos($url, DI::baseUrl()) === FALSE) {
$resource = add_retriever_resource($url, $item['uid'], $item['contact-id'], true);
if (!$resource['completed']) {
add_retriever_item($item, $resource);
@ -826,7 +826,7 @@ function retriever_transform_images(array &$item, array $resource) {
return;
}
$photo = Photo::store($image, $uid, $cid, $rid, $filename, $album, 0, 0, "", "", "", "", $desc);
$new_url = DI::baseUrl()->get(true) . '/photo/' . $rid . '-0.' . $image->getExt();
$new_url = DI::baseUrl() . '/photo/' . $rid . '-0.' . $image->getExt();
if (!strlen($new_url)) {
Logger::warning('retriever_transform_images: no replacement URL for image ' . $resource['url']);
return;
@ -845,31 +845,31 @@ function retriever_transform_images(array &$item, array $resource) {
* @param App $a The App object
*/
function retriever_content(App $a) {
if (!Session::getLocalUser()) {
if (!DI::userSession()->getLocalUserId()) {
$a->page['content'] .= "<p>Please log in</p>";
return;
}
if (isset(DI::args()->getArgv()[1]) and DI::args()->getArgv()[1] === 'help') {
$feeds = DBA::selectToArray('contact', ['id', 'name', 'thumb'], ['uid' => Session::getLocalUser(), 'network' => 'feed']);
$feeds = DBA::selectToArray('contact', ['id', 'name', 'thumb'], ['uid' => DI::userSession()->getLocalUserId(), 'network' => 'feed']);
for ($i = 0; $i < count($feeds); ++$i) {
$feeds[$i]['url'] = DI::baseUrl()->get(true) . '/retriever/' . $feeds[$i]['id'];
$feeds[$i]['url'] = DI::baseUrl() . '/retriever/' . $feeds[$i]['id'];
}
$template = Renderer::getMarkupTemplate('/help.tpl', 'addon/retriever/');
$a->page['content'] .= Renderer::replaceMacros($template, array(
'$config' => DI::baseUrl()->get(true) . '/settings/addon',
'$config' => DI::baseUrl() . '/settings/addon',
'$allow_images' => DI::config()->get('retriever', 'allow_images'),
'$feeds' => $feeds));
return;
}
if (isset(DI::args()->getArgv()[1])) {
$arg1 = DI::args()->getArgv()[1];
$retriever_rule = get_retriever_rule($arg1, Session::getLocalUser(), false);
$retriever_rule = get_retriever_rule($arg1, DI::userSession()->getLocalUserId(), false);
if (!$retriever_rule) {
$retriever_rule = ['id' => 0, 'data' => ['enable' => 0, 'modurl' => '', 'pattern' => '', 'replace' => '', 'images' => 0, 'storecookies' => 0, 'cookiedata' => '', 'customxslt' => '', 'include' => '', 'exclude' => '']];
}
if (!empty($_POST["id"])) {
$retriever_rule = get_retriever_rule($arg1, Session::getLocalUser(), true);
$retriever_rule = get_retriever_rule($arg1, DI::userSession()->getLocalUserId(), true);
$retriever_rule['data'] = array();
foreach (array('modurl', 'pattern', 'replace', 'enable', 'images', 'customxslt', 'storecookies', 'cookiedata') as $setting) {
if (empty($_POST['retriever_' . $setting])) {
@ -951,7 +951,7 @@ function retriever_content(App $a) {
$retriever_rule['data']['customxslt'],
DI::l10n()->t("When standard rules aren't enough, apply custom XSLT to the article")),
'$title' => DI::l10n()->t('Retrieve Feed Content'),
'$help' => DI::baseUrl()->get(true) . '/retriever/help',
'$help' => DI::baseUrl() . '/retriever/help',
'$help_t' => DI::l10n()->t('Get Help'),
'$submit_t' => DI::l10n()->t('Submit'),
'$submit' => DI::l10n()->t('Save Settings'),
@ -972,15 +972,14 @@ function retriever_content(App $a) {
/**
* @brief Hook that adds the retriever option to the contact menu
*
* @param App $a The App object (by ref)
* @param array $args Contact menu details to be filled in (by ref)
*/
function retriever_contact_photo_menu(App &$a, array &$args) {
function retriever_contact_photo_menu(array &$args) {
if (!$args) {
return;
}
if ($args["contact"]["network"] == "feed") {
$args["menu"]['retriever'] = array(DI::l10n()->t('Retriever'), DI::baseUrl()->get(true) . '/retriever/' . $args["contact"]['id']);
$args["menu"]['retriever'] = array(DI::l10n()->t('Retriever'), DI::baseUrl() . '/retriever/' . $args["contact"]['id']);
}
}
@ -1018,12 +1017,12 @@ function retriever_post_remote_hook(App &$a, array &$item) {
* @param string $s HTML string to which to append settings content (by ref)
*/
function retriever_addon_settings(App &$a, string &$s) {
$all_photos = DI::config()->get(Session::getLocalUser(), 'retriever', 'all_photos');
$oembed = DI::config()->get(Session::getLocalUser(), 'retriever', 'oembed');
$all_photos = DI::config()->get(DI::userSession()->getLocalUserId(), 'retriever', 'all_photos');
$oembed = DI::config()->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'),
'$help' => DI::baseUrl()->get(true) . '/retriever/help',
'$help' => DI::baseUrl() . '/retriever/help',
'$allow_images' => DI::config()->get('retriever', 'allow_images'));
$config['$allphotos'] = array('retriever_all_photos',
DI::l10n()->t('All Photos'),
@ -1044,15 +1043,15 @@ function retriever_addon_settings(App &$a, string &$s) {
*/
function retriever_addon_settings_post(App $a, array $post) {
if ($post['retriever_all_photos']) {
DI::config()->set(Session::getLocalUser(), 'retriever', 'all_photos', $post['retriever_all_photos']);
DI::config()->set(DI::userSession()->getLocalUserId(), 'retriever', 'all_photos', $post['retriever_all_photos']);
}
else {
DI::config()->delete(Session::getLocalUser(), 'retriever', 'all_photos');
DI::config()->delete(DI::userSession()->getLocalUserId(), 'retriever', 'all_photos');
}
if ($post['retriever_oembed']) {
DI::config()->set(Session::getLocalUser(), 'retriever', 'oembed', $post['retriever_oembed']);
DI::config()->set(DI::userSession()->getLocalUserId(), 'retriever', 'oembed', $post['retriever_oembed']);
}
else {
DI::config()->delete(Session::getLocalUser(), 'retriever', 'oembed');
DI::config()->delete(DI::userSession()->getLocalUserId(), 'retriever', 'oembed');
}
}