Skip to content

Commit

Permalink
Added Form Creator plugin support
Browse files Browse the repository at this point in the history
Added helper function isValidInteger() to be able to test if a field is an integer
changed version to 0.1.7
  • Loading branch information
tomolimo committed Dec 16, 2016
1 parent 6409db0 commit 424a834
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 11 deletions.
6 changes: 3 additions & 3 deletions formvalidation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@
</authors>
<versions>
<version>
<num>0.1.6</num>
<num>0.1.7</num>
<compatibility>0.85</compatibility>
</version>
<version>
<num>0.1.6</num>
<num>0.1.7</num>
<compatibility>0.90</compatibility>
</version>
<version>
<num>0.1.6</num>
<num>0.1.7</num>
<compatibility>9.1</compatibility>
</version>
</versions>
Expand Down
2 changes: 1 addition & 1 deletion hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function plugin_formvalidation_install() {
(4, 'Name', 3, 'div>table>tbody>tr:eq(1)>td:eq(1) input[name=\\\"name\\\"]', NULL, 'div>table>tbody>tr:eq(1)>td:eq(1)', 'div>table>tbody>tr:eq(1)>td:eq(0)', 1, 1, NULL, NULL, NULL, NULL),
(5, 'Value CSS selector', 3, 'div>table>tbody>tr:eq(3)>td:eq(1) input[name=\\\"css_selector_value\\\"]', NULL, 'div>table>tbody>tr:eq(3)>td:eq(1)', 'div>table>tbody>tr:eq(3)>td:eq(0)', 1, 1, NULL, NULL, NULL, NULL),
(6, 'Force mandatory sign', 3, 'div>table>tbody>tr:eq(6)>td:eq(1)>span input[name=\\\"show_mandatory\\\"]', NULL, 'div>table>tbody>tr:eq(6)>td:eq(1)', 'div>table>tbody>tr:eq(6)>td:eq(0)', 1, 0, NULL, NULL, NULL, NULL),
(7, 'Mandatory sign formula', 3, 'div>table>tbody>tr:eq(7)>td:eq(1) input[name=\\\"show_mandatory_if\\\"]', NULL, 'div>table>tbody>tr:eq(7)>td:eq(1)', 'div>table>tbody>tr:eq(7)>td:eq(0)', 1, 0, NULL, NULL, NULL, NULL),
(7, 'Mandatory sign formula', 3, 'div>table>tbody>tr:eq(7)>td:eq(1) input[name=\\\"show_mandatory_if\\\"]', NULL, 'div>table>tbody>tr:eq(7)>td:eq(1)', 'div>table>tbody>tr:eq(7)>td:eq(0)', 0, 0, NULL, NULL, NULL, NULL),
(8, 'Mandatory sign CSS selector', 3, 'div>table>tbody>tr:eq(8)>td:eq(1) input[name=\\\"css_selector_mandatorysign\\\"]', NULL, 'div>table>tbody>tr:eq(8)>td:eq(1)', 'div>table>tbody>tr:eq(8)>td:eq(0)', 1, 0, '#6 || #7!=\'\'', NULL, NULL, NULL),
(9, 'Title', 4, 'div>table>tbody>tr:eq(8)>td:eq(1) input[name=\\\"name\\\"]', NULL, 'div>table>tbody>tr:eq(8)>td:eq(1)', 'div>table>tbody>tr:eq(8)>td:eq(0)', 1, 1, NULL, NULL, NULL, NULL),
(10, 'Description', 4, 'div>table>tbody>tr:eq(9)>td:eq(1)>div textarea[name=\\\"content\\\"]', NULL, 'div>table>tbody>tr:eq(9)>td:eq(1)', 'div>table>tbody>tr:eq(9)>td:eq(0)', 1, 0, '#11 == 2','(#11 == 1) || (#11 == 2 && #.length > 10 && countWords(#) > 5)', NULL, NULL),
Expand Down
8 changes: 6 additions & 2 deletions inc/page.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ function showForm ($ID, $options=array('candel'=>false)) {
}

static function getItemtypes() {
echo '';
return array(
__("Assets") => array(
'Computer' => _n("Computer", "Computers", 2),
Expand Down Expand Up @@ -186,8 +187,11 @@ static function getItemtypes() {
'User' => _n("User", "Users", 2),
'Group' => _n("Group", "Groups", 2),
'Entity' => _n("Entity", "Entities", 2),
'Profile' => _n("Profile", "Profiles", 2))
);
'Profile' => _n("Profile", "Profiles", 2)),
__("Plugins") => array(
'PluginFormcreatorForm' => "Form Creator"
)
);
}


Expand Down
14 changes: 12 additions & 2 deletions js/formvalidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,13 @@ along with GLPI. If not, see <http://www.gnu.org/licenses/>.
return /^(?:[0-1]\d|2[0-3]):[0-5]\d(?::[0-5]\d)?$/.test(str);
}


//------------------------------------------
// helper function to verify a if a string
// is really an integer
//------------------------------------------
function isValidInteger(str) {
return /^\d+$/.test(str);
}

//------------------------------------------
// helper function to count words in a given string
Expand Down Expand Up @@ -159,7 +165,7 @@ along with GLPI. If not, see <http://www.gnu.org/licenses/>.
$('<div></div>').dialog({
open: function (event, ui) { $('.ui-dialog-titlebar-close').hide(); },
close: function (event, ui) { $(this).remove(); $('.ui-widget-overlay.ui-front').remove(); },
resizable: false,
resizable: true,
modal: true,
title: title,
buttons: {
Expand All @@ -184,10 +190,14 @@ along with GLPI. If not, see <http://www.gnu.org/licenses/>.

// "/plugins/formvalidation/front/page.form.php"
// "/plugins/rayusermanagementticket/front/rayusermanagementticket.helpdesk.public.php"
// "/plugins/formcreator/front/formdisplay.php"
var itemtype = location.pathname.match(/(plugin)s\/([a-z]+)(?:\/[a-z]+)+\/([a-z]+)\.form\.php$/);
if (!itemtype) {
itemtype = location.pathname.match(/(plugin)s\/([a-z]+)(?:\/[a-z]+)+\/([a-z]+)\.helpdesk.public\.php$/);
}
if (!itemtype) {
itemtype = location.pathname.match(/(plugin)s\/(formcreator)\/front\/(form)display.php$/);
}
if (!itemtype) {
itemtype = location.pathname.match(/front\/helpdesk.public.php$/);
if (itemtype && !location.search.match(/^\?create_ticket=1$/)) {
Expand Down
3 changes: 2 additions & 1 deletion locales/en_GB.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
--------------------------------------------------------------------------
*/
$LANG['plugin_formvalidation']['alert']="Form Validation";
$LANG['plugin_formvalidation']['mandatorytitle']="Mandatory fields:";
$LANG['plugin_formvalidation']['mandatorytitle']="Mandatory fields or wrong values:";
$LANG['plugin_formvalidation']['formulaerror']="Contact your admin: an evaluation error occured in formula: ";

// Form Validation Messages
Expand All @@ -42,3 +42,4 @@
$LANG['plugin_formvalidation']['forms'][4][4][10]="Description must be at least 10 chars and 5 words.";
$LANG['plugin_formvalidation']['forms'][4][5][12]="Description must be at least 10 chars and 3 words.";
$LANG['plugin_formvalidation']['forms'][4][6][14]="Description must be at least 10 chars and 5 words.";

2 changes: 1 addition & 1 deletion locales/fr_FR.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
--------------------------------------------------------------------------
*/
$LANG['plugin_formvalidation']['alert']="Validation formulaire";
$LANG['plugin_formvalidation']['mandatorytitle']="Champs obligatoires :";
$LANG['plugin_formvalidation']['mandatorytitle']="Champs obligatoires ou valeurs erronées :";
$LANG['plugin_formvalidation']['formulaerror']="Contactez votre administrateur : une erreur d'évaluation est survenue dans la formule : ";

// Form Validation Messages
Expand Down
2 changes: 1 addition & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function plugin_init_formvalidation() {
function plugin_version_formvalidation() {

return array('name' => 'Form Validation',
'version' => '0.1.6',
'version' => '0.1.7',
'author' => 'Olivier Moron',
'license' => 'GPLv2+',
'homepage' => 'https://github.com/tomolimo/formvalidation',
Expand Down

0 comments on commit 424a834

Please sign in to comment.