public function getInputfields()
 {
     $form = parent::getInputfields();
     $f = $this->modules->get('InputfieldMarkup');
     $f->value = '<h2>Email address pre-registration validation<h2>';
     $form->add($f);
     $f = $this->modules->get('InputfieldText');
     $f->attr('name', 'subject');
     $f->label = $this->_('Subject address validation email');
     $f->required = true;
     $form->add($f);
     $f = $this->modules->get('InputfieldTextarea');
     $f->attr('name', 'content');
     $f->label = $this->_('Content address validation email');
     $f->required = true;
     $form->add($f);
     $f = $this->modules->get('InputfieldRadios');
     $f->label = 'Type of email:';
     $f->value = '1';
     $f->addOption('0', 'Text');
     $f->addOption('1', 'HTML');
     $f->attr('name', 'emailType');
     $form->add($f);
     return $form;
 }
 public function getInputfields()
 {
     $inputfields = parent::getInputfields();
     $f = $this->modules->get('InputfieldText');
     $f->attr('name', 'selector');
     $f->label = 'Selector';
     $f->description = 'This is the JQuery Selector to find the fields where the unselect button should be shown';
     $f->notes = 'Default: ' . $this->selector;
     $f->required = true;
     $inputfields->add($f);
     return $inputfields;
 }
 public function getInputfields()
 {
     $inputfields = parent::getInputfields();
     $f = $this->modules->get('InputfieldInteger');
     $f->attr('name', 'height');
     $f->label = 'Thumbnail height';
     $f->notes = 'Leave one field blank to keep aspect ratio';
     $f->columnWidth = '50%';
     $inputfields->add($f);
     $f = $this->modules->get('InputfieldInteger');
     $f->attr('name', 'width');
     $f->label = 'Thumbnail width';
     $f->notes = 'Leave one field blank to keep aspect ratio';
     $f->columnWidth = '50%';
     $inputfields->add($f);
     return $inputfields;
 }
 /**
  * Configure notifications
  *
  * @return InputfieldWrapper
  *
  */
 public function getInputfields()
 {
     $form = parent::getInputfields();
     $modules = $this->wire('modules');
     $on = $this->_('On');
     $off = $this->_('Off');
     $f = $modules->get('InputfieldRadios');
     $f->attr('name', 'disabled');
     $f->label = __('Notifications status');
     $f->description = __('When turned off, notifications will not be rendered.');
     $f->addOption(0, $on);
     $f->addOption(1, $off);
     $f->optionColumns = 1;
     $f->columnWidth = 33;
     $form->add($f);
     $f = $modules->get('InputfieldRadios');
     $f->attr('name', 'trackEdits');
     $f->label = __('Track page edits?');
     $f->description = __('Notifies users when they try to edit a page that is already being edited.');
     $f->addOption(1, $on);
     $f->addOption(0, $off);
     $f->optionColumns = 1;
     $f->columnWidth = 34;
     $form->add($f);
     $f = $modules->get('InputfieldRadios');
     $f->attr('name', 'reverse');
     $f->label = __('Notification order');
     $f->description = __('Select what order the notifications should display in.');
     $f->addOption(0, __('Newest to oldest'));
     $f->addOption(1, __('Oldest to newest'));
     $f->optionColumns = 1;
     $f->columnWidth = 33;
     $form->add($f);
     $f = $modules->get('InputfieldCheckboxes');
     $f->attr('name', 'activeHooks');
     $f->label = __('Active automatic notification hooks');
     $f->description = __('Whenever one of these events occurs, the system user above will be notified.');
     $f->addOption(0, __('404 page not found'));
     $f->addOption(1, __('User login success and failure'));
     $f->addOption(2, __('User logout'));
     $f->notes = __('These are primarily just examples of notifications for the purpose of demonstration.');
     $f->columnWidth = 50;
     $form->add($f);
     $f = $modules->get('InputfieldName');
     $f->attr('name', 'systemUserName');
     $f->label = __('Name of user that receives system notifications');
     $f->columnWidth = 50;
     $form->add($f);
     $f = $modules->get('InputfieldInteger');
     $f->attr('name', 'updateDelay');
     $f->label = __('Time between updates');
     $f->description = __('How often to check for notification updates (in milliseconds). Example: 5000 means 5 seconds.');
     $f->columnWidth = 50;
     $form->add($f);
     $f = $modules->get('InputfieldText');
     $f->attr('name', 'dateFormat');
     $f->label = __('Date format');
     $f->description = __('Date format used for notifications. Use date() or strftime() format, or "relative" for relative date/time, "rel" for abbreviated date/time.');
     $f->columnWidth = 50;
     $form->add($f);
     $f = $modules->get('InputfieldIcon');
     $f->attr('name', 'iconMessage');
     $f->label = __('Message icon');
     $f->prefixValue = false;
     $form->add($f);
     $f = $modules->get('InputfieldIcon');
     $f->attr('name', 'iconWarning');
     $f->label = __('Warning icon');
     $f->prefixValue = false;
     $form->add($f);
     $f = $modules->get('InputfieldIcon');
     $f->attr('name', 'iconError');
     $f->label = __('Error icon');
     $f->prefixValue = false;
     $form->add($f);
     $f = $modules->get('InputfieldInteger');
     $f->attr('name', 'ghostDelay');
     $f->label = __('Ghost delay');
     $f->description = __('How long ghost messages appear for (in ms).');
     $f->columnWidth = 25;
     $form->add($f);
     $f = $modules->get('InputfieldInteger');
     $f->attr('name', 'ghostDelayError');
     $f->label = __('Ghost error delay');
     $f->description = __('How long ghost errors appear for (in ms).');
     $f->columnWidth = 25;
     $form->add($f);
     $f = $modules->get('InputfieldFloat');
     $f->attr('name', 'ghostOpacity');
     $f->label = __('Ghost full opacity');
     $f->description = __('Full opacity of ghosts (0.1-1.0)');
     $f->columnWidth = 25;
     $form->add($f);
     $f = $modules->get('InputfieldFloat');
     $f->attr('name', 'ghostLimit');
     $f->label = __('Ghost Limit');
     $f->description = __('Show summary ghost if more this.');
     $f->columnWidth = 25;
     $form->add($f);
     $f = $modules->get('InputfieldRadios');
     $f->attr('name', 'ghostFadeSpeed');
     $f->label = __('Ghost fade speed');
     $f->description = __('Speed at which ghosts fade in or out.');
     $f->addOption('', __('Immediate (no fade in/out)'));
     $f->addOption('fast', __('Fast'));
     $f->addOption('normal', __('Normal'));
     $f->addOption('slow', __('Slow'));
     $f->columnWidth = 50;
     $form->add($f);
     $f = $modules->get('InputfieldRadios');
     $f->attr('name', 'ghostPos');
     $f->label = __('Ghost position');
     $f->description = __('What side of the screen ghosts should float on.');
     $f->addOption(self::ghostPosLeft, $this->_('Left'));
     $f->addOption(self::ghostPosRight, $this->_('Right'));
     $f->columnWidth = 50;
     $form->add($f);
     $f = $modules->get('InputfieldRadios');
     $f->attr('name', 'placement');
     $f->label = __('Runtime/single-request notices');
     $f->addOption(self::placementCombined, __('Display as notifications'));
     $f->addOption(self::placementSeparate, __('Leave them alone'));
     $f->columnWidth = 50;
     $form->add($f);
     include_once dirname(__FILE__) . "/Notification.php";
     $this->message('Example runtime message notification');
     $this->message('Example debug message notification', Notification::flagDebug);
     $this->warning('Example runtime warning notification');
     $this->warning('Example debug warning notification', Notification::flagDebug);
     $this->error('Example runtime error notification');
     $this->error('Example debug error notification', Notification::flagDebug);
     return $form;
 }
Beispiel #5
0
 /**
  * Get the Inputfields that configure the given module or return null if not configurable
  * 
  * @param string|Module|int $moduleName
  * @param InputfieldWrapper|null $form Optionally specify the form you want Inputfields appended to.
  * @return InputfieldWrapper|null
  * 
  */
 public function ___getModuleConfigInputfields($moduleName, InputfieldWrapper $form = null)
 {
     $moduleName = $this->getModuleClass($moduleName);
     $configurable = $this->isConfigurableModule($moduleName);
     if (!$configurable) {
         return null;
     }
     if (is_null($form)) {
         $form = new InputfieldWrapper();
     }
     $data = $this->modules->getModuleConfigData($moduleName);
     // check for configurable module interface
     $configurableInterface = $this->isConfigurableModule($moduleName, "interface");
     if ($configurableInterface) {
         if (is_int($configurableInterface) && $configurableInterface > 1 && $configurableInterface < 20) {
             // non-static
             /** @var ConfigurableModule $module */
             $module = $this->getModule($moduleName);
             if ($configurableInterface === 2) {
                 // requires no arguments
                 $fields = $module->getModuleConfigInputfields();
             } else {
                 if ($configurableInterface === 3) {
                     // requires $data array
                     $fields = $module->getModuleConfigInputfields($data);
                 } else {
                     if ($configurableInterface === 4) {
                         // requires InputfieldWrapper
                         // we allow for option of no return statement in the method
                         $fields = new InputfieldWrapper();
                         $_fields = $module->getModuleConfigInputfields($fields);
                         if ($_fields instanceof InputfieldWrapper) {
                             $fields = $_fields;
                         }
                         unset($_fields);
                     } else {
                         if ($configurableInterface === 19) {
                             // non-static getModuleConfigArray method
                             $fields = new InputfieldWrapper();
                             $fields->importArray($module->getModuleConfigArray());
                             $fields->populateValues($module);
                         }
                     }
                 }
             }
         } else {
             if ($configurableInterface === 20) {
                 // static getModuleConfigArray method
                 $fields = new InputfieldWrapper();
                 $fields->importArray(call_user_func(array($moduleName, 'getModuleConfigArray')));
                 $fields->populateValues($data);
             } else {
                 if ($configurableInterface) {
                     // static getModuleConfigInputfields method
                     $fields = call_user_func(array($moduleName, 'getModuleConfigInputfields'), $data);
                 }
             }
         }
         if ($fields instanceof InputfieldWrapper) {
             foreach ($fields as $field) {
                 $form->append($field);
             }
         } else {
             if ($fields instanceof Inputfield) {
                 $form->append($fields);
             } else {
                 $this->error("{$moduleName}.getModuleConfigInputfields() did not return InputfieldWrapper");
             }
         }
     }
     // check for file-based config
     $file = $this->isConfigurableModule($moduleName, "file");
     if (!$file || !is_string($file) || !is_file($file)) {
         return $form;
     }
     $config = null;
     include_once $file;
     $configClass = $moduleName . "Config";
     $configModule = null;
     if (class_exists($configClass)) {
         // file contains a ModuleNameConfig class
         $configModule = new $configClass();
     } else {
         if (is_null($config)) {
             include $file;
         }
         // in case of previous include_once
         if (is_array($config)) {
             // file contains a $config array
             $configModule = new ModuleConfig();
             $configModule->add($config);
         }
     }
     if ($configModule && $configModule instanceof ModuleConfig) {
         $defaults = $configModule->getDefaults();
         $data = array_merge($defaults, $data);
         $configModule->setArray($data);
         $fields = $configModule->getInputfields();
         if ($fields instanceof InputfieldWrapper) {
             foreach ($fields as $field) {
                 $form->append($field);
             }
             foreach ($data as $key => $value) {
                 $f = $form->getChildByName($key);
                 if ($f) {
                     $f->attr('value', $value);
                 }
             }
         } else {
             $this->error("{$configModule}.getInputfields() did not return InputfieldWrapper");
         }
     }
     return $form;
 }
 /**
  * Retrieves the list of config input fields
  * Implementation of the ConfigurableModule interface
  *
  * @return InputfieldWrapper
  */
 public function getInputfields()
 {
     $formfields = $this->data['formfields'];
     $unsubscribe = $this->data['unsubscribe'];
     $notifyAdmin = $this->data['notifyAdmin'];
     $noCompare = $this->data['noCompare'];
     $inputfields = parent::getInputfields();
     // select fields
     $field = $this->modules->get('InputfieldAsmSelect');
     $field->description = __('Add all fields which should be attached to the subscription form.') . PHP_EOL . __('You have to add all needed fields to the user template first¹.');
     $field->addOption('', '');
     $field->label = __('Select form fields for subscription');
     $field->attr('name', 'formfields');
     $field->required = true;
     $field->columnWidth = 50;
     foreach (wire('templates')->get('user')->fields as $f) {
         $field->addOption($f->name, $f->name);
     }
     $inputfields->add($field);
     // select name fields
     $field = $this->modules->get('InputfieldAsmSelect');
     $field->description = __('Add the fields which should be used as username.') . PHP_EOL . __('Please save the chosen form fields first to get a list to select from.');
     $field->label = __('Select name fields');
     $field->attr('name', 'namefields');
     $field->columnWidth = 50;
     if (is_array($formfields)) {
         foreach ($formfields as $formfield) {
             $f = wire('fields')->get($formfield);
             $field->addOption($f->name, $f->name);
         }
     }
     $inputfields->add($field);
     // help - how to add fields to the user template
     $help = $this->modules->get('InputfieldMarkup');
     $helpLink = 'https://processwire.com/talk/topic/1156-custom-user-fields/?p=10161';
     $helpContent = '<p><a  target="_blank" href="' . $helpLink . '"><sup>1</sup> How to add fields to the user template?</a></p>';
     $help->value = $helpContent;
     $inputfields->add($help);
     // unsubscribe field
     $field = $this->modules->get('InputfieldCheckbox');
     $field->name = 'unsubscribe';
     $field->label = 'Unsubscribe option';
     $field->description = __('Should the form contain an unsubscribe option?');
     $field->value = 1;
     $field->attr('checked', $unsubscribe ? 'checked' : '');
     $field->columnWidth = 25;
     $inputfields->add($field);
     // noCompare field
     $field = $this->modules->get('InputfieldCheckbox');
     $field->name = 'noCompare';
     $field->label = 'Do not compare E-Mail-Addresses';
     $field->description = __('Do not check whether an E-Mail-Address already exists.');
     $field->value = 1;
     $field->attr('checked', $noCompare ? 'checked' : '');
     $field->columnWidth = 25;
     $inputfields->add($field);
     // mailserver field
     $field = $this->modules->get('InputfieldText');
     $field->name = 'mailfrom';
     $field->label = __('E-Mail From Address');
     $field->description = __('Sender Address');
     $field->columnWidth = 25;
     $inputfields->add($field);
     // periodOfValidity field
     $field = $this->modules->get('InputfieldInteger');
     $field->name = 'periodOfValidity';
     $field->label = __('Period of Validity');
     $field->description = __('Number of days confirmation links are valid.');
     $field->columnWidth = 25;
     $inputfields->add($field);
     // new fieldset containing messages
     $fieldset = $this->modules->get('InputfieldFieldset');
     $fieldset->label = $this->_('E-Mail Messages');
     $fieldset->collapsed = Inputfield::collapsedYes;
     $fieldset->icon = 'send';
     $field = $this->modules->get('InputfieldTextarea');
     $field->name = 'messageSubscribe';
     $field->label = __('Subscribe E-Mail Message');
     $field->description = __('Use %fieldName% as placeholder, for example %email%');
     $field->rows = 8;
     $field->columnWidth = 50;
     $fieldset->add($field);
     $field = $this->modules->get('InputfieldTextarea');
     $field->name = 'messageUnsubscribe';
     $field->label = __('Unsubscribe E-Mail Message');
     $field->description = __('Use %fieldName% as placeholder, for example %email%');
     $field->rows = 8;
     $field->columnWidth = 50;
     $fieldset->add($field);
     $inputfields->add($fieldset);
     // new fieldset containing admin notification
     $fieldset = $this->modules->get('InputfieldFieldset');
     $fieldset->label = $this->_('Notify Admin');
     $fieldset->collapsed = Inputfield::collapsedYes;
     $fieldset->icon = 'comment';
     // notify admin field
     $field = $this->modules->get('InputfieldCheckbox');
     $field->name = 'notifyAdmin';
     $field->label = 'Notify Admin';
     $field->description = __('Should the admin be notified by email?');
     $field->value = 1;
     $field->columnWidth = 50;
     $field->attr('checked', $notifyAdmin ? 'checked' : '');
     $fieldset->add($field);
     // notify admin - mailto field
     $field = $this->modules->get('InputfieldText');
     $field->name = 'notifyAdminMailto';
     $field->label = __('Admin Notification E-Mail');
     $field->description = __('Mailto Address');
     $field->columnWidth = 50;
     $field->showIf = "notifyAdmin=1";
     $fieldset->add($field);
     // notify admin - subscribtion - mailserver field
     $field = $this->modules->get('InputfieldText');
     $field->name = 'notifyAdminSubscribeMailfrom';
     $field->label = __('Subscription - E-Mail From Address');
     $field->description = __('Sender Address');
     $field->columnWidth = 50;
     $field->showIf = "notifyAdmin=1";
     $fieldset->add($field);
     // notify admin - unsubscribtion - mailserver field
     $field = $this->modules->get('InputfieldText');
     $field->name = 'notifyAdminUnsubscribeMailfrom';
     $field->label = __('Unsubscription - E-Mail From Address');
     $field->description = __('Sender Address');
     $field->columnWidth = 50;
     $field->showIf = "notifyAdmin=1";
     $fieldset->add($field);
     // notify admin - subscription - message field
     $field = $this->modules->get('InputfieldTextarea');
     $field->name = 'notifyAdminMessageSubscribe';
     $field->label = __('Subscribe E-Mail Message');
     $field->description = __('Use %fieldName% as placeholder, for example %email%');
     $field->rows = 8;
     $field->columnWidth = 50;
     $field->showIf = "notifyAdmin=1";
     $fieldset->add($field);
     // notify admin - unsubscription - message field
     $field = $this->modules->get('InputfieldTextarea');
     $field->name = 'notifyAdminMessageUnsubscribe';
     $field->label = __('Unsubscribe E-Mail Message');
     $field->description = __('Use %fieldName% as placeholder, for example %email%');
     $field->rows = 8;
     $field->columnWidth = 50;
     $field->showIf = "notifyAdmin=1";
     $fieldset->add($field);
     $inputfields->add($fieldset);
     return $inputfields;
 }