Ejemplo n.º 1
0
 /**
  * Extracts a theme after it has been downloaded.
  */
 public function extractTheme($name, $hash)
 {
     $fileCode = $name . $hash;
     $filePath = $this->getFilePath($fileCode);
     if (!Zip::extract($filePath, $this->baseDirectory . '/themes/')) {
         throw new ApplicationException(Lang::get('system::lang.zip.extract_failed', ['file' => $filePath]));
     }
     $this->themeManager->setInstalled($name);
     @unlink($filePath);
 }
Ejemplo n.º 2
0
 /**
  * Execute the console command.
  * @return void
  */
 public function fire()
 {
     $themeName = $this->argument('name');
     $argDirName = $this->argument('dirName');
     if ($argDirName && $themeName == $argDirName) {
         $argDirName = null;
     }
     if ($argDirName) {
         if (!preg_match('/^[a-z0-9\\_\\-]+$/i', $argDirName)) {
             return $this->error('Invalid destination directory name.');
         }
         if (Theme::exists($argDirName)) {
             return $this->error(sprintf('A theme named %s already exists.', $argDirName));
         }
     }
     try {
         $themeManager = ThemeManager::instance();
         $updateManager = UpdateManager::instance();
         $themeDetails = $updateManager->requestThemeDetails($themeName);
         if ($themeManager->isInstalled($themeDetails['code'])) {
             return $this->error(sprintf('The theme %s is already installed.', $themeDetails['code']));
         }
         if (Theme::exists($themeDetails['code'])) {
             return $this->error(sprintf('A theme named %s already exists.', $themeDetails['code']));
         }
         $fields = ['Name', 'Description', 'Author', 'URL', ''];
         $this->info(sprintf(implode(': %s' . PHP_EOL, $fields), $themeDetails['code'], $themeDetails['description'], $themeDetails['author'], $themeDetails['product_url']));
         if (!$this->confirm('Do you wish to continue? [Y|n]', true)) {
             return;
         }
         $this->info('Downloading theme...');
         $updateManager->downloadTheme($themeDetails['code'], $themeDetails['hash']);
         $this->info('Extracting theme...');
         $updateManager->extractTheme($themeDetails['code'], $themeDetails['hash']);
         $dirName = $this->themeCodeToDir($themeDetails['code']);
         if ($argDirName) {
             /*
              * Move downloaded theme to a new directory.
              * Basically we're renaming it.
              */
             File::move(themes_path() . '/' . $dirName, themes_path() . '/' . $argDirName);
             /*
              * Let's make sure to unflag the 'old' theme as
              * installed so it can be re-installed later.
              */
             $themeManager->setUninstalled($themeDetails['code']);
             $dirName = $argDirName;
         }
         $this->info(sprintf('The theme %s has been installed. (now %s)', $themeDetails['code'], $dirName));
     } catch (Exception $ex) {
         $this->error($ex->getMessage());
     }
 }
Ejemplo n.º 3
0
 /**
  * Initialize this singleton.
  */
 protected function init()
 {
     $this->pluginManager = PluginManager::instance();
     $this->themeManager = ThemeManager::instance();
     $this->versionManager = VersionManager::instance();
     $this->tempDirectory = temp_path();
     $this->baseDirectory = base_path();
     $this->disableCoreUpdates = Config::get('cms.disableCoreUpdates', false);
     $this->bindContainerObjects();
     /*
      * Ensure temp directory exists
      */
     if (!File::isDirectory($this->tempDirectory)) {
         File::makeDirectory($this->tempDirectory, 0777, true);
     }
 }
Ejemplo n.º 4
0
 /**
  * Execute the console command.
  */
 public function fire()
 {
     $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);
     }
     if ($this->option('include-marketplace')) {
         // @todo List everything in the marketplace - not just popular.
         $popularThemes = $updateManager->requestPopularProducts('theme');
         foreach ($popularThemes as $popularTheme) {
             if (!$themeManager->isInstalled($popularTheme['code'])) {
                 $this->info('[ ] ' . $popularTheme['code']);
             }
         }
     }
     $this->info(PHP_EOL . "[*] Active    [-] Installed    [ ] Not installed");
 }
Ejemplo n.º 5
0
 /**
  * Execute the console command.
  * @return void
  */
 public function fire()
 {
     $themeManager = ThemeManager::instance();
     $themeName = $this->argument('name');
     $themeExists = Theme::exists($themeName);
     if (!$themeExists) {
         $themeName = strtolower(str_replace('.', '-', $themeName));
         $themeExists = Theme::exists($themeName);
     }
     if (!$themeExists) {
         return $this->error(sprintf('The theme %s does not exist.', $themeName));
     }
     if (!$this->confirmToProceed(sprintf('This will DELETE theme "%s" from the filesystem and database.', $themeName))) {
         return;
     }
     try {
         $themeManager->deleteTheme($themeName);
         $this->info(sprintf('The theme %s has been deleted.', $themeName));
     } catch (Exception $ex) {
         $this->error($ex->getMessage());
     }
 }
 /**
  * Deletes a single theme from the system.
  * @return void
  */
 public function onRemoveTheme()
 {
     if ($themeCode = post('code')) {
         ThemeManager::instance()->deleteTheme($themeCode);
         Flash::success(trans('cms::lang.theme.delete_theme_success'));
     }
     return Redirect::refresh();
 }
Ejemplo n.º 7
0
 public function index_onDelete()
 {
     ThemeManager::instance()->deleteTheme(post('theme'));
     Flash::success(trans('cms::lang.theme.delete_theme_success'));
     return Redirect::refresh();
 }