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