mirror of
https://github.com/processwire/processwire.git
synced 2025-08-20 05:21:29 +02:00
Update Lister and InputfieldSelector option to display Template labels (vs Template names) have additional logic as to when they display both, and be consistent with one another. They now take into account the Lister "useColumnLabels" setting as well.
This commit is contained in:
@@ -359,6 +359,7 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule {
|
||||
$notLabel = $this->_('Not: %s');
|
||||
$findOperators = array();
|
||||
$findNotOperators = array();
|
||||
$showFieldLabels = $this->showFieldLabels;
|
||||
|
||||
$operators = Selectors::getOperators(array(
|
||||
'getIndexType' => 'operator',
|
||||
@@ -407,16 +408,19 @@ class InputfieldSelector extends Inputfield implements ConfigurableModule {
|
||||
$this->operatorTrimChars = '.@';
|
||||
|
||||
$templates = array();
|
||||
$templatesByLabel = array();
|
||||
$initTemplates = $this->getTemplatesFromInitValue($this->initValue);
|
||||
foreach($this->wire()->templates as $template) {
|
||||
if(($template->flags & Template::flagSystem) && !$this->allowSystemTemplates) {
|
||||
continue;
|
||||
}
|
||||
if(($template->flags & Template::flagSystem) && !$this->allowSystemTemplates) continue;
|
||||
if(count($initTemplates) && !in_array($template->id, $initTemplates)) continue;
|
||||
$label = $template->getLabel();
|
||||
if($label != $template->name) $label .= " ($template->name)";
|
||||
if(!$showFieldLabels || $showFieldLabels > 1 || isset($templatesByLabel[$label])) {
|
||||
if(strtolower($template->name) != strtolower($label)) $label .= " ($template->name)";
|
||||
}
|
||||
$templatesByLabel[$label] = $template;
|
||||
$templates[$template->id] = $label;
|
||||
}
|
||||
unset($templatesByLabel);
|
||||
|
||||
// make users selectable if there are under $maxUsers of them
|
||||
// otherwise utilize the user ID property
|
||||
|
@@ -1574,6 +1574,15 @@ class ProcessPageLister extends Process implements ConfigurableModule {
|
||||
foreach($this->statusLabels as $status => $label) if($p->hasStatus($status)) $value[] = $label;
|
||||
$value = implode(', ', $value);
|
||||
|
||||
} else if($name === 'template') {
|
||||
// template label or name
|
||||
$allowName = $this->useColumnLabels ? trim($this->get('sort'), '-') === 'template' : true;
|
||||
$t = $p->template;
|
||||
$value = $t->getLabel();
|
||||
// include template name only if it differs from template label
|
||||
if($allowName && strtolower($t->name) != strtolower($value)) $value .= " ($t->name)";
|
||||
if(!$noEntities) $value = $sanitizer->entities1($value);
|
||||
|
||||
} else if($field && $field->type) {
|
||||
if($subname == 'data') $subname = '';
|
||||
$value = $field->type->markupValue($p, $field, $value, $subname);
|
||||
|
Reference in New Issue
Block a user