<commit_before><?php

/**
 * parser actions.
 *
 * @package    manager
 * @subpackage parser
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
 */
class parserActions extends sfActions
{
	
	/***************************************************************************************************** 
	 * These functions get the raw data from the datasource
	 *****************************************************************************************************/
	
	/*
	 * This one returns the raw data from a file, as a pager. This will be processed
	 * by the getItemsFile function.
	 * 
	 */
	private function getRawDataFile($parser,$args) {
		
		list($start,$limit,$sort,$sort_dir,$filters,$export) = $args;
		
		$pager = null;
		$page=($start==0)?1:(@ceil($start/$limit)+1);		
		
		if($this->getUser()->getProfile()) {
			if($this->getUser()->getProfile()->getWidgetHelpIsEnabled()) {
				$chunk = sfConfig::get("app_parser_filepager_help");
			} else {
				$chunk = sfConfig::get("app_parser_filepager_nohelp");
			}	
			
		}
	
		if($export == "all") {
			$chunk = sfConfig::get("app_parser_filepager_all");
		}
		
		$pager = new immFilePager($parser["datafile"],$chunk,($export == "all") ? sfConfig::get("app_parser_max_chunk_size"): 1);
		$pager->setPage($page);
		$pager->init();
		
		//print_r($pager->getResults());
		
		return $pager;
		
	}
	
	
	/***************************************************************************************************** 
	 * These functions will process the raw data and create input array for grids.
	 * ***************************************************************************************************/
	
	/*
	 * This creates the output from pager data. Can be used when the source is a file.
	 * 
	 */
	private function getItemsFile($pager,$parser) {
		
		$items = array();
		
		if(isset($parser['realtime']) and $parser['realtime'] == "yes")	{				
			$items = call_user_func(array($parser["datasource"]["class"],$parser["datasource"]["method"]["name"]),$parser["datafile"]);			
		} else { 			
			foreach($pager->getResults() as $s) {
				if($parser["datasource"]["lister"] !== "false") {
					$item = call_user_func(array($parser["datasource"]["class"],$parser["datasource"]["method"]["name"]),$s);
					if($item !== false) {
						$items[] = $item;
					}
				} else {
					$items[] = array_combine($parser["columns"],$s);	
				}	
			}
		}
		
		return $items;
	}
	

	/***************************************************************************************************** 
	 * Other private functions, used by the main actions and methods.                                    *
	 * ***************************************************************************************************/
	
    /**
	 * retrieving description and images for some widgets
	 * @author radu
	 */
	public function executeRetrieveWidgetsInfo()
	{
		$portalWidgets=json_decode($this->getRequestParameter('portalWidgets'));
				
		foreach ($portalWidgets as $pwi=>$portalWidgetsFielset)
		{
			foreach ($portalWidgetsFielset->widgets as $pfwi=>$widget)
			{
				$ma=explode('/',$widget);
				$path = sfConfig::get("sf_root_dir").'/apps/'.$this->context->getConfiguration()->getApplication().'/modules/'.$ma[1].'/config/'.$ma[2].'.xml';
				$dom = new DOMDocument();
				if($dom->load($path))
				{
					foreach ($dom->documentElement->childNodes as $oChildNode) {
						if($oChildNode->nodeName=='i:title')
						{
							$title=trim($oChildNode->nodeValue);<commit_msg>i#1904 - removed old file datasource code.<commit_after><?php

/**
 * parser actions.
 *
 * @package    manager
 * @subpackage parser
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
 */
class parserActions extends sfActions
{
    /**
	 * retrieving description and images for some widgets
	 * @author radu
	 */
	public function executeRetrieveWidgetsInfo()
	{
		$portalWidgets=json_decode($this->getRequestParameter('portalWidgets'));
				
		foreach ($portalWidgets as $pwi=>$portalWidgetsFielset)
		{
			foreach ($portalWidgetsFielset->widgets as $pfwi=>$widget)
			{
				$ma=explode('/',$widget);
				$path = sfConfig::get("sf_root_dir").'/apps/'.$this->context->getConfiguration()->getApplication().'/modules/'.$ma[1].'/config/'.$ma[2].'.xml';
				$dom = new DOMDocument();
				if($dom->load($path))
				{
					foreach ($dom->documentElement->childNodes as $oChildNode) {
						if($oChildNode->nodeName=='i:title')
						{
							$title=trim($oChildNode->nodeValue);
{'fraction_non_alphanumeric': 0.287341217696014, 'fraction_numerical': 0.010950503723171266, 'mean_word_length': 4.225400457665904, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1355218', 'n_tokens_mistral': 1608, 'n_tokens_neox': 1324, 'n_words': 244}