<commit_before><?php
/**
 * beautifurl filter replaces page controllers view action calls with corresponding beautifurls(tm).
 *
 * @todo: optimize, cache, conquer world.
 */
class Emerald_Filter_Beautifurl implements Zend_Filter_Interface 
{
	
	public function filter($value)
	{
		
		// We be getting de replaces
		$regex = '/\/page\/view\/id\/(\d+)/';
		preg_match_all($regex, $value, $matches);

		if($matches[0]) {
			$naviModel = new EmCore_Model_Navigation();
			$navigation = $naviModel->getNavigation();
			// We be doin' de replacin'
			foreach($matches[0] as $key => $toReplace) {
				$page = $navigation->findBy('id', $matches[1][$key]);
				if($page) {
					$value = str_ireplace(EMERALD_URL_BASE . $toReplace, $page->uri, $value);	
				}
				
			}
		}

		// We be getting de replaces
		$regex = '/\/em-filelib\/file\/render\/id\/(\d+)(\/version\/([a-z]+))?/';
		preg_match_all($regex, $value, $matches);
		
		if($matches[0]) {
			
			$fl = Zend_Registry::get('Emerald_Filelib');
			
			// We be doin' de replacin'
			foreach($matches[0] as $key => $toReplace) {
				
				$file = $fl->file()->find($matches[1][$key]);
												
				if($file && $file->isAnonymous()) {
					
					$opts = array();
					if(isset($matches[3][$key]) && $matches[3][$key]) {
						$opts['version'] = $matches[3][$key];
					}
					
					$value = str_ireplace(EMERALD_URL_BASE . $toReplace, $file->renderPath($opts), $value);	
				}
				
			}
		}
		

		return $value;
		
		
	}
	
	
}
?><commit_msg>Fixed problem in beautifurl filter.<commit_after><?php
/**
 * beautifurl filter replaces page controllers view action calls with corresponding beautifurls(tm).
 *
 * @todo: optimize, cache, conquer world.
 */
class Emerald_Filter_Beautifurl implements Zend_Filter_Interface 
{
	
	public function filter($value)
	{
		
		// We be getting de replaces
		$regex = '/\/page\/view\/id\/(\d+)/';
		preg_match_all($regex, $value, $matches);

		if($matches[0]) {
			$naviModel = new EmCore_Model_Navigation();
			$navigation = $naviModel->getNavigation();
			// We be doin' de replacin'
			foreach($matches[0] as $key => $toReplace) {
				$page = $navigation->findBy('id', $matches[1][$key]);
				if($page) {
					$value = str_ireplace(EMERALD_URL_BASE . $toReplace, $page->uri, $value);	
				}
				
			}
		}

		// We be getting de replaces
		$regex = '/\/em-filelib\/file\/render\/id\/(\d+)(\/version\/([a-z_]+))?/';
		preg_match_all($regex, $value, $matches);
		
		if($matches[0]) {
			
			$fl = Zend_Registry::get('Emerald_Filelib');
			
			// We be doin' de replacin'
			foreach($matches[0] as $key => $toReplace) {
				
				$file = $fl->file()->find($matches[1][$key]);
												
				if($file && $file->isAnonymous()) {
					
					$opts = array();
					if(isset($matches[3][$key]) && $matches[3][$key]) {
						$opts['version'] = $matches[3][$key];
					}
					
					$value = str_ireplace(EMERALD_URL_BASE . $toReplace, $file->renderPath($opts), $value);	
				}
				
			}
		}
		

		return $value;
		
		
	}
	
	
}
?>
{'fraction_non_alphanumeric': 0.19426857714095302, 'fraction_numerical': 0.005998000666444518, 'mean_word_length': 2.9396325459317585, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, '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': '7643617', 'n_tokens_mistral': 1340, 'n_tokens_neox': 1061, 'n_words': 198}