Load the custom styles as JSON

@throws \common_exception_IsAjaxAction
@throws \common_exception_MissingParameter
977912
public function load() {

        if (!$this->hasRequestParameter('uri')) {
            throw new common_exception_MissingParameter('uri', __METHOD__);
        }
        if (!$this->hasRequestParameter('stylesheetUri')) {
            throw new common_exception_MissingParameter('stylesheetUri', __METHOD__);
        }
        if (!$this->hasRequestParameter('lang')) {
            throw new common_exception_MissingParameter('lang', __METHOD__);
        }
        
        $item = new \core_kernel_classes_Resource($this->getRequestParameter('uri'));
        $lang = $this->getRequestParameter('lang');
        $styleSheet = $this->getRequestParameter('stylesheetUri');
        if (!\tao_helpers_File::securityCheck($styleSheet, true)) {
            throw new \common_exception_Error('invalid stylesheet path "'.$styleSheet.'"');
        }



        $cssArray = CssHelper::loadCssFile($item, $lang, $styleSheet);
        echo json_encode($cssArray);
    }
181286
public RequestContext renderJSON() {
        final JsonRenderer jsonRenderer = new JsonRenderer();
        final JSONObject ret = new JSONObject().put(Keys.STATUS_CODE, false);
        jsonRenderer.setJSONObject(ret);

        this.renderer = jsonRenderer;

        return this;
    }
89696
protected function _loadContentType()
    {
        $this->_loadRawHeaders();

        if(key_exists('Content-Type', $this->_rawHeaders))
            $this->_requestContentType = $this->_rawHeaders['Content-Type'];
    }
162129
public function jsonSerialize() {

    if (!isset($this->componentTextStyles['default'])) {
      $msg = "Document must have at least a \"default\" ComponentTextStyle.";
      $this->triggerError($msg);
      return NULL;
    }

    return parent::jsonSerialize();
  }
491293
protected function loadThemer()
    {
        $app = app();

        $this->styles     = $app->make(Styles::class);
        $this->scripts    = $app->make(Scripts::class);

        if (method_exists($this, 'share')) {
            $this->share([
                 'styles'  => $this->styles,
                 'scripts' => $this->scripts,
                 'images'  => $app->make(Images::class),
             ]);
        }
    }
341387
def as_json(self):
        # type: () -> dict
        """"""
        self._config['applyCss'] = self.applyCss
        self._json['config'] = self._config
        return self._json
987647
public function toJson() {
		$instanceArray['name'] = $this->name;
		$instanceArray['class'] = $this->getClassName();
		$instanceArray['anonymous'] = $this->isAnonymous();
		$instanceArray['type'] = $this->getType();
		
		if ($instanceArray['type'] == self::TYPE_DECLARATIVE) {
			$classDescriptor = $this->getClassDescriptor();
			
			$instanceArray['constructorArguments'] = array();
			foreach ($classDescriptor->getInjectablePropertiesByConstructor() as $propertyName=>$moufProperty) {
				$instanceArray['constructorArguments'][$propertyName] = $this->getConstructorArgumentProperty($propertyName)->toJson();
			}
	
			$instanceArray['properties'] = array();
			foreach ($classDescriptor->getInjectablePropertiesByPublicProperty() as $propertyName=>$moufProperty) {
				$instanceArray['properties'][$propertyName] = $this->getPublicFieldProperty($propertyName)->toJson();
			}
			
			$instanceArray['setters'] = array();
			foreach ($classDescriptor->getInjectablePropertiesBySetter() as $propertyName=>$moufProperty) {
				$instanceArray['setters'][$propertyName] = $this->getSetterProperty($propertyName)->toJson();
			}
			
			// Now, let's search for properties that would be declared in the configuration but that
			// would not exist in the code (this can happen if the property has been renamed in the code)
			$definedPublicProperties = $this->moufManager->getParameterNames($this->name);
			if ($definedPublicProperties) {
				$missingPublicProperties = array_diff($definedPublicProperties, array_keys($instanceArray['properties']));
				foreach ($missingPublicProperties as $missingPublicPropertyName) {
					$instanceArray['properties'][$missingPublicPropertyName] = [
						'warning' => "The public property '".$missingPublicPropertyName."' is declared but does not exist. It is likely it once existed but was renamed or removed.",
						'orphan' => true,
						'type' => null,
						'value' => null,
						'isset' => true,
						'origin' => null,
						'metadata' => null
					];
				}
			}
			
			$definedSetters = $this->moufManager->getParameterNamesForSetter($this->name);
			if ($definedSetters) {
				$missingSetters = array_diff($definedSetters, array_keys($instanceArray['setters']));
				foreach ($missingSetters as $missingSetterName) {
					$instanceArray['setters'][$missingSetterName] = [
					'warning' => "The setter '".$missingSetterName."' is declared but does not exist. It is likely it once existed but was renamed or removed.",
					'orphan' => true,
					'type' => null,
					'value' => null,
					'isset' => true,
					'origin' => null,
					'metadata' => null
					];
				}
			}
				
			$definedConstructorArguments = $this->moufManager->getParameterNamesForConstructor($this->name);
			if ($definedConstructorArguments) {
				$constructor = $classDescriptor->getConstructor();
				if ($constructor) {
					$nbParameters = $classDescriptor->getConstructor()->getNumberOfParameters();
				} else {
					$nbParameters = 0;
				}
				$missingConstructorArguments = array_filter($definedConstructorArguments, function($nb) use ($nbParameters) { return $nbParameters <= $nb; });
				foreach ($missingConstructorArguments as $missingConstructorArgument) {
					$instanceArray['constructorArguments'][$missingConstructorArgument] = [
					'warning' => "The constructor argument n°'".$missingConstructorArgument."' is declared but does not exist. It is likely it once existed but was removed.",
					'orphan' => true,
					'type' => null,
					'value' => null,
					'isset' => true,
					'origin' => null,
					'metadata' => null
					];
				}
			}
			
		} else {
			$instanceArray['code'] = $this->getCode();
		}
		
		return $instanceArray;
	}
1250918
public function jsonSerialize()
    {
        $json = parent::jsonSerialize();
        $json['width'] = $this->getWidth();
        $json['height'] = $this->getHeight();

        return $json;
    }
676581
public function loadCustomizeScript()
    {
        $handle = 'novusopress_customize';
        $url = sprintf('%s/js/customize.js', $this->paths->getBaseAssetsUri());
        $deps = ['jquery', 'customize-preview'];
        $this->loadScript($handle, $url, $deps, true);
    }
1297564
public function renderJson()
    {
        $totalCount = $this->getDatasource()->totalCount();
        $rows = $this->getDatasource()->listRows();

        $tmpData = [];
        foreach ($rows as $row) {
            $tmp = [];

            $this->currentRow = new DefaultRow();
            if ($this->rowCallback instanceof \Closure) {
                $this->rowCallback->call($this, $row);
            }

            foreach ($this->getColumns() as $key => $column) {
                $this->currentColumn = $key;
                $tmp[$column->getName()] = $column->format($row);
            }

            $tmpData[] = $tmp;
        }

        $data = [
            'draw' => $this->getRequest()->get('draw'), // @todo param names configurable
            'recordsTotal' => $totalCount,
            'recordsFiltered' => $totalCount,
            'data' => $tmpData,
        ];

        header('Content-Type: application/json');
        echo json_encode($data);die;
    }
338327
private static function initStyles() {
            if (empty(self::$styles)) {
                foreach (self::$styleColours as $colourCode => $class) {
                    self::$styles[$colourCode] = new $class();

                    foreach (self::$styleVariants as $varCode => $var) {
                        self::$styles[$colourCode . $varCode] = new $class($var);
                    }
                }
            }
        }
1226603
public function renderStylesSettings()
    {
        $this->reloadContent();

        $globalStylesVars = array('pageStylesHead');
        $hooks = array();

        foreach (Finder::findFiles('@*.latte')->in(APP_DIR . '/templates') as $key => $file) {
            $filename = $file->getFileName();

            foreach ($globalStylesVars as $key => $var) {
                if (\WebCMS\Helpers\SystemHelper::checkFileContainsStr(APP_DIR . '/templates/' . $filename, $var)) {
                    $hooks[$filename][$var] = true;
                } else {
                    $hooks[$filename][$var] = false;
                }
            }
        }

        $this->template->stylesHooks = $hooks;
    }
206432
private function LoadFunctionsFromJson()
    {
        $functions_def = Json::Decode(
            file_get_contents(
                $this->definitions_path . "functions.json"
            )
        );

        foreach($functions_def as $header => $namespaces)
        {
            $this->symbols->AddHeader($header);
            
            foreach($namespaces as $namespace => $functions)
            {
                foreach($functions as $function_name => $function_overloads)
                {
                    $function = new Element\FunctionElement($function_name);
                    
                    foreach($function_overloads as $index=>$function_overload)
                    {
                        $overload = new Element\Overload(
                            $function_overload["description"]
                        );
                        
                        $overload->SetReturnType(
                            new Element\ReturnType(
                                $function_overload["return_type"]
                            )
                        );
                        
                        if(isset($function_overload["parameters"]))
                        {
                            foreach($function_overload["parameters"] as $parameter)
                            {
                                if(!isset($parameter["value"]))
                                    $parameter["value"] = "";
                                
                                if(!isset($parameter["description"]))
                                    $parameter["description"] = "";

                                $param = new Element\Parameter(
                                    $parameter["name"], 
                                    $parameter["type"], 
                                    $parameter["value"],
                                    $parameter["description"]
                                );
                                
                                if(!isset($parameter["is_array"]))
                                    $param->is_array = false;
                                else
                                    $param->is_array = $parameter["is_array"];
                                
                                $overload->AddParameter($param);
                            }
                        }
                        
                        $function->AddOverload($overload);
                    }
                    
                    $this->symbols->headers[$header]->AddFunction(
                        $function,
                        $namespace
                    );
                }
            }
        }

        unset($functions_def);
    }
9717
public function loadOutputStyles()
    {
        $styleOne   = array('bold');
        $styleTwo   = array('bold', 'underscore');
        $style      = new OutputFormatterStyle();
        $this->output->getFormatter()->setStyle('normal', $style);
        $style      = new OutputFormatterStyle('white', 'red', $styleOne);
        $this->output->getFormatter()->setStyle('warning', $style);
        $style      = new OutputFormatterStyle('white', 'green', $styleOne);
        $this->output->getFormatter()->setStyle('general', $style);
        $style      = new OutputFormatterStyle('white', 'blue', $styleOne);
        $this->output->getFormatter()->setStyle('notice', $style);
        $style      = new OutputFormatterStyle('white', 'red', $styleTwo);
        $this->output->getFormatter()->setStyle('fatal_error', $style);
    }
1118150
function loadThemeTranslations() {
        // This function is called during theme initialization, and when switching language or theme.
        currentLocale = I18n.locale();
        activeTheme = settingsCache.get('active_theme');

        // Reading file for current locale and active theme and keeping its content in memory
        if (activeTheme) {
            // Reading translation file for theme .hbs templates.
            // Compatibility with both old themes and i18n-capable themes.
            // Preventing missing files.
            try {
                themeStrings = fs.readFileSync(path.join(config.getContentPath('themes'), activeTheme, 'locales', currentLocale + '.json'));
            } catch (err) {
                themeStrings = undefined;
                if (err.code === 'ENOENT') {
                    if (currentLocale !== 'en') {
                        logging.warn(`Theme's file locales/${currentLocale}.json not found.`);
                    }
                } else {
                    throw err;
                }
            }
            if (themeStrings === undefined && currentLocale !== 'en') {
                logging.warn('Falling back to locales/en.json.');
                try {
                    themeStrings = fs.readFileSync(path.join(config.getContentPath('themes'), activeTheme, 'locales', 'en.json'));
                } catch (err) {
                    themeStrings = undefined;
                    if (err.code === 'ENOENT') {
                        logging.warn('Theme\'s file locales/en.json not found.');
                    } else {
                        throw err;
                    }
                }
            }
            if (themeStrings !== undefined) {
                // if translation file is not valid, you will see an error
                try {
                    themeStrings = JSON.parse(themeStrings);
                } catch (err) {
                    themeStrings = undefined;
                    throw err;
                }
            }
        }

        if (themeStrings === undefined) {
            // even if empty, themeStrings must be an object for jp.value
            themeStrings = {};
        }

        _private.initializeIntl();
    }
17109
public function showSettings()
    {
        // Get dependencies
        $settingMapper = ($this->container->dataMapper)('SettingMapper');
        $json = $this->container->json;

        // Fetch settings from database
        $allSettings = $settingMapper->findSiteSettings();

        // Fetch custom settings
        $jsonFilePath = ROOT_DIR . "structure/definitions/customSettings.json";
        if (null === $customSettings = $json->getJson($jsonFilePath, 'setting')) {
            $this->setAlert('danger', 'Custom Settings Error', $json->getErrorMessages());
        } else {
            // Merge saved settings with custom settings
            $allSettings = $this->mergeSettings($allSettings, $customSettings->settings);
        }

        return $this->render('editSettings.html', $allSettings);
    }
137951
public function to_json() {
		parent::to_json();

		$this->json['palette']          = $this->palette;
		$this->json['choices']['alpha'] = ( isset( $this->choices['alpha'] ) && $this->choices['alpha'] ) ? 'true' : 'false';
		$this->json['mode']             = $this->mode;
		$this->json['defaultPalette']   = 			[
			[
				'name'  => esc_attr__( 'Pale Pink', 'kirki' ),
				'slug'  => 'pale-pink',
				'color' => '#f78da7',
			],
			[
				'name'  => esc_attr__( 'Vivid Red', 'kirki' ),
				'slug'  => 'vivid-red',
				'color' => '#cf2e2e',
			],
			[
				'name'  => esc_attr__( 'Luminous Vivid Orange', 'kirki' ),
				'slug'  => 'luminous-vivid-orange',
				'color' => '#ff6900',
			],
			[
				'name'  => esc_attr__( 'Luminous Vivid Amber', 'kirki' ),
				'slug'  => 'luminous-vivid-amber',
				'color' => '#fcb900',
			],
			[
				'name'  => esc_attr__( 'Light Green Cyan', 'kirki' ),
				'slug'  => 'light-green-cyan',
				'color' => '#7bdcb5',
			],
			[
				'name'  => esc_attr__( 'Vivid Green Cyan', 'kirki' ),
				'slug'  => 'vivid-green-cyan',
				'color' => '#00d084',
			],
			[
				'name'  => esc_attr__( 'Pale Cyan Blue', 'kirki' ),
				'slug'  => 'pale-cyan-blue',
				'color' => '#8ed1fc',
			],
			[
				'name'  => esc_html__( 'Vivid Cyan Blue', 'kirki' ),
				'slug'  => 'vivid-cyan-blue',
				'color' => '#0693e3',
			],
			[
				'name'  => esc_attr__( 'White', 'kirki' ),
				'slug'  => 'theme-white',
				'color' => '#fff',
			],
			[
				'name'  => esc_attr__( 'Very Light Gray', 'kirki' ),
				'slug'  => 'very-light-gray',
				'color' => '#eee',
			],
			[
				'name'  => esc_html__( 'Cyan Bluish Gray', 'kirki' ),
				'slug'  => 'cyan-bluish-gray',
				'color' => '#abb8c3',
			],
			[
				'name'  => esc_attr__( 'Blue Gray', 'kirki' ),
				'slug'  => 'blue-gray',
				'color' => '#546E7A',
			],
			[
				'name'  => esc_attr__( 'Very Dark Gray', 'kirki' ),
				'slug'  => 'very-dark-gray',
				'color' => '#313131',
			],
			[
				'name'  => esc_attr__( 'Black', 'kirki' ),
				'slug'  => 'theme-black',
				'color' => '#000',
			],
		];
	}