mirror of
https://github.com/processwire/processwire.git
synced 2025-08-07 23:38:29 +02:00
Various minor updates
This commit is contained in:
@@ -18,11 +18,11 @@ insert_final_newline = true
|
|||||||
|
|
||||||
[*.js]
|
[*.js]
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = false
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
|
||||||
|
|
||||||
[*.{css,less,scss}]
|
[*.{css,less,scss}]
|
||||||
indent_style = tab
|
indent_style = tab
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = false
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
@@ -368,7 +368,7 @@ abstract class Inputfield extends WireData implements Module {
|
|||||||
protected $defaultID = '';
|
protected $defaultID = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not this Inputfield is editable
|
* Whether this Inputfield is editable
|
||||||
*
|
*
|
||||||
* When false, its processInput method won't be called by InputfieldWrapper's processInput
|
* When false, its processInput method won't be called by InputfieldWrapper's processInput
|
||||||
*
|
*
|
||||||
@@ -415,6 +415,8 @@ abstract class Inputfield extends WireData implements Module {
|
|||||||
|
|
||||||
$value = $this instanceof InputfieldHasArrayValue ? array() : null;
|
$value = $this instanceof InputfieldHasArrayValue ? array() : null;
|
||||||
$this->setAttribute('value', $value);
|
$this->setAttribute('value', $value);
|
||||||
|
|
||||||
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -496,7 +498,7 @@ abstract class Inputfield extends WireData implements Module {
|
|||||||
*
|
*
|
||||||
* - This can also be accessed directly, i.e. `$value = $inputfield->property;`.
|
* - This can also be accessed directly, i.e. `$value = $inputfield->property;`.
|
||||||
*
|
*
|
||||||
* - For getting attribute values, this will work but it is preferable to use the `Inputfield::attr()` method.
|
* - For getting attribute values, this will work, but it is preferable to use the `Inputfield::attr()` method.
|
||||||
*
|
*
|
||||||
* - For getting non-attribute values that have potential name conflicts with attributes (or just as a
|
* - For getting non-attribute values that have potential name conflicts with attributes (or just as a
|
||||||
* reliable alternative), use the `Inputfield::getSetting()` method instead, which excludes the possibility
|
* reliable alternative), use the `Inputfield::getSetting()` method instead, which excludes the possibility
|
||||||
@@ -675,7 +677,7 @@ abstract class Inputfield extends WireData implements Module {
|
|||||||
/**
|
/**
|
||||||
* Set an attribute
|
* Set an attribute
|
||||||
*
|
*
|
||||||
* - For most public API use, you might consider using the the shorter `Inputfield::attr()` method instead.
|
* - For most public API use, you might consider using the shorter `Inputfield::attr()` method instead.
|
||||||
*
|
*
|
||||||
* - When setting the `class` attribute it is preferable to use the `Inputfield::addClass()` method.
|
* - When setting the `class` attribute it is preferable to use the `Inputfield::addClass()` method.
|
||||||
*
|
*
|
||||||
@@ -1464,9 +1466,9 @@ abstract class Inputfield extends WireData implements Module {
|
|||||||
public function ___getConfigInputfields() {
|
public function ___getConfigInputfields() {
|
||||||
|
|
||||||
$conditionsText = $this->_('Conditions are expressed with a "field=value" selector containing fields and values to match. Multiple conditions should be separated by a comma.');
|
$conditionsText = $this->_('Conditions are expressed with a "field=value" selector containing fields and values to match. Multiple conditions should be separated by a comma.');
|
||||||
$conditionsNote = $this->_('Read more about [how to use this](http://processwire.com/api/selectors/inputfield-dependencies/).');
|
$conditionsNote = $this->_('Read more about [how to use this](https://processwire.com/api/selectors/inputfield-dependencies/).');
|
||||||
|
|
||||||
/** @var InputfieldWrapper $fields */
|
/** @var InputfieldWrapper $inputfields */
|
||||||
$inputfields = $this->wire(new InputfieldWrapper());
|
$inputfields = $this->wire(new InputfieldWrapper());
|
||||||
|
|
||||||
$fieldset = $inputfields->InputfieldFieldset;
|
$fieldset = $inputfields->InputfieldFieldset;
|
||||||
@@ -1657,6 +1659,7 @@ abstract class Inputfield extends WireData implements Module {
|
|||||||
$inputfields = $this->getConfigInputfields();
|
$inputfields = $this->getConfigInputfields();
|
||||||
if(!$inputfields || !count($inputfields)) return $data;
|
if(!$inputfields || !count($inputfields)) return $data;
|
||||||
foreach($inputfields->getAll() as $inputfield) {
|
foreach($inputfields->getAll() as $inputfield) {
|
||||||
|
/** @var Inputfield $inputfield */
|
||||||
$value = $inputfield->isEmpty() ? '' : $inputfield->value;
|
$value = $inputfield->isEmpty() ? '' : $inputfield->value;
|
||||||
if(is_object($value)) $value = (string) $value;
|
if(is_object($value)) $value = (string) $value;
|
||||||
$data[$inputfield->name] = $value;
|
$data[$inputfield->name] = $value;
|
||||||
@@ -1703,7 +1706,7 @@ abstract class Inputfield extends WireData implements Module {
|
|||||||
*
|
*
|
||||||
* @param string $text Text of error message
|
* @param string $text Text of error message
|
||||||
* @param int $flags Optional flags
|
* @param int $flags Optional flags
|
||||||
* @return mixed
|
* @return $this
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function error($text, $flags = 0) {
|
public function error($text, $flags = 0) {
|
||||||
@@ -1876,7 +1879,7 @@ abstract class Inputfield extends WireData implements Module {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function editable($setEditable = null) {
|
public function editable($setEditable = null) {
|
||||||
if(!is_null($setEditable)) $this->editable = $setEditable ? true : false;
|
if(!is_null($setEditable)) $this->editable = (bool) $setEditable;
|
||||||
return $this->editable;
|
return $this->editable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,7 +25,7 @@ class CommentArray extends PaginatedArray implements WirePaginatable {
|
|||||||
/**
|
/**
|
||||||
* Field object associated with this CommentArray
|
* Field object associated with this CommentArray
|
||||||
*
|
*
|
||||||
* @var Field|null
|
* @var Field|CommentField|null
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected $field = null;
|
protected $field = null;
|
||||||
@@ -240,7 +240,6 @@ class CommentArray extends PaginatedArray implements WirePaginatable {
|
|||||||
public function isIdentical(WireArray $items, $strict = true) {
|
public function isIdentical(WireArray $items, $strict = true) {
|
||||||
$isIdentical = parent::isIdentical($items, $strict);
|
$isIdentical = parent::isIdentical($items, $strict);
|
||||||
if($isIdentical && $strict && $items instanceof CommentArray) {
|
if($isIdentical && $strict && $items instanceof CommentArray) {
|
||||||
/** @var CommentArray $items */
|
|
||||||
if(((string) $this->getPage()) != ((string) $items->getPage())) return false;
|
if(((string) $this->getPage()) != ((string) $items->getPage())) return false;
|
||||||
if(((string) $this->getField()) != ((string) $items->getField())) return false;
|
if(((string) $this->getField()) != ((string) $items->getField())) return false;
|
||||||
}
|
}
|
||||||
@@ -333,6 +332,7 @@ class CommentArray extends PaginatedArray implements WirePaginatable {
|
|||||||
$commentID = $comment instanceof Comment ? $comment->id : (int) $comment;
|
$commentID = $comment instanceof Comment ? $comment->id : (int) $comment;
|
||||||
$has = false;
|
$has = false;
|
||||||
foreach($this as $item) {
|
foreach($this as $item) {
|
||||||
|
/** @var Comment $item */
|
||||||
if($item->id !== $commentID) continue;
|
if($item->id !== $commentID) continue;
|
||||||
$has = true;
|
$has = true;
|
||||||
break;
|
break;
|
||||||
|
@@ -146,7 +146,7 @@ class CommentField extends Field {
|
|||||||
* @param Page $page
|
* @param Page $page
|
||||||
* @param Comment $comment
|
* @param Comment $comment
|
||||||
* @param array $properties Associative array of properties to update
|
* @param array $properties Associative array of properties to update
|
||||||
* @return mixed
|
* @return bool
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function updateComment(Page $page, Comment $comment, array $properties) {
|
public function updateComment(Page $page, Comment $comment, array $properties) {
|
||||||
|
@@ -160,14 +160,13 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
$editable = $page->editable();
|
$editable = $page->editable();
|
||||||
if(!is_array($value)) $value = array($value);
|
if(!is_array($value)) $value = array($value);
|
||||||
|
|
||||||
foreach($value as $sort => $item) {
|
foreach($value as $item) {
|
||||||
|
|
||||||
if(!is_array($item)) continue;
|
if(!is_array($item)) continue;
|
||||||
|
|
||||||
// don't load non-approved comments if the user can't edit them
|
// don't load non-approved comments if the user can't edit them
|
||||||
if(!$editable && $item['status'] < Comment::statusApproved) continue;
|
if(!$editable && $item['status'] < Comment::statusApproved) continue;
|
||||||
|
|
||||||
/** @var Comment $comment */
|
|
||||||
$comment = $this->makeComment($page, $field, $item);
|
$comment = $this->makeComment($page, $field, $item);
|
||||||
$commentArray->add($comment);
|
$commentArray->add($comment);
|
||||||
$comment->setIsLoaded(true);
|
$comment->setIsLoaded(true);
|
||||||
@@ -184,7 +183,7 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
*
|
*
|
||||||
* @param Page $page
|
* @param Page $page
|
||||||
* @param Field $field
|
* @param Field $field
|
||||||
* @param string|int|array|object $value
|
* @param string|int|array|object|CommentArray $value
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -192,11 +191,13 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
|
|
||||||
$sleepValue = array();
|
$sleepValue = array();
|
||||||
if(!$value instanceof CommentArray) return $sleepValue;
|
if(!$value instanceof CommentArray) return $sleepValue;
|
||||||
|
|
||||||
$schemaVersion = $field->get('schemaVersion');
|
$schemaVersion = $field->get('schemaVersion');
|
||||||
$sanitizer = $this->wire('sanitizer'); /** @var Sanitizer $sanitizer */
|
$sanitizer = $this->wire()->sanitizer;
|
||||||
$maxIdxLen = $this->wire('database')->getMaxIndexLength();
|
$maxIdxLen = $this->wire()->database->getMaxIndexLength();
|
||||||
|
|
||||||
foreach($value as $comment) {
|
foreach($value as $comment) {
|
||||||
|
/** @var Comment $comment */
|
||||||
|
|
||||||
if($comment->id) {
|
if($comment->id) {
|
||||||
$this->checkExistingComment($page, $field, $comment);
|
$this->checkExistingComment($page, $field, $comment);
|
||||||
@@ -626,6 +627,7 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
$itemsRemoved = $allItems->getItemsRemoved();
|
$itemsRemoved = $allItems->getItemsRemoved();
|
||||||
if(count($itemsRemoved)) {
|
if(count($itemsRemoved)) {
|
||||||
foreach($itemsRemoved as $item) {
|
foreach($itemsRemoved as $item) {
|
||||||
|
/** @var Comment $item */
|
||||||
if(!$item->id) continue;
|
if(!$item->id) continue;
|
||||||
$this->deleteComment($page, $field, $item, 'deleted from savePageField()');
|
$this->deleteComment($page, $field, $item, 'deleted from savePageField()');
|
||||||
}
|
}
|
||||||
@@ -634,6 +636,7 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
$maxSort = 0;
|
$maxSort = 0;
|
||||||
$items = $allItems->makeNew();
|
$items = $allItems->makeNew();
|
||||||
foreach($allItems as $item) {
|
foreach($allItems as $item) {
|
||||||
|
/** @var Comment $item */
|
||||||
if($item->isChanged() || !$item->id) $items->add($item);
|
if($item->isChanged() || !$item->id) $items->add($item);
|
||||||
if($item->sort > $maxSort) $maxSort = $item->sort;
|
if($item->sort > $maxSort) $maxSort = $item->sort;
|
||||||
}
|
}
|
||||||
@@ -645,7 +648,7 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
$keys = is_array($value) ? array_keys($value) : array('data');
|
$keys = is_array($value) ? array_keys($value) : array('data');
|
||||||
|
|
||||||
// cycle through the values, executing an update query for each
|
// cycle through the values, executing an update query for each
|
||||||
foreach($values as $commentKey => $value) {
|
foreach($values as $value) {
|
||||||
|
|
||||||
$binds = array();
|
$binds = array();
|
||||||
$sql = $value['id'] ? "UPDATE " : "INSERT INTO ";
|
$sql = $value['id'] ? "UPDATE " : "INSERT INTO ";
|
||||||
@@ -688,6 +691,7 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
// populate newly added comment ID to Comment object
|
// populate newly added comment ID to Comment object
|
||||||
$value['id'] = $database->lastInsertId();
|
$value['id'] = $database->lastInsertId();
|
||||||
foreach($allItems as $item) {
|
foreach($allItems as $item) {
|
||||||
|
/** @var Comment $item */
|
||||||
if(!$item->id && $item->code === $value['code']) {
|
if(!$item->id && $item->code === $value['code']) {
|
||||||
$item->id = $value['id'];
|
$item->id = $value['id'];
|
||||||
$this->commentAdded($page, $field, $item);
|
$this->commentAdded($page, $field, $item);
|
||||||
@@ -1569,7 +1573,7 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
* @param Field $field
|
* @param Field $field
|
||||||
* @param Comment $comment
|
* @param Comment $comment
|
||||||
* @param array $properties Associative array of properties to update
|
* @param array $properties Associative array of properties to update
|
||||||
* @return mixed
|
* @return bool
|
||||||
* @throws WireException
|
* @throws WireException
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -1734,7 +1738,7 @@ class FieldtypeComments extends FieldtypeMulti {
|
|||||||
// the $page->data() call used so load not triggered, only returns comments if already loaded
|
// the $page->data() call used so load not triggered, only returns comments if already loaded
|
||||||
$comments = $page->data($field->name);
|
$comments = $page->data($field->name);
|
||||||
// add to loaded CommentArray for page, but only if it is already loaded in memory
|
// add to loaded CommentArray for page, but only if it is already loaded in memory
|
||||||
if($comments && $comments instanceof CommentArray) $comments->add($comment);
|
if($comments instanceof CommentArray) $comments->add($comment);
|
||||||
$this->commentAdded($page, $field, $comment);
|
$this->commentAdded($page, $field, $comment);
|
||||||
if($approved) $this->triggerPageFieldSaved($page, $field);
|
if($approved) $this->triggerPageFieldSaved($page, $field);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -105,7 +105,7 @@ class SelectableOption extends WireData { // implements LanguagesValueInterface
|
|||||||
*/
|
*/
|
||||||
public function getProperty($property) {
|
public function getProperty($property) {
|
||||||
if($this->wire('languages')) {
|
if($this->wire('languages')) {
|
||||||
$language = $this->wire('user')->language;
|
$language = $this->wire()->user->language;
|
||||||
if($language->isDefault()) {
|
if($language->isDefault()) {
|
||||||
$value = parent::get($property);
|
$value = parent::get($property);
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user