diff --git a/wire/core/Config.php b/wire/core/Config.php index 8f2d2ce8..d4c2945a 100644 --- a/wire/core/Config.php +++ b/wire/core/Config.php @@ -95,6 +95,7 @@ * @property array $adminThumbOptions Admin thumbnail image options #pw-group-images * @property array $httpHosts HTTP hosts For added security, specify the host names ProcessWire should recognize. #pw-group-HTTP-and-input * @property int $maxPageNum Maximum number of recognized paginations #pw-group-URLs + * @property bool $noHTTPS When boolean true, pages requiring HTTPS will not enforce it (useful for dev environments). * * @property string $dbHost Database host #pw-group-database * @property string $dbName Database name #pw-group-database @@ -402,5 +403,22 @@ class Config extends WireData { return $this; } + + /** + * Return true if current PHP version is equal to or newer than the given version + * + * ~~~~~ + * if($config->phpVersion('7.0.0')) { + * // PHP version is 7.x + * } + * ~~~~~ + * + * @param string|null $minVersion + * @return bool + * + */ + public function phpVersion($minVersion) { + return version_compare(PHP_VERSION, $minVersion) >= 0; + } } diff --git a/wire/core/Page.php b/wire/core/Page.php index 94d37663..c59e2102 100644 --- a/wire/core/Page.php +++ b/wire/core/Page.php @@ -2834,15 +2834,23 @@ class Page extends WireData implements \Countable, WireMatchable { * */ public function httpUrl($options = array()) { - if(!$this->template) return ''; - switch($this->template->https) { + $template = $this->template; + if(!$template) return ''; + /** @var Config $config */ + $config = $this->wire('config'); + $mode = $template->https; + if($mode > 0 && $config->noHTTPS) $mode = 0; + switch($mode) { case -1: $protocol = 'http'; break; case 1: $protocol = 'https'; break; - default: $protocol = $this->wire('config')->https ? 'https' : 'http'; + default: $protocol = $config->https ? 'https' : 'http'; } - if(is_array($options)) unset($options['http']); - else if(is_bool($options)) $options = array(); - return "$protocol://" . $this->wire('config')->httpHost . $this->url($options); + if(is_array($options)) { + unset($options['http']); + } else if(is_bool($options)) { + $options = array(); + } + return "$protocol://" . $config->httpHost . $this->url($options); } /** @@ -2866,13 +2874,16 @@ class Page extends WireData implements \Countable, WireMatchable { * */ public function editUrl($options = array()) { + /** @var Config $config */ + $config = $this->wire('config'); + /** @var Template $adminTemplate */ $adminTemplate = $this->wire('templates')->get('admin'); - $https = $adminTemplate && ($adminTemplate->https > 0); - $url = ($https && !$this->wire('config')->https) ? 'https://' . $this->wire('config')->httpHost : ''; - $url .= $this->wire('config')->urls->admin . "page/edit/?id=$this->id"; + $https = $adminTemplate && ($adminTemplate->https > 0) && !$config->noHTTPS; + $url = ($https && !$config->https) ? 'https://' . $config->httpHost : ''; + $url .= $config->urls->admin . "page/edit/?id=$this->id"; if($options === true || (is_array($options) && !empty($options['http']))) { if(strpos($url, '://') === false) { - $url = ($https ? 'https://' : 'http://') . $this->wire('config')->httpHost . $url; + $url = ($https ? 'https://' : 'http://') . $config->httpHost . $url; } } $append = $this->wire('session')->getFor($this, 'appendEditUrl'); @@ -3356,9 +3367,14 @@ class Page extends WireData implements \Countable, WireMatchable { if(is_null($status)) $status = $this->status; if($value === false) return $status; $names = array(); + $remainder = $status; foreach(self::$statuses as $name => $value) { - if($status & $value) $names[$value] = $name; + if($status & $value) { + $names[$value] = $name; + $remainder = $remainder & ~$value; + } } + if($remainder > 1) $names[$remainder] = "unknown-$remainder"; return $names; } diff --git a/wire/modules/Page/PageFrontEdit/PageFrontEdit.module b/wire/modules/Page/PageFrontEdit/PageFrontEdit.module index 31748d16..56c3702e 100644 --- a/wire/modules/Page/PageFrontEdit/PageFrontEdit.module +++ b/wire/modules/Page/PageFrontEdit/PageFrontEdit.module @@ -164,7 +164,7 @@ class PageFrontEdit extends WireData implements Module { if($config->ajax && $input->post('action') == 'PageFrontEditSave') { // skip, this is handled by another hook - } else if($this->wire('templates')->get('admin')->https == 1 && !$config->https && $page->template->https != -1) { + } else if($this->wire('templates')->get('admin')->https == 1 && !$config->https && !$config->noHTTPS && $page->template->https != -1) { // hooks allowed, but we need the same scheme as admin $url = $input->httpUrl(true); if(strpos($url, 'http://') === 0) { diff --git a/wire/modules/Process/ProcessPageView.module b/wire/modules/Process/ProcessPageView.module index e922e215..d15a4f73 100644 --- a/wire/modules/Process/ProcessPageView.module +++ b/wire/modules/Process/ProcessPageView.module @@ -677,11 +677,12 @@ class ProcessPageView extends Process { * */ protected function checkProtocol($page) { - - $requireHTTPS = $page->template->https; - if($requireHTTPS == 0) return; // neither HTTP or HTTPS required - + + /** @var Config $config */ $config = $this->wire('config'); + $requireHTTPS = $page->template->https; + if($requireHTTPS == 0 || $config->noHTTPS) return; // neither HTTP or HTTPS required + $isHTTPS = $config->https; $scheme = '';