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
$textArray = $text;
$text = reset($textArray);
} else if($text === true) {
} else if($text === true && $textdomain !== null) {
// setting (or getting) custom option
list($option, $values) = array($textdomain, $context);
if($option === 'replacements' || $option === 'translations') {
@@ -135,8 +135,10 @@ function __($text, $textdomain = null, $context = '') {
return __(true, 'translations', $option);
} else {
// set and get other options
if($context !== '') $options[$option] = $values;
return isset($options[$option]) ? $options[$option] : null;
if($option === 'encode') $option = 'entityEncode'; // supported alias
$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)) {
$text = (string) $text;

View File

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

View File

@@ -126,7 +126,11 @@ class MarkupAdminDataTable extends ModuleJS {
/**
* 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
*
*/

View File

@@ -993,9 +993,11 @@ class PageFrontEdit extends WireData implements Module {
$data['error'] = "Failed CSRF check";
}
}
header("Content-type: application/json");
header("HTTP/1.1 200 OK");
$http = new WireHttp();
$this->wire($http);
$http->sendHeader("Content-type: application/json");
$http->sendStatusHeader(200);
echo json_encode($data);
exit;
}

View File

@@ -939,7 +939,10 @@ class ProcessPageView extends Process {
*/
protected function header404() {
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++;
}