diff --git a/DESCRIPTION b/DESCRIPTION index 7170f2e3b4b1169587b3dda9867de80b610998e3..214e46f3b0c5ef59b2fceea7432b4a5a0eda3d0d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: Mediawikir Type: Package Title: Connects to a mediawiki instance and writes in it what you want. Provides classes Mediawikir and Batchator. -Version: 0.1.12 +Version: 0.1.13 Author: Mathieu Loiseau Maintainer: Mathieu Loiseau <loiseaum@univ-grenoble-alpes.fr> Description: Mediawikir class can be used to post the output of an R script directly into a mediawiki instance. Batchator class allows batch page creation. diff --git a/R/class.R b/R/class.R index a4fcc053b35e5b9a3e7ef3b891f6ee92892d6a94..cc12ddff2803c610ebab1b34e39076aed4a63f96 100644 --- a/R/class.R +++ b/R/class.R @@ -289,9 +289,23 @@ Mediawikir <- R6Class("Mediawikir", }, ###### - # replaceSingleLineTemplateField + #' Replaces a field of a template in the selected \code{page}. + #' + #' This method does not work with numbered parameters. If the sought field does not exist, adds it at the beginning of the template. + #' + #' Right now it works only for pages that only contain one occurence of the parameter (it does not take outer context into account) + #' + #' Additionnally, this function is not made for templates the value of which spans accross multiple lines. + #' @param field The name of the field concerned + #' @param newValue The new value of the field + #' @return A message logging operations + #' @examples + #' obj <- Mediawikir$new("http://wiki.lezinter.net", "user","pass","installDir") + #' obj$setPage("Title of the page to modify (or its ID)") + #' obj$replaceSingleLineTemplateField("attribute","new value") + #' #Will replace |attribute=* by |attribute=new value (or create it) ###### - replaceSingleLineTemplateField = function(field="", newValue="", template=""){ + replaceSingleLineTemplateField = function(field="", newValue=""){ success <- self$getContent() if(success != FALSE){ search <- paste("\\|", field, "\\=[^\\|\\}\\n]*", sep="") diff --git a/man/Mediawikir.Rd b/man/Mediawikir.Rd index cf05bc532fdcd0dcfd747e6eb86a295143f9ced3..201f79598059df026c738d77554fff09f02227b5 100644 --- a/man/Mediawikir.Rd +++ b/man/Mediawikir.Rd @@ -65,6 +65,13 @@ A Mediawikir controller serves to connect to a mediawiki API as a registered use \item{\code{newValue}}{The new value of the field} }} } +Replaces a field of a template in the selected \code{page}. + +This method does not work with numbered parameters. If the sought field does not exist, adds it at the beginning of the template. + +Right now it works only for pages that only contain one occurence of the parameter (it does not take outer context into account) + +Additionnally, this function is not made for templates the value of which spans accross multiple lines. } \examples{ @@ -77,6 +84,15 @@ A Mediawikir controller serves to connect to a mediawiki API as a registered use mwHandler$addContent(paste("[[",fileName,"]]",sep="")) mwHandler$postContent() mwHandler$replaceSingleLineTemplateField("attribute", "newValue") + +## ------------------------------------------------ +## Method `Mediawikir$replaceSingleLineTemplateField` +## ------------------------------------------------ + +obj <- Mediawikir$new("http://wiki.lezinter.net", "user","pass","installDir") +obj$setPage("Title of the page to modify (or its ID)") +obj$replaceSingleLineTemplateField("attribute","new value") +#Will replace |attribute=* by |attribute=new value (or create it) } \keyword{mediawiki} \section{Public fields}{ @@ -171,11 +187,30 @@ A Mediawikir controller serves to connect to a mediawiki API as a registered use \if{html}{\out{<a id="method-replaceSingleLineTemplateField"></a>}} \subsection{Method \code{replaceSingleLineTemplateField()}}{ \subsection{Usage}{ -\if{html}{\out{<div class="r">}}\preformatted{Mediawikir$replaceSingleLineTemplateField( - field = "", - newValue = "", - template = "" -)}\if{html}{\out{</div>}} +\if{html}{\out{<div class="r">}}\preformatted{Mediawikir$replaceSingleLineTemplateField(field = "", newValue = "")}\if{html}{\out{</div>}} +} + +\subsection{Arguments}{ +\if{html}{\out{<div class="arguments">}} +\describe{ +\item{\code{field}}{The name of the field concerned} + +\item{\code{newValue}}{The new value of the field} +} +\if{html}{\out{</div>}} +} +\subsection{Returns}{ +A message logging operations +} +\subsection{Examples}{ +\if{html}{\out{<div class="r example copy">}} +\preformatted{obj <- Mediawikir$new("http://wiki.lezinter.net", "user","pass","installDir") +obj$setPage("Title of the page to modify (or its ID)") +obj$replaceSingleLineTemplateField("attribute","new value") +#Will replace |attribute=* by |attribute=new value (or create it) +} +\if{html}{\out{</div>}} + } }