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

class Pages extends Public_Controller {

    function __construct() 
    {
        parent::Public_Controller();
        
        $this->load->model('pages_m');
    }

    function _remap()
    {
    	// This basically keeps links to /home always pointing to the actual homepage even when the default_controller is changed
		@include(APPPATH.'/config/routes.php'); // simple hack to get the default_controller, could find another way.
		
		$slug = implode('--', $this->uri->segment_array());

		// The default route is set to a different module than pages. Send them to there if they come looking for the homepage
		if(!empty($route) && $slug == 'home' && $route['default_controller'] != 'pages')
		{
			redirect('');
		}
		
		// Default route = pages
		else
		{
			// Show the requested page with all segments available
			call_user_func(array($this, 'page'), $slug);
		}
    }
    
    
    function page($slug = 'home')
    {
    	// No data, and its not the home page
        if(!$page = $this->cache->model('pages_m', 'getBySlug', array($slug, DEFAULT_LANGUAGE)) )
        {
        	show_404();
        }
        
        // Parse any settings, links or url tags
        $this->load->library('parser');
        $page->body = $this->parser->string_parse($page->body);
        
        // Not got a meta title? Use slogan for homepage or the normal page title for other pages
        if($page->meta_title == '')
        {<commit_msg>bug: Fixed issue #32 - Home page and slug.<commit_after><?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Pages extends Public_Controller {

    function __construct() 
    {
        parent::Public_Controller();
        
        $this->load->model('pages_m');
    }

    function _remap()
    {

	$slug = $this->uri->segment(1, 'home');

    	// This basically keeps links to /home always pointing to the actual homepage even when the default_controller is changed
		@include(APPPATH.'/config/routes.php'); // simple hack to get the default_controller, could find another way.
		
		// The default route is set to a different module than pages. Send them to there if they come looking for the homepage
		if(!empty($route) && $slug == 'home' && $route['default_controller'] != 'pages')
		{
			redirect('');
		}
		
		// Default route = pages
		else
		{
			// Show the requested page with all segments available
			call_user_func(array($this, 'page'), $slug);
		}
    }
    
    
    function page($slug = 'home')
    {
    	// No data, and its not the home page
        if(!$page = $this->cache->model('pages_m', 'getBySlug', array($slug, DEFAULT_LANGUAGE)) )
        {
        	show_404();
        }
        
        // Parse any settings, links or url tags
        $this->load->library('parser');
        $page->body = $this->parser->string_parse($page->body);
        
        // Not got a meta title? Use slogan for homepage or the normal page title for other pages
        if($page->meta_title == '')
        {
{'fraction_non_alphanumeric': 0.13368112161721551, 'fraction_numerical': 0.0029344636452559502, 'mean_word_length': 2.5799299883313886, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, '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': '2486626', 'n_tokens_mistral': 926, 'n_tokens_neox': 870, 'n_words': 283}