From 1633b990caaafd7a2b15221b0df334986b85c78c Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 3 Nov 2016 11:10:04 -0400 Subject: [PATCH] Update several Inputfield modules to remove unnecessary newlines in markup and add phpdocs where appropriate --- wire/core/InputfieldWrapper.php | 20 ++-- wire/core/Pagefile.php | 3 +- wire/core/WireData.php | 2 + .../InputfieldRepeater.module | 1 + .../InputfieldAsmSelect.module | 4 +- .../Inputfield/InputfieldButton.module | 1 + .../InputfieldCKEditor.module | 20 +++- .../Inputfield/InputfieldCheckbox.module | 2 +- .../InputfieldCheckboxes.module | 8 +- .../InputfieldDatetime.module | 4 +- .../modules/Inputfield/InputfieldEmail.module | 5 +- .../Inputfield/InputfieldFieldset.module | 2 +- .../InputfieldFile/InputfieldFile.module | 54 +++++---- .../modules/Inputfield/InputfieldFloat.module | 10 ++ wire/modules/Inputfield/InputfieldForm.module | 28 +++-- .../Inputfield/InputfieldHidden.module | 3 +- .../InputfieldIcon/InputfieldIcon.module | 8 +- .../Inputfield/InputfieldMarkup.module | 6 +- .../InputfieldPage/InputfieldPage.module | 20 ++-- .../InputfieldPageAutocomplete.module | 6 +- .../InputfieldPageListSelect.module | 2 +- .../InputfieldPageListSelectMultiple.module | 8 +- .../InputfieldPageName.module | 2 +- .../InputfieldPageTable.module | 1 + .../InputfieldPageTableAjax.php | 4 +- .../InputfieldRadios/InputfieldRadios.module | 9 +- .../Inputfield/InputfieldSelect.module | 111 +++++++++++++++--- .../InputfieldSubmit/InputfieldSubmit.module | 6 +- wire/modules/Inputfield/InputfieldText.module | 2 +- .../Inputfield/InputfieldTextarea.module | 2 +- 30 files changed, 245 insertions(+), 109 deletions(-) diff --git a/wire/core/InputfieldWrapper.php b/wire/core/InputfieldWrapper.php index 6fc6de1a..2fdb5f26 100644 --- a/wire/core/InputfieldWrapper.php +++ b/wire/core/InputfieldWrapper.php @@ -42,15 +42,15 @@ class InputfieldWrapper extends Inputfield implements \Countable, \IteratorAggre * */ static protected $defaultMarkup = array( - 'list' => "\n\n", - 'item' => "\n\t
  • \n{out}\n\t
  • ", - 'item_label' => "\n\t\t", - 'item_label_hidden' => "\n\t\t", - 'item_content' => "\n\t\t
    \n{out}\n\t\t
    ", - 'item_error' => "\n

    {out}

    ", - 'item_description' => "\n

    {out}

    ", - 'item_head' => "\n

    {out}

    ", - 'item_notes' => "\n

    {out}

    ", + 'list' => "", + 'item' => "
  • {out}
  • ", + 'item_label' => "", + 'item_label_hidden' => "", + 'item_content' => "
    {out}
    ", + 'item_error' => "

    {out}

    ", + 'item_description' => "

    {out}

    ", + 'item_head' => "

    {out}

    ", + 'item_notes' => "

    {out}

    ", 'item_icon' => " ", 'item_toggle' => "", // ALSO: @@ -900,7 +900,7 @@ class InputfieldWrapper extends Inputfield implements \Countable, \IteratorAggre * #pw-internal * * @param bool $clear Set to true in order to clear the delayed children list. - * @return array + * @return array|Inputfield[] * */ public function _getDelayedChildren($clear = false) { diff --git a/wire/core/Pagefile.php b/wire/core/Pagefile.php index 06ef5c2c..186e805c 100644 --- a/wire/core/Pagefile.php +++ b/wire/core/Pagefile.php @@ -19,7 +19,8 @@ * @property-read string $filename full disk path to the file on the server. * @property-read string $name Returns the filename without the path, same as the "basename" property. * @property-read string $hash Get a unique hash (for the page) representing this Pagefile. - * @property-read string $tagsArray Get file tags as an array. #pw-group-tags @since 3.0.17 + * @property-read string $tagsArray Get file tags as an array. #pw-group-tags @since 3.0.17 + * @property-read int $sort Sort order in database. #pw-group-other * @property string $basename Returns the filename without the path. * @property string $description Value of the file’s description field (string), if enabled. Note you can also set this property directly. * @property string $tags Value of the file’s tags field (string), if enabled. #pw-group-tags diff --git a/wire/core/WireData.php b/wire/core/WireData.php index 028c50ec..d754bb50 100644 --- a/wire/core/WireData.php +++ b/wire/core/WireData.php @@ -23,6 +23,8 @@ * * ProcessWire 3.x, Copyright 2016 by Ryan Cramer * https://processwire.com + * + * @method WireArray and($items = null) * */ diff --git a/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module b/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module index f667e503..d892de1c 100644 --- a/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module +++ b/wire/modules/Fieldtype/FieldtypeRepeater/InputfieldRepeater.module @@ -498,6 +498,7 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList { $forIDs = null; if($loading == FieldtypeRepeater::loadingAll && $collapse != FieldtypeRepeater::collapseNone) $forIDs = array(); list($editorUrl, $queryString) = explode('?', $this->page->editUrl()); + if($queryString) {} $this->wire('config')->js('InputfieldRepeater', array( 'editorUrl' => $editorUrl, diff --git a/wire/modules/Inputfield/InputfieldAsmSelect/InputfieldAsmSelect.module b/wire/modules/Inputfield/InputfieldAsmSelect/InputfieldAsmSelect.module index a8c4f4b9..12e2e4ac 100644 --- a/wire/modules/Inputfield/InputfieldAsmSelect/InputfieldAsmSelect.module +++ b/wire/modules/Inputfield/InputfieldAsmSelect/InputfieldAsmSelect.module @@ -2,6 +2,8 @@ /** * A Page List Selector for selecting a single page + * + * @property int|bool $usePageEdit * */ class InputfieldAsmSelect extends InputfieldSelectMultiple implements InputfieldHasArrayValue { @@ -69,7 +71,7 @@ class InputfieldAsmSelect extends InputfieldSelectMultiple implements Inputfield $this->wire('modules')->get('JqueryUI')->use('modal'); } - if($this->hasFieldtype == 'FieldtypePage' && $this->usePageEdit && !$this->editLink) { + if($this->hasFieldtype == 'FieldtypePage' && $this->usePageEdit && empty($this->asmOptions['editLink'])) { $this->setAsmSelectOption('editLink', $this->wire('config')->urls->admin . 'page/edit/?id={value}'); $this->setAsmSelectOption('editLinkOnlySelected', false); $this->setAsmSelectOption('editLinkButtonSelector', ".InputfieldSubmit button.ui-button:visible"); diff --git a/wire/modules/Inputfield/InputfieldButton.module b/wire/modules/Inputfield/InputfieldButton.module index 818b5a72..9f3a5be4 100644 --- a/wire/modules/Inputfield/InputfieldButton.module +++ b/wire/modules/Inputfield/InputfieldButton.module @@ -5,6 +5,7 @@ * * @property string $href URL to link to * @property string $aclass Optional class name(s) for element (if href is used). + * @property string $target Link target * */ class InputfieldButton extends InputfieldSubmit { diff --git a/wire/modules/Inputfield/InputfieldCKEditor/InputfieldCKEditor.module b/wire/modules/Inputfield/InputfieldCKEditor/InputfieldCKEditor.module index aa7249ac..3d46433c 100644 --- a/wire/modules/Inputfield/InputfieldCKEditor/InputfieldCKEditor.module +++ b/wire/modules/Inputfield/InputfieldCKEditor/InputfieldCKEditor.module @@ -167,6 +167,9 @@ class InputfieldCKEditor extends InputfieldTextarea { * Toolbar items split by commas * Groups of toolbar items split by lines * Toolbar lines that starts with '#' are ignored + * + * @param string $str + * @return array * */ protected function toolbarStringToArray($str) { @@ -299,7 +302,7 @@ class InputfieldCKEditor extends InputfieldTextarea { if($this->contentsInlineCss) { $this->config->styles->add($this->pathFromRoot($this->contentsInlineCss, true)); } else { - $this->config->styles->add($this->config->urls->InputfieldCKEditor . "contents-inline.css"); + $this->config->styles->add($this->config->urls('InputfieldCKEditor') . "contents-inline.css"); } } @@ -403,7 +406,7 @@ class InputfieldCKEditor extends InputfieldTextarea { if($this->wire('files')->mkdir($path, true)) { $this->message("Created new CKEditor external plugins directory: $url"); } else { - $this->error("The CKEditor external plugins directory does not exist: $url - Please create it when/if you want to install external plugins.", Notice::warning); + $this->warning("The CKEditor external plugins directory does not exist: $url - Please create it when/if you want to install external plugins."); } } continue; @@ -463,6 +466,9 @@ class InputfieldCKEditor extends InputfieldTextarea { * Clean up a value that will be sent to/from the editor * * This is primarily for HTML Purifier + * + * @param string $value + * @return string * */ protected function purifyValue($value) { @@ -517,6 +523,9 @@ class InputfieldCKEditor extends InputfieldTextarea { * Process data submitted to a CKEditor field * * When inline mode is used, the content is run through HTML Purifier + * + * @param WireInputData $input + * @return $this * */ public function ___processInput(WireInputData $input) { @@ -637,9 +646,11 @@ class InputfieldCKEditor extends InputfieldTextarea { if($f) $inputfields->remove($f); } + /** @var InputfieldFieldset $wrapper */ $wrapper = $this->wire('modules')->get('InputfieldFieldset'); $wrapper->label = $this->_('CKEditor Settings'); + /** @var InputfieldTextarea $f */ $f = $this->wire('modules')->get('InputfieldTextarea'); $f->attr('name', 'toolbar'); $f->attr('value', $this->toolbar); @@ -650,6 +661,7 @@ class InputfieldCKEditor extends InputfieldTextarea { $purifierInstalled = $this->wire('modules')->isInstalled('MarkupHTMLPurifier'); + /** @var InputfieldRadios $f */ $f = $this->wire('modules')->get('InputfieldRadios'); $f->attr('name', 'inlineMode'); $f->label = $this->_('Editor Mode'); @@ -782,11 +794,13 @@ class InputfieldCKEditor extends InputfieldTextarea { $this->_('only for this CKEditor field'); $wrapper->add($f); + /** @var InputfieldFieldset $fieldset */ $fieldset = $this->modules->get('InputfieldFieldset'); $fieldset->attr('name', '_plugins_fieldset'); $fieldset->label = $this->_('Plugins'); $wrapper->add($fieldset); - + + /** @var InputfieldCheckboxes $f */ $f = $this->modules->get('InputfieldCheckboxes'); $f->attr('name', 'extraPlugins'); $f->label = $this->_('Extra Plugins'); diff --git a/wire/modules/Inputfield/InputfieldCheckbox.module b/wire/modules/Inputfield/InputfieldCheckbox.module index 51027a71..d3fd26f5 100644 --- a/wire/modules/Inputfield/InputfieldCheckbox.module +++ b/wire/modules/Inputfield/InputfieldCheckbox.module @@ -106,7 +106,7 @@ class InputfieldCheckbox extends Inputfield { $this->checkedValueIsLabel = false; } // autocheck mode: when non-zero 'value' set, then 'checked=checked' is assumed - if($this->autocheck || $this->formBuilder) $this->attr('checked', 'checked'); + if($this->autocheck || $this->getSetting('formBuilder')) $this->attr('checked', 'checked'); } diff --git a/wire/modules/Inputfield/InputfieldCheckboxes/InputfieldCheckboxes.module b/wire/modules/Inputfield/InputfieldCheckboxes/InputfieldCheckboxes.module index 0dd36bbc..ebcb5a0f 100644 --- a/wire/modules/Inputfield/InputfieldCheckboxes/InputfieldCheckboxes.module +++ b/wire/modules/Inputfield/InputfieldCheckboxes/InputfieldCheckboxes.module @@ -40,6 +40,7 @@ class InputfieldCheckboxes extends InputfieldSelectMultiple implements Inputfiel $entityEncode = $this->getSetting('entityEncodeText') === false ? false : true; if($this->table) { + /** @var MarkupAdminDataTable $table */ $table = $this->modules->get("MarkupAdminDataTable"); $table->setEncodeEntities(false); $table->addClass('pw-no-select'); @@ -62,7 +63,7 @@ class InputfieldCheckboxes extends InputfieldSelectMultiple implements Inputfiel $ulClass = 'InputfieldCheckboxesStacked'; } - if(!$table) $out = "\n"; return $out; @@ -115,6 +116,7 @@ class InputfieldCheckboxes extends InputfieldSelectMultiple implements Inputfiel public function ___getConfigInputfields() { $inputfields = parent::___getConfigInputfields(); + /** @var InputfieldInteger $f */ $f = $this->wire('modules')->get('InputfieldInteger'); $f->label = $this->_('Columns of Checkboxes'); $f->description = $this->_('If you want the checkboxes to display in columns (rather than stacked), enter the number of columns you want to use (up to 10). To display checkboxes side-by-side (inline) enter 1.'); diff --git a/wire/modules/Inputfield/InputfieldDatetime/InputfieldDatetime.module b/wire/modules/Inputfield/InputfieldDatetime/InputfieldDatetime.module index 24a18a39..0201516d 100644 --- a/wire/modules/Inputfield/InputfieldDatetime/InputfieldDatetime.module +++ b/wire/modules/Inputfield/InputfieldDatetime/InputfieldDatetime.module @@ -173,7 +173,7 @@ class InputfieldDatetime extends Inputfield { if(empty($value)) $value = ''; $yearRange = $sanitizer->entities($this->yearRange); - $out = "\n" . + $out = "getAttributesString($attrs) . " " . "value='$value' " . "data-dateformat='$dateFormatJS' " . @@ -400,7 +400,7 @@ class InputfieldDatetime extends Inputfield { $f->columnWidth = 50; $inputfields->append($f); - /** @var InputfieldText $f */ + /** @var InputfieldText $field */ $field = $this->modules->get('InputfieldText'); $field->setAttribute('name', 'placeholder'); $field->label = $this->_('Placeholder Text'); diff --git a/wire/modules/Inputfield/InputfieldEmail.module b/wire/modules/Inputfield/InputfieldEmail.module index 41ca92fa..5cc5f002 100644 --- a/wire/modules/Inputfield/InputfieldEmail.module +++ b/wire/modules/Inputfield/InputfieldEmail.module @@ -33,14 +33,14 @@ class InputfieldEmail extends InputfieldText { if(!$this->label || $this->label == $this->name) $this->label = $this->_('E-Mail'); // label headline when no default specified if($this->confirm && count($this->getErrors())) $this->attr('value', ''); $attrs = $this->getAttributes(); - $out = "\ngetAttributesString($attrs) . " />"; + $out = "getAttributesString($attrs) . " />"; if($this->confirm) { foreach(array('id', 'name') as $key) { if(isset($attrs[$key])) $attrs[$key] = '_' . $attrs[$key] . '_confirm'; } $attrs['aria-label'] = $this->confirmLabel; $attrs['placeholder'] = $this->confirmLabel; - $out .= "\n
    getAttributesString($attrs) . " />
    "; + $out .= "
    getAttributesString($attrs) . " />
    "; } return $out; } @@ -75,6 +75,7 @@ class InputfieldEmail extends InputfieldText { if($f) $inputfields->remove($f); } + /** @var InputfieldCheckbox $f */ $f = $this->wire('modules')->get('InputfieldCheckbox'); $f->attr('name', 'confirm'); $f->label = $this->_('Confirm email address?'); diff --git a/wire/modules/Inputfield/InputfieldFieldset.module b/wire/modules/Inputfield/InputfieldFieldset.module index 902bac58..24c5571a 100644 --- a/wire/modules/Inputfield/InputfieldFieldset.module +++ b/wire/modules/Inputfield/InputfieldFieldset.module @@ -14,7 +14,7 @@ class InputfieldFieldset extends InputfieldWrapper { public function ___render() { // Note the extra "\n" is required in order to prevent InputfieldWrapper from // skipping over an empty fieldset. Empty fieldsets are used by InputfieldRepeater - // for thier description/label, and possibly others use it the same way. + // for their description/label, and possibly others use it the same way. return parent::___render() . "\n"; } diff --git a/wire/modules/Inputfield/InputfieldFile/InputfieldFile.module b/wire/modules/Inputfield/InputfieldFile/InputfieldFile.module index 1c9ce939..dfd4f7a9 100644 --- a/wire/modules/Inputfield/InputfieldFile/InputfieldFile.module +++ b/wire/modules/Inputfield/InputfieldFile/InputfieldFile.module @@ -19,6 +19,15 @@ * @property bool|int $noCollapseItem Set to true to disable collapsed items (like for LanguageTranslator tool or other things that add tools to files) * @property bool|int $noShortName Set to true to disable shortened filenames in output * @property bool|int $noCustomButton Set to true to disable use of the styled + * + * @method string renderItem($pagefile, $id, $n) + * @method string renderList($value) + * @method string renderUpload($value) + * @method void fileAdded(Pagefile $pagefile) + * @method array extractMetadata(Pagefile $pagefile, array $metadata = array()) + * @method void processInputAddFile($filename) + * @method void processInputDeleteFile(Pagefile $pagefile) + * @method bool processInputFile(WireInputData $input, Pagefile $pagefile, $n) * */ class InputfieldFile extends Inputfield implements InputfieldItemList { @@ -181,7 +190,7 @@ class InputfieldFile extends Inputfield implements InputfieldItemList { * Set the parent of this Inputfield * * @param InputfieldWrapper $parent - * @return this + * @return $this * */ public function setParent(InputfieldWrapper $parent) { @@ -195,7 +204,8 @@ class InputfieldFile extends Inputfield implements InputfieldItemList { } protected function renderItemDescriptionField(Pagefile $pagefile, $id, $n) { - + + if($n) {} $out = ''; $tabs = ''; static $hasLangTabs = null; @@ -317,26 +327,26 @@ class InputfieldFile extends Inputfield implements InputfieldItemList { $deleteLabel = $this->labels['delete']; $out = - "\n\t\t

    " . - "\n\t\t\t" . wireIconMarkupFile($pagefile->basename, "fa-fw HideIfEmpty") . - "\n\t\t\t$displayName " . - "\n\t\t\t" . str_replace(' ', ' ', $pagefile->filesizeStr) . " "; + "

    " . + wireIconMarkupFile($pagefile->basename, "fa-fw HideIfEmpty") . + "$displayName " . + "" . str_replace(' ', ' ', $pagefile->filesizeStr) . " "; if(!$this->renderValueMode) $out .= - "\n\t\t\t

    " . - "\n\t\t
    " . - "\n\t\t\t" . $this->renderItemDescriptionField($pagefile, $id, $n); + "

    " . + "
    " . + $this->renderItemDescriptionField($pagefile, $id, $n); if(!$this->renderValueMode) $out .= - "\n\t\t\t"; + ""; $out .= - "\n\t\t
    "; + "
    "; return $out; } @@ -347,7 +357,7 @@ class InputfieldFile extends Inputfield implements InputfieldItemList { // they will get strict notices from php if we add a new argument here. $item = $this->currentItem; $id = $item && !$this->renderValueMode ? " id='file_$item->hash'" : ""; - return "\n\t$out\n\t"; + return "$out"; } protected function renderListReady($value) { @@ -380,12 +390,13 @@ class InputfieldFile extends Inputfield implements InputfieldItemList { $class = 'InputfieldFileList ui-helper-clearfix'; if($this->overwrite && !$this->renderValueMode) $class .= " InputfieldFileOverwrite"; - if($out) $out = "\n
      $out\n
    "; + if($out) $out = "
      $out
    "; return $out; } protected function ___renderUpload($value) { + if($value) {} if($this->noUpload || $this->renderValueMode) return ''; // enables user to choose more than one file @@ -570,6 +581,7 @@ class InputfieldFile extends Inputfield implements InputfieldItemList { } $this->value->add($filename); + /** @var Pagefile $item */ $item = $this->value->last(); try { @@ -610,6 +622,7 @@ class InputfieldFile extends Inputfield implements InputfieldItemList { if($replace) { if(strpos($replace, '?') !== false) { list($replace, $unused) = explode('?', $replace); + if($unused) {} } $replaceFile = $this->value->getFile($replace); if($replaceFile && $replaceFile instanceof Pagefile) { @@ -766,9 +779,11 @@ class InputfieldFile extends Inputfield implements InputfieldItemList { /** * Send an ajax response * - * $error bool Whether it was successful - * $message string Message you want to return - * $file string Full path and filename or blank if not applicable + * @param bool $error Whether it was successful + * @param string $message Message you want to return + * @param string $file Full path and filename or blank if not applicable + * @param string $size + * @param string $markup * */ protected function ajaxResponse($error, $message, $file = '', $size = '', $markup = '') { @@ -825,7 +840,8 @@ class InputfieldFile extends Inputfield implements InputfieldItemList { */ public function ___getConfigInputfields() { $inputfields = parent::___getConfigInputfields(); - + + /** @var InputfieldCheckbox $f */ $f = $this->modules->get("InputfieldCheckbox"); $f->attr('name', 'unzip'); $f->attr('value', 1); @@ -863,8 +879,6 @@ class InputfieldFile extends Inputfield implements InputfieldItemList { $inputfields->append($f); } - // @todo make noAjax option configurable - return $inputfields; } diff --git a/wire/modules/Inputfield/InputfieldFloat.module b/wire/modules/Inputfield/InputfieldFloat.module index 6f1f77f9..4723b8f6 100644 --- a/wire/modules/Inputfield/InputfieldFloat.module +++ b/wire/modules/Inputfield/InputfieldFloat.module @@ -1,5 +1,12 @@ " . + $out = + "
    " . $description . $this->getSetting('prependMarkup') . parent::___render() . $tokenField . $this->getSetting('appendMarkup') . - "\n
    "; + ""; return $out; } @@ -167,7 +169,8 @@ class InputfieldForm extends InputfieldWrapper { $delayedN = count($delayedChildren); $processedN = 0; $unprocessedN = 0; - + + /** @var Inputfield[] $savedChildren */ $savedChildren = $delayedChildren; while(count($delayedChildren)) { @@ -191,6 +194,7 @@ class InputfieldForm extends InputfieldWrapper { // whether we should process $child now or not $processNow = true; + $selector = null; foreach($selectors as $selector) { @@ -204,8 +208,8 @@ class InputfieldForm extends InputfieldWrapper { // if field had already been through the loop, but was not processed, add it back in for processing if(!isset($delayedChildren[$name]) - && !$savedChildren[$name]->showIfProcessed - && !$savedChildren[$name]->showIfSkipped) { + && !$savedChildren[$name]->getSetting('showIfProcessed') + && !$savedChildren[$name]->getSetting('showIfSkipped')) { $delayedChildren[$name] = $savedChildren[$name]; } @@ -214,13 +218,13 @@ class InputfieldForm extends InputfieldWrapper { $savedChildren[$name]->showIf = '1>0'; // forced match } - if($savedChildren[$name]->showIfSkipped) { + if($savedChildren[$name]->getSetting('showIfSkipped')) { // dependency $field does not need to be processed, so neither does this field unset($delayedChildren[$child->name]); $processNow = false; if(self::debug) $this->debugNote("Removing field '$child->name' because '$name' it not shown."); - } else if(!$savedChildren[$name]->showIfProcessed) { + } else if(!$savedChildren[$name]->getSetting('showIfProcessed')) { // dependency $field is another one in $delayedChildren, send it back to the end unset($delayedChildren[$child->name]); // put it back on the end @@ -305,7 +309,7 @@ class InputfieldForm extends InputfieldWrapper { * Process input for fields with a required-if dependency * * @param WireInputData $input - * @param array $delayedChildren + * @param array|Inputfield[] $delayedChildren * @return bool * */ @@ -313,7 +317,7 @@ class InputfieldForm extends InputfieldWrapper { // process input for any remaining delayedChildren not already processed by processInputShowIf foreach($delayedChildren as $child) { - if($child->showIfSkipped || $child->showIfProcessed) continue; + if($child->getSetting('showIfSkipped') || $child->getSetting('showIfProcessed')) continue; if(self::debug) $this->debugNote("Now Processing requiredIf delayed child: $child->name"); $child->processInput($input); } @@ -326,7 +330,7 @@ class InputfieldForm extends InputfieldWrapper { // if field was not shown, then it can't be required - if($child->showIfSkipped) continue; + if($child->getSetting('showIfSkipped')) continue; $required = true; $selectorString = $child->getSetting('requiredIf'); @@ -374,7 +378,7 @@ class InputfieldForm extends InputfieldWrapper { * Does the selector match the given Inputfield name? * * @param Selector $selector - * @param $name Name of Inputfield + * @param string $name Name of Inputfield * @param string $debugNote Optional qualifier note for debugging * @return bool|null Returns true|false if match determined, or NULL if $name is not present in form * diff --git a/wire/modules/Inputfield/InputfieldHidden.module b/wire/modules/Inputfield/InputfieldHidden.module index b9cd1743..0bc7b2f0 100644 --- a/wire/modules/Inputfield/InputfieldHidden.module +++ b/wire/modules/Inputfield/InputfieldHidden.module @@ -22,7 +22,7 @@ class InputfieldHidden extends Inputfield { } public function ___render() { - return "\ngetAttributesString() . " />"; + return "getAttributesString() . " />"; } public function getAttributes() { @@ -41,6 +41,7 @@ class InputfieldHidden extends Inputfield { $f = $inputfields->getChildByName('columnWidth'); $inputfields->remove($f); + /** @var InputfieldText $field */ $field = $this->modules->get('InputfieldText'); $field->setAttribute('name', 'initValue'); $field->label = $this->_('Value'); diff --git a/wire/modules/Inputfield/InputfieldIcon/InputfieldIcon.module b/wire/modules/Inputfield/InputfieldIcon/InputfieldIcon.module index 4ef4fa14..ac92d95f 100644 --- a/wire/modules/Inputfield/InputfieldIcon/InputfieldIcon.module +++ b/wire/modules/Inputfield/InputfieldIcon/InputfieldIcon.module @@ -1,5 +1,11 @@ prefixValue) { + if($this->getSetting('prefixValue')) { if(strpos($value, self::prefix) !== 0) { // add prefix $value = self::prefix . $value; diff --git a/wire/modules/Inputfield/InputfieldMarkup.module b/wire/modules/Inputfield/InputfieldMarkup.module index a908840a..e8f61846 100644 --- a/wire/modules/Inputfield/InputfieldMarkup.module +++ b/wire/modules/Inputfield/InputfieldMarkup.module @@ -65,12 +65,12 @@ class InputfieldMarkup extends InputfieldWrapper { if($this->getSetting('entityEncodeText') !== false && $textFormat != Inputfield::textFormatNone) { if($textFormat == Inputfield::textFormatBasic) { $description = $this->entityEncode($description, Inputfield::textFormatBasic); - $out = "\n

    {$description}

    $out"; + $out = "

    {$description}

    $out"; } else if($textFormat == Inputfield::textFormatMarkdown) { - $out = "\n
    " . $this->entityEncode($description, Inputfield::textFormatMarkdown) . "
    $out"; + $out = "
    " . $this->entityEncode($description, Inputfield::textFormatMarkdown) . "
    $out"; } } else { - $out = "\n
    $description
    $out"; + $out = "
    $description
    $out"; } $this->description = ''; // prevents it from appearing again at the bottom } diff --git a/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module b/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module index a4e3c51f..4667cb2d 100644 --- a/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module +++ b/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module @@ -575,7 +575,7 @@ class InputfieldPage extends Inputfield implements ConfigurableModule { $inputfield->addClass($addClass); } - $out = "\n
    "; + $out = "
    "; $out .= $inputfield->render(); $out .= $this->renderAddable(); @@ -606,7 +606,7 @@ class InputfieldPage extends Inputfield implements ConfigurableModule { "value='$selector' />"; } - $out .= "\n
    "; + $out .= "
    "; return $out; } @@ -657,14 +657,14 @@ class InputfieldPage extends Inputfield implements ConfigurableModule { $label =" " . $this->_('Create New'); $out = - "\n
    " . - "\n\t

    $label

    " . - "\n\t

    " . - "\n\t\t" . - "\n\t\t$input" . - "\n\t\t$notes" . - "\n\t

    " . - "\n
    "; + "
    " . + "

    $label

    " . + "

    " . + "" . + "$input" . + "$notes" . + "

    " . + "
    "; return $out; } diff --git a/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module b/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module index 8f2fc4b2..672fa83f 100644 --- a/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module +++ b/wire/modules/Inputfield/InputfieldPageAutocomplete/InputfieldPageAutocomplete.module @@ -105,7 +105,7 @@ class InputfieldPageAutocomplete extends Inputfield implements InputfieldHasArra if(strpos($label, '&') !== false) $label = $this->wire('sanitizer')->unentities($label); $label = $this->wire('sanitizer')->entities($label); $out = - "\n
  • " . + "
  • " . " " . "$value" . "$label " . @@ -122,7 +122,7 @@ class InputfieldPageAutocomplete extends Inputfield implements InputfieldHasArra */ protected function ___renderList() { - $out = "\n
      " . + $out = "
        " . $this->renderListItem("Label", "1", "itemTemplate"); foreach($this->value as $page_id) { @@ -135,7 +135,7 @@ class InputfieldPageAutocomplete extends Inputfield implements InputfieldHasArra $out .= $this->renderListItem($value, $page->id); } - $out .= "\n
      "; + $out .= "
    "; return $out; } diff --git a/wire/modules/Inputfield/InputfieldPageListSelect/InputfieldPageListSelect.module b/wire/modules/Inputfield/InputfieldPageListSelect/InputfieldPageListSelect.module index ecaf7367..41a5e473 100644 --- a/wire/modules/Inputfield/InputfieldPageListSelect/InputfieldPageListSelect.module +++ b/wire/modules/Inputfield/InputfieldPageListSelect/InputfieldPageListSelect.module @@ -64,7 +64,7 @@ class InputfieldPageListSelect extends Inputfield implements InputfieldPageListS $attrs['data-cancel'] = $this->cancelLabel; $attrs['data-labelName'] = $this->attr('name'); - $out = "\ngetAttributesString($attrs) . " />"; + $out = "getAttributesString($attrs) . " />"; return $out; } diff --git a/wire/modules/Inputfield/InputfieldPageListSelect/InputfieldPageListSelectMultiple.module b/wire/modules/Inputfield/InputfieldPageListSelect/InputfieldPageListSelectMultiple.module index 87151bc6..a371cb4b 100644 --- a/wire/modules/Inputfield/InputfieldPageListSelect/InputfieldPageListSelectMultiple.module +++ b/wire/modules/Inputfield/InputfieldPageListSelect/InputfieldPageListSelectMultiple.module @@ -47,7 +47,7 @@ class InputfieldPageListSelectMultiple extends Inputfield implements InputfieldH protected function renderListItem($label, $value, $class = '') { if($class) $class = " $class"; $out = - "\n
  • " . + "
  • " . // "" . " " . "$value" . @@ -73,7 +73,7 @@ class InputfieldPageListSelectMultiple extends Inputfield implements InputfieldH return "

    " . $this->_('Unable to render this field due to missing parent page in field settings.') . '

    '; } - $out = "\n
      " . $this->renderListItem("Label", "1", "itemTemplate"); + $out = "
        " . $this->renderListItem("Label", "1", "itemTemplate"); foreach($this->value as $page_id) { $page = $this->pages->get((int) $page_id); @@ -83,7 +83,7 @@ class InputfieldPageListSelectMultiple extends Inputfield implements InputfieldH $out .= $this->renderListItem($label, $page->id); } - $out .= "\n
      "; + $out .= "
    "; $this->addClass('InputfieldPageListSelectMultipleData'); $attrs = $this->getAttributes(); @@ -100,7 +100,7 @@ class InputfieldPageListSelectMultiple extends Inputfield implements InputfieldH $attrStr = $this->getAttributesString($attrs); $attrStr = "value='" . implode(',', $this->value) . "' $attrStr"; - $out .= "\n"; + $out .= ""; return $out; } diff --git a/wire/modules/Inputfield/InputfieldPageName/InputfieldPageName.module b/wire/modules/Inputfield/InputfieldPageName/InputfieldPageName.module index 95967e46..7d87e954 100644 --- a/wire/modules/Inputfield/InputfieldPageName/InputfieldPageName.module +++ b/wire/modules/Inputfield/InputfieldPageName/InputfieldPageName.module @@ -13,6 +13,7 @@ * @property string $checkboxName Leave blank to disable * @property string $checkboxLabel * @property string $checkboxValue + * @property string $checkboxSuffix * @property bool $checkboxChecked * */ @@ -286,7 +287,6 @@ class InputfieldPageName extends InputfieldName implements ConfigurableModule { if(is_array($data[$name])) { // data already in right save format, but need it to be a string for editing - if(empty($replacements)) $replacements = self::$defaultReplacements; $replacements = self::replacementArrayToString($data[$name]); } else { diff --git a/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTable.module b/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTable.module index fbd60083..f88a8d60 100644 --- a/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTable.module +++ b/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTable.module @@ -378,6 +378,7 @@ class InputfieldPageTable extends Inputfield { if(isset($fields[$column])) { // custom + /** @var Field $field */ $field = $fields[$column]; $v = $item->getFormatted($fieldName); if($field->type instanceof FieldtypeImage) { diff --git a/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTableAjax.php b/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTableAjax.php index 016c8310..5433ddfd 100644 --- a/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTableAjax.php +++ b/wire/modules/Inputfield/InputfieldPageTable/InputfieldPageTableAjax.php @@ -9,6 +9,8 @@ * * ProcessWire 3.x, Copyright 2016 by Ryan Cramer * https://processwire.com + * + * @method void checkAjax() * */ @@ -123,7 +125,7 @@ class InputfieldPageTableAjax extends Wire { protected function sortItems(Page $page, Field $field, $sort) { // if this field has it's own sort settings, then we have nothing to do here. - if($field->sortfields && $field->sortfields != 'sort') return; + if($field->get('sortfields') && $field->get('sortfields') != 'sort') return; $value = $page->getUnformatted($field->name); if(!$value instanceof PageArray || !$value->count()) return; diff --git a/wire/modules/Inputfield/InputfieldRadios/InputfieldRadios.module b/wire/modules/Inputfield/InputfieldRadios/InputfieldRadios.module index b2079057..1f9cc439 100644 --- a/wire/modules/Inputfield/InputfieldRadios/InputfieldRadios.module +++ b/wire/modules/Inputfield/InputfieldRadios/InputfieldRadios.module @@ -44,10 +44,10 @@ class InputfieldRadios extends InputfieldSelect { // don't bother setting a width, we will let them float where they want instead $ulClass = 'InputfieldRadiosFloated'; } - $out = "\n\t
      "; + $out = "
        "; } else { - $out = "\n\t
          "; + $out = "
            "; } foreach($options as $key => $value) { @@ -69,7 +69,7 @@ class InputfieldRadios extends InputfieldSelect { $label = "$label"; $out .= - "\n\t\t" . + "" . ""; } - $out .= "\n\t
          "; + $out .= "
        "; return $out; } @@ -95,6 +95,7 @@ class InputfieldRadios extends InputfieldSelect { public function ___getConfigInputfields() { $inputfields = parent::___getConfigInputfields(); + /** @var InputfieldInteger $f */ $f = $this->wire('modules')->get('InputfieldInteger'); $f->label = $this->_('Columns of Radio Buttons'); $f->description = $this->_('If you want the radio buttons to display in columns (rather than stacked), enter the number of columns you want to use (up to 10). To display buttons side-by-side (inline) enter 1.'); diff --git a/wire/modules/Inputfield/InputfieldSelect.module b/wire/modules/Inputfield/InputfieldSelect.module index 26c10061..5cf44d1f 100644 --- a/wire/modules/Inputfield/InputfieldSelect.module +++ b/wire/modules/Inputfield/InputfieldSelect.module @@ -8,7 +8,7 @@ * Sublcasses will want to override the render method, but it's not necessary to override processInput(). * Subclasses that select multiple values should implement the InputfieldHasArrayValue interface. * - * @todo add support for 'required' attribute? + * @property string|int $defaultValue * */ class InputfieldSelect extends Inputfield { @@ -51,7 +51,8 @@ class InputfieldSelect extends Inputfield { * * @param string $value Value that the option submits * @param string $label|array Optional label associated with the value (if null, value will be used as the label) - * @param array $attributes Optional attributes to be associated with this option (i.e. a 'selected' attribute for an "; + if($allowBlank && !$this->required && !$this->attr('multiple') && !$hasBlankOption) { + $out .= ""; + } foreach($options as $value => $label) { if(is_array($label)) { - $out .= "\n\t" . + $out .= + "" . $this->renderOptions($label, false) . - "\n\t"; + ""; continue; } $selected = $this->isOptionSelected($value) ? " selected='selected'" : ''; $attrs = $this->getOptionAttributesString($value); - $out .= "\n\t" . $this->entityEncode($label) . ""; + $out .= + "" . + $this->entityEncode($label) . + ""; } return $out; @@ -262,6 +291,7 @@ class InputfieldSelect extends Inputfield { // when a value is required and the value is empty and a default value is specified, we use it. if($this instanceof InputfieldHasArrayValue) { + /** @var InputfieldSelect $this */ $value = explode("\n", $this->defaultValue); foreach($value as $k => $v) { $value[$k] = trim($v); // remove possible extra LF @@ -277,6 +307,8 @@ class InputfieldSelect extends Inputfield { /** * Render and return the output for this Select + * + * @return string * */ public function ___render() { @@ -285,13 +317,19 @@ class InputfieldSelect extends Inputfield { unset($attrs['value']); $out = - "\ngetAttributesString($attrs) . ">" . $this->renderOptions($this->options) . - "\n"; + ""; return $out; } + /** + * Render non-editable value + * + * @return string + * + */ public function ___renderValue() { $out = ''; @@ -315,7 +353,7 @@ class InputfieldSelect extends Inputfield { } } - if(strlen($out)) $out = "
          $out
        "; + if(strlen($out)) $out = "
          $out
        "; return $out; } @@ -335,8 +373,8 @@ class InputfieldSelect extends Inputfield { /** * Get an attributes string intended for the