# ---- 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=NULL){
  if(!is.null(pkg)){
    meta <- try(utils::packageDescription(pkg))
    if(inherits(meta,"try-error") || is.na(meta)) return()
  }
  # 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 ----'
statnet.cite.head("ergm.count")
statnet.cite.pkg()
statnet.cite.pkg("ergm")
statnet.cite.foot("ergm.count")
