Semantic MediaWiki and related extensions
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
SMWInfolink Class Reference

Public Member Functions

 __construct ( $internal, $caption, $target, $style=false, array $params=[])
 
 isRestricted ( $isRestricted)
 
 setCompactLink ( $isCompactLink=true)
 
 setParameter ( $value, $key=false)
 
 getParameter ( $key)
 
 setCaption ( $caption)
 
 setStyle ( $style)
 
 setLinkAttributes (array $linkAttributes)
 
 getText ( $outputformat, $linker=null)
 
 getHTML ( $linker=null)
 
 getWikiText ( $linker=null)
 
 getURL ()
 
 getLocalURL ()
 

Static Public Member Functions

static newInternalLink ( $caption, $target, $style=false, array $params=[])
 
static newExternalLink ( $caption, $url, $style=false, array $params=[])
 
static newPropertySearchLink ( $caption, $propertyName, $propertyValue, $style='smwsearch')
 
static newInversePropertySearchLink ( $caption, $subject, $propertyname, $style=false)
 
static newBrowsingLink ( $caption, $titleText, $style='smwbrowse')
 
static encodeParameters (array $params, $forTitle=true)
 
static decodeParameters ( $titleParam='', $allParams=false)
 
static encodeCompactLink ( $value, $compound=false)
 
static decodeCompactLink ( $value)
 

Public Attributes

const LINK_UPPER_LENGTH_RESTRICTION = 2000
 

Protected Member Functions

 getLinker (&$linker=null)
 

Protected Attributes

 $mTarget
 
 $mCaption
 
 $mStyle
 
 $mInternal
 
 $mParams
 

Detailed Description

This class mainly is a container to store URLs for the factbox in a clean way. The class provides methods for creating source code for realising them in wiki or html contexts.

GNU GPL v2+

Since
1.0
Author
Markus Krötzsch
Jeroen De Dauw
mwjames

Constructor & Destructor Documentation

◆ __construct()

SMWInfolink::__construct (   $internal,
  $caption,
  $target,
  $style = false,
array  $params = [] 
)

Create a new link to some internal page or to some external URL.

Parameters
boolean$internalIndicates whether $target is a page name (true) or URL (false).
string$captionThe label for the link.
string$targetThe actual link target.
mixed$styleCSS class of a span to embedd the link into, or false if no extra style is required.
array$paramsArray of parameters, format $name => $value, if any.

Member Function Documentation

◆ decodeCompactLink()

static SMWInfolink::decodeCompactLink (   $value)
static
Since
3.0
Parameters
string$value
Returns
string

◆ decodeParameters()

static SMWInfolink::decodeParameters (   $titleParam = '',
  $allParams = false 
)
static

Obtain an array of parameters from the parameters given to some HTTP service. In particular, this function performs all necessary decoding as may be needed, e.g., to recover the proper parameter strings after encoding for use in wiki title names as done by SMWInfolink::encodeParameters().

If $allparams is set to true, it is assumed that further data should be obtained from the global $wgRequest, and all given parameters are read.

$titleparam is the string extracted by MediaWiki from special page calls of the form Special:Something/titleparam Note: it is assumed that the given $titleparam is already urldecoded, as is normal when getting such parameters from MediaWiki. SMW-escaped parameters largely prevent double decoding effects (i.e. there are no new "%" after one pass of urldecoding)

The function SMWInfolink::encodeParameters() can be used to create a suitable encoding. It is strongly recommended to not create any code that depends on the concrete way of how parameters are encoded within this function, and to always use the respective encoding/decoding methods instead.

Parameters
string$titleParam
boolean$allParams

◆ encodeCompactLink()

static SMWInfolink::encodeCompactLink (   $value,
  $compound = false 
)
static
Since
3.0
Parameters
string$value
Returns
string|array

◆ encodeParameters()

static SMWInfolink::encodeParameters ( array  $params,
  $forTitle = true 
)
static

Encode an array of parameters, formatted as $name => $value, to a parameter string that can be used for linking. If $forTitle is true (default), then the parameters are encoded for use in a MediaWiki page title (useful for making internal links to parameterised special pages), otherwise the parameters are encoded HTTP GET style. The parameter name "x" is used to collect parameters that do not have any string keys in GET, and hence "x" should never be used as a parameter name.

The function SMWInfolink::decodeParameters() can be used to undo this encoding. It is strongly recommended to not create any code that depends on the concrete way of how parameters are encoded within this function, and to always use the respective encoding/decoding methods instead.

Parameters
array$params
boolean$forTitle

: SMW's parameter separator, must not occur within params

◆ getHTML()

SMWInfolink::getHTML (   $linker = null)

Return hyperlink for this infolink in HTML format.

Returns
string

◆ getLinker()

SMWInfolink::getLinker ( $linker = null)
protected

Return a Linker object, using the parameter $linker if not null, and creatng a new one otherwise. $linker is usually a user skin object, while the fallback linker object is not customised to user settings.

Returns
Linker

◆ getLocalURL()

SMWInfolink::getLocalURL ( )
Since
3.0
Returns
string

◆ getParameter()

SMWInfolink::getParameter (   $key)

Get the value of some named parameter, or null if no parameter of that name exists.

◆ getText()

SMWInfolink::getText (   $outputformat,
  $linker = null 
)

Returns a suitable text string for displaying this link in HTML or wiki, depending on whether $outputformat is SMW_OUTPUT_WIKI or SMW_OUTPUT_HTML.

The parameter $linker controls linking of values such as titles and should be some Linker object (for HTML output). Some default linker will be created if needed and not provided.

◆ getURL()

SMWInfolink::getURL ( )

Return a fully qualified URL that points to the link target (whether internal or not). This function might be used when the URL is needed outside normal links, e.g. in the HTML header or in some metadata file. For making normal links, getText() should be used.

Returns
string

◆ getWikiText()

SMWInfolink::getWikiText (   $linker = null)

Return hyperlink for this infolink in wiki format.

Returns
string

◆ isRestricted()

SMWInfolink::isRestricted (   $isRestricted)
Since
3.0
Parameters
boolean$isRestricted

◆ newBrowsingLink()

static SMWInfolink::newBrowsingLink (   $caption,
  $titleText,
  $style = 'smwbrowse' 
)
static

Static function to construct links to the browsing special.

Parameters
string$captionThe label for the link.
string$titleText
mixed$styleCSS class of a span to embedd the link into, or false if no extra style is required.
Returns
SMWInfolink

◆ newExternalLink()

static SMWInfolink::newExternalLink (   $caption,
  $url,
  $style = false,
array  $params = [] 
)
static

Create a new link to an external location $url.

Parameters
string$captionThe label for the link.
string$urlThe actual link target.
mixed$styleCSS class of a span to embedd the link into, or false if no extra style is required.
array$paramsArray of parameters, format $name => $value, if any.
Returns
SMWInfolink

◆ newInternalLink()

static SMWInfolink::newInternalLink (   $caption,
  $target,
  $style = false,
array  $params = [] 
)
static

Create a new link to an internal page $target. All parameters are mere strings as used by wiki users.

Parameters
string$captionThe label for the link.
string$targetThe actual link target.
mixed$styleCSS class of a span to embedd the link into, or false if no extra style is required.
array$paramsArray of parameters, format $name => $value, if any.
Returns
SMWInfolink

◆ newInversePropertySearchLink()

static SMWInfolink::newInversePropertySearchLink (   $caption,
  $subject,
  $propertyname,
  $style = false 
)
static

Static function to construct links to inverse property searches.

Parameters
string$captionThe label for the link.
string$subject
string$propertyName
mixed$styleCSS class of a span to embed the link into, or false if no extra style is required.
Returns
SMWInfolink

◆ newPropertySearchLink()

static SMWInfolink::newPropertySearchLink (   $caption,
  $propertyName,
  $propertyValue,
  $style = 'smwsearch' 
)
static

Static function to construct links to property searches.

Parameters
string$captionThe label for the link.
string$propertyName
string$propertyValue
mixed$styleCSS class of a span to embedd the link into, or false if no extra style is required.
Returns
SMWInfolink

◆ setCaption()

SMWInfolink::setCaption (   $caption)

Change the link text.

◆ setCompactLink()

SMWInfolink::setCompactLink (   $isCompactLink = true)
Since
3.0
Parameters
boolean$isCompactLink

◆ setLinkAttributes()

SMWInfolink::setLinkAttributes ( array  $linkAttributes)

Modify link attributes

Since
3.0
Parameters
array$linkAttributes

◆ setParameter()

SMWInfolink::setParameter (   $value,
  $key = false 
)

Set (or add) parameter values for an existing link.

Parameters
mixed$value
mixed$key

◆ setStyle()

SMWInfolink::setStyle (   $style)

Change the link's CSS class.


The documentation for this class was generated from the following file:

About | General disclaimer | Privacy policy