/** * Debug info specific to Page objects * * @param Page $page * @return array * */ protected function Page(Page $page) { $info = array('instanceID' => $page->instanceID, 'id' => $page->id, 'name' => $page->name, 'namePrevious' => '', 'path' => $page->path(), 'status' => implode(', ', $page->status(true)), 'statusPrevious' => 0, 'template' => $page->template ? $page->template->name : '', 'templatePrevious' => '', 'parent' => $page->parent ? $page->parent->path : '', 'parentPrevious' => '', 'numChildren' => $page->numChildren(), 'sort' => $page->sort, 'sortfield' => $page->sortfield, 'created' => $page->created, 'modified' => $page->modified, 'createdUser' => $page->createdUser ? $page->createdUser->name : $page->created_users_id, 'modifiedUser' => $page->modifiedUser ? $page->modifiedUser->name : $page->modified_users_id); if ($page->namePrevious) { $info['namePrevious'] = $page->namePrevious; } else { unset($info['namePrevious']); } if ($page->statusPrevious !== null) { $info['statusPrevious'] = implode(', ', $page->status(true, $page->statusPrevious)); } else { unset($info['statusPrevious']); } if ($page->templatePrevious) { $info['templatePrevious'] = $page->templatePrevious->name; } else { unset($info['templatePrevious']); } if ($page->parentPrevious) { $info['parentPrevious'] = $page->parentPrevious->path(); } else { unset($info['parentPrevious']); } if ($page->isNew) { $info['isNew'] = 1; } $info['isLoaded'] = (int) $page->isLoaded(); $info['outputFormatting'] = (int) $page->outputFormatting(); if ($page->quietMode) { $info['quietMode'] = 1; } foreach (array('created', 'modified') as $key) { $info[$key] = wireDate($this->wire('config')->dateFormat, $info[$key]) . " " . "(" . wireDate('relative', $info[$key]) . ")"; } return $info; }
/** * Constructor * * @param Request $request * @return PagesController */ function __construct($request) { parent::__construct($request); //echo $this->logged_user->getProjectPermission('page', $this->active_project); if ($this->logged_user->getProjectPermission('page', $this->active_project) < PROJECT_PERMISSION_ACCESS) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $section_url = pages_module_url($this->active_project); $this->wireframe->addBreadCrumb(lang('Pages'), $section_url); if ($this->active_category->isLoaded()) { $this->wireframe->addBreadCrumb($this->active_category->getName(), assemble_url('project_pages', array('project_id' => $this->active_project->getId(), 'category_id' => $this->active_category->getId()))); } // if $page_id = $this->request->get('page_id'); if ($page_id) { $this->active_page = Pages::findById($page_id); } // if if (instance_of($this->active_page, 'Page')) { $parents = array(); $parent = $this->active_page->getParent(); while (instance_of($parent, 'ProjectObject')) { if (instance_of($parent, 'Page')) { if (array_key_exists($parent->getId(), $parents)) { break; // avoid dead loops } // if $parents[$parent->getId()] = $parent; $parent = $parent->getParent(); } elseif (instance_of($parent, 'Category')) { $parents[$parent->getId()] = $parent; break; } else { break; } // if } // while $parents = array_reverse($parents); foreach ($parents as $parent) { if (instance_of($parent, 'Page')) { $this->wireframe->addBreadCrumb($parent->getName(), $parent->getViewUrl()); } elseif (instance_of($parent, 'Category')) { $this->wireframe->addBreadCrumb($parent->getName(), assemble_url('project_pages', array('project_id' => $this->active_project->getId(), 'category_id' => $parent->getId()))); } // if } // foreach $this->wireframe->addBreadCrumb($this->active_page->getName(), $this->active_page->getViewUrl()); } else { $this->active_page = new Page(); } // if if (Page::canAdd($this->logged_user, $this->active_project)) { if ($this->active_page->isLoaded()) { $add_page_url = pages_module_add_page_url($this->active_project, array('parent' => $this->active_page)); } elseif ($this->active_category->isLoaded()) { $add_page_url = pages_module_add_page_url($this->active_project, array('parent' => $this->active_category)); } else { $add_page_url = pages_module_add_page_url($this->active_project); } // if $this->wireframe->addPageAction(lang('New Page'), $add_page_url); } // if $this->smarty->assign(array('active_page' => $this->active_page, 'pages_url' => $section_url, 'add_page_url' => $add_page_url, 'page_tab' => 'pages')); }