2019-05-02 06:01:43 +02:00
< ? php
namespace Friendica\Module\Admin\Addons ;
use Friendica\Core\Addon ;
use Friendica\Core\Renderer ;
2019-12-15 22:34:11 +01:00
use Friendica\DI ;
2019-05-02 06:01:43 +02:00
use Friendica\Module\BaseAdminModule ;
class Index extends BaseAdminModule
{
2019-11-05 22:48:54 +01:00
public static function content ( array $parameters = [])
2019-05-02 06:01:43 +02:00
{
2019-11-05 21:22:54 +01:00
parent :: content ( $parameters );
2019-05-02 06:01:43 +02:00
// reload active themes
if ( ! empty ( $_GET [ 'action' ])) {
parent :: checkFormSecurityTokenRedirectOnError ( '/admin/addons' , 'admin_addons' , 't' );
switch ( $_GET [ 'action' ]) {
case 'reload' :
Addon :: reload ();
info ( 'Addons reloaded' );
break ;
case 'toggle' :
2019-10-15 15:20:32 +02:00
$addon = $_GET [ 'addon' ] ? ? '' ;
2019-05-02 06:01:43 +02:00
if ( Addon :: isEnabled ( $addon )) {
Addon :: uninstall ( $addon );
2020-01-18 20:52:34 +01:00
info ( DI :: l10n () -> t ( 'Addon %s disabled.' , $addon ));
2019-05-02 06:01:43 +02:00
} elseif ( Addon :: install ( $addon )) {
2020-01-18 20:52:34 +01:00
info ( DI :: l10n () -> t ( 'Addon %s enabled.' , $addon ));
2019-05-02 06:01:43 +02:00
} else {
2020-01-18 20:52:34 +01:00
info ( DI :: l10n () -> t ( 'Addon %s failed to install.' , $addon ));
2019-05-02 06:01:43 +02:00
}
break ;
}
2019-12-16 00:28:31 +01:00
DI :: baseUrl () -> redirect ( 'admin/addons' );
2019-05-02 06:01:43 +02:00
}
$addons = Addon :: getAvailableList ();
$t = Renderer :: getMarkupTemplate ( 'admin/addons/index.tpl' );
return Renderer :: replaceMacros ( $t , [
2020-01-18 20:52:34 +01:00
'$title' => DI :: l10n () -> t ( 'Administration' ),
'$page' => DI :: l10n () -> t ( 'Addons' ),
'$submit' => DI :: l10n () -> t ( 'Save Settings' ),
'$reload' => DI :: l10n () -> t ( 'Reload active addons' ),
2019-12-16 01:05:15 +01:00
'$baseurl' => DI :: baseUrl () -> get ( true ),
2019-05-02 06:01:43 +02:00
'$function' => 'addons' ,
'$addons' => $addons ,
'$pcount' => count ( $addons ),
2020-01-18 20:52:34 +01:00
'$noplugshint' => DI :: l10n () -> t ( 'There are currently no addons available on your node. You can find the official addon repository at %1$s and might find other interesting addons in the open addon registry at %2$s' , 'https://github.com/friendica/friendica-addons' , 'http://addons.friendi.ca' ),
2019-05-02 06:01:43 +02:00
'$form_security_token' => parent :: getFormSecurityToken ( 'admin_addons' ),
]);
}
}