Commit fd74d822 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '5910-use-more-html5-input-types' into '1.4-dev'

Resolve "Use more HTML5 input types"

See merge request fusiondirectory/fd!425
parents 5caac96e 3925fb2a
......@@ -24,7 +24,7 @@
<input type="submit" name="open_readonly" value="{t}Read only{/t}"/>
{/if}
&nbsp;
<input type="submit" name="cancel_lock" value="{t}Cancel{/t}"/>
<input type="submit" formnovalidate="formnovalidate" name="cancel_lock" value="{t}Cancel{/t}"/>
</p>
<input type="hidden" name="dn" value="{$dn}"/>
......
......@@ -24,7 +24,7 @@
<div id="pulldown">
<input type="hidden" name="act" id="actionmenu" value=""/>
<div style="display:none"><input type="submit" name="exec_act" id="exec_act" value=""/></div>
<div style="display:none"><input type="submit" formnovalidate="formnovalidate" name="exec_act" id="exec_act" value=""/></div>
<ul class="level1" id="root">
<li>
<a href="#">{t}Actions{/t}&nbsp;<img class="center optional" src="images/down-arrow.png" alt="down arrow"/></a>
......
......@@ -36,7 +36,7 @@
<hr/>
<label for="SEARCH" title="{$SEARCHDESC|escape}"><img src="geticon.php?context=actions&amp;icon=system-search&amp;size=16" alt="Search"/>
<input class="filter_textfield" id="SEARCH" name="SEARCH" type="text" value="{$SEARCH}"/>
<input class="filter_textfield" id="SEARCH" name="SEARCH" type="search" value="{$SEARCH}"/>
</label>
<div>
<input type="submit" name="apply" value="{t}Apply filter{/t}"/>
......
{if $readOnly}
<p class="plugbottom">
<input type="submit" name="edit_cancel" value="{msgPool type=cancelButton}"/>
<input type="submit" formnovalidate="formnovalidate" name="edit_cancel" value="{msgPool type=cancelButton}"/>
</p>
{else}
<p class="plugbottom">
......@@ -10,6 +10,6 @@
<input type="submit" name="edit_apply" value="{msgPool type=applyButton}"/>
&nbsp;
{/if}
<input type="submit" name="edit_cancel" value="{msgPool type=cancelButton}"/>
<input type="submit" formnovalidate="formnovalidate" name="edit_cancel" value="{msgPool type=cancelButton}"/>
</p>
{/if}
......@@ -23,7 +23,7 @@
<p class="plugbottom">
<input type="submit" name="restore_confirmed" value="{t}Continue{/t}"/>
<input type="submit" name="restore_cancel" value="{msgPool type=cancelButton}"/>
<input type="submit" formnovalidate="formnovalidate" name="restore_cancel" value="{msgPool type=cancelButton}"/>
</p>
</div>
</div>
......@@ -22,7 +22,7 @@
<p class="plugbottom">
<input type="submit" name="delete_confirmed" value="{msgPool type=delButton}"/>
<input type="submit" name="delete_cancel" value="{msgPool type=cancelButton}"/>
<input type="submit" formnovalidate="formnovalidate" name="delete_cancel" value="{msgPool type=cancelButton}"/>
</p>
</div>
</div>
......@@ -5,5 +5,5 @@
<input type="submit" name="add_finish" value="{msgPool type=addButton}"/>
&nbsp;
{/if}
<input type="submit" name="add_cancel" value="{msgPool type=cancelButton}"/>
<input type="submit" formnovalidate="formnovalidate" name="add_cancel" value="{msgPool type=cancelButton}"/>
</p>
......@@ -23,5 +23,5 @@
<p class="plugbottom">
<input type="submit" name="template_continue" value="{t}Continue{/t}"/>
&nbsp;
<input type="submit" name="template_cancel" value="{msgPool type=cancelButton}"/>
<input type="submit" formnovalidate="formnovalidate" name="template_cancel" value="{msgPool type=cancelButton}"/>
</p>
......@@ -256,8 +256,8 @@ class CopyPasteHandler
$display .= '<p class="plugbottom">'."\n";
$display .= '<input type="submit" name="edit_finish" style="width:80px" value="'.msgPool::okButton().'"/>'."\n";
$display .= "&nbsp;\n";
$display .= '<input type="submit" name="abort_current_cut-copy_operation" value="'.msgPool::cancelButton().'"/>'."\n";
$display .= '<input type="submit" name="abort_all_cut-copy_operations" value="'._('Cancel all').'"/>'."\n";
$display .= '<input type="submit" formnovalidate="formnovalidate" name="abort_current_cut-copy_operation" value="'.msgPool::cancelButton().'"/>'."\n";
$display .= '<input type="submit" formnovalidate="formnovalidate" name="abort_all_cut-copy_operations" value="'._('Cancel all').'"/>'."\n";
$display .= '</p>';
}
return $display;
......
......@@ -107,7 +107,7 @@ class SnapshotCreateDialog extends simplePlugin
$str .= '<p class="plugbottom">'.
' <input type="submit" name="edit_finish" value="'.msgPool::saveButton().'"/>&nbsp;'.
' <input type="submit" name="edit_cancel" value="'.msgPool::cancelButton().'"/>'.
' <input type="submit" formnovalidate="formnovalidate" name="edit_cancel" value="'.msgPool::cancelButton().'"/>'.
'</p>';
return $str;
......@@ -342,7 +342,7 @@ class SnapshotRestoreDialog extends simplePlugin
$smarty->assign('SnapshotHandlerACL', $acl);
$str = parent::execute();
$str .= '<p class="plugbottom">'.
' <input type="submit" name="edit_cancel" value="'.msgPool::backButton().'"/>'.
' <input type="submit" formnovalidate="formnovalidate" name="edit_cancel" value="'.msgPool::backButton().'"/>'.
'</p>';
}
......
......@@ -260,7 +260,7 @@ class baseSelector
if ($this->submitButton) {
$this->tree .= "&nbsp;<input class='center' type='image' src='geticon.php?context=actions&amp;icon=submit&amp;size=16' title='"._("Submit")."' name='submit_base_".$this->pid."' id='submit_base_".$this->pid."' alt='"._("Submit")."'>";
}
$this->tree .= '<input type="submit" style="display:none" name="submit_tree_base_'.$this->pid.'" id="submit_tree_base_'.$this->pid.'"/>';
$this->tree .= '<input type="submit" formnovalidate="formnovalidate" style="display:none" name="submit_tree_base_'.$this->pid.'" id="submit_tree_base_'.$this->pid.'"/>';
$this->tree .= '<input type="hidden" name="bs_rebase_'.$this->pid.'" id="bs_rebase_'.$this->pid.'"/>';
$this->tree .= '<input type="hidden" name="BPID" id="BPID" value="'.$this->pid.'"/>';
}
......
......@@ -128,7 +128,7 @@ class ldapSizeLimit
function renderWarning()
{
if (($this->sizeLimit >= 10000000) || $this->limitExceeded) {
$config = '<input type="submit" name="edit_sizelimit" value="'._('Configure').'"/>';
$config = '<input type="submit" name="edit_sizelimit" value="'._('Configure').'" formnovalidate="formnovalidate"/>';
} else {
$config = '';
}
......
......@@ -1309,7 +1309,7 @@ class listing
// Load shortcut
$result = '<input type="hidden" name="act" id="actionmenu" value="">'.
'<div style="display:none"><input type="submit" name="exec_act" id="exec_act" value=""/></div>'.
'<div style="display:none"><input type="submit" formnovalidate="formnovalidate" name="exec_act" id="exec_act" value=""/></div>'.
'<ul class="level1" id="root"><li><a href="#">'._('Actions').
'&nbsp;<img class="center optional" src="images/down-arrow.png" alt="down arrow"/></a>';
......
......@@ -166,7 +166,7 @@ class tests
*/
public static function is_mac($mac)
{
return preg_match("/^[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]:[a-f0-9][a-f0-9]$/i", $mac);
return preg_match('/^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$/', $mac);
}
......
......@@ -128,7 +128,7 @@ class ManagementConfigurationDialog extends simplePlugin
$str .= '<p class="plugbottom">'.
' <input type="submit" name="edit_finish" value="'.msgPool::saveButton().'"/>&nbsp;'.
' <input type="submit" name="edit_cancel" value="'.msgPool::cancelButton().'"/>'.
' <input type="submit" formnovalidate="formnovalidate" name="edit_cancel" value="'.msgPool::cancelButton().'"/>'.
'</p>';
return $str;
......
......@@ -169,7 +169,7 @@ class FileDownloadAttribute extends FileAttribute
$display = '';
if ($this->upload) {
$display .= $this->renderInputField('file', $id);
$display .= $this->renderInputField('submit', 'upload'.$id, array('value' => _('Upload')));
$display .= $this->renderInputField('submit', 'upload'.$id, array('value' => _('Upload'), 'formnovalidate' => 'formnovalidate'));
}
$display .= $this->renderInputField(
'image', 'download'.$id,
......
......@@ -108,6 +108,9 @@ class IntAttribute extends Attribute
$js = $this->managedAttributesJS();
$attributes['onChange'] = 'javascript:'.htmlentities($js, ENT_COMPAT, 'UTF-8');
}
if ($this->isRequired()) {
$attributes['required'] = 'required';
}
$display = $this->renderInputField('number', $id, $attributes);
return $this->renderAcl($display);
}
......
......@@ -108,10 +108,15 @@ class phoneSelectDialog extends GenericDialog
/*! \brief This class allow to handle easily an LDAP attribute that contains a phone number
*/
class PhoneNumberAttribute extends TestValidateAttribute
class PhoneNumberAttribute extends StringAttribute
{
protected $trim = TRUE;
protected $testFunc = 'is_phone_nr';
protected $trim = TRUE;
protected $inputType = 'tel';
function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = '', $acl = '', $regexp = '/^[\/0-9 ()+*-]+$/', $example = NULL)
{
parent::__construct($label, $description, $ldapName, $required, $defaultValue, $acl, $regexp, $example);
}
}
/*! \brief Displays a text field and a button to select the phone from object list
......
......@@ -43,7 +43,7 @@ class SetAttribute extends Attribute
$values
);
$this->attribute = $attribute;
$this->attribute->setRequired(TRUE);
$this->attribute->setRequired(FALSE);
$this->valueUnicity = $valueUnicity;
}
......@@ -278,8 +278,8 @@ class SetAttribute extends Attribute
function renderButtons ()
{
$id = $this->getHtmlId();
$buttons = $this->renderInputField('submit', 'add'.$id, array('value' => '{msgPool type=addButton}'));
$buttons .= $this->renderInputField('submit', 'del'.$id, array('value' => '{msgPool type=delButton}'));
$buttons = $this->renderInputField('submit', 'add'.$id, array('value' => '{msgPool type=addButton}', 'formnovalidate' => 'formnovalidate'));
$buttons .= $this->renderInputField('submit', 'del'.$id, array('value' => '{msgPool type=delButton}', 'formnovalidate' => 'formnovalidate'));
return $buttons;
}
......@@ -656,7 +656,7 @@ class OrderedArrayAttribute extends SetAttribute
function renderButtons ()
{
$id = $this->getHtmlId();
$buttons = $this->renderInputField('submit', 'add'.$id, array('value' => '{msgPool type=addButton}'));
$buttons = $this->renderInputField('submit', 'add'.$id, array('value' => '{msgPool type=addButton}', 'formnovalidate' => 'formnovalidate'));
return $buttons;
}
}
......
......@@ -27,6 +27,8 @@ class StringAttribute extends Attribute
protected $example;
protected $autocomplete = NULL;
protected $trim = FALSE;
protected $inputType = 'text';
protected $html5pattern = NULL;
/*! \brief The constructor of StringAttribute
*
......@@ -42,7 +44,7 @@ class StringAttribute extends Attribute
function __construct ($label, $description, $ldapName, $required = FALSE, $defaultValue = "", $acl = "", $regexp = "", $example = NULL)
{
parent::__construct($label, $description, $ldapName, $required, $defaultValue, $acl);
$this->pattern = $regexp;
$this->setPattern($regexp);
$this->example = ($example === NULL ? $defaultValue : $example);
}
......@@ -54,6 +56,14 @@ class StringAttribute extends Attribute
function setPattern ($pattern)
{
$this->pattern = $pattern;
if (preg_match('/^(.)\^(.*)\$\1$/', $pattern, $m)) {
/* Only convert anchored patterns
* First and last characters are the same means no modifiers are in use
*/
$this->html5pattern = $m[2];
} else {
$this->html5pattern = NULL;
}
}
function renderFormInput ()
......@@ -69,7 +79,13 @@ class StringAttribute extends Attribute
if ($this->autocomplete !== NULL) {
$attributes['autocomplete'] = ($this->autocomplete ? 'on' : 'off' );
}
$display = $this->renderInputField('text', $id, $attributes);
if ($this->html5pattern !== NULL) {
$attributes['pattern'] = '{literal}'.htmlentities($this->html5pattern, ENT_COMPAT, 'UTF-8').'{/literal}';
}
if ($this->isRequired()) {
$attributes['required'] = 'required';
}
$display = $this->renderInputField($this->inputType, $id, $attributes);
return $this->renderAcl($display);
}
......@@ -142,7 +158,9 @@ class TextAreaAttribute extends StringAttribute
{
$id = $this->getHtmlId();
$display = '<textarea name="'.$id.'" id="'.$id.'"'.
($this->disabled ? ' disabled="disabled"' : '').'>'.
($this->disabled ? ' disabled="disabled"' : '').
($this->isRequired() ? ' required="required"' : '').
'>'.
'{literal}'.htmlentities($this->getValue(), ENT_COMPAT, 'UTF-8').'{/literal}</textarea>';
return $this->renderAcl($display);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment