/**
  * Return an InputfieldWrapper of Inputfields necessary to configure this module
  * 
  * Values will be populated to the Inputfields automatically. However, you may also retrieve
  * any of the values from $this->[property]; as needed. 
  * 
  * Descending classes should call this method at the top of their getInputfields() method. 
  * 
  * Use this method only if defining Inputfield objects programatically. If definining via
  * an array then you should not implement this method. 
  * 
  * @return InputfieldWrapper
  * 
  */
 public function getInputfields()
 {
     foreach ($this->getDefaults() as $key => $value) {
         $this->set($key, $value);
     }
     $inputfields = new InputfieldWrapper();
     if (count($this->inputfieldsArray)) {
         $inputfields->add($this->inputfieldsArray);
     }
     return $inputfields;
 }
Beispiel #2
0
 /**
  * Render a value using an Inputfield's renderValue() method
  * 
  * @param $value
  * @return string
  * 
  */
 protected function renderInputfieldValue($value)
 {
     $field = $this->getField();
     $page = $this->getPage();
     if (!$page->id || !$field) {
         return (string) $value;
     }
     /** @var Inputfield $inputfield */
     $inputfield = $field->getInputfield($page);
     if (!$inputfield) {
         return (string) $value;
     }
     $inputfield->columnWidth = 100;
     $inputfield->attr('value', $value);
     if (method_exists($inputfield, 'setField')) {
         $inputfield->setField($field);
     }
     if (method_exists($inputfield, 'setPage')) {
         $inputfield->setPage($page);
     }
     $wrapper = new InputfieldWrapper();
     $wrapper->quietMode = true;
     $wrapper->add($inputfield);
     $out = $wrapper->renderValue();
     return $out;
 }
Beispiel #3
0
 /**
  * Get all of the Inputfields associated with the provided Page and populate them
  *
  * @param Page $page
  * @return Inputfield acting as a container for multiple Inputfields
  *
  */
 public function getPageInputfields(Page $page)
 {
     $container = new InputfieldWrapper();
     foreach ($this as $field) {
         $inputfield = $field->getInputfield($page);
         if (!$inputfield) {
             continue;
         }
         $inputfield->value = $page->get($field->name);
         $container->add($inputfield);
     }
     return $container;
 }
 public function getConfig(array $data)
 {
     // check that they have the required PW version
     if (version_compare(wire('config')->version, '2.2.13', '<')) {
         $this->error("Email Image requires ProcessWire 2.2.13 or newer. Please update.");
     }
     $modules = wire('modules');
     $form = new InputfieldWrapper();
     $field = $modules->get("InputfieldText");
     $field->attr('name', 'pop3_hostname');
     $field->attr('value', $data['pop3_hostname']);
     $field->label = __('POP3 hostname');
     $field->columnWidth = 50;
     $field->required = true;
     $form->add($field);
     $field = $modules->get("InputfieldInteger");
     $field->attr('name', 'pop3_port');
     $field->attr('value', $data['pop3_port']);
     $field->label = __('POP3 port');
     $field->columnWidth = 20;
     $field->required = true;
     $form->add($field);
     $field = $modules->get("InputfieldInteger");
     $field->attr('name', 'wait_seconds');
     $field->attr('value', $data['wait_seconds']);
     $field->label = __('Check every # seconds');
     $field->columnWidth = 30;
     $field->required = true;
     $form->add($field);
     $field = $modules->get("InputfieldText");
     $field->attr('name', 'pop3_user');
     $field->attr('value', $data['pop3_user']);
     $field->label = __('POP3 user');
     $field->columnWidth = 50;
     $field->required = true;
     $form->add($field);
     $field = $modules->get("InputfieldText");
     $field->attr('name', 'pop3_password');
     $field->attr('value', $data['pop3_password']);
     $field->attr('type', 'password');
     $field->label = __('POP3 password');
     $field->columnWidth = 50;
     $field->required = true;
     $form->add($field);
     $field = $modules->get("InputfieldTextarea");
     $field->attr('name', 'valid_senders');
     $field->attr('value', $data['valid_senders']);
     $field->label = __('Valid senders');
     $field->description = __('Enter a list of email addresses (1 per line) to process emails from.');
     $form->add($field);
     $fieldset = $modules->get('InputfieldFieldset');
     $fieldset->label = __('Advanced');
     $fieldset->attr('name', '_advanced');
     $fieldset->collapsed = Inputfield::collapsedYes;
     $field = $modules->get('InputfieldCheckbox');
     $field->attr('name', 'pop3_apop');
     $field->attr('value', 1);
     $field->attr('checked', $data['pop3_apop'] ? 'checked' : '');
     $field->columnWidth = 50;
     $field->label = __('Use APOP?');
     $field->notes = __('In rare cases this may be required.');
     $fieldset->add($field);
     $field = $modules->get('InputfieldCheckbox');
     $field->attr('name', 'pop3_tls');
     $field->attr('value', 1);
     $field->attr('checked', $data['pop3_tls'] ? 'checked' : '');
     $field->columnWidth = 50;
     $field->label = __('Use TLS?');
     $field->notes = __('GMail uses TLS and port 993.');
     $fieldset->add($field);
     $field = $modules->get("InputfieldText");
     $field->attr('name', 'pop3_body_txt_start');
     $field->attr('value', $data['pop3_body_txt_start']);
     $field->label = __('Tag or word that starts email body text for image description');
     $field->notes = __('Example: [text]');
     $field->columnWidth = 50;
     $fieldset->add($field);
     $field = $modules->get("InputfieldText");
     $field->attr('name', 'pop3_body_txt_end');
     $field->attr('value', $data['pop3_body_txt_end']);
     $field->label = __('Tag or word that ends email body text for image description');
     $field->notes = __('Example: [/text]');
     $field->columnWidth = 50;
     $fieldset->add($field);
     $form->add($fieldset);
     $field = $modules->get('InputfieldCheckbox');
     $field->attr('name', '_test_settings');
     $field->label = __('Test settings now');
     $field->attr('value', 1);
     $field->attr('checked', '');
     $form->add($field);
     if (wire('session')->test_settings) {
         wire('session')->remove('test_settings');
         $field->notes = $this->testSettings();
     } else {
         if (wire('input')->post->_test_settings) {
             wire('session')->set('test_settings', 1);
         }
     }
     $file = wire('config')->paths->templates . 'email-images.php';
     if (!is_file($file)) {
         $this->error("Please copy the file /site/modules/EmailImage/email-images.php to /site/templates/email-images.php");
     }
     return $form;
 }
Beispiel #5
0
 /**
  * Get all of the Inputfields associated with the provided Page and populate them
  *
  * @param Page $page
  * @param string $contextStr Optional context string to append to all the Inputfield's names (helper for things like repeaters)
  * @return Inputfield acting as a container for multiple Inputfields
  *
  */
 public function getPageInputfields(Page $page, $contextStr = '')
 {
     $container = new InputfieldWrapper();
     foreach ($this as $field) {
         // get a clone in the context of this fieldgroup, if it has contextual settings
         if (isset($this->fieldContexts[$field->id])) {
             $field = $this->getField($field->id, true);
         }
         $inputfield = $field->getInputfield($page, $contextStr);
         if (!$inputfield) {
             continue;
         }
         $inputfield->value = $page->get($field->name);
         $container->add($inputfield);
     }
     return $container;
 }
 /**
  * Get any custom configuration fields for this Inputfield
  *
  * Intended to be extended by each Inputfield as needed to add more config options. 
  * 
  * NOTE: Inputfields with a name that starts with an underscore, i.e. "_myname" are assumed to be for runtime
  * use and are NOT stored in the database.
  *
  * @return InputfieldWrapper
  *
  */
 public function ___getConfigInputfields()
 {
     $conditionsText = $this->_('Conditions are expressed with a "field=value" selector containing fields and values to match. Multiple conditions should be separated by a comma.');
     $conditionsNote = $this->_('Read more about [how to use this](http://processwire.com/api/selectors/inputfield-dependencies/).');
     $fields = new InputfieldWrapper();
     $fieldset = $this->modules->get('InputfieldFieldset');
     $fieldset->label = $this->_('Visibility');
     $fieldset->attr('name', 'visibility');
     $fieldset->icon = 'eye';
     $field = $this->modules->get("InputfieldSelect");
     $field->attr('name', 'collapsed');
     $field->label = $this->_('Presentation');
     $field->description = $this->_("How should this field be displayed in the editor?");
     $field->addOption(self::collapsedNo, $this->_('Always open (default)'));
     $field->addOption(self::collapsedNever, $this->_('Always open and cannot be collapsed'));
     $field->addOption(self::collapsedBlank, $this->_("Collapsed only when blank"));
     $field->addOption(self::collapsedPopulated, $this->_("Collapsed only when populated"));
     $field->addOption(self::collapsedYes, $this->_("Always collapsed, requiring a click to open"));
     $field->addOption(self::collapsedHidden, $this->_("Hidden, not shown in the editor"));
     $field->addOption(self::collapsedYesLocked, $this->_("Always collapsed and not editable (locked)"));
     $field->addOption(self::collapsedNoLocked, $this->_("Open when populated and not editable (locked)"));
     $field->attr('value', (int) $this->collapsed);
     $fieldset->append($field);
     $field = $this->modules->get("InputfieldText");
     $field->label = $this->_('Show this field only if...');
     $field->description = $this->_('Enter the conditions under which the field will be shown.') . ' ' . $conditionsText;
     $field->notes = $conditionsNote;
     $field->icon = 'question-circle';
     $field->attr('name', 'showIf');
     $field->attr('value', $this->getSetting('showIf'));
     $field->collapsed = Inputfield::collapsedBlank;
     $field->showIf = "collapsed!=" . self::collapsedHidden;
     $fieldset->append($field);
     $fieldset->collapsed = $this->collapsed == Inputfield::collapsedNo && !$this->getSetting('showIf') ? Inputfield::collapsedYes : Inputfield::collapsedNo;
     $fields->append($fieldset);
     $field = $this->modules->get('InputfieldInteger');
     $value = (int) $this->getSetting('columnWidth');
     if ($value < 10 || $value >= 100) {
         $value = 100;
     }
     $field->label = sprintf($this->_("Column Width (%d%%)"), $value);
     $field->icon = 'arrows-h';
     $field->attr('id+name', 'columnWidth');
     $field->attr('type', 'text');
     $field->attr('maxlength', 4);
     $field->attr('size', 4);
     $field->attr('max', 100);
     $field->attr('value', $value . '%');
     $field->description = $this->_("The percentage width of this field's container (10%-100%). If placed next to other fields with reduced widths, it will create floated columns.");
     // Description of colWidth option
     $field->notes = $this->_("Note that not all fields will work at reduced widths, so you should test the result after changing this.");
     // Notes for colWidth option
     if (!wire('input')->get('process_template')) {
         if ($value == 100) {
             $field->collapsed = Inputfield::collapsedYes;
         }
     }
     $fields->append($field);
     if (!$this instanceof InputfieldWrapper) {
         $field = $this->modules->get('InputfieldCheckbox');
         $field->label = $this->_('Required?');
         $field->icon = 'asterisk';
         $field->attr('name', 'required');
         $field->attr('value', 1);
         $field->attr('checked', $this->getSetting('required') ? 'checked' : '');
         $field->description = $this->_("If checked, a value will be required for this field.");
         $field->collapsed = $this->getSetting('required') ? Inputfield::collapsedNo : Inputfield::collapsedYes;
         $fields->add($field);
         $field = $this->modules->get('InputfieldText');
         $field->label = $this->_('Required only if...');
         $field->icon = 'asterisk';
         $field->description = $this->_('Enter the conditions under which a value will be required for this field.') . ' ' . $conditionsText;
         $field->notes = $conditionsNote;
         $field->attr('name', 'requiredIf');
         $field->attr('value', $this->getSetting('requiredIf'));
         $field->collapsed = $field->attr('value') ? Inputfield::collapsedNo : Inputfield::collapsedYes;
         $field->showIf = "required>0";
         $fields->add($field);
     }
     return $fields;
 }
 public function getConfig(array $data)
 {
     // check that they have the required PW version
     if (version_compare(wire('config')->version, '2.5.11', '<')) {
         $this->error(" requires ProcessWire 2.5.11 or newer. Please update.");
     }
     $modules = wire('modules');
     if ($modules->isInstalled('InputfieldRangeSlider')) {
         $rangeSliderInfo = InputfieldRangeSlider::getModuleInfo();
     }
     $hasSlider = $modules->isInstalled('InputfieldRangeSlider') && version_compare($rangeSliderInfo['version'], '1.0.4', '>=');
     $form = new InputfieldWrapper();
     $fieldset = $modules->get('InputfieldFieldset');
     $fieldset->label = 'Quality & Sharpening';
     $fieldset->attr('name', '_quality_sharpening');
     $fieldset->description = __('Here you can set sitewide options for Quality and Sharpening');
     $fieldset->collapsed = Inputfield::collapsedNo;
     $field = $modules->get('InputfieldCheckbox');
     $field->attr('name', 'manualSelectionDisabled');
     $field->label = __('Globally disable the usage of DropDown-Selects for Quality & Sharpening!');
     $field->attr('value', 1);
     $field->attr('checked', $data['manualSelectionDisabled'] ? 'checked' : '');
     $field->columnWidth = 100;
     $fieldset->add($field);
     $field = $modules->get('InputfieldSelect');
     $field->label = 'global setting for Sharpening';
     $field->attr('name', 'optionSharpening');
     if (is_numeric($data['optionSharpening']) && isset(self::$sharpeningValues[intval($data['optionSharpening'])])) {
         $value = $data['optionSharpening'];
     } elseif (is_string($data['optionSharpening']) && in_array($data['optionSharpening'], self::$sharpeningValues)) {
         $flippedA = array_flip(self::$sharpeningValues);
         $value = strval($flippedA[$data['optionSharpening']]);
     } else {
         $value = '1';
     }
     $field->attr('value', intval($value));
     $field->addOptions(self::$sharpeningValues);
     $field->description = __('sharpening: none | soft | medium | strong');
     $field->columnWidth = 50;
     $field->showIf = "manualSelectionDisabled=1";
     $fieldset->add($field);
     $field = $modules->get('InputfieldInteger');
     $field->label = 'global setting for Quality';
     $field->attr('name', 'optionQuality');
     $field->attr('value', $data['optionQuality'] > 0 && $data['optionQuality'] <= 100 ? $data['optionQuality'] : 90);
     $field->description = __('quality: 1-100 where higher is better but bigger');
     $field->columnWidth = 50;
     $field->showIf = "manualSelectionDisabled=1";
     if ($hasSlider) {
         $field->collapsed = Inputfield::collapsedHidden;
         $fieldset->add($field);
         $fieldS = $modules->get('InputfieldRangeSlider');
         // read value from optionQuality, not from optionQualitySlider
         $fieldS->label = 'quality';
         $fieldS->attr('name', 'optionQualitySlider');
         $fieldS->attr('value', array('min' => $data['optionQuality'] > 0 && $data['optionQuality'] <= 100 ? $data['optionQuality'] : 90));
         $fieldS->isrange = false;
         $fieldS->minValue = 1;
         $fieldS->maxValue = 100;
         $fieldS->step = 1;
         $fieldS->width = 100;
         $fieldS->description = __('quality: 1-100 where higher is better but bigger');
         $fieldS->columnWidth = 50;
         $fieldS->showIf = "manualSelectionDisabled=1";
         $fieldset->add($fieldS);
     } else {
         $fieldset->add($field);
     }
     $form->add($fieldset);
     //        $field = $modules->get("InputfieldMarkup");
     //        $field->attr('name', 'info1');
     //        $field->collapsed = Inputfield::collapsedNo;
     //        $field->attr('value',
     //            "THIS IS A TEMPORARY PLACEHOLDER FOR LATER CONTRIBUTIONS<br /><br />"
     //            );
     //        $field->label = __('Info');
     //        $field->columnWidth = 100;
     //        $form->add($field);
     //        $field = $modules->get('InputfieldCheckbox');
     //        $field->attr('name', 'remove_all_variations');
     //        $field->label = __('Remove all Imagevariations to clear the images-cache sitewide!');
     //        $field->attr('value', 1);
     //        $field->attr('checked', '');
     //        $field->columnWidth = 65;
     //        $form->add($field);
     //
     //        if(wire('session')->remove_all_variations) {
     //            wire('session')->remove('remove_all_variations');
     //            $testmode = '1'==$data['do_only_test_run'] ? true : false;
     //            $field->notes = $this->doTheDishes( !$testmode );
     //        } else if(wire('input')->post->remove_all_variations) {
     //            wire('session')->set('remove_all_variations', 1);
     //        }
     //
     //        $field = $modules->get('InputfieldCheckbox');
     //        $field->attr('name', 'do_only_test_run');
     //        $field->label = __('Run only in test mode! Do not delete the variations.');
     //        $field->attr('value', 1);
     //        $field->attr('checked', '1');
     //        $field->columnWidth = 35;
     //        $form->add($field);
     return $form;
 }
Beispiel #8
0
 /**
  * Populate any configuration inputfields to the given $inputfields wrapper for $process
  *
  * @param InputfieldWrapper $inputfields
  * @param Process $process
  *
  */
 public function addConfigInputfields(InputfieldWrapper $inputfields)
 {
     $field = $this->wire('modules')->get('InputfieldCheckbox');
     $field->attr('name', 'useBookmarks');
     $field->label = $this->_('Allow use of bookmarks?');
     $field->description = $this->_('Bookmarks enable you to create shortcuts to pages from this module, configurable by user role. Useful for large applications.');
     $field->icon = 'bookmark-o';
     if ($this->process->useBookmarks) {
         $field->attr('checked', 'checked');
     }
     $inputfields->add($field);
 }