Convert to vendor module, remove secure assets suggestion

This commit is contained in:
Robbie Averill 2017-10-18 22:02:49 +13:00
parent 177bd3eec7
commit 9c15c74f7b
6 changed files with 25 additions and 30 deletions

View File

@ -2,7 +2,7 @@ language: php
env:
global:
- COMPOSER_ROOT_VERSION=4.0.x-dev
- COMPOSER_ROOT_VERSION=5.0.x-dev
matrix:
include:

View File

@ -8,7 +8,6 @@ use SilverStripe\Assets\Upload;
use SilverStripe\Control\Controller;
use SilverStripe\Control\Email\Email;
use SilverStripe\Control\HTTP;
use SilverStripe\Core\Manifest\Module;
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\Form;
use SilverStripe\i18n\i18n;
@ -45,28 +44,26 @@ class UserDefinedFormController extends PageController
$page = $this->data();
$userforms = ModuleLoader::getModule('silverstripe/userforms');
$admin = ModuleLoader::getModule('silverstripe/admin');
// load the css
if (!$page->config()->get('block_default_userforms_css')) {
Requirements::css($userforms->getRelativeResourcePath('client/dist/styles/userforms.css'));
Requirements::css('silverstripe/userforms:client/dist/styles/userforms.css');
}
// load the jquery
if (!$page->config()->get('block_default_userforms_js')) {
Requirements::javascript('//code.jquery.com/jquery-1.7.2.min.js');
Requirements::javascript(
$userforms->getRelativeResourcePath('client/thirdparty/jquery-validate/jquery.validate.min.js')
'silverstripe/userforms:client/thirdparty/jquery-validate/jquery.validate.min.js'
);
Requirements::add_i18n_javascript($userforms->getRelativeResourcePath('client/lang'));
Requirements::javascript($userforms->getRelativeResourcePath('client/dist/js/userforms.js'));
Requirements::add_i18n_javascript('silverstripe/userforms:client/lang');
Requirements::javascript('silverstripe/userforms:client/dist/js/userforms.js');
$this->addUserFormsValidatei18n($userforms);
$this->addUserFormsValidatei18n();
// Bind a confirmation message when navigating away from a partially completed form.
if ($page::config()->get('enable_are_you_sure')) {
Requirements::javascript(
$userforms->getRelativeResourcePath('client/thirdparty/jquery.are-you-sure/jquery.are-you-sure.js')
'silverstripe/userforms:client/thirdparty/jquery.are-you-sure/jquery.are-you-sure.js'
);
}
}
@ -76,11 +73,11 @@ class UserDefinedFormController extends PageController
* Add the necessary jQuery validate i18n translation files, either by locale or by langauge,
* e.g. 'en_NZ' or 'en'. This adds "methods_abc.min.js" as well as "messages_abc.min.js" from the
* jQuery validate thirdparty library.
*
* @param Module $module
*/
protected function addUserFormsValidatei18n(Module $module)
protected function addUserFormsValidatei18n()
{
$module = ModuleLoader::getModule('silverstripe/userforms');
$candidates = [
i18n::getData()->langFromLocale(i18n::config()->get('default_locale')),
i18n::config()->get('default_locale'),
@ -91,8 +88,10 @@ class UserDefinedFormController extends PageController
foreach ($candidates as $candidate) {
foreach (['messages', 'methods'] as $candidateType) {
$localisationCandidate = "client/thirdparty/jquery-validate/localization/{$candidateType}_{$candidate}.min.js";
if ($module->hasResource($localisationCandidate)) {
Requirements::javascript($module->getRelativeResourcePath($localisationCandidate));
$resource = $module->getResource($localisationCandidate);
if ($resource->exists()) {
Requirements::javascript($resource->getRelativePath());
}
}
}

View File

@ -2,7 +2,6 @@
namespace SilverStripe\UserForms\Extension;
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\Tab;
use SilverStripe\Forms\GridField\GridField;
@ -66,8 +65,7 @@ class UserFormFieldEditorExtension extends DataExtension
*/
public function getFieldEditorGrid()
{
$module = ModuleLoader::getModule('silverstripe/userforms');
Requirements::javascript($module->getRelativeResourcePath('client/dist/js/userforms-cms.js'));
Requirements::javascript('silverstripe/userforms:client/dist/js/userforms-cms.js');
$fields = $this->owner->Fields();

View File

@ -8,7 +8,6 @@ use SilverStripe\CMS\Controllers\CMSMain;
use SilverStripe\CMS\Controllers\CMSPageEditController;
use SilverStripe\Control\Controller;
use SilverStripe\Control\Email\Email;
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldGroup;
@ -187,9 +186,7 @@ class EmailRecipient extends DataObject
*/
public function getCMSFields()
{
Requirements::javascript(
ModuleLoader::getModule('silverstripe/userforms')->getRelativeResourcePath('client/dist/js/userforms-cms.js')
);
Requirements::javascript('silverstripe/userforms:client/dist/js/userforms-cms.js');
// Determine optional field values
$form = $this->getFormParent();

View File

@ -4,7 +4,6 @@ namespace SilverStripe\UserForms;
use Colymba\BulkManager\BulkManager;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Core\Manifest\ModuleLoader;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\CompositeField;
use SilverStripe\Forms\FieldList;
@ -167,10 +166,7 @@ trait UserForm
*/
public function getCMSFields()
{
Requirements::css(
ModuleLoader::getModule('silverstripe/userforms')
->getRelativeResourcePath('client/dist/styles/userforms-cms.css')
);
Requirements::css('silverstripe/userforms:client/dist/styles/userforms-cms.css');
$this->beforeUpdateCMSFields(function ($fields) {

View File

@ -1,7 +1,7 @@
{
"name": "silverstripe/userforms",
"description": "UserForms enables CMS users to create dynamic forms via a drag and drop interface and without getting involved in any PHP code",
"type": "silverstripe-module",
"type": "silverstripe-vendormodule",
"keywords": [
"silverstripe",
"userforms"
@ -48,13 +48,18 @@
},
"suggest": {
"colymba/gridfield-bulk-editing-tools": "Allows for bulk management of form submissions",
"silverstripe/secureassets": "Enables files uploaded via userforms to be secured from public access",
"silverstripe/gridfieldqueuedexport": "Export large submission as CSV through queued jobs in the background"
},
"extra": {
"branch-alias": {
"dev-master": "5.0.x-dev"
}
},
"expose": [
"client/dist",
"client/lang",
"client/thirdparty",
"images"
]
},
"prefer-stable": true,
"minimum-stability": "dev"