/** * Return data on a resource view (this will be some form of HTML) * * @param object $publication Current publication * @param string $option Name of the component * @param array $areas Active area(s) * @param string $rtrn Data to be returned * @param string $version Version name * @param boolean $extended Whether or not to show panel * @return array */ public function onPublication($publication, $option, $areas, $rtrn = 'all', $version = 'default', $extended = true, $authorized = true) { $arr = array('html' => '', 'metadata' => ''); // 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->onPublicationAreas($publication)) && !array_intersect($areas, array_keys($this->onPublicationAreas($publication)))) { // do nothing return $arr; } } if (!$publication->_category->_params->get('plg_supportingdocs')) { return $arr; } // Are we returning HTML? if ($rtrn == 'all' || $rtrn == 'html') { $database = App::get('db'); $config = Component::params($option); // Instantiate a view $view = new \Hubzero\Plugin\View(array('folder' => 'publications', 'element' => 'supportingdocs', 'name' => 'browse')); // Get docs $pContent = new \Components\Publications\Tables\Attachment($database); $view->docs = $pContent->getAttachments($publication->version_id, $filters = array('role' => array(1, 0, 2), 'order' => 'a.role DESC, a.ordering ASC')); // Get projects html helper require_once PATH_CORE . DS . 'components' . DS . 'com_projects' . DS . 'helpers' . DS . 'html.php'; // Build publication path $base_path = $config->get('webpath'); $view->path = \Components\Publications\Helpers\Html::buildPubPath($publication->id, $publication->version_id, $base_path, $publication->secret, $root = 1); // Pass the view some info $view->option = $option; $view->publication = $publication; $view->config = $config; $view->version = $version; $view->live_site = Request::base(); $view->authorized = $authorized; if ($this->getError()) { $view->setError($this->getError()); } // Return the output $arr['html'] = $view->loadTemplate(); } return $arr; }
/** * List project notes available for publishing * * @return array */ public function browser() { // Incoming $ajax = Request::getInt('ajax', 0); $primary = Request::getInt('primary', 1); $versionid = Request::getInt('versionid', 0); if (!$ajax) { return false; } // Output HTML $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'notes', 'name' => 'browser')); // Get current attachments $pContent = new \Components\Publications\Tables\Attachment($this->_database); $role = $primary ? '1' : '0'; $other = $primary ? '0' : '1'; $view->attachments = $pContent->getAttachments($versionid, $filters = array('role' => $role, 'type' => 'note')); // Output HTML $view->params = $this->model->params; $view->option = $this->_option; $view->database = $this->_database; $view->model = $this->model; $view->uid = $this->_uid; $view->config = $this->_config; $view->title = $this->_area['title']; $view->primary = $primary; $view->versionid = $versionid; // Get messages and errors if ($this->getError()) { $view->setError($this->getError()); } $html = $view->loadTemplate(); $arr = array('html' => $html, 'metadata' => ''); return $arr; }
/** * Sets the fields in this class with database data. * * @return boolean True if succss and False otherwise */ private function populateRDFData() { // Grabs database object $database = \App::get('db'); $resource = new \Components\Publications\Tables\Version($database); $resource = $resource->getLastPubRelease($this->id); if (!$resource) { // Return if ID does not exist throw new Exception(Lang::txt('COM_PUBLICATIONS_FILE_NOT_FOUND'), 404); return false; } $this->setPaths(); // Gets the author name $this->author_id = $resource->created_by; $this->created_by = User::getInstance($this->author_id)->name; // Set created date $this->date_created = $this->formatDate($resource->created); // Set description $this->intro = $resource->description; // Set title $this->title = $resource->title; // Set last modified date $this->date_modified = $this->formatDate($resource->modified); // Set published date $this->date_published = $this->formatDate($resource->published_up); // Set version ID $this->version_id = $resource->id; // Load the $types variable. In the form of array([type_id] => [type_name]). $resource = new \Components\Publications\Tables\Publication($database); $pub = $resource->getPublication($this->id); $type_id = $pub->category; $typesData = new \Components\Publications\Tables\Category($database); $allTypes = $typesData->getCategories(array('state' => 'all')); $this->types = array(); foreach ($allTypes as $type) { $types[$type->id] = $type->name; } // Get the type name of this resource $this->type = $types[$type_id]; // Get attachments $pubAttach = new \Components\Publications\Tables\Attachment($database); $attachments = $pubAttach->getAttachments($this->version_id); foreach ($attachments as $child) { $this->aggregates[$child->id]['parent_id'] = $this->id; $this->aggregates[$child->id]['title'] = basename($child->path); $this->aggregates[$child->id]['created'] = $this->formatDate($child->created); $this->aggregates[$child->id]['standalone'] = 0; $this->aggregates[$child->id]['path'] = $child->path; $this->aggregates[$child->id]['url'] = $this->componentURL . $this->id . '/serve?a=' . $child->id; } return true; }