Page HTMLPage AdministrationPage

public class AdministrationPage extends HTMLPage

class.administrationpage.php #15

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

array $Alert

An array of Alert objects used to display page level messages to Symphony backend users one by one. Prior to Symphony 2.3 this variable only held a single Alert object.

XMLElement $Breadcrumbs

An object that stores the markup for the breadcrumbs and is only used internally.

XMLElement $Contents

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

XMLElement $Context

A <div> that contains the breadcrumbs, the page title and some contextual actions (e.g. "Create new").

array $Drawer

An array of Drawer widgets for the current page

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.

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/xml/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.

It fires a delegate, NavigationPostBuild, to allow extensions to manipulate the navigation.

Uses
  • NavigationPostBuild
See Also
void __construct()

Constructor calls the parent constructor to set up the basic HTML, Head and Body XMLElement's. This function also sets the XMLElement element style to be HTML, instead of XML

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 addTimestampValidationPageAlert(string $errorMessage, Entry|Section $existingObject, string $action)

Adds a localized Alert message for failed timestamp validations. It also adds meta information about the last author and timestamp.

Parameters
  • $errorMessage stringThe error message to display.

  • $existingObject Entry|SectionThe Entry or section object that failed validation.

  • $action stringThe requested action.

void appendAlert()

If $this->Alert is set, it will be added to this page. The AppendPageAlert delegate is fired to allow extensions to provide their their own Alert messages for this page. Since Symphony 2.3, there may be more than one Alert per page. Alerts are displayed in the order of severity, with Errors first, then Success alerts followed by Notices.

Uses
  • AppendPageAlert
void appendNavigation()

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, array|XMLElement|string $actions)

Appends the heading of this Symphony page to the Context element. Action buttons can be provided (e.g. "Create new") as second parameter.

Parameters
  • $value stringThe heading text

  • $actions array|XMLElement|stringSome contextual actions to append to the heading, they can be provided as an array of XMLElements or strings. Traditionally Symphony uses this to append a "Create new" link to the Context div.

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. The InitialiseAdminPageHead delegate allows extensions to add elements to the <head>. The CanAccessPage delegate allows extensions to restrict access to pages.

Uses
  • InitialiseAdminPageHead
  • CanAccessPage
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 check uses the ASSETS . /xml/navigation.xml file to determine if the current page (or the current page namespace) can be viewed by the currently logged in Author.

Uses
  • CanAccessPage
Returns

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

See Also
boolean doesAuthorHaveAccess(string $item_limit)

Given the limit of the current navigation item or page, this function returns if the current Author can access that item or not.

string generate(null $page)

Appends the $this->Header, $this->Context and $this->Contents to $this->Wrapper before adding the ID and class attributes for the <body> element. This function will also place any Drawer elements in their relevant positions in the page. After this has completed the parent generate() is called which will convert the XMLElement's into strings ready for output.

See Also
array getContext()

Accessor for $this->_context which includes contextual information about the current page such as the class, file location or page root. This information varies depending on if the page is provided by an extension, is for the publish area, is the login page or any other page

array getNavigationArray(string $context, array $nav)

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

When it calls __buildNavigation, it fires a delegate, NavigationPostBuild, to allow extensions to manipulate the navigation.

Uses
  • NavigationPostBuild
See Also
void insertAction(XMLElement $action, boolean $append)

This function allows a user to insert an Action button to the page. It accepts an XMLElement (which should be of the Anchor type), an optional parameter $prepend, which when true will add this action before any existing actions.

Parameters
  • $action XMLElementAn Anchor element to add to the top of the page.

  • $append booleanIf true, this will add the $action after existing actions, otherwise it will be added before existing actions. By default this is true, which will add the $action after current actions.

See Also
void insertBreadcrumbs(array $values)

Allows developers to specify a list of nav items that build the path to the current page or, in jargon, "breadcrumbs".

Parameters
  • $values arrayAn array of XMLElement's or strings that compose the path. If breadcrumbs already exist, any new item will be appended to the rightmost part of the path.

void insertDrawer(XMLElement $drawer, string $position, string $button)

Allows a Drawer element to added to the backend page in one of three positions, horizontal, vertical-left or vertical-right. The button to trigger the visibility of the drawer will be added after existing actions by default.

Parameters
  • $drawer XMLElementAn XMLElement representing the drawer, use Widget::Drawer to construct

  • $position stringWhere $position can be horizontal, vertical-left or vertical-right. Defaults to horizontal.

  • $button stringIf not passed, a button to open/close the drawer will not be added to the interface. Accepts 'prepend' or 'append' values, which will add the button before or after existing buttons. Defaults to prepend. If any other value is passed, no button will be added.

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

Given a $message and an optional $type, this function will add an Alert instance into this page's $this->Alert property. Since Symphony 2.3, there may be more than one Alert per page. Unless the Alert is an Error, it is required the $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. If omitted, this defaults to Alert::NOTICE.

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)

Specifies the type of page that being created. This is used to trigger various styling hooks. If your page is mainly a form, pass 'form' as the parameter, if it's displaying a single entry, pass 'single'. If any other parameter is passed, the 'index' styling will be applied.

Parameters
  • $type stringAccepts 'form' or 'single', any other $type will trigger 'index' styling.

void sortAlerts(mixed $a, mixed $b, string $context)

Allows for appending of alerts. Administration::instance()->Page->Alert is way to tell what is currently in the system

Parameters
  • $context string'/backend/'

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

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