forked from jimmylorunning/FormBuilder-2-Craft-CMS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 695aaeb
Showing
115 changed files
with
6,462 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_STORE | ||
.keep | ||
.sass-cache | ||
.sass-cache/* | ||
**/.sass-cache | ||
**/.sass-cache/* | ||
node_modules/ | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
/* | ||
Plugin Name: FormBuilder 2 | ||
Plugin Url: http://github.com/roundhouse/formbuilder2 | ||
Author: Vadim Goncharov (https://github.com/owldesign) | ||
Author URI: http://roundhouseagency.com | ||
Description: Form builder for craft cms. Lets you build multiple forms with custom fields. Dynamically display the forms in your templates. Upon submission the forms are saved and stored in the database as well as notification sent to the form's owner. | ||
Version: 0.0.1 | ||
*/ | ||
|
||
namespace Craft; | ||
|
||
class FormBuilder2Plugin extends BasePlugin | ||
{ | ||
|
||
public function getName() | ||
{ | ||
return 'FormBuilder 2'; | ||
} | ||
|
||
public function getVersion() | ||
{ | ||
return '0.0.1'; | ||
} | ||
|
||
public function getDeveloper() | ||
{ | ||
return 'Roundhouse Agency'; | ||
} | ||
|
||
public function getDeveloperUrl() | ||
{ | ||
return 'https://github.com/roundhouse'; | ||
} | ||
|
||
protected function defineSettings() | ||
{ | ||
return array( | ||
'inputTemplatePath' => array(AttributeType::String, 'default' => 'templates/forms/input', 'required' => true) | ||
); | ||
} | ||
|
||
public function getSettingsHtml() | ||
{ | ||
$settings = craft()->plugins->getPlugin('FormBuilder2')->getSettings(); | ||
|
||
return craft()->templates->render('formbuilder2/configuration', array( | ||
'settings' => $settings | ||
)); | ||
|
||
} | ||
|
||
public function hasCpSection() | ||
{ | ||
return true; | ||
} | ||
|
||
public function registerCpRoutes() | ||
{ | ||
return array( | ||
'formbuilder2' => array('action' => 'formBuilder2/dashboard'), | ||
'formbuilder2/configuration' => array('action' => 'formBuilder2_Configuration/configuration'), | ||
'formbuilder2/entries' => array('action' => 'formBuilder2_Entry/allEntries'), | ||
'formbuilder2/forms' => array('action' => 'formBuilder2_Form/allForms'), | ||
'formbuilder2/form/create' => array('action' => 'formBuilder2_Form/editForm'), | ||
// 'formbuilder2/(?P<recipeId>\d+)' => 'cocktailrecipes/_edit', | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
module.exports = (grunt) -> | ||
grunt.initConfig | ||
|
||
# ============================================= | ||
# VARIABLES | ||
# ============================================= | ||
ScssDirectory: 'resources/scss' | ||
CoffeeDirectory: 'resources/coffee' | ||
ResourcesDirectory: 'resources' | ||
|
||
# ============================================= | ||
# WATCH FOR CHANGE | ||
# ============================================= | ||
watch: | ||
css: | ||
files: ['<%= ScssDirectory %>/**/*'] | ||
tasks: ['sass'] | ||
scripts: | ||
files: ['<%= CoffeeDirectory %>/*'] | ||
tasks: ['coffee'] | ||
options: | ||
livereload: false | ||
|
||
# ============================================= | ||
# SASS COMPILE | ||
# ============================================= | ||
# https://github.com/gruntjs/grunt-contrib-sass | ||
# ============================================= | ||
sass: | ||
compile: | ||
options: | ||
compress: false | ||
sourcemap: 'none' # none, file, inline, none | ||
style: 'nested' # nested, compact, compressed, expanded | ||
files: | ||
'<%= ResourcesDirectory %>/css/formbuilder2.css': '<%= ScssDirectory %>/formbuilder2.scss', | ||
|
||
# ============================================= | ||
# COFFEE COMPILING | ||
# ============================================= | ||
# https://github.com/gruntjs/grunt-contrib-coffee | ||
# ============================================= | ||
coffee: | ||
options: | ||
join: true | ||
bare: true | ||
compile: | ||
files: | ||
'<%= ResourcesDirectory %>/js/formbuilder2.js': ['<%= CoffeeDirectory %>/formbuilder2.coffee'] | ||
|
||
# ============================================= | ||
# UGLIFY JAVASCRIPT | ||
# ============================================= | ||
# https://github.com/gruntjs/grunt-contrib-uglify | ||
# ============================================= | ||
uglify: | ||
options: | ||
sourceMap: true | ||
mangle: false | ||
beautify: false | ||
compress: true | ||
dist: | ||
files: | ||
'<%= ResourcesDirectory %>/js/formbuilder2.min.js': ['<%= ResourcesDirectory %>/js/formbuilder2.js'] | ||
|
||
# ============================================= | ||
# LOAD PLUGINS | ||
# ============================================= | ||
grunt.loadNpmTasks 'grunt-contrib-sass' | ||
grunt.loadNpmTasks 'grunt-contrib-coffee' | ||
grunt.loadNpmTasks 'grunt-contrib-watch' | ||
grunt.loadNpmTasks 'grunt-contrib-uglify' | ||
|
||
# ============================================= | ||
# TASKS | ||
# ============================================= | ||
grunt.registerTask 'default', ['watch'] | ||
grunt.registerTask 'minify', ['uglify'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
<?php | ||
namespace Craft; | ||
|
||
/** | ||
* OFFICIAL DOCUMENTATION: | ||
* http://buildwithcraft.com/docs/plugins/controllers | ||
*/ | ||
|
||
/** | ||
* Business Logic Controller | ||
* | ||
* Controller methods get a little more complicated... There are several ways to access them: | ||
* | ||
* 1. Submitting a form can trigger a controller action. | ||
* 2. Using an AJAX request can trigger a controller action. | ||
* 3. Routing to an action URL will trigger a controller action. | ||
* | ||
* A controller can do many things, but be wary... If your logic gets too complex, you may want | ||
* to off-load much of it to the Service file. | ||
*/ | ||
|
||
class FormBuilder2Controller extends BaseController | ||
{ | ||
|
||
/** | ||
* By default, access to controllers is restricted to logged-in users. | ||
* However, you can allow anonymous access by uncommenting the line below. | ||
* | ||
* It is also possible to allow anonymous access to only certain methods, | ||
* by supplying an array of method names, rather than a boolean value. | ||
* | ||
* See also: | ||
* http://buildwithcraft.com/docs/plugins/controllers#allowing-anonymous-access-to-actions | ||
*/ | ||
protected $allowAnonymous = true; | ||
|
||
/** | ||
* For a normal form submission, send it here. | ||
* | ||
* HOW TO USE IT | ||
* The HTML form in your template should include this hidden field: | ||
* | ||
* <input type="hidden" name="action" value="formbuilder2/exampleFormSubmit"> | ||
* | ||
*/ | ||
public function actionExampleFormSubmit() | ||
{ | ||
// ... whatever you want to do with the submitted data... | ||
$this->redirect('thankyou/page/url'); | ||
} | ||
|
||
/** | ||
* When you need AJAX, this is how to do it. | ||
* | ||
* HOW TO USE IT | ||
* In your front-end JavaScript, POST your AJAX call like this: | ||
* | ||
* // example uses jQuery | ||
* $.post('actions/formbuilder2/exampleAjax' ... | ||
* | ||
* Or if your plugin is doing something within the control panel, | ||
* you've got a built-in function available which Craft provides: | ||
* | ||
* Craft.postActionRequest('formBuilder2/exampleAjax' ... | ||
* | ||
*/ | ||
public function actionExampleAjax() | ||
{ | ||
$this->requireAjaxRequest(); | ||
// ... whatever your AJAX does... | ||
$response = array('response' => 'Round trip via AJAX!'); | ||
$this->returnJson($response); | ||
} | ||
|
||
/** | ||
* Load Dashboard | ||
* | ||
*/ | ||
public function actionDashboard() | ||
{ | ||
$variables['forms'] = craft()->formBuilder2_form->getAllForms(); | ||
$variables['settings'] = craft()->plugins->getPlugin('FormBuilder2'); | ||
return $this->renderTemplate('formbuilder2/dashboard', $variables); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
namespace Craft; | ||
|
||
class FormBuilder2_ConfigurationController extends BaseController | ||
{ | ||
|
||
protected $allowAnonymous = true; | ||
|
||
/** | ||
* Get Plugin Settings for Configuration Page | ||
* | ||
*/ | ||
public function actionConfiguration() | ||
{ | ||
$settings = craft()->plugins->getPlugin('FormBuilder2')->getSettings(); | ||
$plugin = craft()->plugins->getPlugin('FormBuilder2'); | ||
|
||
$this->renderTemplate('formbuilder2/configuration', array( | ||
'settings' => $settings, | ||
'plugin' => $plugin | ||
)); | ||
} | ||
|
||
/** | ||
* Saves a plugin's settings. | ||
* | ||
*/ | ||
public function actionSavePluginSettings() | ||
{ | ||
$this->requirePostRequest(); | ||
$pluginClass = craft()->request->getRequiredPost('pluginClass'); | ||
$settings = craft()->request->getPost(); | ||
|
||
$plugin = craft()->plugins->getPlugin($pluginClass); | ||
if (!$plugin) | ||
{ | ||
throw new Exception(Craft::t('No plugin exists with the class “{class}”', array('class' => $pluginClass))); | ||
} | ||
|
||
if (craft()->plugins->savePluginSettings($plugin, $settings)) | ||
{ | ||
craft()->userSession->setNotice(Craft::t('Plugin settings saved.')); | ||
|
||
$this->redirectToPostedUrl(); | ||
} | ||
|
||
craft()->userSession->setError(Craft::t('Couldn’t save plugin settings.')); | ||
|
||
// Send the plugin back to the template | ||
craft()->urlManager->setRouteVariables(array( | ||
'plugin' => $plugin | ||
)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
namespace Craft; | ||
|
||
class FormBuilder2_EntryController extends BaseController | ||
{ | ||
|
||
protected $allowAnonymous = true; | ||
|
||
|
||
/** | ||
* Get All Forms | ||
* | ||
*/ | ||
public function actionAllEntries() | ||
{ | ||
$variables['forms'] = craft()->formBuilder2_form->getAllForms(); | ||
$variables['settings'] = craft()->plugins->getPlugin('FormBuilder2'); | ||
return $this->renderTemplate('formbuilder2/entries/index', $variables); | ||
} | ||
|
||
|
||
|
||
} |
Oops, something went wrong.