<commit_before><?php
/**
 * @package plugins.caption
 * @subpackage model.filters
 */
class EntryCaptionAssetSearchFilter extends AdvancedSearchFilterItem
{
	/**
	 * @var string
	 */
	protected  $contentLike;

	/**
	 * @var string
	 */
	protected $contentMultiLikeOr;

	/**
	 * @var string
	 */
	protected $contentMultiLikeAnd;
	
	
	/**
	 * @return the $contentLike
	 */
	public function getContentLike() {
		return $this->contentLike;
	}

	/**
	 * @return the $contentMultiLikeOr
	 */
	public function getContentMultiLikeOr() {
		return $this->contentMultiLikeOr;
	}

	/**
	 * @return the $contentMultiLikeAnd
	 */
	public function getContentMultiLikeAnd() {
		return $this->contentMultiLikeAnd;
	}

	/**
	 * @param string $contentLike
	 */
	public function setContentLike($contentLike) {
		$this->contentLike = $this->formatCondition($contentLike, ' ', ' ');
	}

	/**
	 * @param string $contentMultiLikeOr
	 */
	public function setContentMultiLikeOr($contentMultiLikeOr) {
		$this->contentMultiLikeOr = $this->formatCondition($contentMultiLikeOr, ',', ' | ');
	}

	/**
	 * @param string $contentMultiLikeAnd
	 */
	public function setContentMultiLikeAnd($contentMultiLikeAnd) {
		$this->contentMultiLikeAnd = $this->formatCondition($contentMultiLikeAnd, ' ', ' ');
	}

	private function formatCondition($conditionString, $explodeDelimiter, $implodeDelimiter)
	{
		$res = null;		
		$vals = explode($explodeDelimiter, $conditionString);
		foreach($vals as $valIndex => $valValue)
		{
			if(!is_numeric($valValue) && strlen($valValue) <= 0)
				unset($vals[$valIndex]);
			elseif(preg_match('/[\s\t]/', $valValue))
				$vals[$valIndex] = '"' . SphinxUtils::escapeString($valValue) . '"';
			else
				$vals[$valIndex] = SphinxUtils::escapeString($valValue);
		}
					
		if(count($vals))
		{
			$res = implode($implodeDelimiter, $vals);
		}		
		return $res;
	}
	
	private function addCondition($conditionStr, IKalturaIndexQuery $query)
	{		
		if(!is_null($conditionStr))
		{
			$condition = "ca_prefix<<$conditionStr<<ca_sufix";
			KalturaLog::debug("condition [" . print_r($condition, true) . "]");
			$key = '@' . CaptionSearchPlugin::getSearchFieldName(CaptionSearchPlugin::SEARCH_FIELD_DATA);<commit_msg>fwr: caption asset search - add caption search to the entry filter<commit_after><?php
/**
 * @package plugins.caption
 * @subpackage model.filters
 */
class EntryCaptionAssetSearchFilter extends AdvancedSearchFilterItem
{
	/**
	 * @var string
	 */
	protected  $contentLike;

	/**
	 * @var string
	 */
	protected $contentMultiLikeOr;

	/**
	 * @var string
	 */
	protected $contentMultiLikeAnd;
	
	
	/**
	 * @return the $contentLike
	 */
	public function getContentLike() {
		return $this->contentLike;
	}

	/**
	 * @return the $contentMultiLikeOr
	 */
	public function getContentMultiLikeOr() {
		return $this->contentMultiLikeOr;
	}

	/**
	 * @return the $contentMultiLikeAnd
	 */
	public function getContentMultiLikeAnd() {
		return $this->contentMultiLikeAnd;
	}

	/**
	 * @param string $contentLike
	 */
	public function setContentLike($contentLike) {
		$this->contentLike = $this->formatCondition($contentLike, null, ' ');
	}

	/**
	 * @param string $contentMultiLikeOr
	 */
	public function setContentMultiLikeOr($contentMultiLikeOr) {
		$this->contentMultiLikeOr = $this->formatCondition($contentMultiLikeOr, ',', ' | ');
	}

	/**
	 * @param string $contentMultiLikeAnd
	 */
	public function setContentMultiLikeAnd($contentMultiLikeAnd) {
		$this->contentMultiLikeAnd = $this->formatCondition($contentMultiLikeAnd, ',', ' ');
	}

	private function formatCondition($conditionString, $explodeDelimiter, $implodeDelimiter)
	{
		if(!strlen($conditionString))
		{
			return null;
		}
		
		$res = null;
		if($explodeDelimiter)
		{		
			$vals = explode($explodeDelimiter, $conditionString);
			foreach($vals as $valIndex => $valValue)
			{
				if(!$valValue)
					unset($vals[$valIndex]);
				elseif(preg_match('/[\s\t]/', $valValue))
					$vals[$valIndex] = '"' . SphinxUtils::escapeString($valValue) . '"';
				else
					$vals[$valIndex] = SphinxUtils::escapeString($valValue);
			}
						
			if(count($vals))
			{
				$res = implode($implodeDelimiter, $vals);
			}	
		}	
		else
		{
			if(preg_match('/[\s\t]/', $conditionString)) 
				$res = '"' . SphinxUtils::escapeString($conditionString) . '"';
			else
				$res = SphinxUtils::escapeString($conditionString);
									
		}
		return $res;
	}
	
	private function addCondition($conditionStr, IKalturaIndexQuery $query)
	{		
		if(!is_null($conditionStr))
		{
			$condition = "ca_prefix<<$conditionStr<<ca_sufix";
			KalturaLog::debug("condition [" . print_r($condition, true) . "]");
			$key = '@' . CaptionSearchPlugin::getSearchFieldName(CaptionSearchPlugin::SEARCH_FIELD_DATA);
{'fraction_non_alphanumeric': 0.15625, 'fraction_numerical': 0.00021114864864864866, 'mean_word_length': 4.245847176079734, 'pattern_counts': {'":': 0, '<': 14, '<?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': '18943', 'n_tokens_mistral': 1723, 'n_tokens_neox': 1528, 'n_words': 246}