File manager - Edit - /home/opticamezl/www/newok/builder-source.zip
Back
PK eG�\bԇ>� � config/customizer.jsonnu �[��� { "sources": { "filters": { "before": { "label": "Before", "description": "Add text before the content field." }, "after": { "label": "After", "description": "Add text after the content field." }, "search": { "label": "Search", "description": "Select a predefined search pattern or enter a custom string or regular expression to search for. The regular expression has to be enclosed between slashes. For example `my-string` or `/ab+c/`.", "type": "data-list", "options": { "URL Protocol": "/https?:\\/\\//", "Hyphen and Underscore": "/[\\-_]/" } }, "replace": { "label": "Replace", "description": "Enter the replacement string which may contain references. If left empty, the search matches will be removed." }, "limit": { "label": "Content Length", "description": "Limit the content length to a number of characters. All HTML elements will be stripped.", "type": "number", "attrs": { "placeholder": "No limit." } }, "preserve": { "type": "checkbox", "text": "Preserve words" }, "date": { "label": "Date Format", "description": "Select a predefined date format or enter a custom format.", "type": "data-list", "default": "", "options": { "Aug 6, 1999 (M j, Y)": "M j, Y", "August 06, 1999 (F d, Y)": "F d, Y", "08/06/1999 (m/d/Y)": "m/d/Y", "08.06.1999 (m.d.Y)": "m.d.Y", "6 Aug, 1999 (j M, Y)": "j M, Y", "Tuesday, Aug 06 (l, M d)": "l, M d", "15:00 (G:i)": "G:i", "3:00 pm (g:i A)": "g:i a" }, "attrs": { "placeholder": "Default" } } }, "directives": { "slice": { "fields": { "_grid": { "description": "Set the starting point and limit the number of items.", "type": "grid", "width": "1-2", "fields": { "offset": { "label": "Start", "type": "number", "default": 0, "modifier": 1, "attrs": { "min": 1, "required": true } }, "limit": { "label": "Quantity", "type": "limit", "attrs": { "placeholder": "No limit", "min": 0 } } } } } } } } } PK eG�\�Ġ�O O config/builder.jsonnu �[��� { "source": { "type": "fields", "fields": { "_source": { "label": "Dynamic Content", "type": "source-select", "description": "Select a content source to make its fields available for mapping. Choose between sources of the current page or query a custom source." }, "_sourceArgs": { "type": "source-query-args" }, "_sourceField": { "label": "Multiple Items Source", "type": "source-field-select", "description": "By default, fields of related sources with single items are available for mapping. Select a related source which has multiple items to map its fields.", "show": "yootheme.builder.helpers.Source.showMultipleSelectField(this.builder.path(this.node))" }, "_sourceFieldArgs": { "type": "source-field-args" }, "_sourceFieldDirectives": { "type": "source-field-directives" }, "_sourceCondition": { "type": "fields", "fields": { "_sourceConditionProp": { "label": "Dynamic Condition", "prop": "_condition", "type": "source-prop-select", "description": "Set a condition to display the element or its item depending on the content of a field." }, "_sourceConditionArgs": { "type": "source-prop-filters", "prop": "_condition", "fields": { "_grid": { "type": "grid", "width": "1-2", "fields": { "condition": { "label": "Condition", "type": "select", "default": "!!", "options": { "Is empty": "!", "Is not empty": "!!", "Is equal to": "=", "Is not equal to": "!=", "Contains": "~=", "Does not contain": "!~=", "Less than": "<", "Greater than": ">", "Starts with": "^=", "Does not start with": "!^=", "Ends with": "$=", "Does not end with": "!$=", "Matches a RegExp": "regex" }, "enable": "!show_empty" }, "condition_value": { "label": "Value", "enable": "!show_empty && $match(condition, '=|<|>|regex')" } } }, "show_empty": { "type": "checkbox", "text": "Show element only if dynamic content is empty" } } } }, "show": "yootheme.builder.helpers.Source.getSourceField(this.builder.path(this.node))" } } } } PK eG�\���D� � src/Source.phpnu �[��� <?php namespace YOOtheme\Builder; use YOOtheme\Event; use YOOtheme\GraphQL\Executor\ExecutionResult; use YOOtheme\GraphQL\GraphQL; use YOOtheme\GraphQL\SchemaBuilder; use YOOtheme\GraphQL\Type\Schema; use YOOtheme\GraphQL\Utils\AST; use YOOtheme\GraphQL\Utils\Introspection; class Source extends SchemaBuilder { /** * @var Schema|null */ protected $schema; /** * Gets the schema. * * @return Schema */ public function getSchema() { return $this->schema ?: ($this->schema = $this->buildSchema()); } /** * Sets the schema. * * @param Schema $schema * * @return Schema */ public function setSchema(Schema $schema) { return $this->schema = $schema; } /** * Executes a query on schema. * * @param mixed $source * @param mixed $value * @param mixed $context * @param array|null $variables * @param string|null $operation * @param callable $fieldResolver * @param array $validationRules * * @return ExecutionResult */ public function query( $source, $value = null, $context = null, $variables = null, $operation = null, $fieldResolver = null, $validationRules = null ) { if (is_array($source)) { $source = AST::fromArray($source); } return GraphQL::executeQuery( $this->getSchema(), $source, $value, $context, $variables, $operation, $fieldResolver, $validationRules, ); } /** * Executes an introspection on schema. * * @param array $options * * @return ExecutionResult */ public function queryIntrospection(array $options = []) { $metadata = [ 'type' => $this->getType('Object'), 'resolve' => fn($type) => Event::emit( 'source.type.metadata|filter', $type->config['metadata'] ?? null, $type, ), ]; $options += [ '__Type' => compact('metadata'), '__Field' => compact('metadata'), '__Directive' => compact('metadata'), '__InputValue' => compact('metadata'), ]; return GraphQL::executeQuery( $this->getSchema(), Introspection::getIntrospectionQuery($options), ); } } PK eG�\)�%� � src/Source/Type/RequestType.phpnu �[��� <?php namespace YOOtheme\Builder\Source\Type; use function YOOtheme\trans; use YOOtheme\Http\Request; class RequestType { /** * @return array */ public static function config() { return [ 'fields' => [ 'url' => [ 'type' => 'String', 'metadata' => [ 'label' => trans('URL'), ], 'extensions' => [ 'call' => __CLASS__ . '::resolveUrl', ], ], 'method' => [ 'type' => 'String', 'metadata' => [ 'label' => trans('Method'), ], 'extensions' => [ 'call' => __CLASS__ . '::resolveMethod', ], ], 'scheme' => [ 'type' => 'String', 'metadata' => [ 'label' => trans('Scheme'), ], 'extensions' => [ 'call' => __CLASS__ . '::resolveScheme', ], ], 'host' => [ 'type' => 'String', 'metadata' => [ 'label' => trans('Host'), ], 'extensions' => [ 'call' => __CLASS__ . '::resolveHost', ], ], 'port' => [ 'type' => 'String', 'metadata' => [ 'label' => trans('Port'), ], 'extensions' => [ 'call' => __CLASS__ . '::resolvePort', ], ], 'path' => [ 'type' => 'String', 'metadata' => [ 'label' => trans('Path'), ], 'extensions' => [ 'call' => __CLASS__ . '::resolvePath', ], ], 'query' => [ 'type' => 'String', 'metadata' => [ 'label' => trans('Query'), ], 'extensions' => [ 'call' => __CLASS__ . '::resolveQuery', ], ], ], 'metadata' => [ 'type' => true, 'label' => trans('Request'), ], ]; } public static function resolveUrl(Request $request) { return (string) $request->getUri(); } public static function resolveMethod(Request $request) { return $request->getMethod(); } public static function resolveScheme(Request $request) { return $request->getUri()->getScheme(); } public static function resolveHost(Request $request) { return $request->getUri()->getHost(); } public static function resolvePort(Request $request) { return $request->getUri()->getPort(); } public static function resolvePath(Request $request) { return $request->getUri()->getPath(); } public static function resolveQuery(Request $request) { return $request->getUri()->getQuery(); } } PK eG�\\\1EB B src/Source/Type/SiteType.phpnu �[��� <?php namespace YOOtheme\Builder\Source\Type; use YOOtheme\Config; use YOOtheme\Http\Request; use function YOOtheme\app; use function YOOtheme\trans; class SiteType { /** * @return array */ public static function config() { return [ 'fields' => [ 'title' => [ 'type' => 'String', 'metadata' => [ 'label' => trans('Site Title'), 'filters' => ['limit', 'preserve'], ], ], 'page_title' => [ 'type' => 'String', 'metadata' => [ 'label' => trans('Page Title'), 'filters' => ['limit', 'preserve'], ], ], 'page_locale' => [ 'type' => 'String', 'metadata' => [ 'label' => trans('Page Locale'), ], 'extensions' => [ 'call' => __CLASS__ . '::resolvePageLocale', ], ], 'page_url' => [ 'type' => 'String', 'args' => [ 'query' => [ 'type' => 'Boolean', ], ], 'metadata' => [ 'label' => trans('Page URL'), 'arguments' => [ 'query' => [ 'label' => trans('Query String'), 'type' => 'checkbox', 'text' => trans('Include query string'), 'default' => false, ], ], ], 'extensions' => [ 'call' => __CLASS__ . '::resolvePageUrl', ], ], 'is_guest' => [ 'type' => 'Int', 'metadata' => [ 'label' => trans('Guest User'), 'condition' => true, ], ], 'user' => [ 'type' => 'User', 'metadata' => [ 'label' => trans('Current User'), ], ], 'request' => [ 'type' => 'Request', 'metadata' => [ 'label' => trans('Request'), ], 'extensions' => [ 'call' => __CLASS__ . '::resolveRequest', ], ], ], 'metadata' => [ 'type' => true, 'label' => trans('Site'), ], ]; } public static function resolveRequest() { return app(Request::class); } public static function resolvePageUrl($obj, array $args) { $uri = static::resolveRequest()->getUri(); return $uri->getPath() . ($args['query'] ? "?{$uri->getQuery()}" : ''); } public static function resolvePageLocale() { return app(Config::class)('locale.code'); } } PK eG�\�*p ) src/Source/Listener/LoadBuilderConfig.phpnu �[��� <?php namespace YOOtheme\Builder\Source\Listener; use YOOtheme\Builder\BuilderConfig; use YOOtheme\Builder\Source; use YOOtheme\Config; use YOOtheme\GraphQL\SchemaPrinter; class LoadBuilderConfig { public Config $config; public Source $source; public function __construct(Config $config, Source $source) { $this->config = $config; $this->source = $source; } /** * @param BuilderConfig $config */ public function handle($config): void { $dir = $this->config->get('image.cacheDir'); $file = "{$dir}/schema-{$this->config->get('source.id')}.gql"; $result = $this->source->queryIntrospection()->toArray(); $content = SchemaPrinter::doPrint($this->source->getSchema()); // update schema cache if (isset($result['data'])) { file_put_contents($file, $content); } elseif (is_file($file)) { unlink($file); } $config->merge(['schema' => $result['data']['__schema'] ?? $result]); } } PK eG�\�Cq~� � + src/Source/Listener/OrderSourceMetadata.phpnu �[��� <?php namespace YOOtheme\Builder\Source\Listener; class OrderSourceMetadata { public static function handle($metadata) { if (!empty($metadata['fields'])) { uasort( $metadata['fields'], fn($fieldA, $fieldB) => ($fieldA['@order'] ?? 0) - ($fieldB['@order'] ?? 0), ); } return $metadata; } } PK eG�\v��� � ( src/Source/Listener/LoadSourceSchema.phpnu �[��� <?php namespace YOOtheme\Builder\Source\Listener; use YOOtheme\Builder\Source; use YOOtheme\Config; use YOOtheme\Event; use YOOtheme\File; use YOOtheme\GraphQL\Error\Error; use YOOtheme\Http\Request; class LoadSourceSchema { public Config $config; public Request $request; public function __construct(Config $config, Request $request) { $this->config = $config; $this->request = $request; } /** * @param Source $source * @return bool|null */ public function handle($source): ?bool { $dir = $this->config->get('image.cacheDir'); $name = "schema-{$this->config->get('source.id')}"; $file = "{$dir}/{$name}.gql"; try { if ( $this->config->get('app.isSite') && !$this->request->getAttribute('customizer') && is_file($file) && filectime($file) > filectime(__FILE__) ) { // load schema from cache $hash = hash('crc32b', $file); $source->setSchema($source->loadSchema($file, "{$dir}/schema-{$hash}.php")); // stop event return false; } // delete invalid schema cache } catch (Error $e) { Event::emit('source.error', [$e]); File::rename($file, "{$dir}/{$name}.error.gql"); } return null; } } PK eG�\�q�� � &