403Webshell
Server IP : 85.158.181.41  /  Your IP : 216.73.217.12
Web Server : Apache
System : Linux cloud9-vm129 6.1.178+1-ph #ph SMP PREEMPT_DYNAMIC Wed Jul 29 09:00:54 UTC 2026 x86_64
User : moncbefd ( 1024)
PHP Version : 7.3.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/moncbefd/www.moneta.at/GXModules/Gambio/StyleEdit/Core/Components/Theme/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/moncbefd/www.moneta.at/GXModules/Gambio/StyleEdit/Core/Components/Theme//Validator.php
<?php
/*--------------------------------------------------------------------------------------------------
    Validator.php 2019-10-14
    Gambio GmbH
    http://www.gambio.de
    Copyright (c) 2019 Gambio GmbH
    Released under the GNU General Public License (Version 2)
    [http://www.gnu.org/licenses/gpl-2.0.html]
    --------------------------------------------------------------------------------------------------
 */

namespace Gambio\StyleEdit\Core\Components\Theme;

use Exception;
use FileNotFoundException;
use FilesystemAdapter;
use Gambio\StyleEdit\Core\Components\Theme\Json\ThemeInheritanceHandler;
use Gambio\StyleEdit\Core\SingletonPrototype;
use Gambio\StyleEdit\StyleEditConfiguration;
use stdClass;

/**
 * Class Validator
 *
 * Checks if a theme can be opened in StyleEdit4.
 *
 * theme.json
 * * * * *  Must be a valid json
 * * * * *  content must be an object
 * * * * *  content must have an id
 * * * * *  content must have a config object
 * * * * * * * * *  with a basics & areas object
 */
class Validator
{
    /**
     * @var string
     */
    protected $themeName;
    
    /**
     * @var FilesystemAdapter
     */
    protected $filesystemThemes;
    
    /**
     * @var bool
     */
    protected $themeCanBeOpenedInStyleEdit4 = true;
    /**
     * @var StyleEditConfiguration
     */
    protected $styleEditConfiguration;
    
    
    /**
     * @param string                 $themeName
     *
     * @param FilesystemAdapter|null $adapter
     *
     * @return Validator
     * @throws Exception
     */
    public static function for(string $themeName, ?FilesystemAdapter $adapter = null): self
    {
        // the SingletonPrototype can only construct this if the inject method of the dependencyInjector class was executed!
        $filesystemThemes       = $adapter ?? SingletonPrototype::instance()->get(FilesystemAdapter::class);
        $styleEditConfiguration = SingletonPrototype::instance()->get(StyleEditConfiguration::class);
        
        $instance = SingletonPrototype::instance()
            ->get(static::class, $themeName, $filesystemThemes, $styleEditConfiguration);
        
        return $instance;
    }
    
    
    /**
     * Validator constructor.
     *
     * @param string                 $themeName
     * @param FilesystemAdapter      $filesystemThemes
     *
     * @param StyleEditConfiguration $styleEditConfiguration
     *
     * @throws FileNotFoundException
     */
    public function __construct(
        string $themeName,
        FilesystemAdapter $filesystemThemes,
        StyleEditConfiguration $styleEditConfiguration
    ) {
        $this->themeName              = $themeName;
        $this->filesystemThemes       = $filesystemThemes;
        $this->styleEditConfiguration = $styleEditConfiguration;
        
        $this->validateThemeJson();
    }
    
    
    /**
     *
     * @throws FileNotFoundException
     * @throws Exception
     */
    protected function validateThemeJson(): void
    {
        $themeJsonPath = $this->themeName . DIRECTORY_SEPARATOR . 'theme.json';
        
        if (!$this->filesystemThemes->has($themeJsonPath)) {
            
            $this->themeCanBeOpenedInStyleEdit4 = false;
            
            return;
        }
        
        $jsonInheritanceHandler = SingletonPrototype::instance()->get(ThemeInheritanceHandler::class);
        $jsonInheritanceHandler->setFilename($this->styleEditConfiguration->themesFolderPath() . $themeJsonPath);
        $themeJson = $jsonInheritanceHandler->execute();
        
        if (!$themeJson instanceof stdClass
            || !isset($themeJson->id, $themeJson->config, $themeJson->config->basics, $themeJson->config->areas)
            || !$themeJson->config->basics instanceof stdClass
            || !$themeJson->config->areas instanceof stdClass) {
            
            $this->themeCanBeOpenedInStyleEdit4 = false;
        }
    }
    
    
    /**
     * @return bool
     */
    public function canBeOpenedInStyleEdit4(): bool
    {
        return $this->themeCanBeOpenedInStyleEdit4;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit