<commit_before><?php
declare(ENCODING = 'utf-8');
namespace F3\Fluid\Core;

/*                                                                        *
 * This script is part of the TYPO3 project - inspiring people to share!  *
 *                                                                        *
 * TYPO3 is free software; you can redistribute it and/or modify it under *
 * the terms of the GNU General Public License version 2 as published by  *
 * the Free Software Foundation.                                          *
 *                                                                        *
 * This script is distributed in the hope that it will be useful, but     *
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
 * Public License for more details.                                       *
 *                                                                        */

/**
 * @package Fluid
 * @subpackage Core
 * @version $Id:$
 */
/**
 * Tag based view helper.
 * Sould be used as the base class for all view helpers which output simple tags, as it provides some
 * convenience methods to register default attributes, ...
 *
 * @package Fluid
 * @subpackage Core
 * @version $Id:$
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
 */
abstract class TagBasedViewHelper extends \F3\Fluid\Core\AbstractViewHelper {
	
	/**
	 * Names of all registered tag attributes
	 * @var array
	 */
	protected $tagAttributes = array();
	
	/**
	 * Register a new tag attribute. Tag attributes are all arguments which will be directly appended to a tag if you call $this->renderTagAttributes()
	 * 
	 * The tag attributes registered here are rendered with the $this->renderTagAttributes() method.
	 * 
	 * @param string $name Name of tag attribute
	 * @param string $description Description of tag attribute
	 * @param boolean $required set to TRUE if tag attribute is required. Defaults to FALSE.
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 */
	protected function registerTagAttribute($name, $description, $required=FALSE) {
		$this->registerArgument($name, 'string', $description, $required);
		$this->tagAttributes[] = $name;
	}
	
	/**
	 * Registers all standard HTML universal attributes.
	 * Should be used inside registerArguments();
	 * 
	 * The following attributes are registered:
	 * - class (CSS Class)
	 * - dir (Text direction)
	 * - id (Universal identifier)
	 * - lang (Language)
	 * - style (per-element style)
	 * - title (tooltip text)
	 *
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 */
	protected function registerUniversalTagAttributes() {
		$this->registerTagAttribute('class', 'CSS class(es) for this element');
		$this->registerTagAttribute('dir', 'Text direction for this HTML element. Allowed strings: "ltr" (left to right), "rtl" (right to left)');
		$this->registerTagAttribute('id', 'Unique (in this file) identifier for this HTML element.');
		$this->registerTagAttribute('lang', 'Language for this element. Use short names specified in RFC 1766');
		$this->registerTagAttribute('style', 'Individual CSS styles for this element');
		$this->registerTagAttribute('title', 'Tooltip text of element');
	}
	
	/**
	 * Render all tag attributes which were registered in $this->tagAttributes.
	 * You should call this method in your render() method if you output some tag.
	 * 
	 * @return string Concatenated list of attributes
	 * @author <NAME> <<EMAIL>>
	 * @todo HTMLSPECIALCHAR output
	 */
	protected function renderTagAttributes() {
		$attributes = array();
		foreach ($this->tagAttributes as $attributeName) {
			if ($this->arguments[$attributeName]) {
				$attributes[] = $attributeName . '="' . $this->arguments[$attributeName] . '"';
			}
		}
		return implode(' ', $attributes);
	}
}
<commit_msg>Fluid: * Adding additionalArguments support Original-Commit-Hash: 0f6ad2d29211e5e06460a8301be38dd341e64d0c<commit_after><?php
declare(ENCODING = 'utf-8');
namespace F3\Fluid\Core;

/*                                                                        *
 * This script is part of the TYPO3 project - inspiring people to share!  *
 *                                                                        *
 * TYPO3 is free software; you can redistribute it and/or modify it under *
 * the terms of the GNU General Public License version 2 as published by  *
 * the Free Software Foundation.                                          *
 *                                                                        *
 * This script is distributed in the hope that it will be useful, but     *
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
 * Public License for more details.                                       *
 *                                                                        */

/**
 * @package Fluid
 * @subpackage Core
 * @version $Id:$
 */
/**
 * Tag based view helper.
 * Sould be used as the base class for all view helpers which output simple tags, as it provides some
 * convenience methods to register default attributes, ...
 *
 * @package Fluid
 * @subpackage Core
 * @version $Id:$
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
 */
abstract class TagBasedViewHelper extends \F3\Fluid\Core\AbstractViewHelper {
	
	/**
	 * Names of all registered tag attributes
	 * @var array
	 */
	protected $tagAttributes = array();
	public function __construct() {
		$this->registerArgument('additionalArguments', 'array', 'Additional arguments', FALSE);
	}
	/**
	 * Register a new tag attribute. Tag attributes are all arguments which will be directly appended to a tag if you call $this->renderTagAttributes()
	 * 
	 * The tag attributes registered here are rendered with the $this->renderTagAttributes() method.
	 * 
	 * @param string $name Name of tag attribute
	 * @param string $description Description of tag attribute
	 * @param boolean $required set to TRUE if tag attribute is required. Defaults to FALSE.
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 */
	protected function registerTagAttribute($name, $description, $required=FALSE) {
		$this->registerArgument($name, 'string', $description, $required);
		$this->tagAttributes[] = $name;
	}
	
	/**
	 * Registers all standard HTML universal attributes.
	 * Should be used inside registerArguments();
	 * 
	 * The following attributes are registered:
	 * - class (CSS Class)
	 * - dir (Text direction)
	 * - id (Universal identifier)
	 * - lang (Language)
	 * - style (per-element style)
	 * - title (tooltip text)
	 *
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 */
	protected function registerUniversalTagAttributes() {
		$this->registerTagAttribute('class', 'CSS class(es) for this element');
		$this->registerTagAttribute('dir', 'Text direction for this HTML element. Allowed strings: "ltr" (left to right), "rtl" (right to left)');
		$this->registerTagAttribute('id', 'Unique (in this file) identifier for this HTML element.');
		$this->registerTagAttribute('lang', 'Language for this element. Use short names specified in RFC 1766');
		$this->registerTagAttribute('style', 'Individual CSS styles for this element');
		$this->registerTagAttribute('title', 'Tooltip text of element');
	}
	
	/**
	 * Render all tag attributes which were registered in $this->tagAttributes.
	 * You should call this method in your render() method if you output some tag.
	 * 
	 * @return string Concatenated list of attributes
	 * @author <NAME> <<EMAIL>>
	 * @todo HTMLSPECIALCHAR output
	 */
	protected function renderTagAttributes() {
		$attributes = array();
		foreach ($this->arguments['additionalArguments'] as $key => $value) {
			$this->tagAttributes[$key] = $value;
		}
		foreach ($this->tagAttributes as $attributeName) {
			if ($this->arguments[$attributeName]) {
				$attributes[] = $attributeName . '="' . $this->arguments[$attributeName] . '"';
			}
		}
		return implode(' ', $attributes);
	}
}

{'fraction_non_alphanumeric': 0.10799456320276782, 'fraction_numerical': 0.005931051526010132, 'mean_word_length': 2.662443438914027, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 53, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6881745', 'n_tokens_mistral': 2162, 'n_tokens_neox': 1980, 'n_words': 772}