| 1 |
<?php |
<?php |
| 2 |
// $Id: ds.module,v 1.1.2.1 2009/10/18 18:26:37 swentel Exp $ |
// $Id: ds.module,v 1.1.2.2 2009/10/20 16:31:20 swentel Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* Core functions for the Display Suite module. |
* Core functions for the Display Suite module. |
| 83 |
/** |
/** |
| 84 |
* API function to get fields. |
* API function to get fields. |
| 85 |
* |
* |
| 86 |
* @param string $module The name of the module. |
* @param string $module The name of the module. |
| 87 |
* @param string $type_name The name of object (ie, page or story for node types, profile for users) |
* @param string $type_name The name of object (ie, page or story for node types, profile for users) |
| 88 |
* @param string $build_mode The build mode. |
* @param string $build_mode The build mode. |
| 89 |
* @param array $extra Extra properties we might want to check on (ie has_body property). |
* @param array $extra Extra properties we might want to check on (ie has_body property). |
| 91 |
*/ |
*/ |
| 92 |
function ds_get_fields($module, $type_name, $build_mode, $extra = array()) { |
function ds_get_fields($module, $type_name, $build_mode, $extra = array()) { |
| 93 |
static $static_fields = array(); |
static $static_fields = array(); |
| 94 |
if (!isset($static_fields[$type_name][$build_mode])) { |
if (!isset($static_fields[$module][$type_name][$build_mode])) { |
| 95 |
|
|
| 96 |
// Fields in code. |
// Fields in code. |
| 97 |
$fields = module_invoke_all('ds_fields', $type_name, $build_mode, $extra); |
$fields = module_invoke_all('ds_fields', $type_name, $build_mode, $extra); |
| 113 |
} |
} |
| 114 |
|
|
| 115 |
// Give modules a change to alter fields. |
// Give modules a change to alter fields. |
| 116 |
drupal_alter($module .'_fields', $fields); |
drupal_alter('ds_fields', $fields); |
| 117 |
|
|
| 118 |
$static_fields[$module][$type_name][$build_mode] = $fields; |
$static_fields[$module][$type_name][$build_mode] = $fields; |
| 119 |
} |
} |
| 120 |
return $static_fields[$type_name][$build_mode]; |
return $static_fields[$module][$type_name][$build_mode]; |
| 121 |
} |
} |
| 122 |
|
|
| 123 |
/** |
/** |
| 148 |
* Process plugins. |
* Process plugins. |
| 149 |
* |
* |
| 150 |
* @param string $module The module to process for. |
* @param string $module The module to process for. |
| 151 |
|
* @param string $object_type The type of object (node, user, comment). |
| 152 |
* @param array $display_settings Display settings. |
* @param array $display_settings Display settings. |
| 153 |
* @param array $vars The variables currently processed. |
* @param array $vars The variables currently processed. |
| 154 |
* @param stdClass $display Collection of arrays with object data. |
* @param stdClass $display Collection of arrays with object data. |
| 155 |
*/ |
*/ |
| 156 |
function ds_plugins_process($module, $display_settings, &$vars, &$display) { |
function ds_plugins_process($module, $object_type, $display_settings, &$vars, &$display) { |
| 157 |
$plugins = variable_get($module .'_plugin_settings', array()); |
$plugins = variable_get($module .'_plugin_settings', array()); |
| 158 |
if (!empty($plugins)) { |
if (!empty($plugins)) { |
| 159 |
foreach ($plugins as $key => $plugin) { |
foreach ($plugins as $key => $plugin) { |
| 161 |
require_once($plugin['filename']); |
require_once($plugin['filename']); |
| 162 |
} |
} |
| 163 |
$function = $plugin['process_callback']; |
$function = $plugin['process_callback']; |
| 164 |
$function($vars, $display, $display_settings); |
$function($vars, $display, $display_settings, $type_name); |
| 165 |
} |
} |
| 166 |
} |
} |
| 167 |
} |
} |
| 171 |
* |
* |
| 172 |
* @param string $key The name of the key to create. |
* @param string $key The name of the key to create. |
| 173 |
* @param array $value The field array. |
* @param array $value The field array. |
|
* @param string $object_type Type of object for token support. |
|
| 174 |
* @param stdClass $object The object. |
* @param stdClass $object The object. |
| 175 |
|
* @param string $object_type Type of object for token support. |
| 176 |
*/ |
*/ |
| 177 |
function ds_eval_code($key, $field, $object_type, &$object) { |
function ds_eval_code($key, $field, &$object, $object_type) { |
| 178 |
if (isset($field['code'])) { |
if (isset($field['code'])) { |
| 179 |
$key = $key .'_rendered'; |
$key = $key .'_rendered'; |
| 180 |
$value = ds_eval($field['code'], $object); |
$value = ds_eval($field['code'], $object); |
| 267 |
* @return array $regions Collection of regions. |
* @return array $regions Collection of regions. |
| 268 |
*/ |
*/ |
| 269 |
function ds_regions($regions = 'all') { |
function ds_regions($regions = 'all') { |
| 270 |
|
$regions = 'all'; |
| 271 |
if ($regions == 'all') { |
if ($regions == 'all') { |
| 272 |
return array( |
return array( |
| 273 |
'header' => t('Header'), |
'header' => t('Header'), |