mirror of
https://github.com/processwire/processwire.git
synced 2025-08-11 09:14:58 +02:00
Fix issue processwire/processwire-issues#1225 plus some other small upgrades to the FieldsTableTools notices
This commit is contained in:
@@ -223,13 +223,11 @@ class FieldsTableTools extends Wire {
|
||||
if($checking) return;
|
||||
|
||||
$col = 'data';
|
||||
$session = $this->wire('session');
|
||||
if($verbose && !$session) return;
|
||||
|
||||
// is unique index requested?
|
||||
$useUnique = (bool) $field->get('flagUnique');
|
||||
|
||||
// ise unique index already present?
|
||||
// is unique index already present?
|
||||
$hasUnique = (bool) $field->hasFlag(Field::flagUnique);
|
||||
|
||||
if($useUnique === $hasUnique) return;
|
||||
@@ -243,33 +241,34 @@ class FieldsTableTools extends Wire {
|
||||
$qty = $this->deleteEmptyRows($field, $col);
|
||||
|
||||
if($qty && $verbose) {
|
||||
$session->message(sprintf($this->_('Deleted %d empty row(s) for field %s'), $qty, $field->name));
|
||||
$this->message(sprintf($this->_('Deleted %d empty row(s) for field %s'), $qty, $field->name));
|
||||
}
|
||||
|
||||
$result = $this->setUniqueIndex($field, true);
|
||||
|
||||
if($result === false && $verbose) {
|
||||
$pageEditUrl = $this->wire()->config->urls->admin . 'page/edit/?id=';
|
||||
$msg = $this->_('Unique index cannot be added yet because there are already non-unique row(s) present:') . ' ';
|
||||
$rows = $this->findDuplicateRows($field, array('verbose' => true, 'column' => $col));
|
||||
foreach($rows as $row) {
|
||||
$ids = array();
|
||||
foreach($row['rows'] as $a) {
|
||||
$ids[] = $a['pages_id'];
|
||||
$ids[] = '[' . $a['pages_id'] . '](' . $pageEditUrl . $a['pages_id'] . ')';
|
||||
}
|
||||
$msg .= "\n• $row[value] — " .
|
||||
$msg .= "[br]• $row[value] — " .
|
||||
sprintf($this->_('Appears %d times'), $row['count']) . ' ' .
|
||||
sprintf($this->_('(pages: %s)'), implode(', ', $ids)) . ' ';
|
||||
sprintf($this->_('(page IDs: %s)'), implode(', ', $ids)) . ' ';
|
||||
}
|
||||
$session->error($msg, Notice::noGroup);
|
||||
$this->error($msg, Notice::noGroup | Notice::allowMarkdown);
|
||||
|
||||
} else if($result && $verbose) {
|
||||
$session->message($this->_('Added unique index'));
|
||||
$this->message($this->_('Added unique index') . " ($field->name)", Notice::noGroup);
|
||||
}
|
||||
|
||||
} else if($hasUnique && !$useUnique) {
|
||||
// remove unique index
|
||||
$result = $this->setUniqueIndex($field, false);
|
||||
if($result && $verbose) $session->message($this->_('Removed unique index'));
|
||||
if($result && $verbose) $this->message($this->_('Removed unique index') . " ($field->name)", Notice::noGroup);
|
||||
}
|
||||
|
||||
$checking = false;
|
||||
|
@@ -848,7 +848,7 @@ class Pageimage extends Pagefile {
|
||||
// create a new resize if it doesn't already exist or forceNew option is set
|
||||
if(!$filenameFinalExists && !file_exists($this->filename())) {
|
||||
// no original file exists to create variation from
|
||||
$this->error = "Original image does not exist to create size variation";
|
||||
$this->error = "Original image does not exist to create size variation: " . $this->url();
|
||||
|
||||
} else if(!$filenameFinalExists || $options['forceNew']) {
|
||||
|
||||
|
@@ -294,8 +294,8 @@ class PagesNames extends Wire {
|
||||
$format = empty($options['format']) ? '' : $options['format'];
|
||||
}
|
||||
|
||||
/** @var Languages|null $languages */
|
||||
$languages = $this->wire('languages');
|
||||
$languages = $this->wire()->languages;
|
||||
$sanitizer = $this->wire()->sanitizer;
|
||||
|
||||
$options = array_merge($defaults, $options);
|
||||
if(!strlen($format)) $format = $this->defaultPageNameFormat($page);
|
||||
@@ -354,7 +354,7 @@ class PagesNames extends Wire {
|
||||
$name = wireDate($format);
|
||||
$formatType = 'date';
|
||||
|
||||
} else if($this->wire('sanitizer')->fieldName($format) === $format) {
|
||||
} else if($sanitizer->fieldName($format) === $format) {
|
||||
// single field name or predefined string
|
||||
// this can also return null, which falls back to if() statement below
|
||||
$name = (string) $page->getUnformatted($format);
|
||||
@@ -395,8 +395,7 @@ class PagesNames extends Wire {
|
||||
|
||||
if(strlen($name) > $this->nameMaxLength) $name = $this->adjustNameLength($name);
|
||||
|
||||
$utf8 = $this->wire('config')->pageNameCharset === 'UTF8';
|
||||
$sanitizer = $this->wire('sanitizer');
|
||||
$utf8 = $this->wire()->config->pageNameCharset === 'UTF8';
|
||||
$name = $utf8 ? $sanitizer->pageNameUTF8($name) : $sanitizer->pageName($name, Sanitizer::translate);
|
||||
|
||||
if($language) $languages->unsetLanguage();
|
||||
|
Reference in New Issue
Block a user