Commit 27d2a1b0 authored by Yassine Doghri's avatar Yassine Doghri
Browse files

feat(plugins): activate / deactivate plugin using settings table

+ load plugin icon
+ add pagination
+ autoload plugins in Config/Autoload.php to handle plugin
i18n
+ style plugin cards
parent 587938d2
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ class Autoload extends AutoloadConfig
        'Modules\PremiumPodcasts' => ROOTPATH . 'modules/PremiumPodcasts/',
        'Modules\Update'          => ROOTPATH . 'modules/Update/',
        'Modules\WebSub'          => ROOTPATH . 'modules/WebSub/',
        'Plugins'                 => ROOTPATH . 'plugins',
        'Themes'                  => ROOTPATH . 'themes',
        'ViewComponents'          => APPPATH . 'Libraries/ViewComponents/',
        'ViewThemes'              => APPPATH . 'Libraries/ViewThemes/',
@@ -111,4 +110,20 @@ class Autoload extends AutoloadConfig
     * @var list<string>
     */
    public $helpers = ['auth', 'setting', 'icons'];

    public function __construct()
    {
        // load plugins namespaces
        $pluginsPaths = glob(ROOTPATH . '/plugins/*', GLOB_ONLYDIR);

        if (! $pluginsPaths) {
            $pluginsPaths = [];
        }

        foreach ($pluginsPaths as $pluginPath) {
            $this->psr4[sprintf('Plugins\%s', basename($pluginPath))] = $pluginPath;
        }

        parent::__construct();
    }
}
+7 −2
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ use CodeIgniter\I18n\Time;
use Config\Mimes;
use Modules\Media\Entities\Chapters;
use Modules\Media\Entities\Transcript;
use Modules\Plugins\Plugins;
use Modules\PremiumPodcasts\Entities\Subscription;

if (! function_exists('get_rss_feed')) {
@@ -31,6 +32,7 @@ if (! function_exists('get_rss_feed')) {
        Subscription $subscription = null,
        string $token = null
    ): string {
        /** @var Plugins $plugins */
        $plugins = service('plugins');

        $episodes = $podcast->episodes;
@@ -71,8 +73,6 @@ if (! function_exists('get_rss_feed')) {
        $channel->addChild('generator', 'Castopod - https://castopod.org/');
        $channel->addChild('docs', 'https://cyber.harvard.edu/rss/rss.html');

        $plugins->runHook('setChannelTag', [$podcast, $channel]);

        if ($podcast->guid === '') {
            // FIXME: guid shouldn't be empty here as it should be filled upon Podcast creation
            $uuid = service('uuid');
@@ -297,6 +297,9 @@ if (! function_exists('get_rss_feed')) {
            ], $channel);
        }

        // run plugins hook at the end
        $plugins->setChannelTag($podcast, $channel);

        foreach ($episodes as $episode) {
            if ($episode->is_premium && ! $subscription instanceof Subscription) {
                continue;
@@ -456,6 +459,8 @@ if (! function_exists('get_rss_feed')) {
                    'elements' => $episode->custom_rss,
                ], $item);
            }

            $plugins->setItemTag($episode, $item);
        }

        return $rss->asXML();
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ return [
    'add' => 'add',
    'new' => 'new',
    'edit' => 'edit',
    'plugins' => 'plugins',
    'persons' => 'persons',
    'publish' => 'publish',
    'publish-edit' => 'edit publication',
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ return [
    'podcast-create' => 'New podcast',
    'all-podcast-imports' => 'All Podcast imports',
    'podcast-imports-add' => 'Import a podcast',
    'plugins' => 'Plugins',
    'plugins-installed' => 'Installed',
    'persons' => 'Persons',
    'person-list' => 'All persons',
    'person-create' => 'New person',
+2 −0
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ class AuthGroups extends ShieldAuthGroups
    public array $instanceBasePermissions = [
        'admin.access',
        'admin.settings',
        'plugins.manage',
        'users.manage',
        'persons.manage',
        'pages.manage',
@@ -122,6 +123,7 @@ class AuthGroups extends ShieldAuthGroups
    public array $instanceMatrix = [
        'superadmin' => [
            'admin.*',
            'plugins.*',
            'podcasts.*',
            'users.manage',
            'persons.manage',
Loading