mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 08:17:12 +02:00
Various minor tweaks/updates
This commit is contained in:
@@ -144,17 +144,7 @@ abstract class AdminThemeFramework extends AdminTheme {
|
||||
public function getPageTitle(Page $p) {
|
||||
|
||||
if($p->name == 'add' && $p->parent->name == 'page') {
|
||||
// ProcessPageAdd: avoid showing this menu item if there are no predefined family settings to use
|
||||
$numAddable = $this->wire('session')->getFor('ProcessPageAdd', 'numAddable');
|
||||
if($numAddable === null) {
|
||||
/** @var ProcessPageAdd $processPageAdd */
|
||||
$processPageAdd = $this->wire('modules')->getModule('ProcessPageAdd', array('noInit' => true));
|
||||
if($processPageAdd) {
|
||||
$addData = $processPageAdd->executeNavJSON(array('getArray' => true));
|
||||
$numAddable = $addData['list'];
|
||||
}
|
||||
}
|
||||
if(!$numAddable) return '';
|
||||
|
||||
$title = $this->getAddNewLabel();
|
||||
|
||||
} else {
|
||||
@@ -310,26 +300,55 @@ abstract class AdminThemeFramework extends AdminTheme {
|
||||
public function allowPageInNav(Page $p, $children = array(), $permission = null) {
|
||||
|
||||
if($this->isSuperuser) return true;
|
||||
if($p->viewable()) return true;
|
||||
$allow = false;
|
||||
|
||||
foreach($children as $child) {
|
||||
if($child->viewable()) {
|
||||
$allow = true;
|
||||
break;
|
||||
$allow = false;
|
||||
$pageViewable = $p->viewable();
|
||||
$numChildren = count($children);
|
||||
|
||||
if($p->process == 'ProcessPageAdd') {
|
||||
// ProcessPageAdd: avoid showing this menu item if there are no predefined family settings to use
|
||||
$numAddable = $this->wire('session')->getFor('ProcessPageAdd', 'numAddable');
|
||||
if($numAddable === null) {
|
||||
/** @var ProcessPageAdd $processPageAdd */
|
||||
$processPageAdd = $this->wire('modules')->getModule('ProcessPageAdd', array('noInit' => true));
|
||||
if($processPageAdd) {
|
||||
$addData = $processPageAdd->executeNavJSON(array('getArray' => true));
|
||||
$numAddable = $addData['list'];
|
||||
$this->wire('session')->setFor('ProcessPageAdd', 'numAddable', $numAddable);
|
||||
}
|
||||
}
|
||||
// no addable options, so do not show the "Add New" item
|
||||
if(!$numAddable) return false;
|
||||
|
||||
} else if(empty($permission)) {
|
||||
// no permission specified
|
||||
|
||||
if(!$p->process) {
|
||||
// no process module present, so we delegate to just the page viewable state if no children to check
|
||||
if($pageViewable && !$numChildren) return true;
|
||||
|
||||
} else if($p->process == 'ProcessList') {
|
||||
// page just serves as a list for children
|
||||
|
||||
} else {
|
||||
// determine permission from Process module, if present
|
||||
$moduleInfo = $this->wire('modules')->getModuleInfo($p->process);
|
||||
if(!empty($moduleInfo['permission'])) $permission = $moduleInfo['permission'];
|
||||
}
|
||||
}
|
||||
|
||||
if($allow) return true;
|
||||
|
||||
if($permission === null && $p->process) {
|
||||
// determine permission
|
||||
$moduleInfo = $this->wire('modules')->getModuleInfo($p->process);
|
||||
if(!empty($moduleInfo['permission'])) $permission = $moduleInfo['permission'];
|
||||
}
|
||||
|
||||
if($permission) {
|
||||
// specific permission required to determine view access
|
||||
$allow = $this->wire('user')->hasPermission($permission);
|
||||
|
||||
} else if($pageViewable && $p->parent_id == $this->wire('config')->adminRootPageID) {
|
||||
// primary nav page requires that at least one child is viewable
|
||||
foreach($children as $child) {
|
||||
if($this->allowPageInNav($child)) {
|
||||
$allow = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $allow;
|
||||
@@ -461,7 +480,7 @@ abstract class AdminThemeFramework extends AdminTheme {
|
||||
);
|
||||
|
||||
if(!empty($moduleInfo['nav'])) {
|
||||
$childItem['children'] = $this->moduleToNavArray($moduleInfo, $c); // @todo should $p be $c?
|
||||
$childItem['children'] = $this->moduleToNavArray($moduleInfo, $c);
|
||||
}
|
||||
|
||||
$navArray['children'][] = $childItem;
|
||||
|
@@ -809,12 +809,13 @@ abstract class Inputfield extends WireData implements Module {
|
||||
foreach($addClasses as $addClass) {
|
||||
$addClass = trim($addClass);
|
||||
if(!strlen($addClass)) continue;
|
||||
if(in_array($addClass, $classes)) continue; // if already present, don't add it
|
||||
$classes[] = $addClass;
|
||||
}
|
||||
|
||||
$classes = array_unique($classes);
|
||||
|
||||
// convert back to string
|
||||
$value = implode(' ', $classes);
|
||||
$value = trim(implode(' ', $classes));
|
||||
|
||||
// set back to Inputfield
|
||||
if($property == 'class') {
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -172,3 +172,17 @@
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.pw-dropdown-menu {
|
||||
.PageListStatusUnpublished {
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.PageListStatusHidden {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.PageListStatusNotEditable {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -87,7 +87,7 @@ ul.InputfieldFileList li .InputfieldFileDescription {
|
||||
ul.InputfieldFileList li .InputfieldFileDescription input {
|
||||
width: 100%; }
|
||||
ul.InputfieldFileList li .InputfieldFileSort {
|
||||
display: none; }
|
||||
display: none !important; }
|
||||
|
||||
.Inputfield .InputfieldFileTags input {
|
||||
margin-bottom: 0.5em; }
|
||||
|
@@ -113,7 +113,7 @@ ul.InputfieldFileList li {
|
||||
}
|
||||
}
|
||||
.InputfieldFileSort {
|
||||
display: none;
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -28,6 +28,13 @@ class InputfieldRadios extends InputfieldSelect {
|
||||
|
||||
public function ___render() {
|
||||
|
||||
$defaults = array(
|
||||
'wbr' => true,
|
||||
'noSelectLabels' => true,
|
||||
);
|
||||
$settings = $this->wire('config')->get('InputfieldRadios');
|
||||
$settings = is_array($settings) ? array_merge($defaults, $settings) : $defaults;
|
||||
|
||||
$this->checkDefaultValue();
|
||||
$inline = false;
|
||||
$columns = (int) $this->optionColumns;
|
||||
@@ -59,14 +66,13 @@ class InputfieldRadios extends InputfieldSelect {
|
||||
if($this->isOptionSelected($key)) $checked = " checked='checked'";
|
||||
$disabled = empty($attrs['disabled']) ? "" : " disabled='disabled'";
|
||||
unset($attrs['selected'], $attrs['checked'], $attrs['disabled']);
|
||||
$textClass = 'pw-no-select';
|
||||
$textClass = $settings['noSelectLabels'] ? 'pw-no-select' : '';
|
||||
if($disabled) $textClass .= ' ui-state-disabled';
|
||||
$attrs = $this->getOptionAttributesString($attrs);
|
||||
if($attrs) $attrs = ' ' . $attrs;
|
||||
$label = str_replace(' ', ' !wbr!', $value);
|
||||
$label = $settings['wbr'] ? str_replace(' ', ' !wbr!', $value) : $value;
|
||||
$label = $this->entityEncode($label, Inputfield::textFormatBasic);
|
||||
$label = str_replace('!wbr!', '<wbr>', $label);
|
||||
$label = "<span class='$textClass'>$label</span>";
|
||||
if($settings['wbr']) $label = str_replace('!wbr!', '<wbr>', $label);
|
||||
$class = trim($this->wire('sanitizer')->entities($this->attr('class')));
|
||||
|
||||
$out .=
|
||||
|
@@ -2,6 +2,7 @@
|
||||
float: left;
|
||||
margin-right: 1em;
|
||||
margin-bottom: 1em;
|
||||
width: 70px;
|
||||
}
|
||||
|
||||
.InputfieldColumnWidthSlider {
|
||||
|
@@ -33,7 +33,7 @@ $(document).ready(function() {
|
||||
$("#Inputfield_required").change(setAsmListItemStatus);
|
||||
setAsmListItemStatus();
|
||||
|
||||
if($columnWidth.size() > 0) {
|
||||
if($columnWidth.length > 0) {
|
||||
var $slider = $("<div class='InputfieldColumnWidthSlider'></div>");
|
||||
var columnWidthVal = parseInt($("#columnWidth").val());
|
||||
$columnWidth.val(columnWidthVal + '%');
|
||||
|
@@ -1 +1 @@
|
||||
$(document).ready(function(){var e=function(){$("#field_filter_form").submit()};$("#templates_id").change(e);$("#fieldtype").change(e);$("#show_system").click(e);var b=$("#asmListItemStatus");var d=$("#columnWidth");function a(){var i=b.attr("data-tpl");if(!i){return}var k=$("#Inputfield_showIf").val();var j=$("#Inputfield_required").is(":checked")?true:false;if(k&&k.length>0){i="<i class='fa fa-question-circle'></i>"+i}if(j){i="<i class='fa fa-asterisk'></i>"+i}var h=parseInt(d.val());if(h==100){h=0}if(h>0){h=h+"%"}else{h=""}i=i.replace("%",h);b.val(i)}$("#Inputfield_showIf").change(a);$("#Inputfield_required").change(a);a();if(d.size()>0){var f=$("<div class='InputfieldColumnWidthSlider'></div>");var c=parseInt($("#columnWidth").val());d.val(c+"%");d.after(f);f.slider({range:"min",min:10,max:100,value:parseInt(d.val()),slide:function(i,h){var j=h.value+"%";d.val(j);a()}});d.change(function(){var h=parseInt($(this).val());if(h>100){h=100}if(h<10){h=10}$(this).val(h+"%");f.slider("option","value",h)})}var g=$("#ProcessFieldEdit");if(g.size()>0&&$("li.WireTab").size()>1){g.find("script").remove();g.WireTabs({items:$(".Inputfields li.WireTab"),id:"FieldEditTabs",skipRememberTabIDs:["delete"]})}$("#fieldgroupContextSelect").change(function(){var i=$("#Inputfield_id").val();var j=$(this).val();var h="./edit?id="+i;if(j>0){h+="&fieldgroup_id="+j}window.location=h});$("a.fieldFlag").click(function(){return false});$("#export_data").click(function(){$(this).select()});$(".import_toggle input[type=radio]").change(function(){var h=$(this).parents("p.import_toggle").next("table");var i=$(this).closest(".InputfieldFieldset");if($(this).is(":checked")&&$(this).val()==0){h.hide();i.addClass("ui-priority-secondary")}else{h.show();i.removeClass("ui-priority-secondary")}}).change();$("#wrap_Inputfield_send_templates").find(":input").change(function(){$("#_send_templates_changed").val("changed")});$("#viewRoles_37").click(function(){if($(this).is(":checked")){$("input.viewRoles").attr("checked","checked")}});$("input.viewRoles:not(#viewRoles_37)").click(function(){if($("#viewRoles_37").is(":checked")){return false}return true});$("input.editRoles:not(:disabled)").click(function(){if($(this).is(":checked")){$(this).closest("tr").find("input.viewRoles").attr("checked","checked")}});$(".override-select-all").click(function(){var h=$(this).closest("table").find("input[type=checkbox]");if($(this).hasClass("override-checked")){h.removeAttr("checked");$(this).removeClass("override-checked")}else{h.attr("checked","checked");$(this).addClass("override-checked")}return false})});
|
||||
$(document).ready(function(){var e=function(){$("#field_filter_form").submit()};$("#templates_id").change(e);$("#fieldtype").change(e);$("#show_system").click(e);var b=$("#asmListItemStatus");var d=$("#columnWidth");function a(){var i=b.attr("data-tpl");if(!i){return}var k=$("#Inputfield_showIf").val();var j=$("#Inputfield_required").is(":checked")?true:false;if(k&&k.length>0){i="<i class='fa fa-question-circle'></i>"+i}if(j){i="<i class='fa fa-asterisk'></i>"+i}var h=parseInt(d.val());if(h==100){h=0}if(h>0){h=h+"%"}else{h=""}i=i.replace("%",h);b.val(i)}$("#Inputfield_showIf").change(a);$("#Inputfield_required").change(a);a();if(d.length>0){var f=$("<div class='InputfieldColumnWidthSlider'></div>");var c=parseInt($("#columnWidth").val());d.val(c+"%");d.after(f);f.slider({range:"min",min:10,max:100,value:parseInt(d.val()),slide:function(i,h){var j=h.value+"%";d.val(j);a()}});d.change(function(){var h=parseInt($(this).val());if(h>100){h=100}if(h<10){h=10}$(this).val(h+"%");f.slider("option","value",h)})}var g=$("#ProcessFieldEdit");if(g.size()>0&&$("li.WireTab").size()>1){g.find("script").remove();g.WireTabs({items:$(".Inputfields li.WireTab"),id:"FieldEditTabs",skipRememberTabIDs:["delete"]})}$("#fieldgroupContextSelect").change(function(){var i=$("#Inputfield_id").val();var j=$(this).val();var h="./edit?id="+i;if(j>0){h+="&fieldgroup_id="+j}window.location=h});$("a.fieldFlag").click(function(){return false});$("#export_data").click(function(){$(this).select()});$(".import_toggle input[type=radio]").change(function(){var h=$(this).parents("p.import_toggle").next("table");var i=$(this).closest(".InputfieldFieldset");if($(this).is(":checked")&&$(this).val()==0){h.hide();i.addClass("ui-priority-secondary")}else{h.show();i.removeClass("ui-priority-secondary")}}).change();$("#wrap_Inputfield_send_templates").find(":input").change(function(){$("#_send_templates_changed").val("changed")});$("#viewRoles_37").click(function(){if($(this).is(":checked")){$("input.viewRoles").attr("checked","checked")}});$("input.viewRoles:not(#viewRoles_37)").click(function(){if($("#viewRoles_37").is(":checked")){return false}return true});$("input.editRoles:not(:disabled)").click(function(){if($(this).is(":checked")){$(this).closest("tr").find("input.viewRoles").attr("checked","checked")}});$(".override-select-all").click(function(){var h=$(this).closest("table").find("input[type=checkbox]");if($(this).hasClass("override-checked")){h.removeAttr("checked");$(this).removeClass("override-checked")}else{h.attr("checked","checked");$(this).addClass("override-checked")}return false})});
|
@@ -784,6 +784,7 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
||||
|
||||
$fields->attr('id', $id);
|
||||
$fields->attr('title', $title);
|
||||
$fields->addClass('WireTab');
|
||||
$this->addTab($id, $title);
|
||||
|
||||
if($this->page->template->nameContentTab) {
|
||||
@@ -1446,13 +1447,23 @@ class ProcessPageEdit extends Process implements WirePageEditor, ConfigurableMod
|
||||
*
|
||||
*/
|
||||
protected function ___processSaveRedirect($redirectUrl) {
|
||||
if(!$redirectUrl) $redirectUrl = "./?id={$this->page->id}&s=1";
|
||||
if($redirectUrl) {
|
||||
$redirectUrl .= (strpos($redirectUrl, '?') === false ? '?' : '&') . 's=1';
|
||||
} else {
|
||||
$redirectUrl = "./?id={$this->page->id}&s=1";
|
||||
}
|
||||
$redirectUrl .= "&c=" . count($this->changes);
|
||||
$modal = $this->wire('config')->modal;
|
||||
if($modal) $redirectUrl .= "&modal=$modal";
|
||||
if(count($this->fields)) {
|
||||
if(count($this->fields) == 1) $redirectUrl .= "&field={$this->field->name}";
|
||||
else $redirectUrl .= "&fields=" . implode(',', array_keys($this->fields));
|
||||
if(count($this->changes)) $redirectUrl .= "&changes=" . implode(',', $this->changes);
|
||||
if(count($this->fields) == 1) {
|
||||
$redirectUrl .= "&field={$this->field->name}";
|
||||
} else {
|
||||
$redirectUrl .= "&fields=" . implode(',', array_keys($this->fields));
|
||||
}
|
||||
if(count($this->changes)) {
|
||||
$redirectUrl .= "&changes=" . implode(',', $this->changes);
|
||||
}
|
||||
}
|
||||
$this->redirectUrl = $redirectUrl;
|
||||
$this->session->redirect($redirectUrl);
|
||||
|
@@ -509,9 +509,11 @@ class ProcessPageList extends Process implements ConfigurableModule {
|
||||
$id = $page->id;
|
||||
if(in_array($id, $skipPageIDs)) continue;
|
||||
$url = '';
|
||||
$editable = false;
|
||||
|
||||
if($page->editable()) {
|
||||
$url = $page->editUrl();
|
||||
$editable = true;
|
||||
} else if($page->viewable()) {
|
||||
$url = $page->url();
|
||||
} else if(!$page->listable()) {
|
||||
@@ -520,13 +522,21 @@ class ProcessPageList extends Process implements ConfigurableModule {
|
||||
|
||||
$numChildren = $id > 1 ? $page->numChildren : 0;
|
||||
$label = $renderer->getPageLabel($page, array('noTags' => true));
|
||||
if($page->isUnpublished()) $label = "<s>$label</s>";
|
||||
if(strlen($label) > $maxLabelLength) {
|
||||
$label = substr($label, 0, $maxLabelLength);
|
||||
$pos = strrpos($label, ' ');
|
||||
if($pos !== false) $label = substr($label, 0, $pos);
|
||||
$label .= ' …';
|
||||
}
|
||||
$labelClasses = array();
|
||||
if($page->isUnpublished()) $labelClasses[] = 'PageListStatusUnpublished';
|
||||
if($page->isHidden()) $labelClasses[] = 'PageListStatusHidden';
|
||||
if($page->hasStatus(Page::statusLocked)) $labelClasses[] = 'PageListStatusLocked';
|
||||
if($page->hasStatus(Page::statusDraft)) $labelClasses[] = 'PageListStatusDraft';
|
||||
if(!$editable) $labelClasses[] = 'PageListStatusNotEditable';
|
||||
if(count($labelClasses)) {
|
||||
$label = "<span class='" . implode(' ', $labelClasses) . "'>$label</span>";
|
||||
}
|
||||
if($numChildren) $label .= " <small>$numChildren</small>";
|
||||
$label .= ' ';
|
||||
|
||||
@@ -535,6 +545,7 @@ class ProcessPageList extends Process implements ConfigurableModule {
|
||||
'id' => $id,
|
||||
'label' => $label,
|
||||
'icon' => $page->getIcon(),
|
||||
'edit' => $editable
|
||||
);
|
||||
|
||||
if($page->id > 1 && $page->numChildren) {
|
||||
|
Reference in New Issue
Block a user