diff --git a/app/_config.php b/app/_config.php index 78d5a31..04b0f68 100644 --- a/app/_config.php +++ b/app/_config.php @@ -20,5 +20,12 @@ $config->enablePlugins([ $config->addButtonsToLine(2, 'hr'); $config->setOption('block_formats', 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Address=address;Pre=pre'); $config->setOption('invalid_elements', 'h1'); +$config->setOption( + 'table_class_list', + [ + ['title' => 'Transparent Table', 'value' => 'table-none'], + ['title' => 'Shaded rows', 'value' => 'table table-striped table-bordered'], + ] +); FulltextSearchable::enable(); diff --git a/app/_config/config.yml b/app/_config/config.yml index 406240d..261fb4a 100644 --- a/app/_config/config.yml +++ b/app/_config/config.yml @@ -19,8 +19,8 @@ SilverStripe\View\SSViewer: SilverStripe\Admin\LeftAndMain: extra_requirements_css: - - 'app/client/dist/css/cms.css' + - 'app/client/dist/css/app_cms.css' SilverStripe\Forms\HTMLEditor\TinyMCEConfig: editor_css: - - 'app/client/dist/css/editor.css' + - 'app/client/dist/css/app_editor.css' diff --git a/app/_config/elements.yml b/app/_config/elements.yml index 99c30da..a8755e7 100644 --- a/app/_config/elements.yml +++ b/app/_config/elements.yml @@ -25,6 +25,7 @@ SilverStripe\CMS\Model\SiteTree: - Dynamic\Elements\Oembed\Elements\ElementOembed - Dynamic\Elements\Elements\ElementTestimonials - Site\Elements\TeamMembersElement + - Site\Elements\SliderElement DNADesign\ElementalList\Model\ElementList: default_global_elements: false @@ -50,4 +51,3 @@ DNADesign\Elemental\Models\ElementContent: Dynamic\Elements\Image\Elements\ElementImage: extensions: - Site\Extensions\ElementImageWidget - diff --git a/app/_config/extensions.yml b/app/_config/extensions.yml index e657287..7b0767c 100644 --- a/app/_config/extensions.yml +++ b/app/_config/extensions.yml @@ -1,6 +1,5 @@ SilverStripe\SiteConfig\SiteConfig: extensions: - - Broarm\OpeningHours\OpeningHours - Site\Extensions\SiteConfigExtension - Site\Extensions\SocialExtension @@ -19,3 +18,18 @@ Dynamic\FlexSlider\Model\SlideImage: SilverStripe\Core\Injector\Injector: SilverStripe\UserForms\Model\UserDefinedForm: class: Site\Extensions\CMSMain_HiddenClass + SilverStripe\Security\MemberAuthenticator\LostPasswordHandler: + class: Site\Extensions\LostPasswordHandlerExtension + +# User Forms +SilverStripe\UserForms\Form\UserForm: + extensions: + - Site\Extensions\PlaceholderFormExtension + +SilverStripe\UserForms\Model\UserDefinedForm: + extensions: + - Site\Extensions\UserDefinedFormExtension + +DNADesign\ElementalUserForms\Model\ElementForm: + extensions: + - Site\Extensions\UserDefinedFormExtension diff --git a/app/_config/files.yml b/app/_config/files.yml new file mode 100644 index 0000000..85b9172 --- /dev/null +++ b/app/_config/files.yml @@ -0,0 +1,79 @@ +--- +Name: webapp-files +--- + +SilverStripe\Assets\Upload_Validator: + allowedExtensions: + - 'stl' + +SilverStripe\Assets\File: + allowed_extensions: + - 'ace' + - 'arc' + - 'arj' + - 'asf' + - 'au' + - 'avi' + - 'bmp' + - 'bz2' + - 'cab' + - 'cda' + - 'csv' + - 'dmg' + - 'doc' + - 'docx' + - 'dotx' + - 'flv' + - 'gif' + - 'gpx' + - 'gz' + - 'hqx' + - 'ico' + - 'jpeg' + - 'jpg' + - 'kml' + - 'm4a' + - 'm4v' + - 'mid' + - 'midi' + - 'mkv' + - 'mov' + - 'mp3' + - 'mp4' + - 'mpa' + - 'mpeg' + - 'mpg' + - 'ogg' + - 'ogv' + - 'pages' + - 'pcx' + - 'pdf' + - 'png' + - 'pps' + - 'ppt' + - 'pptx' + - 'potx' + - 'ra' + - 'ram' + - 'rm' + - 'rtf' + - 'sit' + - 'sitx' + - 'tar' + - 'tgz' + - 'tif' + - 'tiff' + - 'txt' + - 'wav' + - 'webm' + - 'wma' + - 'wmv' + - 'xls' + - 'xlsx' + - 'xltx' + - 'zip' + - 'zipx' + - 'stl' + app_categories: + document: + - 'stl' diff --git a/app/_config/webpack.yml b/app/_config/webpack.yml index 0aac7b8..7341a0c 100644 --- a/app/_config/webpack.yml +++ b/app/_config/webpack.yml @@ -3,9 +3,11 @@ # Cuz WebPack compiling script use it to set configuration Site\Templates\WebpackTemplateProvider: - SRC: app/client/src - DIST: app/client/dist + APPDIR: app + THEMESDIR: themes HOSTNAME: localhost PORT: 3000 - TYPESJS: app/client/src/js/types - TYPESSCSS: app/client/src/scss/types + SRC: client/src + DIST: client/dist + TYPESJS: client/src/js/types + TYPESSCSS: client/src/scss/types \ No newline at end of file diff --git a/app/client/src/js/_components/_ui.carousel.js b/app/client/src/js/_components/_ui.carousel.js index 91c9e6f..623ee1d 100644 --- a/app/client/src/js/_components/_ui.carousel.js +++ b/app/client/src/js/_components/_ui.carousel.js @@ -43,8 +43,7 @@ const CarouselUI = (($) => { // create arrows if ($e.data('arrows')) { - let $prev = $('Previous'); - $e.prepend($prev); + $e.prepend('Previous'); $e.prepend('Next'); } @@ -68,8 +67,8 @@ const CarouselUI = (($) => { $(event.target).carousel('prev'); }); - $e.find('img').hammer().bind('tap', (event) => { - $e.carousel('next'); + $e.hammer().bind('tap', (event) => { + $(event.target).carousel('next'); }); }); } @@ -88,4 +87,4 @@ const CarouselUI = (($) => { return CarouselUI; })($); -export default CarouselUI; +export default CarouselUI; \ No newline at end of file diff --git a/app/client/src/js/_components/_ui.form.basics.js b/app/client/src/js/_components/_ui.form.basics.js index d5e05b1..ae2d41a 100644 --- a/app/client/src/js/_components/_ui.form.basics.js +++ b/app/client/src/js/_components/_ui.form.basics.js @@ -27,10 +27,26 @@ const FormBasics = (($) => { const $el = $(el); $el.selectpicker({ - liveSearch: $el.data('live-search') + iconBase: 'fas', + tickIcon: 'fa-check', + liveSearch: $el.data('live-search'), + noneSelectedText: $el.data('none-selected-text') || 'Nothing selected', + maxOptions: $el.data('max-options') || false, }); + + // FIX: hidden picker + $el.parents('.field.dropdown').find('.dropdown-toggle').click(); + $el.parents('.field.dropdown').find('.dropdown-toggle').click(); + $el.parents('.field.dropdown').find('.dropdown-toggle').blur(); }); + // FIX: hidden picker click + if ($selectFields.length) { + setTimeout(() => { + $(window).scrollTop(0, 0); + }, 600); + } + $fields.each((e, el) => { const $el = $(el); diff --git a/app/client/src/js/_components/_ui.form.croppie.js b/app/client/src/js/_components/_ui.form.croppie.js index 47107dd..d18b5c5 100644 --- a/app/client/src/js/_components/_ui.form.croppie.js +++ b/app/client/src/js/_components/_ui.form.croppie.js @@ -104,6 +104,10 @@ const CroppieUI = (($) => { data.append(name, blob, name + '-image.png'); data.append('ajax', '1'); + if (!$(form).data('jsFormValidate').validate()) { + return false; + } + $.ajax({ url: $(form).attr('action'), data: data, @@ -112,27 +116,29 @@ const CroppieUI = (($) => { type: $(form).attr('method'), success: function(data) { let IS_JSON = false; + let json = {}; try { IS_JSON = true; - const json = $.parseJSON(data); + json = $.parseJSON(data); } catch (e) { IS_JSON = false; } - if (IS_JSON && typeof json === 'object') { - for (let k in json) { + if (IS_JSON) { + /*for (let k in json) { $form.find('select[name="' + k + '"],input[name="' + k + '"],textarea[name="' + k + '"]').setError(true, json[k]); - } + }*/ if (typeof json['status'] !== 'undefined' && json['status'] === 'success') { if (typeof json['link'] !== 'undefined') { G.location = json['link']; } else { - G.location.reload(false); + //G.location.reload(false); } } } else { - G.location.reload(false); + $(form).replaceWith(data); + //G.location.reload(false); } SpinnerUI.hide(); diff --git a/app/client/src/js/_components/_ui.form.validate.field.js b/app/client/src/js/_components/_ui.form.validate.field.js index 05baab2..92ba711 100644 --- a/app/client/src/js/_components/_ui.form.validate.field.js +++ b/app/client/src/js/_components/_ui.form.validate.field.js @@ -65,22 +65,26 @@ const FormValidateField = (($) => { }); } + this.removeError(); if (valid) { - this.removeError(); return true; } - this.setError(scrollTo, msg); + setTimeout(() => { + this.setError(scrollTo, msg); + }, 500); + return false; } valideURL(str) { - const regex = /(http|https):\/\/(\w+:{0,1}\w*)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%!\-\/]))?/; - if (!regex.test(str)) { - return false; - } else { - return true; - } + const pattern = new RegExp('^(https?:\\/\\/){1}' + // protocol + '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|' + // domain name + '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address + '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path + '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string + '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator + return pattern.test(str); } setError(scrollTo = true, msg = null) { diff --git a/app/client/src/js/_components/_ui.form.validate.js b/app/client/src/js/_components/_ui.form.validate.js index 18896af..6caf750 100644 --- a/app/client/src/js/_components/_ui.form.validate.js +++ b/app/client/src/js/_components/_ui.form.validate.js @@ -1,6 +1,7 @@ import $ from 'jquery'; import Events from "../_events"; import FormValidateField from "./_ui.form.validate.field"; +import SpinnerUI from './_ui.spinner'; const FormValidate = (($) => { // Constants @@ -67,6 +68,7 @@ const FormValidate = (($) => { validate(scrollTo = true, badCallback = false) { console.log('Checking the form ...'); const ui = this; + let valid = true; ui._fields.each(function(i, el) { const $el = $(el); @@ -77,9 +79,14 @@ const FormValidate = (($) => { badCallback(); } + console.log('Invalid form data'); + SpinnerUI.hide(); + valid = false; return false; } }); + + return valid; } static _jQueryInterface() { diff --git a/app/client/src/js/_main.js b/app/client/src/js/_main.js index e4be3d5..43a02e6 100644 --- a/app/client/src/js/_main.js +++ b/app/client/src/js/_main.js @@ -20,7 +20,7 @@ import FormDatetime from './_components/_ui.form.datetime'; import FormStepped from './_components/_ui.form.stepped'; import FormValidate from './_components/_ui.form.validate'; import FormStorage from './_components/_ui.form.storage'; -import FormCroppie from './_components/_ui.form.croppie'; +//import FormCroppie from './_components/_ui.form.croppie'; import AjaxUI from './_components/_ui.ajax'; diff --git a/app/client/src/scss/_components/_ui.carousel.scss b/app/client/src/scss/_components/_ui.carousel.scss index 3d3c1f2..4bec96c 100644 --- a/app/client/src/scss/_components/_ui.carousel.scss +++ b/app/client/src/scss/_components/_ui.carousel.scss @@ -15,7 +15,13 @@ } .carousel-indicators li { - box-shadow: 1px 1px #000; + box-shadow: none; + + // 1px 1px #000; +} + +.carousel-title { + color: #fff; } .carousel-title, diff --git a/app/client/src/scss/_components/_ui.form.basics.scss b/app/client/src/scss/_components/_ui.form.basics.scss new file mode 100644 index 0000000..5d48f38 --- /dev/null +++ b/app/client/src/scss/_components/_ui.form.basics.scss @@ -0,0 +1,39 @@ +// date-time fields +input.date, +input.time { + &[readonly] { + background-color: $white; + } +} + +.bootstrap-timepicker-widget, +.datepicker-dropdown { + border: 1px solid #ced4da; + box-shadow: 0 0 3px #999; +} + +.bootstrap-timepicker-widget { + .glyphicon { + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + display: inline-block; + font-style: normal; + font-variant: normal; + text-rendering: auto; + line-height: 1; + font-family: Font Awesome\ 5 Free; + font-weight: 900; + } + + .glyphicon-chevron-up:before { + content: "\f077"; + } + + .glyphicon-chevron-down:before { + content: "\f078"; + } + + input { + border: 1px solid #ced4da; + } +} diff --git a/app/client/src/scss/_components/_ui.main.scss b/app/client/src/scss/_components/_ui.main.scss index 3316993..b3d58b9 100644 --- a/app/client/src/scss/_components/_ui.main.scss +++ b/app/client/src/scss/_components/_ui.main.scss @@ -60,6 +60,55 @@ button, input, optgroup, select, textarea, .field { margin: ($grid-gutter-height / 4) 0; + + &.composite { + margin-top: 0; + margin-bottom: 0; + } + + &.required { + &:after { + display: block; + position: absolute; + top: 2rem; + right: .5rem; + content: "*"; + color: $red; + z-index: 2; + } + } + + &.holder-error, + &.error { + input, select, textarea { + border-color: $red; + } + + label { + color: $red; + } + } + + .bootstrap-select:not([class*="col-"]):not([class*="form-control"]):not(.input-group-btn) { + width: 100%; + } +} + +.message { + @extend .alert; + + @extend .alert-info; + + display: block; + margin: .5rem 0; +} + +.message.validation, +.message.required, +.message.error { + @extend .alert; + + @extend .alert-danger; } // stick navbar to top using mobile layout diff --git a/app/client/src/scss/_layout.scss b/app/client/src/scss/_layout.scss index d21024c..788e79e 100644 --- a/app/client/src/scss/_layout.scss +++ b/app/client/src/scss/_layout.scss @@ -53,42 +53,12 @@ body.shrink {} @extend .alert-danger; } -// date-time fields -input.date, -input.time { - &[readonly] { - background-color: $white; - } -} - -.bootstrap-timepicker-widget, -.datepicker-dropdown { - border: 1px solid #ced4da; - box-shadow: 0 0 3px #999; -} - -.bootstrap-timepicker-widget { - .glyphicon { - -moz-osx-font-smoothing: grayscale; - -webkit-font-smoothing: antialiased; - display: inline-block; - font-style: normal; - font-variant: normal; - text-rendering: auto; - line-height: 1; - font-family: Font Awesome\ 5 Free; - font-weight: 900; - } - - .glyphicon-chevron-up:before { - content: "\f077"; - } - - .glyphicon-chevron-down:before { - content: "\f078"; - } - - input { - border: 1px solid #ced4da; +.element { + &.site__elements__sliderelement { + .element-container { + width: 100%; + padding: 0; + max-width: none; + } } } diff --git a/app/client/src/scss/app.scss b/app/client/src/scss/app.scss index 37905fd..2ab06a8 100644 --- a/app/client/src/scss/app.scss +++ b/app/client/src/scss/app.scss @@ -13,6 +13,7 @@ @import "_components/_ui.lightbox"; @import "_components/_ui.main"; +@import "_components/_ui.form.basics"; @import "_components/_ui.elemental"; // Your custom styling diff --git a/app/client/src/scss/types/editor.scss b/app/client/src/scss/types/editor.scss index 22f61ea..487dedd 100644 --- a/app/client/src/scss/types/editor.scss +++ b/app/client/src/scss/types/editor.scss @@ -45,6 +45,15 @@ table { @extend .table; @extend .table-bordered; - - @extend .table-striped; +} + +table { + &.table-none { + border: 0; + + tr, td, th { + border: 0; + background: none !important; + } + } } diff --git a/app/lang/en.yml b/app/lang/en.yml index 2eaea60..300b5d5 100644 --- a/app/lang/en.yml +++ b/app/lang/en.yml @@ -2,6 +2,10 @@ en: SilverStripe\Security\Member: SURNAME: 'Last Name' db_Surname: 'Last Name' + SUBJECTPASSWORDRESET: 'Your password reset link' + ENTEREMAIL: 'Please enter an email address to get a password reset link.' + PASSWORDRESETSENTHEADER: 'Password reset link sent' + PASSWORDRESETSENTTEXT: 'Thank you. A reset link has been sent, provided an account exists for this email address.' Page: LOADINGTEXT: "LOADING .." JAVASCRIPTREQUIRED: "Please, enable javascript!" @@ -13,3 +17,7 @@ en: db_Surname: 'Last Name' SilverShop\Page\CheckoutPage: ProceedToPayment: 'Send Order to Store' + UndefinedOffset\NoCaptcha\Forms\NocaptchaField: + EMPTY: "Please prove you are human - check the Captcha box." + NOSCRIPT: "You must enable JavaScript to submit this form" + VALIDATE_ERROR: "Captcha could not be validated" diff --git a/app/src/Shop/CheckoutMapComponent.php b/app/src/.Shop/CheckoutMapComponent.php similarity index 100% rename from app/src/Shop/CheckoutMapComponent.php rename to app/src/.Shop/CheckoutMapComponent.php diff --git a/app/src/Shop/CheckoutNoDeliveryConfig.php b/app/src/.Shop/CheckoutNoDeliveryConfig.php similarity index 100% rename from app/src/Shop/CheckoutNoDeliveryConfig.php rename to app/src/.Shop/CheckoutNoDeliveryConfig.php diff --git a/app/src/Elements/SliderElement.php b/app/src/Elements/SliderElement.php index 75e3eb1..8dafcb0 100644 --- a/app/src/Elements/SliderElement.php +++ b/app/src/Elements/SliderElement.php @@ -61,17 +61,19 @@ class SliderElement extends ElementSlideshow ]); $grid = $fields->dataFieldByName('Slides'); - $config = $grid->getConfig(); + if ($grid) { + $config = $grid->getConfig(); - $columns = new GridFieldEditableColumns(); - $columns->setDisplayFields([ - 'Hide' => [ - 'title' => 'Hide it?', - 'field' => CheckboxField::class, - ], - ]); + $columns = new GridFieldEditableColumns(); + $columns->setDisplayFields([ + 'Hide' => [ + 'title' => 'Hide it?', + 'field' => CheckboxField::class, + ], + ]); - $config->addComponent($columns); + $config->addComponent($columns); + } return $fields; } diff --git a/app/src/Extensions/LostPasswordHandlerExtension.php b/app/src/Extensions/LostPasswordHandlerExtension.php new file mode 100644 index 0000000..3c9156e --- /dev/null +++ b/app/src/Extensions/LostPasswordHandlerExtension.php @@ -0,0 +1,69 @@ + 'passwordsent', + ]; + + private static $allowed_actions = [ + 'passwordsent', + ]; + + /** + * Show the "password sent" page, after a user has requested + * to reset their password. + * + * @return array + */ + public function passwordsent() + { + $message = _t( + 'SilverStripe\\Security\\Security.PASSWORDRESETSENTTEXT', + "Thank you. A reset link has been sent, provided an account exists for this email address." + ); + + $email = $this->getRequest()->getVar('email'); + $message = $email + ? 'Thank you! A reset link has been sent to \''.$email.'\', provided an account exists for this email address.' + : $message; + + return [ + 'Title' => _t( + 'SilverStripe\\Security\\Security.PASSWORDRESETSENTHEADER', + "Password reset link sent".($email ? ' to \''.$email.'\'' : '') + ), + 'ElementalArea' => DBField::create_field('HTMLFragment', "
$message
"), + ]; + } + + /** + * Avoid information disclosure by displaying the same status, regardless wether the email address actually exists + * + * @param array $data + * @return HTTPResponse + */ + protected function redirectToSuccess(array $data) + { + $link = $this->link('passwordsent').'?email='.$data['Email']; + + return $this->redirect($this->addBackURLParam($link)); + } +} diff --git a/app/src/Extensions/PlaceholderFormExtension.php b/app/src/Extensions/PlaceholderFormExtension.php new file mode 100644 index 0000000..7168ddb --- /dev/null +++ b/app/src/Extensions/PlaceholderFormExtension.php @@ -0,0 +1,37 @@ +setPlaceholder($field); + } + } + + private function setPlaceholder($field) + { + if(is_a($field, TextField::class)) { + $field->setAttribute( + 'placeholder', + $field->Title() + .($field->hasClass('requiredField') ? '*' : '') + ); + $field->setTitle(''); + } + + if(is_a($field, CompositeField::class)) { + $children = $field->getChildren(); + foreach ($children as $child) { + $this->setPlaceholder($child); + } + } + } +} diff --git a/app/src/Extensions/SiteConfigExtension.php b/app/src/Extensions/SiteConfigExtension.php index dcd58fe..620df96 100644 --- a/app/src/Extensions/SiteConfigExtension.php +++ b/app/src/Extensions/SiteConfigExtension.php @@ -11,6 +11,7 @@ use SilverStripe\ORM\DataExtension; use SilverStripe\CMS\Model\SiteTree; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\TreeMultiselectField; +use SilverStripe\Forms\DropdownField; use BetterBrief\GoogleMapField; class SiteConfigExtension extends DataExtension diff --git a/app/src/Extensions/UserDefinedFormExtension.php b/app/src/Extensions/UserDefinedFormExtension.php new file mode 100644 index 0000000..5167979 --- /dev/null +++ b/app/src/Extensions/UserDefinedFormExtension.php @@ -0,0 +1,79 @@ + 'HTMLText', + 'RedirectOnComplete' => 'Boolean(0)', + 'RedirectOnCompleteURL' => 'Varchar(255)', + ]; + + private static $many_many = [ + 'SubmissionColumns' => EditableFormField::class, + ]; + + public function updateCMSFields(FieldList $fields) + { + parent::updateCMSFields($fields); + + $fields->removeByName('RedirectOnComplete'); + $fields->removeByName('RedirectOnCompleteURL'); + + $fields->removeByName('SubmissionColumns'); + + $fields->addFieldToTab( + 'Root.Main', + ListboxField::create( + 'SubmissionColumns', + 'Display following columns at submissions list', + $this->owner->Fields()->map('ID', 'Title') + ) + ); + + $tab = $fields->findOrMakeTab('Root.FormOptions'); + + /*$tab->push(CheckboxField::create('RedirectOnComplete')); + $tab->push(TextField::create('RedirectOnCompleteURL'));*/ + $tab->push(TextareaField::create('CustomThankYouCode')); + + $grid = $fields->dataFieldByName('Submissions'); + + $config = $grid->getConfig(); + $config->getComponentByType(GridFieldPaginator::class)->setItemsPerPage(100); + + $cols = $this->owner->SubmissionColumns(); + if ($grid && $cols->count()) { + $dataCols = $config->getComponentByType(GridFieldDataColumns::class); + + $columns = [ + 'ID' => 'ID', + 'Created' => 'Created', + ]; + + foreach ($cols as $col) { + $title = $col->getField('Title'); + $name = $col->getField('Name'); + $columns[$name] = [ + 'title' => $title, + 'callback' => function($item) use ($name) { + return $item->relField($name); + } + ]; + } + + $columns['Actions'] = 'Actions'; + + $dataCols->setDisplayFields($columns); + } + } +} diff --git a/app/src/Pages/PageController.php b/app/src/Pages/PageController.php index e3d7e52..791f1eb 100644 --- a/app/src/Pages/PageController.php +++ b/app/src/Pages/PageController.php @@ -18,6 +18,8 @@ use SilverStripe\Forms\RequiredFields; use SilverStripe\Control\HTTPRequest; use SilverStripe\ORM\ArrayList; use DNADesign\Elemental\Models\ElementContent; +use DNADesign\Elemental\Models\ElementalArea; +use DNADesign\ElementalUserForms\Control\ElementFormController; class PageController extends ContentController { @@ -38,6 +40,26 @@ class PageController extends ContentController return $this->render(); } + public function ElementalArea() + { + if($this->CurrentElement()) { + return false; + } + + return ElementalArea::get()->byID($this->getField('ElementalAreaID')); + } + + public function CurrentElement() + { + $contoller_curr = Controller::curr(); + + if(is_a($contoller_curr, ElementFormController::class)) { + return $contoller_curr; + } + + return false; + } + public function SearchForm() { return Form::create( @@ -98,7 +120,7 @@ class PageController extends ContentController $results->removeDuplicates(); return ArrayData::create([ - 'Title' => 'Search query "'.$term.'"', + 'Title' => 'You searched for: "'.$term.'"', 'Results' => PaginatedList::create($results), ]); } @@ -124,8 +146,10 @@ class PageController extends ContentController public function getSiteWideMessage() { - if (!$this->site_message) { - $session = $this->getRequest()->getSession(); + $request = $this->getRequest(); + + if ($request->isGET() && !$this->site_message) { + $session = $request->getSession(); $this->site_message = $session->get('SiteWideMessage'); $session->clear('SiteWideMessage'); } diff --git a/app/src/Templates/DeferedRequirements.php b/app/src/Templates/DeferedRequirements.php index c3b62b1..793318e 100644 --- a/app/src/Templates/DeferedRequirements.php +++ b/app/src/Templates/DeferedRequirements.php @@ -36,6 +36,7 @@ class DeferedRequirements implements TemplateGlobalProvider public static function Auto($class = false) { $config = Config::inst()->get(self::class); + $themeName = WebpackTemplateProvider::themeName(); // Initialization Requirements::block(THIRDPARTY_DIR.'/jquery/jquery.js'); @@ -50,10 +51,10 @@ class DeferedRequirements implements TemplateGlobalProvider } // App libs if (!$config['nofontawesome']) { - DeferedRequirements::loadCSS('//use.fontawesome.com/releases/v5.3.1/css/all.css'); + DeferedRequirements::loadCSS('//use.fontawesome.com/releases/v5.4.0/css/all.css'); } - DeferedRequirements::loadCSS('app.css'); - DeferedRequirements::loadJS('app.js'); + DeferedRequirements::loadCSS($themeName.'.css'); + DeferedRequirements::loadJS($themeName.'.js'); // Class libs $class = get_class(Controller::curr()); @@ -72,17 +73,17 @@ class DeferedRequirements implements TemplateGlobalProvider $dir = Path::join( Director::publicFolder(), ManifestFileFinder::RESOURCES_DIR, - 'app', + $themeName, 'client', 'dist' ); - if (file_exists(Path::join($dir, 'css', $class . '.css'))) { - DeferedRequirements::loadCSS($class . '.css'); + if (file_exists(Path::join($dir, 'css', $themeName.'_'.$class . '.css'))) { + DeferedRequirements::loadCSS($themeName.'_'.$class . '.css'); } - if (file_exists(Path::join($dir, 'js', $class . '.js'))) { - DeferedRequirements::loadJS($class . '.js'); + if (file_exists(Path::join($dir, 'js', $themeName.'_'.$class . '.js'))) { + DeferedRequirements::loadJS($themeName.'_'.$class . '.js'); } return self::forTemplate(); @@ -90,7 +91,8 @@ class DeferedRequirements implements TemplateGlobalProvider public static function loadCSS($css) { - if (self::$defered && !self::_webpackActive()) { + $external = (mb_substr($css, 0, 2) === '//' || mb_substr($css, 0, 4) === 'http'); + if ($external || (self::$defered && !self::_webpackActive())) { self::$css[] = $css; } else { WebpackTemplateProvider::loadCSS($css); @@ -99,6 +101,9 @@ class DeferedRequirements implements TemplateGlobalProvider public static function loadJS($js) { + /*$external = (mb_substr($js, 0, 2) === '//' || mb_substr($js, 0, 4) === 'http'); + if ($external || (self::$defered && !self::_webpackActive())) {*/ + // webpack supposed to load external JS if (self::$defered && !self::_webpackActive()) { self::$js[] = $js; } else { @@ -118,10 +123,6 @@ class DeferedRequirements implements TemplateGlobalProvider public static function forTemplate() { - if (!self::$defered || self::_webpackActive()) { - return false; - } - $result = ''; foreach (self::$css as $css) { $result .= ''; @@ -137,7 +138,7 @@ class DeferedRequirements implements TemplateGlobalProvider .'function lscd(a){aFile | Size limit |
---|---|
'.$k.' | '.$size.' |
'; + $msgs = $result->getMessages(); + foreach ($msgs as $msg) { + echo self::error($msg['fieldName'].': '.$msg['message']); + } + echo '
'; + } +} diff --git a/app/templates/Includes/Content.ss b/app/templates/Includes/Content.ss index 309ed0a..59b2378 100644 --- a/app/templates/Includes/Content.ss +++ b/app/templates/Includes/Content.ss @@ -2,7 +2,11 @@