You are here

function scald_sas_to_rendered in Scald: Media Management made easy 7

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

Process a text string and replace shorthands with rendered Scald Atoms.

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

Parameters

string $string: A text string to be processed.

string $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.

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

string[] $allowed_contexts: An array of contexts slugs that are allowed to be used in the passed-in string. If empty, any context that's not hidden will be allowed.

Return value

string The same text string, but with all the Scald Atom Shorthands replaced with the atom, rendered in the context either specified in the SAS or in the context given as an argument if $override is TRUE.

See also

scald_rendered_to_sas()

3 calls to scald_sas_to_rendered()
mee_field_attach_view_alter in modules/fields/mee/mee.module
Implements hook_field_attach_view_alter.
mee_field_widget_form_alter in modules/fields/mee/mee.module
Implements hook_field_widget_form_alter().
mee_panels_pane_content_alter in modules/fields/mee/mee.module
Implements hook_panels_pane_content_alter().

File

./scald.module, line 854
The Scald Core, which handles all Scald Registries and dispatch.

Code

function scald_sas_to_rendered($string, $context = NULL, $override = FALSE, $allowed_contexts = array()) {
  if (empty($context) || !array_key_exists($context, scald_contexts())) {
    $context = 'title';
  }
  if (empty($allowed_contexts)) {
    $allowed_contexts = array_keys(scald_contexts_public());
  }
  _scald_sas_to_rendered_callback('set', $context, $override, $allowed_contexts);
  $rendered = preg_replace_callback(SCALD_SAS_MATCH_PATTERN, '_scald_sas_to_rendered_callback', $string);
  return $rendered;
}