/** * Serve wiki page (usually via public link) * * @param int $projectid * @return void */ public function serve($type = '', $projectid = 0, $query = '') { $this->_area = $this->onProjectAreas(); if ($type != $this->_area['name']) { return false; } $data = json_decode($query); if (!isset($data->pageid) || !$projectid) { return false; } $this->loadLanguage(); $database = App::get('db'); $this->_option = 'com_projects'; // Instantiate a project $this->model = new \Components\Projects\Models\Project($projectid); if (!$this->model->exists()) { return false; } $groupname = $this->model->config()->get('group_prefix', 'pr-') . $this->model->get('alias'); $scope = 'projects' . DS . $this->model->get('alias') . DS . 'notes'; // Include note model include_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'models' . DS . 'note.php'; // Get our model $this->note = new \Components\Projects\Models\Note($scope, $groupname, $projectid); // Fix pathway (com_wiki screws it up) $this->fixupPathway(); // Load requested page $page = $this->note->page($data->pageid); if (!$page->get('id')) { return false; } // Write title & build pathway Document::setTitle(Lang::txt(strtoupper($this->_option)) . ': ' . stripslashes($this->model->get('title')) . ' - ' . stripslashes($page->get('title'))); // Instantiate a new view $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'notes', 'name' => 'pubview')); $view->option = $this->_option; $view->model = $this->model; $view->page = $page; $view->revision = $page->revision('current'); $view->masterscope = 'projects' . DS . $this->model->get('alias') . DS . 'notes'; // Output HTML if ($this->getError()) { $view->setError($this->getError()); } $view->display(); return true; }
/** * Rate an item * * @return void */ public function rateitem() { $database = App::get('db'); $publication =& $this->publication; $id = Request::getInt('refid', 0); $ajax = Request::getInt('no_html', 0); $cat = Request::getVar('category', 'pubreview'); $vote = Request::getVar('vote', ''); $ip = Request::ip(); if (!$id || !$publication->exists()) { // Cannot proceed return; } // Is the user logged in? if (User::isGuest()) { $this->setError(Lang::txt('PLG_PUBLICATIONS_REVIEWS_LOGIN_NOTICE')); return; } // Load answer $rev = new \Components\Publications\Tables\Review($database); $rev->load($id); $voted = $rev->getVote($id, $cat, User::get('id'), 'v.id'); if ($vote) { require_once PATH_CORE . DS . 'components' . DS . 'com_answers' . DS . 'tables' . DS . 'vote.php'; $v = new \Components\Answers\Tables\Vote($database); if ($voted) { $v->load($voted); } $v->referenceid = $id; $v->category = $cat; $v->voter = User::get('id'); $v->ip = $ip; $v->voted = Date::toSql(); $v->helpful = $vote; if (!$v->check()) { $this->setError($v->getError()); return; } if (!$v->store()) { $this->setError($v->getError()); return; } } // update display if ($ajax) { $response = $rev->getRating($publication->get('id'), User::get('id')); $view = new \Hubzero\Plugin\View(array('folder' => 'publications', 'element' => 'reviews', 'name' => 'browse', 'layout' => '_rateitem')); $view->option = $this->_option; $view->item = new PublicationsModelReview($response[0]); $view->rid = $publication->get('id'); $view->display(); exit; } App::redirect(Route::url($publication->get('reviews'))); }
$params = $element->params; $max = $params->max; $min = $params->min; ?> <input type="hidden" id="maxitems" name="maxitems" value="<?php echo $max; ?> " /> <input type="hidden" id="minitems" name="minitems" value="<?php echo $min; ?> " /> <?php // Show selection $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => 'selector', 'layout' => $this->block)); $view->option = $this->option; $view->project = $this->project; $view->database = $this->database; $view->manifest = $manifest; $view->publication = $this->publication; $view->url = Route::url($this->publication->link('edit')); $view->display(); $task = 'apply'; } ?> <input type="hidden" name="action" value="<?php echo $task; ?> " /> </form> </div>
/** * Include status bar - publication steps/sections/version navigation * * @return array */ public static function drawStatusBar($item, $step = NULL, $showSubSteps = false, $review = 0) { $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => 'edit', 'layout' => 'statusbar')); $view->row = $item->row; $view->version = $item->version; $view->panels = $item->panels; $view->active = isset($item->active) ? $item->active : NULL; $view->move = isset($item->move) ? $item->move : 0; $view->step = $step; $view->lastpane = $item->lastpane; $view->option = $item->option; $view->project = $item->project; $view->current_idx = $item->current_idx; $view->last_idx = $item->last_idx; $view->checked = $item->checked; $view->url = $item->url; $view->review = $review; $view->show_substeps = $showSubSteps; $view->display(); }
/** * Rate an item * * @return void */ public function rateitem() { $id = Request::getInt('refid', 0); $ajax = Request::getInt('no_html', 0); $cat = Request::getVar('category', 'review'); $vote = Request::getVar('vote', ''); $ip = Request::ip(); $rid = Request::getInt('id', 0); if (!$id) { // Cannot proceed return; } // Is the user logged in? if (User::isGuest()) { $this->setError(Lang::txt('PLG_RESOURCES_REVIEWS_PLEASE_LOGIN_TO_VOTE')); return; } // Load entry $rev = \Components\Resources\Reviews\Models\Review::oneOrNew($id); if (!$rev->vote($vote, User::get('id'), $ip)) { $this->setError($rev->getError()); return; } // update display if ($ajax) { $rev->set('vote', $vote); $rev->set('helpful', $rev->votes()->whereEquals('vote', 1)->total()); $rev->set('nothelpful', $rev->votes()->whereEquals('vote', -1)->total()); $view = new \Hubzero\Plugin\View(array('folder' => 'resources', 'element' => 'reviews', 'name' => 'browse', 'layout' => '_rateitem')); $view->option = $this->_option; $view->item = $rev; $view->display(); exit; } App::redirect(Route::url('index.php?option=' . $this->_option . '&id=' . $rid . '&active=reviews', false)); }
/** * Return data on a resource view (this will be some form of HTML) * * @param object $resource Current resource * @param string $option Name of the component * @param array $areas Active area(s) * @param string $rtrn Data to be returned * @return array */ public function onResources($model, $option, $areas, $rtrn = 'all') { if (!$model->type->params->get('plg_share')) { return; } $arr = array('area' => $this->_name, 'html' => '', 'metadata' => ''); $sef = Route::url('index.php?option=' . $option . '&id=' . $model->resource->id); $url = Request::base() . ltrim($sef, '/'); // Incoming action $sharewith = Request::getVar('sharewith', ''); if ($sharewith && $sharewith != 'email') { $this->share($sharewith, $url, $model->resource); return; } // Email form if ($sharewith == 'email') { // Instantiate a view $view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'options', 'layout' => 'email')); // Pass the view some info $view->option = $option; $view->resource = $model->resource; $view->_params = $this->params; $view->url = $url; foreach ($this->getErrors() as $error) { $view->setError($error); } // Return the output $view->display(); exit; } // Build the HTML meant for the "about" tab's metadata overview if ($rtrn == 'all' || $rtrn == 'metadata') { // Instantiate a view $view = new \Hubzero\Plugin\View(array('folder' => $this->_type, 'element' => $this->_name, 'name' => 'options')); // Pass the view some info $view->option = $option; $view->resource = $model->resource; $view->_params = $this->params; $view->url = $url; foreach ($this->getErrors() as $error) { $view->setError($error); } // Return the output $arr['metadata'] = $view->loadTemplate(); } return $arr; }
/** * Draw publication draft status bar * * @return string HTML */ public function drawStatusBar() { if (!$this->_progress) { return false; } $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'publications', 'name' => 'draft', 'layout' => 'statusbar')); $view->pub = $this->_pub; $view->progress = $this->_progress; $view->active = $this->_blockname; $view->activenum = $this->_blockorder; $view->database = $this->_db; $view->display(); }