Source of file PopupLeftAndMain.php
Size: 4,538 Bytes - Last Modified: 2019-06-07T11:26:00+00:00
/var/www/docs.ssmods.com/process/src/src/PopupLeftAndMain.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 | <?php namespace AgenceCaza\Popup; use SilverStripe\Admin\LeftAndMain; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\CheckboxField; use SilverStripe\Forms\DateTimeField; use SilverStripe\Forms\TimeField; use SilverStripe\Forms\DateField; use SilverStripe\Forms\HTMLEditor\HTMLEditorField; use SilverStripe\Forms\DropdownField; use SilverStripe\Forms\TextField; use SilverStripe\Forms\Form; use SilverStripe\Versioned\Versioned; use SilverStripe\Forms\FormAction; use SilverStripe\View\Requirements; use SilverStripe\Forms\TabSet; use SilverStripe\Forms\Tab; use SilverStripe\AssetAdmin\Forms\UploadField; use SilverStripe\Assets\Image; use AgenceCaza\Popup\PopupConfig; use SheaDawson\TimePickerField\TimePickerField; class PopupLeftAndMain extends LeftAndMain { private static $url_segment = 'popup'; private static $menu_title = 'Popup'; private static $url_rule = '/$Action/$ID/$OtherID'; private static $allowed_actions = array( 'doSave','success' ); public function getEditForm($id = null, $fields = null) { if (!$id) { $id = $this->currentPageID(); } $form = parent::getEditForm($id); /* */ $fields = FieldList::create( $root = TabSet::create( 'Root', Tab::create( '', CheckboxField::create('Online', _t('PopupLeftAndMain.ONLINE','Put online')), CheckboxField::create('Reset', _t('PopupLeftAndMain.RESETDATETIME','Reset the cookie datetime')), TextField::create( 'DisplayDelay', _t('PopupLeftAndMain.DISPLAYDELAY','Display delay') )->setDescription( _t('PopupLeftAndMain.INSECONDS','in seconds') ), $date = DatetimeField::create('DateTime', _t('PopupLeftAndMain.STARTDATETIME','Start datetime'))->setDatetimeFormat('YYYY-MM-dd HH:mm:ss')->setHTML5(false), $dateend = DatetimeField::create('DateTimeEnd', _t('PopupLeftAndMain.ENDDATETIME','End datetime'))->setDatetimeFormat('YYYY-MM-dd HH:mm:ss')->setHTML5(false), DropdownField::create( 'RedirectID', _t('PopupLeftAndMain.REDIRECTTO','Redirect to:'), Versioned::get_by_stage('Page','Live')->map('ID','Title') ), HtmlEditorField::create( 'Content', _t('PopupLeftAndMain.CONTENT','Content') ), $uploadField = UploadField::create( 'Image', 'Image' )->setAllowedMaxFileNumber(1), TextField::create( 'ButtonText', _t('PopupLeftAndMain.BUTTONTEXT','Button text') ) ) ) ); //$date->setTimeField(TimePickerField::create('DateTime[time]')->setTitle('Date And Time')); //$date->getDateField()->setConfig('showcalendar', true); // $dateend->getDateField()->setConfig('showcalendar', true); // $dateend->setTimeField(TimePickerField::create('DateTimeEnd[time]')->setTitle('End time')); $uploadField->setFolderName('Uploads/Popup'); $actions = new FieldList( FormAction::create("doSave")->setTitle(_t('PopupLeftAndMain.SUBMIT','Submit'))->addExtraClass('btn-primary') ); $form = new Form( $this, 'EditForm', $fields, $actions ); $form->addExtraClass('cms-edit-form'); $form->setTemplate($this->getTemplatesWithSuffix('_EditForm')); //$form->setFormAction($this->Link().'PopupSubmit'); $config = PopupConfig::get()->first(); if (isset($config) > 0) { $form->loadDataFrom($config); } $this->extend('updateEditForm', $form); return $form; } public function doSave($data, Form $form) { $config = PopupConfig::get()->first(); if (!isset($config) ) { $config = new PopupConfig(); } else { if (isset($data['Reset'])) { $config->DateTimeActive = time(); $form->sessionMessage(_t('PopupLeftAndMain.SETTINGSSAVEDANDCOOKIERRESETTED','Settings saved and cookie resetted'), 'good'); } else { $form->sessionMessage(_t('PopupLeftAndMain.SETTINGSSAVED','Settings saved'), 'good'); } } $form->saveInto($config); $config->write(); return $this->redirect($this->Link('success')); } public function success() { return $this->redirect("admin/popup"); } public function init() { parent::init(); Requirements::css('agencecaza/silverstripe-popup:client/css/PopupLeftAndMain.css'); Requirements::css('agencecaza/silverstripe-popup:client/thirdparty/datetimepicker/build/jquery.datetimepicker.min.css'); Requirements::javascript('agencecaza/silverstripe-popup:client/thirdparty/datetimepicker/build/jquery.datetimepicker.full.min.js'); Requirements::javascript('agencecaza/silverstripe-popup:client/javascript/DateTime.js'); } } |