示例#1
0
 /**
  * Creates a newspaper article citation
  *
  * @param Work $work
  */
 function newspaper(Work $work)
 {
     //Add the contributors
     $ret = $this->formatAuthors($work->contributors);
     //Add the article title (if provided)
     if ($work->articleTitle) {
         //Uppercase all words in article title, lowercase all art., prep., & conj., append a period, and encapsulate in double quotes
         $articleTitle = ucwords($work->articleTitle);
         $articleTitle = Utility::lowerArticles($articleTitle);
         $articleTitle = Utility::addPeriod($articleTitle);
         $ret .= '"' . $articleTitle . '" ';
     }
     //in print
     if ($work->medium == "print") {
         //Add the newspaper title (if provided)
         if ($work->newspaperTitle) {
             //Uppercase all words in a newspaper's title
             $newspaperTitle = ucwords($work->newspaperTitle);
             //Remove articles (A, An, The) before the newspaper title
             $newspaperTitle = Utility::removeArticle($newspaperTitle);
             $ret .= '<i>' . $newspaperTitle . '</i>' . ' ';
         }
         //Add the newspaper city (if provided)
         if ($work->newspaperCity) {
             $ret .= '[' . ucwords($work->newspaperCity) . ']' . ' ';
         }
         //Add the date published (if provided)
         if ($work->day || $work->month || $work->year) {
             $ret .= $this->formatPublishDate($work->day, $work->month, $work->year);
         }
         //Add the edition (if provided)
         if ($work->edition) {
             $edition = strtolower($work->edition);
             $ret .= ', ' . $this->abbreviateEdition($edition);
         }
         //Add the section (if provided)
         if ($work->section) {
             $ret .= ', ' . $this->formatNewspaperSection($work->section);
         }
         //Add a colon
         $ret .= ': ';
         //Add the page numbers
         $ret .= $this->getPageNumbers($work->startPage, $work->endPage, $work->hasNonConsecutivePages);
         //Add the medium
         $ret .= 'Print.';
     }
     //on a website
     if ($work->medium == "website") {
         //Add the web site title (if provided)
         if ($work->webTitle) {
             $ret .= '<i>' . ucwords($work->webTitle) . '</i>' . '. ';
         }
         //Add the newspaper title (if provided)
         if ($work->newspaperTitle) {
             //Uppercase all words in a newspaper's title
             $newspaperTitle = ucwords($work->newspaperTitle);
             //Remove articles (A, An, The) before the newspaper title
             $newspaperTitle = Utility::removeArticle($newspaperTitle);
             $ret .= '<i>' . $newspaperTitle . '</i>' . ', ';
         }
         //Add the electronically published date (if provided)
         if ($work->electronicPublishDay || $work->electronicPublishMonth || $work->electronicPublishYear) {
             $ret .= $this->formatPublishDate($work->electronicPublishDay, $work->electronicPublishMonth, $work->electronicPublishYear) . '. ';
         }
         //Add the medium
         $ret .= 'Web. ';
         //Add the access date (if provided)
         if ($work->webAccessDay || $work->webAccessMonth || $work->webAccessYear) {
             $ret .= $this->formatAccessDate($work->webAccessDay, $work->webAccessMonth, $work->webAccessYear) . '. ';
         }
         //Add the URL (if provided)
         if ($work->webUrl) {
             $ret .= '&#60;';
             $ret .= Utility::checkUrlPrepend($work->webUrl);
             $ret .= '&#62;';
             $ret .= '. ';
         }
     }
     //in a database
     if ($work->medium == "db") {
         //Add the newspaper title (if provided)
         if ($work->newspaperTitle) {
             //Uppercase all words in a newspaper's title
             $newspaperTitle = ucwords($work->newspaperTitle);
             //Remove articles (A, An, The) before the newspaper title
             $newspaperTitle = Utility::removeArticle($newspaperTitle);
             $ret .= '<i>' . $newspaperTitle . '</i>' . ' ';
         }
         //Add the newspaper city (if provided)
         if ($work->dbNewspaperCity) {
             $ret .= '[' . ucwords($work->dbNewspaperCity) . ']' . ' ';
         }
         //Add the date published (if provided)
         if ($work->dbPublishedDay || $work->dbPublishedMonth || $work->dbPublishedYear) {
             $ret .= $this->formatPublishDate($work->dbPublishedDay, $work->dbPublishedMonth, $work->dbPublishedYear);
         }
         //Add the edition (if provided)
         if ($work->dbEdition) {
             $dbEdition = strtolower($work->dbEdition);
             $ret .= ', ' . $this->abbreviateEdition($dbEdition);
         }
         //Add a colon
         $ret .= ': ';
         //Add the page numbers
         $ret .= $this->getPageNumbers($work->dbStartPage, $work->dbEndPage, $work->dbHasNonConsecutive);
         //Add the database title (if provided)
         if ($work->db) {
             $ret .= '<i>' . ucwords($work->db) . '</i>' . '. ';
         }
         //Add the medium
         $ret .= 'Web. ';
         //Add the access date
         $ret .= $this->formatAccessDate($work->dbAccessDay, $work->dbAccessMonth, $work->dbAccessYear) . '. ';
         //Add the URL (if provided)
         if ($work->dbUrl) {
             $ret .= '&#60;';
             $ret .= Utility::checkUrlPrepend($work->dbUrl);
             $ret .= '&#62;';
             $ret .= '. ';
         }
     }
     return $ret;
 }