Page HTMLPage AdministrationPage

public class AdministrationPage extends HTMLPage

class.administrationpage.php #18

The AdministrationPage class represents a Symphony backend page. It extends the HTMLPage class and unlike the Frontend, is generated using a number XMLElement objects. Instances of this class override the view, switchboard and action functions to construct the page. These functions act as pseudo MVC, with the switchboard being controller, and the view/action being the view.

Properties

Alert $Alert

An instance of the Alert class. Used to display page level messages to Symphony users.

XMLElement $Contents

A <div> that contains the content of a Symphony backend page.

XMLElement $Footer

A <div> that contains the Symphony footer, typically the version and the current Author's details.

XMLElement $Header

A <div> that contains the header of a Symphony backend page, which typically contains the Site title and the navigation.

XMLElement $Wrapper

As the name suggests, a <div> that holds the following $Header, $Contents and $Footer.

Administration $_Parent

An instance of the Administration class

See Also
array $_context

An associative array describing this pages context. This can include the section handle, the current entry_id, the page name and any flags such as 'saved' or 'created'. This variable often provided in delegates so extensions can manipulate based off the current context or add new keys.

array $_navigation

An associative array of the navigation where the key is the group index, and the value is an associative array of 'name', 'index' and 'children'. Name is the name of the this group, index is the same as the key and children is an associative array of navigation items containing the keys 'link', 'name' and 'visible'. In Symphony, all navigation items are contained within a group, and the group has no 'default' link, therefore it is up to the children to provide the link to pages. This link should be relative to the Symphony path, although it is possible to provide an absolute link by providing a key, 'relative' with the value false.

Methods

void __buildNavigation()

This function populates the $_navigation array with an associative array of all the navigation groups and their links. Symphony only supports one level of navigation, so children links cannot have children links. The default Symphony navigation is found in the ASSETS/navigation.xml folder. This is loaded first, and then the Section navigation is built, followed by the Extension navigation. Additionally, this function will set the active group of the navigation by checking the current page against the array of links.

See Also
void __construct(Administration $parent)

Constructor takes the Administration instance and sets it to be the $this->_Parent. Calls the parent constructor to set up the basic HTML, Head and Body XMLElements. This function also sets the XMLElement type to be HTML, instead of XML

Parameters
  • $parent AdministrationThe Administration object that this page has been created from passed by reference

array __fetchAvailablePageTypes(string $context, XMLElement $wrapper)

Returns all the page types that exist in this Symphony install. There are 5 default system page types, and new types can be added by Developers via the Page Editor.

Returns

An array of strings of the page types used in this Symphony install. At the minimum, this will be an array with the values 'index', 'XML', 'admin', '404' and '403'.

void __switchboard(string $type)

The __switchboard function acts as a controller to display content based off the $type. By default, the $type is 'view' but it can be set also set to 'action'. The $type is prepended by __ and the context is append to the $type to create the name of the function that will provide that logic. For example, if the $type was action and the context of the current page was new, the resulting function to be called would be named __actionNew(). If an action function is not provided by the Page, this function returns nothing, however if a view function is not provided, a 404 page will be returned.

Parameters
  • $type stringEither 'view' or 'action', by default this will be 'view'

void action()

This function is called when $_REQUEST contains a key of 'action'. Any logic that needs to occur immediately for the action to complete should be contained within this function. By default this calls the __switchboard with the type set to 'action'.

See Also
void appendAlert()

If $this->Alert is set, it will be prepended to the Form of this page. A delegate is fired here to allow extensions to provide their their own Alert messages to the page. Note that only one Alert is allowed per page at any one time.

Uses
  • AppendPageAlert
void appendFooter()

Creates the Symphony footer for an Administration page. By default this includes the installed Symphony version and the currently logged in Author. A delegate is provided to allow extensions to manipulate the footer HTML, which is an XMLElement of a <ul> element.

Uses
  • AddElementToFooter
void appendNavigation(string $context)

This function will append the Navigation to the AdministrationPage. It fires a delegate, NavigationPreRender, to allow extensions to manipulate the navigation. Extensions should not use this to add their own navigation, they should provide the navigation through their fetchNavigation function. Note with the Section navigation groups, if there is only one section in a group and that section is set to visible, the group will not appear in the navigation.

Uses
  • NavigationPreRender
See Also
void appendSubheading(string $value, XMLElement|string $html)

Appends the heading of this Symphony page to the Form element. If a link is provided, it will be append to $value

Parameters
  • $value stringThe heading text

  • $html XMLElement|stringSome HTML to append to the heading, this can be provided as an XMLElement or as a string. traditionally Symphony uses this to append a link to the heading

void build(array $context)

This function initialises a lot of the basic elements that make up a Symphony backend page such as the default stylesheets and scripts, the navigation and the footer. Any alerts are also appended by this function. view() is called to build the actual content of the page. Delegates fire to allow extensions to add elements to the <head> and footer.

Uses
  • InitaliseAdminPageHead
  • AppendElementBelowView
Parameters
  • $context arrayAn associative array describing this pages context. This can include the section handle, the current entry_id, the page name and any flags such as 'saved' or 'created'. This list is not exhaustive and extensions can add their own keys to the array.

See Also
boolean canAccessPage(string $context)

Checks the current Symphony Author can access the current page. This includes the check to ensure that an Author cannot access a hidden section.

Returns

True if the Author can access the current page, false otherwise

string generate()

Appends the $this->Header, $this->Contents and $this->Footer to $this->Wrapper before adding the ID and class attributes for the <body> element. After this has completed the parent's generate function is called which will convert the XMLElement's into strings ready for output

See Also
array getNavigationArray(string $context, array $nav)

Returns the $_navigation variable of this Page. If it is empty, it will be built by __buildNavigation

See Also
void pageAlert(string $message, string $type)

Sets this page's $Alert to an instance of the Alert class of a given Alter type. Unless the Alert is an Error, it is required the a message be passed to this function.

Parameters
  • $message stringThe message to display to users

  • $type stringAn Alert constant, being Alert::NOTICE, Alert::ERROR or Alert::SUCCESS. The differing types will show the error in a different style in the backend.

void setBodyClass(string $class)

Setter function to set the class attribute on the <body> element. This function will respect any previous classes that have been added to this <body>

Parameters
  • $class stringThe string of the classname, multiple classes can be specified by uses a space separator

void setPageType(string $type)

Adds either the tables or forms stylesheet to the page. By default this is forms, but can be override by passing 'table' to the function. The stylesheets reside in the ASSETS folder

Parameters
  • $type stringEither 'form' or 'table'. Defaults to 'form'

void view()

Called to build the content for the page. This function immediately calls __switchboard() which acts a bit of a controller to show content based on off a type, such as 'view' or 'action'. AdministrationPages can override this function to just display content if they do not need the switchboard functionality

See Also
void wrapFormElementWithError(XMLElement $element, string $message)

Will wrap a <div> around a desired element to trigger the default Symphony error styling.

Parameters
  • $element XMLElementThe element that should be wrapped with an error

  • $message stringThe text for this error. This will be appended after the $element, but inside the wrapping <div>

See Also
Deprecated

This function is deprecated and will be removed in the next version of Symphony. This preferred way to wrap an element with an error is using Widget::wrapFormElementWithError

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details