Permalink
Browse files

First commit

  • Loading branch information...
0 parents commit bf2df277a068a96792a85630e3d89545a4e422cc @migliori committed Aug 13, 2015
@@ -0,0 +1,5 @@
+[
+ {
+ "keys": ["ctrl+alt+w"], "command": "php_form_builder"
+ }
+]
@@ -0,0 +1,5 @@
+[
+ {
+ "keys": ["super+alt+w"], "command": "php_form_builder"
+ }
+]
@@ -0,0 +1,5 @@
+[
+ {
+ "keys": ["ctrl+alt+w"], "command": "php_form_builder"
+ }
+]
@@ -0,0 +1,160 @@
+[{
+ "id": "tools",
+ "children": [{
+ "id": "php_form_builder",
+ "caption": "PHP Form Builder",
+ "children": [{
+ "id": "php_form_builder_completions",
+ "caption": "Completions",
+ "children": [{
+ "caption": "new Form()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "newForm"}
+ }, {
+ "caption": "setAction()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "setAction"}
+ }, {
+ "caption": "startFieldset()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "startFieldset"}
+ }, {
+ "caption": "endFieldset()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "endFieldset"}
+ }, {
+ "caption": "addInputWrapper()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "addInputWrapper"}
+ }, {
+ "caption": "groupInputs()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "groupInputs"}
+ }, {
+ "caption": "addInput()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "addInput"}
+ }, {
+ "caption": "addTextarea()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "addTextarea"}
+ }, {
+ "caption": "addOption()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "addOption"}
+ }, {
+ "caption": "addSelect()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "addSelect"}
+ }, {
+ "caption": "addCountrySelect()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "addCountrySelect"}
+ }, {
+ "caption": "addRadio()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "addRadio"}
+ }, {
+ "caption": "printRadioGroup()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "printRadioGroup"}
+ }, {
+ "caption": "addCheckbox()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "addCheckbox"}
+ }, {
+ "caption": "printCheckboxGroup()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "printCheckboxGroup"}
+ }, {
+ "caption": "addBtn()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "addBtn"}
+ }, {
+ "caption": "printBtnGroup()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "printBtnGroup"}
+ }, {
+ "caption": "addPlugin()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "addPlugin"}
+ }, {
+ "caption": "addFileUpload()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "addFileUpload"}
+ }, {
+ "caption": "printIncludes()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "printIncludes"}
+ }, {
+ "caption": "printJsCode()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "printJsCode"}
+ }, {
+ "caption": "render()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "render"}
+ }, {
+ "caption": "Form::sendMail()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "FormSendMail"}
+ }, {
+ "caption": "Form::sendAdvancedMail()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "FormSendAdvancedMail"}
+ }, {
+ "caption": "Form::registerValues()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "FormRegisterValues"}
+ }, {
+ "caption": "Form::mergeValues()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "FormMergeValues"}
+ }, {
+ "caption": "Form::clear()",
+ "command": "completion_trigger", "args": {"completionTriggerText": "FormClear"}
+ }]
+ }]
+ }]
+},
+{
+ "caption": "Preferences",
+ "mnemonic": "n",
+ "id": "preferences",
+ "children": [{
+ "caption": "Package Settings",
+ "mnemonic": "P",
+ "id": "package-settings",
+ "children": [{
+ "caption": "PHP Form Builder",
+ "children": [{
+ "command": "open_file",
+ "args": {
+ "file": "${packages}/PHP Form Builder/Default (OSX).sublime-keymap",
+ "platform": "OSX"
+ },
+ "caption": "Key Bindings – Default"
+ },
+ {
+ "command": "open_file",
+ "args": {
+ "file": "${packages}/PHP Form Builder/Default (Linux).sublime-keymap",
+ "platform": "Linux"
+ },
+ "caption": "Key Bindings – Default"
+ },
+ {
+ "command": "open_file",
+ "args": {
+ "file": "${packages}/PHP Form Builder/Default (Windows).sublime-keymap",
+ "platform": "Windows"
+ },
+ "caption": "Key Bindings – Default"
+ },
+ {
+ "command": "open_file",
+ "args": {
+ "file": "${packages}/User/Default (OSX).sublime-keymap",
+ "platform": "OSX"
+ },
+ "caption": "Key Bindings – User"
+ },
+ {
+ "command": "open_file",
+ "args": {
+ "file": "${packages}/User/Default (Linux).sublime-keymap",
+ "platform": "Linux"
+ },
+ "caption": "Key Bindings – User"
+ },
+ {
+ "command": "open_file",
+ "args": {
+ "file": "${packages}/User/Default (Windows).sublime-keymap",
+ "platform": "Windows"
+ },
+ "caption": "Key Bindings – User"
+ },
+ { "caption": "-" },
+ {
+ "command": "open_file",
+ "args": {"file": "${packages}/PHP Form Builder/README.md"},
+ "caption": "README"
+ }]
+ }]
+ }]
+}]
@@ -0,0 +1,78 @@
+import sublime, sublime_plugin
+
+class CompletionTriggerCommand(sublime_plugin.TextCommand):
+ def run(self, edit, completionTriggerText):
+ self.view.insert(edit, self.view.sel()[0].begin(), completionTriggerText)
+ self.view.run_command("auto_complete")
+ self.view.run_command("insert_best_completion")
+
+class phpFormBuilderCommand(sublime_plugin.TextCommand):
+ def on_quick_panel_selection(self, index):
+ if index == -1:
+ return
+ else:
+ self.view.run_command('completion_trigger', {"completionTriggerText": self.completions_trigger[index]})
+ def run(self, edit):
+ self.form_element_labels = [
+ 'new Form($form_ID, $layout = \'horizontal\', $attr = \'\');',
+ 'setAction($url, $add_get_vars = true)',
+ 'setOptions();',
+ 'startFieldset($legend = \'\')',
+ 'endFieldset()',
+ 'addInputWrapper($html, $element_name)',
+ 'groupInputs($input1, $input2, $input3 = \'\')',
+ 'addInput($type, $name, $value = \'\', $label = \'\', $attr = \'\')',
+ 'addTextarea($name, $value = \'\', $label = \'\', $attr = \'\')',
+ 'addOption($select_name, $value, $txt, $group_name = \'\', $attr = \'\')',
+ 'addSelect($select_name, $label = \'\', $attr = \'\', $displayGroupLabels = true)',
+ 'addCountrySelect($select_name, $label = \'\', $attr = \'\', $user_options = array())',
+ 'addRadio($group_name, $label, $value, $attr)',
+ 'printRadioGroup($group_name, $label = \'\', $inline = true, $attr = \'\')',
+ 'addCheckbox($group_name, $label, $name, $value, $attr)',
+ 'printCheckboxGroup($group_name, $label = \'\', $inline = true, $attr = \'\')',
+ 'addBtn($type, $name, $value, $text, $attr = \'\', $btnGroupName = \'\')',
+ 'printBtnGroup($btnGroupName, $label = \'\')',
+ 'addHtml($html, $element_name = \'\', $pos = \'after\')',
+ 'addPlugin($plugin_name, $selector, $js_content = \'default\', $js_replacements = \'\')',
+ 'addFileUpload($type, $name, $value = \'\', $label = \'\', $attr = \'\', $fileUpload_config = \'\')',
+ 'printIncludes($type)',
+ 'render($debug = false)',
+ 'printJsCode()',
+ 'Form::sendMail($from_email, $adress, $subject, $filter_values = \'\', $values = \'\')',
+ 'Form::sendAdvancedMail($options, $values = \'\')',
+ 'Form::registerValues($form_ID)',
+ 'Form::mergeValues(array(\'step-form-1\', \'step-form-2\', \'step-form-3\'))',
+ 'Form::clear($form_ID)'
+ ]
+ self.completions_trigger = [
+ 'newForm',
+ 'setAction',
+ 'setOptions',
+ 'startFieldset',
+ 'endFieldset',
+ 'addInputWrapper',
+ 'groupInputs',
+ 'addInput',
+ 'addTextarea',
+ 'addOption',
+ 'addSelect',
+ 'addCountrySelect',
+ 'addRadio',
+ 'printRadioGroup',
+ 'addCheckbox',
+ 'printCheckboxGroup',
+ 'addBtn',
+ 'printBtnGroup',
+ 'addHtml',
+ 'addPlugin',
+ 'addFileUpload',
+ 'printIncludes',
+ 'render',
+ 'printJsCode',
+ 'FormSendMail',
+ 'FormSendAdvancedMail',
+ 'FormRegisterValues',
+ 'FormMergeValues',
+ 'FormClear'
+ ]
+ self.view.window().show_quick_panel(self.form_element_labels, self.on_quick_panel_selection)
@@ -0,0 +1,36 @@
+{
+ "scope": "source.php -variable.other.php",
+
+ "completions":
+ [
+ { "trigger": "setOptions();", "contents": "\\$options = array(\n 'horizontalLabelCol' => 'col-sm-${1:4}',\n 'horizontalOffsetCol' => 'col-sm-offset-${1:4}',\n 'horizontalElementCol' => 'col-sm-${2:8}',\n);\n\\$form->setOptions(\\$options);" },
+ { "trigger": "newForm", "contents": "use phpforms\\Form;\nuse phpforms\\Validator\\Validator;\n\n@session_start();\ninclude_once rtrim(\\$_SERVER['DOCUMENT_ROOT'], DIRECTORY_SEPARATOR) . '/${1:phpforms}/Form.php';\n/* =============================================\n validation if posted\n============================================= */\n\nif (\\$_SERVER[\"REQUEST_METHOD\"] == \"POST\") {\n include_once '${1:phpforms}/Validator/Validator.php';\n include_once '${1:phpforms}/Validator/Exception.php';\n \\$validator = new Validator(\\$_POST);\n \\$required = array('name', 'first-name');\n foreach (\\$required as \\$required) {\n \\$validator->required()->validate(\\$required);\n }\n // check for errors\n\n if (\\$validator->hasErrors()) {\n \\$_SESSION['errors']['${2:my-form}'] = \\$validator->getAllErrors();\n } else {\n \\$from_email = '${3:you@your-email.com}';\n \\$adress = '${3:you@your-email.com}';\n \\$subject = '${4:Email Subject}';\n \\$filter_values = '${2:my-form}, submit-btn';\n \\$sent_message = Form::sendMail(\\$from_email, \\$adress, \\$subject, \\$filter_values);\n Form::clear('${2:my-form}');\n }\n}\n\\$form = new Form('${2:my-form}');\n\\$form->addInput('text', 'name', '', 'Name : ', 'required=required');\n\\$form->addInput('text', 'first-name', '', 'First name : ', 'required=required');\n\\$form->addBtn('button', 'cancel', 0, 'Cancel', 'class=btn btn-warning', 'btn-group');\n\\$form->addBtn('submit', 'submit-btn', 1, 'Submit', 'class=btn btn-success', 'btn-group');\n\\$form->printBtnGroup('btn-group');" },
+ { "trigger": "setAction($url, $add_get_vars = true)", "contents": "\\$form->setAction(${1:htmlspecialchars($_SERVER[\"PHP_SELF\"])}, ${2:\\$add_get_vars = true});" },
+ { "trigger": "addHtml($html, $element_name = '', $pos = 'after')", "contents": "\\$form->addHtml(${1:\\$html}, ${2:\\$element_name = ''}, ${3:\\$pos = 'after'});" },
+ { "trigger": "addInputWrapper($html, $element_name)", "contents": "\\$form->addInputWrapper(${1:'<div class=\"wrapper\"></div>'}, ${2:'element_name'});" },
+ { "trigger": "addInput($type, $name, $value = '', $label = '', $attr = '')", "contents": "\\$form->addInput(${1:\\$type}, ${2:\\$name}, ${3:\\$value = ''}, ${4:\\$label = ''}, ${5:\\$attr = ''});" },
+ { "trigger": "groupInputs($input1, $input2, $input3 = '')", "contents": "\\$form->groupInputs('${1:field_1}', '${2:field_2}');" },
+ { "trigger": "addFileUpload($type, $name, $value = '', $label = '', $attr = '', $fileUpload_config = '')", "contents": "\\$fileUpload_config = array(\n 'xml' => ${1:'default'},\n 'uploader' => ${2:'defaultFileUpload.php'},\n 'btn-text' => ${3:'Browse ...'},\n 'max-number-of-files' => ${4:3}\n);\n\\$form->addHtml('<span class=\"help-block\">3 files max. Accepted File Types : .pdf, .doc[x], .xls[x], .txt</span>', ${5:\\$name}, 'after');\n\\$form->addFileUpload('file', ${5:\\$name}, ${6:\\$value = ''}, ${7:\\$label = ''}, ${8:\\$attr = ''}, \\$fileUpload_config);\n" },
+ { "trigger": "addTextarea($name, $value = '', $label = '', $attr = '')", "contents": "\\$form->addTextarea(${1:\\$name}, ${2:\\$value = ''}, ${3:\\$label = ''}, ${4:\\$attr = ''});" },
+ { "trigger": "addOption($select_name, $value, $txt, $group_name = '', $attr = '')", "contents": "\\$form->addOption(${1:\\$select_name}, ${2:\\$value}, ${3:\\$txt}, ${4:\\$group_name = ''}, ${5:\\$attr = ''});" },
+ { "trigger": "addSelect($select_name, $label = '', $attr = '', $displayGroupLabels = true)", "contents": "\\$form->addSelect(${1:\\$select_name}, ${2:\\$label}, ${3:\\$attr = ''}, ${4:\\$displayGroupLabels = true});" },
+ { "trigger": "addCountrySelect($select_name, $label = '', $attr = '', $user_options = array())", "contents": "\\$form->addCountrySelect('${1:country}', '${2:Country : }');" },
+ { "trigger": "addRadio($group_name, $label, $value, $attr)", "contents": "\\$form->addRadio(${1:\\$group_name}, ${2:\\$label}, ${3:\\$value}, ${4:\\$attr = ''});" },
+ { "trigger": "printRadioGroup($group_name, $label = '', $inline = true, $attr = '')", "contents": "\\$form->printRadioGroup(${1:\\$group_name}, ${2:\\$label}, ${3:\\$inline = true}, ${4:\\$attr = ''});" },
+ { "trigger": "addCheckbox($group_name, $label, $name, $value, $attr)", "contents": "\\$form->addCheckbox(${1:\\$group_name}, ${2:\\$label}, ${3:\\$name}, ${4:\\$value}, ${5:\\$attr});" },
+ { "trigger": "printCheckboxGroup($group_name, $label = '', $inline = true, $attr = '')", "contents": "\\$form->printCheckboxGroup(${1:\\$group_name}, ${2:\\$label}, ${3:\\$inline = true}, ${4:\\$attr = ''});" },
+ { "trigger": "addBtn($type, $name, $value, $text, $attr = '', $btnGroupName = '')", "contents": "\\$form->addBtn(${1:\\$type}, ${2:\\$name}, ${3:\\$value}, ${4:\\$text}, ${5:\\$attr = ''}, ${6:\\$btnGroupName = ''});" },
+ { "trigger": "printBtnGroup($btnGroupName, $label = '')", "contents": "\\$form->printBtnGroup(${1:\\$btnGroupName}, ${2:\\$label = ''});" },
+ { "trigger": "startFieldset($legend = '')", "contents": "\\$form->startFieldset(${1:\\$legend = ''});" },
+ { "trigger": "endFieldset()", "contents": "\\$form->endFieldset();" },
+ { "trigger": "addPlugin($plugin_name, $selector, $js_content = 'default', $js_replacements = '')", "contents": "\\$form->addPlugin(${1:\\$plugin_name}, ${2:'#selector'}, ${3:\\$js_content = 'default'}, ${4:\\$js_replacements = ''});" },
+ { "trigger": "printIncludes($type)", "contents": "\\$form->printIncludes('${1:js | css}');" },
+ { "trigger": "printJsCode()", "contents": "\\$form->printJsCode();" },
+ { "trigger": "FormSendMail($from_email, $adress, $subject, $filter_values = '', $values = '')", "contents": "\\$from_email = '${1:you@your-email.com}';\n\\$adress = '${2:recipient@email.com}';\n\\$subject = '${3:Email Subject}';\n\\$filter_values = '${4:my-form, submit-btn}';\n\\$sent_message = Form::sendMail(\\$from_email, \\$adress, \\$subject, \\$filter_values);" },
+ { "trigger": "FormSendAdvancedMail($options, $values = '')", "contents": "\\$options = array(\n 'from_email' => '${1:you@your-email.com}',\n 'from_name' => '${2:phpforms}', // optional\n 'reply_to' => '${3:you@your-email.com}', // optional\n 'adress' => '${4:john.doe@gmail.com}',\n 'cc' => '${5:john.doe@free.fr}', // optional\n 'bcc' => '${6:john.doe@hotmail.com, john.doe@wanadoo.com}', // optional\n 'subject' => '${7:contact from phpforms}',\n 'attachments' => '${8:img/wallacegromit.jpg}', // optional\n 'html_template' => '${9:../mailer/email-templates/contact-email.html}', // optional\n 'css_template' => '${10:../mailer/email-templates/contact-email.css'}, // optional\n 'filter_values' => '${11:}', // optional\n 'sent_message' => '${12:<p class=\"alert alert-success\">Your message has been successfully sent !</p>}', // optional\n 'display_errors' => ${13:true} // optional, default false\n );\n \\$sent_message = Form::sendAdvancedMail(\\$options);\n" },
+ { "trigger": "FormRegisterValues($form_ID)", "contents": "Form::registerValues('${1:my-form}');" },
+ { "trigger": "FormMergeValues(array('step-form-1', 'step-form-2', 'step-form-3'))", "contents": "Form::mergeValues(array('${1:step-form-1}', '${2:step-form-2}', '${3:step-form-3}'));" },
+ { "trigger": "FormClear($form_ID)", "contents": "Form::clear('${1:my-form}');" },
+ { "trigger": "render($debug = false)", "contents": "\\$form->render(${1:true | false});" }
+ ]
+}
Oops, something went wrong.

0 comments on commit bf2df27

Please sign in to comment.