X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=widgets%2Fwidgets.php;h=319a8a78d6f6c35335f4a12bc7a4e09b6c13dac9;hb=d3e26c729fcd6e566ce6c9d533c6a45c332dc04c;hp=5c075964837bd943efbebfd38b2a34fc982dccbc;hpb=02fdb7c6542bb5ad8b7e524cf98fef9571f48379;p=friendica-addons.git diff --git a/widgets/widgets.php b/widgets/widgets.php index 5c075964..319a8a78 100644 --- a/widgets/widgets.php +++ b/widgets/widgets.php @@ -10,9 +10,9 @@ use Friendica\Core\Hook; use Friendica\Core\L10n; use Friendica\Core\Logger; -use Friendica\Core\PConfig; use Friendica\Core\Renderer; use Friendica\Database\DBA; +use Friendica\DI; function widgets_install() { Hook::register('addon_settings', 'addon/widgets/widgets.php', 'widgets_settings'); @@ -20,16 +20,11 @@ function widgets_install() { Logger::log("installed widgets"); } -function widgets_uninstall() { - Hook::unregister('addon_settings', 'addon/widgets/widgets.php', 'widgets_settings'); - Hook::unregister('addon_settings_post', 'addon/widgets/widgets.php', 'widgets_settings_post'); -} - function widgets_settings_post(){ if(! local_user()) return; if (isset($_POST['widgets-submit'])){ - PConfig::delete(local_user(), 'widgets', 'key'); + DI::pConfig()->delete(local_user(), 'widgets', 'key'); } } @@ -39,8 +34,8 @@ function widgets_settings(&$a,&$o) { return; - $key = PConfig::get(local_user(), 'widgets', 'key' ); - if ($key=='') { $key = mt_rand(); PConfig::set(local_user(), 'widgets', 'key', $key); } + $key = DI::pConfig()->get(local_user(), 'widgets', 'key' ); + if ($key=='') { $key = mt_rand(); DI::pConfig()->set(local_user(), 'widgets', 'key', $key); } $widgets = []; $d = dir(dirname(__file__)); @@ -61,11 +56,11 @@ function widgets_settings(&$a,&$o) { # $t = file_get_contents( dirname(__file__). "/settings.tpl" ); $t = Renderer::getMarkupTemplate("settings.tpl", "addon/widgets/"); $o .= Renderer::replaceMacros($t, [ - '$submit' => L10n::t('Generate new key'), + '$submit' => DI::l10n()->t('Generate new key'), '$title' => "Widgets", - '$label' => L10n::t('Widgets key'), + '$label' => DI::l10n()->t('Widgets key'), '$key' => $key, - '$widgets_h' => L10n::t('Widgets available'), + '$widgets_h' => DI::l10n()->t('Widgets available'), '$widgets' => $widgets, ]); @@ -76,8 +71,7 @@ function widgets_module() { } function _abs_url($s){ - $a = \get_app(); - return preg_replace("|href=(['\"])([^h][^t][^t][^p])|", "href=\$1".$a->getBaseURL()."/\$2", $s); + return preg_replace("|href=(['\"])([^h][^t][^t][^p])|", "href=\$1" . DI::baseUrl()->get() . "/\$2", $s); } function _randomAlphaNum($length){ @@ -127,7 +121,7 @@ function widgets_content(&$a) { if (isset($_GET['p']) && local_user()==$conf['uid'] ) { $o .= ""; $o .= "

Preview Widget

"; - $o .= ''. L10n::t("Addon Settings") .''; + $o .= ''. DI::l10n()->t("Addon Settings") .''; $o .= "

".call_user_func($a->argv[1].'_widget_name')."

"; $o .= call_user_func($a->argv[1].'_widget_help'); @@ -143,10 +137,10 @@ function widgets_content(&$a) { $script = file_get_contents(dirname(__file__)."/widgets.js"); $o .= Renderer::replaceMacros($script, [ - '$entrypoint' => $a->getBaseURL()."/widgets/".$a->argv[1]."/cb/", + '$entrypoint' => DI::baseUrl()->get()."/widgets/".$a->argv[1]."/cb/", '$key' => $conf['key'], '$widget_id' => 'f9a_'.$a->argv[1]."_"._randomAlphaNum(6), - '$loader' => $a->getBaseURL()."/images/rotator.gif", + '$loader' => DI::baseUrl()->get()."/images/rotator.gif", '$args' => (isset($_GET['a'])?$_GET['a']:''), '$width' => $widget_size[0], '$height' => $widget_size[1], @@ -164,7 +158,7 @@ function widgets_content(&$a) {

Copy and paste this code

" - .htmlspecialchars('') ."";