From 880ed9511dc46e0783b836a5d5f3477763f27ee7 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 31 Dec 2020 15:54:06 -0500 Subject: [PATCH] Add a Template::editUrl() method --- wire/core/Modules.php | 4 ++-- wire/core/Template.php | 30 ++++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/wire/core/Modules.php b/wire/core/Modules.php index 2a9a0c34..313aa142 100644 --- a/wire/core/Modules.php +++ b/wire/core/Modules.php @@ -4808,7 +4808,7 @@ class Modules extends WireArray { if($moduleVersions[$id] != $moduleInfo['version']) { $fromVersion = $this->formatVersion($moduleVersions[$id]); $toVersion = $this->formatVersion($moduleInfo['version']); - $versionChanges[] = "$moduleName: $fromVersion => $toVersion"; + $versionChanges[] = "$fromVersion => $toVersion: $moduleName"; $this->modulesLastVersions[$id] = $moduleVersions[$id]; if(strpos($moduleName, 'Fieldtype') === 0) { // apply update now, to Fieldtype modules only (since they are loaded differently) @@ -4864,7 +4864,7 @@ class Modules extends WireArray { 'items' => $missModules, ), array( - 'label' => $this->_('Found %d module version changes (applied when module is loaded):'), + 'label' => $this->_('Found %d module version changes (applied when each module is loaded):'), 'items' => $versionChanges, ), ); diff --git a/wire/core/Template.php b/wire/core/Template.php index a2c7755e..2f342d6d 100644 --- a/wire/core/Template.php +++ b/wire/core/Template.php @@ -110,6 +110,7 @@ * @property string $pageLabelField CSV or space separated string of field names to be displayed by ProcessPageList (overrides those set with ProcessPageList config). #pw-group-other * @property int|bool $_importMode Internal use property set by template importer when importing #pw-internal * @property int|null $connectedFieldID ID of connected field or null or 0 if not applicable. #pw-internal + * @property string $editUrl URL to edit template, for administrator. #pw-internal * * Hookable methods * @@ -310,14 +311,15 @@ class Template extends WireData implements Saveable, Exportable { */ public function get($key) { - if($key == 'filename') return $this->filename(); - if($key == 'fields') $key = 'fieldgroup'; - if($key == 'fieldgroup') return $this->fieldgroup; - if($key == 'fieldgroupPrevious') return $this->fieldgroupPrevious; - if($key == 'roles') return $this->getRoles(); - if($key == 'cacheTime') $key = 'cache_time'; // for camel case consistency - if($key == 'icon') return $this->getIcon(); - if($key == 'urlSegments') return $this->urlSegments(); + if($key === 'filename') return $this->filename(); + if($key === 'fields') $key = 'fieldgroup'; + if($key === 'fieldgroup') return $this->fieldgroup; + if($key === 'fieldgroupPrevious') return $this->fieldgroupPrevious; + if($key === 'roles') return $this->getRoles(); + if($key === 'cacheTime') $key = 'cache_time'; // for camel case consistency + if($key === 'icon') return $this->getIcon(); + if($key === 'urlSegments') return $this->urlSegments(); + if($key === 'editUrl') return $this->editUrl(); return isset($this->settings[$key]) ? $this->settings[$key] : parent::get($key); } @@ -1452,6 +1454,18 @@ class Template extends WireData implements Saveable, Exportable { return $field; } + /** + * URL to edit template settings (for administrator) + * + * @param bool $http Full http/https URL? + * @return string + * @since 3.0.170 + * + */ + public function editUrl($http = false) { + return $this->wire()->config->urls($http ? 'httpAdmin' : 'admin') . "setup/template/edit?id=$this->id"; + } + /** * Ensures that isset() and empty() work for this classes properties. *