<commit_before><?php
/**
 * Anqh extended Form helper class.
 *
 * @package    Anqh
 * @author     <NAME>
 * @copyright  (c) 2009 <NAME>
 * @license    http://www.opensource.org/licenses/mit-license.php MIT license
 */
class form extends form_Core {

	/**
	 * Creates an HTML form button input tag.
	 *
	 * @param   string|array  input name or an array of HTML attributes
	 * @param   string|array  input value, when using a name or values
	 * @param   string        a string to be attached to the end of the attributes
	 * @param   string        $label
	 * @param   string|array  $error
	 * @param   string|array  $tip
	 * @return  string
	 */
	public static function button_wrap($data = '', $value = '', $extra = '', $label = '', $error = '', $tip = '') {
		$name = is_array($data) ? arr::get($data, 'name') : $data;
		$value = is_array($value) ? arr::get($value, $name) : $value;

		$input = form::button($data, $value, $extra);

		return form::wrap($input, $name, $label, $error, $tip);
	}


	/**
	 * Creates an HTML form checkbox input tag.
	 *
	 * @param   string|array   input name or an array of HTML attributes
	 * @param   string         input value, when using a name
	 * @param   boolean|array  make the checkbox checked by default
	 * @param   string         a string to be attached to the end of the attributes
	 * @param   string         $label
	 * @param   string|array   $error
	 * @param   string|array   $tip
	 * @return  string
	 */
	public static function checkbox_wrap($data, $value = '', $checked = FALSE, $extra = '', $label = '', $error = '', $tip = '') {
		$name = is_array($data) ? arr::get($data, 'name') : $data;
		$value = is_array($value) ? arr::get($value, $name) : $value;
		$checked = is_array($checked) ? arr::get($checked, $name) == $value : $checked;

		// Add id to input if label given
		if ($label) {
			if (!is_array($data)) {
				$data = array('name' => $name, 'id' => $name);
			} else if (!isset($data['id'])) {
				$data['id'] = $name;
			}
		}

		$input = form::checkbox($data, $value, $checked, $extra);

		return form::wrap($input, $name, $label, $error, $tip, true);
	}


	/**
	 * Creates checkboxes list
	 *
	 * @param   string        $name    input name
	 * @param   array         $data    array of checkboxes
	 * @param   array         $values  checked values
	 * @param   string        $label
	 * @param   string|array  $error
	 * @param   string|array  $tip
	 * @return  string
	 */
	public static function checkboxes_wrap($name, $data = array(), $values = array(), $label = '', $error = '', $class = '', $tip = '') {

		// Get checkboxes
		$checkboxes = isset($data[$name]) ? $data[$name] : $data;

		if (!empty($checkboxes)) {

			// Create internal id
			$singular = inflector::singular($name) . '_';

			// Get values
			$values = array_key_exists($name, $values) ? $values[$name] : $values;
			$input = (empty($class)) ? "<ul>\n" : '<ul class="' . $class . "\">\n";
			foreach ($checkboxes as $checkbox_id => $checkbox_name) {
				$internal_id = $singular . $checkbox_id;
				$input .= '<li>';
				$input .= form::checkbox(array('id' => $internal_id, 'name' => $name . '[' . $checkbox_id . ']'), $checkbox_name, isset($values[$checkbox_id]));
				$input .= form::label($internal_id, $checkbox_name);<commit_msg>checkbox group with value as 1 instead of name<commit_after><?php
/**
 * Anqh extended Form helper class.
 *
 * @package    Anqh
 * @author     <NAME>
 * @copyright  (c) 2009-2010 <NAME>
 * @license    http://www.opensource.org/licenses/mit-license.php MIT license
 */
class form extends form_Core {

	/**
	 * Creates an HTML form button input tag.
	 *
	 * @param   string|array  input name or an array of HTML attributes
	 * @param   string|array  input value, when using a name or values
	 * @param   string        a string to be attached to the end of the attributes
	 * @param   string        $label
	 * @param   string|array  $error
	 * @param   string|array  $tip
	 * @return  string
	 */
	public static function button_wrap($data = '', $value = '', $extra = '', $label = '', $error = '', $tip = '') {
		$name = is_array($data) ? arr::get($data, 'name') : $data;
		$value = is_array($value) ? arr::get($value, $name) : $value;

		$input = form::button($data, $value, $extra);

		return form::wrap($input, $name, $label, $error, $tip);
	}


	/**
	 * Creates an HTML form checkbox input tag.
	 *
	 * @param   string|array   input name or an array of HTML attributes
	 * @param   string         input value, when using a name
	 * @param   boolean|array  make the checkbox checked by default
	 * @param   string         a string to be attached to the end of the attributes
	 * @param   string         $label
	 * @param   string|array   $error
	 * @param   string|array   $tip
	 * @return  string
	 */
	public static function checkbox_wrap($data, $value = '', $checked = FALSE, $extra = '', $label = '', $error = '', $tip = '') {
		$name = is_array($data) ? arr::get($data, 'name') : $data;
		$value = is_array($value) ? arr::get($value, $name) : $value;
		$checked = is_array($checked) ? arr::get($checked, $name) == $value : $checked;

		// Add id to input if label given
		if ($label) {
			if (!is_array($data)) {
				$data = array('name' => $name, 'id' => $name);
			} else if (!isset($data['id'])) {
				$data['id'] = $name;
			}
		}

		$input = form::checkbox($data, $value, $checked, $extra);

		return form::wrap($input, $name, $label, $error, $tip, true);
	}


	/**
	 * Creates checkboxes list
	 *
	 * @param   string        $name    input name
	 * @param   array         $data    array of checkboxes
	 * @param   array         $values  checked values
	 * @param   string        $label
	 * @param   string|array  $error
	 * @param   string|array  $tip
	 * @return  string
	 */
	public static function checkboxes_wrap($name, $data = array(), $values = array(), $label = '', $error = '', $class = '', $tip = '') {

		// Get checkboxes
		$checkboxes = isset($data[$name]) ? $data[$name] : $data;

		if (!empty($checkboxes)) {

			// Create internal id
			$singular = inflector::singular($name) . '_';

			// Get values
			$values = array_key_exists($name, $values) ? $values[$name] : $values;
			$input = (empty($class)) ? "<ul>\n" : '<ul class="' . $class . "\">\n";
			foreach ($checkboxes as $checkbox_id => $checkbox_name) {
				$internal_id = $singular . $checkbox_id;
				$input .= '<li>';
				$input .= form::checkbox(array('id' => $internal_id, 'name' => $name . '[' . $checkbox_id . ']'), 1, isset($values[$checkbox_id]));
				$input .= form::label($internal_id, $checkbox_name);
{'fraction_non_alphanumeric': 0.17547600913937547, 'fraction_numerical': 0.0021325209444021326, 'mean_word_length': 3.06815365551425, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7226916', 'n_tokens_mistral': 2283, 'n_tokens_neox': 2071, 'n_words': 625}