class spaces_controller_context in Spaces 7.3
Same name and namespace in other branches
- 6.3 plugins/spaces_controller_context.inc \spaces_controller_context
- 7 plugins/spaces_controller_context.inc \spaces_controller_context
Context controller.
Hierarchy
- class \spaces_controller
- class \spaces_controller_context
Expanded class hierarchy of spaces_controller_context
2 string references to 'spaces_controller_context'
- spaces_spaces_plugins in ./
spaces.module - Implements hook_spaces_plugins().
- spaces_spaces_registry in ./
spaces.module - Implements hook_spaces_registry().
File
- plugins/
spaces_controller_context.inc, line 6
View source
class spaces_controller_context extends spaces_controller {
/**
* Load the context described by an override identifier like
* 'foo:reaction:block'.
*/
protected function load_from_override($override_id) {
if ($split = explode(':', $override_id)) {
$context_name = array_shift($split);
$context = context_load($context_name);
return $context;
}
return FALSE;
}
/**
* Split the single context object into array of individual plugin values.
*/
protected function plugin_values($context) {
$keys = array(
'conditions',
'reactions',
);
$plugins = array();
if (!empty($context->conditions)) {
foreach ($context->conditions as $plugin => $values) {
$plugins["{$context->name}:condition:{$plugin}"] = $values;
}
}
if (!empty($context->reactions)) {
foreach ($context->reactions as $plugin => $values) {
$plugins["{$context->name}:reaction:{$plugin}"] = $values;
}
}
return $plugins;
}
/**
* Override of load_space_values().
*
* All overrides are retrieved at once for a given space to reduce the number
* of queries run when a space is active.
*/
protected function load_space_values($id = NULL) {
if (!$this->loaded_all['space']) {
$result = db_query("\n SELECT object_id AS id, value\n FROM {spaces_overrides}\n WHERE type = :type\n AND id = :id\n AND object_type = :otype", array(
':type' => $this->space_type,
':id' => $this->space_id,
':otype' => $this->controller,
));
foreach ($result as $row) {
$this->values['space'][$row->id] = unserialize($row->value);
}
$this->loaded_all['space'] = TRUE;
}
}
/**
* Override of load_original_values().
*
* Note that $id here is *NOT* $context->name, but rather a derived plugin
* id allowing overrides to be set on a granular, per-plugin level. The
* format of $id is "{$context->name}:{$plugin_type}:{$plugin}", e.g.
* "blog:reaction:block".
*/
protected function load_original_values($id = NULL) {
if (empty($this->loaded_all['original'])) {
if (!isset($id)) {
$contexts = context_load();
foreach ($contexts as $name => $context) {
array_merge($this->values['original'], $this
->plugin_values($context));
}
$this->loaded_all['original'] = TRUE;
}
else {
if (!isset($this->loaded['original'][$id])) {
if ($context = $this
->load_from_override($id)) {
$plugins = $this
->plugin_values($context);
foreach ($plugins as $plugin_id => $plugin_values) {
$this->values['original'][$plugin_id] = $plugin_values;
$this->loaded['original'][$plugin_id] = TRUE;
}
}
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
spaces_controller:: |
property | |||
spaces_controller:: |
protected | property | ||
spaces_controller:: |
protected | property | ||
spaces_controller:: |
property | |||
spaces_controller:: |
property | |||
spaces_controller:: |
property | |||
spaces_controller:: |
function | Delete a controller object override for this space. | ||
spaces_controller:: |
function | Get a value for this controller. | ||
spaces_controller:: |
function | Initialize overrides. Assume this controller is now active. This method is re-run when the caller wants to ensure the values provided by the controller are refreshed. | 1 | |
spaces_controller:: |
protected | function | Protected method that ensures a preset-level override for the provided object has been loaded. Since presets values are stored in aggregate, the $id argument here is largely for consistency. | 1 |
spaces_controller:: |
protected | function | Wrapper around load_[environment]_values. | |
spaces_controller:: |
protected | function | Clear out loaded values. | |
spaces_controller:: |
function | Set override values for a given controller object in this space. | ||
spaces_controller:: |
function | Provide a readable display of an object override for administration. | ||
spaces_controller:: |
function | |||
spaces_controller_context:: |
protected | function | Load the context described by an override identifier like 'foo:reaction:block'. | |
spaces_controller_context:: |
protected | function |
Override of load_original_values(). Overrides spaces_controller:: |
|
spaces_controller_context:: |
protected | function |
Override of load_space_values(). Overrides spaces_controller:: |
|
spaces_controller_context:: |
protected | function | Split the single context object into array of individual plugin values. |