1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-07 15:26:54 +02:00
This commit is contained in:
Ryan Cramer
2024-12-13 09:10:37 -05:00
parent 2361b90739
commit 68fa2b47f6

View File

@@ -115,7 +115,6 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$pages = $this->wire()->pages; $pages = $this->wire()->pages;
$input = $this->wire()->input; $input = $this->wire()->input;
/** @var ProcessPageList $pageList */ /** @var ProcessPageList $pageList */
$pageList = $modules->get('ProcessPageList'); $pageList = $modules->get('ProcessPageList');
$pageList->renderReady(); $pageList->renderReady();
@@ -123,21 +122,22 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$this->startLabel = $this->_('Choose page'); $this->startLabel = $this->_('Choose page');
$id = (int) $input->get('id'); $id = (int) $input->get('id');
$this->langID = (int) $input->get('lang'); $this->langID = (int) $input->get('lang');
if($id) $this->page = $pages->get($id); $page = $id > 0 ? $pages->get($id) : $pages->newNullPage();
// if($this->page && $this->page->id && !$this->wire()->user->hasPermission("page-view", $this->page)) {
if($this->page && $this->page->id && !$this->page->viewable()) { if($page->id && !$page->viewable(false)) {
throw new WireException($this->_('Page is not viewable')); $page = $pages->newNullPage();
} }
if(!$this->page) $this->page = $pages->newNullPage();
$this->page = $page;
$this->wire()->config->js('ProcessPageEditLink', array( $this->wire()->config->js('ProcessPageEditLink', array(
'selectStartLabel' => $this->startLabel, 'selectStartLabel' => $this->startLabel,
'langID' => $this->langID, 'langID' => $this->langID,
'pageID' => $id, 'pageID' => $id,
'pageUrl' => $this->page->url, 'pageUrl' => $page->id ? $page->url : '',
'pageName' => $this->page->name, 'pageName' => $page->id ? $page->name : '',
'rootParentUrl' => $this->page->rootParent->url, 'rootParentUrl' => $page->id ? $page->rootParent->url : '',
'slashUrls' => $this->page->template ? $this->page->template->slashUrls : 1, 'slashUrls' => $page->template ? $page->template->slashUrls : 1,
'urlType' => $this->urlType, 'urlType' => $this->urlType,
'extLinkRel' => $sanitizer->names($this->extLinkRel), 'extLinkRel' => $sanitizer->names($this->extLinkRel),
'extLinkTarget' => $this->extLinkTarget, 'extLinkTarget' => $this->extLinkTarget,
@@ -573,12 +573,14 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
$files = array(); $files = array();
if(!$page->id) return $files; if(!$page->id) return $files;
foreach($page->template->fieldgroup as $field) { foreach($page->template->fieldgroup as $field) {
/** @var Fieldtype $type */ if(!$page->viewable($field)) continue;
$type = $field->type; $type = $field->type; /** @var Fieldtype $type */
if($type instanceof FieldtypeFile) { if($type instanceof FieldtypeFile) {
$value = $page->get($field->name); $value = $page->get($field->name);
if($value) foreach($page->get($field->name) as $file) { if($value) {
$files[$file->url] = $prefix . $field->getLabel() . ': ' . $file->basename; foreach($page->get($field->name) as $file) {
$files[$file->url] = $prefix . $field->getLabel() . ': ' . $file->basename;
}
} }
} else if(wireInstanceOf($type, 'FieldtypeRepeater')) { } else if(wireInstanceOf($type, 'FieldtypeRepeater')) {
$value = $page->get($field->name); $value = $page->get($field->name);