function theme_simple_dialog_link in Simple Dialog 7
Formats the a link to launch the target path in a jquery ui dialog modal frame.
Parameters
$variables: An associative array containing:
- text: The link text for the anchor tag.
- path: The internal path or external URL being linked to, such as "node/34" or "http://example.com/foo". This is the path that will be used to
- 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.
- 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
),
- link_options: An associative array of additional options that will be passed directly into l() The position option can be given as a string or an array of xy values formatted as specified in the jQuery ui documentation at: http://jqueryui.com/demos/dialog/#option-position
- class: An array of classes to add to the link. Use this argument instead of adding it to link_options[attributes][class] to avoid it being overwritten.
1 theme call to theme_simple_dialog_link()
- simple_dialog_example_examples_page in simple_dialog_example/
simple_dialog_example.module - Outputs the page with the example links
File
- ./
simple_dialog.module, line 227
Code
function theme_simple_dialog_link($args) {
// Store the arguments
$text = $args['text'];
$path = $args['path'];
$selector = $args['selector'];
$title = $args['title'];
$options = $args['options'];
$class = array_merge(array(
'simple-dialog',
), $args['class']);
// 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 ($options && is_array($options)) {
foreach ($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 link options
$link_options = array(
'html' => TRUE,
'attributes' => array(
'title' => $title,
'name' => $selector,
'rel' => $dialog_options,
'class' => $class,
),
);
// We need to merge the options passed into the theme function with our
// default options in $link_options
if (!empty($args['link_options'])) {
// Attributes need to be merged separately
if (isset($args['link_options']['attributes'])) {
$link_options['attributes'] = array_merge($args['link_options']['attributes'], $link_options['attributes']);
}
// Merge the link options
$link_options = array_merge($args['link_options'], $link_options);
}
// Return the properly formatted link
return l($text, $path, $link_options);
}