class Content (View source)

The Content class provides all methods to add, modify, move or delete content (pages, shared data and files).

Methods

__construct(object $Automad)

Set $this->Automad when creating an instance.

array
addPage()

Add page based on $_POST.

array
copyResized()

Copy an image resized based on $_POST.

array
deleteFiles(array $files, string $path)

Delete files.

array
deletePage()

Delete page based on $_POST.

array
duplicatePage()

Duplicate a page based on $_POST.

array
editFileInfo()

Edit file information (file name and caption) based on $_POST.

string
extractPrefixFromPath(string $path)

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

string
getPageFilePath(object $Page)

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

string
getPathByPostUrl()

Return the file system path for the directory of a page based on $_POST['url'].

array
getSearchResults()

Get results for a search query from $_GET. In case there is only one match, redirect to the edit page for that URL.

array
import()

Import file from URL based on $_POST.

array
inPageEdit()

Handle AJAX request for editing a data variable in-page context.

array
movePage()

Move a page based on $_POST.

array
savePage(string $url, array $data)

Save a page.

array
saveSharedData(array $data)

Save shared data.

array
upload()

Upload handler based on $_POST and $_FILES.

Details

__construct(object $Automad)

Set $this->Automad when creating an instance.

Parameters

object $Automad

array addPage()

Add page based on $_POST.

Return Value

array $output (AJAX response)

array copyResized()

Copy an image resized based on $_POST.

Return Value

array $output (AJAX response)

array deleteFiles(array $files, string $path)

Delete files.

Parameters

array $files
string $path

Return Value

array $output (AJAX response)

array deletePage()

Delete page based on $_POST.

Return Value

array $output (AJAX response)

array duplicatePage()

Duplicate a page based on $_POST.

Return Value

array $output (AJAX response)

array editFileInfo()

Edit file information (file name and caption) based on $_POST.

Return Value

array $output (AJAX response)

string extractPrefixFromPath(string $path)

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

Parameters

string $path

Return Value

string Prefix

string getPageFilePath(object $Page)

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

Parameters

object $Page

Return Value

string The full file system path

string getPathByPostUrl()

Return the file system path for the directory of a page based on $_POST['url'].

In case URL is empty, return the '/shared' directory.

Return Value

string The full path to the related directory

array getSearchResults()

Get results for a search query from $_GET. In case there is only one match, redirect to the edit page for that URL.

Return Value

array The matching pages

array import()

Import file from URL based on $_POST.

Return Value

array The $output array with possible error messages.

array inPageEdit()

Handle AJAX request for editing a data variable in-page context.

If no data gets received, form fields to build up the editing dialog are send back. Else the received data gets merged with the full data array of the requested context and saved back into the .txt file. In case the title variable gets modified, the page directory gets renamed accordingly.

Return Value

array $output (AJAX response)

array movePage()

Move a page based on $_POST.

Return Value

array $output (AJAX response)

array savePage(string $url, array $data)

Save a page.

Parameters

string $url
array $data

Return Value

array $output (AJAX response)

array saveSharedData(array $data)

Save shared data.

Parameters

array $data

Return Value

array $output (AJAX response)

array upload()

Upload handler based on $_POST and $_FILES.

Return Value

array $output (AJAX response)