Sitemap
extends AbstractFile
in package
Class for representing sitemap files
Tags
Table of Contents
- XHTML_NAMESPACE = 'xmlns:xhtml="http://www.w3.org/1999/xhtml"'
- $alternativeLanguages : array<string|int, mixed>
- Alternative languages
- $frequency : string
- Frequency of URL updates (always, daily, weekly, monthly, yearly, never)
- $topTag : string
- Top-level tag.
- $urls : array<string|int, mixed>
- URLs in map.
- $xhtmlNamespaceNeeded : bool
- Whether the XHTML namespace is needed
- __construct() : mixed
- Constructor
- addUrl() : void
- Add a URL to the map.
- clear() : void
- Remove all entries
- getCount() : int
- Get the count of items
- isEmpty() : bool
- Check if the sitemap is empty
- toString() : string
- Get the map as a string.
- write() : bool
- Write the map to a file on disk.
- getEntry() : string
- Translate a URL into an appropriate entry for this sitemap file.
- getExtraNamespaces() : array<string|int, mixed>
- Get any extra namespace declarations needed for the sitemap
Constants
XHTML_NAMESPACE
public
mixed
XHTML_NAMESPACE
= 'xmlns:xhtml="http://www.w3.org/1999/xhtml"'
Properties
$alternativeLanguages
Alternative languages
protected
array<string|int, mixed>
$alternativeLanguages
= []
$frequency
Frequency of URL updates (always, daily, weekly, monthly, yearly, never)
protected
string
$frequency
$topTag
Top-level tag.
protected
string
$topTag
$urls
URLs in map.
protected
array<string|int, mixed>
$urls
= []
$xhtmlNamespaceNeeded
Whether the XHTML namespace is needed
protected
bool
$xhtmlNamespaceNeeded
= false
Methods
__construct()
Constructor
public
__construct([string $frequency = 'weekly' ]) : mixed
Parameters
- $frequency : string = 'weekly'
-
Frequency of URL updates
Return values
mixed —addUrl()
Add a URL to the map.
public
addUrl(string|array<string|int, mixed> $url) : void
Parameters
- $url : string|array<string|int, mixed>
-
URL as a string or as an associative array
Return values
void —clear()
Remove all entries
public
clear() : void
Return values
void —getCount()
Get the count of items
public
getCount() : int
Return values
int —isEmpty()
Check if the sitemap is empty
public
isEmpty() : bool
Return values
bool —toString()
Get the map as a string.
public
toString() : string
Return values
string —write()
Write the map to a file on disk.
public
write(string $file) : bool
Parameters
- $file : string
-
Target filename
Return values
bool —getEntry()
Translate a URL into an appropriate entry for this sitemap file.
protected
getEntry(string|array<string|int, mixed> $url) : string
Parameters
- $url : string|array<string|int, mixed>
-
URL as a string or as an associative array
Return values
string —XML fragment
getExtraNamespaces()
Get any extra namespace declarations needed for the sitemap
protected
getExtraNamespaces() : array<string|int, mixed>