/** * Creates a citation object for each citation parser function. * * Reads flags and parameters from WCArgumentReader object, * then creates an appropriate child of class WCStyle based on the * first parameter after the colon, then returns the citation as text. * @remark Note that this $parser is guaranteed to be the same parser that * initialized the object. * * @param WCArgumentReader $argumentReader * @return string Unique marker for citation. */ public function parseCitation( WCArgumentReader $argumentReader ) { # Use the explicit citation style if defined, or use last style. $styleClassName = $argumentReader->getStyleClassName(); if ( $styleClassName ) { # Store citation style in a running database of style object singlets. $this->currentDefaultStyle = self::getStyle($styleClassName); } # A citation function, with no data, may exist merely to define the citation style. if ( $argumentReader->isEmpty() ) { ++$this->citationCount; return ''; } $reference = new WCReference(); $citation = new WCCitation( $reference ); $citation->readArguments( $argumentReader ); $reference->finalize(); # Store reference in database that checks for uniqueness. # $citation->reference will be reloaded later, after all citations are read. $citation->distance = $this->referenceStore->addUniqueReference( $this->citationCount, $reference ); # Is this a citation explicitly inserted in bibliography tags? # If so, then we will not be leaving behind a marker. if ( $this->bibliographyLevel > 0 ) { ++$this->citationCount; return ''; # Only a single marker is left behind per bibliography. } # Determine whether the citation is in a note, or inline. $section = $this->sectionStack[ $this->sectionStackPointer ]; if ( $this->noteLevel > 0 ) { $section->addNoteCite( $this->citationCount, $citation ); } else { $section->addInlineCite( $this->citationCount, $citation ); } # Store citation and leave behind a random marker for later replacement by the citation: $this->citations[ $this->citationCount++ ] = $citation; return $citation->marker; }