{remove} {text}"; return parent::renderAdminNotices($notices, $options); } /** * Render quicklinks for templates/fields. Designed to be called by renderSideNav() * * @param Page $page * @param array $items * @param string $title * @param string $json * @return string * */ public function renderQuicklinks(Page $page, array $items, $title, $json = '') { if($json) $json = $page->url . $json; $textdomain = str_replace($this->wire('config')->paths->root, '/', $this->wire('modules')->getModuleFile($page->process)); $out = ""; return $out; } /** * Render top navigation items * * @return string * */ public function renderTopNav() { $items = array(); $class = ''; $user = $this->wire('user'); $config = $this->wire("config"); $adminTheme = $this->wire('adminTheme'); $fieldName = "avatar_field_" . $user->template->name; $adminTheme->$fieldName != '' ? $avatarField = $adminTheme->$fieldName : $avatarField = ''; $avatarField != '' ? $imgField = $user->get($avatarField) : $imgField = ''; $avatar = ""; if($user->isLoggedin()) { if($config->debug && $user->isSuperuser()) { $debugLabel = __('Debug Mode Tools', '/wire/templates-admin/debug.inc'); $items[] = array( "class" => "", "label" => "", "link" => "#", "attrs" => "title='$debugLabel' onclick=\"$('#debug_toggle').click();return false;\"", ); } if($this->wire('process') != 'ProcessPageList') { $treeLabel = $this->_('Tree'); $items[] = array( "class" => "", "label" => "", "link" => $config->urls->admin . 'page/', "attrs" => "class='pw-panel' " . "data-tab-text='$treeLabel' " . "data-tab-icon='sitemap' " . "title='$treeLabel'" ); } } // View site $items[] = array( "class" => "", "label" => "", "link" => $config->urls->root ); // Search toggle $items[] = array( "class" => "search-toggle", "label" => "", "link" => "#" ); // Superuser quick links if ($this->user->isSuperuser()){ $items[] = array( "class" => "superuser", "label" => "", "children" => array( " " . $this->_('Support Forums') => array('https://processwire.com/talk/', 'target="_blank"'), " " . $this->_('Documentation') => array('https://processwire.com/docs/', 'target="_blank"'), " " . $this->_('Github Repo') => array('https://github.com/processwire/processwire/', 'target="_blank"'), " " . $this->_('Cheatsheet') => array('http://cheatsheet.processwire.com', 'target="_blank"'), " " . $this->_('Hooks') => array('https://processwire.com/api/hooks/', 'target="_blank"'), ) ); } // Avatar field for user information if ($imgField != '') { $class = 'avatar'; count($imgField) ? $img = $imgField->first() : $img = $imgField; $userImg = $img->size(52,52); // render at 2x for hi-dpi (52x52 for 26x26) $avatar = "$user->name"; } // User information, profile, logout $items[] = array( "class" => "avatar", "label" => "$avatar " . $this->getDisplayName($user) . "", "children" => array( " " . $this->_('Profile') => $config->urls->admin . "profile/", " " . $this->_('Logout') => $config->urls->admin . "login/logout/" ) ); return $this->topNavItems($items); } /** * Render top navigation items (hookable) * * @return string * */ public function ___topNavItems(array $items) { $out = ''; $defaults = array( "class" => "", "label" => "", "link" => "#", "attrs" => "", "children" => false ); foreach ($items as $item){ // Create variables for each default key. // If $item contains a key listed in the default array, use that value, otherwise use the default. foreach ($defaults as $key => $val){ array_key_exists($key, $item) ? ${$key} = $item[$key] : ${$key} = $val; } // Add dropdown class if there are children if($children) $class .= " pw-dropdown"; $out .= "
  • $label"; if (is_array($children)){ $out .= ""; } $out .= "
  • "; } return $out; } /** * Render a side navigation items * * This function designed primarily to be called by the renderSideNavItems() function. * * @param Page $p * @return string * */ public function renderSideNavItem(Page $p) { $isSuperuser = $this->wire('user')->isSuperuser(); $sanitizer = $this->wire('sanitizer'); $modules = $this->wire('modules'); $showItem = $isSuperuser; $children = $p->numChildren() ? $p->children("check_access=0") : array(); if($p->name == 'page' && !$children->has("name=list")) { // +PW27: ensure the "Tree" page is shown if it is hidden $children->prepend($p->child("name=list, include=hidden")); } $out = ''; $iconName = $p->name; $icon = $this->wire('adminTheme')->$iconName; if(!$icon) $icon = 'fa-file-text-o'; $numViewable = 0; if(!$showItem) { $checkPages = count($children) ? $children : array($p); foreach($checkPages as $child) { if($child->viewable()) { $showItem = true; $numViewable++; if($numViewable > 1) break; // we don't need to know about any more } } } // don't bother with a drop-down here if only 1 child if($p->name == 'page' && !$isSuperuser && $numViewable < 2) { $children = array(); } if(!$showItem) return ''; if($p->process) { $moduleInfo = $modules->getModuleInfo($p->process); $textdomain = str_replace($this->wire('config')->paths->root, '/', $this->wire('modules')->getModuleFile($p->process)); } else { $moduleInfo = array(); $textdomain = ''; } if(!count($children) && !empty($moduleInfo['nav'])) $children = $moduleInfo['nav']; $class = strpos($this->wire('page')->path, $p->path) === 0 ? 'current' : ''; // current class $class .= count($children) > 0 ? " parent" : ''; // parent class $title = $sanitizer->entities1((string) $this->_($p->get('title|name'))); $currentPagePath = $this->wire('page')->url; // use URL to support sub directory installs $out .= "
  • "; if(count($children) && WireArray::iterable($children)) { $out .= " $title"; $out .= ""; } else { $class = $class ? " class='$class $p->name'" : "class='$p->name'"; $out .= " $title"; } $out .= "
  • "; return $out; } /** * Render the the user display name as specified in module config. * * @return string * */ public function getDisplayName(User $user) { $out = ''; $adminTheme = $this->wire('adminTheme'); $field_name = "userFields_". $user->template->name; trim($adminTheme->$field_name) == '' ? $adminTheme->$field_name = 'name' : ''; // force to name field if empty $userFields = explode(',', $adminTheme->$field_name); foreach($userFields as $f){ $f = trim($f); if ($f == 'name'){ $out .= "{$user->name} "; // can't use wire('fields') to get name field } else { $field = $this->wire('fields')->get($f); if($field instanceof Field && in_array($field->type, array('FieldtypeText', 'FieldtypeConcat', 'FieldtypePageTitle'))){ $out .= $this->wire('sanitizer')->entities1($user->$f) . " "; } } } return rtrim($out, ' '); // clean up the trailing space. } /** * Render all sidenav navigation items, ready to populate in ul#main-nav * * @return string * */ public function renderSideNavItems() { $out = ''; $admin = $this->wire('pages')->get($this->wire('config')->adminRootPageID); foreach($admin->children("check_access=0") as $p) { if(!$p->viewable()) continue; $out .= $this->renderSideNavItem($p); } return $out; } }