Skip to content

Instantly share code, notes, and snippets.

@kriswallsmith
Created June 24, 2010 18:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kriswallsmith/451769 to your computer and use it in GitHub Desktop.
Save kriswallsmith/451769 to your computer and use it in GitHub Desktop.
<?php
class aPage extends PluginaPage
{
/**
* A shortcut method for loading fixture data.
*
* With this method in place you can simplify your aPage fixture file to a
* much more concise syntax using the "initial_areas" entry.
*
* aPage:
* home:
* slug: /
* initial_areas:
* # the page title is just an aText slot
* title: Home Page
*
* # a_slot('header', 'aText')
* header: Home Page
*
* # a_slot('content', 'aRichText')
* content:
* type: aRichText
* value: >
* <p>Welcome to my homepage!</p>
*
* # a_area('sidebar', ...
* sidebar:
* -
* type: mySidebar
* value:
* header: Howdy!
* content: <p>This is my content!</p>
* -
* type: mySidebar
* value:
* header: Howdy again!
* content: <p>This is more content!</p>
*
* @param array $areas An associative array of areas
*/
public function setInitialAreas(array $areas)
{
foreach ($areas as $name => $area)
{
if (!is_array($area))
{
// default to a plain text slot
$area = array(array(
'type' => 'aText',
'value' => $area,
));
}
if (!is_integer(key($area)))
{
// support multiple slots in one area
$area = array($area);
}
// build AreaVersionSlots first
$avs = array();
foreach ($area as $i => $values)
{
// support custom slot types
$value = is_array($values['value']) ? serialize($values['value']) : $values['value'];
$avs[] = array(
'permid' => $i + 1,
'rank' => $i + 1,
'Slot' => array('type' => $values['type'], 'value' => $value),
);
}
$area = new aArea();
$area->fromArray(array(
'name' => $name,
'culture' => 'en',
'latest_version' => 1,
'AreaVersions' => array(array('version' => 1, 'AreaVersionSlots' => $avs)),
));
$this->Areas[] = $area;
}
}
}
@thrashr888
Copy link

What plugin is this for?

@kriswallsmith
Copy link
Author

This is for apostrophePlugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment