vB_Xml_Import_PageTemplate
extends vB_Xml_Import
in package
Table of Contents
- OPTION_ADDSPECIFICWIDGETS = 32
- OPTION_ADDWIDGETS = 8
- OPTION_IGNOREMISSINGPARENTS = 4
- OPTION_IGNOREMISSINGROUTES = 2
- OPTION_OVERWRITE = 1
- OPTION_OVERWRITECOLUMN = 16
- TYPE_CHANNEL = 'channels'
- TYPE_PAGE = 'pages'
- TYPE_PAGETEMPLATE = 'pageTemplates'
- TYPE_ROUTE = 'routes'
- TYPE_SCREENLAYOUT = 'screenLayouts'
- TYPE_THEME = 'themes'
- TYPE_WIDGET = 'widgets'
- $db : vB_dB_Assertor
- $importedElements : array<string|int, mixed>
- $options : int
- $overwriteColumn : string
- Column to overwrite, if OPTION_OVERWRITECOLUMN is set
- $parsedXML : array<string|int, mixed>
- $productid : mixed
- $referencedWidgets : array<string|int, mixed>
- Widgets referenced by instances in the imported template
- $widgetsToAdd : mixed
- List of specific widgets that should be added. Used only in conjuction with OPTION_ADDSPECIFICWIDGETS
- __construct() : mixed
- __serialize() : mixed
- __sleep() : mixed
- __unserialize() : mixed
- __wakeup() : mixed
- getImportedId() : int
- Returns the id for an imported element
- importFromFile() : mixed
- Imports objects from the specified filepath
- importFromParsedXML() : mixed
- Imports objects from parsed XML starting at the base of the relevant objects.
- parseFile() : mixed
- replaceChannelGuidsInWidgetConfigs() : mixed
- Replaces the text "channelguid:<GUID>" in any config options with the actual channel nodeid. This must be called after channels are imported.
- replacePhrasePlaceholdersInWidgetConfigs() : mixed
- Replaces the text "phrase:<phrasevarname>" in any config options with the actual phrase text.
- setOptions() : mixed
- setOverwriteColumn() : mixed
- Sets the column to overwrite, if OPTION_OVERWRITECOLUMN is set
- setWidgetsToAdd() : mixed
- Sets widgets to be added in conjuction with the OPTION_ADDSPECIFICWIDGETS flag
- canAddWidget() : mixed
- Checks if the given widget can be added. Used only in conjuction with OPTION_ADDSPECIFICWIDGETS.
- getXmlList() : The
- Get a list from the parsed xml array
- import() : mixed
- Import objects
- replacePhrasePlaceholdersInArray() : array<string|int, mixed>
- If an array value is of the form "phrase:<phrasevarname>" replace it with the actual phrase.
- setImportedId() : mixed
- Stores an imported element with the new id
- widgetInstanceExists() : bool
- Checks to see if the described widget instance already exists on the page template. Used by the OPTION_ADDSPECIFICWIDGETS flag.
- checkWidgets() : mixed
- Checks if all referenced widgets are already defined Also sets referencedWidgets class attribute to be used while importing
Constants
OPTION_ADDSPECIFICWIDGETS
public
mixed
OPTION_ADDSPECIFICWIDGETS
= 32
OPTION_ADDWIDGETS
public
mixed
OPTION_ADDWIDGETS
= 8
OPTION_IGNOREMISSINGPARENTS
public
mixed
OPTION_IGNOREMISSINGPARENTS
= 4
OPTION_IGNOREMISSINGROUTES
public
mixed
OPTION_IGNOREMISSINGROUTES
= 2
OPTION_OVERWRITE
public
mixed
OPTION_OVERWRITE
= 1
OPTION_OVERWRITECOLUMN
public
mixed
OPTION_OVERWRITECOLUMN
= 16
TYPE_CHANNEL
public
mixed
TYPE_CHANNEL
= 'channels'
TYPE_PAGE
public
mixed
TYPE_PAGE
= 'pages'
TYPE_PAGETEMPLATE
public
mixed
TYPE_PAGETEMPLATE
= 'pageTemplates'
TYPE_ROUTE
public
mixed
TYPE_ROUTE
= 'routes'
TYPE_SCREENLAYOUT
public
mixed
TYPE_SCREENLAYOUT
= 'screenLayouts'
TYPE_THEME
public
mixed
TYPE_THEME
= 'themes'
TYPE_WIDGET
public
mixed
TYPE_WIDGET
= 'widgets'
Properties
$db
protected
vB_dB_Assertor
$db
$importedElements
protected
static array<string|int, mixed>
$importedElements
$options
protected
int
$options
$overwriteColumn
Column to overwrite, if OPTION_OVERWRITECOLUMN is set
protected
string
$overwriteColumn
= ''
$parsedXML
protected
array<string|int, mixed>
$parsedXML
$productid
protected
mixed
$productid
$referencedWidgets
Widgets referenced by instances in the imported template
protected
array<string|int, mixed>
$referencedWidgets
= array()
$widgetsToAdd
List of specific widgets that should be added. Used only in conjuction with OPTION_ADDSPECIFICWIDGETS
protected
mixed
$widgetsToAdd
= array()
Methods
__construct()
public
__construct([mixed $productid = 'vbulletin' ][, mixed $options = 9 ]) : mixed
Parameters
- $productid : mixed = 'vbulletin'
- $options : mixed = 9
Return values
mixed —__serialize()
public
__serialize() : mixed
Return values
mixed —__sleep()
public
__sleep() : mixed
Return values
mixed —__unserialize()
public
__unserialize(mixed $serialized) : mixed
Parameters
- $serialized : mixed
Return values
mixed —__wakeup()
public
__wakeup() : mixed
Return values
mixed —getImportedId()
Returns the id for an imported element
public
static getImportedId(string $type[, string $guid = NULL ]) : int
Parameters
- $type : string
- $guid : string = NULL
Return values
int —importFromFile()
Imports objects from the specified filepath
public
importFromFile(string $filepath[, string $guid = false ]) : mixed
Parameters
- $filepath : string
- $guid : string = false
-
Only import the record associated with this guid
Return values
mixed —importFromParsedXML()
Imports objects from parsed XML starting at the base of the relevant objects.
public
importFromParsedXML(array<string|int, mixed> $parsedXML) : mixed
Parameters
- $parsedXML : array<string|int, mixed>
Return values
mixed —parseFile()
public
static parseFile(mixed $filepath) : mixed
Parameters
- $filepath : mixed
Return values
mixed —replaceChannelGuidsInWidgetConfigs()
Replaces the text "channelguid:<GUID>" in any config options with the actual channel nodeid. This must be called after channels are imported.
public
replaceChannelGuidsInWidgetConfigs() : mixed
Return values
mixed —replacePhrasePlaceholdersInWidgetConfigs()
Replaces the text "phrase:<phrasevarname>" in any config options with the actual phrase text.
public
replacePhrasePlaceholdersInWidgetConfigs() : mixed
This replaces placeholders in any widget config, even ones that already exist, which is why it needs to be done independently of the import, which does not overwrite existing widget instances.
Return values
mixed —setOptions()
public
setOptions(mixed $options) : mixed
Parameters
- $options : mixed
Return values
mixed —setOverwriteColumn()
Sets the column to overwrite, if OPTION_OVERWRITECOLUMN is set
public
setOverwriteColumn(mixed $column) : mixed
Parameters
- $column : mixed
Return values
mixed —setWidgetsToAdd()
Sets widgets to be added in conjuction with the OPTION_ADDSPECIFICWIDGETS flag
public
setWidgetsToAdd(array<string|int, mixed> $widgets) : mixed
Parameters
- $widgets : array<string|int, mixed>
Return values
mixed —canAddWidget()
Checks if the given widget can be added. Used only in conjuction with OPTION_ADDSPECIFICWIDGETS.
protected
canAddWidget(array<string|int, mixed> $widget, mixed $pageTemplateGuid, mixed $pageTemplateId) : mixed
Parameters
- $widget : array<string|int, mixed>
- $pageTemplateGuid : mixed
- $pageTemplateId : mixed
Return values
mixed —getXmlList()
Get a list from the parsed xml array
protected
getXmlList(array<string|int, mixed> $parentxml, string $listname) : The
A common way to format lists in xml is
The problem is a single item is ambiguous
It could be a one element list or it could be a scalar child -- we only know from the context of the data, which the parser doesn't know. Our parser assumes that it is a scalar value unless there are multiple tags with the same name. Therefor so the first is rendered as:
tag['subtag'] = [0 => $element, 1 => $element]
While the second is:
tag['subtag'] = $element.
Rather than handle each list element as a special case if there is only one item in the xml, this function will examine the element passed and if it isn't a 0 indexed array as expect will wrap the single element in an array() call. The first case is not affected and the second is converted to tag['subtag'] = array(0 => $element), which is what we'd actually expect.
This is why we should use JSON.
Parameters
- $parentxml : array<string|int, mixed>
-
-- The parsed XML array containing the list. This must be the direct parent of the lsit
- $listname : string
-
-- The tag name for the list values
Return values
The —list properly regularized to a numerically indexed array.
import()
Import objects
protected
import([mixed $onlyGuid = [] ]) : mixed
Parameters
- $onlyGuid : mixed = []
Return values
mixed —replacePhrasePlaceholdersInArray()
If an array value is of the form "phrase:<phrasevarname>" replace it with the actual phrase.
protected
replacePhrasePlaceholdersInArray(array<string|int, mixed> $array) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
Return values
array<string|int, mixed> —The array with phrases replaced.
setImportedId()
Stores an imported element with the new id
protected
static setImportedId(string $type, string $guid, mixed $newid) : mixed
Parameters
- $type : string
- $guid : string
- $newid : mixed
Return values
mixed —widgetInstanceExists()
Checks to see if the described widget instance already exists on the page template. Used by the OPTION_ADDSPECIFICWIDGETS flag.
protected
widgetInstanceExists(mixed $widgetToAdd, mixed $pageTemplateId) : bool
Parameters
- $widgetToAdd : mixed
- $pageTemplateId : mixed
Return values
bool —checkWidgets()
Checks if all referenced widgets are already defined Also sets referencedWidgets class attribute to be used while importing
private
checkWidgets(array<string|int, mixed> $pageTemplates, mixed $onlyGuid) : mixed
Parameters
- $pageTemplates : array<string|int, mixed>
-
-- the pageTemplates to check. This is expected to come from the XML but must already be a canonical array.
- $onlyGuid : mixed