<commit_before><?php
namespace Coxis\Core;

class Controller {
	public function forward404($msg = 'Not found') {
		throw new ControllerException($msg, \Response::setCode(404));
	}
	
	public static function url_for($action, $params=array(), $relative=false) {
		return \URL::url_for(array(static::getControllerName(), $action), $params, $relative);
	}
	
	public static function getControllerName() {
		return preg_replace('/Controller$/', '', get_called_class());
	}
	
	public function canonical($canonical, $relative=true, $redirect=true) {
		if($relative)
			$uri = URL::get();
		else
			$uri = URL::current();
		
		if($redirect && $canonical != $uri)
			throw new ControllerException('Page not found', \Response::setCode(301)->redirect($canonical, $relative));
		if($relative)
			HTML::code('<link rel="canonical" href="'.URL::to($canonical).'">');
		else
			HTML::code('<link rel="canonical" href="'.$canonical.'">');
	}

	public static function hookOn($hookName, $cAction) {
		$cAction = array_values($cAction);
		$controller = $cAction[0];
		$action = $cAction[1];
		\Hook::hookOn($hookName, function($chain, $arg1=null, $arg2=null, $arg3=null, $arg4=null,
			$arg5=null, $arg6=null, $arg7=null, $arg8=null, $arg9=null, $arg10=null) use($controller, $action) {
			$args = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, &$arg7, &$arg8, &$arg9, &$arg10);
			return Router::run($controller, $action, $args);
		});
	}

	public function run($action, $params=array(), $showView=false) {
		$this->view = null;
		if(($actionName=$action) != 'configure')
			$actionName = $action.'Action';
	
		if(!is_array($params))
			$params = array($params);

		ob_start();<commit_msg>corrections from cds<commit_after><?php
namespace Coxis\Core;

class Controller {
	public function forward404($msg = 'Not found') {
		throw new ControllerException($msg, \Response::setCode(404));
	}
	
	public static function url_for($action, $params=array(), $relative=false) {
		return \URL::url_for(array(static::getControllerName(), $action), $params, $relative);
	}
	
	public static function getControllerName() {
		return preg_replace('/Controller$/', '', get_called_class());
	}
	
	public function canonical($canonical, $relative=true, $redirect=true) {
		if($relative)
			$uri = \URL::get();
		else
			$uri = \URL::current();
		
		if($redirect && $canonical != $uri)
			throw new ControllerException('Page not found', \Response::setCode(301)->redirect($canonical, $relative));
		if($relative)
			\HTML::code('<link rel="canonical" href="'.\URL::to($canonical).'">');
		else
			\HTML::code('<link rel="canonical" href="'.$canonical.'">');
	}

	public static function hookOn($hookName, $cAction) {
		$cAction = array_values($cAction);
		$controller = $cAction[0];
		$action = $cAction[1];
		\Hook::hookOn($hookName, function($chain, $arg1=null, $arg2=null, $arg3=null, $arg4=null,
			$arg5=null, $arg6=null, $arg7=null, $arg8=null, $arg9=null, $arg10=null) use($controller, $action) {
			$args = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6, &$arg7, &$arg8, &$arg9, &$arg10);
			return Router::run($controller, $action, $args);
		});
	}

	public function run($action, $params=array(), $showView=false) {
		$this->view = null;
		if(($actionName=$action) != 'configure')
			$actionName = $action.'Action';
	
		if(!is_array($params))
			$params = array($params);

		ob_start();
{'fraction_non_alphanumeric': 0.20612730517549077, 'fraction_numerical': 0.019631171921475312, 'mean_word_length': 5.699203187250996, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '6916720', 'n_tokens_mistral': 1281, 'n_tokens_neox': 1128, 'n_words': 233}