<commit_before><?php

/**
 * A base class handler for URL-based actions.
 *  
 * @package Habari
 **/  
class ActionHandler {
	public $action= '';               // string name of action
	public $handler_vars= array();    // internal array of handler variables (state info)

	/**
	 * All handlers must implement act() to conform to handler API.
	 * This is the default implementation of act(), which attempts
	 * to call a class member method of $this->act_$action().  Any
	 * subclass is welcome to override this default implementation.
	 *
	 * @param string $action the action that was in the URL rule
	 */	 	 	 	 
	public function act($action) {
		$this->action= $action;
		
		$action_method= 'act_' . $action;
		$before_action_method= 'before_' . $action_method;
		$after_action_method= 'after_' . $action_method;
		
		if (method_exists($this, $action_method)) {
			if (method_exists($this, $before_action_method)) {
				$this->$before_action_method();
			}
			Plugins::act( $before_action_method );
			
			$this->$action_method();
			
			Plugins::act( $after_action_method );
			if (method_exists($this, $after_action_method)) {
				$this->$after_action_method();
			}
		}
	}

	/**
	 * Helper method to convert calls to $handler->my_action()
	 * to $handler->act('my_action');
	 * 
	 * @param string $function function name
	 * @param array $args function arguments
	 */
	public function __call($function, $args) {
		$this->handler_vars= array_merge($this->handler_vars, $args);
		return $this->act($function);
	}
	
}

?>
<commit_msg>adding redirect method to actionhandler to allow for redirects<commit_after><?php

/**
 * A base class handler for URL-based actions.
 *  
 * @package Habari
 **/  
class ActionHandler {
	public $action= '';               // string name of action
	public $handler_vars= array();    // internal array of handler variables (state info)

	/**
	 * All handlers must implement act() to conform to handler API.
	 * This is the default implementation of act(), which attempts
	 * to call a class member method of $this->act_$action().  Any
	 * subclass is welcome to override this default implementation.
	 *
	 * @param string $action the action that was in the URL rule
	 */	 	 	 	 
	public function act($action) {
		$this->action= $action;
		
		$action_method= 'act_' . $action;
		$before_action_method= 'before_' . $action_method;
		$after_action_method= 'after_' . $action_method;
		
		if (method_exists($this, $action_method)) {
			if (method_exists($this, $before_action_method)) {
				$this->$before_action_method();
			}
			Plugins::act( $before_action_method );
			
			$this->$action_method();
			
			Plugins::act( $after_action_method );
			if (method_exists($this, $after_action_method)) {
				$this->$after_action_method();
			}
		}
	}

	/**
	 * Helper method to convert calls to $handler->my_action()
	 * to $handler->act('my_action');
	 * 
	 * @param string $function function name
	 * @param array $args function arguments
	 */
	public function __call($function, $args) {
		$this->handler_vars= array_merge($this->handler_vars, $args);
		return $this->act($function);
	}
	
	public function act_redirect()
	{
		$vars = isset($_SERVER['QUERY_STRING']) ? Utils::get_params($_SERVER['QUERY_STRING']) : array();
		Utils::redirect( URL::get(null, $vars) );
		exit;
	}
}

?>

{'fraction_non_alphanumeric': 0.13789981894990946, 'fraction_numerical': 0.0, 'mean_word_length': 3.6888260254596887, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '236632', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1010, 'n_words': 285}