<commit_before><?php
/**
 * Provides session-based messaging for page-to-page communication
 * 
 * @copyright  Copyright (c) 2007-2008 <NAME>
 * @author     <NAME> [wb] <<EMAIL>>
 * @license    http://flourishlib.com/license
 * 
 * @package    Flourish
 * @link       http://flourishlib.com/fMessaging
 * 
 * @version    1.0.0b
 * @changes    1.0.0b  The initial implementation [wb, 2008-03-05]
 */
class fMessaging
{
	/**
	 * Creates a message that is stored in the session and retrieved by another page
	 * 
	 * @param  string $name       A name for the message
	 * @param  string $message    The message to send
	 * @param  string $recipient  The intended recipient
	 * @return void
	 */
	static public function create($name, $message, $recipient)
	{                                         
		fSession::set($name, $message, __CLASS__ . '::' . $recipient . '::');
	}
	
	
	/**
	 * Retrieves and removes a message from the session
	 * 
	 * @param  string $name       The name of the message to retrieve
	 * @param  string $recipient  The intended recipient
	 * @return string  The message contents
	 */
	static public function retrieve($name, $recipient)
	{
		$prefix  = __CLASS__ . '::' . $recipient . '::';
		$message = fSession::get($name, NULL, $prefix);
		fSession::clear($name, $prefix);
		return $message;
	}
	
	
	/**
	 * Retrieves a message, removes it from the session and prints it with the CSS class specified - will not print if no content
	 * 
	 * The message will be printed in a paragraph tag if it does not contain
	 * any block level HTML. Otherwise it will be printed in a div tag.
	 * 
	 * @param  string $name       The name of the message to retrieve
	 * @param  string $recipient  The intended recipient
	 * @return void
	 */
	static public function show($name, $recipient, $css_class='')
	{
		fHTML::show(self::retrieve($name, $recipient), $css_class);
	}
	
	
	/**
	 * Forces use as a static class
	 * 
	 * @return fMessaging
	 */
	private function __construct() { }
}



/**<commit_msg>Implemented a suggestion from ticket #34 to default to the message name for the CSS class in fMessaging::show()<commit_after><?php
/**
 * Provides session-based messaging for page-to-page communication
 * 
 * @copyright  Copyright (c) 2007-2008 <NAME>
 * @author     <NAME> [wb] <<EMAIL>>
 * @license    http://flourishlib.com/license
 * 
 * @package    Flourish
 * @link       http://flourishlib.com/fMessaging
 * 
 * @version    1.0.0b
 * @changes    1.0.0b  The initial implementation [wb, 2008-03-05]
 */
class fMessaging
{
	/**
	 * Creates a message that is stored in the session and retrieved by another page
	 * 
	 * @param  string $name       A name for the message
	 * @param  string $message    The message to send
	 * @param  string $recipient  The intended recipient
	 * @return void
	 */
	static public function create($name, $message, $recipient)
	{                                         
		fSession::set($name, $message, __CLASS__ . '::' . $recipient . '::');
	}
	
	
	/**
	 * Retrieves and removes a message from the session
	 * 
	 * @param  string $name       The name of the message to retrieve
	 * @param  string $recipient  The intended recipient
	 * @return string  The message contents
	 */
	static public function retrieve($name, $recipient)
	{
		$prefix  = __CLASS__ . '::' . $recipient . '::';
		$message = fSession::get($name, NULL, $prefix);
		fSession::clear($name, $prefix);
		return $message;
	}
	
	
	/**
	 * Retrieves a message, removes it from the session and prints it with the CSS class specified - will not print if no content
	 * 
	 * The message will be printed in a paragraph tag if it does not contain
	 * any block level HTML. Otherwise it will be printed in a div tag.
	 * 
	 * @param  string $name       The name of the message to retrieve
	 * @param  string $recipient  The intended recipient
	 * @param  string $css_class  The CSS class to use when displaying the message - if NULL is passed or the parameter is ommitted, $name will be used instead
	 * @return void
	 */
	static public function show($name, $recipient, $css_class=NULL)
	{
		$css_class = ($css_class === NULL) ? $name : $css_class;
		fHTML::show(self::retrieve($name, $recipient), $css_class);
	}
	
	
	/**
	 * Forces use as a static class
	 * 
	 * @return fMessaging
	 */
	private function __construct() { }
}



/**
{'fraction_non_alphanumeric': 0.11341632088520055, 'fraction_numerical': 0.010603964960811434, 'mean_word_length': 2.8879928315412187, 'pattern_counts': {'":': 0, '<': 13, '<?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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1530177', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1261, 'n_words': 472}