Move theme to themes directory

@return $this
@throws \Exception
495841
public function moveTheme()
    {
        $this->destinationDir = base_path('themes') . '/' . $this->getAttribute('namespace');

        // remove hidden directories
        File::deleteDirectory($this->tmpDirectory.'/.git');
        File::deleteDirectory($this->tmpDirectory.'/.idea');

        $success = File::copyDirectory($this->tmpDirectory, $this->destinationDir);
        if (!$success) {
            throw new \Exception("Theme could not be moved to " . $this->destinationDir . ". Check you have all permissions needed!");
        }else{
            File::deleteDirectory($this->tmpDirectory);
        }

        return $this;
    }
839597
public function setTheme($theme = 'light')
    {
        if (in_array($theme, self::$themes))
            $this->theme = $theme;
        else
            throw new \Exception('Theme "'.$theme.'"" is not supported. Available themes : '.join(', ', self::$themes));

        return $this;
    }
77025
public function load(string $path): ThemeManager
    {
        $this->setThemeDirectory();
        $this->setThemeConstants();
        $this->loadThemeConfiguration($path);
        $this->setThemeAutoloading();

        return $this;
    }
906507
protected function get_current_theme()
	{
		if ( ! $this->is_logged_in() ) {
			throw new \Exception( "You are not logged in" );
		}

		$this->getSession()->visit( $this->locatePath( $this->get_admin_url() . '/themes.php' ) );
		$page = $this->getSession()->getPage();
		$e = $page->find( 'css', ".theme.active" );
		if ( $e ) {
			$classes = preg_split( "/\s+/", trim( $e->getAttribute( "aria-describedby" ) ) );
			$theme = preg_replace( "/\-(name|action)$/", "", $classes[0] );
			if ( $theme ) {
				return $theme;
			}
		}

		throw new \Exception( "Maybe you don't have permission to get the current theme." );
	}
999090
public function map()
    {
        $themeName = ltrim(
            str_replace(themes_path(), '', realpath(__DIR__.'/../../')),
            '\/'
        );

        Route::middleware('web')
            ->namespace($this->namespace)
            ->group(themes_path($themeName.'/routes.php'));
    }
1165151
public function getThemesFromDir()
	{
		$themeList = array();
		$themePath = Yii::getPathOfAlias('webroot.themes');
		$themes    = scandir($themePath);
		foreach($themes as $theme) {
			$themeName = $this->urlTitle($theme);
			$themeFile = $themePath.'/'.$theme.'/'.$themeName.'.yaml';
			if(file_exists($themeFile)) {
				if(!in_array($themeName, $this->getIgnoreTheme())) {
					$themeList[] = $theme;
				}
			}
		}

		if(count($themeList) > 0)
			return $themeList;
		else
			return false;
	}
230023
public function all()
    {
        $themes = [];

        if ($this->files->exists($path)) {
            $scannedThemes = $this->files->directories($path);
            foreach ($scannedThemes as $theme) {
                $themes[] = basename($theme);
            }
        }
        return new Collection($themes);
    }
780471
public function getAssetDirectory()
    {
        $mergedFileDirectory = StaticContainer::get('path.tmp') . '/assets';

        if (!is_dir($mergedFileDirectory)) {
            Filesystem::mkdir($mergedFileDirectory);
        }

        if (!is_writable($mergedFileDirectory)) {
            throw new Exception("Directory " . $mergedFileDirectory . " has to be writable.");
        }

        return $mergedFileDirectory;
    }
404212
private function getPath()
	{
		$themesPath = $this->themesPath;											//  Basic Themes Path
		if( $this->themeName )														//  Theme Path is set
			$themesPath .= $this->themeName;										//  add Theme Path
		if( $this->cssFolder )														//  CSS Folder is set
			$themesPath .= $this->cssFolder;										//  add CSS Folder
		if( $this->mediumPath )														//  Medium Path is set
			$themesPath .= $this->mediumPath;										//  add Medium Path
		return $themesPath;
	}
427162
protected function _change()
    {
        $disabledThemes = plugin()
            ->filter(function ($theme) {
                return $theme->isTheme && !in_array($theme->name, [option('front_theme'), option('back_theme')]);
            })
            ->toArray();

        if (!count($disabledThemes)) {
            $this->err(__d('installer', '<info>There are no disabled themes!</info>'));
            $this->out();

            return;
        }

        $index = 1;
        $this->out();
        foreach ($disabledThemes as $theme) {
            $disabledThemes[$index] = $theme;
            $this->out(
                __d('installer', '[{0, number, integer}] {1} [{2}]', [
                    $index,
                    $theme->humanName,
                    ($theme->isAdmin ? __d('installer', 'backend') : __d('installer', 'frontend')),
                ])
            );
            $index++;
        }
        $this->out();

        $message = __d('installer', "Which theme would you like to activate?\n[Q]uit");
        while (true) {
            $in = $this->in($message);
            if (strtoupper($in) === 'Q') {
                $this->err(__d('installer', 'Operation aborted'));
                break;
            } elseif (intval($in) < 1 || !isset($disabledThemes[intval($in)])) {
                $this->err(__d('installer', 'Invalid option'));
            } else {
                $task = $this->dispatchShell("Installer.themes change -t {$disabledThemes[$in]->name}");

                if ($task === 0) {
                    $this->out(__d('installer', 'Theme changed!'));
                    Plugin::dropCache();
                } else {
                    $this->err(__d('installer', 'Theme could not be changed.'), 2);
                    $this->out();
                }
                break;
            }
        }

        $this->out();
    }
170396
private function movePath() {
		$source = $this->getSource();
		$destinationPath = $source->getPath();
		$sourcePath = $source->getPath($this->request->from);

		$this->accessControl->checkPermission($this->getUserRole(), $this->action, $destinationPath);
		$this->accessControl->checkPermission($this->getUserRole(), $this->action, $sourcePath);

		if ($sourcePath) {
			if ($destinationPath) {
				if (is_file($sourcePath) or is_dir($sourcePath)) {
					rename($sourcePath, $destinationPath . basename($sourcePath));
				} else {
					throw new \Exception('Not file', Consts::ERROR_CODE_NOT_EXISTS);
				}
			} else {
				throw new \Exception('Need destination path', Consts::ERROR_CODE_BAD_REQUEST);
			}
		} else {
			throw new \Exception('Need source path', Consts::ERROR_CODE_BAD_REQUEST);
		}
	}
608868
def install_theme(path_to_theme):
    
    pref_init()
    # cp the file
    filename = basename(path_to_theme)
    dest = join(THEMES_DIR, filename)
    copy(path_to_theme, dest)
    # unzip
    zf = zipfile.ZipFile(dest)
    # should make sure zipfile contains only themename folder which doesn't conflict
    # with existing themename. Or some kind of sanity check
    zf.extractall(THEMES_DIR)  # plus this is a potential security flaw pre 2.7.4
    # remove the copied zipfile
    unlink(dest)
761603
public function addAutomaticTheme()
    {
        $nbTheme = 0;
        $theme = new ThemeEntity();

        $directoryThemes = $theme->getBasePath();

        $nbTheme = $this->checkAssets($directoryThemes, $nbTheme);

        return $nbTheme;
    }
44122
public function theme()
    {
        $keys = [
            'Theme_id'
        ];

        /** @var ThemeSettingsTable $ThemeSettings */
        $ThemeSettings = $this->loadModel('Wasabi/Cms.ThemeSettings');

        $settings = $ThemeSettings->getKeyValues(new GeneralSetting(), $keys);

        if ($this->request->is('post') && !empty($this->request->data)) {
            $settings = $ThemeSettings->newEntity($this->request->data);
            if (!$settings->errors()) {
                if ($ThemeSettings->saveKeyValues($settings, $keys)) {
                    $this->Flash->success(__d('wasabi_cms', 'The theme settings have been updated.'));
                    $this->redirect(['action' => 'theme']);
                    return;
                } else {
                    $this->Flash->error($this->dbErrorMessage);
                }
            } else {
                $this->Flash->error($this->formErrorMessage);
            }
        }
        $this->set([
            'settings' => $settings,
            'themes' => ThemeManager::getThemesForSelect()
        ]);
    }
722978
protected function initialize()
    {
        $themeConfig = $this->config->get('theme', 'api');

        if (!$themeConfig) {
            throw new ConfigException('Theme configuration is not present');
        }

        $themeDir = $this->findThemeDirectory($themeConfig, $this->options['path']);

        if (!file_exists($themeDir)) {
            throw new ConfigException('There is no theme named '.$themeConfig['name']);
        }

        $outputDir = $this->findOutputDirectory($this->options['output']);

        if (!$outputDir) {
            throw new ConfigException('Api path (output directory) is not configured');
        }

        $this->outputDirectory = $outputDir;

        if (!file_exists($outputDir)) {
            if (!mkdir($outputDir, 0777, true)) {
                throw new Exception("Can't write output directory $outputDir");
            }
        }

        if (!is_writable($outputDir)) {
            throw new Exception("Can't write output directory $outputDir");
        }

        $themeConfig['options'] = $this->prepareThemeOptions($themeConfig, $this->options['options']);

        $this->theme = new Theme($themeDir, $outputDir, $themeConfig, $this->config, $this);

        $this->baseUrl = $this->options['url'];
    }
341344
public function setAsCurrentOrganization()
    {
        $organizationId = $this->getId();

        if ($organizationId && (! \Gems_Cookies::setOrganization($organizationId, $this->basepath->getBasePath()))) {
            throw new \Exception('Cookies must be enabled for this site.');
        }

        $escort = \GemsEscort::getInstance();
        if ($escort instanceof \Gems_Project_Layout_MultiLayoutInterface) {
            $escort->layoutSwitch($this->getStyle());
        }

        return $this;
    }
1317598
public function moveAction()
    {
        $id = $this->params('id');
        $repositories = $this->repositories;
        $application = $repositories->get('Applications/Application')->find($id);
        
        if (!$application) {
            throw new \DomainException('Application not found.');
        }

        $this->acl($application, 'move');
        
        $user = $this->auth()->getUser();
        $cv = $repositories->get('Cv/Cv')->createFromApplication($application, $user);
        
        $repositories->store($cv);
        $repositories->remove($application);

        $this->notification()->success(
            /*@translate*/ 'Application has been successfully moved to Talent Pool'
        );
        
        return $this->redirect()->toRoute('lang/applications', array(), true);
    }