1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 16:26:59 +02:00

Add a Template::editUrl() method

This commit is contained in:
Ryan Cramer
2020-12-31 15:54:06 -05:00
parent 1d990a604e
commit 880ed9511d
2 changed files with 24 additions and 10 deletions

View File

@@ -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,
),
);

View File

@@ -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.
*