Overview
SHA1:22ea4885911173a732797054450b811a24ed38fc
Date: 2018-11-28 16:36:59
User: bohwaz
Comment:Corrige élément sélectionné dans les champs membres de type <select>
Timelines: family | ancestors | descendants | both | trunk | stable
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2018-11-28
21:02
[bfe170eb47] Correctif recherche avancée (user: bohwaz, tags: trunk, stable)
16:36
[22ea488591] Corrige élément sélectionné dans les champs membres de type <select> (user: bohwaz, tags: trunk, stable)
16:26
[9031386c21] Ne pas vérifier l'email si vide (user: bohwaz, tags: trunk, stable)
Changes

Modified src/include/lib/Garradin/Template.php from [808469b185] to [86d1b59d2c].

143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
...
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
...
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
...
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
		{
			return '';
		}

		return '<p class="error">' . $this->escape($params['message']) . '</p>';
	}

	protected function formField(array $params)
	{
		if (!isset($params['name']))
		{
			throw new \BadFunctionCallException('name argument is mandatory');
		}

		$name = $params['name'];
................................................................................
		{
			if ($value == $params['selected'])
				return ' selected="selected" ';

			return '';
		}

		return htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8');
	}

	protected function formatPhoneNumber($n)
	{
		$n = preg_replace('![^\d\+]!', '', $n);

		if (substr($n, 0, 1) == '+')
................................................................................
		}
		elseif ($type == 'date')
		{
			$params['pattern'] = '\d{4}-\d{2}-\d{2}';
		}

		$field = '';
		$value = $this->formField($params);
		$attributes = 'name="' . htmlspecialchars($params['name'], ENT_QUOTES, 'UTF-8') . '" ';
		$attributes .= 'id="f_' . htmlspecialchars($params['name'], ENT_QUOTES, 'UTF-8') . '" ';

		if ($params['name'] == 'numero' && $config->type == 'number' && !$value)
		{
			$value = DB::getInstance()->firstColumn('SELECT MAX(numero) + 1 FROM membres;');
		}
................................................................................
					. htmlspecialchars($params['name'], ENT_QUOTES, 'UTF-8') . '[' . (int)$k . ']" value="1" '
					. (($value & $b) ? 'checked="checked"' : '') . ' ' . $attributes . '/> ' 
					. htmlspecialchars($v, ENT_QUOTES, 'UTF-8') . '</label><br />';
			}
		}
		elseif ($type == 'textarea')
		{
			$field .= '<textarea ' . $attributes . 'cols="30" rows="5">' . $value . '</textarea>';
		}
		else
		{
			if ($type == 'checkbox')
			{
				if (!empty($value))
				{
					$attributes .= 'checked="checked" ';
				}

				$value = '1';
			}

			$field .= '<input type="' . $type . '" ' . $attributes . ' value="' . $value . '" />';
		}

		$out = '
		<dt>';

		if ($type == 'checkbox')
		{







|







 







|







 







|







 







|













|







143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
...
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
...
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
...
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
		{
			return '';
		}

		return '<p class="error">' . $this->escape($params['message']) . '</p>';
	}

	protected function formField(array $params, $escape = true)
	{
		if (!isset($params['name']))
		{
			throw new \BadFunctionCallException('name argument is mandatory');
		}

		$name = $params['name'];
................................................................................
		{
			if ($value == $params['selected'])
				return ' selected="selected" ';

			return '';
		}

		return $escape ? htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8') : $value;
	}

	protected function formatPhoneNumber($n)
	{
		$n = preg_replace('![^\d\+]!', '', $n);

		if (substr($n, 0, 1) == '+')
................................................................................
		}
		elseif ($type == 'date')
		{
			$params['pattern'] = '\d{4}-\d{2}-\d{2}';
		}

		$field = '';
		$value = $this->formField($params, false);
		$attributes = 'name="' . htmlspecialchars($params['name'], ENT_QUOTES, 'UTF-8') . '" ';
		$attributes .= 'id="f_' . htmlspecialchars($params['name'], ENT_QUOTES, 'UTF-8') . '" ';

		if ($params['name'] == 'numero' && $config->type == 'number' && !$value)
		{
			$value = DB::getInstance()->firstColumn('SELECT MAX(numero) + 1 FROM membres;');
		}
................................................................................
					. htmlspecialchars($params['name'], ENT_QUOTES, 'UTF-8') . '[' . (int)$k . ']" value="1" '
					. (($value & $b) ? 'checked="checked"' : '') . ' ' . $attributes . '/> ' 
					. htmlspecialchars($v, ENT_QUOTES, 'UTF-8') . '</label><br />';
			}
		}
		elseif ($type == 'textarea')
		{
			$field .= '<textarea ' . $attributes . 'cols="30" rows="5">' . htmlspecialchars($value, ENT_QUOTES) . '</textarea>';
		}
		else
		{
			if ($type == 'checkbox')
			{
				if (!empty($value))
				{
					$attributes .= 'checked="checked" ';
				}

				$value = '1';
			}

			$field .= '<input type="' . $type . '" ' . $attributes . ' value="' . htmlspecialchars($value, ENT_QUOTES) . '" />';
		}

		$out = '
		<dt>';

		if ($type == 'checkbox')
		{