mirror of
https://github.com/processwire/processwire.git
synced 2025-08-07 07:16:51 +02:00
Minor code updates in various classes
This commit is contained in:
@@ -95,6 +95,7 @@ class ImageSizer extends Wire {
|
||||
*
|
||||
*/
|
||||
public function __construct($filename = '', $options = array()) {
|
||||
parent::__construct();
|
||||
if(!empty($options)) $this->setOptions($options);
|
||||
if(!empty($filename)) $this->setFilename($filename);
|
||||
}
|
||||
@@ -114,7 +115,7 @@ class ImageSizer extends Wire {
|
||||
|
||||
self::$knownEngines = array();
|
||||
|
||||
$modules = $this->wire('modules');
|
||||
$modules = $this->wire()->modules;
|
||||
$engines = $modules->findByPrefix('ImageSizerEngine');
|
||||
$numEngines = count($engines);
|
||||
|
||||
@@ -228,7 +229,6 @@ class ImageSizer extends Wire {
|
||||
$e = $this->getEngine($engineName);
|
||||
if(!$e) continue;
|
||||
|
||||
/** @var ImageSizerEngine $e */
|
||||
$e->prepare($filename, $options, $inspectionResult);
|
||||
$supported = $e->supported();
|
||||
|
||||
@@ -430,7 +430,7 @@ class ImageSizer extends Wire {
|
||||
$engineClass = __NAMESPACE__ . "\\$engineName";
|
||||
$engine = $this->wire(new $engineClass());
|
||||
} else {
|
||||
$engine = $this->wire('modules')->get($engineName);
|
||||
$engine = $this->wire()->modules->get($engineName);
|
||||
}
|
||||
return $engine;
|
||||
}
|
||||
@@ -452,7 +452,7 @@ class ImageSizer extends Wire {
|
||||
return $this->engine;
|
||||
}
|
||||
|
||||
public function __get($key) { return $this->getEngine()->__get($key); }
|
||||
public function __get($name) { return $this->getEngine()->__get($name); }
|
||||
|
||||
/**
|
||||
* ImageInformation from Image Inspector in short form or full RawInfoData
|
||||
@@ -607,7 +607,7 @@ class ImageSizer extends Wire {
|
||||
$count = 0;
|
||||
while(!feof($fh) && $count < 2) {
|
||||
$chunk = fread($fh, 1024 * 100); //read 100kb at a time
|
||||
$count += preg_match_all('#\x00\x21\xF9\x04.{4}\x00[\x2C\x21]#s', $chunk, $matches);
|
||||
$count += preg_match_all('#\x00\x21\xF9\x04.{4}\x00[\x2C\x21]#s', $chunk);
|
||||
}
|
||||
fclose($fh);
|
||||
return $count > 1;
|
||||
@@ -618,7 +618,7 @@ class ImageSizer extends Wire {
|
||||
*
|
||||
* @param mixed $image Pageimage or filename
|
||||
*
|
||||
* @return mixed|null|bool
|
||||
* @return null|bool
|
||||
*
|
||||
*/
|
||||
static public function imageResetIPTC($image) {
|
||||
|
@@ -399,7 +399,7 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
||||
$this->inspectionResult = $inspectionResult;
|
||||
|
||||
// filling all options with global custom values from config.php
|
||||
$options = array_merge($this->wire('config')->imageSizerOptions, $options);
|
||||
$options = array_merge($this->wire()->config->imageSizerOptions, $options);
|
||||
$this->setOptions($options);
|
||||
$this->loadImageInfo($filename, false);
|
||||
}
|
||||
@@ -521,7 +521,7 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
||||
if(is_callable("$className::getModuleInfo")) {
|
||||
$moduleInfo = $className::getModuleInfo();
|
||||
} else {
|
||||
$moduleInfo = $this->wire('modules')->getModuleInfoVerbose($className);
|
||||
$moduleInfo = $this->wire()->modules->getModuleInfoVerbose($className);
|
||||
}
|
||||
|
||||
if(!is_array($moduleInfo)) $moduleInfo = array();
|
||||
@@ -635,7 +635,7 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
||||
*
|
||||
*/
|
||||
public function writeBackIPTC($filename, $includeCustomTags = false) {
|
||||
if($this->wire('config')->debug) {
|
||||
if($this->wire()->config->debug) {
|
||||
// add a timestamp and the name of the image sizer engine to the IPTC tag number 217
|
||||
$entry = $this->className() . '-' . date('Ymd:His');
|
||||
if(!$this->iptcRaw) $this->iptcRaw = array();
|
||||
@@ -648,9 +648,10 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
||||
$dest = preg_replace('/\.' . $extension . '$/', '_tmp.' . $extension, $filename);
|
||||
if(strlen($content) == @file_put_contents($dest, $content, \LOCK_EX)) {
|
||||
// on success we replace the file
|
||||
$this->wire('files')->unlink($filename);
|
||||
$this->wire('files')->rename($dest, $filename);
|
||||
$this->wire('files')->chmod($filename);
|
||||
$files = $this->wire()->files;
|
||||
$files->unlink($filename);
|
||||
$files->rename($dest, $filename);
|
||||
$files->chmod($filename);
|
||||
return true;
|
||||
} else {
|
||||
// it was created a temp diskfile but not with all data in it
|
||||
@@ -1460,7 +1461,7 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
||||
/**
|
||||
* Return the image type constant
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*
|
||||
*/
|
||||
public function getImageType() {
|
||||
@@ -1731,14 +1732,16 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
||||
return false; // fallback or failed
|
||||
}
|
||||
|
||||
$files = $this->wire()->files;
|
||||
|
||||
if($this->webpOnly) {
|
||||
$this->wire('files')->unlink($this->tmpFile);
|
||||
$files->unlink($this->tmpFile);
|
||||
} else {
|
||||
// all went well, copy back the temp file,
|
||||
if(!@copy($this->tmpFile, $this->filename)) return false; // fallback or failed
|
||||
$this->wire('files')->chmod($this->filename);
|
||||
$files->chmod($this->filename);
|
||||
// remove the temp file
|
||||
$this->wire('files')->unlink($this->tmpFile);
|
||||
$files->unlink($this->tmpFile);
|
||||
// post processing: IPTC, setModified and reload ImageInfo
|
||||
$this->writeBackIPTC($this->filename, false);
|
||||
}
|
||||
@@ -1758,6 +1761,7 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
||||
*/
|
||||
public function rotate($degrees, $dstFilename = '') {
|
||||
|
||||
$files = $this->wire()->files;
|
||||
$degrees = (int) $degrees;
|
||||
$srcFilename = $this->filename;
|
||||
|
||||
@@ -1767,7 +1771,7 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
||||
if($degrees < -360) $degrees = $degrees - 360;
|
||||
|
||||
if($degrees == 0 || $degrees == 360 || $degrees == -360) {
|
||||
if($dstFilename != $this->filename) wireCopy($this->filename, $dstFilename);
|
||||
if($dstFilename != $this->filename) $files->copy($this->filename, $dstFilename);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1787,13 +1791,13 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
||||
if($result) {
|
||||
// success
|
||||
if($tmpFilename != $dstFilename) {
|
||||
if(is_file($dstFilename)) $this->wire('files')->unlink($dstFilename);
|
||||
$this->wire('files')->rename($tmpFilename, $dstFilename);
|
||||
if(is_file($dstFilename)) $files->unlink($dstFilename);
|
||||
$files->rename($tmpFilename, $dstFilename);
|
||||
}
|
||||
$this->wire('files')->chmod($dstFilename);
|
||||
$files->chmod($dstFilename);
|
||||
} else {
|
||||
// fail
|
||||
if(is_file($tmpFilename)) $this->wire('files')->unlink($tmpFilename);
|
||||
if(is_file($tmpFilename)) $files->unlink($tmpFilename);
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -2076,7 +2080,7 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
||||
*/
|
||||
public function getModuleConfigInputfields(InputfieldWrapper $inputfields) {
|
||||
|
||||
$f = $this->wire('modules')->get('InputfieldInteger');
|
||||
$f = $inputfields->InputfieldInteger;
|
||||
$f->attr('name', 'enginePriority');
|
||||
$f->label = $this->_('Engine priority');
|
||||
$f->description = $this->_('This determines what order this engine is tried in relation to other ImageSizerEngine modules.');
|
||||
@@ -2086,7 +2090,7 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
||||
$f->icon = 'sort-numeric-asc';
|
||||
$inputfields->add($f);
|
||||
|
||||
$f = $this->wire('modules')->get('InputfieldRadios');
|
||||
$f = $inputfields->InputfieldRadios;
|
||||
$f->attr('name', 'sharpening');
|
||||
$f->label = $this->_('Sharpening');
|
||||
$f->addOption('none', $this->_('None'));
|
||||
@@ -2098,7 +2102,7 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable
|
||||
$f->icon = 'image';
|
||||
$inputfields->add($f);
|
||||
|
||||
$f = $this->wire('modules')->get('InputfieldInteger');
|
||||
$f = $inputfields->InputfieldInteger;
|
||||
$f->attr('name', 'quality');
|
||||
$f->label = $this->_('Quality');
|
||||
$f->description = $this->_('Default quality setting from 1 to 100 where 1 is lowest quality, and 100 is highest.');
|
||||
|
@@ -377,7 +377,7 @@ class ImageSizerEngineGD extends ImageSizerEngine {
|
||||
}
|
||||
|
||||
// write to file(s)
|
||||
if(file_exists($dstFilename)) $this->wire('files')->unlink($dstFilename);
|
||||
if(file_exists($dstFilename)) $this->wire()->files->unlink($dstFilename);
|
||||
|
||||
$result = null; // null=not yet known
|
||||
|
||||
@@ -457,7 +457,7 @@ class ImageSizerEngineGD extends ImageSizerEngine {
|
||||
if(!function_exists('imagewebp')) return false;
|
||||
$path_parts = pathinfo($filename);
|
||||
$webpFilename = $path_parts['dirname'] . '/' . $path_parts['filename'] . '.webp';
|
||||
if(file_exists($webpFilename)) $this->wire('files')->unlink($webpFilename);
|
||||
if(file_exists($webpFilename)) $this->wire()->files->unlink($webpFilename);
|
||||
return imagewebp($im, $webpFilename, $quality);
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
* Pagefile objects are contained by a `Pagefiles` object.
|
||||
* #pw-body
|
||||
*
|
||||
* ProcessWire 3.x, Copyright 2022 by Ryan Cramer
|
||||
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
|
||||
* https://processwire.com
|
||||
*
|
||||
* @property-read string $url URL to the file on the server.
|
||||
@@ -357,7 +357,7 @@ class Pagefile extends WireData implements WireArrayItem {
|
||||
$key = $type === 'created' ? '_createdUser' : '_modifiedUser';
|
||||
if(!$this->$key) {
|
||||
$id = (int) parent::get($type . '_users_id');
|
||||
$this->$key = $id ? $this->wire('users')->get($id) : new NullPage();
|
||||
$this->$key = ($id ? $this->wire()->users->get($id) : new NullPage());
|
||||
}
|
||||
return $this->$key;
|
||||
}
|
||||
@@ -577,7 +577,7 @@ class Pagefile extends WireData implements WireArrayItem {
|
||||
|
||||
if(is_null($language)) {
|
||||
// return description for current user language, or inherit from default if not available
|
||||
$user = $this->wire('user');
|
||||
$user = $this->wire()->user;
|
||||
$value = null;
|
||||
if($user->language && $user->language->id) {
|
||||
$value = parent::get("description{$user->language}");
|
||||
|
@@ -38,7 +38,7 @@
|
||||
* Typically a Pagefiles object will be associated with a specific field attached to a Page.
|
||||
* There may be multiple instances of Pagefiles attached to a given Page (depending on what fields are in it's fieldgroup).
|
||||
*
|
||||
* ProcessWire 3.x, Copyright 2018 by Ryan Cramer
|
||||
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
|
||||
* https://processwire.com
|
||||
*
|
||||
*
|
||||
@@ -304,13 +304,13 @@ class Pagefiles extends WireArray implements PageFieldValueInterface {
|
||||
/**
|
||||
* Get for direct access to properties
|
||||
*
|
||||
* @param int|string $property
|
||||
* @param int|string $name
|
||||
* @return bool|mixed|Page|Wire|WireData
|
||||
*
|
||||
*/
|
||||
public function __get($property) {
|
||||
if(in_array($property, array('page', 'field', 'url', 'path'))) return $this->get($property);
|
||||
return parent::__get($property);
|
||||
public function __get($name) {
|
||||
if(in_array($name, array('page', 'field', 'url', 'path'))) return $this->get($name);
|
||||
return parent::__get($name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -375,7 +375,9 @@ class Pagefiles extends WireArray implements PageFieldValueInterface {
|
||||
*/
|
||||
public function hookPageSave() {
|
||||
|
||||
if($this->page && $this->field && !$this->page->isChanged($this->field->name)) return $this;
|
||||
if($this->page && $this->field) {
|
||||
if(!$this->page->isChanged($this->field->name)) return $this;
|
||||
}
|
||||
|
||||
$this->page->filesManager()->uncache();
|
||||
|
||||
@@ -780,12 +782,13 @@ class Pagefiles extends WireArray implements PageFieldValueInterface {
|
||||
if(!is_bool($set)) {
|
||||
// temp status is not being set
|
||||
if(!$isTemp) return false; // if not a temp file, we can exit now
|
||||
if(!$checkDeletable) return $isTemp; // if not checking deletable, we can exit now
|
||||
if(!$checkDeletable) return true; // if not checking deletable, we can exit now
|
||||
}
|
||||
|
||||
$user = $this->wire('user');
|
||||
$user = $this->wire()->user;
|
||||
$session = $this->wire()->session;
|
||||
|
||||
$now = time();
|
||||
$session = $this->wire('session');
|
||||
$pageID = $this->page ? $this->page->id : 0;
|
||||
$fieldID = $this->field ? $this->field->id : 0;
|
||||
$sessionKey = "tempFiles_{$pageID}_{$fieldID}";
|
||||
@@ -806,8 +809,11 @@ class Pagefiles extends WireArray implements PageFieldValueInterface {
|
||||
unset($tempFiles[$pagefile->basename]);
|
||||
// remove file from session - note that this means a 'deletable' check can only be used once, for newly uploaded files
|
||||
// as it is assumed you will be removing the file as a result of this method call
|
||||
if(count($tempFiles)) $session->set($this, $sessionKey, $tempFiles);
|
||||
else $session->remove($this, $sessionKey);
|
||||
if(count($tempFiles)) {
|
||||
$session->set($this, $sessionKey, $tempFiles);
|
||||
} else {
|
||||
$session->remove($this, $sessionKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -867,7 +873,11 @@ class Pagefiles extends WireArray implements PageFieldValueInterface {
|
||||
}
|
||||
if(count($removed) && $this->page && $this->field) {
|
||||
$this->page->save($this->field->name, array('quiet' => true));
|
||||
$this->message("Removed '{$this->field->name}' temp file(s) for page {$this->page->path} - " . implode(', ', $removed), Notice::debug | Notice::log);
|
||||
$this->message(
|
||||
"Removed '{$this->field->name}' temp file(s) for page {$this->page->path} - " .
|
||||
implode(', ', $removed),
|
||||
Notice::debug | Notice::log
|
||||
);
|
||||
}
|
||||
return count($removed);
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* A WireData object that maintains its data in a database table rather than just in memory.
|
||||
* An example of usage is the `$page->meta()` method.
|
||||
*
|
||||
* ProcessWire 3.x, Copyright 2019
|
||||
* ProcessWire 3.x, Copyright 2023
|
||||
* https://processwire.com
|
||||
*
|
||||
*/
|
||||
@@ -215,7 +215,7 @@ class WireDataDB extends WireData implements \Countable {
|
||||
$sql =
|
||||
"INSERT INTO `$table` (source_id, name, data) VALUES(:source_id, :name, :data) " .
|
||||
"ON DUPLICATE KEY UPDATE source_id=VALUES(source_id), name=VALUES(name), data=VALUES(data)";
|
||||
$query = $this->wire('database')->prepare($sql);
|
||||
$query = $this->wire()->database->prepare($sql);
|
||||
$query->bindValue(':source_id', $this->sourceID(), \PDO::PARAM_INT);
|
||||
$query->bindValue(':name', $name);
|
||||
$query->bindValue(':data', $data);
|
||||
|
@@ -213,8 +213,7 @@ class WireShutdown extends Wire {
|
||||
*
|
||||
*/
|
||||
protected function getWireInput() {
|
||||
/** @var WireInput $input */
|
||||
$input = $this->wire('input');
|
||||
$input = $this->wire()->input;
|
||||
if($input) return $input;
|
||||
$input = $this->wire(new WireInput());
|
||||
return $input;
|
||||
@@ -228,8 +227,7 @@ class WireShutdown extends Wire {
|
||||
*/
|
||||
protected function getCurrentUrl() {
|
||||
|
||||
/** @var Page|null $page */
|
||||
$page = $this->wire('page');
|
||||
$page = $this->wire()->page;
|
||||
$input = $this->getWireInput();
|
||||
$http = isset($_SERVER['HTTP_HOST']) || isset($_SERVER['REQUEST_URI']);
|
||||
|
||||
@@ -552,9 +550,12 @@ class WireShutdown extends Wire {
|
||||
if($useHTML && $config->ajax) $useHTML = false;
|
||||
|
||||
// include IP address is user name if configured to do so
|
||||
if($config->logIP && $this->wire('session')) {
|
||||
$ip = $this->wire('session')->getIP();
|
||||
if(strlen($ip)) $name = "$name ($ip)";
|
||||
if($config->logIP) {
|
||||
$session = $this->wire()->session;
|
||||
if($session) {
|
||||
$ip = $session->getIP();
|
||||
if(strlen($ip)) $name = "$name ($ip)";
|
||||
}
|
||||
}
|
||||
|
||||
// save to errors.txt log file
|
||||
@@ -781,7 +782,7 @@ class WireShutdown extends Wire {
|
||||
public function shutdownExternal() {
|
||||
if(error_get_last()) return;
|
||||
/** @var ProcessPageView $process */
|
||||
$process = $this->wire('process');
|
||||
$process = $this->wire()->process;
|
||||
if($process == 'ProcessPageView') $process->finished();
|
||||
}
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@
|
||||
* /wire/core/Fieldtype.php
|
||||
* /wire/core/FieldtypeMulti.php
|
||||
*
|
||||
* ProcessWire 3.x, Copyright 2022 by Ryan Cramer
|
||||
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
|
||||
* https://processwire.com
|
||||
*
|
||||
* @property array $allowFieldtypes Allowed Fieldtype types for custom fields
|
||||
@@ -407,7 +407,7 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule, Fieldt
|
||||
$isChanged = $pagefile->isChanged();
|
||||
|
||||
if($isNew) {
|
||||
$pagefile->createdUser = $this->wire('user');
|
||||
$pagefile->createdUser = $this->wire()->user;
|
||||
if(!$pagefile->isTemp()) $pagefile->created = time();
|
||||
}
|
||||
|
||||
@@ -415,7 +415,7 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule, Fieldt
|
||||
$changes = array_flip($pagefile->getChanges());
|
||||
unset($changes['hash'], $changes['sort'], $changes['modified'], $changes['modified_users_id']);
|
||||
if($isNew || count($changes)) {
|
||||
$pagefile->modifiedUser = $this->wire('user');
|
||||
$pagefile->modifiedUser = $this->wire()->user;
|
||||
if(!$pagefile->isTemp()) $pagefile->modified = time();
|
||||
}
|
||||
}
|
||||
@@ -893,7 +893,7 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule, Fieldt
|
||||
} else if(ctype_digit("$value")) {
|
||||
$value = (int) $value;
|
||||
} else {
|
||||
$value = $this->wire('users')->get('name=' . $this->wire('sanitizer')->pageName($value))->id;
|
||||
$value = $this->wire()->users->get('name=' . $this->wire()->sanitizer->pageName($value))->id;
|
||||
if(!$value) {
|
||||
$operator = '=';
|
||||
$value = -1;
|
||||
@@ -959,8 +959,7 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule, Fieldt
|
||||
*/
|
||||
protected function getMatchQuerySubfield($query, &$subfield, &$operator, &$value) {
|
||||
|
||||
/** @var Sanitizer $sanitizer */
|
||||
$sanitizer = $this->wire('sanitizer');
|
||||
$sanitizer = $this->wire()->sanitizer;
|
||||
$selector = $query->selector;
|
||||
$property = '';
|
||||
|
||||
@@ -970,7 +969,7 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule, Fieldt
|
||||
while(count($parts) > 2) $property = array_pop($parts);
|
||||
}
|
||||
|
||||
$field = $this->wire('fields')->get($subfield);
|
||||
$field = $this->wire()->fields->get($subfield);
|
||||
$fileField = $query->field;
|
||||
|
||||
if($fileField && !$fileField->type instanceof FieldtypeFile) $fileField = null;
|
||||
@@ -986,7 +985,7 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule, Fieldt
|
||||
throw new PageFinderSyntaxException("Property '$property' not supported in field '" . $selector->field() . "'");
|
||||
} else if(!ctype_digit("$value") && $sanitizer->pagePathName($value) === $value) {
|
||||
// page path to ID
|
||||
$p = $this->wire('pages')->get($value);
|
||||
$p = $this->wire()->pages->get($value);
|
||||
if($p->id && $p->viewable(false)) $value = $p->id;
|
||||
}
|
||||
}
|
||||
@@ -1055,7 +1054,7 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule, Fieldt
|
||||
*/
|
||||
public function getDatabaseSchema(Field $field) {
|
||||
|
||||
$database = $this->wire('database');
|
||||
$database = $this->wire()->database;
|
||||
$schema = parent::getDatabaseSchema($field);
|
||||
$maxLen = $database->getMaxIndexLength();
|
||||
|
||||
@@ -1075,7 +1074,7 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule, Fieldt
|
||||
|
||||
if($field->id && !$field->prevFieldtype) {
|
||||
if($field->flags & Field::flagFieldgroupContext) {
|
||||
$field = $this->wire('fields')->get($field->name);
|
||||
$field = $this->wire()->fields->get($field->name);
|
||||
}
|
||||
$fileSchema1 = (int) $field->get('fileSchema');
|
||||
$fileSchema2 = $this->updateDatabaseSchema($field, $schema, $fileSchema1);
|
||||
@@ -1102,10 +1101,9 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule, Fieldt
|
||||
protected function updateDatabaseSchema(Field $field, array &$schema, $fileSchema) {
|
||||
|
||||
$contextField = $field;
|
||||
if($field->flags & Field::flagFieldgroupContext) $field = $this->wire('fields')->get($field->name);
|
||||
if($field->flags & Field::flagFieldgroupContext) $field = $this->wire()->fields->get($field->name);
|
||||
|
||||
/** @var WireDatabasePDO $database */
|
||||
$database = $this->wire('database');
|
||||
$database = $this->wire()->database;
|
||||
$table = $database->escapeTable($field->table);
|
||||
|
||||
$hasFilesize = $fileSchema & self::fileSchemaFilesize;
|
||||
@@ -1212,8 +1210,7 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule, Fieldt
|
||||
*/
|
||||
protected function addColumn(Field $field, $column, array &$schema) {
|
||||
|
||||
/** @var WireDatabasePDO $database */
|
||||
$database = $this->wire('database');
|
||||
$database = $this->wire()->database;
|
||||
|
||||
if($database->columnExists($field->table, $column)) return true;
|
||||
|
||||
@@ -1499,7 +1496,7 @@ class FieldtypeFile extends FieldtypeMulti implements ConfigurableModule, Fieldt
|
||||
public function saveFile(Page $page, Field $field, Pagefile $pagefile, array $columns = array()) {
|
||||
|
||||
$item = $this->sleepFile($page, $field, $pagefile);
|
||||
$database = $this->wire('database'); /** @var WireDatabasePDO $database */
|
||||
$database = $this->wire()->database;
|
||||
$table = $database->escapeTable($field->getTable());
|
||||
$sets = array();
|
||||
$binds = array(':pages_id' => $page->id);
|
||||
|
@@ -9,7 +9,7 @@
|
||||
* /wire/core/Fieldtype.php
|
||||
* /wire/core/FieldtypeMulti.php
|
||||
*
|
||||
* ProcessWire 3.x, Copyright 2020 by Ryan Cramer
|
||||
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
|
||||
* https://processwire.com
|
||||
*
|
||||
*
|
||||
@@ -99,7 +99,7 @@ class FieldtypeImage extends FieldtypeFile implements FieldtypeHasFiles, Fieldty
|
||||
|
||||
if(!$hasDimensions) {
|
||||
$numErrors = 0;
|
||||
if($this->wire('database')->tableExists($field->getTable())) {
|
||||
if($this->wire()->database->tableExists($field->getTable())) {
|
||||
$columns = array('width', 'height', 'ratio');
|
||||
foreach($columns as $column) {
|
||||
if(!$this->addColumn($field, $column, $schema)) $numErrors++;
|
||||
|
@@ -3,7 +3,7 @@
|
||||
/**
|
||||
* ProcessWire Selectable Option class, for FieldtypeOptions
|
||||
*
|
||||
* ProcessWire 3.x, Copyright 2022 by Ryan Cramer
|
||||
* ProcessWire 3.x, Copyright 2023 by Ryan Cramer
|
||||
* https://processwire.com
|
||||
*
|
||||
* @property int $id
|
||||
@@ -86,8 +86,9 @@ class SelectableOption extends WireData { // implements LanguagesValueInterface
|
||||
'sort' => $this->get('sort'),
|
||||
'data' => $this->get('data'),
|
||||
);
|
||||
if($this->wire('languages')) {
|
||||
foreach($this->wire('languages') as $language) {
|
||||
$languages = $this->wire()->languages;
|
||||
if($languages) {
|
||||
foreach($languages as $language) {
|
||||
if($language->isDefault()) continue;
|
||||
$values["title$language"] = $this->get("title$language");
|
||||
$values["value$language"] = $this->get("value$language");
|
||||
@@ -105,7 +106,7 @@ class SelectableOption extends WireData { // implements LanguagesValueInterface
|
||||
*
|
||||
*/
|
||||
public function getProperty($property) {
|
||||
if($this->wire('languages')) {
|
||||
if($this->wire()->languages) {
|
||||
$language = $this->wire()->user->language;
|
||||
if($language->isDefault()) {
|
||||
$value = parent::get($property);
|
||||
@@ -117,7 +118,7 @@ class SelectableOption extends WireData { // implements LanguagesValueInterface
|
||||
} else {
|
||||
$value = parent::get($property);
|
||||
}
|
||||
if($this->of) $value = $this->wire('sanitizer')->entities($value);
|
||||
if($this->of) $value = $this->wire()->sanitizer->entities($value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user