function template_preprocess_simple_dialog_link in Simple Dialog 8
Preprocesses variables for simple dialog links
Parameters
$variables: An associative array containing:
- text: The link text for the anchor tag.
- path: The URL to pull the dialog contents from.
- title: The 'title' attribute of the link. Will also be used for the title of the jQuery ui dialog
- selector: The css id of the element on the target page. This element and it's containing html will be loaded via AJAX into the dialog window.
- attributes: An associative array of additional link attributes
- class: An array of classes to add to the link. Use this argument instead of adding it to attributes[class] to avoid it being overwritten.
- options: (optional) An associative array of additional jQuery ui dialog options keyed by the option name. example:
$options = array(
'optionName' => 'optionValue', // examples:
'width' => 900,
'resizable' => FALSE,
'position' => 'center', // Position can be a string or:
'position' => array(60, 'top') // can be an array of xy values
),
File
- ./
simple_dialog.module, line 159
Code
function template_preprocess_simple_dialog_link(&$variables) {
// Somewhere to store our dialog options. Will be imploded at the end
$dialog_options = array();
// as long as there are some options and the options variable is an array
if ($variables['options'] && is_array($variables['options'])) {
foreach ($variables['options'] as $option_name => $value) {
if ($option_name == 'position' && is_array($value)) {
$dialog_options[] = $option_name . ':[' . $value[0] . ',' . $value[1] . ']';
}
elseif ($value) {
$dialog_options[] = $option_name . ':' . $value;
}
else {
$dialog_options[] = $option_name . ':false';
}
}
}
// Concatenate using the semi-colon
$dialog_options = implode(';', $dialog_options);
// Setup the default attributes
array_unshift($variables['class'], 'simple-dialog');
$attributes = array(
'title' => $variables['title'],
'name' => $variables['selector'],
'rel' => $dialog_options,
'class' => $variables['class'],
);
// We need to merge any other attributes that were provided through the
// attributes variable
if (!empty($variables['attributes'])) {
$attributes = array_merge($variables['attributes'], $attributes);
}
$variables['attributes'] = new Attribute($attributes);
}