Skip to content

Commit

Permalink
Various minor tweaks/updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ryancramerdesign committed Apr 7, 2017
1 parent 98594eb commit 75a969b
Show file tree
Hide file tree
Showing 15 changed files with 109 additions and 46 deletions.
73 changes: 46 additions & 27 deletions wire/core/AdminThemeFramework.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,7 @@ public function getHeadline() {
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 {
Expand Down Expand Up @@ -310,26 +300,55 @@ public function getHeadJS() {
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;
$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;
Expand Down Expand Up @@ -461,7 +480,7 @@ public function pageToNavArray(Page $p) {
);

if(!empty($moduleInfo['nav'])) {
$childItem['children'] = $this->moduleToNavArray($moduleInfo, $c); // @todo should $p be $c?
$childItem['children'] = $this->moduleToNavArray($moduleInfo, $c);
}

$navArray['children'][] = $childItem;
Expand Down
5 changes: 3 additions & 2 deletions wire/core/Inputfield.php
Original file line number Diff line number Diff line change
Expand Up @@ -809,12 +809,13 @@ public function addClass($class, $property = 'class') {
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') {
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,17 @@
margin-bottom: 5px;
}

.pw-dropdown-menu {
.PageListStatusUnpublished {
text-decoration: line-through;
}

.PageListStatusHidden {
opacity: 0.5;
}

.PageListStatusNotEditable {
cursor: not-allowed;
}
}

2 changes: 1 addition & 1 deletion wire/modules/Inputfield/InputfieldFile/InputfieldFile.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion wire/modules/Inputfield/InputfieldFile/InputfieldFile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ ul.InputfieldFileList li {
}
}
.InputfieldFileSort {
display: none;
display: none !important;
}
}

Expand Down
14 changes: 10 additions & 4 deletions wire/modules/Inputfield/InputfieldRadios/InputfieldRadios.module
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 .=
Expand Down
1 change: 1 addition & 0 deletions wire/modules/Process/ProcessField/ProcessField.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
float: left;
margin-right: 1em;
margin-bottom: 1em;
width: 70px;
}

.InputfieldColumnWidthSlider {
Expand Down
2 changes: 1 addition & 1 deletion wire/modules/Process/ProcessField/ProcessField.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 + '%');
Expand Down
2 changes: 1 addition & 1 deletion wire/modules/Process/ProcessField/ProcessField.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 15 additions & 4 deletions wire/modules/Process/ProcessPageEdit/ProcessPageEdit.module
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 12 additions & 1 deletion wire/modules/Process/ProcessPageList/ProcessPageList.module
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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 .= ' &hellip;';
}
$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 .= ' &nbsp; ';

Expand All @@ -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) {
Expand Down

0 comments on commit 75a969b

Please sign in to comment.