2015-04-25 03:57:40 +02:00
|
|
|
<?php namespace System\Console;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
|
|
use Cms\Classes\Theme;
|
|
|
|
use Cms\Classes\ThemeManager;
|
|
|
|
use System\Classes\UpdateManager;
|
|
|
|
|
2017-03-16 17:08:20 +11:00
|
|
|
/**
|
|
|
|
* Console command to list themes.
|
|
|
|
*
|
|
|
|
* This lists all the available themes in the system. It also shows the active theme.
|
|
|
|
*
|
|
|
|
* @package october\system
|
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
*/
|
2015-04-25 03:57:40 +02:00
|
|
|
class ThemeList extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The console command name.
|
|
|
|
*/
|
|
|
|
protected $name = 'theme:list';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*/
|
|
|
|
protected $description = 'List available themes.';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*/
|
2017-07-14 16:28:47 +10:00
|
|
|
public function handle()
|
2015-04-25 03:57:40 +02:00
|
|
|
{
|
2015-05-02 12:29:22 +10:00
|
|
|
$themeManager = ThemeManager::instance();
|
|
|
|
$updateManager = UpdateManager::instance();
|
|
|
|
|
|
|
|
foreach (Theme::all() as $theme) {
|
|
|
|
$flag = $theme->isActiveTheme() ? '[*] ' : '[-] ';
|
|
|
|
$themeId = $theme->getId();
|
|
|
|
$themeName = $themeManager->findByDirName($themeId) ?: $themeId;
|
|
|
|
$this->info($flag . $themeName);
|
2015-04-25 03:57:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->option('include-marketplace')) {
|
|
|
|
// @todo List everything in the marketplace - not just popular.
|
|
|
|
|
2015-05-02 12:29:22 +10:00
|
|
|
$popularThemes = $updateManager->requestPopularProducts('theme');
|
2015-04-25 03:57:40 +02:00
|
|
|
|
2015-05-02 12:29:22 +10:00
|
|
|
foreach ($popularThemes as $popularTheme) {
|
|
|
|
if (!$themeManager->isInstalled($popularTheme['code'])) {
|
|
|
|
$this->info('[ ] '.$popularTheme['code']);
|
2015-04-25 03:57:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-02 12:29:22 +10:00
|
|
|
$this->info(PHP_EOL."[*] Active [-] Installed [ ] Not installed");
|
2015-04-25 03:57:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the console command options.
|
|
|
|
*/
|
|
|
|
protected function getOptions()
|
|
|
|
{
|
|
|
|
return [
|
2015-04-26 20:16:38 +02:00
|
|
|
['include-marketplace', 'm', InputOption::VALUE_NONE, 'Include downloadable themes from the October marketplace.']
|
2015-04-25 03:57:40 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|