# ---- BEGIN STATNET CITATION FUNCTIONS ----
# A header function for ensuring that all the statnet packages provide consistent messaging
statnet.cite.head <- function(pkg){
  citHeader(
    paste("`",pkg,"` is part of the Statnet suite of packages.  ",
          "If you are using the `",pkg,"` package for research that will be published, ",
          "we request that you acknowledge this by citing the following.\n",
          'For BibTeX format, use toBibtex(citation("',pkg,'")).',
          sep="")
    )
}

# A footer function for ensuring that all the statnet packages provide consistent messaging
statnet.cite.foot <- function(pkg){
  # the 'meta' variable is be provided by R's CITATION processing script
  citFooter("We have invested a lot of time and effort in creating the",
            "Statnet suite of packages for use by other researchers.",
            "Please cite it in all papers where it is used. The package",pkg," is made distributed under the terms of the license:",meta$License )
}

# generates a consistent bibentry citation for the software manual of the package
statnet.cite.pkg <- function(pkg){
  # the 'meta' variable is provided by R's CITATION processing script
  projhomepage <- "http://www.statnet.org"
  # compute the list of authors  
  auts <- eval(parse(text=meta$`Authors@R`))
  auts <- auts[sapply(auts, function(aut) "aut" %in% aut$role)]
  # create a citation entry for a "software manual" for this version of the software
  # it will be appended with any specific articles defineded inthe package citation file
  bibentry("Manual",
           author = auts,
           title = paste(meta$Package,": ", meta$Title, sep=""),
           organization = paste("The Statnet Project (\\url{", projhomepage, "})",sep=""),
           year         = substr(meta$Date,1,4),
           note         = paste("R package version ", meta$Version, sep=""),
           url          = paste("http://CRAN.R-project.org/package=",meta$Package,sep="")
           )
}
# ---- END STATNET CITATION FUNCTIONS ----'

# specific citation entries for the ergm package
statnet.cite.head("ergm")
statnet.cite.pkg("ergm")

bibentry("Article",
         title = "ergm: A Package to Fit, Simulate and Diagnose Exponential-Family Models for Networks",
         author = personList(as.person("David R. Hunter"),
           as.person("Mark S. Handcock"),
           as.person("Carter T. Butts"),
           as.person("Steven M. Goodreau"),
           as.person("Morris, Martina")),
         journal = "Journal of Statistical Software",
         year = 2008,
         volume = 24,
         number = 3,
	 pages = "1--29")

statnet.cite.foot("ergm")
