} elseif ($allowOverwrite || !isset($data[$key])) {
// Spec: Keys MUST be unique; first one wins.
// But overwriting is allowed when a merge node is used in current block.
if (null !== $subTag) {
$data[$key] = new TaggedValue($subTag, $value);
} else {
$data[$key] = $value;
}
} else {
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), $realCurrentLineNbKey + 1, $this->currentLine);
}
}
} else {
$value = $this->parseValue(rtrim($values['value']), $flags, $context);
// Spec: Keys MUST be unique; first one wins.
// But overwriting is allowed when a merge node is used in current block.
if ($allowOverwrite || !isset($data[$key])) {
$data[$key] = $value;
} else {
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), $this->getRealCurrentLineNb() + 1, $this->currentLine);
}
}
if ($isRef) {
$this->refs[$isRef] = $data[$key];
array_pop($this->refsBeingParsed);
}
} elseif ('"' === $this->currentLine[0] || "'" === $this->currentLine[0]) {
if (null !== $context) {
throw new ParseException('Unable to parse.', $this->getRealCurrentLineNb() + 1, $this->currentLine, $this->filename);
}
try {
return Inline::parse($this->lexInlineQuotedString(), $flags, $this->refs);
} catch (ParseException $e) {
$e->setParsedLine($this->getRealCurrentLineNb() + 1);
$e->setSnippet($this->currentLine);
throw $e;
}
} elseif ('{' === $this->currentLine[0]) {
Arguments
"Duplicate key "type" detected at line 23 (near "type: Repeaat Track")."
private function parseBlock(int $offset, string $yaml, int $flags)
{
$skippedLineNumbers = $this->skippedLineNumbers;
foreach ($this->locallySkippedLineNumbers as $lineNumber) {
if ($lineNumber < $offset) {
continue;
}
$skippedLineNumbers[] = $lineNumber;
}
$parser = new self();
$parser->offset = $offset;
$parser->totalNumberOfLines = $this->totalNumberOfLines;
$parser->skippedLineNumbers = $skippedLineNumbers;
$parser->refs = &$this->refs;
$parser->refsBeingParsed = $this->refsBeingParsed;
return $parser->doParse($yaml, $flags);
}
/**
* Returns the current line number (takes the offset into account).
*
* @internal
*/
public function getRealCurrentLineNb(): int
{
$realCurrentLineNumber = $this->currentLineNb + $this->offset;
foreach ($this->skippedLineNumbers as $skippedLineNumber) {
if ($skippedLineNumber > $realCurrentLineNumber) {
break;
}
++$realCurrentLineNumber;
}
return $realCurrentLineNumber;
} elseif (null !== $subTag = $this->getLineTag(ltrim($values['value'], ' '), $flags)) {
$data[] = new TaggedValue(
$subTag,
$this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(null, true), $flags)
);
} else {
if (
isset($values['leadspaces'])
&& (
'!' === $values['value'][0]
|| self::preg_match('#^(?P<key>'.Inline::REGEX_QUOTED_STRING.'|[^ \'"\{\[].*?) *\:(\s+(?P<value>.+?))?\s*$#u', $this->trimTag($values['value']), $matches)
)
) {
// this is a compact notation element, add to next block and parse
$block = $values['value'];
if ($this->isNextLineIndented()) {
$block .= "\n".$this->getNextEmbedBlock($this->getCurrentLineIndentation() + \strlen($values['leadspaces']) + 1);
}
$data[] = $this->parseBlock($this->getRealCurrentLineNb(), $block, $flags);
} else {
$data[] = $this->parseValue($values['value'], $flags, $context);
}
}
if ($isRef) {
$this->refs[$isRef] = end($data);
array_pop($this->refsBeingParsed);
}
} elseif (
self::preg_match('#^(?P<key>(?:![^\s]++\s++)?(?:'.Inline::REGEX_QUOTED_STRING.'|(?:!?!php/const:)?[^ \'"\[\{!].*?)) *\:(( |\t)++(?P<value>.+))?$#u', rtrim($this->currentLine), $values)
&& (false === strpos($values['key'], ' #') || \in_array($values['key'][0], ['"', "'"]))
) {
if ($context && 'sequence' == $context) {
throw new ParseException('You cannot define a mapping item when in a sequence.', $this->currentLineNb + 1, $this->currentLine, $this->filename);
}
$context = 'mapping';
try {
$key = Inline::parseScalar($values['key']);
} catch (ParseException $e) {
private function parseBlock(int $offset, string $yaml, int $flags)
{
$skippedLineNumbers = $this->skippedLineNumbers;
foreach ($this->locallySkippedLineNumbers as $lineNumber) {
if ($lineNumber < $offset) {
continue;
}
$skippedLineNumbers[] = $lineNumber;
}
$parser = new self();
$parser->offset = $offset;
$parser->totalNumberOfLines = $this->totalNumberOfLines;
$parser->skippedLineNumbers = $skippedLineNumbers;
$parser->refs = &$this->refs;
$parser->refsBeingParsed = $this->refsBeingParsed;
return $parser->doParse($yaml, $flags);
}
/**
* Returns the current line number (takes the offset into account).
*
* @internal
*/
public function getRealCurrentLineNb(): int
{
$realCurrentLineNumber = $this->currentLineNb + $this->offset;
foreach ($this->skippedLineNumbers as $skippedLineNumber) {
if ($skippedLineNumber > $realCurrentLineNumber) {
break;
}
++$realCurrentLineNumber;
}
return $realCurrentLineNumber;
// Merge keys
} elseif (!isset($values['value']) || '' === $values['value'] || 0 === strpos($values['value'], '#') || (null !== $subTag = $this->getLineTag($values['value'], $flags)) || '<<' === $key) {
// hash
// if next line is less indented or equal, then it means that the current value is null
if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) {
// Spec: Keys MUST be unique; first one wins.
// But overwriting is allowed when a merge node is used in current block.
if ($allowOverwrite || !isset($data[$key])) {
if (null !== $subTag) {
$data[$key] = new TaggedValue($subTag, '');
} else {
$data[$key] = null;
}
} else {
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), $this->getRealCurrentLineNb() + 1, $this->currentLine);
}
} else {
// remember the parsed line number here in case we need it to provide some contexts in error messages below
$realCurrentLineNbKey = $this->getRealCurrentLineNb();
$value = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(), $flags);
if ('<<' === $key) {
$this->refs[$refMatches['ref']] = $value;
if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $value instanceof \stdClass) {
$value = (array) $value;
}
$data += $value;
} elseif ($allowOverwrite || !isset($data[$key])) {
// Spec: Keys MUST be unique; first one wins.
// But overwriting is allowed when a merge node is used in current block.
if (null !== $subTag) {
$data[$key] = new TaggedValue($subTag, $value);
} else {
$data[$key] = $value;
}
} else {
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), $realCurrentLineNbKey + 1, $this->currentLine);
}
}
private function parseBlock(int $offset, string $yaml, int $flags)
{
$skippedLineNumbers = $this->skippedLineNumbers;
foreach ($this->locallySkippedLineNumbers as $lineNumber) {
if ($lineNumber < $offset) {
continue;
}
$skippedLineNumbers[] = $lineNumber;
}
$parser = new self();
$parser->offset = $offset;
$parser->totalNumberOfLines = $this->totalNumberOfLines;
$parser->skippedLineNumbers = $skippedLineNumbers;
$parser->refs = &$this->refs;
$parser->refsBeingParsed = $this->refsBeingParsed;
return $parser->doParse($yaml, $flags);
}
/**
* Returns the current line number (takes the offset into account).
*
* @internal
*/
public function getRealCurrentLineNb(): int
{
$realCurrentLineNumber = $this->currentLineNb + $this->offset;
foreach ($this->skippedLineNumbers as $skippedLineNumber) {
if ($skippedLineNumber > $realCurrentLineNumber) {
break;
}
++$realCurrentLineNumber;
}
return $realCurrentLineNumber;
// Merge keys
} elseif (!isset($values['value']) || '' === $values['value'] || 0 === strpos($values['value'], '#') || (null !== $subTag = $this->getLineTag($values['value'], $flags)) || '<<' === $key) {
// hash
// if next line is less indented or equal, then it means that the current value is null
if (!$this->isNextLineIndented() && !$this->isNextLineUnIndentedCollection()) {
// Spec: Keys MUST be unique; first one wins.
// But overwriting is allowed when a merge node is used in current block.
if ($allowOverwrite || !isset($data[$key])) {
if (null !== $subTag) {
$data[$key] = new TaggedValue($subTag, '');
} else {
$data[$key] = null;
}
} else {
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), $this->getRealCurrentLineNb() + 1, $this->currentLine);
}
} else {
// remember the parsed line number here in case we need it to provide some contexts in error messages below
$realCurrentLineNbKey = $this->getRealCurrentLineNb();
$value = $this->parseBlock($this->getRealCurrentLineNb() + 1, $this->getNextEmbedBlock(), $flags);
if ('<<' === $key) {
$this->refs[$refMatches['ref']] = $value;
if (Yaml::PARSE_OBJECT_FOR_MAP & $flags && $value instanceof \stdClass) {
$value = (array) $value;
}
$data += $value;
} elseif ($allowOverwrite || !isset($data[$key])) {
// Spec: Keys MUST be unique; first one wins.
// But overwriting is allowed when a merge node is used in current block.
if (null !== $subTag) {
$data[$key] = new TaggedValue($subTag, $value);
} else {
$data[$key] = $value;
}
} else {
throw new ParseException(sprintf('Duplicate key "%s" detected.', $key), $realCurrentLineNbKey + 1, $this->currentLine);
}
}
*
* @throws ParseException If the YAML is not valid
*/
public function parse(string $value, int $flags = 0)
{
if (false === preg_match('//u', $value)) {
throw new ParseException('The YAML value does not appear to be valid UTF-8.', -1, null, $this->filename);
}
$this->refs = [];
$mbEncoding = null;
if (2 /* MB_OVERLOAD_STRING */ & (int) \ini_get('mbstring.func_overload')) {
$mbEncoding = mb_internal_encoding();
mb_internal_encoding('UTF-8');
}
try {
$data = $this->doParse($value, $flags);
} finally {
if (null !== $mbEncoding) {
mb_internal_encoding($mbEncoding);
}
$this->refsBeingParsed = [];
$this->offset = 0;
$this->lines = [];
$this->currentLine = '';
$this->numberOfParsedLines = 0;
$this->refs = [];
$this->skippedLineNumbers = [];
$this->locallySkippedLineNumbers = [];
$this->totalNumberOfLines = null;
}
return $data;
}
private function doParse(string $value, int $flags)
{
* Parses YAML into a PHP value.
*
* Usage:
* <code>
* $array = Yaml::parse(file_get_contents('config.yml'));
* print_r($array);
* </code>
*
* @param string $input A string containing YAML
* @param int $flags A bit field of PARSE_* constants to customize the YAML parser behavior
*
* @return mixed
*
* @throws ParseException If the YAML is not valid
*/
public static function parse(string $input, int $flags = 0)
{
$yaml = new Parser();
return $yaml->parse($input, $flags);
}
/**
* Dumps a PHP value to a YAML string.
*
* The dump method, when supplied with an array, will do its best
* to convert the array into friendly YAML.
*
* @param mixed $input The PHP value
* @param int $inline The level where you switch to inline YAML
* @param int $indent The amount of spaces to use for indentation of nested nodes
* @param int $flags A bit field of DUMP_* constants to customize the dumped YAML string
*/
public static function dump($input, int $inline = 2, int $indent = 4, int $flags = 0): string
{
$yaml = new Dumper($indent);
return $yaml->dump($input, $inline, 0, $flags);
}
}
class YamlConfigLoader extends FileLoader
{
/**
* Load all YML configuration files.
*
* @param mixed $resource
* @param null $type
*
* @return array
*/
public function load($resource, $type = null)
{
$files = $this->getLocator()->locate($resource, null, false);
$elements = [];
foreach ($files as $file) {
# Parse YML file.
$config = Yaml::parse(file_get_contents($file));
$elements[$file] = $config;
}
return $elements;
}
/**
* Determines the configuration file is YML or not.
*
* @param mixed $resource
* @param null $type
*
* @return bool
*/
public function supports($resource, $type = null)
{
return is_string($resource) && 'yml' === pathinfo(
$resource,
PATHINFO_EXTENSION
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class DelegatingLoader extends Loader
{
public function __construct(LoaderResolverInterface $resolver)
{
$this->resolver = $resolver;
}
/**
* {@inheritdoc}
*/
public function load($resource, $type = null)
{
if (false === $loader = $this->resolver->resolve($resource, $type)) {
throw new FileLoaderLoadException($resource, null, null, null, $type);
}
return $loader->load($resource, $type);
}
/**
* {@inheritdoc}
*/
public function supports($resource, $type = null)
{
return false !== $this->resolver->resolve($resource, $type);
}
}
* @throws \Symfony\Component\Config\Exception\FileLoaderLoadException
*/
public function load()
{
$elements = [];
// load configuration that has PHP extension.
try {
$configs = $this->loader->load('config.php', 'php');
$elements = array_merge($elements, $configs);
} catch (ConfigFileIsNotAnArray $e) {
xception($e->getMessage());
} catch (InvalidArgumentException $e) {
//xception( $e->getMessage(), 0);
}
// load configuration that has YML extension.
try {
$configs = $this->loader->load('config.yml', 'yml');
$elements = array_merge($elements, $configs);
} catch (ConfigFileIsNotAnArray $e) {
xception($e->getMessage());
} catch (InvalidArgumentException $e) {
//xception( $e->getMessage(), 0);
}
$elements = $this->transform($elements);
return $elements;
}
/**
* Get all directories of the given path.
*
* @param $path
*
* @return array
*/
protected function directories($path)
public function getConfigs()
{
$configs = $this->finalTransformer->transform($this->configs);
return $configs;
}
/**
* Load elements.
*
* @param $path
* @param $url
*
* @return array
*/
protected function load($path, $url)
{
$loader = new Loader($path, $url);
return $loader->load();
}
/**
* Validating the configuration file.
*
* @param $configs
*
* @return mixed
*/
protected function validate($configs)
{
$configs = array_reduce($configs, function ($carry, $config) {
$this->validator->validate($config, $config['file']);
return $carry;
}, []);
return $configs;
}
$this->finalTransformer = $finalTransformer;
}
/**
* Fill up the configuration array.
*
* @param $path
* @param $url
* @param $groups
*
* @return $this
* @throws DirectoryNotFoundException
*/
public function fill($path, $url, $groups)
{
if (!is_dir($path)) {
throw new DirectoryNotFoundException("directory `{$path}` was not found in filesystem");
}
$configs = $this->load($path, $url);
$this->validate($configs);
$configs = $this->transform($configs, $path);
$configs = $this->setGroups($configs, $groups);
$this->configs = array_merge($this->configs, $configs);
return $this;
}
/**
* Get configuration.
*
* @return array
*/
public function getConfigs()
{
$configs = $this->finalTransformer->transform($this->configs);
{
foreach ($this->pathBags as $bag) {
call_user_func_array([$this, 'add'], $bag);
}
return $this;
}
/**
* Adding bag to the config bag.
*
* @param $path
* @param $url
* @param array $group
*
* @return $this
*/
public function add($path, $url, $group = [])
{
try {
$this->configBag->fill($path, $url, $group);
} catch (DirectoryNotFoundException $e) {
xception($e->getMessage());
}
return $this;
}
/**
* Get config bag instance.
*
* @return ConfigBag
*/
public function getConfigBag()
{
return $this->configBag;
}
}
* @param $path
* @param $url
* @param array $groups
*/
public function fill($path, $url, $groups = [], $builder = '')
{
if(!$builder && $this->builder == 'frontend') return;
$this->pathBags[] = compact("path", "url", "groups");
}
/**
* Adding all path bags to the config bag.
*
* @return $this
*/
public function load()
{
foreach ($this->pathBags as $bag) {
call_user_func_array([$this, 'add'], $bag);
}
return $this;
}
/**
* Adding bag to the config bag.
*
* @param $path
* @param $url
* @param array $group
*
* @return $this
*/
public function add($path, $url, $group = [])
{
try {
$this->configBag->fill($path, $url, $group);
} catch (DirectoryNotFoundException $e) {
xception($e->getMessage());
}
* @param $path
* @param $url
* @param array $groups
*/
public function fill($path, $url, $groups = [], $builder = '')
{
if(!$builder && $this->builder == 'frontend') return;
$this->pathBags[] = compact("path", "url", "groups");
}
/**
* Adding all path bags to the config bag.
*
* @return $this
*/
public function load()
{
foreach ($this->pathBags as $bag) {
call_user_func_array([$this, 'add'], $bag);
}
return $this;
}
/**
* Adding bag to the config bag.
*
* @param $path
* @param $url
* @param array $group
*
* @return $this
*/
public function add($path, $url, $group = [])
{
try {
$this->configBag->fill($path, $url, $group);
} catch (DirectoryNotFoundException $e) {
xception($e->getMessage());
}
* @return mixed
*/
public function getNodes()
{
return $this->cache->fetch('nodes', function () {
return $this->getNodesBag()->load()->getConfigBag()->getConfigs();
});
}
/**
* Get elements.
*
* [IMPORTANT] This method need to decouple. So that, the application can work with other platform.
*
* @return mixed
*/
public function getElements()
{
return $this->cache->fetch('elements', function () {
$elements = $this->getElementsBag()->load()->getConfigBag()->getConfigs();
$elementsInfo = qxGetElementsInfo();
$elementsInfo = array_reduce($elementsInfo, function ($carry, $element) {
$carry[$element->alias] = (array)$element; // must be send as alias
return $carry;
}, []);
$elements = array_map(function ($element) use ($elementsInfo) {
if (array_key_exists($element['slug'], $elementsInfo)) {
$checked = $elementsInfo[$element['slug']]['status'];
} else {
if (in_array($element['slug'], $this->disabledElements)) {
$checked = false;
} else {
$checked = true;
}
}
*
* @param $id
* @param $callback
*
* @return mixed
*/
protected function getCacheById($id, $callback)
{
$id = $id . $this->builder;
if (!$this->shouldCache) {
return $callback();
} else {
$cache = $this->cache->get($id, 'lib_quix');
if($cache){
return $cache;
}else{
$data = $callback();
// $this->cache->store($data, $id, 'quix'); // old way
$this->cache->store($data, $id, $this->cachePath); // new path with v2 support
return $data;
}
// if ($this->cache->contains($id)) {
// return $this->cache->fetch($id);
// } else {
// $data = $callback();
// $this->cache->save($id, $data, $this->cacheLifeTime);
// return $data;
// }
}
}
}
}
/**
* Get cache details by ID.
*
* @param $id
*
* @return mixed
*/
public function fetch($id)
{
$id = $id . $this->builder;
$args = func_get_args();
if (count($args) === 1) {
// return $this->cache->fetch($id);
return $this->cache->get($id, 'lib_quix');
} else {
$callback = $args[1];
return $this->getCacheById($id, $callback);
}
}
/**
* Get Cache by id.
*
* @param $id
* @param $callback
*
* @return mixed
*/
protected function getCacheById($id, $callback)
{
$id = $id . $this->builder;
if (!$this->shouldCache) {
return $callback();
} else {
$cache = $this->cache->get($id, 'lib_quix');
}, []);
$elements = array_map(function ($element) use ($elementsInfo) {
if (array_key_exists($element['slug'], $elementsInfo)) {
$checked = $elementsInfo[$element['slug']]['status'];
} else {
if (in_array($element['slug'], $this->disabledElements)) {
$checked = false;
} else {
$checked = true;
}
}
$element['enabled'] = $checked;
return $element;
}, $elements);
return $elements;
});
}
/**
* Get elements json.
*
* [IMPORTANT] This method need to decouple. So that, the application can work with other platform.
*
* @return mixed
*/
public function getElementsJson()
{
return $this->cache->fetch('json_elements', function () {
return json_encode($this->getElements());
});
}
/**
* loading shape divider svg
*
* @return mixed
return new ElementBag($validator, $transformer, $container['finalConfigTransformer'], $builder);
};
// Bind nodes with the container
$this->container['nodes'] = function ($container) use ($builder) {
$validator = new NodeValidator();
$transformer = new NodeTransformer(new FormEngine(new ControlsTransformer($builder)), $builder);
return new NodeBag($validator, $transformer, $container['finalConfigTransformer'], $builder);
};
// Bind presets with the container
$this->container['presets'] = function ($container) {
return new Library();
};
// Bind allNodes with the container
$this->container['allNodes'] = function ($container) {
$elements = $this->getElements();
$nodes = $this->getNodes();
return array_merge($elements, $nodes);
};
// Bind mobile detect with the container
$this->container['mobile_detect'] = function ($container) {
return new Mobile_Detect();
};
// Bind view with the container
$this->container['view'] = function ($container) use ($builder) {
// if( checkQuixIsVersion2() && ($builder == "frontend") ) {
if ($builder == 'frontend') {
return new View(new TwigEngine, $builder);
} else {
return new View(new PhpEngine, $builder);
}
};
// Bind view renderer with the container
{
if (!isset($this->keys[$id])) {
throw new UnknownIdentifierException($id);
}
if (
isset($this->raw[$id])
|| !\is_object($this->values[$id])
|| isset($this->protected[$this->values[$id]])
|| !\method_exists($this->values[$id], '__invoke')
) {
return $this->values[$id];
}
if (isset($this->factories[$this->values[$id]])) {
return $this->values[$id]($this);
}
$raw = $this->values[$id];
$val = $this->values[$id] = $raw($this);
$this->raw[$id] = $raw;
$this->frozen[$id] = true;
return $val;
}
/**
* Checks if a parameter or an object is set.
*
* @param string $id The unique identifier for the parameter or object
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($id)
{
return isset($this->keys[$id]);
}
}
/**
* Get presents bag.
*
* @return mixed
*/
public function getPresetsBag()
{
return $this->container['presets'];
}
/**
* Get all nodes.
*
* @return mixed
*/
public function getAllNodes()
{
return $this->container['allNodes'];
}
/**
* Get view renderer.
*
* @return mixed
*/
public function getViewRenderer()
{
return $this->container['viewRenderer'];
}
/**
* Get template renderer.
*
* @return mixed
*/
public function getTemplateRenderer()
{
return $this->container['templateRenderer'];
};
// Bind style renderer with the container
$this->container['styleRenderer'] = function ($container) {
return new StyleRenderer($container['view'], $container['mobile_detect'], $container['allNodes']);
};
// Bind script renderer with the container
$this->container['scriptRenderer'] = function ($container) {
return new ScriptRenderer($container['view'], $container['mobile_detect'], $container['allNodes']);
};
// Bind template renderer with the container
$this->container['templateRenderer'] = function ($container) {
return new TemplateRenderer($container['view'], $container['mobile_detect'], $container['allNodes']);
};
// Bind web font renderer with the container
$this->container['webFontsRenderer'] = function ($container) {
return new WebFontsRenderer($this->cache, $this->getAllNodes());
};
// Bind view engine tracker with the container
$this->container['engineTracker'] = function () {
return new EngineTracker;
};
}
/**
* Get element bag.
*
* @return mixed
*/
public function getElementsBag()
{
return $this->container['elements'];
}
/**
* Get nodes bag.
{
if (!isset($this->keys[$id])) {
throw new UnknownIdentifierException($id);
}
if (
isset($this->raw[$id])
|| !\is_object($this->values[$id])
|| isset($this->protected[$this->values[$id]])
|| !\method_exists($this->values[$id], '__invoke')
) {
return $this->values[$id];
}
if (isset($this->factories[$this->values[$id]])) {
return $this->values[$id]($this);
}
$raw = $this->values[$id];
$val = $this->values[$id] = $raw($this);
$this->raw[$id] = $raw;
$this->frozen[$id] = true;
return $val;
}
/**
* Checks if a parameter or an object is set.
*
* @param string $id The unique identifier for the parameter or object
*
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($id)
{
return isset($this->keys[$id]);
}
}
/**
* Get script renderer.
*
* @return mixed
*/
public function getScriptRenderer()
{
return $this->container['scriptRenderer'];
}
/**
* Get web fonts renderer.
*
* @return mixed
*/
public function getWebFontsRenderer()
{
return $this->container['webFontsRenderer'];
}
/**
* Get nodes.
*
* @return mixed
*/
public function getNodes()
{
return $this->cache->fetch('nodes', function () {
return $this->getNodesBag()->load()->getConfigBag()->getConfigs();
});
}
/**
* Get elements.
*
* [IMPORTANT] This method need to decouple. So that, the application can work with other platform.
*
* @return mixed
}
}
if (JDEBUG) {
\JProfiler::getInstance('Application')->mark('After loading core CSS (' . $item->builder . ')');
}
}
public static function loadAssetsClassicBuilder($quix, $data, $item, $type, $pageModifiedTimeStamp)
{
if (JDEBUG) {
\JProfiler::getInstance('Application')->mark('Before loading assets (' . $item->builder . ')');
}
$document = \JFactory::getDocument();
// classic builder codes start
loadClassicBuilderPreviewAssets();
plgSystemQuix::addQuixTrapCSSclassic();
$webFontsRenderer = $quix->getWebFontsRenderer();
$fonts = $webFontsRenderer->getUsedFonts($data);
$fontsWeight = $webFontsRenderer->getUsedFontsWeight();
Assets::bulkCssMinifier(
$pageModifiedTimeStamp,
$quix->getStyleRenderer()->render($data, null, $item->builder),
$type,
$item->id
);
if (count($fonts)) {
/**
* Dynamically generate font families name string.
*/
$fontFamilies = '';
$count = count($fonts);
foreach ($fonts as $font) {
$weights = isset($fontsWeight[$font])
if (strlen($jsCotent) > 2) {
Assets::bulkJsMinifier($pageModifiedTimeStamp . '-fileJS' . $type . $item->id, $jsCotent, $type, $item->id);
}
} else {
$scriptRendared = $quix->getScriptRenderer()->render($data, null, $item->builder);
$scriptRendared = QuixRenderItemHelper::minimizeJavascriptSimple($scriptRendared);
// var_dump($scriptRendared);die;
if (strlen($scriptRendared) > 8) { // as less then 8 not seems possible
$scripts = "(function(){{$scriptRendared}}());";
file_put_contents(get_compiled_js_path() . "{$compiledJs}", $scripts);
Assets::bulkJsMinifier($pageModifiedTimeStamp . '-script', $scripts, $type, $item->id);
}
// Assets::load($item->builder);
}
// ======= visual builder codes end
} else {
QuixRenderItemHelper::loadAssetsClassicBuilder($quix, $data, $item, $type, $pageModifiedTimeStamp);
} ?>
<?php
if (JDEBUG) {
\JProfiler::getInstance('Application')->mark('Before making view (' . $item->builder . ')');
} ?>
<?php echo $quix->getViewRenderer()->render($data, null, $item->builder); ?>
<?php
if (JDEBUG) {
\JProfiler::getInstance('Application')->mark('After making view (' . $item->builder . ')');
} ?>
</div>
</div>
<?php
if ($item->builder == 'frontend' && !empty($code)) {
Assets::bulkJsMinifier($pageModifiedTimeStamp . '-loadGlobalStyles' . $type . $item->id, ";(function(){ if(typeof loadGlobalStyles == 'function') loadGlobalStyles($code); })();", $type, $item->id);
// $document->addScriptDeclaration(";(function(){ if(typeof loadGlobalStyles == 'function') loadGlobalStyles($code); })();");
}
return false;
}
if (isset($this->item->id) && $this->item->id) {
// hardcode type for builder use, so we know its page
$this->item->type = 'page';
// Check the view access to the article (the model has already computed the values).
if ($this->item->params->get('access-view') == false && ($this->item->params->get('show_noauth', '0') == '0')) {
$app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'), 'error');
$app->setHeader('status', 403, true);
return;
}
// count hits
$this->get('Hit');
// render quix content and trigger content plugin
$this->item->text = quixRenderItem($this->item);
// render quix content and trigger content plugin
/*
$itemCacheName = $this->item->builder . '-page-' . $this->item->id;
$cache = JFactory::getCache('com_quix', '');
$cache->setCaching( true );
$pageContent = $cache->get($itemCacheName);
if (!empty($pageContent)) {
$the_page_output = $pageContent;
}else{
$the_page_output = quixRenderItem($this->item);
$cache->store($the_page_output, $itemCacheName);
}
$this->item->text = $the_page_output;
*/
} else {
JError::raiseError(404, JText::_('JERROR_PAGE_NOT_FOUND'));
return false;
}
$registeredurlparams->$key = $value;
}
$app->registeredurlparams = $registeredurlparams;
}
try
{
/** @var \JCacheControllerView $cache */
$cache = \JFactory::getCache($option, 'view');
$cache->get($view, 'display');
}
catch (\JCacheException $exception)
{
$view->display();
}
}
else
{
$view->display();
}
return $this;
}
/**
* Execute a task by triggering a method in the derived class.
*
* @param string $task The task to perform. If no matching task is found, the '__default' task is executed, if defined.
*
* @return mixed The value returned by the called method.
*
* @since 3.0
* @throws \Exception
*/
public function execute($task)
{
$this->task = $task;
$task = strtolower((string) $task);
// Somehow the person just went to the form - we don't allow that.
// return JError::raiseError(403, JText::sprintf('COM_QUIX_UNHELD_ID', $id));
// directly redirect to task edit
$url = 'index.php?option=com_quix&task=' . $this->input->get('type', 'page') . '.edit&id=' . $id;
$app->redirect($url);
}
// JCH fix for amp format
QuixFrontendHelper::fixJCH();
if ($format == 'amp') {
$free = QuixHelper::isFreeQuix();
if ($free) {
$uri = JUri::getInstance();
$uri->delVar('format');
$app->redirect($uri->toString());
}
}
return parent::display($cachable, $urlparams);
}
/**
* Method to perform ajax call
*
* @param element element name must be passed
* @param format format can be html, raw, json; default: json
* @param method default method: get; will call getAjax(). postfix is: Ajax.
*
* @return core output, like: json or other format
* url example: index.php?option=com_quix&task=ajax&element=simple-contact&format=json&method=get
* @since 1.3
*/
public function ajax()
{
// Reference global application object
$app = JFactory::getApplication();
// JInput object
$input = $app->input;
$task = strtolower((string) $task);
if (isset($this->taskMap[$task]))
{
$doTask = $this->taskMap[$task];
}
elseif (isset($this->taskMap['__default']))
{
$doTask = $this->taskMap['__default'];
}
else
{
throw new \Exception(\JText::sprintf('JLIB_APPLICATION_ERROR_TASK_NOT_FOUND', $task), 404);
}
// Record the actual task being fired
$this->doTask = $doTask;
return $this->$doTask();
}
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return \JModelLegacy|boolean Model object on success; otherwise false on failure.
*
* @since 3.0
*/
public function getModel($name = '', $prefix = '', $config = array())
{
if (empty($name))
{
$name = $this->getName();
}
{
$app->setHeader('status', 403, true);
$app->redirect(JRoute::_('index.php'), 403);
}
}
}
// Include dependencies
jimport( 'quix.app.bootstrap' );
global $QuixBuilderType ;
$QuixBuilderType = "frontend";
jimport( 'quix.app.init' );
JLoader::register( 'QuixFrontendHelper', JPATH_COMPONENT . '/helpers/quix.php' );
JLoader::register( 'QuixHelper', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/quix.php' );
// Execute the task.
$controller = JControllerLegacy::getInstance( 'Quix' );
$controller->execute( $app->input->get( 'task' ) );
$controller->redirect();
{
\JProfiler::getInstance('Application')->mark('afterRenderComponent ' . $option);
}
return $contents;
}
/**
* Execute the component.
*
* @param string $path The component path.
*
* @return string The component output
*
* @since 1.7
*/
protected static function executeComponent($path)
{
ob_start();
require_once $path;
return ob_get_clean();
}
/**
* Load the installed components into the components property.
*
* @param string $option The element value for the extension
*
* @return boolean True on success
*
* @since 1.5
* @deprecated 4.0 Use JComponentHelper::load() instead
*/
protected static function _load($option)
{
return static::load($option);
}
/**
Arguments
"/var/www/clients/client89/web354/web/components/com_quix/quix.php"
*/
define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/' . $option);
}
$path = JPATH_COMPONENT . '/' . $file . '.php';
// If component is disabled throw error
if (!static::isEnabled($option) || !file_exists($path))
{
throw new MissingComponentException(\JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND'), 404);
}
// Load common and local language files.
$lang->load($option, JPATH_BASE, null, false, true) || $lang->load($option, JPATH_COMPONENT, null, false, true);
// Handle template preview outlining.
$contents = null;
// Execute the component.
$contents = static::executeComponent($path);
// Revert the scope
$app->scope = $scope;
if (JDEBUG)
{
\JProfiler::getInstance('Application')->mark('afterRenderComponent ' . $option);
}
return $contents;
}
/**
* Execute the component.
*
* @param string $path The component path.
*
* @return string The component output
*
* @since 1.7
case 'feed':
$document->setBase(htmlspecialchars(\JUri::current()));
break;
}
$document->setTitle($params->get('page_title'));
$document->setDescription($params->get('page_description'));
// Add version number or not based on global configuration
if ($this->get('MetaVersion', 0))
{
$document->setGenerator('Joomla! - Open Source Content Management - Version ' . JVERSION);
}
else
{
$document->setGenerator('Joomla! - Open Source Content Management');
}
$contents = ComponentHelper::renderComponent($component);
$document->setBuffer($contents, 'component');
// Trigger the onAfterDispatch event.
\JPluginHelper::importPlugin('system');
$this->triggerEvent('onAfterDispatch');
}
/**
* Method to run the Web application routines.
*
* @return void
*
* @since 3.2
*/
protected function doExecute()
{
// Initialise the application
$this->initialiseApp();
// Mark afterInitialise in the profiler.
// Mark afterInitialise in the profiler.
JDEBUG ? $this->profiler->mark('afterInitialise') : null;
// Route the application
$this->route();
// Mark afterRoute in the profiler.
JDEBUG ? $this->profiler->mark('afterRoute') : null;
/*
* Check if the user is required to reset their password
*
* Before $this->route(); "option" and "view" can't be safely read using:
* $this->input->getCmd('option'); or $this->input->getCmd('view');
* ex: due of the sef urls
*/
$this->checkUserRequireReset('com_users', 'profile', 'edit', 'com_users/profile.save,com_users/profile.apply,com_users/user.logout');
// Dispatch the application
$this->dispatch();
// Mark afterDispatch in the profiler.
JDEBUG ? $this->profiler->mark('afterDispatch') : null;
}
/**
* Return the current state of the detect browser option.
*
* @return boolean
*
* @since 3.2
*/
public function getDetectBrowser()
{
return $this->_detect_browser;
}
/**
* Return the current state of the language filter.
*
array('option', 'view', 'format', 'lang', 'Itemid', 'template', 'templateStyle', 'task'),
function($systemVariable) use ($input) {
return $input->exists($systemVariable) && is_array($input->getRaw($systemVariable));
}
);
// Unset invalid system variables
foreach ($invalidInputVariables as $systemVariable)
{
$input->set($systemVariable, null);
}
// Abort when there are invalid variables
if ($invalidInputVariables)
{
throw new \RuntimeException('Invalid input, aborting application.');
}
// Perform application routines.
$this->doExecute();
// If we have an application document object, render it.
if ($this->document instanceof \JDocument)
{
// Render the application output.
$this->render();
}
// If gzip compression is enabled in configuration and the server is compliant, compress the output.
if ($this->get('gzip') && !ini_get('zlib.output_compression') && ini_get('output_handler') !== 'ob_gzhandler')
{
$this->compress();
// Trigger the onAfterCompress event.
$this->triggerEvent('onAfterCompress');
}
// Send the application response.
$this->respond();
{
include_once __DIR__ . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', __DIR__);
require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_BASE . '/includes/framework.php';
// Set profiler start time and memory usage and mark afterLoad in the profiler.
JDEBUG ? JProfiler::getInstance('Application')->setStart($startTime, $startMem)->mark('afterLoad') : null;
// Instantiate the application.
$app = JFactory::getApplication('site');
// Execute the application.
$app->execute();