<commit_before><?php
namespace Craft;

class Neo_ReasonsService extends BaseApplicationComponent
{
	public function pluginInit()
	{
		if(craft()->plugins->getPlugin('reasons') && craft()->request->isCpRequest() && !craft()->isConsole())
		{
			if(craft()->request->isAjaxRequest())
			{

			}
			else
			{
				craft()->templates->includeJs('if(window.Neo) Neo.ReasonsPlugin.conditionals = ' . JsonHelper::encode($this->getConditionals()));
			}

			craft()->on('fields.saveFieldLayout', array($this, 'onSaveFieldLayout'));
		}
	}

	public function saveConditionals(/*Reasons_ConditionalsModel*/ $conditionals)
	{
		craft()->neo->requirePlugin('reasons');
		craft()->reasons->saveConditionals($conditionals);
	}

	public function getConditionals()
	{
		craft()->neo->requirePlugin('reasons');

		// TODO Reduce database impact

		$blockTypeConditionals = array();<commit_msg>Improved sending conditionals to frontend<commit_after><?php
namespace Craft;

class Neo_ReasonsService extends BaseApplicationComponent
{
	public function pluginInit()
	{
		if(craft()->plugins->getPlugin('reasons') && craft()->request->isCpRequest() && !craft()->isConsole())
		{
			if(craft()->request->isAjaxRequest())
			{

			}
			else
			{
				$data = array(
					'conditionals' => $this->getConditionals(),
				);

				craft()->templates->includeJs('if(window.Craft && Craft.ReasonsPlugin) Craft.ReasonsPlugin.neoData = ' . JsonHelper::encode($data));
			}

			craft()->on('fields.saveFieldLayout', array($this, 'onSaveFieldLayout'));
		}
	}

	public function saveConditionals(/*Reasons_ConditionalsModel*/ $conditionals)
	{
		craft()->neo->requirePlugin('reasons');
		craft()->reasons->saveConditionals($conditionals);
	}

	public function getConditionals()
	{
		craft()->neo->requirePlugin('reasons');

		// TODO Reduce database impact

		$blockTypeConditionals = array();
{'fraction_non_alphanumeric': 0.1725067385444744, 'fraction_numerical': 0.0, 'mean_word_length': 5.125412541254126, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 38, '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': '230136', 'n_tokens_mistral': 627, 'n_tokens_neox': 551, 'n_words': 82}