mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 08:17:12 +02:00
Minor updates in various classes
This commit is contained in:
@@ -451,8 +451,10 @@ class Debug {
|
|||||||
$arg = '"' . $arg . '"';
|
$arg = '"' . $arg . '"';
|
||||||
} else if(is_bool($arg)) {
|
} else if(is_bool($arg)) {
|
||||||
$arg = $arg ? 'true' : 'false';
|
$arg = $arg ? 'true' : 'false';
|
||||||
|
} else if($arg === null) {
|
||||||
|
$arg = 'null';
|
||||||
} else {
|
} else {
|
||||||
// leave as-is
|
// leave as-is (int, float, etc.)
|
||||||
}
|
}
|
||||||
$newArgs[] = $arg;
|
$newArgs[] = $arg;
|
||||||
}
|
}
|
||||||
|
@@ -1052,9 +1052,10 @@ class ModulesInfo extends ModulesClass {
|
|||||||
public function clearModuleInfoCache($showMessages = false) {
|
public function clearModuleInfoCache($showMessages = false) {
|
||||||
|
|
||||||
$sanitizer = $this->wire()->sanitizer;
|
$sanitizer = $this->wire()->sanitizer;
|
||||||
|
$config = $this->wire()->config;
|
||||||
|
|
||||||
$versionChanges = array();
|
$versionChanges = array();
|
||||||
$upgradeLinks = array();
|
$editLinks = array();
|
||||||
$newModules = array();
|
$newModules = array();
|
||||||
$moveModules = array();
|
$moveModules = array();
|
||||||
$missModules = array();
|
$missModules = array();
|
||||||
@@ -1102,7 +1103,7 @@ class ModulesInfo extends ModulesClass {
|
|||||||
// apply update now, to Fieldtype modules only (since they are loaded differently)
|
// apply update now, to Fieldtype modules only (since they are loaded differently)
|
||||||
$this->modules->getModule($moduleName);
|
$this->modules->getModule($moduleName);
|
||||||
} else {
|
} else {
|
||||||
$upgradeLinks[$moduleName] = "<a class='pw-modal' target='_blank' href='$editUrl'>" .
|
$editLinks[$moduleName] = "<a class='pw-modal' target='_blank' href='$editUrl'>" .
|
||||||
$sanitizer->entities1($this->_('Apply')) . "</a>";
|
$sanitizer->entities1($this->_('Apply')) . "</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1124,7 +1125,10 @@ class ModulesInfo extends ModulesClass {
|
|||||||
if(!$file) {
|
if(!$file) {
|
||||||
$file = $this->modules->getModuleFile($moduleName, array('fast' => true, 'guess' => true));
|
$file = $this->modules->getModuleFile($moduleName, array('fast' => true, 'guess' => true));
|
||||||
// add flagsNoFile if file cannot be located
|
// add flagsNoFile if file cannot be located
|
||||||
$missModules[] = "$moduleName => $file";
|
$missModules[$moduleName] = "$moduleName => $file";
|
||||||
|
$editUrl = $this->modules->configs->getModuleEditUrl($moduleName, false) . '&missing=1';
|
||||||
|
$editLinks[$moduleName] = "<a class='pw-modal' target='_blank' href='$editUrl'>" .
|
||||||
|
$sanitizer->entities1($this->_('Edit')) . "</a>";
|
||||||
$this->modules->flags->setFlag($moduleID, Modules::flagsNoFile, true);
|
$this->modules->flags->setFlag($moduleID, Modules::flagsNoFile, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1162,12 +1166,14 @@ class ModulesInfo extends ModulesClass {
|
|||||||
$items = array();
|
$items = array();
|
||||||
foreach($report['items'] as $moduleName => $item) {
|
foreach($report['items'] as $moduleName => $item) {
|
||||||
$item = $sanitizer->entities($item);
|
$item = $sanitizer->entities($item);
|
||||||
if(isset($upgradeLinks[$moduleName])) $item .= " - " . $upgradeLinks[$moduleName];
|
if(isset($editLinks[$moduleName])) $item .= " - " . $editLinks[$moduleName];
|
||||||
$items[] = $item;
|
$items[] = $item;
|
||||||
}
|
}
|
||||||
|
$itemsStr = implode("\n", $items);
|
||||||
|
$itemsStr = str_replace($config->paths->root, $config->urls->root, $itemsStr);
|
||||||
$this->message(
|
$this->message(
|
||||||
$sanitizer->entities1(sprintf($report['label'], count($items))) .
|
$sanitizer->entities1(sprintf($report['label'], count($items))) .
|
||||||
'<pre>' . implode("\n", $items) . '</pre>',
|
"<pre>$itemsStr</pre>",
|
||||||
'icon-plug markup nogroup'
|
'icon-plug markup nogroup'
|
||||||
);
|
);
|
||||||
$qty++;
|
$qty++;
|
||||||
|
@@ -376,7 +376,7 @@ class FieldtypeModule extends Fieldtype {
|
|||||||
* When specified, value must be a formatted value.
|
* When specified, value must be a formatted value.
|
||||||
* If null or not specified (recommended), it will be retrieved automatically.
|
* If null or not specified (recommended), it will be retrieved automatically.
|
||||||
* @param string $property Optionally specify the property or index to render. If omitted, entire value is rendered.
|
* @param string $property Optionally specify the property or index to render. If omitted, entire value is rendered.
|
||||||
* @return string|MarkupFieldtype Returns a string or object that can be output as a string, ready for output.
|
* @return string Returns a string or object that can be output as a string, ready for output.
|
||||||
* Return a MarkupFieldtype value when suitable so that the caller has potential specify additional
|
* Return a MarkupFieldtype value when suitable so that the caller has potential specify additional
|
||||||
* config options before typecasting it to a string.
|
* config options before typecasting it to a string.
|
||||||
*
|
*
|
||||||
@@ -398,6 +398,7 @@ class FieldtypeModule extends Fieldtype {
|
|||||||
*/
|
*/
|
||||||
public function ___getSelectorInfo(Field $field, array $data = array()) {
|
public function ___getSelectorInfo(Field $field, array $data = array()) {
|
||||||
if($data) {}
|
if($data) {}
|
||||||
|
/** @var FieldSelectorInfo $selectorInfo */
|
||||||
$selectorInfo = $this->wire(new FieldSelectorInfo());
|
$selectorInfo = $this->wire(new FieldSelectorInfo());
|
||||||
$labelField = $field->get('labelField');
|
$labelField = $field->get('labelField');
|
||||||
$info = $selectorInfo->getSelectorInfo($field);
|
$info = $selectorInfo->getSelectorInfo($field);
|
||||||
@@ -436,4 +437,3 @@ class FieldtypeModule extends Fieldtype {
|
|||||||
return parent::getMatchQuery($query, $table, $subfield, $operator, $value);
|
return parent::getMatchQuery($query, $table, $subfield, $operator, $value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -634,7 +634,7 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule {
|
|||||||
$s = $session->get($this->className());
|
$s = $session->get($this->className());
|
||||||
if(!is_array($s)) $s = array();
|
if(!is_array($s)) $s = array();
|
||||||
if(count($s) > 100) $s = array_slice($s, -100); // prevent from growing too large
|
if(count($s) > 100) $s = array_slice($s, -100); // prevent from growing too large
|
||||||
$id = 'id' . $this->wire('page')->id . "_" . $this->wire()->sanitizer->fieldName($this->attr('name'));
|
$id = 'id' . $this->wire()->page->id . "_" . $this->wire()->sanitizer->fieldName($this->attr('name'));
|
||||||
if(!isset($s[$id])) $s[$id] = array();
|
if(!isset($s[$id])) $s[$id] = array();
|
||||||
$s[$id][$key] = $value;
|
$s[$id][$key] = $value;
|
||||||
$session->set($this->className(), $s);
|
$session->set($this->className(), $s);
|
||||||
@@ -649,7 +649,9 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function sessionGet($key) {
|
protected function sessionGet($key) {
|
||||||
$s = $this->wire()->session->get($this->className());
|
$session = $this->wire()->session;
|
||||||
|
if(!$session) return null;
|
||||||
|
$s = $session->get($this->className());
|
||||||
if(!$s) return null;
|
if(!$s) return null;
|
||||||
$id = 'id' . $this->wire()->page->id . "_" . $this->wire()->sanitizer->fieldName($this->attr('name'));
|
$id = 'id' . $this->wire()->page->id . "_" . $this->wire()->sanitizer->fieldName($this->attr('name'));
|
||||||
if(empty($s[$id])) return null;
|
if(empty($s[$id])) return null;
|
||||||
@@ -1816,7 +1818,7 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function setAttribute($key, $value) {
|
public function setAttribute($key, $value) {
|
||||||
if($key == 'value') {
|
if($key === 'value' && $value !== null) {
|
||||||
if($this->initValue && strpos($value, $this->initValue) === 0) {
|
if($this->initValue && strpos($value, $this->initValue) === 0) {
|
||||||
// remove initValue from value so that inputs aren't drawn for it
|
// remove initValue from value so that inputs aren't drawn for it
|
||||||
$value = substr($value, strlen($this->initValue));
|
$value = substr($value, strlen($this->initValue));
|
||||||
|
Reference in New Issue
Block a user