<commit_before><?php
abstract class website_phptal_EditAttribute extends PHPTAL_Php_Attribute
{
	/**
	 * @var Boolean
	 */
	private static $isActive;

	/**
	 * @see PHPTAL_Php_Attribute::start
	 */
	public function start()
	{
		if (self::isActive())
		{
			list($attrName, $attrValue) = $this->startTag();
			$this->tag->attributes['change:'.$attrName] = $attrValue;
		}
	}

	/**
	 * @see PHPTAL_Php_Attribute::end
	 */
	public function end()
	{
		// empty
	}

	abstract protected function startTag();
	
	static function isActive()
	{
		if (self::$isActive === null)
		{
			self::$isActive = RequestContext::getInstance()->getMode() != RequestContext::BACKOFFICE_MODE
				&& users_UserService::getInstance()->getCurrentBackEndUser() !== null; 
		}
		return self::$isActive;
	}
}

class PHPTAL_Php_Attribute_CHANGE_docattr extends website_phptal_EditAttribute
{
	protected function startTag()
	{
		return array("document", "<?php echo ".$this->tag->generator->evaluateExpression($this->expression)." ?>");
	}
}

class PHPTAL_Php_Attribute_CHANGE_propattr extends website_phptal_EditAttribute
{
	protected function startTag()
	{
		return array("property", $this->expression);
	}
}

/**
 * <a change:edit="document item" />
 */
class PHPTAL_Php_Attribute_CHANGE_edit extends ChangeTalAttribute
{

	private static $called = false;
	/**
	 * @param array $params
	 * @return String
	 */
	public static function renderEdit($params)
	{
		if (website_phptal_EditAttribute::isActive())
		{
			$currentURL = LinkHelper::getCurrentUrl();
			$document = $params["document"];
			$documentModel = $document->getPersistentModel();
			//Update
			$editPermission = "modules_".$documentModel->getModuleName().".Update.".$documentModel->getDocumentName();
			$user = users_UserService::getInstance()->getCurrentBackEndUser();
			$permissionService = f_permission_PermissionService::getInstance();
			if ($permissionService->hasPermission($user, $editPermission, $document->getId()))
			{
				$html = "";
				if ($document->isCorrection())
				{
					$isCorrection = true;
					$document = DocumentHelper::getDocumentInstance($document->getCorrectionofid());
				}
				else
				{
					$isCorrection = false;
				}

				if ($document->hasCorrection())
				{<commit_msg>[FIX] Correction d'une fatal sur l'attribut phptal EditAttribute appelé sans document<commit_after><?php
abstract class website_phptal_EditAttribute extends PHPTAL_Php_Attribute
{
	/**
	 * @var Boolean
	 */
	private static $isActive;

	/**
	 * @see PHPTAL_Php_Attribute::start
	 */
	public function start()
	{
		if (self::isActive())
		{
			list($attrName, $attrValue) = $this->startTag();
			$this->tag->attributes['change:'.$attrName] = $attrValue;
		}
	}

	/**
	 * @see PHPTAL_Php_Attribute::end
	 */
	public function end()
	{
		// empty
	}

	abstract protected function startTag();
	
	static function isActive()
	{
		if (self::$isActive === null)
		{
			self::$isActive = RequestContext::getInstance()->getMode() != RequestContext::BACKOFFICE_MODE
				&& users_UserService::getInstance()->getCurrentBackEndUser() !== null; 
		}
		return self::$isActive;
	}
}

class PHPTAL_Php_Attribute_CHANGE_docattr extends website_phptal_EditAttribute
{
	protected function startTag()
	{
		return array("document", "<?php echo ".$this->tag->generator->evaluateExpression($this->expression)." ?>");
	}
}

class PHPTAL_Php_Attribute_CHANGE_propattr extends website_phptal_EditAttribute
{
	protected function startTag()
	{
		return array("property", $this->expression);
	}
}

/**
 * <a change:edit="document item" />
 */
class PHPTAL_Php_Attribute_CHANGE_edit extends ChangeTalAttribute
{

	private static $called = false;
	/**
	 * @param array $params
	 * @return String
	 */
	public static function renderEdit($params)
	{
		if (website_phptal_EditAttribute::isActive() && 
			($params["document"] instanceof f_persistentdocument_PersistentDocument))
		{
			$currentURL = LinkHelper::getCurrentUrl();
			$document = $params["document"];
			$documentModel = $document->getPersistentModel();
			//Update
			$editPermission = "modules_".$documentModel->getModuleName().".Update.".$documentModel->getDocumentName();
			$user = users_UserService::getInstance()->getCurrentBackEndUser();
			$permissionService = f_permission_PermissionService::getInstance();
			if ($permissionService->hasPermission($user, $editPermission, $document->getId()))
			{
				$html = "";
				if ($document->isCorrection())
				{
					$isCorrection = true;
					$document = DocumentHelper::getDocumentInstance($document->getCorrectionofid());
				}
				else
				{
					$isCorrection = false;
				}

				if ($document->hasCorrection())
				{
{'fraction_non_alphanumeric': 0.14952667814113596, 'fraction_numerical': 0.0, 'mean_word_length': 4.718327183271833, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 45, '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': '6326558', 'n_tokens_mistral': 1613, 'n_tokens_neox': 1437, 'n_words': 251}