complete = false; $this -> error=false; $this -> publicationId = JRequest :: getString('activePublicationId'); $publicationId = JRequest :: getString('publicationId'); $this -> linkType = JRequest :: getString('isDataset') ; $this -> sourceType = JRequest :: getString('sourceType') ; $user = JFactory :: getUser(); $this -> itemId = JRequest :: getUInt('Itemid', 0); $this -> newPublication = JRequest :: getString('newPublication'); $this -> newPublication = ($this -> newPublication == 'true'); $this -> source = JRequest :: getString('source', self :: OPENAIRE); $redirectUrl='index.php?option=com_openaire&view=claiminline2&isDataset='.$this -> linkType.'&sourceType='.$this -> sourceType.'&action=clear&activePublicationId=' . $this -> publicationId . '&tmpl=modal&Itemid=' . $this -> itemId . '&source=' . $this -> source. '&newPublication='.$this -> newPublication ; if (JFactory :: getUser() -> guest) { JFactory :: getApplication() -> redirect(JRoute :: _(JUri :: base() . 'index.php?option=com_users&view=login&tmpl=modal&isDataset='. $this -> linkType.'&activePublicationId=' . $this -> publicationId . '&Itemid=' . $this -> itemId . '&return=' . base64_encode(JRoute :: _(JUri :: base() . $redirectUrl, FALSE)), FALSE)); return TRUE; } $claimModel = $this -> getModel(self :: CLAIM_MODEL); $searchModel = $this -> getModel(self :: SEARCH_MODEL); $application = JFactory :: getApplication(); $this -> keyword = JRequest :: getString('keyword'); $this -> page = JRequest :: getUInt('page', self :: PAGE); $this -> size = JRequest :: getUInt('size', self :: SIZE); $locale = JFactory :: getLanguage() -> getTag(); $publicationSource = JRequest :: getString('publicationSource'); $projectId = JRequest :: getString('projectId'); $conceptId = JRequest :: getString('conceptId'); if ($this -> keyword != NULL) { switch ($this -> source) { case self :: OPENAIRE: $this -> result = $searchModel -> searchPublications($this -> keyword, FALSE, FALSE, FALSE, FALSE, NULL, NULL, NULL, NULL,NULL, NULL, NULL, NULL, NULL, NULL, $this -> page, $this -> size, $locale,FALSE); break; case self :: DOI: $this -> result = $claimModel -> searchDOI($this -> keyword, $this -> page, $this -> size); break; case self :: ORCID: $this -> result = $claimModel -> searchORCID($this -> keyword, $this -> page, $this -> size); break; case self :: DATACITE: $this -> result = $claimModel -> searchDataCite($this -> keyword, $this -> page, $this -> size); break; } $this -> totalPages = ($this -> result == NULL) ? NULL : ceil((isset($this -> result -> totalPublications) ? $this -> result -> totalPublications : $this -> result -> totalDatasets) / $this -> size); if ($this -> totalPages == NULL) $this -> totalPages = 1; $this -> page = ($this -> page > $this -> totalPages)? $this -> totalPages:$this -> page; $this -> pagingStart = $this -> page; $this -> pagingEnd = $this -> page; while (($this -> pagingEnd - $this -> pagingStart < self :: MAX_PAGES - 1) && (($this -> pagingStart != 1) || ($this -> pagingEnd != $this -> totalPages))) { if ($this -> pagingStart > 1) $this -> pagingStart --; if ($this -> pagingEnd < $this -> totalPages) $this -> pagingEnd++; } } switch (JRequest :: getString('action')) { case self :: SUBMIT: if($this -> sourceType==='dataset'){ $publication = $searchModel->getDataset($this -> publicationId, $locale); }else{ $publication = $searchModel->getPublication($this -> publicationId, $locale); } if($publication==null){ $this -> error= true; $this -> complete = true; parent :: display($template); return TRUE; } $this -> error= $claimModel->claimSelectedPublications($user, OpenAireModelClaim::CLAIMINLINE2, $publication, $this -> publicationId,$this -> sourceType); $this -> complete = true; parent :: display($template); return TRUE; case self :: ADD_PUBLICATION: if (($publicationId != NULL) && ($this -> result != NULL)) { if (isset($this -> result -> totalPublications) && ($this -> result -> totalPublications != 0)) { foreach ($this -> result -> publications as $publication) { if ($publication -> id == $publicationId) { $publication -> claim_type = "publication"; $publication -> source = $this -> source; $claimModel -> addSelectedPublication($publication, OpenAireModelClaim::CLAIMINLINE2 . $this->publicationId); $application -> redirect(JRoute :: _(JUri :: base() . 'index.php?option=com_openaire&view=claiminline2&isDataset='.$this -> linkType.'&sourceType='.$this -> sourceType.'&activePublicationId=' . $this -> publicationId . '&tmpl=modal&Itemid=' . $this -> itemId . '&source=' . $this -> source . '&keyword=' . $this -> keyword . '&page=' . $this -> page . '&newPublication=true', FALSE)); return TRUE; } } } else if (isset($this -> result -> totalDatasets) && ($this -> result -> totalDatasets != 0)) { foreach ($this -> result -> datasets as $dataset) { if ($dataset -> id == $publicationId) { $dataset -> claim_type = "dataset"; $dataset -> source = $this -> source; $claimModel -> addSelectedPublication($dataset, OpenAireModelClaim::CLAIMINLINE2 . $this->publicationId); $application -> redirect(JRoute :: _(JUri :: base() . 'index.php?option=com_openaire&view=claiminline2&isDataset='.$this -> linkType.'&sourceType='.$this -> sourceType.'&tmpl=modal&activePublicationId=' . $this -> publicationId . '&Itemid=' . $this -> itemId . '&source=' . $this -> source . '&keyword=' . $this -> keyword . '&page=' . $this -> page . '&newPublication=true', FALSE)); return TRUE; } } } } $application -> redirect(JRoute :: _(JUri :: base() . 'index.php?option=com_openaire&view=claiminline2&isDataset='.$this -> linkType.'&sourceType='.$this -> sourceType.'&Itemid=' . $this -> itemId . '&source=' . $this -> source . '&keyword=' . $this -> keyword . '&page=' . $this -> page, FALSE)); return TRUE; case self :: REMOVE_PUBLICATION: $claimModel -> removeSelectedPublication($publicationSource, $publicationId, OpenAireModelClaim::CLAIMINLINE2 . $this->publicationId ); $application -> redirect(JRoute :: _(JUri :: base() . 'index.php?option=com_openaire&view=claiminline2&isDataset='.$this -> linkType.'&sourceType='.$this -> sourceType.'&tmpl=modal&Itemid=' . $this -> itemId . '&source=' . $this -> source . '&keyword=' . $this -> keyword . '&page=' . $this -> page, FALSE)); return TRUE; case self :: REMOVE_PROJECT: $claimModel -> removeSelectedProject($projectId); $application -> redirect(JRoute :: _(JUri :: base() . 'index.php?option=com_openaire&view=claiminline2&isDataset='.$this -> linkType.'&sourceType='.$this -> sourceType.'&Itemid=' . $this -> itemId . '&source=' . $this -> source . '&keyword=' . $this -> keyword . '&page=' . $this -> page, FALSE)); return TRUE; case self :: REMOVE_CONCEPT: $claimModel -> removeSelectedConcept($conceptId); $application -> redirect(JRoute :: _(JUri :: base() . 'index.php?option=com_openaire&view=claiminline2&isDataset='.$this -> linkType.'&sourceType='.$this -> sourceType.'&Itemid=' . $this -> itemId . '&source=' . $this -> source . '&keyword=' . $this -> keyword . '&page=' . $this -> page, FALSE)); return TRUE; case self :: CLEAR: $claimModel->emptySelectedPublications(OpenAireModelClaim::CLAIMINLINE2 . $this->publicationId); } $this -> selectedProjects = array(); $this -> selectedConcepts = array(); /*if ($this -> selectedProjects == NULL && $this -> selectedConcepts == NULL) { $application -> redirect(JRoute :: _(JUri :: base() . 'index.php?option=com_openaire&view=claim1&Itemid=' . $this -> itemId, FALSE)); return TRUE; }*/ $this -> selectedPublications = $claimModel -> getSelectedPublications(OpenAireModelClaim :: CLAIMINLINE2 . $this->publicationId); if (count($errors = $this -> get('Errors')) > 0) { JLog :: add('Error viewing claiminline2: ' . implode("\n", $errors), JLog :: ERROR, self :: LOG); return FALSE; } parent :: display($template); } }