/** * List citations * * @return void */ public function displayTask() { $this->view->filters = array('limit' => Request::getState($this->_option . '.' . $this->_controller . '.limit', 'limit', Config::get('list_limit'), 'int'), 'start' => Request::getState($this->_option . '.' . $this->_controller . '.limitstart', 'limitstart', 0, 'int'), 'sort' => Request::getState($this->_option . '.' . $this->_controller . '.sort', 'sort', 'created DESC'), 'search' => urldecode(Request::getState($this->_option . '.' . $this->_controller . '.search', 'search', '')), 'published' => array(0, 1), 'scope' => Request::getVar('scope', 'all')); $obj = new Citation($this->database); // Get a record count $this->view->total = $obj->getCount($this->view->filters); // Get records $this->view->rows = $obj->getRecords($this->view->filters); //get the dynamic citation types $ct = new Type($this->database); $this->view->types = $ct->getType(); // Output the HTML $this->view->display(); }
/** * Browse entries * * @return void */ public function browseTask() { // Instantiate a new view $this->view->title = Lang::txt(strtoupper($this->_option)); $this->view->database = $this->database; $this->view->config = $this->config; $this->view->isAdmin = false; if (User::authorise('core.manage', $this->_option)) { $this->view->isAdmin = true; } // get the earliest year we have citations for $query = "SELECT c.year FROM `#__citations` as c WHERE c.published=1 AND c.year <> 0 AND c.year IS NOT NULL ORDER BY c.year ASC LIMIT 1"; $this->view->database->setQuery($query); $earliest_year = $this->view->database->loadResult(); $earliest_year = $earliest_year ? $earliest_year : 1990; // Incoming $this->view->filters = array('limit' => Request::getInt('limit', 50, 'request'), 'start' => Request::getInt('limitstart', 0, 'get'), 'id' => Request::getInt('id', 0), 'tag' => Request::getVar('tag', '', 'request', 'none', 2), 'search' => Request::getVar('search', ''), 'type' => Request::getVar('type', ''), 'author' => Request::getVar('author', ''), 'publishedin' => Request::getVar('publishedin', ''), 'year_start' => Request::getInt('year_start', $earliest_year), 'year_end' => Request::getInt('year_end', date("Y")), 'filter' => Request::getVar('filter', ''), 'sort' => Request::getVar('sort', 'created DESC'), 'reftype' => Request::getVar('reftype', array('research' => 1, 'education' => 1, 'eduresearch' => 1, 'cyberinfrastructure' => 1)), 'geo' => Request::getVar('geo', array('us' => 1, 'na' => 1, 'eu' => 1, 'as' => 1)), 'aff' => Request::getVar('aff', array('university' => 1, 'industry' => 1, 'government' => 1)), 'startuploaddate' => Request::getVar('startuploaddate', '0000-00-00'), 'enduploaddate' => Request::getVar('enduploaddate', '0000-00-00'), 'scope' => 'hub'); $this->view->filter = array('all' => Lang::txt('COM_CITATIONS_ALL'), 'aff' => Lang::txt('COM_CITATIONS_AFFILIATED'), 'nonaff' => Lang::txt('COM_CITATIONS_NONAFFILIATED')); if (!in_array($this->view->filters['filter'], array_keys($this->view->filter))) { $this->view->filters['filter'] = ''; } // Sort Filter $this->view->sorts = array('sec_cnt DESC' => Lang::txt('COM_CITATIONS_CITEDBY'), 'year DESC' => Lang::txt('COM_CITATIONS_YEAR'), 'created DESC' => Lang::txt('COM_CITATIONS_NEWEST'), 'title ASC' => Lang::txt('COM_CITATIONS_TITLE'), 'author ASC' => Lang::txt('COM_CITATIONS_AUTHOR'), 'journal ASC' => Lang::txt('COM_CITATIONS_JOURNAL')); if (!in_array($this->view->filters['sort'], array_keys($this->view->sorts))) { $this->view->filters['sort'] = 'created DESC'; } // Handling ids of the the boxes checked for download $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $session = App::get('session'); // If it's new search remove all user citation checkmarks if (isset($_POST['filter'])) { $this->view->filters['idlist'] = ""; $session->set('idlist', $this->view->filters['idlist']); } else { $this->view->filters['idlist'] = Request::getVar('idlist', $session->get('idlist')); $session->set('idlist', $this->view->filters['idlist']); } // Reset the filter if the user came from a different section if (strpos($referer, "/citations/browse") == false) { $this->view->filters['idlist'] = ""; $session->set('idlist', $this->view->filters['idlist']); } // Convert upload dates to correct time format if ($this->view->filters['startuploaddate'] == '0000-00-00' || $this->view->filters['startuploaddate'] == '0000-00-00 00:00:00' || $this->view->filters['startuploaddate'] == '') { $this->view->filters['startuploaddate'] = '0000-00-00 00:00:00'; } else { $this->view->filters['startuploaddate'] = Date::of($this->view->filters['startuploaddate'])->format('Y-m-d 00:00:00'); } if ($this->view->filters['enduploaddate'] == '0000-00-00' || $this->view->filters['enduploaddate'] == '0000-00-00 00:00:00' || $this->view->filters['enduploaddate'] == '') { $this->view->filters['enduploaddate'] = Date::of('now')->modify('+1 DAY')->format('Y-m-d 00:00:00'); } else { $this->view->filters['enduploaddate'] = Date::of($this->view->filters['enduploaddate'])->format('Y-m-d 00:00:00'); } // Make sure the end date for the upload search isn't before the start date if ($this->view->filters['startuploaddate'] > $this->view->filters['enduploaddate']) { App::redirect(Route::url('index.php?option=com_citations&task=browse'), Lang::txt('COM_CITATIONS_END_DATE_MUST_BE_AFTER_START_DATE'), 'error'); return; } // Clean up filters a little array_walk($this->view->filters, function (&$val, &$key) { if (!is_array($val)) { $val = trim($val); $val = str_replace('"', '', $val); $key = $val; } }); // Instantiate a new citations object $obj = new Citation($this->database); // Get a record count $this->view->total = $obj->getCount($this->view->filters, $this->view->isAdmin); // Get records $this->view->citations = $obj->getRecords($this->view->filters, $this->view->isAdmin); // Add some data to our view for form filtering/sorting $ct = new Type($this->database); $this->view->types = $ct->getType(); // Get the users id to make lookup $users_ip = Request::ip(); // Get the param for ip regex to use machine ip $ip_regex = array('10.\\d{2,5}.\\d{2,5}.\\d{2,5}'); $use_machine_ip = false; foreach ($ip_regex as $ipr) { $match = preg_match('/' . $ipr . '/i', $users_ip); if ($match) { $use_machine_ip = true; } } // Make url based on if were using machine ip or users if ($use_machine_ip) { $url = 'http://worldcatlibraries.org/registry/lookup?IP=' . $_SERVER['SERVER_ADDR']; } else { $url = 'http://worldcatlibraries.org/registry/lookup?IP=' . $users_ip; } // Get the resolver $r = null; if (function_exists('curl_init')) { $cURL = curl_init(); curl_setopt($cURL, CURLOPT_URL, $url); curl_setopt($cURL, CURLOPT_RETURNTRANSFER, 1); curl_setopt($cURL, CURLOPT_TIMEOUT, 10); $r = curl_exec($cURL); curl_close($cURL); } // Parse the returned xml $this->view->openurl = array('link' => '', 'text' => '', 'icon' => ''); // Parse the return from resolver lookup $resolver = null; $xml = simplexml_load_string($r); if (isset($xml->resolverRegistryEntry)) { $resolver = $xml->resolverRegistryEntry->resolver; } // If we have resolver set vars for creating open urls if ($resolver != null) { $this->view->openurl['link'] = $resolver->baseURL; $this->view->openurl['text'] = $resolver->linkText; $this->view->openurl['icon'] = $resolver->linkIcon; } // Set the page title $this->_buildTitle(); // Set the pathway $this->_buildPathway(); // Pass any error messages to the view foreach ($this->getErrors() as $error) { $this->view->setError($error); } // Get any messages $this->view->messages = \Notify::messages('citations'); // Are we allowing importing? $this->view->allow_import = $this->config->get('citation_import', 1); $this->view->allow_bulk_import = $this->config->get('citation_bulk_import', 1); // Output HTML $this->view->display(); }