Automad
 All Classes Functions Variables Pages
Automad\GUI\GUI Class Reference

Public Member Functions

 __construct ()
 

Public Attributes

 $output
 

Private Member Functions

 accountsGeneratePHP ($accounts)
 
 accountsGetArray ()
 
 accountsSaveArray ($accounts)
 
 element ($element)
 
 extractPrefixFromPath ($path)
 
 getPageVarsInTemplate ($theme, $template)
 
 getSiteVarsInThemes ()
 
 movePage ($oldPath, $newParentPath, $prefix, $title)
 
 pageFile ($page)
 
 passwordHash ($password)
 
 passwordVerified ($password, $hash)
 
 siteTree ($parent, $collection, $parameters, $hideCurrent=false)
 
 siteName ()
 
 templateSelectBox ($id= '', $name= '', $selectedTheme=false, $selectedTemplate=false)
 
 user ()
 
 varTextArea ($key, $value, $removeButton=false)
 

Private Attributes

 $collection
 
 $guiTitle = 'Automad'
 
 $siteData
 
 $tb = array()
 

Detailed Description

The GUI class provides all methods used for the GUI.

Author
Marc Anton Dahmen hello.nosp@m.@mar.nosp@m.cdahm.nosp@m.en.d.nosp@m.e
License
MIT license - http://automad.org/license

Definition at line 52 of file gui.php.

Constructor & Destructor Documentation

Automad\GUI\GUI::__construct ( )

Load the site's global data and include modules according to the current context.

When a the GUI gets initialize, at first it gets verified, if an user is logged in or not. That has the highest priority. If no user is logged in, the existance of "config/accounts.txt" gets checked and either the login or the install module gets loaded.

If an user is logged in, the Automad object gets created and the current "context" gets determined from the GET parameters. According that context, the matching module gets loaded after verifying its exsistance. When there is no context passed via get, it gets checked for "ajax", to possibly call a matching ajax module. If both is negative, the start page's module gets included.

Example Context: http://domain.com/gui?context=edit_page will include automad/gui/context/edit_page.php Example Ajax: http://domain.com/gui?ajax=page_data will include automad/gui/ajax/page_data.php

Since every request for the gui (pages and ajax) gets still routed over "/index.php" > "/automad/init.php" > new GUI(), all the session/login checking needs only to be done here once, simply because all modules get includede here.

Definition at line 108 of file gui.php.

References Automad\Core\Parse\markdownFile(), Automad\Core\Parse\queryKey(), and Automad\Core\Parse\siteData().

Member Function Documentation

Automad\GUI\GUI::accountsGeneratePHP (   $accounts)
private

Generate the PHP code for the accounts file. Basically the code returns the unserialized serialized array with all users. That way, the accounts array can be stored as PHP. The accounts file has to be a PHP file for security reasons. When trying to access the file directly via the browser, it gets executed instead of revealing any user names.

Parameters
array$accounts
Returns
The PHP code as string

Definition at line 169 of file gui.php.

Automad\GUI\GUI::accountsGetArray ( )
private

Get the accounts array by including the accounts PHP file.

Returns
The accounts array

Definition at line 184 of file gui.php.

Automad\GUI\GUI::accountsSaveArray (   $accounts)
private

Save the accounts array as PHP to AM_FILE_ACCOUNTS.

Returns
Success (true/false)

Definition at line 197 of file gui.php.

Automad\GUI\GUI::element (   $element)
private

Load GUI element from automad/gui/elements.

Parameters
string$element

Definition at line 210 of file gui.php.

Automad\GUI\GUI::extractPrefixFromPath (   $path)
private

Extract the deepest directory's prefix from a given path.

Returns
Prefix

Definition at line 223 of file gui.php.

Automad\GUI\GUI::getPageVarsInTemplate (   $theme,
  $template 
)
private

Get a list (array) of all variables used in a template file and its nested elements. This method also parses extensions and toolbox methods and therefore also finds all variables created dynamically by these methods.

Parameters
string$theme
string$template
Returns
Array of matched variables

Definition at line 239 of file gui.php.

Automad\GUI\GUI::getSiteVarsInThemes ( )
private

Collect all site variables used in any .php file below the /themes directory.

Note: Unlike getPageVarsInTemplate(), this method doesn't parse any extensions or tools, since there is no current page when editing global settings. Therefore it is not possible to find any shared variable which gets created by an extension or a toolbox method. Only variables which are hardcoded in the template files or its nested elements get collected. As a good practice, it should be avoided within any extension to create site variables dynamically. That should only be done with page variables.

Returns
Array with site variables

Definition at line 290 of file gui.php.

Automad\GUI\GUI::movePage (   $oldPath,
  $newParentPath,
  $prefix,
  $title 
)
private

Move a page's directory to a new location. The final path is composed of the parent directoy, the prefix and the title. In case the resulting path is already occupied, an index get appended to the prefix, to be reproducible when resaving the page.

Parameters
string$oldPath
string$newParentPath(destination)
string$prefix
string$title
Returns
$newPath

Definition at line 335 of file gui.php.

References Automad\Core\Parse\sanitize().

Automad\GUI\GUI::pageFile (   $page)
private

Return the full file system path of a page's data file.

Parameters
object$page
Returns
Filename

Definition at line 385 of file gui.php.

Automad\GUI\GUI::passwordHash (   $password)
private

Create hash from password to store in accounts.txt.

Parameters
string$password
Returns
Hashed/salted password

Definition at line 399 of file gui.php.

Automad\GUI\GUI::passwordVerified (   $password,
  $hash 
)
private

Verify if a password matches its hashed version.

Parameters
string$password(clear text)
string$hash(hashed password)
Returns
true/false

Definition at line 416 of file gui.php.

Automad\GUI\GUI::siteName ( )
private

Return the Site's name.

Returns
Site's name

Definition at line 484 of file gui.php.

Automad\GUI\GUI::siteTree (   $parent,
  $collection,
  $parameters,
  $hideCurrent = false 
)
private

Create recursive site tree for editing a page. Every page link sends a post request to gui/pages.php containing the page's url.

Parameters
string$parent
array$collection
array$parameters(additional query string parameters to be passed along with the url)
boolean$hideCurrent
Returns
the branch's HTML

Definition at line 434 of file gui.php.

References Automad\Core\Parse\queryKey().

Automad\GUI\GUI::templateSelectBox (   $id = '',
  $name = '',
  $selectedTheme = false,
  $selectedTemplate = false 
)
private

Create a select box containing all installed themes/templates to be included in a HTML form.

Parameters
string$id(HTML id)
string$name(Fieldname)
string$selectedTheme
string$selectedTemplate
Returns
The HTML for the select box including a label and a wrapping div.

Definition at line 501 of file gui.php.

Automad\GUI\GUI::user ( )
private

Return the currently logged in user.

Returns
username

Definition at line 557 of file gui.php.

Automad\GUI\GUI::varTextArea (   $key,
  $value,
  $removeButton = false 
)
private

Create textarea for page/shared variables with optional button for removal.

Parameters
string$key(name)
string$value(value)
boolean$removeButton
Returns
The HTML for the textarea

Definition at line 575 of file gui.php.

Member Data Documentation

Automad\GUI\GUI::$collection
private

Automad's collection.

Definition at line 59 of file gui.php.

Automad\GUI\GUI::$guiTitle = 'Automad'
private

The GUI page's title.

Definition at line 66 of file gui.php.

Automad\GUI\GUI::$output

The GUI's buffered HTML.

Definition at line 73 of file gui.php.

Automad\GUI\GUI::$siteData
private

The Site's data and settings.

Definition at line 80 of file gui.php.

Automad\GUI\GUI::$tb = array()
private

Text blocks to be used for feedback, button text and alerts.

Definition at line 87 of file gui.php.


The documentation for this class was generated from the following file: