You are here

function cpn_wrap_output in Code per Node 6

Same name and namespace in other branches
  1. 7 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.

3 calls to cpn_wrap_output()
cpn_block_submit in ./cpn.module
Block submit callback.
cpn_nodeapi in ./cpn.module
Implementation of hook_nodeapi().
cpn_node_type_submit in ./cpn.module
Node type submit callback.

File

./cpn.module, line 507
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;
}