% $Id: authoryear.bbx,v 0.8e 2009/07/04 15:02:31 lehman beta $

\ProvidesFile{authoryear.bbx}
[\abx@bbxid $Id: authoryear.bbx,v 0.8e 2009/07/04 15:02:31 lehman beta $]

\RequireBibliographyStyle{standard}
\ExecuteBibliographyOptions{labelyear,sorting=nyt,pagetracker}

\DeclareFieldFormat{shorthandwidth}{#1}
\renewcommand*{\thebibitem}{\item}
\renewcommand*{\thelositem}{\item}
\setlength{\bibitemsep}{0pt}

\renewenvironment*{thebibliography}
  {\list
     {}
     {\setlength{\leftmargin}{\bibhang}%
      \setlength{\itemindent}{-\leftmargin}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}}}
  {\endlist}

\renewenvironment*{theshorthands}
  {\list
     {\printfield[shorthandwidth]{shorthand}}
     {\setlength{\labelwidth}{\shorthandwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist}

\InitializeBibliographyStyle{%
  \global\undef\bbx@lasthash}

\renewbibmacro*{author}{%
  \ifthenelse{\ifuseauthor\AND\NOT\ifnameundef{author}}
    {\ifthenelse{\iffieldequals{fullhash}{\bbx@lasthash}\AND
                 \NOT\iffirstonpage}
       {\bibnamedash}
       {\savefield{fullhash}{\bbx@lasthash}%
        \printnames{author}%
	\iffieldundef{authortype}
	  {\setunit{\addspace}}
	  {\setunit{\addcomma\space}}}%
     \iffieldundef{authortype}
       {}
       {\usebibmacro{authorstrg}%
	\setunit{\addspace}}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\addspace}}%
  \usebibmacro{year+labelyear}}

\renewbibmacro*{editor}{%
  \usebibmacro{bbx:editor}{editorstrg}}
\renewbibmacro*{editor+others}{%
  \usebibmacro{bbx:editor}{editor+othersstrg}}
\newbibmacro*{bbx:editor}[1]{%
  \ifthenelse{\ifuseeditor\AND\NOT\ifnameundef{editor}}
    {\ifthenelse{\iffieldequals{fullhash}{\bbx@lasthash}\AND
                 \NOT\iffirstonpage}
       {\bibnamedash}
       {\printnames{editor}%
	\setunit{\addcomma\space}%
	\savefield{fullhash}{\bbx@lasthash}}%
     \usebibmacro{#1}%
     \clearname{editor}%
     \setunit{\addspace}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\addspace}}%
  \usebibmacro{year+labelyear}}

\renewbibmacro*{translator}{%
  \usebibmacro{bbx:translator}{translatorstrg}}
\renewbibmacro*{translator+others}{%
  \usebibmacro{bbx:translator}{translator+othersstrg}}
\newbibmacro*{bbx:translator}[1]{%
  \ifthenelse{\ifusetranslator\AND\NOT\ifnameundef{translator}}
    {\ifthenelse{\iffieldequals{fullhash}{\bbx@lasthash}\AND
                 \NOT\iffirstonpage}
       {\bibnamedash}
       {\printnames{translator}%
	\setunit{\addcomma\space}%
	\savefield{fullhash}{\bbx@lasthash}}%
     \usebibmacro{translator+othersstrg}%
     \clearname{translator}%
     \setunit{\addspace}}%
    {\global\undef\bbx@lasthash
     \usebibmacro{labeltitle}%
     \setunit*{\addspace}}%
  \usebibmacro{year+labelyear}}

\newbibmacro*{year+labelyear}{%
  \iffieldundef{year}
    {}
    {\printtext[parens]{%
       \printfield{year}%
       \printfield{labelyear}}}}

\newbibmacro*{labeltitle}{%
  \iffieldundef{label}
    {\iffieldundef{shorttitle}
       {\printfield{title}%
        \clearfield{title}}
       {\printfield[title]{shorttitle}}}
    {\printfield{label}}}

\renewbibmacro*{issue+date}{%
  \ifthenelse{\iffieldundef{issue}\AND\iffieldundef{month}}
    {}
    {\printtext[parens]{%
       \iffieldundef{issue}
         {\iffieldundef{day}
            {\printfield{month}%
             \setunit{\addspace}%
             \printfield{year}}
            {\printtext{\bibdate}}}
         {\printfield{issue}%
          \setunit{\addspace}%
          \printfield{year}}}}%
  \newunit}

\renewbibmacro*{publisher+location+year}{%
  \printlist{location}%
  \setunit*{\addcolon\space}%
  \printlist{publisher}%
  \newunit}

\renewbibmacro*{institution+location+year}{%
  \printlist{location}%
  \setunit*{\addcolon\space}%
  \printlist{institution}%
  \newunit}

\renewbibmacro*{location+year}{%
  \printlist{location}}

\renewbibmacro*{date}{%
  \iffieldundef{year}
    {}
    {\iffieldundef{month}
       {}
       {\iffieldundef{day}
          {\printfield{month}%
           \setunit{\addspace}%
           \printfield{year}}
          {\printtext{\bibdate}}}}}

\endinput
