Process includes

@param  Element $includes
@return array
@throws InvalidConfig
970982
protected function processIncludes(Element $includes) {
		$definitions = [];
		
		foreach ($includes->getContent() as $include) {
			if ($include->getName() === 'include') {
				if (isset($include->load)) {
					$definitions[] = $include->load;
					continue;
				}
				
				$content = $include->getValue();
				
				if (! empty($content)) {
					$definitions[] = $content;
					continue;
				}
				
				throw new InvalidConfig('Include must contain value or "load" attribute', null, null, $include);
			}
			
			throw new InvalidConfig('Unknown element "' . $include->getName() . '" in includes', null, null, $include);
		}
		
		return $definitions;
	}
1040782
private function replaceElements($elements, $res)
    {
        $replaces = [];

        // Some components may be disabled for current page
        $disabled_components = Structure::getDisabledComponents();
        $cached_components = Structure::getCachedComponents();

        $cacher = Cacher::getInstance()->getDefaultCacher();

        // May be another MVC class that implements required features
        $this->mvc_instance = new MVC();

        // Change elements to its' real data
        foreach($elements as $k=> $v){

            if (in_array($v['class'], $disabled_components)) {
                // Skip disabled
                $replaces[$res[0][$k]] = '';
            } elseif (in_array($v['class'], $cached_components)) {
                // Get from hard cache
                $cache_key = PAGE_ID . '_' . md5(PAGE_ID . '_' . $k . '_' . $v['class']);
                $cached_value = $cacher->get($cache_key);
                if ($cached_value) {
                    $replaces[$res[0][$k]] = $cached_value;
                } else {
                    // Replace if not found in cache
                    $replaces[$res[0][$k]] = $this->callReplace($v);
                    // Save in cache
                    $cacher->set($cache_key, $replaces[$res[0][$k]]);
                }
            } else {
                // Usual replace
                $replaces[$res[0][$k]] = $this->callReplace($v);
            }

        }
        // Replace data with its' component variables in template
        if ($replaces) {
            reset($replaces);
            foreach($replaces as $k=>$v){
                $this->html = str_replace($k, $v, $this->html);
            }
        }
    }
1094581
protected function parseIncludes(array $includes)
    {
        $return = [
            'includes' => [],
            'modes' => []
        ];

        foreach ($includes as $include) {
            $explode = explode(':', $include);

            if (!isset($explode[1])) {
                $explode[1] = $this->defaults['mode'];
            }

            $return['includes'][] = $explode[0];
            $return['modes'][$explode[0]] = $explode[1];
        }

        return $return;
    }
245543
public function excluding($excludes)
	{
		if($excludes === true)
		{
			$this->model->setIncludes([]);
		}
		else
		{
			$excludes = (array) $excludes;

			$includes = $this->model->getIncludes();

			foreach($excludes as $key => $relation)
			{
				if(is_string($relation) && isset($includes[$relation]))
				{
					unset($includes[$relation], $excludes[$key]); // Unset relations that may have been set with a criterion closure
				}
			}

			$this->model->setIncludes(array_udiff($includes, $excludes, function($a, $b)
			{
				return $a === $b ? 0 : -1;
			}));
		}

		return $this;
	}
351132
public void _include(IncludeBuilderBase includes) {
        if (includes == null) {
            return;
        }

        if (includes.documentsToInclude != null) {
            for (String doc : includes.documentsToInclude) {
                documentIncludes.add(doc);
            }
        }

        _includeCounters(includes.alias, includes.countersToIncludeBySourcePath);
    }
494618
public function setExcludes($excludes)
    {
        if ($this->isReference()) {
            throw $this->tooManyAttributes();
        }
        $this->defaultPatterns->setExcludes($excludes);
    }
881874
public List<T> find(String... includes) throws IOException {
        return find(getWorld().filter().include(includes));
    }
38780
protected function applyIncludes($dataTypes): array
    {
        $inclusions = explode(',', $this->include);
        // Find any invalid data to include.
        $invalidIncludes = array_diff($inclusions, $dataTypes);
        if (count($invalidIncludes) > 0) {
            $errorMessage = 'WARNING: Invalid include(s)';
            $errorMessage .= ': '.implode(', ', $invalidIncludes).'.'.PHP_EOL;
            $errorMessage .= ' Valid inclusions are '.implode(', ', $dataTypes);

            // Output an error message outlining what invalid exclusions were specified.
            Schematic::warning($errorMessage);
        }
        // Remove any explicitly included data types from the list of data types to export.
        return array_intersect($dataTypes, $inclusions);
    }
307212
protected function processIncludes()
    {
        foreach ($this->getXml()->xpath('/includes/include[@type != "" and @file != ""]') as $include) {
            $processor = $this->getIncludeProcessor((string)$include['type']);
            if (!$processor) {
                trigger_error(sprintf('No include processor for "%s" available. Did you forget to register it?', (string)$include['type']), E_USER_WARNING);
                continue;
            }

            $file = $this->getModulePath((string)$include['file']);
            $processor->load($file, $this->manifest);
        }

        return $this;
    }
553173
private function checkInclude($include,$deep = false){
		if (is_string($include)){
			$include = array($include);
		}
		$include = Hash::normalize($include);

		foreach($include as $key => $val){
			$val = Hash::merge($this->includeDef,$val);
			// if Embed in config is true all include array set true
			if($this->config['embed']){
				$val['embed'] = true;
			}
			if ($val['include']){
				$val['include'] = $this->checkInclude($val['include'],true);
			}
			$include[$key] = $val;

		}
		
		
		if (!$deep){
			$this->include = $include;
		}
    	return $include;
	}
1251709
public static function getNumberOperands($includeSelector = false)
    {
        $values = array(
            self::OPERATOR_EQUAL,
            self::OPERATOR_GREATER_THAN,
            self::OPERATOR_GREATER_THAN_EQUAL,
            self::OPERATOR_LOWER_THAN,
            self::OPERATOR_LOWER_THAN_EQUAL,
        );

        if ($includeSelector) {
            $values[] = self::OPERAND_SELECTOR;
        }

        return $values;
    }
1155357
public function load_includes() {

		// Get includes
		$includes = $this->includes;

		// Loop conditions
		foreach ( $includes as $condition => $files ) {

			$do_includes = false;

			// Check condition
			switch( $condition ) {

				// Admin Only
				case 'admin':

					if ( is_admin() ) {
						$do_includes = true;
					}

					break;

				// Frontend Only
				case 'frontend':

					if ( ! is_admin() ) {
						$do_includes = true;
					}

					break;

				// Admin or Frontend (always)
				default:

					$do_includes = true;

					break;

			}

			// Loop files if condition met
			if ( $do_includes ) {

				foreach ( $files as $file ) {
					require_once trailingslashit( CTC_PATH ) . $file;
				}

			}

		}

	}
1026008
protected function processCall(Element $call) {
		if (! isset($call->method)) {
			throw new InvalidConfig('Definition of a call must contain the "method" attribute', null, null, $call);
		}
		
		$definition = new stdClass();
		$definition->method = trim($call->method);
		
		$content = $call->getContent();
		
		if (! empty($content)) {
			$this->processDefinitionParameters($content, $definition);
		}
		
		return $definition;
	}
285754
protected function getIncludes(array $parameters, string $errorTitle): iterable
    {
        if (\array_key_exists(P::PARAM_INCLUDE, $parameters) === true) {
            $paramName = P::PARAM_INCLUDE;
            $includes  = $parameters[$paramName];
            foreach ($this->splitCommaSeparatedStringAndCheckNoEmpties($paramName, $includes, $errorTitle) as $path) {
                yield $path => $this->splitStringAndCheckNoEmpties($paramName, $path, '.', $errorTitle);
            }
        }
    }
358974
protected function processArguments(array $args) {
		$definition = [];
		
		foreach ($args as $arg) {
			if ($arg->getName() !== 'argument') {
				throw new InvalidConfig('Unknown element "' . $arg->getName() . '" in arguments definition', null, null, $arg);
			}

			$definition[] = $this->processArgument($arg);
		}
		
		return $definition;
	}
487427
public function setIncludes($includes)
    {
        if ($this->isReference()) {
            throw $this->tooManyAttributes();
        }
        $this->defaultPatterns->setIncludes($includes);
    }
432187
function initializeIncludes()
    {
        // If we have this global variable we shouldn't do any processing
        if ( !empty( $GLOBALS['eZSimpleTagsInit'] ) )
            return;

        $GLOBALS['eZSimpleTagsInit'] = true;
        $ini = eZINI::instance( 'template.ini' );
        $extensions = $ini->variable( 'SimpleTagsOperator', 'Extensions' );
        $pathList = eZExtension::expandedPathList( $extensions, 'simpletags' );
        $includeList = $ini->variable( 'SimpleTagsOperator', 'IncludeList' );

        foreach ( $includeList as $includeFile )
        {
            foreach ( $pathList as $path )
            {
                $file = $path . '/' . $includeFile;
                if ( file_exists( $file ) )
                {
                    include_once( $file );
                }
            }
        }
    }