/** * Return data on a course view (this will be some form of HTML) * * @param object $course Current course * @param object $offering Name of the component * @param boolean $describe Return plugin description only? * @return object */ public function onCourse($course, $offering, $describe = false) { if (!$offering->access('manage', 'section')) { return; } $response = with(new \Hubzero\Base\Object())->set('name', $this->_name)->set('title', Lang::txt('PLG_COURSES_' . strtoupper($this->_name)))->set('description', Lang::txt('PLG_COURSES_' . strtoupper($this->_name) . '_BLURB'))->set('default_access', $this->params->get('plugin_access', 'managers'))->set('display_menu_tab', true)->set('icon', 'f083'); if ($describe) { return $response; } $nonadmin = Request::getState('com_courses.offering' . $offering->get('id') . '.nonadmin', 0); if (!($active = Request::getVar('active')) && !$nonadmin) { Request::setVar('active', $active = $this->_name); } if ($response->get('name') == $active) { // Set the page title Document::setTitle(Document::getTitle() . ': ' . Lang::txt('PLG_COURSES_' . strtoupper($this->_name))); Pathway::append(Lang::txt('PLG_COURSES_' . strtoupper($this->_name)), $offering->link() . '&active=' . $this->_name); $view = with($this->view('default', 'overview'))->set('option', Request::getVar('option', 'com_courses'))->set('course', $course)->set('offering', $offering)->set('params', $this->params); foreach ($this->getErrors() as $error) { $view->setError($error); } $response->set('html', $view->loadTemplate()); } // Return the output return $response; }
function testGetTitle() { $doc = new Document(); $doc->addTitle('nom random'); $doc->addTitle('nom corrigé'); $this->assertIdentical($doc->getTitle(), 'nom corrigé'); }
/** * Return data on a course view (this will be some form of HTML) * * @param object $course Current course * @param object $offering Name of the component * @param boolean $describe Return plugin description only? * @return object */ public function onCourse($course, $offering, $describe = false) { $response = with(new \Hubzero\Base\Object())->set('name', $this->_name)->set('title', Lang::txt('PLG_COURSES_' . strtoupper($this->_name)))->set('description', Lang::txt('PLG_COURSES_' . strtoupper($this->_name) . '_BLURB'))->set('default_access', $this->params->get('plugin_access', 'members'))->set('display_menu_tab', true)->set('icon', 'f095'); if ($describe) { return $response; } if (!($active = Request::getVar('active'))) { Request::setVar('active', $active = $this->_name); } // Get a student count $response->set('meta_count', $offering->announcements(array('count' => true))); // Check if our area is in the array of areas we want to return results for if ($response->get('name') == $active) { // Set some variables so other functions have access $this->option = Request::getCmd('option', 'com_courses'); $this->course = $course; $this->offering = $offering; // Set the page title Document::setTitle(Document::getTitle() . ': ' . Lang::txt('PLG_COURSES_ANNOUNCEMENTS')); Pathway::append(Lang::txt('PLG_COURSES_' . strtoupper($this->_name)), $this->offering->link() . '&active=' . $this->_name); require_once Component::path('com_courses') . DS . 'models' . DS . 'announcement.php'; $action = Request::getWord('action', ''); switch (strtolower($action)) { case 'save': $response->set('html', $this->_save()); break; case 'new': $response->set('html', $this->_edit()); break; case 'edit': $response->set('html', $this->_edit()); break; case 'delete': $response->set('html', $this->_delete()); break; default: $response->set('html', $this->_list()); break; } } // Return the output return $response; }
function AssertDocument(Document $document, $id, $title) { $this->assertEquals($id, $document->getID()); $this->assertEquals($title, $document->getTitle()); }
/** * Return data on a group view (this will be some form of HTML) * * @param object $group Current group * @param string $option Name of the component * @param string $authorized User's authorization level * @param integer $limit Number of records to pull * @param integer $limitstart Start of records to pull * @param string $action Action to perform * @param array $access What can be accessed * @param array $areas Active area(s) * @return array */ public function onGroup($group, $option, $authorized, $limit = 0, $limitstart = 0, $action = '', $access, $areas = null) { $return = 'html'; $active = $this->_name; // The output array we're returning $arr = array('html' => '', 'metadata' => ''); //get this area details $this_area = $this->onGroupAreas(); // Check if our area is in the array of areas we want to return results for if (is_array($areas) && $limit) { if (!in_array($this_area['name'], $areas)) { $return = 'metadata'; } } include_once PATH_CORE . DS . 'components' . DS . 'com_blog' . DS . 'models' . DS . 'archive.php'; $this->model = new \Components\Blog\Models\Archive('group', $group->get('gidNumber')); //are we returning html if ($return == 'html') { //set group members plugin access level $group_plugin_acl = $access[$active]; //get the group members $members = $group->get('members'); //if set to nobody make sure cant access if ($group_plugin_acl == 'nobody') { $arr['html'] = '<p class="info">' . Lang::txt('GROUPS_PLUGIN_OFF', ucfirst($active)) . '</p>'; return $arr; } //check if guest and force login if plugin access is registered or members if (User::isGuest() && ($group_plugin_acl == 'registered' || $group_plugin_acl == 'members')) { $url = Route::url('index.php?option=com_groups&cn=' . $group->get('cn') . '&active=' . $active, false, true); App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($url)), Lang::txt('GROUPS_PLUGIN_REGISTERED', ucfirst($active)), 'warning'); return; } //check to see if user is member and plugin access requires members if (!in_array(User::get('id'), $members) && $group_plugin_acl == 'members' && $authorized != 'admin') { $arr['html'] = '<p class="info">' . Lang::txt('GROUPS_PLUGIN_REQUIRES_MEMBER', ucfirst($active)) . '</p>'; return $arr; } //user vars $this->authorized = $authorized; //group vars $this->group = $group; $this->members = $members; // Set some variables so other functions have access $this->action = $action; $this->option = $option; $this->database = App::get('db'); //get the plugins params $this->params = \Hubzero\Plugin\Params::getParams($group->gidNumber, 'groups', $this->_name); if ($authorized == 'manager' || $authorized == 'admin') { $this->params->set('access-edit-comment', true); $this->params->set('access-delete-comment', true); } // Append to document the title Document::setTitle(Document::getTitle() . ': ' . Lang::txt('PLG_GROUPS_BLOG')); switch ($this->action) { // Feeds case 'feed.rss': $this->_feed(); break; case 'feed': $this->_feed(); break; //case 'comments.rss': $this->_commentsFeed(); break; //case 'comments': $this->_commentsFeed(); break; // Settings //case 'comments.rss': $this->_commentsFeed(); break; //case 'comments': $this->_commentsFeed(); break; // Settings case 'savesettings': $arr['html'] = $this->_savesettings(); break; case 'settings': $arr['html'] = $this->_settings(); break; // Comments // Comments case 'savecomment': $arr['html'] = $this->_savecomment(); break; case 'newcomment': $arr['html'] = $this->_newcomment(); break; case 'editcomment': $arr['html'] = $this->_entry(); break; case 'deletecomment': $arr['html'] = $this->_deletecomment(); break; // Entries // Entries case 'save': $arr['html'] = $this->_save(); break; case 'new': $arr['html'] = $this->_new(); break; case 'edit': $arr['html'] = $this->_edit(); break; case 'delete': $arr['html'] = $this->_delete(); break; case 'entry': $arr['html'] = $this->_entry(); break; case 'archive': case 'browse': default: $arr['html'] = $this->_browse(); break; } } $filters = array('scope' => 'group', 'scope_id' => $group->get('gidNumber'), 'state' => 1, 'access' => User::getAuthorisedViewLevels()); // Build the HTML meant for the "profile" tab's metadata overview $arr['metadata']['count'] = $this->model->entries($filters)->total(); return $arr; }
/** * Return data on a group view (this will be some form of HTML) * * @param object $group Current group * @param string $option Name of the component * @param string $authorized User's authorization level * @param integer $limit Number of records to pull * @param integer $limitstart Start of records to pull * @param string $action Action to perform * @param array $access What can be accessed * @param array $areas Active area(s) * @return array */ public function onGroup($group, $option, $authorized, $limit = 0, $limitstart = 0, $action = '', $access, $areas = null) { $returnhtml = true; $active = 'members'; // The output array we're returning $arr = array('html' => '', 'metadata' => ''); //get this area details $this_area = $this->onGroupAreas(); // Check if our area is in the array of areas we want to return results for if (is_array($areas) && $limit) { if (!in_array($this_area['name'], $areas)) { $returnhtml = false; } } // Set some variables so other functions have access $this->authorized = $authorized; $this->action = $action; $this->_option = $option; $this->group = $group; $this->name = substr($option, 4, strlen($option)); // Only perform the following if this is the active tab/plugin if ($returnhtml) { //set group members plugin access level $group_plugin_acl = $access[$active]; //get the group members $members = $group->get('members'); //if set to nobody make sure cant access if ($group_plugin_acl == 'nobody') { $arr['html'] = '<p class="info">' . Lang::txt('GROUPS_PLUGIN_OFF', ucfirst($active)) . '</p>'; return $arr; } //check if guest and force login if plugin access is registered or members if (User::isGuest() && ($group_plugin_acl == 'registered' || $group_plugin_acl == 'members')) { $url = Route::url('index.php?option=com_groups&cn=' . $group->get('cn') . '&active=' . $active, false, true); App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($url)), Lang::txt('GROUPS_PLUGIN_REGISTERED', ucfirst($active)), 'warning'); return; } //check to see if user is member and plugin access requires members if (!in_array(User::get('id'), $members) && $group_plugin_acl == 'members' && $authorized != 'admin') { $arr['html'] = '<p class="info">' . Lang::txt('GROUPS_PLUGIN_REQUIRES_MEMBER', ucfirst($active)) . '</p>'; return $arr; } // Append to document the title Document::setTitle(Document::getTitle() . ': ' . Lang::txt('PLG_GROUPS_FILES')); $this->path = PATH_APP . DS . trim($this->params->get('uploadpath', '/site/groups'), DS) . DS . $this->group->get('gidNumber'); $arr['html'] = $this->_browse(); } // Return the output return $arr; }
/** * Output tab controls for resource plugins (sub views) * * @param string $option Component name * @param string $id Publication ID * @param array $cats Active plugins' names * @param string $active Current plugin name * @param string $alias Publication alias * @param string $version Publication version * @return string HTML */ public static function tabs($option, $id, $cats, $active = 'about', $alias = '', $version = '') { $html = ''; $html .= "\t" . '<ul class="sub-menu">' . "\n"; $i = 1; foreach ($cats as $cat) { $name = key($cat); /*if ($name == 'usage') { continue; }*/ if ($name != '') { if ($alias) { $url = Route::url('index.php?option=' . $option . '&alias=' . $alias . '&active=' . $name); } else { $url = Route::url('index.php?option=' . $option . '&id=' . $id . '&active=' . $name); } if ($version && $version != 'default') { $url .= '?v=' . $version; } if (strtolower($name) == $active) { Pathway::append($cat[$name], $url); if ($active != 'about') { $title = Document::getTitle(); Document::setTitle($title . ': ' . $cat[$name]); } } $html .= "\t\t" . '<li id="sm-' . $i . '"'; $html .= strtolower($name) == $active ? ' class="active"' : ''; $html .= '><a class="tab" href="' . $url . '"><span>' . $cat[$name] . '</span></a></li>' . "\n"; $i++; } } $html .= "\t" . '</ul>' . "\n"; return $html; }
?> <section class="course section"> <div class="subject"> <ul class="sub-menu"> <?php if ($action == 'addpage') { $this->active = ''; } if ($this->plugins) { foreach ($this->plugins as $i => $plugin) { $url = Route::url($this->course->link() . '&active=' . $plugin->get('name')); if ($plugin->get('name') == $this->active) { Pathway::append($plugin->get('title'), $url); if ($this->active != 'overview') { Document::setTitle(Document::getTitle() . ': ' . $plugin->get('title')); } } ?> <li id="sm-<?php echo $i; ?> "<?php echo $plugin->get('name') == $this->active ? ' class="active"' : ''; ?> > <a class="tab" data-rel="<?php echo $plugin->get('name'); ?> " href="<?php echo $url;
/** * @param Document $document * @return string */ protected static function createDocumentComparisonString($document, $ignoreCopyDifferences = false) { if ($document instanceof Document) { $d = array(); if ($document instanceof Document_PageSnippet) { $elements = $document->getElements(); ksort($elements); foreach ($elements as $key => $value) { if ($value instanceof Document_Tag_Video) { //with video can't use frontend(), it includes random id $d["element_" . $key] = $value->getName() . ":" . $value->type . "_" . $value->id; } else { if (!$value instanceof Document_Tag_Block) { $d["element_" . $key] = $value->getName() . ":" . $value->frontend(); } else { $d["element_" . $key] = $value->getName(); } } } if ($document instanceof Document_Page) { $d["name"] = $document->getName(); $d["keywords"] = $document->getKeywords(); $d["title"] = $document->getTitle(); $d["description"] = $document->getDescription(); } $d["published"] = $document->isPublished(); } if ($document instanceof Document_Link) { $d['link'] = $document->getHtml(); } if (!$ignoreCopyDifferences) { $d["key"] = $document->getKey(); $d["id"] = $document->getId(); $d["modification"] = $document->getModificationDate(); $d["creation"] = $document->getCreationDate(); $d["userModified"] = $document->getUserModification(); $d["parentId"] = $document->getParentId(); $d["path"] = $document->getPath(); } $d["userOwner"] = $document->getUserOwner(); $properties = $document->getProperties(); $d = array_merge($d, self::createPropertiesComparisonString($properties)); return implode(",", $d); } else { return null; } }
/** * Show a form for editing an entry * * @return void */ public function editTask() { // Check if they are logged in if (User::isGuest()) { $url = Request::getVar('REQUEST_URI', '', 'server'); App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($url))); return; } // Check if the page is locked and the user is authorized if ($this->page->get('state') == 1 && !$this->page->access('manage')) { App::redirect(Route::url($this->page->link()), Lang::txt('COM_WIKI_WARNING_NOT_AUTH_EDITOR'), 'warning'); return; } // Check if the page is group restricted and the user is authorized if (!$this->page->access('edit') && !$this->page->access('modify')) { App::redirect(Route::url($this->page->link()), Lang::txt('COM_WIKI_WARNING_NOT_AUTH_EDITOR'), 'warning'); return; } $this->view->setLayout('edit'); // Load the page $ischild = false; if ($this->page->get('id') && $this->_task == 'new') { $this->page->set('id', 0); $ischild = true; } // Get the most recent version for editing if (!is_object($this->revision)) { $this->revision = $this->page->revision('current'); //getCurrentRevision(); $this->revision->set('created_by', User::get('id')); $this->revision->set('summary', ''); } // If an existing page, pull its tags for editing if (!$this->page->exists()) { $this->page->set('access', 0); $this->page->set('created_by', User::get('id')); if ($this->_group) { $this->page->set('group_cn', $this->_group); $this->page->set('scope', $this->_group . '/' . $this->_sub); } if ($ischild && $this->page->get('pagename')) { $this->revision->set('pagetext', ''); $this->page->set('scope', $this->page->get('scope') . ($this->page->get('scope') ? '/' . $this->page->get('pagename') : $this->page->get('pagename'))); $this->page->set('pagename', ''); $this->page->set('title', Lang::txt('COM_WIKI_NEW_PAGE')); } } $this->view->tags = trim(Request::getVar('tags', $this->page->tags('string'), 'post')); $this->view->authors = trim(Request::getVar('authors', $this->page->authors('string'), 'post')); // Prep the pagename for display // e.g. "MainPage" becomes "Main Page" $this->view->title = trim($this->page->get('title')) ? $this->page->get('title') : Lang::txt('COM_WIKI_NEW_PAGE'); // Set the page's <title> tag if ($this->_sub) { Document::setTitle(Document::getTitle() . ': ' . $this->view->title); } else { Document::setTitle(Lang::txt(strtoupper($this->_option)) . ': ' . $this->view->title . ': ' . Lang::txt(strtoupper($this->_option . '_' . $this->_task))); } // Set the pathway if (Pathway::count() <= 0) { Pathway::append(Lang::txt(strtoupper($this->_option)), 'index.php?option=' . $this->_option . '&controller=' . $this->_controller); } if (!$this->_sub) { Pathway::append($this->view->title, $this->page->link()); Pathway::append(Lang::txt(strtoupper($this->_option . '_' . $this->_task)), $this->page->link() . '&task=' . $this->_task); } $this->view->preview = NULL; // Are we previewing? if ($this->preview) { // Yes - get the preview so we can parse it and display $this->view->preview = $this->preview; $pageid = $this->page->get('id'); $lid = Request::getInt('lid', 0, 'post'); if ($lid != $this->page->get('id')) { $pageid = $lid; } // Parse the HTML $wikiconfig = array('option' => $this->_option, 'scope' => $this->page->get('scope'), 'pagename' => $this->page->exists() ? $this->page->get('pagename') : 'Tmp:' . $pageid, 'pageid' => $pageid, 'filepath' => '', 'domain' => $this->_group); $p = Parser::getInstance(); $this->revision->set('pagehtml', $p->parse($this->revision->get('pagetext'), $wikiconfig, true, true)); } $this->view->sub = $this->_sub; $this->view->base_path = $this->_base_path; $this->view->message = $this->_message; $this->view->page = $this->page; $this->view->book = $this->book; $this->view->revision = $this->revision; // Pull a tree of pages in this wiki $items = $this->book->pages('list', array('group' => $this->_group, 'sortby' => 'pagename ASC, scope ASC', 'state' => array(0, 1))); $tree = array(); if ($items) { foreach ($items as $k => $branch) { // Since these will be parent pages, we need to add the item's pagename to the scope $branch->set('scope', $branch->get('scope') ? $branch->get('scope') . '/' . $branch->get('pagename') : $branch->get('pagename')); $branch->set('scopeName', $branch->get('scope')); // Strip the group name from the beginning of the scope for display. if ($this->_group) { $branch->set('scopeName', substr($branch->get('scope'), strlen($this->_group . '/wiki/'))); } // Push the item to the tree $tree[$branch->get('scope')] = $branch; } ksort($tree); } $this->view->tree = $tree; //$items; $this->view->tplate = trim(Request::getVar('tplate', '')); foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->display(); }
} ?> <form action="#" method="POST"> <input type="hidden" id="id" name="id" value="<?php echo $document->getID(); ?> " /> <input type="hidden" id="assignees" name="assignees" value="<?php echo $assignees; ?> " /> <table> <tr> <th><label for="subject">Title:</label></th> <td><input type="text" id="subject" name="subject" value="<?php echo $document->getTitle(); ?> " required /></td> </tr> <tr> <th><label for="clearance">Clearance:</label></th> <td> <select id="clearance" name="clearance"> <?php foreach (SecurityClearance::getAllClearances() as $val => $name) { if ($val != 0) { if ($document->getClearance()->getClearance() == $val) { echo '<option value=' . $val . ' selected>' . $name . '</option>'; } else { echo '<option value=' . $val . '>' . $name . '</option>'; }
/** * Perform actions when viewing a member profile * * @param object $user Current user * @param object $member Current member page * @param string $option Start of records to pull * @param array $areas Active area(s) * @return array */ public function onMembers($user, $member, $option, $areas) { $returnhtml = true; // Check if our area is in the array of areas we want to return results for if (is_array($areas)) { if (!array_intersect($areas, $this->onMembersAreas($user, $member)) && !array_intersect($areas, array_keys($this->onMembersAreas($user, $member)))) { $returnhtml = false; } } $arr = array('html' => '', 'metadata' => ''); // Include models require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'models' . DS . 'project.php'; include_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'models' . DS . 'todo.php'; // Get our models $this->todo = new \Components\Projects\Models\Todo(); $this->model = new \Components\Projects\Models\Project(); // Get member projects $this->projects = $this->model->table()->getUserProjectIds($member->get('id')); // Build filters $this->filters = array('projects' => $this->projects, 'limit' => $this->params->get('limit', 50), 'start' => 0, 'mine' => Request::getInt('mine', 0), 'sortby' => Request::getWord('sortby', 'due'), 'sortdir' => Request::getWord('sortdir', 'ASC'), 'assignedto' => Request::getInt('mine', 0) ? $member->get('id') : 0, 'state' => Request::getInt('state', 0)); if ($returnhtml) { $this->user = $user; $this->member = $member; $this->option = $option; $this->database = App::get('db'); $this->params = \Hubzero\Plugin\Params::getParams($this->member->get('id'), 'members', $this->_name); if ($user->get('id') == $member->get('id')) { $this->params->set('access-edit-comment', true); $this->params->set('access-delete-comment', true); } // Append to document the title Document::setTitle(Document::getTitle() . ': ' . Lang::txt('PLG_MEMBERS_TODO')); // Get and determine task $this->task = Request::getVar('action', ''); switch ($this->task) { case 'browse': default: $arr['html'] = $this->_browse(); break; case 'new': $arr['html'] = $this->_new(); break; case 'save': $arr['html'] = $this->_save(); break; } } // Get an entry count $arr['metadata']['count'] = $this->todo->entries('count', $this->filters); return $arr; }
$base .= '&' . ($this->resource->alias ? 'alias=' . $this->resource->alias : 'id=' . $this->resource->id); $active_key = Request::get('tab_active_key', null) ? Request::get('tab_active_key') : 'active'; ?> <ul id="sub-menu" class="sub-menu"> <?php foreach ($this->cats as $cat) { $name = key($cat); if (!$name) { continue; } $active = false; $url = $base . '&' . $active_key . '=' . $name; if (strtolower($name) == $this->active) { Pathway::append($cat[$name], $url); if ($active != 'about') { Document::setTitle(Document::getTitle() . ': ' . $cat[$name]); } $active = true; } ?> <li id="sm-<?php echo $name; ?> "<?php echo $active ? ' class="active"' : ''; ?> > <a class="tab" data-rel="<?php echo $name; ?> " href="<?php
/** * Perform actions when viewing a member profile * * @param object $user Current user * @param object $member Current member page * @param string $option Start of records to pull * @param array $areas Active area(s) * @return array */ public function onMembers($user, $member, $option, $areas) { $returnhtml = true; // Check if our area is in the array of areas we want to return results for if (is_array($areas)) { if (!array_intersect($areas, $this->onMembersAreas($user, $member)) && !array_intersect($areas, array_keys($this->onMembersAreas($user, $member)))) { $returnhtml = false; } } $arr = array('html' => '', 'metadata' => ''); include_once PATH_CORE . DS . 'components' . DS . 'com_blog' . DS . 'models' . DS . 'archive.php'; // Get our model $this->model = new \Components\Blog\Models\Archive('member', $member->get('id')); if ($returnhtml) { $this->user = $user; $this->member = $member; $this->option = $option; //$this->authorized = $authorized; $this->database = App::get('db'); $this->params = \Hubzero\Plugin\Params::getParams($this->member->get('id'), 'members', $this->_name); if ($user->get('id') == $member->get('id')) { $this->params->set('access-edit-comment', true); $this->params->set('access-delete-comment', true); } // Append to document the title Document::setTitle(Document::getTitle() . ': ' . Lang::txt('PLG_MEMBERS_BLOG')); // Get and determine task $this->task = Request::getVar('action', ''); if (!($task = Request::getVar('action', '', 'post'))) { $bits = $this->_parseUrl(); if ($this->task != 'deletecomment') { $num = count($bits); switch ($num) { case 3: $this->task = 'entry'; break; case 2: case 1: if (is_numeric($bits[0])) { $this->task = 'browse'; } break; } } } else { $this->task = $task; } switch ($this->task) { // Feeds case 'feed.rss': $this->_feed(); break; case 'feed': $this->_feed(); break; //case 'comments.rss': $this->_commentsFeed(); break; //case 'comments': $this->_commentsFeed(); break; // Settings //case 'comments.rss': $this->_commentsFeed(); break; //case 'comments': $this->_commentsFeed(); break; // Settings case 'savesettings': $arr['html'] = $this->_savesettings(); break; case 'settings': $arr['html'] = $this->_settings(); break; // Comments // Comments case 'savecomment': $arr['html'] = $this->_savecomment(); break; case 'newcomment': $arr['html'] = $this->_newcomment(); break; case 'editcomment': $arr['html'] = $this->_entry(); break; case 'deletecomment': $arr['html'] = $this->_deletecomment(); break; // Entries // Entries case 'save': $arr['html'] = $this->_save(); break; case 'new': $arr['html'] = $this->_new(); break; case 'edit': $arr['html'] = $this->_edit(); break; case 'delete': $arr['html'] = $this->_delete(); break; case 'entry': $arr['html'] = $this->_entry(); break; case 'archive': case 'browse': default: $arr['html'] = $this->_browse(); break; } } // Build filters $filters = array('scope' => 'member', 'scope_id' => $member->get('id'), 'state' => 1, 'access' => User::getAuthorisedViewLevels()); if (User::get('id') == $member->get('id')) { $filters['access'][] = 5; $filters['authorized'] = true; } // Get an entry count $arr['metadata']['count'] = $this->model->entries($filters)->count(); return $arr; }
/** * Show a form for editing an entry * * @param object $revision * @return void */ public function editTask($revision = null) { // Check if they are logged in if (User::isGuest()) { $url = Request::getVar('REQUEST_URI', '', 'server'); App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode($url), false)); } // Check if the page is locked and the user is authorized if ($this->page->isLocked() && !$this->page->access('manage')) { App::redirect(Route::url($this->page->link()), Lang::txt('COM_WIKI_WARNING_NOT_AUTH_EDITOR'), 'warning'); } // Check if the page is restricted and the user is authorized if (!$this->page->access('edit') && !$this->page->access('modify')) { App::redirect(Route::url($this->page->link()), Lang::txt('COM_WIKI_WARNING_NOT_AUTH_EDITOR'), 'warning'); } // Load the page $ischild = false; if ($this->page->get('id') && $this->_task == 'new') { $this->page->set('parent', $this->page->get('id')); $this->page->set('id', 0); $ischild = true; } if (!$this->page->get('id') && $this->page->get('path')) { $parent = Page::oneByPath($this->page->get('path'), $this->page->get('scope'), $this->page->get('scope_id')); $this->page->set('parent', $parent->get('id')); } // Get the most recent version for editing if (!is_object($revision)) { $revision = $this->page->version; $revision->set('created_by', User::get('id')); $revision->set('summary', ''); } // If an existing page, pull its tags for editing if (!$this->page->exists()) { $this->page->set('access', 0); $this->page->set('created_by', User::get('id')); $this->page->set('scope', $this->book->get('scope')); $this->page->set('scope_id', $this->book->get('scope_id')); if ($ischild && $this->page->get('pagename')) { $revision->set('pagetext', ''); $this->page->set('path', $this->page->get('path') . ($this->page->get('path') ? '/' : '') . $this->page->get('pagename')); $this->page->set('pagename', ''); $this->page->set('title', Lang::txt('COM_WIKI_NEW_PAGE')); } } $tags = trim(Request::getVar('tags', $this->page->tags('string'), 'post')); //$authors = trim(Request::getVar('authors', $this->page->authors('string'), 'post')); // Set the page's <title> tag if ($this->page->get('scope') == 'site') { Document::setTitle(Lang::txt('COM_WIKI')); } Document::setTitle(Document::getTitle() . ': ' . $this->page->title . ': ' . Lang::txt(strtoupper($this->_option . '_' . $this->_task))); // Set the pathway if (Pathway::count() <= 0) { Pathway::append(Lang::txt(strtoupper($this->_option)), 'index.php?option=' . $this->_option . '&controller=' . $this->_controller); } Pathway::append($this->page->title, $this->page->link()); Pathway::append(Lang::txt(strtoupper($this->_option . '_' . $this->_task)), $this->page->link() . '&task=' . $this->_task); // Are we previewing? if ($this->preview) { $pageid = $this->page->get('id'); $lid = Request::getInt('lid', 0, 'post'); $pagename = $this->page->get('pagename'); if ($lid != $this->page->get('id')) { $this->page->set('id', $lid); } $this->page->set('pagename', $this->page->exists() ? $this->page->get('pagename') : 'Tmp:' . $pageid); $revision->set('pagehtml', $revision->content($this->page)); $this->page->set('id', $pageid); $this->page->set('pagename', $pagename); } // Pull a tree of pages in this wiki $items = $this->book->pages()->whereEquals('state', Page::STATE_PUBLISHED)->where('namespace', '!=', 'Template')->order('pagename', 'asc')->rows(); $tree = array(); if ($items) { foreach ($items as $k => $branch) { // Since these will be parent pages, we need to add the item's pagename to the scope $branch->set('pagename', ($branch->get('path') ? $branch->get('path') . '/' : '') . $branch->get('pagename')); // Push the item to the tree $tree[$branch->get('pagename')] = $branch; } ksort($tree); } $this->view->set('book', $this->book)->set('page', $this->page)->set('revision', $revision)->set('sub', $this->page->get('scope') != 'site')->set('tree', $tree)->set('tags', $tags)->set('preview', $this->preview)->set('base_path', $this->_base_path)->setErrors($this->getErrors())->setLayout('edit')->display(); }