<commit_before><?php
/**
 * This file defines the Render Class
 * Copyright (c) 2009 JadeIT cc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * @license http://www.eclipse.org/legal/epl-v10.html
 * @package Core
 *
 * Contributors:
 * @author <NAME> (JadeIT cc) - initial API and implementation
 */
 
 /**
  * The Render class renders HTML template files.
  *
  */
class Render {
	public static $do_cache = true;

	public static function createTemplate($destination, $origin) {
		$template_file    = self::buildTemplate($origin);
		$template_content = self::evalTemplate($template_file);
		$template_loc     = Backend::getConfig('backend.templates.location', 'templates');
		return file_put_contents(APP_FOLDER . '/' . $template_loc . '/' . $destination, $template_content);
	}

	public static function renderFile($filename, array $values = array()) {
		//Build the template
		$cache_file = self::buildTemplate($filename);
		//Run the PHP in the template
		$toret = self::evalTemplate($cache_file, $values);
		//Parse the #Variables# in the template
		$toret = self::parseVariables($toret, $values);
		return $toret;
	}
	
	/**
	 * This function retrieves the absolute location of a template file
	 *
	 * A template can be defined on three levels (in order of specificity):
	 * + Framework level
	 * + Application level
	 * + Theme level
	 * Should a template not exist on Theme level, the Application level template will be used.
	 * If it does not exist on Application level, the Framework level template will be used.
	 * @todo TODO Consider caching the template locations for faster lookups?
	 */
	public static function checkTemplateFile($filename) {
		$toret = false;
		$template_loc = Backend::getConfig('backend.templates.location', 'templates');
		if (Component::isActive('Theme')) {
			$theme = Theme::get();<commit_msg>Dont create template files when in production<commit_after><?php
/**
 * This file defines the Render Class
 * Copyright (c) 2009 JadeIT cc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * @license http://www.eclipse.org/legal/epl-v10.html
 * @package Core
 *
 * Contributors:
 * @author <NAME> (JadeIT cc) - initial API and implementation
 */
 
 /**
  * The Render class renders HTML template files.
  *
  */
class Render {
	public static $do_cache = true;

	public static function createTemplate($destination, $origin) {
		$template_file    = self::buildTemplate($origin);
		$template_content = self::evalTemplate($template_file);
		$template_loc     = Backend::getConfig('backend.templates.location', 'templates');
		$dest_file        = APP_FOLDER . '/' . $template_loc . '/' . $destination;
		if (file_put_contents($dest_file, $template_content)) {
			if (SITE_STATE != 'production') {
				chmod($dest_file, 0664);
			}
			return true;
		}
		return false;
	}

	public static function renderFile($filename, array $values = array()) {
		//Build the template
		$cache_file = self::buildTemplate($filename);
		//Run the PHP in the template
		$toret = self::evalTemplate($cache_file, $values);
		//Parse the #Variables# in the template
		$toret = self::parseVariables($toret, $values);
		return $toret;
	}
	
	/**
	 * This function retrieves the absolute location of a template file
	 *
	 * A template can be defined on three levels (in order of specificity):
	 * + Framework level
	 * + Application level
	 * + Theme level
	 * Should a template not exist on Theme level, the Application level template will be used.
	 * If it does not exist on Application level, the Framework level template will be used.
	 * @todo TODO Consider caching the template locations for faster lookups?
	 */
	public static function checkTemplateFile($filename) {
		$toret = false;
		$template_loc = Backend::getConfig('backend.templates.location', 'templates');
		if (Component::isActive('Theme')) {
			$theme = Theme::get();
{'fraction_non_alphanumeric': 0.11202317720907774, 'fraction_numerical': 0.004828585224529213, 'mean_word_length': 4.152985074626866, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1166406', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1136, 'n_words': 410}