1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-15 11:14:12 +02:00

A few minor adjustments

This commit is contained in:
Ryan Cramer
2019-06-19 09:30:53 -04:00
parent bccdc2ace4
commit 5f3e9af378
3 changed files with 24 additions and 19 deletions

View File

@@ -617,13 +617,14 @@ class Pageimage extends Pagefile {
* *
*/ */
public function size($width, $height, $options = array()) { public function size($width, $height, $options = array()) {
if(!is_array($options)) $options = $this->sizeOptionsToArray($options);
if($this->wire('hooks')->isHooked('Pageimage::size()')) { if($this->wire('hooks')->isHooked('Pageimage::size()')) {
$result = $this->__call('size', array($width, $height, $options)); $result = $this->__call('size', array($width, $height, $options));
} else { } else {
$result = $this->___size($width, $height, $options); $result = $this->___size($width, $height, $options);
} }
$options['_width'] = $width; $options['_width'] = $width;
$options['_height'] = $height; $options['_height'] = $height;
self::$lastSizeOptions = $options; self::$lastSizeOptions = $options;
@@ -648,23 +649,7 @@ class Pageimage extends Pagefile {
$this->error = ''; $this->error = '';
if($this->ext == 'svg') return $this; if($this->ext == 'svg') return $this;
if(!is_array($options)) $options = $this->sizeOptionsToArray($options);
if(!is_array($options)) {
if(is_string($options)) {
// optionally allow a string to be specified with crop direction, for shorter syntax
if(strpos($options, ',') !== false) $options = explode(',', $options); // 30,40
$options = array('cropping' => $options);
} else if(is_int($options)) {
// optionally allow an integer to be specified with quality, for shorter syntax
$options = array('quality' => $options);
} else if(is_bool($options)) {
// optionally allow a boolean to be specified with upscaling toggle on/off
$options = array('upscaling' => $options);
} else {
// unknown options type
$options = array();
}
}
// originally requested options // originally requested options
$requestOptions = $options; $requestOptions = $options;
@@ -899,6 +884,25 @@ class Pageimage extends Pagefile {
return $pageimage; return $pageimage;
} }
protected function sizeOptionsToArray($options) {
if(is_array($options)) return $options;
if(is_string($options)) {
// optionally allow a string to be specified with crop direction, for shorter syntax
if(strpos($options, ',') !== false) $options = explode(',', $options); // 30,40
$options = array('cropping' => $options);
} else if(is_int($options)) {
// optionally allow an integer to be specified with quality, for shorter syntax
$options = array('quality' => $options);
} else if(is_bool($options)) {
// optionally allow a boolean to be specified with upscaling toggle on/off
$options = array('upscaling' => $options);
} else {
// unknown options type
$options = array();
}
return $options;
}
/** /**
* Same as size() but with width/height assumed to be hidpi width/height * Same as size() but with width/height assumed to be hidpi width/height

View File

@@ -690,6 +690,7 @@ class ProcessPageLister extends Process implements ConfigurableModule {
protected function getSystemColumns() { protected function getSystemColumns() {
$systemColumns = array_keys($this->systemLabels); $systemColumns = array_keys($this->systemLabels);
$systemColumns = array_merge($systemColumns, array('id', 'name', 'path')); $systemColumns = array_merge($systemColumns, array('id', 'name', 'path'));
sort($systemColumns);
return $systemColumns; return $systemColumns;
} }

View File

@@ -808,7 +808,7 @@ class ProcessPageView extends Process {
if($pageNum > 1 && $page->template->allowPageNum) { if($pageNum > 1 && $page->template->allowPageNum) {
$prefix = $this->pageNumPrefix ? $this->pageNumPrefix : $this->wire('config')->pageNumUrlPrefix; $prefix = $this->pageNumPrefix ? $this->pageNumPrefix : $this->wire('config')->pageNumUrlPrefix;
if(!$prefix) $prefix = 'page'; if(!$prefix) $prefix = 'page';
$url .= "$prefix$pageNum"; $url = rtrim($url, '/') . "/$prefix$pageNum";
if($page->template->slashPageNum) { if($page->template->slashPageNum) {
// defined setting for trailing slash // defined setting for trailing slash
if($page->template->slashPageNum == 1) $url .= '/'; if($page->template->slashPageNum == 1) $url .= '/';