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

feat(attributes) Set HTML5 pattern attribute for StringAttribute

Also added formnovalidate="formnovalidate" to all submit inputs which
 should not validate data.

issue #5910
parent bf686278
......@@ -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>
......
{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>';
......
......@@ -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;
......
......@@ -28,6 +28,7 @@ class StringAttribute extends Attribute
protected $autocomplete = NULL;
protected $trim = FALSE;
protected $inputType = 'text';
protected $html5pattern = NULL;
/*! \brief The constructor of StringAttribute
*
......@@ -43,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);
}
......@@ -55,6 +56,12 @@ class StringAttribute extends Attribute
function setPattern ($pattern)
{
$this->pattern = $pattern;
if (preg_match('/^(.)(.*)\1$/', $pattern, $m)) {
// First and last characters are the same means no modifiers are in use
$this->html5pattern = $m[2];
} else {
$this->html5pattern = NULL;
}
}
function renderFormInput ()
......@@ -70,6 +77,9 @@ class StringAttribute extends Attribute
if ($this->autocomplete !== NULL) {
$attributes['autocomplete'] = ($this->autocomplete ? 'on' : 'off' );
}
if ($this->html5pattern !== NULL) {
$attributes['pattern'] = htmlentities($this->html5pattern, ENT_COMPAT, 'UTF-8');
}
$display = $this->renderInputField($this->inputType, $id, $attributes);
return $this->renderAcl($display);
}
......
......@@ -882,7 +882,7 @@ class GenericSimplePluginDialog extends GenericDialog
{
return '<div style="width:100%; text-align:right; clear:both; float:none;">'.
' <input type="submit" name="'.$this->post_finish.'" value="'.msgPool::saveButton().'"/>&nbsp;'.
' <input type="submit" name="'.$this->post_cancel.'" value="'.msgPool::cancelButton().'"/>'.
' <input type="submit" formnovalidate="formnovalidate" name="'.$this->post_cancel.'" value="'.msgPool::cancelButton().'"/>'.
'</div>';
}
......
......@@ -637,7 +637,7 @@ class simpleManagement
$str = '';
if ($this->tabObject->readOnly()) {
$str .= '<p class="plugbottom">'."\n".
'<input type="submit" name="edit_cancel" value="'.msgPool::cancelButton().'">'."\n".
'<input type="submit" formnovalidate="formnovalidate" name="edit_cancel" value="'.msgPool::cancelButton().'">'."\n".
'</p>';
return $str;
} else {
......@@ -649,7 +649,7 @@ class simpleManagement
$str .= '<input type="submit" name="edit_apply" value="'.msgPool::applyButton().'"/>'."\n";
$str .= "&nbsp;\n";
}
$str .= '<input type="submit" name="edit_cancel" value="'.msgPool::cancelButton().'"/>'."\n";
$str .= '<input type="submit" formnovalidate="formnovalidate" name="edit_cancel" value="'.msgPool::cancelButton().'"/>'."\n";
$str .= '</p>';
}
return $str;
......
......@@ -788,7 +788,7 @@ class simplePlugin
$state = '';
}
$display = '<div width="100%"><p><b>'.$text.'</b><br/>'."\n";
$display .= '<input type="submit" value="'.$button_text.'" name="'.$name.'" '.$state.'></p></div><hr class="separator"/>';
$display .= '<input type="submit" formnovalidate="formnovalidate" value="'.$button_text.'" name="'.$name.'" '.$state.'></p></div><hr class="separator"/>';
return $display;
}
......@@ -2174,7 +2174,7 @@ class simplePlugin
if (session::is_set('edit')) {
$display .= '<input type="submit" name="edit_finish" style="width:80px" value="'.msgPool::okButton().'"/>'."\n";
$display .= '&nbsp;';
$display .= '<input type="submit" name="edit_cancel" value="'.msgPool::cancelButton().'"/>'."\n";
$display .= '<input type="submit" formnovalidate="formnovalidate" name="edit_cancel" value="'.msgPool::cancelButton().'"/>'."\n";
} else {
/* Only display edit button if there is at least one attribute editable */
if (preg_match('/r/', $ui->get_permissions($entry_dn, $plCategory.'/'.$tabObject->current))) {
......
......@@ -54,7 +54,7 @@ class simpleService extends simplePlugin
if (!$this->dialog) {
$str .= '<p class="plugbottom servicebottom">'.
' <input type="submit" name="SaveService" value="'.msgPool::saveButton().'"/>&nbsp;'.
' <input type="submit" name="CancelService" value="'.msgPool::cancelButton().'"/>'.
' <input type="submit" formnovalidate="formnovalidate" name="CancelService" value="'.msgPool::cancelButton().'"/>'.
'</div>';
}
......
......@@ -101,7 +101,7 @@ class aclAssignmentDialogWindow extends simplePlugin
'<p class="plugbottom">'.
' <input type="submit" name="add_acl_finish" value="{msgPool type=addButton}"/>'.
' &nbsp;'.
' <input type="submit" name="add_acl_cancel" value="{msgPool type=cancelButton}"/>'.
' <input type="submit" formnovalidate="formnovalidate" name="add_acl_cancel" value="{msgPool type=cancelButton}"/>'.
'</p>');
}
return $display;
......
......@@ -92,7 +92,7 @@ class aclAssignmentCreationDialog extends simplePlugin
return parent::execute()."\n".
'<p class="plugbottom">'."\n".
' <input type="submit" name="'.$this->post_finish.'" value="'.msgPool::addButton().'"/>&nbsp;'."\n".
' <input type="submit" name="'.$this->post_cancel.'" value="'.msgPool::cancelButton().'"/>'."\n".
' <input type="submit" formnovalidate="formnovalidate" name="'.$this->post_cancel.'" value="'.msgPool::cancelButton().'"/>'."\n".
'</p>';
}
}
......
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