2019-05-02 06:01:43 +02:00
< ? php
2020-02-09 15:45:36 +01:00
/**
* @ copyright Copyright ( C ) 2020 , Friendica
*
* @ license GNU AGPL version 3 or any later version
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation , either version 3 of the
* License , or ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU Affero General Public License for more details .
*
* You should have received a copy of the GNU Affero General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*
*/
2019-05-02 06:01:43 +02:00
namespace Friendica\Module\Admin\Addons ;
use Friendica\Core\Addon ;
use Friendica\Core\Renderer ;
2019-12-15 22:34:11 +01:00
use Friendica\DI ;
2020-01-23 05:14:14 +01:00
use Friendica\Module\BaseAdmin ;
2019-05-02 06:01:43 +02:00
2020-01-23 05:14:14 +01:00
class Index extends BaseAdmin
2019-05-02 06:01:43 +02:00
{
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' ),
]);
}
}