<commit_before><?php
class generic_InfoAction extends f_action_BaseJSONAction
{
	
	/**
	 * @see f_action_BaseAction::_execute()
	 *
	 * @param Context $context
	 * @param Request $request
	 */
	protected function _execute($context, $request)
	{
		$result = array();
		try
		{
			$rc = RequestContext::getInstance();
			$documents = $this->getDocumentInstanceArrayFromRequest($request);
			foreach ($documents as $document)
			{
				
				$resultInfo = array('id' => $document->getId(), 
					'model' => $document->getDocumentModelName(), 
					'lang' => $document->getLang(),
					'icon' =>$document->getPersistentModel()->getIcon());
				
				if ($document->isLocalized())
				{
					$resultInfo['labels'] = array();
					foreach ($rc->getSupportedLanguages() as $lang)
					{
						if ($document->isLangAvailable($lang))
						{
							$rc->beginI18nWork($lang);
							$resultInfo['labels'][$lang] = $document->getTreeNodeLabel();
							$rc->endI18nWork();
						}
					}
				}
				else
				{
					$resultInfo['labels'] = array($document->getLang() => $document->getTreeNodeLabel());
				}
				
				$result[] = $resultInfo;
			}
		}
		catch (Exception $e)
		{
			Framework::exception($e);
		}
		
		return $this->sendJSON($result);
	}
	
	/**
	 * Returns an array of the documents IDs received by this action.
	 *
	 * All the IDs contained in the resulting array are REAL integer values, not
	 * strings.
	 *
	 * @param Request $request
	 * @return array<integer>
	 */
	protected function getDocumentIdArrayFromRequest($request)
	{
		$docIds = $request->getParameter(K::COMPONENT_ID_ACCESSOR, array());
		if (is_string($docIds))
		{
			if (strpos($docIds, ',') !== false)
			{
				$docIds = explode(',', $docIds);
			}
			else if (intval($docIds) == $docIds)
			{
				$docIds = array(intval($docIds));
			}
		}
		elseif (is_int($docIds))
		{
			$docIds = array($docIds);
		}
		else if (is_array($docIds))
		{
			foreach ($docIds as $index => $docId)
			{
				if (strval(intval($docId)) === $docId)
				{
					$docIds[$index] = intval($docId);
				}
				else if (! is_int($docId))
				{
					unset($docIds[$index]);
				}
			}
		}
		return $docIds;
	}
}<commit_msg>[FIX] l'action generic/Info traite dorénavant individuelement chaque identifiant<commit_after><?php
class generic_InfoAction extends f_action_BaseJSONAction
{
	
	/**
	 * @see f_action_BaseAction::_execute()
	 *
	 * @param Context $context
	 * @param Request $request
	 */
	protected function _execute($context, $request)
	{
		$result = array();
		foreach ($this->getDocumentIdArrayFromRequest($request) as $documentId)
		{
			try
			{
				$rc = RequestContext::getInstance();
				$document = DocumentHelper::getDocumentInstance($documentId);	
				$resultInfo = array('id' => $document->getId(), 
					'model' => $document->getDocumentModelName(), 
					'lang' => $document->getLang(), 
					'icon' => $document->getPersistentModel()->getIcon());
				
				if ($document->isLocalized())
				{
					$resultInfo['labels'] = array();
					foreach ($rc->getSupportedLanguages() as $lang)
					{
						if ($document->isLangAvailable($lang))
						{
							$rc->beginI18nWork($lang);
							$resultInfo['labels'][$lang] = $document->getTreeNodeLabel();
							$rc->endI18nWork();
						}
					}
				}
				else
				{
					$resultInfo['labels'] = array($document->getLang() => $document->getTreeNodeLabel());
				}
				$result[] = $resultInfo;
			}
			catch (Exception $e)
			{
				Framework::exception($e);
			}
		}
		
		return $this->sendJSON($result);
	}
	
	/**
	 * Returns an array of the documents IDs received by this action.
	 *
	 * All the IDs contained in the resulting array are REAL integer values, not
	 * strings.
	 *
	 * @param Request $request
	 * @return array<integer>
	 */
	protected function getDocumentIdArrayFromRequest($request)
	{
		$docIds = $request->getParameter(K::COMPONENT_ID_ACCESSOR, array());
		if (is_string($docIds))
		{
			if (strpos($docIds, ',') !== false)
			{
				$docIds = explode(',', $docIds);
			}
			else if (intval($docIds) == $docIds)
			{
				$docIds = array(intval($docIds));
			}
			else
			{
				$docIds = array();
			}
		}
		elseif (is_int($docIds))
		{
			$docIds = array($docIds);
		}
		else if (is_array($docIds))
		{
			foreach ($docIds as $index => $docId)
			{
				if (strval(intval($docId)) === $docId)
				{
					$docIds[$index] = intval($docId);
				}
				else if (! is_int($docId))
				{
					unset($docIds[$index]);
				}
			}
		}
		else
		{
			$docIds = array();
		}
		return $docIds;
	}
}
{'fraction_non_alphanumeric': 0.17217661415575772, 'fraction_numerical': 0.0017750166407810074, 'mean_word_length': 3.105646630236794, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 49, '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': '5753288', 'n_tokens_mistral': 1934, 'n_tokens_neox': 1508, 'n_words': 285}