403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/sender/lib/search/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/sender/lib/search/builder.php
<?php

namespace Bitrix\Sender\Search;

use Bitrix\Main\Entity;

/**
 * Class Builder
 * @package Bitrix\Sender\Search
 */
class Builder
{
	/** @var  Entity\Base $entity Entity. */
	private $entity;

	/** @var  Content $content Content. */
	private $content;

	/** @var string $fieldName Field name. */
	private $fieldName;

	/**
	 * Filter constructor.
	 *
	 * @param Entity\Base $entity Entity.
	 * @param string|null $fieldName Field name.
	 */
	public function __construct(Entity\Base $entity, $fieldName)
	{
		$this->entity = $entity;
		$this->fieldName = $fieldName;
	}

	/**
	 * Is full text index enabled.
	 *
	 * @return bool
	 */
	public function isFullTextIndexEnabled()
	{
		return $this->entity->fullTextIndexEnabled($this->fieldName);
	}

	/**
	 * Return true if entity has field.
	 *
	 * @return bool
	 */
	public function hasField()
	{
		return $this->entity->hasField($this->fieldName);
	}

	/**
	 * Get content.
	 *
	 * @return Content
	 */
	public function getContent()
	{
		if (!$this->content)
		{
			$this->content = new Content;
		}

		return $this->content;
	}

	/**
	 * Return true if ca save.
	 *
	 * @return bool
	 */
	public function isEnabled()
	{
		return $this->hasField() && $this->isFullTextIndexEnabled();
	}

	/**
	 * Save.
	 *
	 * @param int $entityId Entity ID.
	 * @return bool
	 */
	public function save($entityId)
	{
		$dataClass = $this->entity->getDataClass();
		return $dataClass::update(
			$entityId,
			array($this->fieldName => $this->content->getString())
		)->isSuccess();
	}

	/**
	 * Apply filter.
	 *
	 * @param array &$filter Filter.
	 * @param string|null $searchString Search string.
	 * @return bool
	 */
	public function applyFilter(array &$filter, $searchString)
	{
		if (!$searchString)
		{
			return false;
		}
		if (!$this->hasField())
		{
			return false;
		}

		$isFullTextEnabled = $this->isFullTextIndexEnabled();
		$operation = $isFullTextEnabled ? '*' : '*%';
		$filter["{$operation}{$this->fieldName}"] = Content::encodeText($searchString);

		return true;
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit