xref: /dokuwiki/lib/plugins/extension/cli.php (revision cc16762d8948ed97ac28eb7ce04c10f2ea668fcd)
1a8d2f3cbSAndreas Gohr<?php
2a8d2f3cbSAndreas Gohr
3a8d2f3cbSAndreas Gohruse splitbrain\phpcli\Colors;
4a8d2f3cbSAndreas Gohr
5a8d2f3cbSAndreas Gohr/**
6a8d2f3cbSAndreas Gohr * Class cli_plugin_extension
7a8d2f3cbSAndreas Gohr *
8a8d2f3cbSAndreas Gohr * Command Line component for the extension manager
9a8d2f3cbSAndreas Gohr *
10a8d2f3cbSAndreas Gohr * @license GPL2
11a8d2f3cbSAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org>
12a8d2f3cbSAndreas Gohr */
13a8d2f3cbSAndreas Gohrclass cli_plugin_extension extends DokuWiki_CLI_Plugin
14a8d2f3cbSAndreas Gohr{
15a8d2f3cbSAndreas Gohr    /** @inheritdoc */
16a8d2f3cbSAndreas Gohr    protected function setup(\splitbrain\phpcli\Options $options)
17a8d2f3cbSAndreas Gohr    {
18a8d2f3cbSAndreas Gohr        // general setup
19b9daa2f5SAndreas Gohr        $options->setHelp(
20b9daa2f5SAndreas Gohr            "Manage plugins and templates for this DokuWiki instance\n\n" .
21b9daa2f5SAndreas Gohr            "Status codes:\n" .
22b9daa2f5SAndreas Gohr            "   i - installed\n" .
23b9daa2f5SAndreas Gohr            "   b - bundled with DokuWiki\n" .
24b9daa2f5SAndreas Gohr            "   g - installed via git\n" .
25b9daa2f5SAndreas Gohr            "   d - disabled\n" .
26b9daa2f5SAndreas Gohr            "   u - update available\n"
27b9daa2f5SAndreas Gohr        );
28a8d2f3cbSAndreas Gohr
29a8d2f3cbSAndreas Gohr        // search
30a8d2f3cbSAndreas Gohr        $options->registerCommand('search', 'Search for an extension');
31a8d2f3cbSAndreas Gohr        $options->registerOption('max', 'Maximum number of results (default 10)', 'm', 'number', 'search');
32a8d2f3cbSAndreas Gohr        $options->registerOption('verbose', 'Show detailed extension information', 'v', false, 'search');
33a8d2f3cbSAndreas Gohr        $options->registerArgument('query', 'The keyword(s) to search for', true, 'search');
34a8d2f3cbSAndreas Gohr
35a8d2f3cbSAndreas Gohr        // list
36a8d2f3cbSAndreas Gohr        $options->registerCommand('list', 'List installed extensions');
37a8d2f3cbSAndreas Gohr        $options->registerOption('verbose', 'Show detailed extension information', 'v', false, 'list');
38b9daa2f5SAndreas Gohr        $options->registerOption('filter', 'Filter by this status', 'f', 'status', 'list');
39a8d2f3cbSAndreas Gohr
40a8d2f3cbSAndreas Gohr        // upgrade
41a8d2f3cbSAndreas Gohr        $options->registerCommand('upgrade', 'Update all installed extensions to their latest versions');
42a8d2f3cbSAndreas Gohr
43a8d2f3cbSAndreas Gohr        // install
44a8d2f3cbSAndreas Gohr        $options->registerCommand('install', 'Install or upgrade extensions');
45a8d2f3cbSAndreas Gohr        $options->registerArgument('extensions...', 'One or more extensions to install', true, 'install');
46a8d2f3cbSAndreas Gohr
47a8d2f3cbSAndreas Gohr        // uninstall
48a8d2f3cbSAndreas Gohr        $options->registerCommand('uninstall', 'Uninstall a new extension');
49a8d2f3cbSAndreas Gohr        $options->registerArgument('extensions...', 'One or more extensions to install', true, 'uninstall');
50a8d2f3cbSAndreas Gohr
51a8d2f3cbSAndreas Gohr        // enable
52a8d2f3cbSAndreas Gohr        $options->registerCommand('enable', 'Enable installed extensions');
53a8d2f3cbSAndreas Gohr        $options->registerArgument('extensions...', 'One or more extensions to enable', true, 'enable');
54a8d2f3cbSAndreas Gohr
55a8d2f3cbSAndreas Gohr        // disable
56a8d2f3cbSAndreas Gohr        $options->registerCommand('disable', 'Disable installed extensions');
57a8d2f3cbSAndreas Gohr        $options->registerArgument('extensions...', 'One or more extensions to disable', true, 'disable');
58a8d2f3cbSAndreas Gohr
59a8d2f3cbSAndreas Gohr
60a8d2f3cbSAndreas Gohr    }
61a8d2f3cbSAndreas Gohr
62a8d2f3cbSAndreas Gohr    /** @inheritdoc */
63a8d2f3cbSAndreas Gohr    protected function main(\splitbrain\phpcli\Options $options)
64a8d2f3cbSAndreas Gohr    {
65ed3520eeSAndreas Gohr        /** @var helper_plugin_extension_repository $repo */
66ed3520eeSAndreas Gohr        $repo = plugin_load('helper', 'extension_repository');
67ed3520eeSAndreas Gohr        if (!$repo->hasAccess(false)) {
68ed3520eeSAndreas Gohr            $this->warning('Extension Repository API is not accessible, no remote info available!');
69ed3520eeSAndreas Gohr        }
70ed3520eeSAndreas Gohr
71a8d2f3cbSAndreas Gohr        switch ($options->getCmd()) {
72a8d2f3cbSAndreas Gohr            case 'list':
73b9daa2f5SAndreas Gohr                $ret = $this->cmdList($options->getOpt('verbose'), $options->getOpt('filter', ''));
74a8d2f3cbSAndreas Gohr                break;
75a8d2f3cbSAndreas Gohr            case 'search':
76a8d2f3cbSAndreas Gohr                $ret = $this->cmdSearch(
77a8d2f3cbSAndreas Gohr                    implode(' ', $options->getArgs()),
78a8d2f3cbSAndreas Gohr                    $options->getOpt('verbose'),
79a8d2f3cbSAndreas Gohr                    (int)$options->getOpt('max', 10)
80a8d2f3cbSAndreas Gohr                );
81a8d2f3cbSAndreas Gohr                break;
82a8d2f3cbSAndreas Gohr            case 'install':
83a8d2f3cbSAndreas Gohr                $ret = $this->cmdInstall($options->getArgs());
84a8d2f3cbSAndreas Gohr                break;
85a8d2f3cbSAndreas Gohr            case 'uninstall':
86a8d2f3cbSAndreas Gohr                $ret = $this->cmdUnInstall($options->getArgs());
87a8d2f3cbSAndreas Gohr                break;
88a8d2f3cbSAndreas Gohr            case 'enable':
89a8d2f3cbSAndreas Gohr                $ret = $this->cmdEnable(true, $options->getArgs());
90a8d2f3cbSAndreas Gohr                break;
91a8d2f3cbSAndreas Gohr            case 'disable':
92a8d2f3cbSAndreas Gohr                $ret = $this->cmdEnable(false, $options->getArgs());
93a8d2f3cbSAndreas Gohr                break;
94a8d2f3cbSAndreas Gohr            case 'upgrade':
95a8d2f3cbSAndreas Gohr                $ret = $this->cmdUpgrade();
96a8d2f3cbSAndreas Gohr                break;
97a8d2f3cbSAndreas Gohr            default:
98a8d2f3cbSAndreas Gohr                echo $options->help();
99a8d2f3cbSAndreas Gohr                $ret = 0;
100a8d2f3cbSAndreas Gohr        }
101a8d2f3cbSAndreas Gohr
102a8d2f3cbSAndreas Gohr        exit($ret);
103a8d2f3cbSAndreas Gohr    }
104a8d2f3cbSAndreas Gohr
105a8d2f3cbSAndreas Gohr    /**
106a8d2f3cbSAndreas Gohr     * Upgrade all extensions
107a8d2f3cbSAndreas Gohr     *
108a8d2f3cbSAndreas Gohr     * @return int
109a8d2f3cbSAndreas Gohr     */
110a8d2f3cbSAndreas Gohr    protected function cmdUpgrade()
111a8d2f3cbSAndreas Gohr    {
112a8d2f3cbSAndreas Gohr        /* @var helper_plugin_extension_extension $ext */
113a8d2f3cbSAndreas Gohr        $ext = $this->loadHelper('extension_extension');
114a8d2f3cbSAndreas Gohr        $list = $this->getInstalledExtensions();
115a8d2f3cbSAndreas Gohr
116a8d2f3cbSAndreas Gohr        $ok = 0;
117a8d2f3cbSAndreas Gohr        foreach ($list as $extname) {
118a8d2f3cbSAndreas Gohr            $ext->setExtension($extname);
119a8d2f3cbSAndreas Gohr            $date = $ext->getInstalledVersion();
120a8d2f3cbSAndreas Gohr            $avail = $ext->getLastUpdate();
121be15e516SAndreas Gohr            if ($avail && $avail > $date && !$ext->isBundled()) {
122a8d2f3cbSAndreas Gohr                $ok += $this->cmdInstall([$extname]);
123a8d2f3cbSAndreas Gohr            }
124a8d2f3cbSAndreas Gohr        }
125a8d2f3cbSAndreas Gohr
126a8d2f3cbSAndreas Gohr        return $ok;
127a8d2f3cbSAndreas Gohr    }
128a8d2f3cbSAndreas Gohr
129a8d2f3cbSAndreas Gohr    /**
130a8d2f3cbSAndreas Gohr     * Enable or disable one or more extensions
131a8d2f3cbSAndreas Gohr     *
132a8d2f3cbSAndreas Gohr     * @param bool $set
133a8d2f3cbSAndreas Gohr     * @param string[] $extensions
134a8d2f3cbSAndreas Gohr     * @return int
135a8d2f3cbSAndreas Gohr     */
136a8d2f3cbSAndreas Gohr    protected function cmdEnable($set, $extensions)
137a8d2f3cbSAndreas Gohr    {
138a8d2f3cbSAndreas Gohr        /* @var helper_plugin_extension_extension $ext */
139a8d2f3cbSAndreas Gohr        $ext = $this->loadHelper('extension_extension');
140a8d2f3cbSAndreas Gohr
141a8d2f3cbSAndreas Gohr        $ok = 0;
142a8d2f3cbSAndreas Gohr        foreach ($extensions as $extname) {
143a8d2f3cbSAndreas Gohr            $ext->setExtension($extname);
144a8d2f3cbSAndreas Gohr            if (!$ext->isInstalled()) {
145a8d2f3cbSAndreas Gohr                $this->error(sprintf('Extension %s is not installed', $ext->getID()));
146a8d2f3cbSAndreas Gohr                $ok += 1;
147a8d2f3cbSAndreas Gohr                continue;
148a8d2f3cbSAndreas Gohr            }
149a8d2f3cbSAndreas Gohr
150a8d2f3cbSAndreas Gohr            if ($set) {
151a8d2f3cbSAndreas Gohr                $status = $ext->enable();
152a8d2f3cbSAndreas Gohr                $msg = 'msg_enabled';
153a8d2f3cbSAndreas Gohr            } else {
154a8d2f3cbSAndreas Gohr                $status = $ext->disable();
155a8d2f3cbSAndreas Gohr                $msg = 'msg_disabled';
156a8d2f3cbSAndreas Gohr            }
157a8d2f3cbSAndreas Gohr
158a8d2f3cbSAndreas Gohr            if ($status !== true) {
159a8d2f3cbSAndreas Gohr                $this->error($status);
160a8d2f3cbSAndreas Gohr                $ok += 1;
161a8d2f3cbSAndreas Gohr                continue;
162a8d2f3cbSAndreas Gohr            } else {
163a8d2f3cbSAndreas Gohr                $this->success(sprintf($this->getLang($msg), $ext->getID()));
164a8d2f3cbSAndreas Gohr            }
165a8d2f3cbSAndreas Gohr        }
166a8d2f3cbSAndreas Gohr
167a8d2f3cbSAndreas Gohr        return $ok;
168a8d2f3cbSAndreas Gohr    }
169a8d2f3cbSAndreas Gohr
170a8d2f3cbSAndreas Gohr    /**
171a8d2f3cbSAndreas Gohr     * Uninstall one or more extensions
172a8d2f3cbSAndreas Gohr     *
173a8d2f3cbSAndreas Gohr     * @param string[] $extensions
174a8d2f3cbSAndreas Gohr     * @return int
175a8d2f3cbSAndreas Gohr     */
176a8d2f3cbSAndreas Gohr    protected function cmdUnInstall($extensions)
177a8d2f3cbSAndreas Gohr    {
178a8d2f3cbSAndreas Gohr        /* @var helper_plugin_extension_extension $ext */
179a8d2f3cbSAndreas Gohr        $ext = $this->loadHelper('extension_extension');
180a8d2f3cbSAndreas Gohr
181a8d2f3cbSAndreas Gohr        $ok = 0;
182a8d2f3cbSAndreas Gohr        foreach ($extensions as $extname) {
183a8d2f3cbSAndreas Gohr            $ext->setExtension($extname);
184a8d2f3cbSAndreas Gohr            if (!$ext->isInstalled()) {
185a8d2f3cbSAndreas Gohr                $this->error(sprintf('Extension %s is not installed', $ext->getID()));
186a8d2f3cbSAndreas Gohr                $ok += 1;
187a8d2f3cbSAndreas Gohr                continue;
188a8d2f3cbSAndreas Gohr            }
189a8d2f3cbSAndreas Gohr
190a8d2f3cbSAndreas Gohr            $status = $ext->uninstall();
191a8d2f3cbSAndreas Gohr            if ($status) {
192a8d2f3cbSAndreas Gohr                $this->success(sprintf($this->getLang('msg_delete_success'), $ext->getID()));
193a8d2f3cbSAndreas Gohr            } else {
194a8d2f3cbSAndreas Gohr                $this->error(sprintf($this->getLang('msg_delete_failed'), hsc($ext->getID())));
195a8d2f3cbSAndreas Gohr                $ok = 1;
196a8d2f3cbSAndreas Gohr            }
197a8d2f3cbSAndreas Gohr        }
198a8d2f3cbSAndreas Gohr
199a8d2f3cbSAndreas Gohr        return $ok;
200a8d2f3cbSAndreas Gohr    }
201a8d2f3cbSAndreas Gohr
202a8d2f3cbSAndreas Gohr    /**
203a8d2f3cbSAndreas Gohr     * Install one or more extensions
204a8d2f3cbSAndreas Gohr     *
205a8d2f3cbSAndreas Gohr     * @param string[] $extensions
206a8d2f3cbSAndreas Gohr     * @return int
207a8d2f3cbSAndreas Gohr     */
208a8d2f3cbSAndreas Gohr    protected function cmdInstall($extensions)
209a8d2f3cbSAndreas Gohr    {
210a8d2f3cbSAndreas Gohr        /* @var helper_plugin_extension_extension $ext */
211a8d2f3cbSAndreas Gohr        $ext = $this->loadHelper('extension_extension');
212a8d2f3cbSAndreas Gohr
213a8d2f3cbSAndreas Gohr        $ok = 0;
214a8d2f3cbSAndreas Gohr        foreach ($extensions as $extname) {
215*cc16762dSLocness            if (preg_match("/^https?:\/\//i", $extname)) {
216*cc16762dSLocness                try {
217*cc16762dSLocness                    $installed = $ext->installFromURL($extname, true);
218*cc16762dSLocness                    foreach ($installed as $name => $info) {
219*cc16762dSLocness                        $this->success(
220*cc16762dSLocness                            sprintf(
221*cc16762dSLocness                                $this->getLang('msg_' . $info['type'] . '_' . $info['action'] . '_success'),
222*cc16762dSLocness                                $info['base']
223*cc16762dSLocness                            )
224*cc16762dSLocness                        );
225*cc16762dSLocness                    }
226*cc16762dSLocness                } catch (Exception $e) {
227*cc16762dSLocness                    $this->error($e->getMessage());
228*cc16762dSLocness                    $ok += 1;
229*cc16762dSLocness                }
230*cc16762dSLocness            } else {
231a8d2f3cbSAndreas Gohr                $ext->setExtension($extname);
232a8d2f3cbSAndreas Gohr
233a8d2f3cbSAndreas Gohr                if (!$ext->getDownloadURL()) {
234a8d2f3cbSAndreas Gohr                    $ok += 1;
235a8d2f3cbSAndreas Gohr                    $this->error(
236a8d2f3cbSAndreas Gohr                        sprintf('Could not find download for %s', $ext->getID())
237a8d2f3cbSAndreas Gohr                    );
238a8d2f3cbSAndreas Gohr                    continue;
239a8d2f3cbSAndreas Gohr                }
240a8d2f3cbSAndreas Gohr
241a8d2f3cbSAndreas Gohr                try {
242a8d2f3cbSAndreas Gohr                    $installed = $ext->installOrUpdate();
243837f79ebSAndreas Gohr                    foreach ($installed as $name => $info) {
244*cc16762dSLocness                        $this->success(
245*cc16762dSLocness                            sprintf(
246a8d2f3cbSAndreas Gohr                                $this->getLang('msg_' . $info['type'] . '_' . $info['action'] . '_success'),
247*cc16762dSLocness                                $info['base']
248*cc16762dSLocness                            )
249a8d2f3cbSAndreas Gohr                        );
250a8d2f3cbSAndreas Gohr                    }
251a8d2f3cbSAndreas Gohr                } catch (Exception $e) {
252a8d2f3cbSAndreas Gohr                    $this->error($e->getMessage());
253a8d2f3cbSAndreas Gohr                    $ok += 1;
254a8d2f3cbSAndreas Gohr                }
255a8d2f3cbSAndreas Gohr            }
256*cc16762dSLocness        }
257a8d2f3cbSAndreas Gohr        return $ok;
258a8d2f3cbSAndreas Gohr    }
259a8d2f3cbSAndreas Gohr
260a8d2f3cbSAndreas Gohr    /**
261a8d2f3cbSAndreas Gohr     * Search for an extension
262a8d2f3cbSAndreas Gohr     *
263a8d2f3cbSAndreas Gohr     * @param string $query
264a8d2f3cbSAndreas Gohr     * @param bool $showdetails
265a8d2f3cbSAndreas Gohr     * @param int $max
266a8d2f3cbSAndreas Gohr     * @return int
267a8d2f3cbSAndreas Gohr     * @throws \splitbrain\phpcli\Exception
268a8d2f3cbSAndreas Gohr     */
269a8d2f3cbSAndreas Gohr    protected function cmdSearch($query, $showdetails, $max)
270a8d2f3cbSAndreas Gohr    {
271a8d2f3cbSAndreas Gohr        /** @var helper_plugin_extension_repository $repository */
272a8d2f3cbSAndreas Gohr        $repository = $this->loadHelper('extension_repository');
273a8d2f3cbSAndreas Gohr        $result = $repository->search($query);
274a8d2f3cbSAndreas Gohr        if ($max) {
275a8d2f3cbSAndreas Gohr            $result = array_slice($result, 0, $max);
276a8d2f3cbSAndreas Gohr        }
277a8d2f3cbSAndreas Gohr
278a8d2f3cbSAndreas Gohr        $this->listExtensions($result, $showdetails);
279a8d2f3cbSAndreas Gohr        return 0;
280a8d2f3cbSAndreas Gohr    }
281a8d2f3cbSAndreas Gohr
282a8d2f3cbSAndreas Gohr    /**
283a8d2f3cbSAndreas Gohr     * @param bool $showdetails
284b9daa2f5SAndreas Gohr     * @param string $filter
285a8d2f3cbSAndreas Gohr     * @return int
286a8d2f3cbSAndreas Gohr     * @throws \splitbrain\phpcli\Exception
287a8d2f3cbSAndreas Gohr     */
288b9daa2f5SAndreas Gohr    protected function cmdList($showdetails, $filter)
289a8d2f3cbSAndreas Gohr    {
290a8d2f3cbSAndreas Gohr        $list = $this->getInstalledExtensions();
291b9daa2f5SAndreas Gohr        $this->listExtensions($list, $showdetails, $filter);
292a8d2f3cbSAndreas Gohr
293a8d2f3cbSAndreas Gohr        return 0;
294a8d2f3cbSAndreas Gohr    }
295a8d2f3cbSAndreas Gohr
296a8d2f3cbSAndreas Gohr    /**
297a8d2f3cbSAndreas Gohr     * Get all installed extensions
298a8d2f3cbSAndreas Gohr     *
299a8d2f3cbSAndreas Gohr     * @return array
300a8d2f3cbSAndreas Gohr     */
301a8d2f3cbSAndreas Gohr    protected function getInstalledExtensions()
302a8d2f3cbSAndreas Gohr    {
303a8d2f3cbSAndreas Gohr        /** @var Doku_Plugin_Controller $plugin_controller */
304a8d2f3cbSAndreas Gohr        global $plugin_controller;
305a8d2f3cbSAndreas Gohr        $pluginlist = $plugin_controller->getList('', true);
306a8d2f3cbSAndreas Gohr        $tpllist = glob(DOKU_INC . 'lib/tpl/*', GLOB_ONLYDIR);
307a8d2f3cbSAndreas Gohr        $tpllist = array_map(function ($path) {
308a8d2f3cbSAndreas Gohr            return 'template:' . basename($path);
309a8d2f3cbSAndreas Gohr        }, $tpllist);
310a8d2f3cbSAndreas Gohr        $list = array_merge($pluginlist, $tpllist);
311a8d2f3cbSAndreas Gohr        sort($list);
312a8d2f3cbSAndreas Gohr        return $list;
313a8d2f3cbSAndreas Gohr    }
314a8d2f3cbSAndreas Gohr
315a8d2f3cbSAndreas Gohr    /**
316a8d2f3cbSAndreas Gohr     * List the given extensions
317a8d2f3cbSAndreas Gohr     *
318a8d2f3cbSAndreas Gohr     * @param string[] $list
319a8d2f3cbSAndreas Gohr     * @param bool $details display details
320b9daa2f5SAndreas Gohr     * @param string $filter filter for this status
321a8d2f3cbSAndreas Gohr     * @throws \splitbrain\phpcli\Exception
322a8d2f3cbSAndreas Gohr     */
323b9daa2f5SAndreas Gohr    protected function listExtensions($list, $details, $filter = '')
324a8d2f3cbSAndreas Gohr    {
325a8d2f3cbSAndreas Gohr        /** @var helper_plugin_extension_extension $ext */
326a8d2f3cbSAndreas Gohr        $ext = $this->loadHelper('extension_extension');
327a8d2f3cbSAndreas Gohr        $tr = new \splitbrain\phpcli\TableFormatter($this->colors);
328a8d2f3cbSAndreas Gohr
329a8d2f3cbSAndreas Gohr
330a8d2f3cbSAndreas Gohr        foreach ($list as $name) {
331a8d2f3cbSAndreas Gohr            $ext->setExtension($name);
332a8d2f3cbSAndreas Gohr
333a8d2f3cbSAndreas Gohr            $status = '';
334a8d2f3cbSAndreas Gohr            if ($ext->isInstalled()) {
335a8d2f3cbSAndreas Gohr                $date = $ext->getInstalledVersion();
336a8d2f3cbSAndreas Gohr                $avail = $ext->getLastUpdate();
337a8d2f3cbSAndreas Gohr                $status = 'i';
338a8d2f3cbSAndreas Gohr                if ($avail && $avail > $date) {
339e5688dc7SAndreas Gohr                    $vcolor = Colors::C_RED;
340b9daa2f5SAndreas Gohr                    $status .= 'u';
341a8d2f3cbSAndreas Gohr                } else {
342e5688dc7SAndreas Gohr                    $vcolor = Colors::C_GREEN;
343a8d2f3cbSAndreas Gohr                }
344a8d2f3cbSAndreas Gohr                if ($ext->isGitControlled()) $status = 'g';
345a8d2f3cbSAndreas Gohr                if ($ext->isBundled()) $status = 'b';
346e5688dc7SAndreas Gohr                if ($ext->isEnabled()) {
347e5688dc7SAndreas Gohr                    $ecolor = Colors::C_BROWN;
348e5688dc7SAndreas Gohr                } else {
349e5688dc7SAndreas Gohr                    $ecolor = Colors::C_DARKGRAY;
350e5688dc7SAndreas Gohr                    $status .= 'd';
351e5688dc7SAndreas Gohr                }
352a8d2f3cbSAndreas Gohr            } else {
353d915fa09SAndreas Gohr                $ecolor = null;
354a8d2f3cbSAndreas Gohr                $date = $ext->getLastUpdate();
355e5688dc7SAndreas Gohr                $vcolor = null;
356a8d2f3cbSAndreas Gohr            }
357a8d2f3cbSAndreas Gohr
358b9daa2f5SAndreas Gohr            if ($filter && strpos($status, $filter) === false) {
359b9daa2f5SAndreas Gohr                continue;
360b9daa2f5SAndreas Gohr            }
361a8d2f3cbSAndreas Gohr
362a8d2f3cbSAndreas Gohr            echo $tr->format(
363a8d2f3cbSAndreas Gohr                [20, 3, 12, '*'],
364a8d2f3cbSAndreas Gohr                [
365a8d2f3cbSAndreas Gohr                    $ext->getID(),
366a8d2f3cbSAndreas Gohr                    $status,
367a8d2f3cbSAndreas Gohr                    $date,
368a8d2f3cbSAndreas Gohr                    strip_tags(sprintf(
369a8d2f3cbSAndreas Gohr                            $this->getLang('extensionby'),
370a8d2f3cbSAndreas Gohr                            $ext->getDisplayName(),
371a8d2f3cbSAndreas Gohr                            $this->colors->wrap($ext->getAuthor(), Colors::C_PURPLE))
372a8d2f3cbSAndreas Gohr                    )
373a8d2f3cbSAndreas Gohr                ],
374a8d2f3cbSAndreas Gohr                [
375e5688dc7SAndreas Gohr                    $ecolor,
376a8d2f3cbSAndreas Gohr                    Colors::C_YELLOW,
377e5688dc7SAndreas Gohr                    $vcolor,
378a8d2f3cbSAndreas Gohr                    null,
379a8d2f3cbSAndreas Gohr                ]
380a8d2f3cbSAndreas Gohr            );
381a8d2f3cbSAndreas Gohr
382a8d2f3cbSAndreas Gohr            if (!$details) continue;
383a8d2f3cbSAndreas Gohr
384a8d2f3cbSAndreas Gohr            echo $tr->format(
385a8d2f3cbSAndreas Gohr                [5, '*'],
386a8d2f3cbSAndreas Gohr                ['', $ext->getDescription()],
387a8d2f3cbSAndreas Gohr                [null, Colors::C_CYAN]
388a8d2f3cbSAndreas Gohr            );
389a8d2f3cbSAndreas Gohr        }
390a8d2f3cbSAndreas Gohr    }
391a8d2f3cbSAndreas Gohr}
392