You are here

function recipe_node_prepare in Recipe 6

Same name and namespace in other branches
  1. 5 recipe.module \recipe_node_prepare()
  2. 7 recipe.module \recipe_node_prepare()

Custom version of node_prepare(). All recipe fields should be run through one of the drupal data checks.

1 call to recipe_node_prepare()
recipe_view in ./recipe.module
Implementation of hook_view().

File

./recipe.module, line 1287
recipe.module - share recipes

Code

function recipe_node_prepare($node, $teaser = FALSE) {

  // Clean and filter the normal node fields.
  $node = node_prepare($node, $teaser);
  if ($teaser == FALSE) {
    $node->body = check_markup($node->body, $node->format, FALSE);
    $node->instructions = check_markup($node->instructions, $node->format, FALSE);
    if ($node->notes) {
      $node->notes = check_markup($node->notes, $node->format, FALSE);
    }
    if ($node->source) {
      $node->source = check_markup($node->source, $node->format, FALSE);
    }
    if ($node->ingredients) {
      $tmp = $node->ingredients;
      $node->ingredients = array();
      foreach ($tmp as $ingredient) {

        // For preview, node->ingredients is an array, for actual display, it's an object
        if (is_array($ingredient)) {
          if (isset($ingredient['name'])) {
            $ingredient['name'] = filter_xss($ingredient['name'], array());
          }
          if (isset($ingredient['note'])) {
            $ingredient['note'] = filter_xss($ingredient['note']);
          }
        }
        elseif (is_object($ingredient)) {
          if (isset($ingredient['name'])) {
            $ingredient['name'] = filter_xss($ingredient['name'], array());
          }
          if (isset($ingredient['note'])) {
            $ingredient['note'] = filter_xss($ingredient['note']);
          }
        }
        $node->ingredients[] = $ingredient;
      }
    }
  }
  return $node;
}