diff --git a/wire/core/PagesExportImport.php b/wire/core/PagesExportImport.php index 6c5496d2..66342826 100644 --- a/wire/core/PagesExportImport.php +++ b/wire/core/PagesExportImport.php @@ -18,7 +18,7 @@ * * Note: all the "change" prefix options require update=true. * - * ProcessWire 3.x, Copyright 2017 by Ryan Cramer + * ProcessWire 3.x, Copyright 2024 by Ryan Cramer * https://processwire.com * */ @@ -35,9 +35,9 @@ class PagesExportImport extends Wire { */ public function getExportPath($subdir = '') { - /** @var WireFileTools $files */ - $files = $this->wire('files'); - $path = $this->wire('config')->paths->assets . 'backups/' . $this->className() . '/'; + $files = $this->wire()->files; + $config = $this->wire()->config; + $path = $config->paths->assets . 'backups/' . $this->className() . '/'; $readmeText = "When this file is present, files and directories in here are auto-deleted after a short period of time."; $readmeFile = $this->className() . '.txt'; @@ -75,8 +75,7 @@ class PagesExportImport extends Wire { */ public function cleanupFiles($maxAge = 3600) { - /** @var WireFileTools $files */ - $files = $this->wire('files'); + $files = $this->wire()->files; $path = $this->getExportPath(); $qty = 0; @@ -111,13 +110,12 @@ class PagesExportImport extends Wire { * * @param PageArray $items * @param array $options - * @return string|bool Path+filename to ZIP file or boolean false on failure + * @return string Path+filename to ZIP file * */ public function exportZIP(PageArray $items, array $options = array()) { - /** @var WireFileTools $files */ - $files = $this->wire('files'); + $files = $this->wire()->files; $options['exportTarget'] = 'zip'; $zipPath = $this->getExportPath(); @@ -173,7 +171,7 @@ class PagesExportImport extends Wire { $path = $tempDir->get(); $options['filesPath'] = $path; - $zipFileItems = $this->wire('files')->unzip($filename, $path); + $zipFileItems = $this->wire()->files->unzip($filename, $path); if(empty($zipFileItems)) return false; @@ -192,7 +190,7 @@ class PagesExportImport extends Wire { * * @param PageArray $items * @param array $options - * @return string|bool JSON string of pages or boolean false on error + * @return string JSON string of pages * */ public function exportJSON(PageArray $items, array $options = array()) { @@ -232,8 +230,9 @@ class PagesExportImport extends Wire { */ public function pagesToArray(PageArray $items, array $options = array()) { - /** @var Config $config */ - $config = $this->wire('config'); + $config = $this->wire()->config; + $modules = $this->wire()->modules; + $fields = $this->wire()->fields; $defaults = array( 'verbose' => false, @@ -247,7 +246,7 @@ class PagesExportImport extends Wire { 'type' => 'ProcessWire:PageArray', 'created' => date('Y-m-d H:i:s'), 'version' => $config->version, - 'user' => $this->wire('user')->name, + 'user' => $this->wire()->user->name, 'host' => $config->httpHost, 'pages' => array(), 'fields' => array(), @@ -260,7 +259,7 @@ class PagesExportImport extends Wire { ); if($items->getLimit()) { - $pageNum = $this->wire('input')->pageNum; + $pageNum = $this->wire()->input->pageNum; $a['pagination'] = array( 'start' => $items->getStart(), 'limit' => $items->getLimit(), @@ -273,8 +272,7 @@ class PagesExportImport extends Wire { unset($a['pagination']); } - /** @var Languages $languages */ - $languages = $this->wire('languages'); + $languages = $this->wire()->languages; if($languages) $languages->setDefault(); $templates = array(); @@ -293,9 +291,9 @@ class PagesExportImport extends Wire { } foreach($fieldNames as $fieldName) { if(isset($a['fields'][$fieldName])) continue; - $field = $this->wire('fields')->get($fieldName); + $field = $fields->get($fieldName); if(!$field || !$field->type) continue; - $moduleInfo = $this->wire('modules')->getModuleInfoVerbose($field->type); + $moduleInfo = $modules->getModuleInfoVerbose($field->type); if($options['verbose']) { $fieldData = $field->getExportData(); unset($fieldData['name']); @@ -363,8 +361,8 @@ class PagesExportImport extends Wire { $of = $page->of(); $page->of(false); - /** @var Languages $languages */ - $languages = $this->wire('languages'); + /** @var Languages|Language[] $languages */ + $languages = $this->wire()->languages; if($languages) $languages->setDefault(); $numFiles = 0; @@ -457,7 +455,7 @@ class PagesExportImport extends Wire { * * @param array $a * @param array $options - * @return PageArray|bool + * @return PageArray|int * @throws WireException * */ @@ -476,7 +474,7 @@ class PagesExportImport extends Wire { if(!empty($options['pageArray']) && $options['pageArray'] instanceof PageArray) { $pageArray = $options['pageArray']; } else { - $pageArray = $this->wire('pages')->newPageArray(); + $pageArray = $this->wire()->pages->newPageArray(); } $count = 0; @@ -494,7 +492,7 @@ class PagesExportImport extends Wire { foreach($a['pages'] as $item) { $page = $this->arrayToPage($item, $options); $id = $item['settings']['id']; - $this->wire('notices')->move($page, $pageArray, array('prefix' => "Page $id: ")); + $this->wire()->notices->move($page, $pageArray, array('prefix' => "Page $id: ")); if(!$options['count']) $pageArray->add($page); $count++; } @@ -680,8 +678,7 @@ class PagesExportImport extends Wire { */ protected function importGetPage(array &$a, array &$options, array &$errors) { - /** @var Pages $pages */ - $pages = $this->wire('pages'); + $pages = $this->wire()->pages; $path = $a['path']; /** @var Page|NullPage $page */ @@ -738,7 +735,7 @@ class PagesExportImport extends Wire { if(is_object($template)) { // ok } else { - $template = $this->wire('templates')->get($template); + $template = $this->wire()->templates->get($template); } if($template) { $options['template'] = $template; @@ -762,12 +759,12 @@ class PagesExportImport extends Wire { // determine parent static $previousPaths = array(); $usePrevious = true; - $pages = $this->wire('pages'); + $pages = $this->wire()->pages; $path = $a['path']; if($options['parent']) { // parent specified in options - if(is_object($options['parent']) && $options['parent'] instanceof Page) { + if($options['parent'] instanceof Page) { $parent = $options['parent']; } else if(ctype_digit("$options[parent]")) { $parent = $pages->get((int) $options['parent']); @@ -841,7 +838,7 @@ class PagesExportImport extends Wire { if(!$isNew) $options['changeTemplate'] = false; $template = $options['template']; $parent = $options['parent']; - $languages = $this->wire('languages'); + $languages = $this->wire()->languages; $langProperties = array(); // populate page base settings @@ -980,9 +977,9 @@ class PagesExportImport extends Wire { $page->trackChange("{$field->name}__"); } } - if(is_object($pageValue) && $pageValue instanceof Wire) { + if($pageValue instanceof Wire) { // movie notices from the pageValue to the page - $this->wire('notices')->move($pageValue, $page); + $this->wire()->notices->move($pageValue, $page); } } else { // test import on existing page, avoids actually setting value to the page @@ -1020,9 +1017,8 @@ class PagesExportImport extends Wire { // 'file3.gif' => [ ... see above ... ], // ]; - /** @var Pagefiles $pagefiles */ $pagefiles = $page->get($field->name); - if(!$pagefiles || !$pagefiles instanceof Pagefiles) { + if(!$pagefiles instanceof Pagefiles) { $page->warning("Unable to import files to field '$field->name' because it is not a files field"); return; } @@ -1033,7 +1029,7 @@ class PagesExportImport extends Wire { $variationsAdded = array(); $maxFiles = (int) $field->get('maxFiles'); - $languages = $this->wire('languages'); + $languages = $this->wire()->languages; $filesPath = $pagefiles->path(); /** @var null|WireHttp $http */ $http = null; @@ -1137,7 +1133,7 @@ class PagesExportImport extends Wire { if($sourceExists) { // copy variation from options[filesPath] - if($this->wire('files')->copy($sourceFile, $targetFile)) { + if($this->wire()->files->copy($sourceFile, $targetFile)) { $variationsAdded[] = $name; } else { $page->warning("Unable to copy file (image variation): $sourceFile"); @@ -1243,13 +1239,9 @@ class PagesExportImport extends Wire { $numExisting = 0; $numNew = 0; - /** @var Pages $pages */ - $pages = $this->wire('pages'); - /** @var Fields $fields */ - $fields = $this->wire('fields'); - /** @var Sanitizer $sanitizer */ - $sanitizer = $this->wire('sanitizer'); - /** @var PageFinder $pageFinder */ + $pages = $this->wire()->pages; + $fields = $this->wire()->fields; + $sanitizer = $this->wire()->sanitizer; $pageFinder = $this->wire(new PageFinder()); // Identify missing fields @@ -1300,7 +1292,7 @@ class PagesExportImport extends Wire { // determine which templates are missing, and which fields are missing from templates foreach($templateNames as $templateName => $fieldNames) { - $template = $this->wire('templates')->get($templateName); + $template = $this->wire()->templates->get($templateName); if($template) { // template exists $missingTemplateFields[$templateName] = array(); @@ -1316,7 +1308,7 @@ class PagesExportImport extends Wire { } // determine which parents are missing - foreach($parentPaths as $key => $path) { + foreach($parentPaths as /* $key => */ $path) { if(isset($pagePaths[$path])) { // this parent already exists or will be created during import } else { diff --git a/wire/modules/Process/ProcessPagesExportImport/ProcessPagesExportImport.module b/wire/modules/Process/ProcessPagesExportImport/ProcessPagesExportImport.module index f450adfd..1dd448b9 100644 --- a/wire/modules/Process/ProcessPagesExportImport/ProcessPagesExportImport.module +++ b/wire/modules/Process/ProcessPagesExportImport/ProcessPagesExportImport.module @@ -3,7 +3,7 @@ /** * ProcessWire Page Export and Import * - * ProcessWire 3.x, Copyright 2017 by Ryan Cramer + * ProcessWire 3.x, Copyright 2024 by Ryan Cramer * https://processwire.com * * Note: this module supports page-edit-export and page-edit-import permissions, but currently the module is @@ -49,8 +49,10 @@ class ProcessPagesExportImport extends Process { * */ public function ___execute() { + $user = $this->wire()->user; + $input = $this->wire()->input; - if(!$this->wire('user')->isSuperuser()) { + if(!$user->isSuperuser()) { throw new WirePermissionException($this->_('Export/import is currently only available to superuser')); } @@ -58,9 +60,7 @@ class ProcessPagesExportImport extends Process { $this->wire($this->exportImport); $this->exportImport->cleanupFiles(600); - $input = $this->wire('input'); - $user = $this->wire('user'); - $breadcrumbLabel = $this->wire('page')->title; + $breadcrumbLabel = $this->wire()->page->title; try { if($input->post('submit_export')) { @@ -77,19 +77,13 @@ class ProcessPagesExportImport extends Process { return $form->render(); } } else { - /* - $this->warning( - 'Please note this is a development version of pages export/import ' . - 'and not yet recommended for production use.' - ); - */ $form = $this->buildForm(); return $form->render(); } } catch(\Exception $e) { if(self::debug) throw $e; $this->error($e->getMessage()); - $this->wire('session')->redirect($this->wire('page')->url); + $this->wire()->session->location($this->wire()->page->url); } return ''; @@ -104,11 +98,9 @@ class ProcessPagesExportImport extends Process { */ protected function buildForm($tab = '') { - /** @var Modules $modules */ - $modules = $this->wire('modules'); + $modules = $this->wire()->modules; $modules->get('JqueryWireTabs'); - /** @var User $user */ - $user = $this->wire('user'); + $user = $this->wire()->user; /** @var InputfieldForm $form */ $form = $modules->get('InputfieldForm'); @@ -135,8 +127,7 @@ class ProcessPagesExportImport extends Process { */ protected function buildImportTab() { - /** @var Modules $modules */ - $modules = $this->wire('modules'); + $modules = $this->wire()->modules; /** @var InputfieldWrapper $tab */ $tab = $this->wire(new InputfieldWrapper()); @@ -185,8 +176,9 @@ class ProcessPagesExportImport extends Process { */ protected function processImport() { - /** @var WireInput $input */ - $input = $this->wire('input'); + $input = $this->wire()->input; + $files = $this->wire()->files; + $session = $this->wire()->session; /** @var InputfieldWrapper|InputfieldForm $importTab */ $importTab = $this->buildForm('import'); @@ -194,8 +186,7 @@ class ProcessPagesExportImport extends Process { $submitCommit = $input->post('submit_commit_import') ? true : false; $submitTest = $input->post('submit_test_import') ? true : false; $submitZIP = !empty($_FILES['import_zip']) && !empty($_FILES['import_zip']['name'][0]); - $fileField = null; - $filesPath = $this->wire('session')->getFor($this, 'filesPath'); + $filesPath = $session->getFor($this, 'filesPath'); $jsonFile = ''; $a = null; @@ -206,11 +197,11 @@ class ProcessPagesExportImport extends Process { $zipFile = $this->exportImport->getExportPath() . $fileField->value->first()->name; if(!$zipFile || !is_file($zipFile)) throw new WireException('No ZIP file found: ' . $zipFile); $unzipPath = $this->exportImport->getExportPath('import-zip'); - $zipFileItems = $this->wire('files')->unzip($zipFile, $unzipPath); - $this->wire('files')->unlink($zipFile); + $zipFileItems = $files->unzip($zipFile, $unzipPath); + $files->unlink($zipFile); if(empty($zipFileItems)) throw new WireException("No files found in ZIP"); $jsonFile = $unzipPath . "pages.json"; - $this->wire('session')->setFor($this, 'filesPath', $unzipPath); + $session->setFor($this, 'filesPath', $unzipPath); } else if(!empty($_POST['import_json'])) { // JSON import @@ -218,7 +209,7 @@ class ProcessPagesExportImport extends Process { $json = $importTab->getChildByName('import_json')->val(); if(empty($json)) throw new WireException($this->_('No import data found')); $a = json_decode($json, true); - $this->wire('session')->setFor($this, 'filesPath', ''); + $session->setFor($this, 'filesPath', ''); } else if($filesPath) { // ZIP import commit or test @@ -252,6 +243,7 @@ class ProcessPagesExportImport extends Process { if($submitCommit) { $form->description = sprintf($this->_n('Imported %d page', 'Imported %d pages', $qty), $qty); foreach($form->children() as $f) { + /** @var Inputfield $f */ if($f->name != 'import_items') $form->remove($f); } } else { @@ -293,8 +285,8 @@ class ProcessPagesExportImport extends Process { // ); set_time_limit(3600); - /** @var WireInput $input */ - $input = $this->wire('input'); + $input = $this->wire()->input; + $config = $this->wire()->config; $form->processInput($input->post); @@ -317,12 +309,12 @@ class ProcessPagesExportImport extends Process { 'changeName' => in_array('name', $fieldNames), 'changeStatus' => in_array('status', $fieldNames), 'changeSort' => in_array('sort', $fieldNames), - 'filesPath' => $this->wire('session')->getFor($this, 'filesPath'), - 'originalHost' => isset($a['host']) ? $a['host'] : $this->wire('config')->httpHost, - 'originalRootUrl' => isset($a['url']) ? $a['url'] : $this->wire('config')->urls->root, + 'filesPath' => $this->wire()->session->getFor($this, 'filesPath'), + 'originalHost' => isset($a['host']) ? $a['host'] : $config->httpHost, + 'originalRootUrl' => isset($a['url']) ? $a['url'] : $config->urls->root, ); - foreach($a['pages'] as $key => $item) { + foreach($a['pages'] as /* $key => */ $item) { $id = $item['settings']['id']; if($submitCommit && !$input->post("confirm$id")) continue; $page = $this->processImportItemToPage($item, $options); @@ -346,23 +338,12 @@ class ProcessPagesExportImport extends Process { */ protected function identifyMissingResources(array &$a) { - /** @var Sanitizer $sanitizer */ - $sanitizer = $this->wire('sanitizer'); - - /** @var Modules $modules*/ - $modules = $this->wire('modules'); - - /** @var Templates $templates */ - $templates = $this->wire('templates'); - - /** @var Fields $fields */ - $fields = $this->wire('fields'); - - /** @var Pages $pages */ - $pages = $this->wire('pages'); - - /** @var WireInput $input */ - $input = $this->wire('input'); + $sanitizer = $this->wire()->sanitizer; + $modules = $this->wire()->modules; + $templates = $this->wire()->templates; + $fields = $this->wire()->fields; + $pages = $this->wire()->pages; + $input = $this->wire()->input; $numFatalItems = 0; $missingItems = array(); @@ -386,7 +367,7 @@ class ProcessPagesExportImport extends Process { $templateName ) . ' ' . $this->_('Select a template to substitute when creating these pages.'); - foreach($this->wire('templates') as $t) { + foreach($templates as $t) { $f->addOption($t->name); } @@ -463,7 +444,7 @@ class ProcessPagesExportImport extends Process { $optionsRecommended = array(); $optionsOther = array(); - foreach($this->wire('fields') as $_field) { + foreach($fields as $_field) { /** @var Field $_field */ if($_field->type->className() == $fieldtypeClass && !$_field->hasFlag(Field::flagSystem)) { $optionsRecommended[$_field->name] = $_field->name; @@ -569,8 +550,7 @@ class ProcessPagesExportImport extends Process { */ protected function adjustImportData(&$a) { - /** @var WireInput $input */ - $input = $this->wire('input'); + $input = $this->wire()->input; $importParentID = (int) $input->post('import_parent'); $importParentType = $input->post('import_parent_type') === 'direct' ? 'direct' : 'below'; @@ -654,8 +634,10 @@ class ProcessPagesExportImport extends Process { */ protected function buildImportForm(InputfieldForm $tab, array &$a) { - $modules = $this->wire('modules'); - + $modules = $this->wire()->modules; + $input = $this->wire()->input; + + /** @var InputfieldForm $form */ $form = $modules->get('InputfieldForm'); $form->attr('id', 'import-form'); $form->description = $this->_('Import summary'); @@ -672,6 +654,7 @@ class ProcessPagesExportImport extends Process { /** @var InputfieldFieldset $importTab */ $importTab = $tab->getChildByName('tab_import'); foreach($importTab->children() as $f) { + /** @var Inputfield $f */ if($f->attr('name') == 'import_zip') { continue; } else if($f instanceof InputfieldSubmit) { @@ -715,7 +698,7 @@ class ProcessPagesExportImport extends Process { $f->icon = 'female'; $f->showIf = 'import_mode!=update'; $f->startLabel = $this->_('Choose parent'); - $checkedDirect = $this->wire('input')->post('import_parent_type') == 'direct' ? "checked='checked'" : ''; + $checkedDirect = $input->post('import_parent_type') == 'direct' ? "checked='checked'" : ''; $checkedBelow = $checkedDirect ? '' : "checked='checked'"; $f->appendMarkup = "

" . @@ -758,13 +741,14 @@ class ProcessPagesExportImport extends Process { $f->addOption('status', "status|" . $this->_('Page status') . "|System"); $f->addOption('sort', "sort|" . $this->_('Page sort index') . "|System"); $f->attr('value', $value); - if(!$this->wire('input')->post('submit_import')) $f->collapsed = Inputfield::collapsedYes; + if(!$input->post('submit_import')) $f->collapsed = Inputfield::collapsedYes; $form->add($f); - $submitTest = $this->wire('input')->post('submit_test_import') ? true : false; - $submitCommit = $this->wire('input')->post('submit_commit_import') ? true : false; + $submitTest = $input->post('submit_test_import') ? true : false; + $submitCommit = $input->post('submit_commit_import') ? true : false; if($submitCommit || $submitTest) { + /** @var InputfieldFieldset $fieldset */ $fieldset = $modules->get('InputfieldFieldset'); $fieldset->attr('name', 'import_items'); $fieldset->label = $this->_('Import pages'); @@ -781,6 +765,7 @@ class ProcessPagesExportImport extends Process { $form->add($f); if(($submitTest || $submitCommit) && empty($a['_noCommit'])) { + /** @var InputfieldSubmit $f */ $f = $modules->get('InputfieldSubmit'); $f->attr('name', 'submit_commit_import'); $f->val($this->_('Commit Import')); @@ -796,25 +781,27 @@ class ProcessPagesExportImport extends Process { * Build a summary InputfieldMarkup for a single item/Page * * @param array $item Import item array - * @param Page|NullPage $page Resulting Page object + * @param Page $page Resulting Page object * @param array $options Import options that were passed to PagesExportImport import() method * @return InputfieldMarkup * */ protected function buildImportItemSummary(array $item, Page $page, array $options) { - $sanitizer = $this->wire('sanitizer'); + $sanitizer = $this->wire()->sanitizer; + $languages = $this->wire()->languages; + $changes = $page->get('_importChanges'); $importType = $page->get('_importType'); - $languages = $this->wire('languages'); $numChanges = wireCount($changes); $originalID = (int) $item['settings']['id']; $out = ''; static $n = 0; $n++; - - $f = $this->wire('modules')->get('InputfieldMarkup'); + + /** @var InputfieldMarkup $f */ + $f = $this->wire()->modules->get('InputfieldMarkup'); $f->addClass('import-form-item'); $f->label = "$n. "; @@ -869,7 +856,7 @@ class ProcessPagesExportImport extends Process { foreach($notices as $notice) { $noticeText = $sanitizer->entities($notice->text); if($noticeType != 'messages') { - $icon = $noticeType == 'errors' ? 'warning' : 'warning'; + $icon = 'warning'; } else { $icon = 'check'; } @@ -885,8 +872,8 @@ class ProcessPagesExportImport extends Process { } else if($numChanges) { // Page (success) $attr = "type='radio' name='confirm$originalID' class='import-confirm'"; - $val = $this->wire('input')->post("confirm$originalID"); - if(($val == $originalID || $val === null) && $numChanges) { + $val = $this->wire()->input->post("confirm$originalID"); + if($val == $originalID || $val === null) { $checkedYes = "checked='checked'"; $checkedNo = ""; } else { @@ -916,14 +903,13 @@ class ProcessPagesExportImport extends Process { */ protected function buildExportTab() { - $modules = $this->wire('modules'); - + /** @var InputfieldWrapper $tab */ $tab = $this->wire(new InputfieldWrapper()); $tab->attr('id+name', 'tab_export'); $tab->attr('title', $this->_('Export')); $tab->addClass('WireTab'); - $f = $modules->get('InputfieldRadios'); + $f = $tab->InputfieldRadios; $f->attr('name', 'export_type'); $f->label = $this->_('What pages do you want to export?'); $f->icon = 'sitemap'; @@ -932,7 +918,7 @@ class ProcessPagesExportImport extends Process { $f->addOption('selector', $this->_('Pages matching search')); $tab->add($f); - $f = $modules->get('InputfieldPageListSelectMultiple'); + $f = $tab->InputfieldPageListSelectMultiple; $f->attr('name', 'pages_specific'); $f->label = $this->_('Select pages'); $f->description = $this->_('Select one or more pages to include in the export.'); @@ -940,7 +926,7 @@ class ProcessPagesExportImport extends Process { $f->showIf = 'export_type=specific'; $tab->add($f); - $f = $modules->get('InputfieldPageListSelect'); + $f = $tab->InputfieldPageListSelect; $f->attr('name', 'pages_parent'); $f->label = $this->_('Select parent page'); $f->description = $this->_('Select the parent of the pages you want to export. The children of this page will be exported.'); @@ -948,7 +934,7 @@ class ProcessPagesExportImport extends Process { $f->showIf = 'export_type=parent'; $tab->add($f); - $f = $modules->get('InputfieldCheckboxes'); + $f = $tab->InputfieldCheckboxes; $f->attr('name', 'options_parent'); $f->label = $this->_('Additional options'); $f->icon = 'sliders'; @@ -960,7 +946,7 @@ class ProcessPagesExportImport extends Process { $f->addOption('unpublished', $this->_('Include hidden and unpublished pages')); $tab->add($f); - $f = $modules->get('InputfieldSelector'); + $f = $tab->InputfieldSelector; $f->attr('name', 'pages_selector'); $f->label = $this->_('Build a search to match pages for export'); $f->description = $this->_('Add one or more fields to search and match pages for export.'); @@ -968,7 +954,7 @@ class ProcessPagesExportImport extends Process { $f->showIf = 'export_type=selector'; $tab->add($f); - $f = $modules->get('InputfieldCheckboxes'); + $f = $tab->InputfieldCheckboxes; $f->attr('name', 'export_fields'); $f->label = $this->_('Export fields'); $f->description = @@ -1003,8 +989,7 @@ class ProcessPagesExportImport extends Process { $tab->add($f); */ - /** @var InputfieldSubmit $f */ - $f = $modules->get('InputfieldSubmit'); + $f = $tab->InputfieldSubmit; $f->attr('name', 'submit_export'); $f->value = $this->_('Export Now'); $f->showIf = $showIf; @@ -1035,10 +1020,10 @@ class ProcessPagesExportImport extends Process { set_time_limit(3600); - /** @var Pages $pages */ - $pages = $this->wire('pages'); - /** @var WireInput $input */ - $input = $this->wire('input'); + $pages = $this->wire()->pages; + $input = $this->wire()->input; + $modules = $this->wire()->modules; + $files = $this->wire()->files; $form = $this->buildForm(); $form->processInput($input->post); @@ -1100,8 +1085,9 @@ class ProcessPagesExportImport extends Process { if($exportTo == 'json') { // json $json = $exporter->exportJSON($exportPages, $exportOptions); - $form = $this->wire('modules')->get('InputfieldForm'); - $f = $this->wire('modules')->get('InputfieldTextarea'); + /** @var InputfieldForm $form */ + $form = $modules->get('InputfieldForm'); + $f = $form->InputfieldTextarea; $f->attr('id+name', 'export_json'); $f->label = $this->_('Pages export data for copy/paste'); $f->description = sprintf( @@ -1119,11 +1105,11 @@ class ProcessPagesExportImport extends Process { // zip file download $zipFile = $exporter->exportZIP($exportPages, $exportOptions); if($zipFile) { - $this->wire('files')->send($zipFile, array( + $files->send($zipFile, array( 'forceDownload' => true, 'exit' => false )); - $this->wire('files')->unlink($zipFile); + $files->unlink($zipFile); exit; } else { throw new WireException('Export failed during ZIP file generation'); @@ -1143,7 +1129,7 @@ class ProcessPagesExportImport extends Process { $exporter = new PagesExportImport(); $this->wire($exporter); $fields = array(); - foreach($this->wire('fields') as $field) { + foreach($this->wire()->fields as $field) { if(!$field->type) continue; $info = $exporter->getFieldInfo($field); if($info['exportable']) $fields[$field->name] = $field; @@ -1169,4 +1155,3 @@ class ProcessPagesExportImport extends Process { } } -