# ---- 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 should be provided by R's CITATION processing script
  # instead of using packageDescription().  But if this code is called in another context
  # use packageDescription() to assign meta
  if(!exists("meta") || is.null(meta)){
    meta <- packageDescription(pkg) 
  }
  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 should be provided by R's CITATION processing script
  # instead of using packageDescription().  But if this code is called in another context
  # use packageDescription() to assign meta
  if(!exists("meta") || is.null(meta)){
      meta <- packageDescription(pkg) 
  }

  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("CRAN.R-project.org/package=",meta$Package,sep="")
           )
}
# ---- END STATNET CITATION FUNCTIONS ----
statnet.cite.head("statnet")
statnet.cite.pkg("statnet")

bibentry("Article",
         title = "statnet: Software Tools for the Representation, Visualization, Analysis and Simulation of Network Data",
         author = personList(person("Mark S.", "Handcock", role=c("aut"), email="handcock@stat.ucla.edu"),
           person("David R.", "Hunter", role=c("aut"), email="dhunter@stat.psu.edu"),
           person("Carter T.", "Butts", role=c("aut"), email="buttsc@uci.edu"),
           person("Steven M.", "Goodreau", role=c("aut"), email="goodreau@u.washington.edu"),
           person("Martina", "Morris", role=c("aut"), email="morrism@u.washington.edu")),
         journal = "Journal of Statistical Software",
         year = 2008,
         volume = 24,
         number = 1,
	 pages = "1--11",
         url = "http://www.jstatsoft.org/v24/i01")

statnet.cite.foot("statnet")
