diff --git a/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.module b/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.module index 39fcd77c..39791c51 100644 --- a/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.module +++ b/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.module @@ -5,7 +5,7 @@ * * Provides the link capability as used by the rich text editor. * - * ProcessWire 3.x, Copyright 2016 by Ryan Cramer + * ProcessWire 3.x, Copyright 2023 by Ryan Cramer * https://processwire.com * * @property string $relOptions @@ -29,7 +29,7 @@ class ProcessPageEditLink extends Process implements ConfigurableModule { 'permanent' => true, 'permission' => 'page-edit', 'icon' => 'link', - ); + ); } /** @@ -109,18 +109,22 @@ class ProcessPageEditLink extends Process implements ConfigurableModule { * */ public function init() { + $input = $this->wire()->input; + $pages = $this->wire()->pages; + $modules = $this->wire()->modules; + $sanitizer = $this->wire()->sanitizer; $this->startLabel = $this->_('Choose page'); - $this->modules->get("ProcessPageList"); - $id = (int) $this->input->get('id'); - $this->langID = (int) $this->input->get('lang'); - if($id) $this->page = $this->pages->get($id); - if($this->page && $this->page->id && !$this->user->hasPermission("page-view", $this->page)) { + $modules->get('ProcessPageList'); + $id = (int) $input->get('id'); + $this->langID = (int) $input->get('lang'); + if($id) $this->page = $pages->get($id); + if($this->page && $this->page->id && !$this->wire()->user->hasPermission("page-view", $this->page)) { throw new WireException("You don't have access to this page"); } - if(!$this->page) $this->page = $this->wire('pages')->newNullPage(); + if(!$this->page) $this->page = $pages->newNullPage(); - $this->config->js('ProcessPageEditLink', array( + $this->wire()->config->js('ProcessPageEditLink', array( 'selectStartLabel' => $this->startLabel, 'langID' => $this->langID, 'pageID' => $id, @@ -129,11 +133,11 @@ class ProcessPageEditLink extends Process implements ConfigurableModule { 'rootParentUrl' => $this->page->rootParent->url, 'slashUrls' => $this->page->template ? $this->page->template->slashUrls : 1, 'urlType' => $this->urlType, - 'extLinkRel' => $this->wire('sanitizer')->names($this->extLinkRel), + 'extLinkRel' => $sanitizer->names($this->extLinkRel), 'extLinkTarget' => $this->extLinkTarget, - 'extLinkClass' => $this->wire('sanitizer')->names($this->extLinkClass), + 'extLinkClass' => $sanitizer->names($this->extLinkClass), 'noLinkTextEdit' => (int) $this->noLinkTextEdit - )); + )); parent::init(); } @@ -145,9 +149,14 @@ class ProcessPageEditLink extends Process implements ConfigurableModule { * */ public function ___execute() { + + $sanitizer = $this->wire()->sanitizer; + $modules = $this->wire()->modules; + $config = $this->wire()->config; + $input = $this->wire()->input; - if($this->wire('input')->get('href')) { - $currentValue = $this->wire('sanitizer')->url($this->wire('input')->get('href'), array( + if($input->get('href')) { + $currentValue = $sanitizer->url($input->get('href'), array( 'stripQuotes' => false, 'allowIDN' => true, )); @@ -155,15 +164,15 @@ class ProcessPageEditLink extends Process implements ConfigurableModule { $currentValue = ''; } - $currentText = $this->wire()->input->get('text'); + $currentText = $input->get('text'); $currentText = $currentText === null ? '' : $this->wire()->sanitizer->text($currentText); /** @var InputfieldForm $form */ - $form = $this->modules->get("InputfieldForm"); + $form = $modules->get("InputfieldForm"); $form->attr('id', 'ProcessPageEditLinkForm'); //$form->description = $this->_("Enter a URL, select a page, or select a file to link:"); // Headline - $this->wire('modules')->get('JqueryWireTabs'); + $modules->get('JqueryWireTabs'); /** @var InputfieldWrapper $fieldset */ $fieldset = $this->wire(new InputfieldWrapper()); @@ -175,7 +184,7 @@ class ProcessPageEditLink extends Process implements ConfigurableModule { // link text editing disabled } else if($currentText) { /** @var InputfieldText $field */ - $field = $this->modules->get("InputfieldText"); + $field = $modules->get("InputfieldText"); $field->label = $this->_('Link text'); $field->icon = 'pencil-square'; $field->attr('id+name', 'link_text'); @@ -184,13 +193,13 @@ class ProcessPageEditLink extends Process implements ConfigurableModule { } /** @var InputfieldPageAutocomplete $field */ - $field = $this->modules->get("InputfieldPageAutocomplete"); + $field = $modules->get("InputfieldPageAutocomplete"); $field->label = $this->_('Link to URL'); $field->attr('id+name', 'link_page_url'); $field->icon = 'external-link-square'; $field->description = $this->_('Enter a URL, email address, anchor, or enter word(s) to find a page.'); $field->labelFieldName = 'url'; - if($this->wire('modules')->isInstalled('PagePaths') && !$this->wire('languages')) { + if($modules->isInstalled('PagePaths') && !$this->wire('languages')) { $field->searchFields = 'path title'; } else { $field->searchFields = 'name title'; @@ -202,22 +211,22 @@ class ProcessPageEditLink extends Process implements ConfigurableModule { $field->disableChars = '/:.#'; $field->useAndWords = true; $field->findPagesSelector = - "has_parent!=" . $this->wire('config')->adminRootPageID . ", " . - "id!=" . $this->wire('config')->http404PageID; + "has_parent!=" . $config->adminRootPageID . ", " . + "id!=" . $config->http404PageID; if($currentValue) $field->attr('value', $currentValue); $fieldset->add($field); - if(is_array($this->wire('input')->get('anchors'))) { + if(is_array($input->get('anchors'))) { $field->columnWidth = 60; /** @var InputfieldSelect $field */ - $field = $this->modules->get('InputfieldSelect'); + $field = $modules->get('InputfieldSelect'); $field->columnWidth = 40; $field->attr('id+name', 'link_page_anchor'); $field->label = $this->_('Select Anchor'); $field->description = $this->_('Anchors found in the text you are editing.'); $field->icon = 'flag'; - foreach($this->wire('input')->get('anchors') as $anchor) { - $anchor = '#' . $this->wire('sanitizer')->text($anchor); + foreach($input->get->array('anchors') as $anchor) { + $anchor = '#' . $sanitizer->text($anchor); if(strlen($anchor)) $field->addOption($anchor); if($currentValue && $currentValue == $anchor) $field->attr('value', $currentValue); } @@ -225,7 +234,7 @@ class ProcessPageEditLink extends Process implements ConfigurableModule { } /** @var InputfieldInteger $field */ - $field = $this->modules->get('InputfieldInteger'); + $field = $modules->get('InputfieldInteger'); $field->attr('id+name', 'link_page_id'); $field->label = $this->_("Select Page"); $field->set('startLabel', $this->startLabel); @@ -234,7 +243,8 @@ class ProcessPageEditLink extends Process implements ConfigurableModule { $fieldset->add($field); if($this->page->numChildren) { - $field = $this->modules->get('InputfieldInteger'); + /** @var InputfieldInteger $field */ + $field = $modules->get('InputfieldInteger'); $field->attr('id+name', 'child_page_id'); $field->label = $this->_("Select Child Page"); $field->description = $this->_('This is the same as "Select Page" above, but may quicker to use if linking to children of the current page.'); @@ -245,25 +255,27 @@ class ProcessPageEditLink extends Process implements ConfigurableModule { } $fieldset->append($this->getFilesField()); - + + /** @var InputfieldWrapper $fieldset */ $fieldset = $this->wire(new InputfieldWrapper()); $fieldset->attr('title', $this->_('Attributes')); $fieldset->attr('id', 'link_attributes'); $fieldset->addClass('WireTab'); $form->append($fieldset); - - $field = $this->modules->get('InputfieldText'); + + /** @var InputfieldText $field */ + $field = $modules->get('InputfieldText'); $field->attr('id+name', 'link_title'); $field->label = $this->_('Title'); $field->description = $this->_('Additional text to describe link.'); - if($this->wire('input')->get('title')) { - $field->attr('value', $this->wire('sanitizer')->text($this->wire('input')->get('title'))); + if($input->get('title')) { + $field->attr('value', $sanitizer->text($input->get('title'))); } $fieldset->add($field); if($this->targetOptions) { /** @var InputfieldSelect $field */ - $field = $this->modules->get('InputfieldSelect'); + $field = $modules->get('InputfieldSelect'); $field->attr('id+name', 'link_target'); $field->label = $this->_('Target'); $field->description = $this->_('Where this link will open.'); @@ -273,7 +285,8 @@ class ProcessPageEditLink extends Process implements ConfigurableModule { } if($this->relOptions) { - $field = $this->modules->get('InputfieldSelect'); + /** @var InputfieldSelect $field */ + $field = $modules->get('InputfieldSelect'); $field->attr('id+name', 'link_rel'); $field->label = $this->_('Rel'); $field->description = $this->_('Relationship of link to document.'); @@ -284,7 +297,7 @@ class ProcessPageEditLink extends Process implements ConfigurableModule { if($this->classOptions) { /** @var InputfieldCheckboxes $field */ - $field = $this->modules->get('InputfieldCheckboxes'); + $field = $modules->get('InputfieldCheckboxes'); $field->attr('id+name', 'link_class'); $field->label = $this->_('Class'); $field->description = $this->_('Additional classes that can affect the look or behavior of the link.'); @@ -293,10 +306,10 @@ class ProcessPageEditLink extends Process implements ConfigurableModule { $fieldset->add($field); } - if($this->wire('user')->isSuperuser()) $fieldset->notes = + if($this->wire()->user->isSuperuser()) $fieldset->notes = sprintf( $this->_('You may customize available attributes shown above in the %s module settings.'), - "[ProcessPageEditLink](" . $this->wire('config')->urls->admin . "module/edit?name=ProcessPageEditLink)" + "[ProcessPageEditLink](" . $config->urls->admin . "module/edit?name=ProcessPageEditLink)" ); return $form->render() . "