public class PageManager

class.pagemanager.php #15

The PageManager class is responsible for providing basic CRUD operations for Symphony frontend pages. These pages are stored in the database in tbl_pages and are resolved to an instance of FrontendPage class from a URL. Additionally, this manager provides functions to access the Page's types, and any linked datasources or events.

Methods

static integer|boolean add(array $fields)

Given an associative array of data, where the key is the column name in tbl_pages and the value is the data, this function will create a new Page and return a Page ID on success.

Parameters
  • $fields arrayAssociative array of field names => values for the Page

Returns

Returns the Page ID of the created Page on success, false otherwise.

static boolean addPageTypesToPage(integer $page_id, array $types)

Given a Page ID and an array of types, this function will add Page types to that Page. If a Page types are stored in tbl_pages_types.

Parameters
  • $page_id integerThe Page ID to add the Types to

  • $types arrayAn array of page types

static string createFilePath(string $path, string $handle)

This function takes a $path and $handle and generates a flattened string for use as a filename for a Page's template.

Parameters
  • $path stringThe path of the Page, which is the handles of the Page parents. If the page has multiple parents, they will be separated by a forward slash. eg. article/read. If a page has no parents, this parameter should be null.

  • $handle stringA Page handle, generated using PageManager::createHandle.

static string createHandle(string $name)

Given a name, this function will return a page handle. These handles will only contain latin characters

Parameters
  • $name stringThe Page name to generate a handle for

static boolean createPageFiles(string $new_path, string $new_handle, string $old_path, string $old_handle)

This function creates the initial .xsl template for the page, whether that be from the TEMPLATES/blueprints.page.xsl file, or from an existing template with the same name. This function will handle the renaming of a page by creating the new files using the old files as the templates then removing the old template. If a template already exists for a Page, it will not be overridden and the function will return true.

Parameters
  • $new_path stringThe path of the Page, which is the handles of the Page parents. If the page has multiple parents, they will be separated by a forward slash. eg. article/read. If a page has no parents, this parameter should be null.

  • $new_handle stringThe new Page handle, generated using PageManager::createHandle.

  • $old_path string(optional) This parameter is only required when renaming a Page. It should be the 'old path' before the Page was renamed.

  • $old_handle string(optional) This parameter is only required when renaming a Page. It should be the 'old handle' before the Page was renamed.

Returns

true when the page files have been created successfully, false otherwise.

See Also
static boolean delete(integer $page_id, boolean $delete_files)

This function takes a Page ID and removes the Page from the database in tbl_pages and it's associated Page Types in tbl_pages_types. This function does not delete any of the Page's children.

Parameters
  • $page_id integerThe ID of the Page that should be deleted.

  • $delete_files booleanIf true, this parameter will remove the Page's templates from the the filesystem. By default this is true.

See Also
static boolean deletePageFiles(string $page_path, string $handle)

Given a Page's $path and $handle, this function will remove it's templates from the PAGES directory returning boolean on completion

Parameters
  • $page_path stringThe path of the Page, which is the handles of the Page parents. If the page has multiple parents, they will be separated by a forward slash. eg. article/read. If a page has no parents, this parameter should be null.

  • $handle stringA Page handle, generated using PageManager::createHandle.

static boolean deletePageTypes(integer $page_id)

Given a $page_id, this function will remove all associated Page Types from tbl_pages_types.

Parameters
  • $page_id integerThe ID of the Page that should be deleted.

static boolean edit(integer $page_id, array $fields, boolean $delete_types)

This function will update a Page in tbl_pages given a $page_id and an associative array of $fields. A third parameter, $delete_types will also delete the Page's associated Page Types if passed true.

Parameters
  • $page_id integerThe ID of the Page that should be updated

  • $fields arrayAssociative array of field names => values for the Page. This array does need to contain every value for the Page, it can just be the changed values.

  • $delete_types booleanIf true, this parameter will cause the Page Types of the Page to be deleted. By default this is false.

See Also
static boolean editPageChildren(integer $page_id, string $page_path)

This function will update all children of a particular page (if any) by renaming/moving all related files to their new path and updating their database information. This is a recursive function and will work to any depth.

Parameters
  • $page_id integerThe ID of the Page whose children need to be updated

  • $page_path stringThe path of the Page, which is the handles of the Page parents. If the page has multiple parents, they will be separated by a forward slash. eg. article/read. If a page has no parents, this parameter should be null.

static array|null fetch(boolean $include_types, array $select, boolean $hierarchical, array $where, string $order_by)

This function will return an associative array of Page information. The information returned is defined by the $include_types and $select parameters, which will return the Page Types for the Page and allow a developer to restrict what information is returned about the Page. Optionally, $where and $order_by parameters allow a developer to further refine their query.

Parameters
  • $include_types booleanWhether to include the resulting Page's Page Types in the return array, under the key type. Defaults to true.

  • $select array(optional) Accepts an array of columns to return from tbl_pages. If omitted, all columns from the table will be returned.

  • $where array(optional) Accepts an array of WHERE statements that will be appended with AND. If omitted, all pages will be returned.

  • $order_by string(optional) Allows a developer to return the Pages in a particular order. The string passed will be appended to ORDER BY. If omitted this will return Pages ordered by sortorder.

  • $hierarchical boolean(optional) If true, builds a multidimensional array representing the pages hierarchy. Defaults to false.

Returns

An associative array of Page information with the key being the column name from tbl_pages and the value being the data. If requested, the array can be made multidimensional to reflect the pages hierarchy. If no Pages are found, null is returned.

static array fetchAllPagesPageTypes()

Fetch an associated array with Page ID's and the types they're using.

Returns

A 2-dimensional associated array where the key is the page ID.

static array fetchAvailablePageTypes()

Returns all the page types that exist in this Symphony install. There are 6 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', 'JSON', 'admin', '404' and '403'.

static array|null fetchChildPages(integer $page_id, array $select)

Returns the child Pages (if any) of the given $page_id.

Parameters
  • $page_id integerThe ID of the Page.

  • $select array(optional) Accepts an array of columns to return from tbl_pages. If omitted, all columns from the table will be returned.

Returns

An associative array of Page information with the key being the column name from tbl_pages and the value being the data. If multiple Pages are found, an array of Pages will be returned. If no Pages are found null is returned.

static integer fetchIDFromHandle(string $handle)

Return a Page ID by the handle

Parameters
  • $handle stringThe handle of the page

Returns

The Page ID

static integer fetchNextSortOrder()

Work out the next available sort order for a new page

Returns

Returns the next sort order

static array|null fetchPageByID(integer|array $page_id, array $select)

Returns Pages that match the given $page_id. Developers can optionally choose to specify what Page information is returned using the $select parameter.

Parameters
  • $page_id integer|arrayThe ID of the Page, or an array of ID's

  • $select array(optional) Accepts an array of columns to return from tbl_pages. If omitted, all columns from the table will be returned.

Returns

An associative array of Page information with the key being the column name from tbl_pages and the value being the data. If multiple Pages are found, an array of Pages will be returned. If no Pages are found null is returned.

static array|null fetchPageByType(string $type)

Returns Pages that match the given $type. If no $type is provided the function returns the result of PageManager::fetch.

Parameters
  • $type stringWhere the type is one of the available Page Types.

Returns

An associative array of Page information with the key being the column name from tbl_pages and the value being the data. If multiple Pages are found, an array of Pages will be returned. If no Pages are found null is returned.

static array fetchPageTypes(integer $page_id)

This function returns a Page's Page Types. If the $page_id parameter is given, the types returned will be for that Page.

Parameters
  • $page_id integerThe ID of the Page.

Returns

An array of the Page Types

static integer fetchTitleFromHandle(string $handle)

Return a Page title by the handle

Parameters
  • $handle stringThe handle of the page

Returns

The Page title

static integer getChildPagesCount(integer $page_id)

This function will return the number of child pages for a given $page_id. This is a recursive function and will return the absolute count.

Parameters
  • $page_id integerThe ID of the Page.

Returns

The number of child pages for the given $page_id

static mixed getTemplate(string $name)

Returns the path to the page-template by looking at the WORKSPACE/template/ directory, then at the TEMPLATES directory for $name.xsl. If the template is not found, false is returned

Parameters
  • $name stringName of the template

Returns

String, which is the path to the template if the template is found, false otherwise

static boolean hasChildPages(integer $page_id)

Given a $page_id, this function returns boolean if the page has child pages.

Parameters
  • $page_id integerThe ID of the Page to check

Returns

true if the page has children, false otherwise

static boolean hasPageTypeBeenUsed(integer $page_id, string $type)

Returns boolean if a the given $type has been used by Symphony for a Page that is not $page_id.

Parameters
  • $page_id integerThe ID of the Page to exclude from the query.

  • $type stringThe Page Type to look for in tbl_page_types.

Returns

true if the type is used, false otherwise

static boolean isDataSourceUsed(string $handle)

Check whether a datasource is used or not

Parameters
  • $handle stringThe datasource handle

Returns

true if used, false if not

static boolean isEventUsed(string $handle)

Check whether a event is used or not

Parameters
  • $handle stringThe event handle

Returns

true if used, false if not

static array resolvePage(mixed $page_id, string $column)

Given the $page_id and a $column, this function will return an array of the given $column for the Page, including all parents.

Parameters
  • $page_id mixedThe ID of the Page that currently being viewed, or the handle of the current Page

Returns

An array of the current Page, containing the $column requested. The current page will be the last item the array, as all parent pages are prepended to the start of the array

static mixed resolvePageByPath(mixed $handle, boolean $path, $handle $The)

Resolve a page by it's handle and path

Parameters
  • $The $handlehandle of the page

  • $path booleanThe path to the page

Returns

Array if found, false if not

static string resolvePageFileLocation(string $path, string $handle)

Resolves the path to this page's XSLT file. The Symphony convention is that they are stored in the PAGES folder. If this page has a parent it will be as if all the / in the URL have been replaced with _. ie. /articles/read/ will produce a file articles_read.xsl

Parameters
  • $path stringThe URL path to this page, excluding the current page. ie, /articles/read would make $path become articles/

  • $handle stringThe handle of the page.

Returns

The path to the XSLT of the page

See Also
static string resolvePagePath(mixed $page_id)

Given the $page_id, return the complete path to the current page. Each part of the Page's path will be separated by '/'.

Parameters
  • $page_id mixedThe ID of the Page that currently being viewed, or the handle of the current Page

Returns

The complete path to the current Page including any parent Pages, ie. /articles/read

static string resolvePageTitle(mixed $page_id)

Given the $page_id, return the complete title of the current page. Each part of the Page's title will be separated by ': '.

Parameters
  • $page_id mixedThe ID of the Page that currently being viewed, or the handle of the current Page

Returns

The title of the current Page. If the page is a child of another it will be prepended by the parent and a colon, ie. Articles: Read

static boolean writePageFiles(string $path, string $data)

A wrapper for General::writeFile, this function takes a $path and a $data and writes the new template to disk.

Parameters
  • $path stringThe path to write the template to

  • $data stringThe contents of the template

Returns

true when written successfully, false otherwise

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