mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 00:06:55 +02:00
Minor adjustments to various classes
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
* This file is licensed under the MIT license
|
* This file is licensed under the MIT license
|
||||||
* https://processwire.com/about/license/mit/
|
* https://processwire.com/about/license/mit/
|
||||||
*
|
*
|
||||||
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
|
* ProcessWire 3.x, Copyright 2019 by Ryan Cramer
|
||||||
* https://processwire.com
|
* https://processwire.com
|
||||||
*
|
*
|
||||||
* @property ProcessWire $wire
|
* @property ProcessWire $wire
|
||||||
@@ -37,6 +37,9 @@
|
|||||||
* @property Config $config
|
* @property Config $config
|
||||||
* @property Fuel $fuel
|
* @property Fuel $fuel
|
||||||
* @property WireProfilerInterface $profiler
|
* @property WireProfilerInterface $profiler
|
||||||
|
* @property WireFileTools $files
|
||||||
|
* @property WireMailTools $mail
|
||||||
|
* @property WireDateTime $datetime
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Fuel implements \IteratorAggregate {
|
class Fuel implements \IteratorAggregate {
|
||||||
@@ -66,6 +69,17 @@ class Fuel implements \IteratorAggregate {
|
|||||||
protected $requiredInterfaces = array(
|
protected $requiredInterfaces = array(
|
||||||
'profiler' => 'WireProfilerInterface'
|
'profiler' => 'WireProfilerInterface'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The most common API variable names, those likely to be called multiple times in any request
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static protected $commonNames = array(
|
||||||
|
'page' => 1, 'pages' => 1, 'session' => 1, 'input' => 1, 'sanitizer' => 1, 'config' => 1,
|
||||||
|
'user' => 1, 'users' => 1, 'fields' => 1, 'templates' => 1, 'database' => 1, 'modules' => 1,
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $key API variable name to set - should be valid PHP variable name.
|
* @param string $key API variable name to set - should be valid PHP variable name.
|
||||||
@@ -110,6 +124,10 @@ class Fuel implements \IteratorAggregate {
|
|||||||
public function __get($key) {
|
public function __get($key) {
|
||||||
return isset($this->data[$key]) ? $this->data[$key] : null;
|
return isset($this->data[$key]) ? $this->data[$key] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get($key) {
|
||||||
|
return isset($this->data[$key]) ? $this->data[$key] : null;
|
||||||
|
}
|
||||||
|
|
||||||
public function getIterator() {
|
public function getIterator() {
|
||||||
return new \ArrayObject($this->data);
|
return new \ArrayObject($this->data);
|
||||||
@@ -119,4 +137,7 @@ class Fuel implements \IteratorAggregate {
|
|||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isCommon($name) {
|
||||||
|
return isset(self::$commonNames[$name]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -767,6 +767,19 @@ class PageFinder extends Wire {
|
|||||||
// allow any Fieldtype that is an instance of given one, or extends it
|
// allow any Fieldtype that is an instance of given one, or extends it
|
||||||
if(!wireInstanceOf($f->type, $fieldtype)
|
if(!wireInstanceOf($f->type, $fieldtype)
|
||||||
&& ($fieldtypeLang === null || !wireInstanceOf($f->type, $fieldtypeLang))) continue;
|
&& ($fieldtypeLang === null || !wireInstanceOf($f->type, $fieldtypeLang))) continue;
|
||||||
|
/** potential replacement for the above 2 lines
|
||||||
|
if($f->type->className() === $fieldName) {
|
||||||
|
// always allowed
|
||||||
|
} else if(!wireInstanceOf($f->type, $fieldtype) && ($fieldtypeLang === null || !wireInstanceOf($f->type, $fieldtypeLang))) {
|
||||||
|
// this field’s type does not extend the one we are looking for
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
// looks good, but now check operators
|
||||||
|
$selectorInfo = $f->type->getSelectorInfo($f);
|
||||||
|
// if operator used in selector is not an allowed one, then skip over this field
|
||||||
|
if(!in_array($selector->operator(), $selectorInfo['operators'])) continue;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// only allow given Fieldtype
|
// only allow given Fieldtype
|
||||||
@@ -1979,11 +1992,11 @@ class PageFinder extends Wire {
|
|||||||
throw new PageFinderSyntaxException("Operator '$selector->operator' is not supported for path or url unless: 1) non-multi-language; 2) you install the PagePaths module.");
|
throw new PageFinderSyntaxException("Operator '$selector->operator' is not supported for path or url unless: 1) non-multi-language; 2) you install the PagePaths module.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if($selector->value == '/') {
|
$selectorValue = $selector->value;
|
||||||
|
if($selectorValue === '/') {
|
||||||
$parts = array();
|
$parts = array();
|
||||||
$query->where("pages.id=1");
|
$query->where("pages.id=1");
|
||||||
} else {
|
} else {
|
||||||
$selectorValue = $selector->value;
|
|
||||||
if(is_array($selectorValue)) {
|
if(is_array($selectorValue)) {
|
||||||
// only the PagePaths module can perform OR value searches on path/url
|
// only the PagePaths module can perform OR value searches on path/url
|
||||||
if($langNames) {
|
if($langNames) {
|
||||||
@@ -1997,7 +2010,7 @@ class PageFinder extends Wire {
|
|||||||
$part = $database->escapeStr($this->wire('sanitizer')->pageName(array_pop($parts), Sanitizer::toAscii));
|
$part = $database->escapeStr($this->wire('sanitizer')->pageName(array_pop($parts), Sanitizer::toAscii));
|
||||||
$sql = "pages.name='$part'";
|
$sql = "pages.name='$part'";
|
||||||
if($langNames) foreach($langNames as $name) $sql .= " OR pages.$name='$part'";
|
if($langNames) foreach($langNames as $name) $sql .= " OR pages.$name='$part'";
|
||||||
$query->where($sql);
|
$query->where("($sql)");
|
||||||
if(!count($parts)) $query->where("pages.parent_id=1");
|
if(!count($parts)) $query->where("pages.parent_id=1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,6 +20,8 @@ require_once(__DIR__ . '/boot.php');
|
|||||||
* ProcessWire 3.x, Copyright 2019 by Ryan Cramer
|
* ProcessWire 3.x, Copyright 2019 by Ryan Cramer
|
||||||
* https://processwire.com
|
* https://processwire.com
|
||||||
*
|
*
|
||||||
|
* @property Fuel $fuel
|
||||||
|
*
|
||||||
* @method init()
|
* @method init()
|
||||||
* @method ready()
|
* @method ready()
|
||||||
* @method finished()
|
* @method finished()
|
||||||
@@ -734,8 +736,9 @@ class ProcessWire extends Wire {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function __get($key) {
|
public function __get($key) {
|
||||||
if($key == 'shutdown') return $this->shutdown;
|
if($key === 'fuel') return $this->fuel;
|
||||||
if($key == 'instanceID') return $this->instanceID;
|
if($key === 'shutdown') return $this->shutdown;
|
||||||
|
if($key === 'instanceID') return $this->instanceID;
|
||||||
return parent::__get($key);
|
return parent::__get($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -502,6 +502,7 @@ class WireTextTools extends Wire {
|
|||||||
$tests = array();
|
$tests = array();
|
||||||
$punctuationChars = $this->getPunctuationChars();
|
$punctuationChars = $this->getPunctuationChars();
|
||||||
$endSentenceChars = $this->getPunctuationChars(true);
|
$endSentenceChars = $this->getPunctuationChars(true);
|
||||||
|
$endSentenceChars[] = ':';
|
||||||
|
|
||||||
if($options['keepFormatTags']) {
|
if($options['keepFormatTags']) {
|
||||||
$options['keepTags'] = array_merge($options['keepTags'], array(
|
$options['keepTags'] = array_merge($options['keepTags'], array(
|
||||||
|
Reference in New Issue
Block a user