guest) { $redirectUrl = JRoute::_('index.php?option=com_user&view=login&return='.base64_encode(JRoute::_('index.php?option='.JRequest::getVar('option').'&view=claim1&Itemid='.JRequest::getVar('Itemid')))); JFactory::getApplication()->redirect($redirectUrl); } $document =& JFactory::getDocument(); $document->addCustomTag(''); $document->addStyleSheet(JRoute :: _(JURI :: base() . 'plugins/content/yoo_tooltip/yoo_tooltip.css.php')); $model = $this->getModel('claim'); $tipModel = $this->getModel('tooltip'); $action = JRequest::getVar('action'); $projectId = JRequest::getVar('projectId'); $redirect = true; switch ($action) { case "select": $selectedDoc = json_decode(base64_decode(JRequest::getVar('doc'))); $model->addSelectDocument($selectedDoc); break; case "unselect": $id = JRequest::getVar('id'); $model->unselectDocument($id); break; case 'reset': $model->reset(); break; case 'removeProject': $model->removeSelectedProject($projectId); break; default: $redirect = false; } if ($redirect) JFactory::getApplication()->redirect(JRoute :: _('index.php?option=' . JRequest :: getVar('option') . '&view=' . JRequest :: getVar('view') . '&Itemid=' . JRequest :: getVar('Itemid') . '&source=' . JRequest :: getVar('source', 'none') . '&searchTerm=' . JRequest :: getVar('searchTerm') . '&page=' . JRequest :: getVar('page'))); $source = JRequest::getVar('source', 'none'); switch ($source) { case 'doi': $doi = JRequest::getVar('searchTerm'); if ($doi != '') $doc = $model->identifyDoi($doi); else $doc = null; if ($doc != null) $docList = array($doc); else $docList = array(); $paging = false; break; case 'orcid': $orcidId = JRequest::getVar('searchTerm'); if ($orcidId != '') $docList = $model->identifyORCID($orcidId); else $docList = array(); $paging = false; break; case 'driver': $term = JRequest::getVar('searchTerm'); $page = JRequest::getVar('page'); $searchResults = $this->search($term, $page); $docList = $this->prepareDocs($searchResults); $paging = true; $this->assignRef('paging_pageCount', $searchResults['result']['numberOfPages']); break; } $this->assignRef('docs', $docList); $this->assignRef('paging', $paging); $this->assignRef('selectedDocs', $model->getSelectedDocuments()); $selectedProjects = $model->getSelectedProjects(); $this->assignRef('selectedProjects', $selectedProjects); foreach($selectedProjects as $id=>$info) { $scriptText = "window.addEvent('domready', function() {"; $scriptText .= $tipModel->createProjectInfoTooltip($info, $id); $scriptText .= "});"; $document->addScriptDeclaration($scriptText); } foreach ($model->getSelectedDocuments() as $i=>$doc) { $scriptText = "window.addEvent('domready', function() {"; $scriptText .= $tipModel->createDocumentTooltip($doc, "selected-".$i); $scriptText .= "});"; $document->addScriptDeclaration($scriptText); } foreach ($docList as $i=>$doc) { $scriptText = "window.addEvent('domready', function() {"; $scriptText .= $tipModel->createDocumentTooltip($doc, "identified-".$i); $scriptText .= "});"; $document->addScriptDeclaration($scriptText); } parent::display($tpl); } private function search($term, $page = 1) { $cache = & JFactory::getCache('com_openaire', 'callback'); $searchModel = $this->getModel('search'); $params = array('href'=>array(base64_encode('/web/Search.action?keyword='.urlencode($term).'&format=xml&includeForm=false&includeStats=false&constraint=ALL&size=10&fields=""&view=summary')), 'page' => array($page)); $conf =& JFactory::getConfig(); $cacheactive = $conf->getValue('config.caching'); $cache->setCaching(1); //enable caching $result = $cache->call(array($searchModel, 'search'), $params, '', '', 'driver'); $cache->setCaching($cacheactive); return $result; } private function prepareDocs($searchResults) { $claimModel = $this->getModel('claim'); $docs = array(); foreach($searchResults['result']['documents'] as $doc) { $doc = $claimModel->parseSearchResult($doc); $docs[] = $doc; } return $docs; } } ?>