<commit_before><?php

abstract class Decoy_Base_Controller extends Controller {
	
	//---------------------------------------------------------------------------
	// Default settings
	//---------------------------------------------------------------------------
	
	// Everything should be restful
	public $restful = true;
	
	// Shared layout for admin view, set in the constructor
	public $layout;
	
	// Default pagination settings
	protected $PER_PAGE = 20;
	const PER_PAGE_SIDEBAR = 6;
	
	// Values that get shared by many controller methods.  Default values for these
	// get set in the constructor.
	protected $MODEL;       // i.e. Post
	protected $CONTROLLER;  // i.e. admin.posts
	protected $TITLE;       // i.e. News Posts
	protected $DESCRIPTION; // i.e. Relevant news about the brand
	protected $COLUMNS = array('Title' => 'title'); // The default columns for listings
	protected $SHOW_VIEW;   // i.e. admin.news.show
	protected $SEARCH;      // i.e. An array describing the fields to search upon
	
	// More of the same, but these are just involved in relationships
	protected $PARENT_MODEL;      // i.e. Photo
	protected $PARENT_CONTROLLER; // i.e. admin.photos
	protected $PARENT_TO_SELF;    // i.e. photos
	protected $SELF_TO_PARENT;    // i.e. post
	
	// Special constructor behaviors
	function __construct() {

		// Set the layout from the Config file
		$this->layout = Config::get('decoy::decoy.layout');
		
		// Get the controller name only, without the namespace (like Admin_) or
		// suffix (like _Controller).  I..e, Admin_News_Posts_Controller becomes
		// 'News_Posts'
		preg_match('#^[^_]+_(.+)_[^_]+$#', get_class($this), $matches);
		$controller_name = $matches[1];
				
		// Make a default title based on the controller name
		if (empty($this->TITLE)) {
			$this->TITLE = str_replace('_', ' ', $controller_name);
		}
		
		// Figure out what the controller get should be.
		// i.e. 'Admin_News_Posts_Controller' becomes 'admin.news_posts';
		if (empty($this->CONTROLLER)) {
			$this->CONTROLLER = preg_replace('#_#', '.', strtolower(substr(get_class($this), 0, -11)), 1);
			
			// If it begins with decoy, it should be like decoy::admin instead of decoy.admin
			if (Str::is('decoy*', $this->CONTROLLER)) $this->CONTROLLER = str_replace('decoy.', 'decoy::', $this->CONTROLLER);
		}
		
		// Figure out what the show view should be.  This is the path to the show view file.  Such
		// as 'admin.news.show'
		if (empty($this->SHOW_VIEW)) $this->SHOW_VIEW = $this->CONTROLLER.'.show';
		<commit_msg>Making the controller name regexp more specific.  And making it not fail if the controller isn't in a subdirectory.  Like if you have a frontend controller that extends the base controller<commit_after><?php

abstract class Decoy_Base_Controller extends Controller {
	
	//---------------------------------------------------------------------------
	// Default settings
	//---------------------------------------------------------------------------
	
	// Everything should be restful
	public $restful = true;
	
	// Shared layout for admin view, set in the constructor
	public $layout;
	
	// Default pagination settings
	protected $PER_PAGE = 20;
	const PER_PAGE_SIDEBAR = 6;
	
	// Values that get shared by many controller methods.  Default values for these
	// get set in the constructor.
	protected $MODEL;       // i.e. Post
	protected $CONTROLLER;  // i.e. admin.posts
	protected $TITLE;       // i.e. News Posts
	protected $DESCRIPTION; // i.e. Relevant news about the brand
	protected $COLUMNS = array('Title' => 'title'); // The default columns for listings
	protected $SHOW_VIEW;   // i.e. admin.news.show
	protected $SEARCH;      // i.e. An array describing the fields to search upon
	
	// More of the same, but these are just involved in relationships
	protected $PARENT_MODEL;      // i.e. Photo
	protected $PARENT_CONTROLLER; // i.e. admin.photos
	protected $PARENT_TO_SELF;    // i.e. photos
	protected $SELF_TO_PARENT;    // i.e. post
	
	// Special constructor behaviors
	function __construct() {

		// Set the layout from the Config file
		$this->layout = Config::get('decoy::decoy.layout');
		
		// Get the controller name only, without the namespace (like Admin_) or
		// suffix (like _Controller).  I..e, Admin_News_Posts_Controller becomes
		// 'News_Posts'
		preg_match('#^(?:Admin_)?(.+)_Controller$#', get_class($this), $matches);
		$controller_name = $matches[1];
				
		// Make a default title based on the controller name
		if (empty($this->TITLE)) {
			$this->TITLE = str_replace('_', ' ', $controller_name);
		}
		
		// Figure out what the controller get should be.
		// i.e. 'Admin_News_Posts_Controller' becomes 'admin.news_posts';
		if (empty($this->CONTROLLER)) {
			$this->CONTROLLER = preg_replace('#_#', '.', strtolower(substr(get_class($this), 0, -11)), 1);
			
			// If it begins with decoy, it should be like decoy::admin instead of decoy.admin
			if (Str::is('decoy*', $this->CONTROLLER)) $this->CONTROLLER = str_replace('decoy.', 'decoy::', $this->CONTROLLER);
		}
		
		// Figure out what the show view should be.  This is the path to the show view file.  Such
		// as 'admin.news.show'
		if (empty($this->SHOW_VIEW)) $this->SHOW_VIEW = $this->CONTROLLER.'.show';
		
{'fraction_non_alphanumeric': 0.1826536473291212, 'fraction_numerical': 0.0030633735401110473, 'mean_word_length': 2.6353514265831595, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '4698066', 'n_tokens_mistral': 1718, 'n_tokens_neox': 1554, 'n_words': 508}