136c0b2b4SAndreas Gohr#!/usr/bin/env php 236c0b2b4SAndreas Gohr<?php 336c0b2b4SAndreas Gohr 436c0b2b4SAndreas Gohruse dokuwiki\Extension\CLIPlugin; 536c0b2b4SAndreas Gohruse dokuwiki\Extension\PluginController; 65586e97bSAndreas Gohruse dokuwiki\plugin\dev\LangProcessor; 7*70316b84SAndreas Gohruse dokuwiki\plugin\dev\Skeletor; 81a23d1dbSAndreas Gohruse dokuwiki\plugin\dev\SVGIcon; 936c0b2b4SAndreas Gohruse splitbrain\phpcli\Exception as CliException; 1036c0b2b4SAndreas Gohruse splitbrain\phpcli\Options; 1136c0b2b4SAndreas Gohr 1236c0b2b4SAndreas Gohr/** 1336c0b2b4SAndreas Gohr * @license GPL2 1436c0b2b4SAndreas Gohr * @author Andreas Gohr <andi@splitbrain.org> 1536c0b2b4SAndreas Gohr */ 1636c0b2b4SAndreas Gohrclass cli_plugin_dev extends CLIPlugin 1736c0b2b4SAndreas Gohr{ 1836c0b2b4SAndreas Gohr /** 1936c0b2b4SAndreas Gohr * Register options and arguments on the given $options object 2036c0b2b4SAndreas Gohr * 2136c0b2b4SAndreas Gohr * @param Options $options 2236c0b2b4SAndreas Gohr * @return void 2336c0b2b4SAndreas Gohr */ 2436c0b2b4SAndreas Gohr protected function setup(Options $options) 2536c0b2b4SAndreas Gohr { 26f2576912SAndreas Gohr $options->useCompactHelp(); 2736c0b2b4SAndreas Gohr $options->setHelp( 28f2576912SAndreas Gohr "CLI to help with DokuWiki plugin and template development.\n\n" . 2936c0b2b4SAndreas Gohr "Run this script from within the extension's directory." 3036c0b2b4SAndreas Gohr ); 3136c0b2b4SAndreas Gohr 32f2576912SAndreas Gohr $options->registerCommand('init', 'Initialize a new plugin or template in the current (empty) directory.'); 33f2576912SAndreas Gohr $options->registerCommand('addTest', 'Add the testing framework files and a test. (_test/)'); 34f2576912SAndreas Gohr $options->registerArgument('test', 'Optional name of the new test. Defaults to the general test.', false, 35f2576912SAndreas Gohr 'addTest'); 36f2576912SAndreas Gohr $options->registerCommand('addConf', 'Add the configuration files. (conf/)'); 37f2576912SAndreas Gohr $options->registerCommand('addLang', 'Add the language files. (lang/)'); 3836c0b2b4SAndreas Gohr 39f2576912SAndreas Gohr $types = PluginController::PLUGIN_TYPES; 40f2576912SAndreas Gohr array_walk( 41f2576912SAndreas Gohr $types, 42f2576912SAndreas Gohr function (&$item) { 43f2576912SAndreas Gohr $item = $this->colors->wrap($item, $this->colors::C_BROWN); 44f2576912SAndreas Gohr } 4536c0b2b4SAndreas Gohr ); 4636c0b2b4SAndreas Gohr 47f2576912SAndreas Gohr $options->registerCommand('addComponent', 'Add a new plugin component.'); 48f2576912SAndreas Gohr $options->registerArgument('type', 'Type of the component. Needs to be one of ' . join(', ', $types), true, 49f2576912SAndreas Gohr 'addComponent'); 50f2576912SAndreas Gohr $options->registerArgument('name', 'Optional name of the component. Defaults to a base component.', false, 51f2576912SAndreas Gohr 'addComponent'); 52f2576912SAndreas Gohr 53f2576912SAndreas Gohr $options->registerCommand('deletedFiles', 'Create the list of deleted files based on the git history.'); 54f2576912SAndreas Gohr $options->registerCommand('rmObsolete', 'Delete obsolete files.'); 551a23d1dbSAndreas Gohr 561a23d1dbSAndreas Gohr $prefixes = array_keys(SVGIcon::SOURCES); 571a23d1dbSAndreas Gohr array_walk( 581a23d1dbSAndreas Gohr $prefixes, 591a23d1dbSAndreas Gohr function (&$item) { 601a23d1dbSAndreas Gohr $item = $this->colors->wrap($item, $this->colors::C_BROWN); 611a23d1dbSAndreas Gohr } 621a23d1dbSAndreas Gohr ); 631a23d1dbSAndreas Gohr 641a23d1dbSAndreas Gohr $options->registerCommand('downloadSvg', 'Download an SVG file from a known icon repository.'); 651a23d1dbSAndreas Gohr $options->registerArgument('prefix:name', 661a23d1dbSAndreas Gohr 'Colon-prefixed name of the icon. Available prefixes: ' . join(', ', $prefixes), true, 'downloadSvg'); 671a23d1dbSAndreas Gohr $options->registerArgument('output', 'File to save, defaults to <name>.svg in current dir', false, 681a23d1dbSAndreas Gohr 'downloadSvg'); 6992738407SAndreas Gohr $options->registerOption('keep-ns', 'Keep the SVG namespace. Use when the file is not inlined into HTML.', 'k', 7092738407SAndreas Gohr false, 'downloadSvg'); 711a23d1dbSAndreas Gohr 728f82d673SAndreas Gohr $options->registerCommand('cleanSvg', 'Clean a existing SVG files to reduce their file size.'); 738f82d673SAndreas Gohr $options->registerArgument('files...', 'The files to clean (will be overwritten)', true, 'cleanSvg'); 7492738407SAndreas Gohr $options->registerOption('keep-ns', 'Keep the SVG namespace. Use when the file is not inlined into HTML.', 'k', 7592738407SAndreas Gohr false, 'cleanSvg'); 765586e97bSAndreas Gohr 775586e97bSAndreas Gohr $options->registerCommand('cleanLang', 785586e97bSAndreas Gohr 'Clean language files from unused language strings. Detecting which strings are truly in use may ' . 795586e97bSAndreas Gohr 'not always correctly work. Use with caution.'); 8036c0b2b4SAndreas Gohr } 8136c0b2b4SAndreas Gohr 8236c0b2b4SAndreas Gohr /** @inheritDoc */ 8336c0b2b4SAndreas Gohr protected function main(Options $options) 8436c0b2b4SAndreas Gohr { 851a23d1dbSAndreas Gohr $args = $options->getArgs(); 861a23d1dbSAndreas Gohr 8736c0b2b4SAndreas Gohr switch ($options->getCmd()) { 8836c0b2b4SAndreas Gohr case 'init': 8936c0b2b4SAndreas Gohr return $this->cmdInit(); 9036c0b2b4SAndreas Gohr case 'addTest': 9136c0b2b4SAndreas Gohr $test = array_shift($args); 9236c0b2b4SAndreas Gohr return $this->cmdAddTest($test); 9336c0b2b4SAndreas Gohr case 'addConf': 9436c0b2b4SAndreas Gohr return $this->cmdAddConf(); 9536c0b2b4SAndreas Gohr case 'addLang': 9636c0b2b4SAndreas Gohr return $this->cmdAddLang(); 9736c0b2b4SAndreas Gohr case 'addComponent': 9836c0b2b4SAndreas Gohr $type = array_shift($args); 9936c0b2b4SAndreas Gohr $component = array_shift($args); 10036c0b2b4SAndreas Gohr return $this->cmdAddComponent($type, $component); 10136c0b2b4SAndreas Gohr case 'deletedFiles': 10236c0b2b4SAndreas Gohr return $this->cmdDeletedFiles(); 103c5c85a97SAndreas Gohr case 'rmObsolete': 1041a23d1dbSAndreas Gohr return $this->cmdRmObsolete(); 1051a23d1dbSAndreas Gohr case 'downloadSvg': 1061a23d1dbSAndreas Gohr $ident = array_shift($args); 1071a23d1dbSAndreas Gohr $save = array_shift($args); 108*70316b84SAndreas Gohr $keep = $options->getOpt('keep-ns'); 10992738407SAndreas Gohr return $this->cmdDownloadSVG($ident, $save, $keep); 1101a23d1dbSAndreas Gohr case 'cleanSvg': 111*70316b84SAndreas Gohr $keep = $options->getOpt('keep-ns'); 1128f82d673SAndreas Gohr return $this->cmdCleanSVG($args, $keep); 1135586e97bSAndreas Gohr case 'cleanLang': 1145586e97bSAndreas Gohr return $this->cmdCleanLang(); 11536c0b2b4SAndreas Gohr default: 1161a23d1dbSAndreas Gohr $this->error('Unknown command'); 11736c0b2b4SAndreas Gohr echo $options->help(); 11836c0b2b4SAndreas Gohr return 0; 11936c0b2b4SAndreas Gohr } 12036c0b2b4SAndreas Gohr } 12136c0b2b4SAndreas Gohr 12236c0b2b4SAndreas Gohr /** 12336c0b2b4SAndreas Gohr * Get the extension name from the current working directory 12436c0b2b4SAndreas Gohr * 12536c0b2b4SAndreas Gohr * @throws CliException if something's wrong 12636c0b2b4SAndreas Gohr * @param string $dir 12736c0b2b4SAndreas Gohr * @return string[] name, type 12836c0b2b4SAndreas Gohr */ 12936c0b2b4SAndreas Gohr protected function getTypedNameFromDir($dir) 13036c0b2b4SAndreas Gohr { 13136c0b2b4SAndreas Gohr $pdir = fullpath(DOKU_PLUGIN); 13236c0b2b4SAndreas Gohr $tdir = fullpath(tpl_incdir() . '../'); 13336c0b2b4SAndreas Gohr 13436c0b2b4SAndreas Gohr if (strpos($dir, $pdir) === 0) { 13536c0b2b4SAndreas Gohr $ldir = substr($dir, strlen($pdir)); 13636c0b2b4SAndreas Gohr $type = 'plugin'; 13736c0b2b4SAndreas Gohr } elseif (strpos($dir, $tdir) === 0) { 13836c0b2b4SAndreas Gohr $ldir = substr($dir, strlen($tdir)); 13936c0b2b4SAndreas Gohr $type = 'template'; 14036c0b2b4SAndreas Gohr } else { 14136c0b2b4SAndreas Gohr throw new CliException('Current directory needs to be in plugin or template directory'); 14236c0b2b4SAndreas Gohr } 14336c0b2b4SAndreas Gohr 14436c0b2b4SAndreas Gohr $ldir = trim($ldir, '/'); 14536c0b2b4SAndreas Gohr 14636c0b2b4SAndreas Gohr if (strpos($ldir, '/') !== false) { 14736c0b2b4SAndreas Gohr throw new CliException('Current directory has to be main extension directory'); 14836c0b2b4SAndreas Gohr } 14936c0b2b4SAndreas Gohr 15036c0b2b4SAndreas Gohr return [$ldir, $type]; 15136c0b2b4SAndreas Gohr } 15236c0b2b4SAndreas Gohr 15336c0b2b4SAndreas Gohr /** 15436c0b2b4SAndreas Gohr * Interactively ask for a value from the user 15536c0b2b4SAndreas Gohr * 15636c0b2b4SAndreas Gohr * @param string $prompt 15736c0b2b4SAndreas Gohr * @param bool $cache cache given value for next time? 15836c0b2b4SAndreas Gohr * @return string 15936c0b2b4SAndreas Gohr */ 16036c0b2b4SAndreas Gohr protected function readLine($prompt, $cache = false) 16136c0b2b4SAndreas Gohr { 16236c0b2b4SAndreas Gohr $value = ''; 16336c0b2b4SAndreas Gohr $default = ''; 16436c0b2b4SAndreas Gohr $cachename = getCacheName($prompt, '.readline'); 16536c0b2b4SAndreas Gohr if ($cache && file_exists($cachename)) { 16636c0b2b4SAndreas Gohr $default = file_get_contents($cachename); 16736c0b2b4SAndreas Gohr } 16836c0b2b4SAndreas Gohr 16936c0b2b4SAndreas Gohr while ($value === '') { 17036c0b2b4SAndreas Gohr echo $prompt; 17136c0b2b4SAndreas Gohr if ($default) echo ' [' . $default . ']'; 17236c0b2b4SAndreas Gohr echo ': '; 17336c0b2b4SAndreas Gohr 17436c0b2b4SAndreas Gohr $fh = fopen('php://stdin', 'r'); 17536c0b2b4SAndreas Gohr $value = trim(fgets($fh)); 17636c0b2b4SAndreas Gohr fclose($fh); 17736c0b2b4SAndreas Gohr 17836c0b2b4SAndreas Gohr if ($value === '') $value = $default; 17936c0b2b4SAndreas Gohr } 18036c0b2b4SAndreas Gohr 18136c0b2b4SAndreas Gohr if ($cache) { 18236c0b2b4SAndreas Gohr file_put_contents($cachename, $value); 18336c0b2b4SAndreas Gohr } 18436c0b2b4SAndreas Gohr 18536c0b2b4SAndreas Gohr return $value; 18636c0b2b4SAndreas Gohr } 18736c0b2b4SAndreas Gohr 18836c0b2b4SAndreas Gohr /** 189*70316b84SAndreas Gohr * Create the given files with their given content 19036c0b2b4SAndreas Gohr * 191*70316b84SAndreas Gohr * Ignores all files that already exist 192*70316b84SAndreas Gohr * 193*70316b84SAndreas Gohr * @param array $files A File array as created by Skeletor::getFiles() 19436c0b2b4SAndreas Gohr */ 195*70316b84SAndreas Gohr protected function createFiles($files) { 196*70316b84SAndreas Gohr foreach ($files as $path => $content) { 197*70316b84SAndreas Gohr if(file_exists($path)) { 198*70316b84SAndreas Gohr $this->error($path . ' already exists'); 199*70316b84SAndreas Gohr continue; 20036c0b2b4SAndreas Gohr } 20136c0b2b4SAndreas Gohr 202*70316b84SAndreas Gohr io_makeFileDir($path); 203*70316b84SAndreas Gohr file_put_contents($path, $content); 204*70316b84SAndreas Gohr $this->success($path . ' created'); 20536c0b2b4SAndreas Gohr } 20636c0b2b4SAndreas Gohr } 20736c0b2b4SAndreas Gohr 20836c0b2b4SAndreas Gohr /** 209c5c85a97SAndreas Gohr * Delete the given file if it exists 210c5c85a97SAndreas Gohr * 211c5c85a97SAndreas Gohr * @param string $file 212c5c85a97SAndreas Gohr */ 213c5c85a97SAndreas Gohr protected function deleteFile($file) 214c5c85a97SAndreas Gohr { 215c5c85a97SAndreas Gohr if (!file_exists($file)) return; 216c5c85a97SAndreas Gohr if (@unlink($file)) { 217c5c85a97SAndreas Gohr $this->success('Delete ' . $file); 218c5c85a97SAndreas Gohr } 219c5c85a97SAndreas Gohr } 220c5c85a97SAndreas Gohr 221c5c85a97SAndreas Gohr /** 222c5c85a97SAndreas Gohr * Run git with the given arguments and return the output 223c5c85a97SAndreas Gohr * 224c5c85a97SAndreas Gohr * @throws CliException when the command can't be run 225c5c85a97SAndreas Gohr * @param string ...$args 226c5c85a97SAndreas Gohr * @return string[] 227c5c85a97SAndreas Gohr */ 228c5c85a97SAndreas Gohr protected function git(...$args) 229c5c85a97SAndreas Gohr { 230c5c85a97SAndreas Gohr $args = array_map('escapeshellarg', $args); 231c5c85a97SAndreas Gohr $cmd = 'git ' . join(' ', $args); 232c5c85a97SAndreas Gohr $output = []; 233c5c85a97SAndreas Gohr $result = 0; 234c5c85a97SAndreas Gohr 235c5c85a97SAndreas Gohr $this->info($cmd); 236c5c85a97SAndreas Gohr $last = exec($cmd, $output, $result); 237c5c85a97SAndreas Gohr if ($last === false || $result !== 0) { 238c5c85a97SAndreas Gohr throw new CliException('Running git failed'); 239c5c85a97SAndreas Gohr } 240c5c85a97SAndreas Gohr 241c5c85a97SAndreas Gohr return $output; 242c5c85a97SAndreas Gohr } 243c5c85a97SAndreas Gohr 244c5c85a97SAndreas Gohr // region Commands 245c5c85a97SAndreas Gohr 246c5c85a97SAndreas Gohr /** 24736c0b2b4SAndreas Gohr * Intialize the current directory as a plugin or template 24836c0b2b4SAndreas Gohr * 24936c0b2b4SAndreas Gohr * @return int 25036c0b2b4SAndreas Gohr */ 25136c0b2b4SAndreas Gohr protected function cmdInit() 25236c0b2b4SAndreas Gohr { 25336c0b2b4SAndreas Gohr $dir = fullpath(getcwd()); 25436c0b2b4SAndreas Gohr if ((new FilesystemIterator($dir))->valid()) { 25536c0b2b4SAndreas Gohr throw new CliException('Current directory needs to be empty'); 25636c0b2b4SAndreas Gohr } 25736c0b2b4SAndreas Gohr 258*70316b84SAndreas Gohr [$base, $type] = $this->getTypedNameFromDir($dir); 25936c0b2b4SAndreas Gohr $user = $this->readLine('Your Name', true); 26036c0b2b4SAndreas Gohr $mail = $this->readLine('Your E-Mail', true); 26136c0b2b4SAndreas Gohr $desc = $this->readLine('Short description'); 26236c0b2b4SAndreas Gohr 263*70316b84SAndreas Gohr $skeletor = new Skeletor($type, $base, $desc, $user, $mail); 264*70316b84SAndreas Gohr $skeletor->addBasics(); 265*70316b84SAndreas Gohr $this->createFiles($skeletor->getFiles()); 26636c0b2b4SAndreas Gohr 2678b06c9ddSAndreas Gohr try { 2688b06c9ddSAndreas Gohr $this->git('init'); 2698b06c9ddSAndreas Gohr } catch (CliException $e) { 2708b06c9ddSAndreas Gohr $this->error($e->getMessage()); 2718b06c9ddSAndreas Gohr } 2728b06c9ddSAndreas Gohr 27336c0b2b4SAndreas Gohr return 0; 27436c0b2b4SAndreas Gohr } 27536c0b2b4SAndreas Gohr 27636c0b2b4SAndreas Gohr /** 27736c0b2b4SAndreas Gohr * Add test framework 27836c0b2b4SAndreas Gohr * 27936c0b2b4SAndreas Gohr * @param string $test Name of the Test to add 28036c0b2b4SAndreas Gohr * @return int 28136c0b2b4SAndreas Gohr */ 28236c0b2b4SAndreas Gohr protected function cmdAddTest($test = '') 28336c0b2b4SAndreas Gohr { 284*70316b84SAndreas Gohr $skeletor = Skeletor::fromDir(getcwd()); 285*70316b84SAndreas Gohr $skeletor->addTest($test); 286*70316b84SAndreas Gohr $this->createFiles($skeletor->getFiles()); 28736c0b2b4SAndreas Gohr return 0; 28836c0b2b4SAndreas Gohr } 28936c0b2b4SAndreas Gohr 29036c0b2b4SAndreas Gohr /** 29136c0b2b4SAndreas Gohr * Add configuration 29236c0b2b4SAndreas Gohr * 29336c0b2b4SAndreas Gohr * @return int 29436c0b2b4SAndreas Gohr */ 29536c0b2b4SAndreas Gohr protected function cmdAddConf() 29636c0b2b4SAndreas Gohr { 297*70316b84SAndreas Gohr $skeletor = Skeletor::fromDir(getcwd()); 298*70316b84SAndreas Gohr $skeletor->addConf(is_dir('lang')); 299*70316b84SAndreas Gohr $this->createFiles($skeletor->getFiles()); 30036c0b2b4SAndreas Gohr return 0; 30136c0b2b4SAndreas Gohr } 30236c0b2b4SAndreas Gohr 30336c0b2b4SAndreas Gohr /** 30436c0b2b4SAndreas Gohr * Add language 30536c0b2b4SAndreas Gohr * 30636c0b2b4SAndreas Gohr * @return int 30736c0b2b4SAndreas Gohr */ 30836c0b2b4SAndreas Gohr protected function cmdAddLang() 30936c0b2b4SAndreas Gohr { 310*70316b84SAndreas Gohr $skeletor = Skeletor::fromDir(getcwd()); 311*70316b84SAndreas Gohr $skeletor->addLang(is_dir('conf')); 312*70316b84SAndreas Gohr $this->createFiles($skeletor->getFiles()); 31336c0b2b4SAndreas Gohr return 0; 31436c0b2b4SAndreas Gohr } 31536c0b2b4SAndreas Gohr 31636c0b2b4SAndreas Gohr /** 31736c0b2b4SAndreas Gohr * Add another component to the plugin 31836c0b2b4SAndreas Gohr * 31936c0b2b4SAndreas Gohr * @param string $type 32036c0b2b4SAndreas Gohr * @param string $component 32136c0b2b4SAndreas Gohr */ 32236c0b2b4SAndreas Gohr protected function cmdAddComponent($type, $component = '') 32336c0b2b4SAndreas Gohr { 324*70316b84SAndreas Gohr $skeletor = Skeletor::fromDir(getcwd()); 325*70316b84SAndreas Gohr $skeletor->addComponent($type, $component); 326*70316b84SAndreas Gohr $this->createFiles($skeletor->getFiles()); 32736c0b2b4SAndreas Gohr return 0; 32836c0b2b4SAndreas Gohr } 32936c0b2b4SAndreas Gohr 33036c0b2b4SAndreas Gohr /** 33136c0b2b4SAndreas Gohr * Generate a list of deleted files from git 33236c0b2b4SAndreas Gohr * 33336c0b2b4SAndreas Gohr * @link https://stackoverflow.com/a/6018049/172068 33436c0b2b4SAndreas Gohr */ 33536c0b2b4SAndreas Gohr protected function cmdDeletedFiles() 33636c0b2b4SAndreas Gohr { 3378b06c9ddSAndreas Gohr if (!is_dir('.git')) throw new CliException('This extension seems not to be managed by git'); 33836c0b2b4SAndreas Gohr 3398b06c9ddSAndreas Gohr $output = $this->git('log', '--no-renames', '--pretty=format:', '--name-only', '--diff-filter=D'); 34036c0b2b4SAndreas Gohr $output = array_map('trim', $output); 34136c0b2b4SAndreas Gohr $output = array_filter($output); 34236c0b2b4SAndreas Gohr $output = array_unique($output); 34336c0b2b4SAndreas Gohr $output = array_filter($output, function ($item) { 34436c0b2b4SAndreas Gohr return !file_exists($item); 34536c0b2b4SAndreas Gohr }); 34636c0b2b4SAndreas Gohr sort($output); 34736c0b2b4SAndreas Gohr 34836c0b2b4SAndreas Gohr if (!count($output)) { 34936c0b2b4SAndreas Gohr $this->info('No deleted files found'); 35036c0b2b4SAndreas Gohr return 0; 35136c0b2b4SAndreas Gohr } 35236c0b2b4SAndreas Gohr 35336c0b2b4SAndreas Gohr $content = "# This is a list of files that were present in previous releases\n" . 35436c0b2b4SAndreas Gohr "# but were removed later. They should not exist in your installation.\n" . 35536c0b2b4SAndreas Gohr join("\n", $output) . "\n"; 35636c0b2b4SAndreas Gohr 35736c0b2b4SAndreas Gohr file_put_contents('deleted.files', $content); 35836c0b2b4SAndreas Gohr $this->success('written deleted.files'); 35936c0b2b4SAndreas Gohr return 0; 36036c0b2b4SAndreas Gohr } 3618b06c9ddSAndreas Gohr 3628b06c9ddSAndreas Gohr /** 363c5c85a97SAndreas Gohr * Remove files that shouldn't be here anymore 3648b06c9ddSAndreas Gohr */ 3651a23d1dbSAndreas Gohr protected function cmdRmObsolete() 3668b06c9ddSAndreas Gohr { 367c5c85a97SAndreas Gohr $this->deleteFile('_test/general.test.php'); 368c5c85a97SAndreas Gohr $this->deleteFile('.travis.yml'); 3698b06c9ddSAndreas Gohr 370c5c85a97SAndreas Gohr return 0; 3718b06c9ddSAndreas Gohr } 3728b06c9ddSAndreas Gohr 3731a23d1dbSAndreas Gohr /** 3741a23d1dbSAndreas Gohr * Download a remote icon 3751a23d1dbSAndreas Gohr * 3761a23d1dbSAndreas Gohr * @param string $ident 3771a23d1dbSAndreas Gohr * @param string $save 37892738407SAndreas Gohr * @param bool $keep 3791a23d1dbSAndreas Gohr * @return int 3801a23d1dbSAndreas Gohr * @throws Exception 3811a23d1dbSAndreas Gohr */ 38292738407SAndreas Gohr protected function cmdDownloadSVG($ident, $save = '', $keep = false) 3831a23d1dbSAndreas Gohr { 3841a23d1dbSAndreas Gohr $svg = new SVGIcon($this); 38592738407SAndreas Gohr $svg->keepNamespace($keep); 3861a23d1dbSAndreas Gohr return (int)$svg->downloadRemoteIcon($ident, $save); 3871a23d1dbSAndreas Gohr } 3881a23d1dbSAndreas Gohr 3891a23d1dbSAndreas Gohr /** 3908f82d673SAndreas Gohr * @param string[] $files 39192738407SAndreas Gohr * @param bool $keep 3921a23d1dbSAndreas Gohr * @return int 3931a23d1dbSAndreas Gohr * @throws Exception 3941a23d1dbSAndreas Gohr */ 3958f82d673SAndreas Gohr protected function cmdCleanSVG($files, $keep = false) 3961a23d1dbSAndreas Gohr { 3971a23d1dbSAndreas Gohr $svg = new SVGIcon($this); 39892738407SAndreas Gohr $svg->keepNamespace($keep); 3998f82d673SAndreas Gohr 4008f82d673SAndreas Gohr $ok = true; 4018f82d673SAndreas Gohr foreach ($files as $file) { 4028f82d673SAndreas Gohr $ok = $ok && $svg->cleanSVGFile($file); 4038f82d673SAndreas Gohr } 4048f82d673SAndreas Gohr return (int)$ok; 4051a23d1dbSAndreas Gohr } 4061a23d1dbSAndreas Gohr 4075586e97bSAndreas Gohr /** 4085586e97bSAndreas Gohr * @return int 4095586e97bSAndreas Gohr */ 4105586e97bSAndreas Gohr protected function cmdCleanLang() 4115586e97bSAndreas Gohr { 4125586e97bSAndreas Gohr $lp = new LangProcessor($this); 4135586e97bSAndreas Gohr 4145586e97bSAndreas Gohr $files = glob('./lang/*/lang.php'); 4155b2e8f12SAndreas Gohr foreach ($files as $file) { 4165b2e8f12SAndreas Gohr $lp->processLangFile($file); 4175b2e8f12SAndreas Gohr } 4185b2e8f12SAndreas Gohr 4195b2e8f12SAndreas Gohr $files = glob('./lang/*/settings.php'); 4205586e97bSAndreas Gohr foreach ($files as $file) { 421f4f76afdSAndreas Gohr $lp->processSettingsFile($file); 4225586e97bSAndreas Gohr } 4235586e97bSAndreas Gohr 4245586e97bSAndreas Gohr return 0; 4255586e97bSAndreas Gohr } 4265586e97bSAndreas Gohr 427c5c85a97SAndreas Gohr //endregion 42836c0b2b4SAndreas Gohr} 429