You are here

function cpn_wrap_output in Code per Node 7

Same name and namespace in other branches
  1. 6 cpn.module \cpn_wrap_output()

Wrap output for a given type using the wrapper variables.

Parameters

$code: The code string to be wrapped.

$entity_type: The type of object to be wrapped. For now this only supports 'node' and 'block'.

$type: The type of code, i.e. "js" or "css".

Return value

string The wrapped string.

4 calls to cpn_wrap_output()
cpn_block_submit in ./cpn.module
Block submit callback.
cpn_node_insert in ./cpn.module
Implements hook_node_insert().
cpn_node_type_submit in ./cpn.module
Node type submit callback.
cpn_node_view in ./cpn.module
Implements hook_node_view().

File

./cpn.module, line 960
Primary hook implementations.

Code

function cpn_wrap_output($code, $entity_type, $type) {

  // If the code string is empty, return an empty string.
  if (empty($code)) {
    return '';
  }

  // Load the wrapper.
  $wrapper = variable_get('cpn_wrapper_' . $entity_type . '_' . $type, '[code]');

  // If the wrapper is empty, just return the raw code.
  if (empty($wrapper)) {
    return $code;
  }

  // Make the string replacement.
  $output = str_replace('[code]', $code, $wrapper);
  return $output;
}