You are here

function scald_sas_to_rendered in Scald: Media Management made easy 6

Same name and namespace in other branches
  1. 7 scald.module \scald_sas_to_rendered()

Process a text string and replace Scald Atom Shorthand (SAS) with rendered Scald Atoms.

Looks for strings along the lines of [scald=SID:context-slug options].

Parameters

$string: A text string to be processed.

$context: A Scald Context. If $override is FALSE, this Context will only be used to render the included Scald Atoms if the SAS does not specify a valid Scald Context. Defaults to 'title', which is a Scald Context provided by Scald Core and therefore guaranteed to be registered.

$override: A boolean used to determine if the Scald Context specified in the SAS should be used or not.

Return value

The same text string, but with

See also

scald_rendered_to_sas

5 calls to scald_sas_to_rendered()
mee_widget in mee/mee.module
Implementation of hook_widget().
scald_composite_nodeapi in scald_composite/scald_composite.module
Implementation of hook_nodeapi().
scald_filter in ./scald.module
Implementation of hook_filter().
theme_mee_formatter_default in mee/mee.module
theme_mee_formatter_plain in mee/mee.module
Theme function for 'plain' text field formatter.

File

./scald.module, line 1867

Code

function scald_sas_to_rendered($string, $context = NULL, $override = FALSE) {
  if (empty($context)) {
    $context = 'title';
  }
  global $_scald_override;
  $_scald_override = $override;
  $rendered = preg_replace_callback(SCALD_SAS_MATCH_PATTERN, create_function('$matches', '
        global $_scald_override;
        return scald_render(
          $matches[1],
          (!empty($matches[2]) && !$_scald_override ? $matches[2] : \'' . $context . '\'),
          (!empty($matches[3]) ? $matches[3] : NULL)
        );
      '), $string);
  unset($_scald_override);
  return $rendered;
}