/**
  * Constructor
  *
  * @param   integer  $referenceid  Scope ID (group, course, etc.)
  * @return  void
  */
 public function __construct($referenceid = 0)
 {
     $this->set('referenceid', $referenceid)->set('category', 'publication')->set('option', $this->_segments['option']);
     $database = \App::get('db');
     $objP = new \Components\Publications\Tables\Publication($database);
     $this->_item = $objP->getPublication($referenceid, 'default');
     //$this->_segments['id']     = $this->_item->id;
     $this->_segments['active'] = 'wishlist';
 }
 /**
  * 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;
 }
Beispiel #3
0
 /**
  * Edit citation view
  *
  * @return     string
  */
 public function editcite()
 {
     // Incoming
     $cid = Request::getInt('cid', 0);
     $pid = Request::getInt('pid', 0);
     $vid = Request::getInt('vid', 0);
     // Output HTML
     $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'links', 'name' => 'selector', 'layout' => 'edit'));
     // Load classes
     $objP = new \Components\Publications\Tables\Publication($this->_database);
     $view->version = new \Components\Publications\Tables\Version($this->_database);
     // Load publication version
     $view->version->load($vid);
     if (!$view->version->id) {
         $this->setError(Lang::txt('PLG_PROJECTS_LINKS_SELECTOR_ERROR_NO_PUBID'));
     }
     // Get publication
     $view->publication = $objP->getPublication($view->version->publication_id, $view->version->version_number, $this->model->get('id'));
     if (!$view->publication) {
         $this->setError(Lang::txt('PLG_PROJECTS_LINKS_SELECTOR_ERROR_NO_PUBID'));
     }
     // On error
     if ($this->getError()) {
         // Output error
         $view = new \Hubzero\Plugin\View(array('folder' => 'projects', 'element' => 'files', 'name' => 'error'));
         $view->title = '';
         $view->option = $this->_option;
         $view->setError($this->getError());
         return $view->loadTemplate();
     }
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'type.php';
     include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'tables' . DS . 'citation.php';
     // Load the object
     $view->row = new \Components\Citations\Tables\Citation($this->_database);
     $view->row->load($cid);
     // get the citation types
     $ct = new \Components\Citations\Tables\Type($this->_database);
     $view->types = $ct->getType();
     $view->option = $this->_option;
     $view->database = $this->_database;
     $view->model = $this->model;
     $view->uid = $this->_uid;
     $view->task = $this->_task;
     $view->ajax = Request::getInt('ajax', 0);
     // Get messages	and errors
     if ($this->getError()) {
         $view->setError($this->getError());
     }
     return $view->loadTemplate();
 }