Searches $this->_contents for template vars.

@param type $fromContents	Content to search; uses internal content if none provided.
@return array				see getTemplateVarDefinitions()
326576
public function getVarDefinitions($fromContents = null) {
		if(is_null($fromContents)) {
			$fromContents = $this->_contents;
		}

		return self::getTemplateVarDefinitions($fromContents);
	}
635204
protected function getVars($content, $details = [])
    {
        // Build defaults
        $defaults = [
            'id' => '',
            'title' => Translate::t('map.title', [], 'mapfield'),
            'default' => '',
            'description' => '',
            'can_upload' => current_user_can('upload_files'),
            'url' => $this->getMarkerAssets(),
            'options' => $this->getMapsOptions(),
            'types' => $this->getMapsTypes(),

            // texts
            't_delete_item' => Translate::t('map.delete_selection', [], 'mapfield'),
            't_item_globals' => Translate::t('map.globals', [], 'mapfield'),
            't_item_configs' => Translate::t('map.configurations', [], 'mapfield'),
            't_item_customs' => Translate::t('map.customizations', [], 'mapfield'),
            't_item_preview' => Translate::t('map.preview', [], 'mapfield'),

            't_address' => Translate::t('map.address.title', [], 'mapfield'),
            't_address_description' => Translate::t('map.address.description', [], 'mapfield'),

            't_marker' => Translate::t('map.marker.title', [], 'mapfield'),
            't_marker_add' => Translate::t('map.marker.add', [], 'mapfield'),
            't_marker_cannot_upload' => Translate::t('map.marker.cannot_upload', [], 'mapfield'),

            't_width' => Translate::t('map.width.title', [], 'mapfield'),
            't_width_description' => Translate::t('map.width.description', [], 'mapfield'),

            't_height' => Translate::t('map.height.title', [], 'mapfield'),
            't_height_description' => Translate::t('map.height.description', [], 'mapfield'),

            't_zoom' => Translate::t('map.zoom.title', [], 'mapfield'),
            't_zoom_description' => Translate::t('map.zoom.description', [], 'mapfield'),

            't_type' => Translate::t('map.type.title', [], 'mapfield'),
            't_type_description' => Translate::t('map.type.description', [], 'mapfield'),

            't_options' => Translate::t('map.options.title', [], 'mapfield'),
            't_options_select' => Translate::t('map.options.select', [], 'mapfield'),
            't_options_description' => Translate::t('map.options.description', [], 'mapfield'),

            't_json' => Translate::t('map.json.title', [], 'mapfield'),
            't_json_yes' => Translate::t('map.json.yes', [], 'mapfield'),
            't_json_no' => Translate::t('map.json.no', [], 'mapfield'),
            't_json_description' => Translate::t('map.json.description', [], 'mapfield'),

            't_update' => Translate::t('map.update', [], 'mapfield'),
        ];

        // Build defaults data
        $vars = array_merge($defaults, $content);

        // Retrieve field value
        $vars['val'] = $this->getValue($content['id'], $details, $vars['default']);

        // Update vars
        $this->getModel()->setVars($vars);
    }
418543
public static function createFromInline($fileContents)
    {
        // '//# sourceMappingURL=data:application/json;charset:utf-8;base64,
        // '//# sourceMappingURL=data:application/json;base64,'
        $pos = strrpos($fileContents, "\n//# sourceMappingURL=");
        $isCss = false;
        if ($pos === false) {
            $pos = strrpos($fileContents, "\n/*# sourceMappingURL=");
            if ($pos === false) {
                throw new Exception("No sourceMappingURL found");
            }
            $isCss = true;
        }
        $url = substr($fileContents, $pos + 22);
        $url = rtrim($url);
        if ($isCss) {
            if (substr($url, -2) != '*/') {
                throw new Exception("sourceMappingURL isn't wrapped with closing */");
            }
            $url = substr($url, 0, -2); //remove "*/"
            $url = rtrim($url);
        }

        if (substr($url, 0, 29) == 'data:application/json;base64,') {
            $map = substr($url, 29);
        } else if (substr($url, 0, 29 + 14) == 'data:application/json;charset:utf-8;base64,') {
            $map = substr($url, 29 + 14);
        } else if (substr($url, 0, 29 + 14) == 'data:application/json;charset=utf-8;base64,') {
            $map = substr($url, 29 + 14);
        } else {
            throw new Exception("Unsupported sourceMappingURL");
        }
        $map = base64_decode($map);
        $map = json_decode($map);
        $fileContents = substr($fileContents, 0, $pos);
        $ret = new self($map, $fileContents);
        $ret->setMimeType($isCss ? 'text/css' : 'text/javascript');
        return $ret;
    }
820346
public function getDescendantsContentUids($contents)
    {
        if (false === is_array($contents)) {
            $contents = array($contents);
        }

        $meta = $this->_em->getClassMetadata('BackBee\ClassContent\Indexes\IdxContentContent');

        $q = $this->_em->getConnection()
                ->createQueryBuilder()
                ->select('c.'.$meta->getColumnName('subcontent_uid'))
                ->from($meta->getTableName(), 'c');

        $index = 0;
        $atleastone = false;
        foreach ($contents as $content) {
            if (false === ($content instanceof AbstractClassContent)) {
                continue;
            }

            if (true === $content->isElementContent()) {
                continue;
            }

            $q->orWhere('c.'.$meta->getColumnName('content_uid').' = :uid'.$index)
                    ->setParameter('uid'.$index, $content->getUid());

            $index++;
            $atleastone = true;
        }

        return (true === $atleastone) ? array_unique($q->execute()->fetchAll(\PDO::FETCH_COLUMN)) : array();
    }
738766
private function _renderTemplate($template, $vars)
	{
		extract($vars, EXTR_SKIP);
		ob_start();

		try
		{
			require($template);
			$contents = ob_get_contents();
		}
		catch (Exception $e)
		{
			// TODO: come up with a clever way of chaining exceptions
			ob_end_clean();
			throw $e;
		}

		ob_end_clean();
		return $contents;
	}
22623
public function findByFrom($from)
    {
        if ($from[0] != '/') {
            $from = "/$from";
        }
        $from = rtrim($from, '?');

        if (strpos($from, '?') !== false) {
            list($base, $querystring) = explode('?', strtolower($from), 2);
        } else {
            $base = $from;
            $querystring = null;
        }

        $filter = array(
            'FromBase' => $base,
        );

        if ($querystring) {
            $filter['FromQuerystring'] = $querystring;
        }

        return RedirectedURL::get()->filter($filter)->first();
    }
576872
protected function display($content, $vars = [], $config = [])
    {
        $this->beforeViewRender();

        return $this->view->fetch($content, $vars, $config, true);
    }
635594
protected function extractProperties($source,$viewSpec,$from)
    {
        $obj = [];
        if (isset($viewSpec['include']))
        {
            $obj['_id'] = $source['_id'];
            foreach ($viewSpec['include'] as $p)
            {
                if(isset($source[$p]))
                {
                    $obj[$p] = $source[$p];
                }
                if($p === INCLUDE_RDF_SEQUENCE)
                {
                    if ($source['rdf:type'])
                    {
                        foreach($source['rdf:type'] as $u => $t)
                        {
                            if (is_array($t) == false)
                            {
                                $t = array($u => $t);
                            }
                            foreach($t as $typeOfType => $type)
                            {
                                if ($typeOfType === 'u' && $type === 'rdf:Seq')
                                {
                                    $seqNumber = 1;
                                    $found = true;
                                    while($found)
                                    {
                                        if (isset($source['rdf:_'.$seqNumber]))
                                        {
                                            $obj['rdf:_'.$seqNumber] = $source['rdf:_'.$seqNumber];
                                            $seqNumber++;
                                        }
                                        else
                                        {
                                            $found = false;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (isset($viewSpec['joins']))
            {
                foreach ($viewSpec['joins'] as $p=>$join)
                {
                    if (isset($join['maxJoins']))
                    {
                        // todo: refactor with below (extract method)
                        // only include up to maxJoins
                        for ($i=0;$i<$join['maxJoins'];$i++)
                        {
                            if(isset($source[$p]) && (isset($source[$p][VALUE_URI]) || isset($source[$p][VALUE_LITERAL])) && $i==0) // cater for source with only one val
                            {
                                $obj[$p] = $source[$p];
                            }
                            if(isset($source[$p]) && isset($source[$p][$i]))
                            {
                                if (!isset($obj[$p])) $obj[$p] = [];
                                $obj[$p][] = $source[$p][$i];
                            }
                        }
                    }
                    else if(isset($source[$p]))
                    {
                        $obj[$p] = $source[$p];
                    }
                }
            }
        }
        else
        {
            foreach($source as $p=>$val)
            {
                if (isset($viewSpec['joins']) && isset($viewSpec['joins'][$p]) && isset($viewSpec['joins'][$p]['maxJoins']))
                {
                    // todo: refactor with above (extract method)
                    // only include up to maxJoins
                    for ($i=0;$i<$viewSpec['joins'][$p]['maxJoins'];$i++)
                    {
                        if($val && (isset($val[VALUE_URI]) || isset($val[VALUE_LITERAL])) && $i==0) // cater for source with only one val
                        {
                            $obj[$p] = $val;
                        }
                        if($val && isset($val[$i]))
                        {
                            if (!$obj[$p]) $obj[$p] = [];
                            $obj[$p][] = $val[$i];
                        }
                    }
                }
                else
                {
                    $obj[$p] = $val;
                }
            }
        }

        // process count aggregate function
        if (isset($viewSpec['counts']))
        {
            foreach ($viewSpec['counts'] as $predicate=>$c)
            {
                if (isset($c['filter'])) // run a db filter
                {
                    $collection = (isset($c['from'])
                        ? $this->config->getCollectionForCBD($this->storeName, $c['from'])
                        : $this->config->getCollectionForCBD($this->storeName, $from)
                    );
                    $query = $c['filter'];
                    $query[$c['property'].'.'.VALUE_URI] = $source['_id'][_ID_RESOURCE]; //todo: how does graph restriction work here?
                    $obj[$predicate] = array(VALUE_LITERAL=>$collection->count($query).''); // make sure it's a string
                }
                else // just look for property in current source...
                {
                    $count = 0;
                    // just count predicates at current location
                    if (isset($source[$c['property']]))
                    {
                        if (isset($source[$c['property']][VALUE_URI]) || isset($source[$c['property']][VALUE_LITERAL]))
                        {
                            $count = 1;
                        }
                        else
                        {
                            $count = count($source[$c['property']]);
                        }
                    }
                    $obj[$predicate] = array(VALUE_LITERAL=>(string)$count);
                }
            }
        }

        return $obj;
    }
238061
public function addPageContent(\Haven\CmsBundle\Entity\PageContent $pageContents) {
        $this->page_contents[] = $pageContents;

        return $this;
    }
894598
private function parseTemplateVars($templateContainer)
    {
        $returnArray = [];

        foreach ($templateContainer->getTemplateVars() as $key => $value) {
            switch ($key) {
                case 'order':
                    $this->parseOrderVars($key, $value, $returnArray);
                    break;
                case 'invoice':
                    $this->parseInvoiceVars($key, $value, $returnArray);
                    break;
                case 'creditmemo':
                    $this->parseCreditmemoVars($key, $value, $returnArray);
                    break;
            }
        }

        return $returnArray;
    }
801113
protected function loadTemplate( $path, array $vars = [] ) {
		try {
			return \Pressbooks\Utility\template( $path, $vars );
		} catch ( \Exception $e ) {
			if ( WP_DEBUG ) {
				return "File not found: {$path}";
			} else {
				return '';
			}
		}
	}
422965
public static function SetTemplates ($templates = []) {
		if (gettype(static::$templates) == 'array') {
			static::$templates = (array) $templates;
		} else {
			static::$templates = (object) $templates;
		}
		return static::$templates;
	}
662727
private function getTemplateFieldTemplates(ContentType $contentType, Content $content)
    {
        $templateFieldTemplates = [];
        $templateFieldsConfig = $this->config->get('theme/templatefields');

        if ($templateFieldsConfig) {
            $templateFieldTemplates = array_keys($templateFieldsConfig);
            // Special case for default template
            $toRepair = [];
            foreach ($contentType['fields'] as $name => $field) {
                if ($field['type'] === 'templateselect' && !empty($content->values[$name])) {
                    $toRepair[$name] = $content->values[$name];
                    $content->set($name, '');
                }
            }
            if ($content->hasTemplateFields()) {
                $templateFieldTemplates[] = '';
            }

            foreach ($toRepair as $name => $value) {
                $content->set($name, $value);
            }
        }

        return $templateFieldTemplates;
    }
875426
public function replaceContents($contents)
    {
        preg_match_all('/{{(.*)}}/', $contents, $matches);

        foreach ($matches[0] as $key => $match) {
            if (!empty($match)) {
                if (($resolved = $this->resolveVariable($matches[1][$key])) !== Constants::NOT_RESOLVED) {
                    $contents = str_replace($matches[0][$key], $resolved, $contents);
                }
            }
        }

        return $contents;
    }
219002
public function parse($contents, $includeDefaults = false)
    {
        $old_libxml_error = libxml_use_internal_errors(true);
        
        $dom = new DOMDocument;
        
        if(@$dom->loadHTML($contents) === false) {
            throw new RuntimeException("Contents is empty");
        }
        
        libxml_use_internal_errors($old_libxml_error);

        foreach($dom->getElementsByTagName('meta') as $tag) {
            if($includeDefaults && $tag->hasAttribute('name') && $tag->hasAttribute('content') && $tag->getAttribute('name') == 'description') {
                $this->addMeta('non-og-description', $tag->getAttribute('content'), self::APPEND);
            } else if($tag->hasAttribute('property') && $tag->hasAttribute('content')) {
                $this->addMeta($tag->getAttribute('property'), $tag->getAttribute('content'), self::APPEND);
            }
        }

        if($includeDefaults) {
            $titles = $dom->getElementsByTagName('title');
            if ($titles->length > 0) {
                $this->addMeta('non-og-title', $titles->item(0)->textContent, self::APPEND);
            }
        }

        unset($dom);
        
        return $this;
    }
523488
protected function getContentObjectVariables(array $conf = array())
    {
        // Call Parent Function to maintain core functions
        $variables = parent::getContentObjectVariables($conf);

        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
        $this->inlineHelper = $objectManager->get(InlineHelper::class);

        // Make some enhancements to data
        $data = $variables['data'];
        $this->inlineHelper->addFilesToData($data, "pages");
        $this->inlineHelper->addIrreToData($data, "pages");
        $variables['data'] = $data;

        return $variables;
    }
864645
protected function getContent($contentTypeSlug, array $contentParameters, ListingOptions $options)
    {
        $contentParameters = array_filter($contentParameters);
        $records = $this->query->getContent($contentTypeSlug, $contentParameters);
        if ($records === null && $options->getPage() !== null) {
            $contentParameters['page'] = $options->getPreviousPage();
            $records = $this->query->getContent($contentTypeSlug, $contentParameters);
        }
        $this->runPagerQueries($records);
        if ($options->getGroupSort() && !$options->getOrder()) {
            $records = $this->runGroupSort($records);
        }

        return $records;
    }