1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-12 17:54:44 +02:00

Various minor updates

This commit is contained in:
Ryan Cramer
2020-09-10 09:34:37 -04:00
parent df16ad5ae4
commit 7d71eac1bc
5 changed files with 20 additions and 9 deletions

View File

@@ -119,7 +119,7 @@ function __($text, $textdomain = null, $context = '') {
// multiple translations accepted for text, with 1st being newest // multiple translations accepted for text, with 1st being newest
$textArray = $text; $textArray = $text;
$text = reset($textArray); $text = reset($textArray);
} else if($text === true) { } else if($text === true && $textdomain !== null) {
// setting (or getting) custom option // setting (or getting) custom option
list($option, $values) = array($textdomain, $context); list($option, $values) = array($textdomain, $context);
if($option === 'replacements' || $option === 'translations') { if($option === 'replacements' || $option === 'translations') {
@@ -135,8 +135,10 @@ function __($text, $textdomain = null, $context = '') {
return __(true, 'translations', $option); return __(true, 'translations', $option);
} else { } else {
// set and get other options // set and get other options
if($context !== '') $options[$option] = $values; if($option === 'encode') $option = 'entityEncode'; // supported alias
return isset($options[$option]) ? $options[$option] : null; $currentValue = isset($options[$option]) ? $options[$option] : null; // existing value is returned even when setting
if($values !== '' && $values !== $currentValue) $options[$option] = $values;
return $currentValue;
} }
} else if(is_object($text)) { } else if(is_object($text)) {
$text = (string) $text; $text = (string) $text;

View File

@@ -303,7 +303,7 @@ class WireShutdown extends Wire {
$codes = $http->getHttpCodes(); $codes = $http->getHttpCodes();
$code = (int) ($this->config ? $this->config->fatalErrorCode : 500); $code = (int) ($this->config ? $this->config->fatalErrorCode : 500);
if(!isset($codes[$code])) $code = 500; if(!isset($codes[$code])) $code = 500;
header("HTTP/1.1 $code " . $codes[$code]); $http->sendStatusHeader($code);
return $code; return $code;
} }

View File

@@ -126,7 +126,11 @@ class MarkupAdminDataTable extends ModuleJS {
/** /**
* Set the header row for the table * Set the header row for the table
* *
* @param array $a Array of header row labels (strings) * Given $a array may be either array of labels (strings) or any of the array items may
* be an array, in which case index 0 is the label and index 1 is a class attribute to use
* for the th element.
*
* @param array $a Array of header row labels
* @return $this * @return $this
* *
*/ */

View File

@@ -994,8 +994,10 @@ class PageFrontEdit extends WireData implements Module {
} }
} }
header("Content-type: application/json"); $http = new WireHttp();
header("HTTP/1.1 200 OK"); $this->wire($http);
$http->sendHeader("Content-type: application/json");
$http->sendStatusHeader(200);
echo json_encode($data); echo json_encode($data);
exit; exit;
} }

View File

@@ -939,7 +939,10 @@ class ProcessPageView extends Process {
*/ */
protected function header404() { protected function header404() {
static $n = 0; static $n = 0;
if(!$n) header("HTTP/1.1 404 Page Not Found"); if($n) return;
$http = new WireHttp();
$this->wire($http);
$http->sendStatusHeader(404);
$n++; $n++;
} }