Compile the content element

@return void
351457
public function compile()
	{
		if (TL_MODE == 'BE') {
			$this->strTemplate = 'be_wildcard';
			$this->Template = new \BackendTemplate($this->strTemplate);
			$this->Template->title = $this->headline;
		}
		else {
			$this->Template = new \FrontendTemplate($this->strTemplate);
			$this->Template->setData($this->arrData);
		}
	}
116495
public function generate()
	{		
		// Get the content element object
		$this->objElement = \ElementsModel::findPublishedByAlias($this->type);

		if ($this->objElement === null)
		{
			return;
		}

		// Register the custom template
		if (!array_key_exists($this->objElement->template, TemplateLoader::getFiles()))
		{
			TemplateLoader::addFile($this->objElement->template, $this->objElement->getRelated('pid')->templates);
		}

		if (TL_MODE == 'BE' && $this->objElement->backendTpl)
		{
			$this->strTemplate = $this->objElement->backendTpl;
		}
		else
		{
			$this->strTemplate = $this->objElement->template;
		}
				
		if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && ($this->invisible || ($this->start != '' && $this->start > time()) || ($this->stop != '' && $this->stop < time())))
		{
			return '';
		}

		$this->Template = new Template($this->strTemplate);
	
		// Deliver some general element data
		$this->Template->setData(
			array (
				'id' => $this->id,
				'pid' => $this->pid,
				'ptable' => $this->ptable,
				'element' => $this->type,
				'tstamp' => $this->tstamp,
				'start' => $this->start,
				'stop' => $this->stop,
				'protected' => $this->protected,
				'inColumn' => $this->strColumn
			)
		);

		// compile pattern to prepare values
		$this->compile();
		
		return $this->Template->parse();
	}
655408
protected function outputContent()
    {
        foreach ($this->_html as $part) {
            if ($part instanceof Element) {
                $part->output();
            } else {
                echo $part;
            }
        }
    }
917861
private function compile() : void
    {
        $this->isCompiled = true;

        if ($this->type === self::TYPE_SIMPLE) {
            $this->compileSimpleTable();
        } else {
            $this->compilePrettyTable();
        }
    }
1174255
private function compile()
    {
        // replace pseudo {param}:type syntax to valid regex
        if (strpos($this->regex, '}:') !== false) {
            $this->regex = preg_replace('#\{([a-zA-Z0-9_-]+)\}:([a-z]+)#', '(?P<$1>:$2)', $this->expression);
            $this->regex = str_replace(
                array_keys($this->regexExpression),
                array_values($this->regexExpression),
                $this->regex
            );
        }

        // replace pseudo {param} syntax without type to valid regex
        if (strpos($this->regex, '}') !== false) {
            $this->regex = preg_replace('#\{([a-zA-Z_]+)\}#', '(?P<$1>[^\/]+)', $this->regex);
        }

        // allow optional trailing slash at the end
        if (substr($this->regex, -1) !== '/') {
            $this->regex .= '[\/]?';
        }
    }
481288
protected function compile()
    {
        $attributes = new Attributes();

        $this->setLinkTitle($attributes);
        $this->setHref($attributes);
        $this->setCssClass($attributes);
        $this->enableLightbox($attributes);
        $this->setDataAttributes($attributes);

        // Override the link target
        if ($this->target) {
            $attributes->setAttribute('target', '_blank');
        }

        if ($this->bootstrap_icon) {
            $this->Template->icon = Bootstrap::generateIcon($this->bootstrap_icon);
        }

        $this->Template->attributes = $attributes;
        $this->Template->link       = $this->linkTitle;
    }
802110
public function renderContentBegin()
    {
        echo CHtml::openTag('div', $this->htmlContentOptions);
        if (!empty($this->content)) {
            echo $this->content;
        }
    }
214650
protected function compile()
    {
        $this->Template->trigger           = $this->mobile_menu_trigger;
        $this->Template->html              = $this->mobile_menu_html;
        $this->Template->position          = $this->mobile_menu_position;
        $this->Template->size              = (int)$this->mobile_menu_size;
        $this->Template->overlay           = $this->mobile_menu_overlay;
        $this->Template->offCanvas         = $this->mobile_menu_offCanvas;
        $this->Template->animation         = $this->mobile_menu_animation;
        $this->Template->animationSpeed    = (int)$this->mobile_menu_animationSpeed;
        $this->Template->mediaQuery        = $this->mobile_menu_mediaQuery;
        $this->Template->noShadow          = $this->mobile_menu_noShadow;
        $this->Template->disableNavigation = $this->mobile_menu_disableNavigation;
        $this->Template->parentTogglers    = $this->mobile_menu_parentTogglers;
        $this->Template->closeOnLinkClick  = $this->mobile_menu_closeOnLinkClick;
        $this->Template->keepInPlace       = $this->mobile_menu_keepInPlace;

        $breakPoint = 0;

        // Display on phones
        if ($this->mobile_menu_phones) {
            $breakPoint = 767;
        }

        // Display on tablets
        if ($this->mobile_menu_tablets) {
            $breakPoint = 991;
        }

        // Set a custom break point
        if ($this->mobile_menu_breakpoint) {
            $breakPoint = (int)$this->mobile_menu_breakpoint;
        }

        $this->Template->breakPoint = $breakPoint;

        $this->addMobileMenuAssets();
    }
667859
public function compile()
	{
		if ($this->multiArticle)
		{
			$objArticles = \ArticleModel::findMultipleByIds(\StringUtil::deserialize($this->data->multiArticle));

			// Return if there are no pages
			if ($objArticles === null)
			{
				return;
			}

			$arrArticles = array();

			// Sort the array keys according to the given order
			if ($this->data->orderArticle != '')
			{
				$tmp = \StringUtil::deserialize($this->data->orderArticle);

				if (!empty($tmp) && is_array($tmp))
				{
					$arrArticles = array_map(function () {}, array_flip($tmp));
				}
			}

			// Add the items to the pre-sorted array
			while ($objArticles->next())
			{
				$arrArticles[$objArticles->id] = $objArticles->row();
			}

			$arrArticles = array_values(array_filter($arrArticles));
			
			$this->writeToTemplate($arrArticles);

			}
		else
		{
			if (($objArticle = \ArticleModel::findById($this->data->singleArticle)) !== null)
			{
				$this->writeToTemplate($objArticle->row());
			}
		}
	}
974173
public function compile()
    {
        // Path prefix
        $prefix = $this->getNewPrefix();
        // List of images
        $data = $this->getList();

        // sizes
        $sizes = [];
        foreach ($this->providers as $provider) {
            if ($provider instanceof SizeProviderInterface) {
                $sizes = array_merge($sizes, $provider->getSizes());
            }
        }

        $num = 0;
        $scss = [];
        foreach ($data as $name => $list) {
            // Sprite size
            $size = !isset($sizes[$name]) ? null : $sizes[$name];
            $size = $this->getSize($name, $size);
            if (is_array($size)) {
                $border = $size[1];
                $sizeH = isset($size[2]) ? $size[2] : $size[0];
                $sizeW = $size[0];
            } else {
                $border = static::BORDER_WIDTH;
                $sizeH = $sizeW = $size;
            }
            $scss[] = $this->compileFile($prefix, $name, $list, [$sizeW, $sizeH], $border);
            $num += count($list);
        }

        // Populating template
        $template = file_get_contents($this->template);
        $scss = str_replace(
            static::TEMPLATE_NEEDLE, join("\n", $scss), $template
        );

        // Creating global classes
        if (static::CREATE_CLASSES) {
            foreach ($data as $name => $list) {
                $scss .= '.#{$' . static::NAMESPACE_NAME . '}';
                $scss .= ', .#{$' . static::NAMESPACE_NAME . '}-' . $name . ' {' . "\n";
                $scss .= '@include ' . static::PREFIX_SPRITE . $name . ';' . "\n";
                $scss .= '};' . "\n";
            }
        }

        // Writing the file
        file_put_contents($this->stylePath, $scss);

        return $num;
    }
1101080
protected function compile() {
        $intSubject = $this->arrData['wb_subject'];

        // get general information about the subject
        $objSubjectResult = $this->Database->prepare('SELECT * FROM tl_subject WHERE id = ?')
                ->limit(1)
                ->execute($intSubject);

        $arrSubject = $objSubjectResult->fetchAssoc();
        $intHeadTeacher = $arrSubject['headTeacher'];
        $this->Template->name = $arrSubject['name'];
        $this->Template->abbreviation = $arrSubject['abbreviation'];
        $this->Template->faculty = $GLOBALS['TL_LANG']['tl_subject']['faculties'][$arrSubject['faculty']];
        $this->Template->rooms = $arrSubject['rooms'];


        // get all the subjects teachers
        $arrTeachers = array();
        $objTeacherResult = $this->Database->prepare('SELECT * FROM tl_member WHERE teacher = 1 ORDER BY lastname, firstname')
                ->execute();

        while ($arrTeacher = $objTeacherResult->fetchAssoc()) {
            $subjects = deserialize($arrTeacher['subjects']);
            if (is_array($subjects) && in_array($intSubject, $subjects)) {
                $arrTeacher['name'] = WBGym::teacherToString($arrTeacher);
                $arrTeacher['isHeadTeacher'] = $arrTeacher['id'] == $intHeadTeacher;
                $arrTeacher['subjects'] = $subjects;

                if ($arrTeacher['isHeadTeacher']) {
                    array_unshift($arrTeachers, $arrTeacher);
                    $this->Template->headTeacher = $arrTeacher;
                } else {
                    $arrTeachers[] = $arrTeacher;
                }
            }
        }

        $this->Template->teachers = $arrTeachers;
    }
593766
public function compile()
    {
        $requestHandler = $this->getRequestHandler();

        $encodedData = $this->encodeData($this->getParams());
        $requestHandler->setRawBody($encodedData);

        $response = $requestHandler->send();
        $xml = new \SimpleXMLElement($response->getBody());
        $data = $this->parseXml($xml);

        return $this->buildResponse($data);
    }
664797
protected function compile()
    {
        $config  = StringUtil::deserialize($this->bs_navbarModules, true);
        $modules = [];
        $models  = $this->prefetchModules($config);

        foreach ($config as $module) {
            $id = $module['module'];

            if ($id != '' && !$module['inactive'] && array_key_exists($id, $models)) {
                $modules[] = $this->generateModule($module, $models[$id]);
            }
        }

        $cssID = $this->cssID;

        if ($this->cssID[1] == '') {
            $cssID[1] = 'navbar-light bg-light';
        }

        if ($this->bs_isResponsive && $this->bs_toggleableSize) {
            $cssID[1] = trim($cssID[1] . ' navbar-expand-' . $this->bs_toggleableSize);
        }

        $this->cssID             = $cssID;
        $this->Template->modules = $modules;
    }
997382
protected function doCompile($_content)
    {
        /* here is where the compiling takes place. Smarty
          tags in the templates are replaces with PHP code,
          then written to compiled files. */
        // init the lexer/parser to compile the template
        $this->lex = new $this->lexer_class($_content, $this);
        $this->parser = new $this->parser_class($this->lex, $this);
        if ($this->inheritance_child) {
            // start state on child templates
            $this->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBODY);
        }
        if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
            $mbEncoding = mb_internal_encoding();
            mb_internal_encoding('ASCII');
        } else {
            $mbEncoding = null;
        }

        if ($this->smarty->_parserdebug) {
            $this->parser->PrintTrace();
            $this->lex->PrintTrace();
        }
        // get tokens from lexer and parse them
        while ($this->lex->yylex() && !$this->abort_and_recompile) {
            if ($this->smarty->_parserdebug) {
                echo "<pre>Line {$this->lex->line} Parsing  {$this->parser->yyTokenName[$this->lex->token]} Token " .
                    htmlentities($this->lex->value) . "</pre>";
            }
            $this->parser->doParse($this->lex->token, $this->lex->value);
        }

        if ($this->abort_and_recompile) {
            // exit here on abort
            return false;
        }
        // finish parsing process
        $this->parser->doParse(0, 0);
        if ($mbEncoding) {
            mb_internal_encoding($mbEncoding);
        }
        // check for unclosed tags
        if (count($this->_tag_stack) > 0) {
            // get stacked info
            list($openTag, $_data) = array_pop($this->_tag_stack);
            $this->trigger_template_error("unclosed {$this->smarty->left_delimiter}" . $openTag . "{$this->smarty->right_delimiter} tag");
        }
        // return compiled code
        // return str_replace(array("? >\n<?php","? ><?php"), array('',''), $this->parser->retvalue);
        return $this->parser->retvalue;
    }
1292048
public function content()
    {
        if ($this->app->getMatchRoute()) {
            $actionName = strtolower(preg_replace('/(?<=\d)(?=[A-Za-z])|(?<=[A-Za-z])(?=\d)|(?<=[a-z])(?=[A-Z])/', '-', $this->app->getActionName()));

            $fileArray = [
                strtolower($this->app->getModuleName()),
                str_replace('controller', '', strtolower($this->app->getControllerName())),
                $actionName . '.phtml'
            ];

            $file = implode('/', $fileArray);
        } else {
            $viewManager = $this->config->get('view_manager');
            $file = $viewManager['template_map']['error/404'];
        }

        $this->render($file);
    }
1158501
protected function renderContent() {
        
        $table_id = $this->data->get('table_id');
        ?>        
        <ol class="breadcrumb small">
        	<li><a href="admin.php"><?php echo I18N::translate('Control panel'); ?></a></li>
			<li><a href="admin_modules.php"><?php echo I18N::translate('Module administration'); ?></a></li>
			<li class="active"><?php echo $this->data->get('title'); ?></li>
		</ol>
		
		<h1><?php echo $this->data->get('title'); ?></h1>
		
		<p><?php echo I18N::translate('The administration tasks are meant to be run at a regular interval - or as regularly as possible.'); ?></p>
		<p>
			<?php echo I18N::translate('It is sometimes necessary to force the execution of a task.'); ?><br />
			<?php echo I18N::translate('In order to do so, use the following URL, with the optional parameter <em>%s</em> if you only want to force the execution of one task: ', 'task'); ?>
		</p>
		<p>
			<code><?php echo $this->data->get('trigger_url_root') .'&force=<span id="token_url">'. $this->data->get('trigger_token') .'</span>[&task='. I18N::translate('task_name').']'; ?></code>
		</p>
		<p>
			<button id="bt_genforcetoken" class="bt bt-primary" onClick="generate_force_token();">
				<div id="bt_tokentext"><?php echo I18N::translate('Regenerate token'); ?></div>
			</button>
		</p>

		<table id="<?php echo $table_id; ?>" class="table table-condensed table-bordered">
    		<thead>
    			<tr>
    				<th><?php echo I18N::translate('Edit'); ?></th>
    				<th><!-- task name --></th>
    				<th><?php echo I18N::translate('Enabled'); ?></th>
    				<th><?php echo I18N::translate('Task name'); ?></th>
    				<th><?php echo I18N::translate('Last success'); ?></th>
    				<th><?php echo I18N::translate('Last result'); ?></th>
    				<th><?php echo I18N::translate('Frequency'); ?></th>
    				<th><?php echo I18N::translate('Remaining occurrences'); ?></th>    				
    				<th><?php echo I18N::translate('Is running?'); ?></th>			
    				<th><?php echo I18N::translate('Run task'); ?></th>
    			</tr>
    		</thead>
    		<tbody>
    		</tbody>
    	</table>
		
		<?php        
    }
337900
function compile( $compiled_template_filename = '' )
		{
			if (empty($this->template))
			{
				return;
			}
			/* Quick hack to allow subtemplates */
			if(eregi("<!-- INCLUDE", $this->template))
			{
				while ($this->count_subtemplates() > 0)
				{
					preg_match_all('/<!-- INCLUDE ([a-zA-Z0-9_.]+) -->/', $this->template, $tvar);
					foreach($tvar[1] as $subfile)
					{
						if(file_exists($this->template_dir . "/$subfile"))
						{
							$subst = implode('',file($this->template_dir . "/$subfile"));
						}
						else
						{
							$subst = 'SmartTemplate Parser Error: Subtemplate not found: \''.$subfile.'\'';
						}
						$this->template = str_replace("<!-- INCLUDE $subfile -->", $subst, $this->template);
					}
				}
			}
			//	END, ELSE Blocks
			$page  =  preg_replace("/<!-- ENDIF.+?-->/",  "<?php\n}\n?>",  $this->template);
			$page  =  preg_replace("/<!-- END[ a-zA-Z0-9_.]* -->/",  "<?php\n}\n\$_obj=\$_stack[--\$_stack_cnt];}\n?>",  $page);
			$page  =  str_replace("<!-- ELSE -->",  "<?php\n} else {\n?>",  $page);

			//	'BEGIN - END' Blocks
			if (preg_match_all('/<!-- BEGIN ([a-zA-Z0-9_.]+) -->/', $page, $var))
			{
				foreach ($var[1] as $tag)
				{
					list($parent, $block)  =  $this->var_name($tag);
					$code  =  "<?php\n"
							. "if (!empty(\$$parent"."['$block'])){\n"
							. "if (!is_array(\$$parent"."['$block']))\n"
							. "\$$parent"."['$block']=array(array('$block'=>\$$parent"."['$block']));\n"
							. "\$_tmp_arr_keys=array_keys(\$$parent"."['$block']);\n"
							. "if (\$_tmp_arr_keys[0]!='0')\n"
							. "\$$parent"."['$block']=array(0=>\$$parent"."['$block']);\n"
							. "\$_stack[\$_stack_cnt++]=\$_obj;\n"
							. "foreach (\$$parent"."['$block'] as \$rowcnt=>\$$block) {\n"
							. "\$$block"."['ROWCNT']=\$rowcnt;\n"
							. "\$$block"."['ALTROW']=\$rowcnt%2;\n"
							. "\$$block"."['ROWBIT']=\$rowcnt%2;\n"
							. "\$_obj=&\$$block;\n?>";
					$page  =  str_replace("<!-- BEGIN $tag -->",  $code,  $page);
				}
			}

			//	'IF nnn=mmm' Blocks
			if (preg_match_all('/<!-- (ELSE)?IF ([a-zA-Z0-9_.]+)[ ]*([!=<>]+)[ ]*(["]?[^"]*["]?) -->/', $page, $var))
			{
				foreach ($var[2] as $cnt => $tag)
				{
					list($parent, $block)  =  $this->var_name($tag);
					$cmp   =  $var[3][$cnt];
					$val   =  $var[4][$cnt];
					$else  =  ($var[1][$cnt] == 'ELSE') ? '} else' : '';
					if ($cmp == '=')
					{
						$cmp  =  '==';
					}
					
					if (preg_match('/"([^"]*)"/',$val,$matches))
					{
						$code  =  "<?php\n$else"."if (\$$parent"."['$block'] $cmp \"".$matches[1]."\"){\n?>";
					}
					elseif (preg_match('/([^"]*)/',$val,$matches))
					{
						list($parent_right, $block_right)  =  $this->var_name($matches[1]);
						$code  =  "<?php\n$else"."if (\$$parent"."['$block'] $cmp \$$parent_right"."['$block_right']){\n?>";
					}
					
					$page  =  str_replace($var[0][$cnt],  $code,  $page);
				}
			}

			//	'IF nnn' Blocks
			if (preg_match_all('/<!-- (ELSE)?IF ([a-zA-Z0-9_.]+) -->/', $page, $var))
			{
				foreach ($var[2] as $cnt => $tag)
				{
					$else  =  ($var[1][$cnt] == 'ELSE') ? '} else' : '';
					list($parent, $block)  =  $this->var_name($tag);
					$code  =  "<?php\n$else"."if (!empty(\$$parent"."['$block'])){\n?>";
					$page  =  str_replace($var[0][$cnt],  $code,  $page);
				}
			}

			//	Replace Scalars
			if (preg_match_all('/{([a-zA-Z0-9_. >]+)}/', $page, $var))
			{
				foreach ($var[1] as $fulltag)
				{
					//	Determin Command (echo / $obj[n]=)
					list($cmd, $tag)  =  $this->cmd_name($fulltag);

					list($block, $skalar)  =  $this->var_name($tag);
					$code  =  "<?php\n$cmd \$$block"."['$skalar'];\n?>\n";
					$page  =  str_replace('{'.$fulltag.'}',  $code,  $page);
				}
			}


			//	ROSI Special: Replace Translations
			if (preg_match_all('/<"([a-zA-Z0-9_.]+)">/', $page, $var))
			{
				foreach ($var[1] as $tag)
				{
					list($block, $skalar)  =  $this->var_name($tag);
					$code  =  "<?php\necho gettext('$skalar');\n?>\n";
					$page  =  str_replace('<"'.$tag.'">',  $code,  $page);
				}
			}


			//	Include Extensions
			$header = '';
			if (preg_match_all('/{([a-zA-Z0-9_]+):([^}]*)}/', $page, $var))
			{
				foreach ($var[2] as $cnt => $tag)
				{
					//	Determin Command (echo / $obj[n]=)
					list($cmd, $tag)  =  $this->cmd_name($tag);

					$extension  =  $var[1][$cnt];
					if (!isset($this->extension_tagged[$extension]))
					{
						$header  .=  "include_once \"smarttemplate_extensions/smarttemplate_extension_$extension.php\";\n";
						$this->extension_tagged[$extension]  =  true;
					}
					if (!strlen($tag))
					{
						$code  =  "<?php\n$cmd smarttemplate_extension_$extension();\n?>\n";
					}
					elseif (substr($tag, 0, 1) == '"')
					{
						$code  =  "<?php\n$cmd smarttemplate_extension_$extension($tag);\n?>\n";
					}
					elseif (strpos($tag, ','))
					{
						list($tag, $addparam)  =  explode(',', $tag, 2);
						list($block, $skalar)  =  $this->var_name($tag);
						if (preg_match('/^([a-zA-Z_]+)/', $addparam, $match))
						{
							$nexttag   =  $match[1];
							list($nextblock, $nextskalar)  =  $this->var_name($nexttag);
							$addparam  =  substr($addparam, strlen($nexttag));
							$code  =  "<?php\n$cmd smarttemplate_extension_$extension(\$$block"."['$skalar'],\$$nextblock"."['$nextskalar']"."$addparam);\n?>\n";
						}
						else
						{
							$code  =  "<?php\n$cmd smarttemplate_extension_$extension(\$$block"."['$skalar'],$addparam);\n?>\n";
						}
					}
					else
					{
						list($block, $skalar)  =  $this->var_name($tag);
						$code  =  "<?php\n$cmd smarttemplate_extension_$extension(\$$block"."['$skalar']);\n?>\n";
					}
					$page  =  str_replace($var[0][$cnt],  $code,  $page);
				}
			}

			//	Add Include Header
			if (isset($header) && !empty($header))
			{
				$page  =  "<?php\n$header\n?>$page";
			}

			//	Store Code to Temp Dir
			if (strlen($compiled_template_filename))
			{
		        if ($hd  =  fopen($compiled_template_filename,  "w"))
		        {
			        fwrite($hd,  $page);
			        fclose($hd);
			        return true;
			    }
			    else
			    {
			    	$this->error  =  "Could not write compiled file.";
			        return false;
			    }
			}
			else
			{
				return $page;
			}
		}