forked from friendica/friendica-addons
Further updates to 2020.03
This commit is contained in:
parent
5f83ba1032
commit
474452f2bc
|
@ -21,7 +21,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Friendica\Core\Addon;
|
use Friendica\Core\Addon;
|
||||||
use Friendica\Core\Config;
|
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Object\Image;
|
use Friendica\Object\Image;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
@ -43,7 +42,7 @@ function phototrack_install() {
|
||||||
Addon::registerHook('notifier_end', 'addon/phototrack/phototrack.php', 'phototrack_notifier_end');
|
Addon::registerHook('notifier_end', 'addon/phototrack/phototrack.php', 'phototrack_notifier_end');
|
||||||
Addon::registerHook('cron', 'addon/phototrack/phototrack.php', 'phototrack_cron');
|
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');
|
$schema = file_get_contents(dirname(__file__).'/database.sql');
|
||||||
$arr = explode(';', $schema);
|
$arr = explode(';', $schema);
|
||||||
foreach ($arr as $a) {
|
foreach ($arr as $a) {
|
||||||
|
@ -52,7 +51,7 @@ function phototrack_install() {
|
||||||
return;
|
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() {
|
function phototrack_batch_size() {
|
||||||
$batch_size = Config::get('phototrack', 'batch_size');
|
$batch_size = DI::config()->get('phototrack', 'batch_size');
|
||||||
if ($batch_size > 0) {
|
if ($batch_size > 0) {
|
||||||
return $batch_size;
|
return $batch_size;
|
||||||
}
|
}
|
||||||
|
@ -210,13 +209,13 @@ function phototrack_search_table($a, $table) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function phototrack_cron_time() {
|
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()) {
|
if ($prev_remaining > 10 * phototrack_batch_size()) {
|
||||||
Logger::debug('phototrack: more than ' . (10 * phototrack_batch_size()) . ' items remaining');
|
Logger::debug('phototrack: more than ' . (10 * phototrack_batch_size()) . ' items remaining');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$last = Config::get('phototrack', 'last_search');
|
$last = DI::config()->get('phototrack', 'last_search');
|
||||||
$search_interval = intval(Config::get('phototrack', 'search_interval'));
|
$search_interval = intval(DI::config()->get('phototrack', 'search_interval'));
|
||||||
if (!$search_interval) {
|
if (!$search_interval) {
|
||||||
$search_interval = PHOTOTRACK_DEFAULT_SEARCH_INTERVAL;
|
$search_interval = PHOTOTRACK_DEFAULT_SEARCH_INTERVAL;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +233,7 @@ function phototrack_cron($a, $b) {
|
||||||
if (!phototrack_cron_time()) {
|
if (!phototrack_cron_time()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Config::set('phototrack', 'last_search', time());
|
DI::config()->set('phototrack', 'last_search', time());
|
||||||
|
|
||||||
$remaining = 0;
|
$remaining = 0;
|
||||||
$remaining += phototrack_search_table($a, 'item');
|
$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, 'fsuggest');
|
||||||
$remaining += phototrack_search_table($a, 'gcontact');
|
$remaining += phototrack_search_table($a, 'gcontact');
|
||||||
|
|
||||||
Config::set('phototrack', 'remaining_items', $remaining);
|
DI::config()->set('phototrack', 'remaining_items', $remaining);
|
||||||
if ($remaining === 0) {
|
if ($remaining === 0) {
|
||||||
phototrack_tidy();
|
phototrack_tidy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -966,13 +966,13 @@ function retriever_post_remote_hook(&$a, &$item) {
|
||||||
retriever_on_item_insert($retriever_rule, $item);
|
retriever_on_item_insert($retriever_rule, $item);
|
||||||
}
|
}
|
||||||
else {
|
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.
|
// Convert to HTML and back to take advantage of bbcode's resolution of oembeds.
|
||||||
$body = retriever_get_body($item);
|
$body = retriever_get_body($item);
|
||||||
$body = HTML::toBBCode(BBCode::convert($body));
|
$body = HTML::toBBCode(BBCode::convert($body));
|
||||||
retriever_set_body($item, $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);
|
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)
|
* @param string $s HTML string to which to append settings content (by ref)
|
||||||
*/
|
*/
|
||||||
function retriever_addon_settings(&$a, &$s) {
|
function retriever_addon_settings(&$a, &$s) {
|
||||||
$all_photos = PDI::config()->get(local_user(), 'retriever', 'all_photos');
|
$all_photos = DI::config()->get(local_user(), 'retriever', 'all_photos');
|
||||||
$oembed = PDI::config()->get(local_user(), 'retriever', 'oembed');
|
$oembed = DI::config()->get(local_user(), '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'),
|
||||||
|
@ -1012,15 +1012,15 @@ function retriever_addon_settings(&$a, &$s) {
|
||||||
*/
|
*/
|
||||||
function retriever_addon_settings_post($a, $post) {
|
function retriever_addon_settings_post($a, $post) {
|
||||||
if ($post['retriever_all_photos']) {
|
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 {
|
else {
|
||||||
PDI::config()->delete(local_user(), 'retriever', 'all_photos');
|
DI::config()->delete(local_user(), 'retriever', 'all_photos');
|
||||||
}
|
}
|
||||||
if ($post['retriever_oembed']) {
|
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 {
|
else {
|
||||||
PDI::config()->delete(local_user(), 'retriever', 'oembed');
|
DI::config()->delete(local_user(), 'retriever', 'oembed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue