public function getCitation($format) { require_once ROOT_DIR . '/sys/CitationBuilder.php'; // Build author list: $authors = array(); $primary = $this->eContentRecord->author; if (!empty($primary)) { $authors[] = $primary; } $authors = array_unique(array_merge($authors, $this->eContentRecord->getPropertyArray('author2'))); // Collect all details for citation builder: $publishers = array($this->eContentRecord->publisher); $pubDates = $this->eContentRecord->getPropertyArray('publishDate'); $pubPlaces = array(); $details = array('authors' => $authors, 'title' => $this->eContentRecord->title, 'subtitle' => $this->eContentRecord->subTitle, 'pubPlace' => count($pubPlaces) > 0 ? $pubPlaces[0] : null, 'pubName' => count($publishers) > 0 ? $publishers[0] : null, 'pubDate' => count($pubDates) > 0 ? $pubDates[0] : null, 'edition' => $this->eContentRecord->getPropertyArray('edition'), 'source' => $this->eContentRecord->source, 'format' => $this->eContentRecord->format()); // Build the citation: $citation = new CitationBuilder($details); switch ($format) { case 'APA': return $citation->getAPA(); case 'MLA': return $citation->getMLA(); case 'AMA': return $citation->getAMA(); case 'ChicagoAuthDate': return $citation->getChicagoAuthDate(); case 'ChicagoHumanities': return $citation->getChicagoHumanities(); } return ''; }
/** * Assign necessary Smarty variables and return a template name * to load in order to display the requested citation format. * For legal values, see getCitationFormats(). Returns null if * format is not supported. * * @param string $format Citation format to display. * @access public * @return string Name of Smarty template file to display. */ public function getCitation($format) { require_once ROOT_DIR . '/sys/CitationBuilder.php'; // Build author list: $authors = array(); $primary = $this->getAuthor(); if (!empty($primary)) { $authors[] = $primary; } $authors = array_unique(array_merge($authors, $this->getContributors())); // Collect all details for citation builder: $publishers = $this->getPublishers(); $pubDates = $this->getPublicationDates(); $pubPlaces = $this->getPlacesOfPublication(); $details = array('authors' => $authors, 'title' => $this->getTitle(), 'subtitle' => $this->getSubtitle(), 'pubPlace' => count($pubPlaces) > 0 ? $pubPlaces[0] : null, 'pubName' => count($publishers) > 0 ? $publishers[0] : null, 'pubDate' => count($pubDates) > 0 ? $pubDates[0] : null, 'edition' => $this->getEdition(), 'format' => $this->getFormats()); // Build the citation: $citation = new CitationBuilder($details); switch ($format) { case 'APA': return $citation->getAPA(); case 'AMA': return $citation->getAMA(); case 'ChicagoAuthDate': return $citation->getChicagoAuthDate(); case 'ChicagoHumanities': return $citation->getChicagoHumanities(); case 'MLA': return $citation->getMLA(); } return ''; }