Further updates to 2020.03

This commit is contained in:
Matthew Exon 2020-08-23 21:15:18 +01:00 committed by Matthew Exon
parent 5f83ba1032
commit 474452f2bc
2 changed files with 16 additions and 17 deletions

View file

@ -21,7 +21,6 @@
*/
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\Logger;
use Friendica\Object\Image;
use Friendica\Database\DBA;
@ -43,7 +42,7 @@ function phototrack_install() {
Addon::registerHook('notifier_end', 'addon/phototrack/phototrack.php', 'phototrack_notifier_end');
Addon::registerHook('cron', 'addon/phototrack/phototrack.php', 'phototrack_cron');
if (Config::get('phototrack', 'dbversion') != '0.1') {
if (DI::config()->get('phototrack', 'dbversion') != '0.1') {
$schema = file_get_contents(dirname(__file__).'/database.sql');
$arr = explode(';', $schema);
foreach ($arr as $a) {
@ -52,7 +51,7 @@ function phototrack_install() {
return;
}
}
Config::set('phototrack', 'dbversion', '0.1');
DI::config()->set('phototrack', 'dbversion', '0.1');
}
}
@ -190,7 +189,7 @@ function phototrack_check_row($a, $table, $row) {
}
function phototrack_batch_size() {
$batch_size = Config::get('phototrack', 'batch_size');
$batch_size = DI::config()->get('phototrack', 'batch_size');
if ($batch_size > 0) {
return $batch_size;
}
@ -210,13 +209,13 @@ function phototrack_search_table($a, $table) {
}
function phototrack_cron_time() {
$prev_remaining = Config::get('phototrack', 'remaining_items');
$prev_remaining = DI::config()->get('phototrack', 'remaining_items');
if ($prev_remaining > 10 * phototrack_batch_size()) {
Logger::debug('phototrack: more than ' . (10 * phototrack_batch_size()) . ' items remaining');
return true;
}
$last = Config::get('phototrack', 'last_search');
$search_interval = intval(Config::get('phototrack', 'search_interval'));
$last = DI::config()->get('phototrack', 'last_search');
$search_interval = intval(DI::config()->get('phototrack', 'search_interval'));
if (!$search_interval) {
$search_interval = PHOTOTRACK_DEFAULT_SEARCH_INTERVAL;
}
@ -234,7 +233,7 @@ function phototrack_cron($a, $b) {
if (!phototrack_cron_time()) {
return;
}
Config::set('phototrack', 'last_search', time());
DI::config()->set('phototrack', 'last_search', time());
$remaining = 0;
$remaining += phototrack_search_table($a, 'item');
@ -244,7 +243,7 @@ function phototrack_cron($a, $b) {
$remaining += phototrack_search_table($a, 'fsuggest');
$remaining += phototrack_search_table($a, 'gcontact');
Config::set('phototrack', 'remaining_items', $remaining);
DI::config()->set('phototrack', 'remaining_items', $remaining);
if ($remaining === 0) {
phototrack_tidy();
}

View file

@ -966,13 +966,13 @@ function retriever_post_remote_hook(&$a, &$item) {
retriever_on_item_insert($retriever_rule, $item);
}
else {
if (PDI::config()->get($item["uid"], 'retriever', 'oembed')) {
if (DI::config()->get($item["uid"], 'retriever', 'oembed')) {
// Convert to HTML and back to take advantage of bbcode's resolution of oembeds.
$body = retriever_get_body($item);
$body = HTML::toBBCode(BBCode::convert($body));
retriever_set_body($item, $body);
}
if (PDI::config()->get($item["uid"], 'retriever', 'all_photos')) {
if (DI::config()->get($item["uid"], 'retriever', 'all_photos')) {
retrieve_images($item);
}
}
@ -986,8 +986,8 @@ function retriever_post_remote_hook(&$a, &$item) {
* @param string $s HTML string to which to append settings content (by ref)
*/
function retriever_addon_settings(&$a, &$s) {
$all_photos = PDI::config()->get(local_user(), 'retriever', 'all_photos');
$oembed = PDI::config()->get(local_user(), 'retriever', 'oembed');
$all_photos = DI::config()->get(local_user(), 'retriever', 'all_photos');
$oembed = DI::config()->get(local_user(), 'retriever', 'oembed');
$template = Renderer::getMarkupTemplate('/settings.tpl', 'addon/retriever/');
$config = array('$submit' => DI::l10n()->t('Save Settings'),
'$title' => DI::l10n()->t('Retriever Settings'),
@ -1012,15 +1012,15 @@ function retriever_addon_settings(&$a, &$s) {
*/
function retriever_addon_settings_post($a, $post) {
if ($post['retriever_all_photos']) {
PDI::config()->set(local_user(), 'retriever', 'all_photos', $post['retriever_all_photos']);
DI::config()->set(local_user(), 'retriever', 'all_photos', $post['retriever_all_photos']);
}
else {
PDI::config()->delete(local_user(), 'retriever', 'all_photos');
DI::config()->delete(local_user(), 'retriever', 'all_photos');
}
if ($post['retriever_oembed']) {
PDI::config()->set(local_user(), 'retriever', 'oembed', $post['retriever_oembed']);
DI::config()->set(local_user(), 'retriever', 'oembed', $post['retriever_oembed']);
}
else {
PDI::config()->delete(local_user(), 'retriever', 'oembed');
DI::config()->delete(local_user(), 'retriever', 'oembed');
}
}