$numaff = 0; $numnon = 0; // Did we get any results back? if ($this->citations) { // Get a needed library include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php'; // Set some vars $affiliated = ''; $nonaffiliated = ''; $formatter = new \Components\Citations\Helpers\Format(); $formatter->setTemplate($this->format); // Loop through the citations and build the HTML foreach ($this->citations as $cite) { $showLinks = $cite->title && $cite->author && $cite->publisher ? true : false; $item = "\t" . '<li>' . "\n"; $formatted = $cite->formatted ? $cite->formatted : \Components\Citations\Helpers\Format::formatReference($cite, ''); if ($cite->doi && $cite->url) { $formatted = str_replace('doi:' . $cite->doi, '<a href="' . $cite->url . '" rel="external">' . 'doi:' . $cite->doi . '</a>', $formatted); } $item .= $formatted; $item .= "\t\t" . '<p class="details">' . "\n"; if ($showLinks) { $item .= "\t\t\t" . '<a href="' . Route::url('index.php?option=com_citations&task=download&id=' . $cite->id . '&format=bibtex&no_html=1') . '" title="' . Lang::txt('PLG_PUBLICATION_CITATIONS_DOWNLOAD_BIBTEX') . '">BibTex</a> <span>|</span> ' . "\n"; $item .= "\t\t\t" . '<a href="' . Route::url('index.php?option=com_citations&task=download&id=' . $cite->id . '&format=endnote&no_html=1') . '" title="' . Lang::txt('PLG_PUBLICATION_CITATIONS_DOWNLOAD_ENDNOTE') . '">EndNote</a>' . "\n"; } if ($cite->eprint) { if ($cite->eprint) { $item .= "\t\t\t" . ' <span>|</span> <a href="' . stripslashes($cite->eprint) . '">' . Lang::txt('PLG_PUBLICATION_CITATIONS_ELECTRONIC_PAPER') . '</a>' . "\n"; } } $item .= "\t\t" . '</p>' . "\n";
<?php if ($this->config->get('citation_show_badges', 'no') == 'yes') { ?> <?php echo \Components\Citations\Helpers\Format::citationBadges($cite, $this->database); ?> <?php } ?> <?php if ($this->config->get('citation_show_tags', 'no') == 'yes') { ?> <?php echo \Components\Citations\Helpers\Format::citationTags($cite, $this->database); ?> <?php } ?> </div> </td> </tr> <?php $counter++; ?> <?php } ?> </tbody> </table>
/** * Show a form for editing an entry * * @return void */ public function editTask() { // Check if they're logged in if (User::isGuest()) { $this->loginTask(); return; } // Check if admin $isAdmin = false; if (User::authorise('core.manage', $this->_option)) { $isAdmin = true; } // are we allowing user to add citation $allowImport = $this->config->get('citation_import', 1); if ($allowImport == 0 || $allowImport == 2 && User::get('usertype') == 'Super Administrator') { // Redirect App::redirect(Route::url('index.php?option=' . $this->_option, false), Lang::txt('COM_CITATION_EDIT_NOTALLOWED'), 'warning'); return; } // get the citation types $ct = new Type($this->database); $types = $ct->getType(); $fields = array(); foreach ($types as $type) { if (isset($type['fields'])) { $f = $type['fields']; if (strpos($f, ',') !== false) { $f = str_replace(',', "\n", $f); } $f = array_map('trim', explode("\n", $f)); $f = array_values(array_filter($f)); $fields[strtolower(str_replace(' ', '', $type['type_title']))] = $f; } } // add an empty value for the first type array_unshift($types, array('type' => '', 'type_title' => ' - Select a Type —')); // Incoming - expecting an array id[]=4232 $id = Request::getInt('id', 0); // Pub author $pubAuthor = false; // Load the associations object $assoc = new Association($this->database); // Get associations if ($id) { $this->view->assocs = $assoc->getRecords(array('cid' => $id), $isAdmin); $pubAuthor = $this->isPubAuthor($this->view->assocs); } // Is user authorized to edit citations? if (!$isAdmin && !$pubAuthor) { $id = 0; } // Load the object $this->view->row = new Citation($this->database); $this->view->row->load($id); //make sure title isnt too long $maxTitleLength = 30; $shortenedTitle = strlen($this->view->row->title) > $maxTitleLength ? substr($this->view->row->title, 0, $maxTitleLength) . '…' : $this->view->row->title; // Set the pathway Pathway::append(Lang::txt(strtoupper($this->_option)), 'index.php?option=' . $this->_option); if ($id && $id != 0) { Pathway::append($shortenedTitle, 'index.php?option=' . $this->_option . '&task=view&id=' . $this->view->row->id); } Pathway::append(Lang::txt('COM_CITATIONS_EDIT'), 'index.php?option=' . $this->_option . '&task=edit&id=' . $this->view->row->id); // Set the page title Document::setTitle(Lang::txt('COM_CITATIONS_CITATION') . $shortenedTitle); //push jquery to doc Document::addScriptDeclaration('var fields = ' . json_encode($fields) . ';'); // Instantiate a new view $this->view->title = Lang::txt(strtoupper($this->_option)) . ': ' . Lang::txt(strtoupper($this->_option) . '_' . strtoupper($this->_task)); $this->view->config = $this->config; // No ID, so we're creating a new entry // Set the ID of the creator if (!$id) { $this->view->row->uid = User::get('id'); // It's new - no associations to get $this->view->assocs = array(); //tags & badges $this->view->tags = array(); $this->view->badges = array(); } else { //tags & badges $this->view->tags = Format::citationTags($this->view->row, $this->database, false); $this->view->badges = Format::citationBadges($this->view->row, $this->database, false); } //get the citation types $ct = new Type($this->database); $this->view->types = $ct->getType(); // Output HTML foreach ($this->getErrors() as $error) { $this->view->setError($error); } $this->view->setLayout('edit')->display(); }
$sitename = Config::get('sitename'); // Build our citation object $citation = ''; if ($this->pub->doi) { include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php'; $cite = new stdClass(); $cite->title = $this->pub->get('title'); $date = $this->pub->published() ? $this->pub->published() : $this->pub->submitted(); $cite->year = Date::of($date)->format('Y'); $cite->location = ''; $cite->date = ''; $cite->url = $site . Route::url($this->pub->link('version')); $cite->type = ''; $cite->author = $this->pub->getUnlinkedContributors(); $cite->doi = $this->pub->get('doi'); $citation = \Components\Citations\Helpers\Format::formatReference($cite); } // Embargo $pubdate = Request::getVar('publish_date'); // Get configs $termsUrl = $this->pub->config()->get('deposit_terms', ''); ?> <!-- Load content selection browser //--> <div id="<?php echo $elName; ?> " class="draft-review <?php echo $complete ? 'draft-complete' : 'draft-incomplete'; ?> <?php
" class="blockelement<?php echo $required ? ' el-required' : ' el-optional'; echo $complete ? ' el-complete' : ' el-incomplete'; ?> freezeblock"> <?php if (count($this->pub->_citations) > 0) { $i = 1; $formatter = new \Components\Citations\Helpers\Format(); $formatter->setTemplate($citationFormat); ?> <div class="list-wrapper"> <ul class="itemlist" id="citations-list"> <?php foreach ($this->pub->_citations as $cite) { $citeText = $cite->formatted ? '<p>' . $cite->formatted . '</p>' : \Components\Citations\Helpers\Format::formatReference($cite, ''); ?> <li> <span class="item-title citation-formatted"><?php echo $citeText; ?> </span> </li> <?php $i++; } ?> </ul> </div> <?php } else {
/** * Edit a citation * * @return void */ public function editTask() { //stop menu from working? Request::setVar('hidemainmenu', 1); //get request vars - expecting an array id[]=4232 $id = Request::getVar('id', array()); if (is_array($id)) { $id = !empty($id) ? $id[0] : 0; } //get all citations sponsors $cs = new Sponsor($this->database); $this->view->sponsors = $cs->getSponsor(); //get all citation types $ct = new Type($this->database); $this->view->types = $ct->getType(); //empty citation object $this->view->row = new Citation($this->database); //if we have an id load that citation data if (isset($id) && $id != '' && $id != 0) { // Load the citation object $this->view->row->load($id); // Get the associations $assoc = new Association($this->database); $this->view->assocs = $assoc->getRecords(array('cid' => $id)); //get sponsors for citation $this->view->row_sponsors = $cs->getCitationSponsor($this->view->row->id); //get the citations tags $this->view->tags = Format::citationTags($this->view->row, \App::get('db'), false); //get the badges $this->view->badges = Format::citationBadges($this->view->row, \App::get('db'), false); //parse citation params $this->view->params = new Registry($this->view->row->params); } else { //set the creator $this->view->row->uid = User::get('id'); // It's new - no associations to get $this->view->assocs = array(); //array of sponsors - empty $this->view->row_sponsors = array(); //empty tags and badges arrays $this->view->tags = array(); $this->view->badges = array(); //empty params object $this->view->params = new Registry(''); } //are we padding back the citation data if (isset($this->row)) { $this->view->row = $this->row; } //are we passing back the tags from edit if ($this->tags != '') { $this->tags = explode(',', $this->tags); foreach ($this->tags as $tag) { $this->view->tags[]['raw_tag'] = $tag; } } //are we passing back the tags from edit if ($this->badges != '') { $this->badges = explode(',', $this->badges); foreach ($this->badges as $badge) { $this->view->badges[]['raw_tag'] = $badge; } } // Set any errors if ($this->getError()) { $this->view->setError($this->getError()); } //set vars for view $this->view->config = $this->config; // Output the HTML $this->view->setLayout('edit')->display(); }
<tr> <th><?php echo Lang::txt('COM_CITATIONS_LOCAL_LIBRARY'); ?> </th> <td> <?php echo Lang::txt('COM_CITATIONS_LOCAL_LIBRARY_DESC'); ?> <ul class="secondary openurl"> <?php if ($this->openUrl) { ?> <li> <?php echo \Components\Citations\Helpers\Format::citationOpenUrl($this->openUrl, $citation); ?> </li> <?php } ?> </ul> </td> </tr> <?php } ?> <tr> <th><?php echo Lang::txt('COM_CITATIONS_GOOGLE_SCHOLAR');
/** * Process a single record * * @param integer $id * @return object */ public function record($id) { if (strstr($id, ':')) { list($id, $revision) = explode(':', $id); } $id = intval($id); if (!isset($revision)) { $revision = 0; } $this->database->setQuery("SELECT r.id, r.id AS identifier, r.title, r.introtext AS description, r.fulltxt, r.created, r.publish_up, r.alias, rt.alias AS type\n\t\t\tFROM `#__resources` AS r\n\t\t\tINNER JOIN `#__resource_types` AS rt ON r.type = rt.id\n\t\t\tWHERE r.id = " . $this->database->quote($id)); $record = $this->database->loadObject(); $record->base = $this->name(); $record->type = $record->base . ':' . $record->type; if ($revision) { $this->database->setQuery("SELECT *\n\t\t\t\tFROM `#__tool_version`\n\t\t\t\tWHERE toolname=" . $this->database->quote($record->alias) . " AND revision=" . $this->database->quote($revision) . "\n\t\t\t\tLIMIT 1"); $tool = $this->database->loadObject(); if ($tool->id) { $record->title .= ' [version ' . $tool->version . ']'; $record->fulltxt = $tool->fulltxt; $record->publish_up = $tool->released; } } $record->date = $record->created; if ($record->publish_up && $record->publish_up != $this->database->getNullDate()) { $record->date = $record->publish_up; } if (!$record->description) { $record->description = $record->fulltxt; $record->description = preg_replace("#<nb:(.*?)>(.*?)</nb:(.*?)>#s", '', $record->description); } $record->description = strip_tags($record->description); $record->description = trim($record->description); unset($record->publish_up); unset($record->created); unset($record->fulltxt); $isTool = 0; if ($record->alias) { $this->database->setQuery("SELECT id\n\t\t\t\tFROM `#__tool`\n\t\t\t\tWHERE toolname=" . $this->database->quote($record->alias) . "\n\t\t\t\tLIMIT 1"); $isTool = $this->database->loadResult(); } if ($revision) { /*"SELECT a.`doi` FROM `#__doi_mapping` AS a LEFT JOIN `#__tool_version` AS v ON v.id=a.versionid WHERE a.rid=" . $this->database->quote($id) . " AND v.revision=" . $this->database->quote($revision) . " LIMIT 1"*/ $this->database->setQuery("SELECT a.`doi`\n\t\t\t\tFROM `#__doi_mapping` AS a\n\t\t\t\tWHERE a.rid=" . $this->database->quote($id) . " AND a.local_revision=" . $this->database->quote($revision) . "\n\t\t\t\tLIMIT 1"); } else { $this->database->setQuery("SELECT a.`doi`\n\t\t\t\tFROM `#__doi_mapping` AS a\n\t\t\t\tWHERE a.rid=" . $this->database->quote($id) . "\n\t\t\t\tORDER BY `versionid` DESC LIMIT 1"); } $record->identifier = $this->identifier($id, $this->database->loadResult(), $revision); $this->database->setQuery("SELECT DISTINCT t.raw_tag\n\t\t\tFROM `#__tags` t, `#__tags_object` tos\n\t\t\tWHERE t.id = tos.tagid AND tos.objectid=" . $this->database->quote($id) . " AND tos.tbl='resources' AND t.admin=0\n\t\t\tORDER BY t.raw_tag"); $record->subject = $this->database->loadColumn(); $record->relation = array(); $this->database->setQuery("SELECT r.id, r.title, r.type, r.logical_type AS logicaltype, r.created, r.created_by,\n\t\t\tr.published, r.publish_up, r.path, r.access, t.type AS logicaltitle, rt.type AS typetitle, r.standalone\n\t\t\tFROM `#__resources` AS r\n\t\t\tINNER JOIN `#__resource_types` AS rt ON r.type=rt.id\n\t\t\tINNER JOIN `#__resource_assoc` AS a ON r.id=a.child_id\n\t\t\tLEFT JOIN `#__resource_types` AS t ON r.logical_type=t.id\n\t\t\tWHERE r.published=1 AND a.parent_id=" . $this->database->quote($id) . "\n\t\t\tORDER BY a.ordering, a.grouping"); if ($children = $this->database->loadObjectList()) { require_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'helpers' . DS . 'html.php'; require_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'tables' . DS . 'type.php'; foreach ($children as $child) { $uri = \Components\Resources\Helpers\Html::processPath('com_resources', $child, $id, 3); if (substr($uri, 0, 4) != 'http') { $uri = self::$base . '/' . ltrim($uri, '/'); } $record->relation[] = array('type' => 'hasPart', 'value' => $uri); } } $this->database->setQuery("SELECT DISTINCT r.id\n\t\t\tFROM `#__resources` AS r\n\t\t\tINNER JOIN `#__resource_assoc` AS a ON r.id=a.parent_id\n\t\t\tWHERE r.published=1 AND a.child_id=" . $this->database->quote($id) . "\n\t\t\tORDER BY a.ordering, a.grouping"); if ($parents = $this->database->loadObjectList()) { foreach ($parents as $parent) { $record->relation[] = array('type' => 'isPartOf', 'value' => $this->identifier($parent->id, 0)); } } if ($isTool) { if ($revision) { $this->database->setQuery("SELECT n.uidNumber AS id,\n\t\t\t\t\t\tCASE WHEN t.name!='' AND t.name IS NOT NULL THEN t.name\n\t\t\t\t\t\tELSE n.name\n\t\t\t\t\t\tEND AS `name`\n\t\t\t\t\tFROM `#__tool_authors` AS t, `#__xprofiles` AS n, `#__tool_version` AS v\n\t\t\t\t\tWHERE n.uidNumber=t.uid AND t.toolname=" . $this->database->quote($record->alias) . " AND v.id=t.version_id and v.state<>3\n\t\t\t\t\tAND t.revision=" . $this->database->quote($revision) . "\n\t\t\t\t\tORDER BY t.ordering"); $record->creator = $this->database->loadColumn(); /*$record->relation[] = array( 'type' => 'isVersionOf', 'value' => $this->identifier($id, '', 0) );*/ } $this->database->setQuery("SELECT v.id, v.revision, d.*\n\t\t\t\tFROM `#__tool_version` as v\n\t\t\t\tLEFT JOIN `#__doi_mapping` as d\n\t\t\t\tON d.alias = v.toolname\n\t\t\t\tAND d.local_revision=v.revision\n\t\t\t\tWHERE v.toolname = " . $this->database->quote($record->alias) . "\n\t\t\t\tORDER BY v.state DESC, v.revision DESC"); $versions = $this->database->loadObjectList(); foreach ($versions as $i => $v) { if (!$v->revision || $v->revision == $revision) { continue; } $record->relation[] = array('type' => 'hasVersion', 'value' => $this->identifier($id, $v->doi, $v->revision)); } } if (!isset($record->creator)) { $this->database->setQuery("SELECT \n\t\t\t\t\tCASE WHEN a.name!='' AND a.name IS NOT NULL THEN a.name\n\t\t\t\t\tELSE n.name\n\t\t\t\t\tEND AS `name`\n\t\t\t\tFROM `#__author_assoc` AS a\n\t\t\t\tLEFT JOIN `#__xprofiles` AS n ON n.uidNumber=a.authorid\n\t\t\t\tWHERE a.subtable='resources' AND a.subid=" . $this->database->quote($id) . " AND a.role!='submitter'\n\t\t\t\tORDER BY a.ordering, a.name"); $record->creator = $this->database->loadColumn(); } $this->database->setQuery("SELECT *\n\t\t\tFROM `#__citations` AS a\n\t\t\tINNER JOIN `#__citations_assoc` AS n ON n.`cid`=a.`id`\n\t\t\tWHERE n.`tbl`='resource' AND n.`oid`=" . $this->database->quote($id) . " AND a.`published`=1\n\t\t\tORDER BY `year` DESC"); $references = $this->database->loadObjectList(); if (count($references) && file_exists(PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php')) { include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php'; $formatter = new \Components\Citations\Helpers\Format(); $formatter->setTemplate('apa'); foreach ($references as $reference) { //<dcterms:isReferencedBy>uytruytry</dcterms:isReferencedBy> //<dcterms:isVersionOf>jgkhfjf</dcterms:isVersionOf> $cite = strip_tags(html_entity_decode($reference->formatted ? $reference->formatted : \Components\Citations\Helpers\Format::formatReference($reference, ''))); $cite = str_replace('"', '"', $cite); $record->relation[] = array('type' => 'references', 'value' => trim($cite)); } } return $record; }
/** * Display the form allowing to edit a citation * * @return string HTML */ private function editAction($row = null) { // Check if they're logged in if (User::isGuest()) { return $this->loginAction(); } if (!$this->params->get('access-manage')) { throw new Exception(Lang::txt('PLG_MEMBERS_CITATIONS_NOT_AUTHORIZED'), 403); } // Create view object $view = $this->view('edit'); $view->member = $this->member; $view->option = $this->option; $view->database = $this->database; $view->allow_tags = $this->member->getParam('citation_allow_tags', 'yes'); $view->allow_badges = $this->member->getParam('citatoin_allow_badges', 'yes'); // Get the citation types $citationsType = \Components\Citations\Models\Type::all(); $view->types = $citationsType->rows(); $fields = array(); foreach ($view->types as $type) { if (isset($type->fields)) { $f = $type->fields; if (strpos($f, ',') !== false) { $f = str_replace(',', "\n", $f); } $f = array_map('trim', explode("\n", $f)); $f = array_values(array_filter($f)); $fields[strtolower(str_replace(' ', '', $type->type_title))] = $f; } } // Incoming $id = Request::getInt('cid', 0); // Load the object if (is_object($row)) { $view->row = $row; } else { $view->row = \Components\Citations\Models\Citation::oneOrNew($id); // check to see if this member created this citation if (!$view->row->isNew() && ($view->row->uid != User::get('id') || $view->row->scope != 'member')) { // redirect App::redirect(Route::url($this->member->getLink() . '&active=' . $this->_name), Lang::txt('PLG_MEMBERS_CITATIONS_OWNER_ONLY'), 'warning'); } } //make sure title isnt too long $maxTitleLength = 30; $shortenedTitle = strlen($view->row->title) > $maxTitleLength ? substr($view->row->title, 0, $maxTitleLength) . '…' : $view->row->title; // Set the pathway if ($id && $id != 0) { Pathway::append($shortenedTitle, 'index.php?option=com_citations&task=view&id=' . $view->row->id); Pathway::append(Lang::txt('PLG_MEMBERS_CITATIONS_EDIT')); } else { Pathway::append(Lang::txt('PLG_MEMBERS_CITATIONS_ADD')); } // Set the page title Document::setTitle(Lang::txt('PLG_MEMBERS_CITATIONS_CITATION') . $shortenedTitle); //push jquery to doc Document::addScriptDeclaration('var fields = ' . json_encode($fields) . ';'); // Instantiate a new view $view->title = Lang::txt('PLG_MEMBERS_CITATIONS') . ': ' . Lang::txt('PLG_MEMBERS_CITATIONS_' . strtoupper($this->action)); // No ID, so we're creating a new entry // Set the ID of the creator if (!$id) { $view->row->uid = User::get('id'); //tags & badges $view->tags = array(); $view->badges = array(); $view->row->id = -time(); } else { if ($view->row->relatedAuthors->count()) { $view->authors = $view->row->relatedAuthors; } elseif ($view->row->relatedAuthors->count() == 0 && $view->row->author != '') { // formats the author for the multi-author plugin $authors = explode(';', $view->row->author); $authorString = ''; $totalAuths = count($authors); $x = 0; foreach ($authors as &$author) { /*** * Because the multi-select keys off of a comma, * imported entries may display incorrectly (Wojkovich, Kevin) breaks the multi-select * Convert this to Kevin Wojkovich and I'll @TODO add some logic in the formatter to * format it properly within the bibilographic format ({LASTNAME},{FIRSTNAME}) ***/ $authorEntry = explode(',', $author); if (count($authorEntry == 2)) { $author = $authorEntry[1] . ' ' . $authorEntry[0]; } $authorString .= $author; if ($totalAuths > 1 && $x < $totalAuths - 1) { $authorString .= ','; } $x = $x + 1; } $view->authorString = $authorString; } //tags & badges $view->tags = \Components\Citations\Helpers\Format::citationTags($view->row, $this->database, false); $view->badges = \Components\Citations\Helpers\Format::citationBadges($view->row, $this->database, false); } // Output HTML foreach ($this->getErrors() as $error) { $view->setError($error); } return $view->loadTemplate(); }
defined('_HZEXEC_') or die; $numaff = 0; $numnon = 0; // Did we get any results back? if ($this->citations) { // Get a needed library include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php'; // Set some vars $affiliated = ''; $nonaffiliated = ''; $formatter = new \Components\Citations\Helpers\Format(); //$formatter->setFormat($this->format); // Loop through the citations and build the HTML foreach ($this->citations as $cite) { $item = "\t" . '<li>' . "\n"; $item .= \Components\Citations\Helpers\Format::formatReference($cite, ''); $item .= "\t\t" . '<p class="details">' . "\n"; $item .= "\t\t\t" . '<a href="' . Route::url('index.php?option=com_citations&task=download&id=' . $cite->id . '&citationFormat=bibtex&no_html=1') . '" title="' . Lang::txt('PLG_RESOURCES_CITATIONS_DOWNLOAD_BIBTEX') . '">BibTex</a> <span>|</span> ' . "\n"; $item .= "\t\t\t" . '<a href="' . Route::url('index.php?option=com_citations&task=download&id=' . $cite->id . '&citationFormat=endnote&no_html=1') . '" title="' . Lang::txt('PLG_RESOURCES_CITATIONS_DOWNLOAD_ENDNOTE') . '">EndNote</a>' . "\n"; if ($cite->eprint) { if ($cite->eprint) { $item .= "\t\t\t" . ' <span>|</span> <a href="' . stripslashes($cite->eprint) . '">' . Lang::txt('PLG_RESOURCES_CITATIONS_ELECTRONIC_PAPER') . '</a>' . "\n"; } } $item .= "\t\t" . '</p>' . "\n"; $item .= "\t" . '</li>' . "\n"; // Decide which group to add it to if ($cite->affiliated) { $affiliated .= $item; $numaff++; } else {
/** * Generate a citation for a resource * * @param string $option Component name * @param object $cite Citation data * @param string $id Resource ID * @param string $citations Citations to prepend * @param integer $type Resource type * @param string $rev Tool revision * @return string HTML */ public static function citation($option, $cite, $id, $citations, $type, $rev = '') { include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php'; $html = '<p>' . Lang::txt('COM_RESOURCES_CITATION_INSTRUCTIONS') . '</p>' . "\n"; if (trim($citations)) { $html .= '<ul class="citations results">' . "\n"; $html .= "\t" . '<li>' . "\n"; $html .= $citations; $html .= "\t" . '</li>' . "\n"; $html .= '</ul>' . "\n"; } if ($cite) { $html .= '<ul class="citations results">' . "\n"; $html .= "\t" . '<li>' . "\n"; $html .= \Components\Citations\Helpers\Format::formatReference($cite); if (is_numeric($rev) || is_string($rev) && $rev != 'dev') { $html .= "\t\t" . '<p class="details">' . "\n"; $html .= "\t\t\t" . '<a href="index.php?option=' . $option . '&task=citation&id=' . $id . '&format=bibtex&no_html=1&rev=' . $rev . '" title="' . Lang::txt('COM_RESOURCES_DOWNLOAD_BIBTEX_FORMAT') . '">BibTex</a> <span>|</span> ' . "\n"; $html .= "\t\t\t" . '<a href="index.php?option=' . $option . '&task=citation&id=' . $id . '&format=endnote&no_html=1&rev=' . $rev . '" title="' . Lang::txt('COM_RESOURCES_DOWNLOAD_ENDNOTE_FORMAT') . '">EndNote</a>' . "\n"; $html .= "\t\t" . '</p>' . "\n"; } $html .= "\t" . '</li>' . "\n"; $html .= '</ul>' . "\n"; } /*if ($type == 7) { $html .= '<p>'.Lang::txt('In addition, we would appreciate it if you would add the following acknowledgment to your publication:').'</p>' . "\n"; $html .= '<ul class="citations results">' . "\n"; $html .= "\t".'<li>' . "\n"; $html .= "\t\t".'<p>'.Lang::txt('Simulation services for results presented here were provided by the Network for Computational Nanotechnology (NCN) at nanoHUB.org').'</p>' . "\n"; $html .= "\t".'</li>' . "\n"; $html .= '</ul>' . "\n"; }*/ return $html; }
/** * Display the form allowing to edit a citation * * @return string HTML */ private function _edit() { // create view object $view = $this->view('default', 'edit'); // Check if they're logged in if (User::isGuest()) { $this->_loginTask(); } // push objects to view $view->group = $this->group; $view->isManager = $this->authorized == 'manager' ? true : false; $view->config = new \Hubzero\Config\Registry($this->group->get('params')); if ($view->isManager == false) { App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->cn . '&active=citations'), Lang::txt('PLG_GROUPS_CITATIONS_GROUP_MANAGER_ONLY'), 'warning'); } // get the citation types $citationsType = \Components\Citations\Models\Type::all(); $view->types = $citationsType->rows()->toObject(); $fields = array(); foreach ($view->types as $type) { if (isset($type->fields)) { $f = $type->fields; if (strpos($f, ',') !== false) { $f = str_replace(',', "\n", $f); } $f = array_map('trim', explode("\n", $f)); $f = array_values(array_filter($f)); $fields[strtolower(str_replace(' ', '', $type->type_title))] = $f; } } // Incoming - expecting an array id[]=4232 $id = Request::getInt('id', 0); // Pub author $pubAuthor = false; // Is user authorized to edit citations? if (!$view->isManager && !$pubAuthor) { $id = 0; } // Load the object $view->row = \Components\Citations\Models\Citation::oneorNew($id); // make sure title isnt too long $maxTitleLength = 30; $shortenedTitle = strlen($view->row->title) > $maxTitleLength ? substr($view->row->title, 0, $maxTitleLength) . '…' : $view->row->title; // Set the pathway if ($id && $id != 0) { Pathway::append($shortenedTitle, 'index.php?option=com_citations&task=view&id=' . $view->row->id); Pathway::append(Lang::txt('PLG_GROUPS_CITATIONS_EDIT')); } else { Pathway::append(Lang::txt('PLG_GROUPS_CITATIONS_ADD')); } // non-owner redirect if (!$view->row->isNew() && $view->row->scope != 'group') { App::redirect(Route::url('index.php?option=com_groups&cn=' . $this->group->cn . '&active=citations'), Lang::txt('PLG_GROUPS_CITATIONS_PERMISSION_DENIED'), 'warning'); } // Set the page title Document::setTitle(Lang::txt('PLG_GROUPS_CITATIONS_CITATION') . $shortenedTitle); // push jquery to doc Document::addScriptDeclaration('var fields = ' . json_encode($fields) . ';'); // Instantiate a new view $view->title = Lang::txt(strtoupper($this->_name)) . ': ' . Lang::txt(strtoupper($this->_name) . '_' . strtoupper($this->action)); // No ID, so we're creating a new entry // Set the ID of the creator if (!$id) { $view->row->uid = User::get('id'); // tags & badges $view->tags = array(); $view->badges = array(); $view->row->id = -time(); } else { if ($view->row->relatedAuthors->count()) { $view->authors = $view->row->relatedAuthors; } elseif ($view->row->relatedAuthors->count() == 0 && $view->row->author != '') { // formats the author for the multi-author plugin $authors = explode(';', $view->row->author); $authorString = ''; $totalAuths = count($authors); $x = 0; foreach ($authors as &$author) { /*** * Because the multi-select keys off of a comma, * imported entries may display incorrectly (Wojkovich, Kevin) breaks the multi-select * Convert this to Kevin Wojkovich and I'll @TODO add some logic in the formatter to * format it properly within the bibilographic format ({LASTNAME},{FIRSTNAME}) ***/ $authorEntry = explode(',', $author); if (count($authorEntry) == 2) { $author = $authorEntry[1] . ' ' . $authorEntry[0]; } $authorString .= $author; if ($totalAuths > 1 && $x < $totalAuths - 1) { $authorString .= ','; } $x = $x + 1; } $view->authorString = $authorString; } // tags & badges $view->tags = \Components\Citations\Helpers\Format::citationTags($view->row, $this->database, false); $view->badges = \Components\Citations\Helpers\Format::citationBadges($view->row, $this->database, false); } // Output HTML foreach ($this->getErrors() as $error) { $view->setError($error); } return $view->loadTemplate(); }
/** * Process a single record * * @param integer $id * @return object */ public function record($id) { if (strstr($id, ':')) { list($id, $revision) = explode(':', $id); } $id = intval($id); if (!isset($revision)) { $revision = 0; } $this->database->setQuery("SELECT pv.*, pv.doi AS identifier, rt.alias AS type\n\t\t\tFROM `#__publication_versions` AS pv\n\t\t\tINNER JOIN `#__publications` AS p ON p.id = pv.publication_id\n\t\t\tINNER JOIN `#__publication_categories` AS rt ON rt.id = p.category\n\t\t\tWHERE p.id = " . $this->database->quote($id) . ($revision ? " AND pv.version_number=" . $this->database->quote($revision) : "")); $record = $this->database->loadObject(); $record->version_id = $record->id; $record->id = $id; $record->base = $this->name(); $record->type = $record->base . ':' . $record->type; $record->title .= ' [version ' . $record->version_label . ']'; $record->description = strip_tags($record->description); $record->description = trim($record->description); $record->identifier = $this->identifier($id, $record->identifier, $revision); $this->database->setQuery("SELECT pv.created, pv.submitted, pv.published_up, pv.accepted\n\t\t\tFROM `#__publication_versions` AS pv\n\t\t\tWHERE pv.id = " . $this->database->quote($record->version_id) . "\n\t\t\tORDER BY pv.submitted DESC LIMIT 1"); $dates = $this->database->loadObject(); $record->date = $dates->created; if ($dates->submitted && $dates->submitted != '0000-00-00 00:00:00') { $record->date = $dates->submitted; } if ($dates->accepted && $dates->accepted != '0000-00-00 00:00:00') { $record->date = $dates->accepted; } if ($dates->published_up && $dates->published_up != '0000-00-00 00:00:00' && $dates->published_up > $record->date) { $record->date = $dates->published_up; } $this->database->setQuery("SELECT pa.name\n\t\t\tFROM `#__publication_authors` AS pa\n\t\t\tWHERE pa.role != 'submitter' AND pa.publication_version_id=" . $this->database->quote($record->version_id) . "\n\t\t\tORDER BY pa.name"); $record->creator = $this->database->loadColumn(); $this->database->setQuery("SELECT DISTINCT t.raw_tag\n\t\t\tFROM `#__tags` t, `#__tags_object` tos\n\t\t\tWHERE t.id = tos.tagid AND tos.objectid=" . $this->database->quote($id) . " AND tos.tbl='publications' AND t.admin=0\n\t\t\tORDER BY t.raw_tag"); $record->subject = $this->database->loadColumn(); // Relations $record->relation = array(); $this->database->setQuery("SELECT v.id, v.publication_id, v.version_number, v.doi\n\t\t\tFROM `#__publication_versions` as v\n\t\t\tWHERE v.state=1 AND v.publication_id = " . $this->database->quote($record->id) . "\n\t\t\tORDER BY v.version_number DESC"); $versions = $this->database->loadObjectList(); foreach ($versions as $i => $v) { if (!$v->version_number || $v->version_number == $revision) { continue; } $record->relation[] = array('type' => 'hasVersion', 'value' => $this->identifier($id, $v->doi, $v->version_number)); } $this->database->setQuery("SELECT *\n\t\t\tFROM `#__citations` AS a\n\t\t\tLEFT JOIN `#__citations_assoc` AS n ON n.`cid`=a.`id`\n\t\t\tWHERE n.`tbl`='publication' AND n.`oid`=" . $this->database->quote($id) . " AND n.`type`='owner' AND a.`published`=1\n\t\t\tORDER BY `year` DESC"); $references = $this->database->loadObjectList(); if (count($references) && file_exists(PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php')) { include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php'; $formatter = new \Components\Citations\Helpers\Format(); $formatter->setTemplate('apa'); foreach ($references as $reference) { $cite = strip_tags(html_entity_decode($reference->formatted ? $reference->formatted : \Components\Citations\Helpers\Format::formatReference($reference, ''))); $cite = str_replace('"', '"', $cite); $record->relation[] = array('type' => 'isReferencedBy', 'value' => trim($cite)); } } $this->database->setQuery("SELECT *\n\t\t\tFROM `#__citations` AS a\n\t\t\tLEFT JOIN `#__citations_assoc` AS n ON n.`cid`=a.`id`\n\t\t\tWHERE n.`tbl`='publication' AND n.`oid`=" . $this->database->quote($id) . " AND n.`type`!='owner' AND a.`published`=1\n\t\t\tORDER BY `year` DESC"); $references = $this->database->loadObjectList(); if (count($references) && file_exists(PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php')) { include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php'; $formatter = new \Components\Citations\Helpers\Format(); $formatter->setTemplate('apa'); foreach ($references as $reference) { $cite = strip_tags(html_entity_decode($reference->formatted ? $reference->formatted : \Components\Citations\Helpers\Format::formatReference($reference, ''))); $cite = str_replace('"', '"', $cite); $record->relation[] = array('type' => 'references', 'value' => trim($cite)); } } return $record; }
/** * Process a single record * * @param integer $id * @return object */ public function record($id) { if (strstr($id, ':')) { list($id, $revision) = explode(':', $id); } $id = intval($id); if (!isset($revision)) { $revision = 0; } $this->database->setQuery("SELECT pv.*, pv.doi AS identifier, rt.alias AS type, pv.publication_id\n\t\t\tFROM `#__publication_versions` AS pv\n\t\t\tINNER JOIN `#__publications` AS p ON p.id = pv.publication_id\n\t\t\tINNER JOIN `#__publication_categories` AS rt ON rt.id = p.category\n\t\t\tWHERE pv.id = " . $this->database->quote($id)); $record = $this->database->loadObject(); $record->version_id = $record->id; $id = $record->publication_id; $record->id = $id; if (!$record->identifier) { $record->identifier = self::$base . '/' . ltrim(\Route::url('index.php?option=com_publications&id=' . $id . ($record->version_id ? '&v=' . $record->version_id : '')), '/'); } $record->base = $this->name(); $record->type = $record->base . ':' . $record->type; $record->description = strip_tags($record->description); $record->description = trim($record->description); $this->database->setQuery("SELECT pv.submitted\n\t\t\tFROM `#__publication_versions` pv, `#__publications` p\n\t\t\tWHERE p.id = pv.publication_id AND p.id = " . $this->database->quote($id) . "\n\t\t\tORDER BY pv.submitted DESC LIMIT 1"); $record->date = $this->database->loadResult(); $this->database->setQuery("SELECT pa.name\n\t\t\tFROM `#__publication_authors` pa, `#__publication_versions` pv, `#__publications` p\n\t\t\tWHERE pa.publication_version_id = pv.id AND pa.role != 'submitter' AND pv.publication_id = p.id AND p.id=" . $this->database->quote($id) . "\n\t\t\tORDER BY pa.name"); $record->creator = $this->database->loadColumn(); $this->database->setQuery("SELECT DISTINCT t.raw_tag\n\t\t\tFROM `#__tags` t, `#__tags_object` tos\n\t\t\tWHERE t.id = tos.tagid AND tos.objectid=" . $this->database->quote($id) . " AND tos.tbl='publications' AND t.admin=0\n\t\t\tORDER BY t.raw_tag"); $record->subject = $this->database->loadColumn(); // Relations $record->relation = array(); $this->database->setQuery("SELECT *\n\t\t\tFROM `#__citations` AS a\n\t\t\tLEFT JOIN `#__citations_assoc` AS n ON n.`cid`=a.`id`\n\t\t\tWHERE n.`tbl`='publication' AND n.`oid`=" . $this->database->quote($id) . " AND n.`type`='owner' AND a.`published`=1\n\t\t\tORDER BY `year` DESC"); $references = $this->database->loadObjectList(); if (count($references) && file_exists(PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php')) { include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php'; $formatter = new \Components\Citations\Helpers\Format(); $formatter->setTemplate('apa'); foreach ($references as $reference) { $cite = strip_tags(html_entity_decode($reference->formatted ? $reference->formatted : \Components\Citations\Helpers\Format::formatReference($reference, ''))); $cite = str_replace('"', '"', $cite); $record->relation[] = array('type' => 'isReferencedBy', 'value' => trim($cite)); } } $this->database->setQuery("SELECT *\n\t\t\tFROM `#__citations` AS a\n\t\t\tLEFT JOIN `#__citations_assoc` AS n ON n.`cid`=a.`id`\n\t\t\tWHERE n.`tbl`='publication' AND n.`oid`=" . $this->database->quote($id) . " AND n.`type`!='owner' AND a.`published`=1\n\t\t\tORDER BY `year` DESC"); $references = $this->database->loadObjectList(); if (count($references) && file_exists(PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php')) { include_once PATH_CORE . DS . 'components' . DS . 'com_citations' . DS . 'helpers' . DS . 'format.php'; $formatter = new \Components\Citations\Helpers\Format(); $formatter->setTemplate('apa'); foreach ($references as $reference) { $cite = strip_tags(html_entity_decode($reference->formatted ? $reference->formatted : \Components\Citations\Helpers\Format::formatReference($reference, ''))); $cite = str_replace('"', '"', $cite); $record->relation[] = array('type' => 'references', 'value' => trim($cite)); } } return $record; }