<commit_before><?php defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * CLASS TEMPLATE
 * https://github.com/danieltorscho/CI_Template_lib
 *
 * Simple template library with some core functionalities to simplify development process for CodeIgniter 2.x
 *
 * @package	CodeIgniter
 * @subpackage	CodeIgniter Library
 * @author	<NAME>
 * @copyright	Copyright (c) 2014, DanielTorscho.<EMAIL>
 * @license	The MIT License (MIT) - https://github.com/danieltorscho/CI_Template_lib/blob/master/LICENSE
 * @link	https://github.com/danieltorscho/CI_Template_lib
 *
 * @docs	https://github.com/danieltorscho/CI_Template_lib/blob/master/README.md
 */
class Template{

	/**
	 * CodeIgniter's global object instance holder
	 */
	private $CI;

	/**
	 * Template data array holds the items in an array to access them in subloaded view
	 *
	 * @var array
	 */
	public static $template_data = array();

	/**
	 * Hold the scripts for header
	 *
	 * @var array
	 */
	private $scripts_head = array();

	/**
	 * Hold the scripts for footer
	 *
	 * @var array
	 */
	private $scripts_foot = array();

	/**
	 * Hold an array of stylesheets
	 *
	 * @var array
	 */
	private $stylesheets = array();

	/**
	 * Pagetitle & Pagename holder
	 *
	 * @var    string
	 */
	private $title;

	/**
	 * Segmented array of breadcrumbs
	 *
	 * @var array
	 */
	private $breadcrumbs = array();

	/**
	 * Default template which should be the subview wrapped into
	 *
	 * @var string
	 */
	private $template_default = '';

	/**
	 * @var string Default variable in which the view should be passed to
	 */
	private $content_view = 'tpl_view';

	/**
	 * Default class settings
	 */
	public function __construct()
	{
		// Get a CI Global Instance
		$this->CI =& get_instance();

		// Load neccessary helpers
		$this->CI->load->helper('inflector');

		// Read default js and work them out with script function
		foreach( $this->CI->config->item('tpl_default_js') as $key => $value ){
			$this->script($key, $value);
		}

		// Read default stylesheets from configuration file
		foreach( $this->CI->config->item('tpl_default_css') as $key => $value ){
			$this->css($key, $value);
		}
	}

	/**
	 * Function which populate the template's data. It sets the items so they can be easily
	 * accessed inside the all subloaded view files
	 *
	 * @param string $key   Make the variables accessible inside the subloaded views as: $name
	 * @param mixed  $value Returns a value.
	 *
	 * @return $this
	 */
	public function set_item( $key, $value )
	{
		return self::$template_data[ $key ] = $value;
	}

	/**
	 * @param string $src
	 * @param bool   $header
	 *
	 * @return $this
	 */
	public function script( $src = '', $header = FALSE )
	{

		if( $header === TRUE ){
			$this->scripts_head[ ] = $src;
			$this->set_item('tpl_scripts_head', $this->scripts_head);
		}else{
			$this->scripts_foot[ ] = $src;
			$this->set_item('tpl_scripts_foot', $this->scripts_foot);
		}

	}

	public function css( $src = '', $type = '' )
	{
		$this->stylesheets[ $src ] = $type;
		$this->set_item('tpl_stylesheets', $this->stylesheets);
	}

	/**
	 * Work Pagetitle and Pagename out and creates two variables for shared views
	 *
	 * @param string $string Catches the title, if empty, creates from sitename
	 */
	public function title( $string = '' )
	{
		// Check if string is empty or not
		if( $string == '' ){

			// If method name is index(), then skip concatenating the method name
			if( $this->CI->router->method == 'index' ){
				$this->title = $this->CI->router->class;
			}else{
				$this->title = $this->CI->router->method . ' - ' . $this->CI->router->class;
			}

			// Make newly created title readable
			$this->title = humanize($this->title);

			// Catche the pagetitle at the current state and set it to the pagename
			$this->set_item('tpl_pagename', $this->title);

			// Mix pagetitle with sitename properly
			$this->title = $this->title . $this->CI->config->item('tpl_title_separator') . $this->CI->config->item('tpl_sitename');

			// Set item
			$this->set_item('tpl_pagetitle', $this->title);
		}else{
			// Workout the pagetitle
			$this->title = $string . $this->CI->config->item('tpl_title_separator') . $this->CI->config->item('tpl_sitename');

			// Set item
			$this->set_item('tpl_pagetitle', $this->title);
			$this->set_item('tpl_pagename', $string);
		}<commit_msg>Check for empty sitename config item<commit_after><?php defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * CLASS TEMPLATE
 * https://github.com/danieltorscho/CI_Template_lib
 *
 * Simple template library with some core functionalities to simplify development process for CodeIgniter 2.x
 *
 * @package	CodeIgniter
 * @subpackage	CodeIgniter Library
 * @author	<NAME>
 * @copyright	Copyright (c) 2014, <EMAIL>
 * @license	The MIT License (MIT) - https://github.com/danieltorscho/CI_Template_lib/blob/master/LICENSE
 * @link	https://github.com/danieltorscho/CI_Template_lib
 *
 * @docs	https://github.com/danieltorscho/CI_Template_lib/blob/master/README.md
 */
class Template{

	/**
	 * CodeIgniter's global object instance holder
	 */
	private $CI;

	/**
	 * Template data array holds the items in an array to access them in subloaded view
	 *
	 * @var array
	 */
	public static $template_data = array();

	/**
	 * Hold the scripts for header
	 *
	 * @var array
	 */
	private $scripts_head = array();

	/**
	 * Hold the scripts for footer
	 *
	 * @var array
	 */
	private $scripts_foot = array();

	/**
	 * Hold an array of stylesheets
	 *
	 * @var array
	 */
	private $stylesheets = array();

	/**
	 * Pagetitle & Pagename holder
	 *
	 * @var    string
	 */
	private $title;

	/**
	 * Segmented array of breadcrumbs
	 *
	 * @var array
	 */
	private $breadcrumbs = array();

	/**
	 * Default template which should be the subview wrapped into
	 *
	 * @var string
	 */
	private $template_default = '';

	/**
	 * @var string Default variable in which the view should be passed to
	 */
	private $content_view = 'tpl_view';

	/**
	 * Default class settings
	 */
	public function __construct()
	{
		// Get a CI Global Instance
		$this->CI =& get_instance();

		// Load neccessary helpers
		$this->CI->load->helper('inflector');

		// Read default js and work them out with script function
		foreach( $this->CI->config->item('tpl_default_js') as $key => $value ){
			$this->script($key, $value);
		}

		// Read default stylesheets from configuration file
		foreach( $this->CI->config->item('tpl_default_css') as $key => $value ){
			$this->css($key, $value);
		}
	}

	/**
	 * Function which populate the template's data. It sets the items so they can be easily
	 * accessed inside the all subloaded view files
	 *
	 * @param string $key   Make the variables accessible inside the subloaded views as: $name
	 * @param mixed  $value Returns a value.
	 *
	 * @return $this
	 */
	public function set_item( $key, $value )
	{
		return self::$template_data[ $key ] = $value;
	}

	/**
	 * @param string $src
	 * @param bool   $header
	 *
	 * @return $this
	 */
	public function script( $src = '', $header = FALSE )
	{

		if( $header === TRUE ){
			$this->scripts_head[ ] = $src;
			$this->set_item('tpl_scripts_head', $this->scripts_head);
		}else{
			$this->scripts_foot[ ] = $src;
			$this->set_item('tpl_scripts_foot', $this->scripts_foot);
		}

	}

	public function css( $src = '', $type = '' )
	{
		$this->stylesheets[ $src ] = $type;
		$this->set_item('tpl_stylesheets', $this->stylesheets);
	}

	/**
	 * Work Pagetitle and Pagename out and creates two variables for shared views
	 *
	 * @param string $string Catches the title, if empty, creates from sitename
	 */
	public function title( $string = '' )
	{
		// Check if sitename is available, if not, create a CMS string
		if( $this->CI->config->item('tpl_sitename') == '' ){
			$this->CI->config->set_item('tpl_sitename', 'CMS');
		}

		// Check if string is empty or not
		if( $string == '' ){

			// If method name is index(), then skip concatenating the method name
			if( $this->CI->router->method == 'index' ){
				$this->title = $this->CI->router->class;
			}else{
				$this->title = $this->CI->router->method . ' - ' . $this->CI->router->class;
			}

			// Make newly created title readable
			$this->title = humanize($this->title);

			// Catche the pagetitle at the current state and set it to the pagename
			$this->set_item('tpl_pagename', $this->title);

			// Mix pagetitle with sitename properly
			$this->title = $this->title . $this->CI->config->item('tpl_title_separator') . $this->CI->config->item('tpl_sitename');

			// Set item
			$this->set_item('tpl_pagetitle', $this->title);
		}else{
			// Workout the pagetitle
			$this->title = $string . $this->CI->config->item('tpl_title_separator') . $this->CI->config->item('tpl_sitename');

			// Set item
			$this->set_item('tpl_pagetitle', $this->title);
			$this->set_item('tpl_pagename', $string);
		}
{'fraction_non_alphanumeric': 0.15350827795922964, 'fraction_numerical': 0.0011262529564140106, 'mean_word_length': 3.3253774963468095, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 135, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, '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': '4103510', 'n_tokens_mistral': 3161, 'n_tokens_neox': 2841, 'n_words': 802}