Hi; I have created a screen display style for those who need Chicago manual of style.

It's my first PhP attempt and it has a few bugs. Namely, I can't figure out how to remove the space after the Author Names and before the period. Also, when you go into "Biblio Settings" in the administer menu and change your "styling" to this module and hit save, you will be taken to a blank white screen. The change works and your biblios will then look correct, but I'm not sure why the detour to a white screen.

If you want to use this style, you can copy the following code into a file, name it "biblio_style_chicago.inc" and plop it into your biblio module folder (should see other files named "biblio_style..." . You can then choose the style in the "Biblio Settings" admin menu.

Happy to get feedback to improve it.

<?php
// $Id: biblio_style_chicago.inc,v 0.0.1 2009/04/19 
// by Adam Crymble for the Network in Canadian History & Environment. http://niche.uwo.ca
// Chicago Manual of Style, beta.
function biblio_style_chicago_info(){

    return array('chicago'=>'Chicago Manual of Style');
                
}
?>

<?php
function biblio_style_chicago($node, $base='biblio', $inline=false){

    if (variable_get('biblio_normalize', 0)) {
      $authors = _biblio_parse_authors($node->biblio_authors);
    } else {
      $authors = $node->biblio_authors;
	  $checkFullStop = strlen($authors);
    }
 // author output

    $authorNum = substr_count($authors, ';'); 
    
    if ($authorNum == 0) {
        //single author
		if ((strrpos($authors, ".") == $checkFullStop - 1)||(strrpos($authors, ".") == $checkFullStop - 2)) {
			$output .= '<span class="biblio-authors">' . (_biblio_author_links($authors,$base,$inline)) . "</span> \n";
		} else {
			$output .= '<span class="biblio-authors">' . (_biblio_author_links($authors,$base,$inline)) . ". </span> \n";
		}
	} elseif ($authorNum == 1) {
        //two authors
        list($name1, $name2) = split(';', $authors);
        $authors = $name1 . ", and " . $name2; 
		if ((strrpos($authors, ".") == $checkFullStop - 1)||(strrpos($authors, ".") == $checkFullStop - 2)) {
			$output .= '<span class="biblio-authors">' . (_biblio_author_links($authors,$base,$inline)) . "</span> \n";
		} else {
			$output .= '<span class="biblio-authors">' . (_biblio_author_links($authors,$base,$inline)) . ". </span> \n";
		}
	} elseif ($authorNum > 1) {
        //three or more authors
        $splitAuthors = explode(";", $authors);
        $multiAuthor = $splitAuthors[0] . ", ";
        if (count($splitauthors == 3)) {
            $multiAuthor .= $splitAuthors[1] . ", and " . $splitAuthors[2];
        } else {
            
            $multiAuthor .= "et.al";
        }
		if ((strrpos($authors, ".") == $checkFullStop - 1)||(strrpos($authors, ".") == $checkFullStop - 2)) {
			$output .= '<span class="biblio-authors">' . (_biblio_author_links($multiAuthor,$base,$inline)) . "</span> \n";
		} else {
			$output .= '<span class="biblio-authors">' . (_biblio_author_links($multiAuthor,$base,$inline)) . ". </span> \n";
		}
	}
    
  //title output
    if ($node->biblio_secondary_title) {
	   $node->biblio_secondary_title = rtrim($node->biblio_secondary_title);
       $secondTitle = $node->title;
       $output .=  '<span class="biblio-title">&quot;';
       $output .= $inline ? l("$node->title", "$base/viewinline/$node->nid") : l("$node->title", "node/$node->nid");   
       $output .= ".&quot; </span> \n";
       $output .= '<em>'.check_plain($node->biblio_secondary_title). '. '.'</em>';

    } else {
       $mainTitle = $node->title;
       $mainTitle = rtrim($mainTitle);
       $output .=  '<span class="biblio-title"><em>';
       $output .= $inline ? l("$mainTitle", "$base/viewinline/$node->nid") : l("$mainTitle", "node/$node->nid"); 
       $output .= ". </em></span> \n";
    }
    
    //for journal articles: volume, number, issue, pages
    if ($node->biblio_volume) {
		$node->biblio_volume = rtrim($node->biblio_volume);
		$output .= check_plain($node->biblio_volume);
    }
	if ($node->biblio_number) {
		$node->biblio_number = rtrim($node->biblio_number);
		$output .= ' no. ' . check_plain($node->biblio_number);
	}
    if ($node->biblio_issue) {
		$node->biblio_issue = rtrim($node->biblio_issue);
		$output .= ' (' . check_plain($node->biblio_issue) . ")";
	}
	if ($node->biblio_pages) {
		$node->biblio_pages = rtrim($node->biblio_pages);
		$output .= ': ' . check_plain($node->biblio_pages). ".";
	}
    
    
   //place, publisher and date output.
    if (($node->biblio_place_published) && ($node->biblio_publisher) && ($node->biblio_year)){
        $output .= ' ' . check_plain($node->biblio_place_published);
        $output .= ': ' . check_plain($node->biblio_publisher);
        $output .= ', ' . check_plain($node->biblio_year) . ".";        
    } elseif (($node->biblio_place_published) && ($node->biblio_year) && ($node->biblio_publisher == -1)) {
        $output .= ' ' . check_plain($node->biblio_place_published);
        $output .= ': ' . check_plain($node->biblio_year) . ".";  
    } elseif (($node->biblio_place_published) && ($node->biblio_publisher) && ($node->biblio_year == -1)){
        $output .= ' ' . check_plain($node->biblio_place_published);
        $output .= ': ' . check_plain($node->biblio_publisher) . ".";
    } elseif (($node->biblio_publisher) && ($node->biblio_place_published == -1) && ($node->biblio_year)){
        $output .= ' ' . check_plain($node->biblio_publisher) . ", " . check_plain($node->biblio_year) . ".";
    } elseif (($node->biblio_place_published) && ($node->biblio_year == -1) && ($node->biblio_publisher == -1)){
        $output .= ' ' . check_plain($node->biblio_place_published) . ".";
    } elseif (($node->biblio_publisher) && ($node->biblio_year == -1) && ($node->biblio_place_published == -1)){
        $output .= ' ' . check_plain($node->biblio_publisher) . ".";
    } elseif (($node->biblio_year) && ($node->biblio_publisher == -1) && ($node->biblio_place_published == -1)){
        $output .= ' ' . check_plain($node->biblio_year) . ".";
  }

  return $output;

}
?>

Thanks.

Adam Crymble

CommentFileSizeAuthor
#6 biblio_style_chicago.txt20.07 KBacrymble

Comments

acrymble’s picture

I should add, to get a proper Chicago style for the author names, you have to turn off the "Normalize author names" feature since this converts given names to initials. You can find this in the "styling" category of the "Biblio Settings" in the admin menu.

rjerome’s picture

Hi Adam,

First thanks for the contribution, and I hate to tell you this after all the work you did, but there is a Chicago style in the 5.x-dev release. I just sort of forgot to make an official release which includes it along with a number of other new styles.

Perhaps you would like to test out the -dev release prior to me making it official?

Ron.

acrymble’s picture

Thanks, I'll check it out. No problem; was a great hands on way to learn some php!

acrymble’s picture

Do I need to install the entire dev module to get the new chicago style to work? I tried just adding the biblio_style_chicago.inc file to my module and when I go to look at my bibliography I get an error:

Fatal Error: Call to undefined function theme_biblio_page_number() in "C:\\Program Files\xampp\htdocs\modules\biblio\biblio_style_chicago.inc" on line 224.

rjerome’s picture

Yes, you do need to install everything and run update.php. I backported those styles from the 6.x version so there were some fairly extensive changes to the code to make them work with 5.x

acrymble’s picture

StatusFileSize
new20.07 KB

I've installed your dev version and looked at the Chicago style. I had to add one conditional statement to only display "Edited by" when there was indeed an editor. It should be corrected in the attached version of the file.

The only other problem I encountered with the style guide was in the case of Authors with a middle initial inputted by the user.

For instance, if the user inputs " Smith, John S." as the author, the program outputs:

Smith, John S.. "Title..."

I'm afraid I'm too new to PhP and wasn't able to figure out the spot where to put an If Statement that would check if the last character in the $author string was a period before deciding to add another period to the end.

Otherwise, I came across no major issues.

Adam

rjerome’s picture

Thanks Adam,

That "Edited by" issue was actually caused by erroneous code at line 342..

      if (count($node->biblio_secondary_authors))      // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)')

should have been...

      if (!empty($node->biblio_secondary_authors))      // editor (if different from author, see note above regarding the check for ' (ed)' or ' (eds)')

There were also a number of errors on the theme_format_authors function which I have rectified.

WRT your Smith, John S. example, what was your expected output? What I'm seeing output (with the newly revised code) is John S. Smith.

Ron.

acrymble’s picture

The problem appears only on "Book Chapter" entries.

Here is the output I am getting (Using Chicago)

Ainley, Marianne G.. "The emergence of Canadian ornithology: an historical overview to 1950." In Contributions to the History of North American Ornithology, edited by W.E. Davis Jr. and J.A. Jackson, 283-302. Cambridge, MA: The Nuttall Ornithological Club, 1995.

Note the extra period after her name.

Here is the Input in the "Author" field.

Ainley, Marianne G

Hope that helps.

Adam

rjerome’s picture

Try the latest -dev version (dated today) when it appears and see if that solves the problem.

Ron.

acrymble’s picture

Version: 5.x-1.9 » 5.x-1.x-dev

I ran the April 29 dev version, and still have the same issue with Book Chapter entries leaving an extra period.

rjerome’s picture

I'm not seeing that on my end. Silly question, but are you sure the extra period is not in your database? Does every entry produce an extra period? Also, you might want to turn off any caching you have active.

bekasu’s picture

Status: Needs review » Closed (fixed)

marking issue closed.