You are here

function node_convert_load_template in Node Convert 7

Same name and namespace in other branches
  1. 6 node_convert.module \node_convert_load_template()

Loads a conversion template array using template_id.

Parameters

$template_id: The template id to use

Return value

array An array containing the template information or FALSE if there is no such template

5 calls to node_convert_load_template()
node_convert_check_template_permission_user in ./node_convert.module
Checks if the logged in user has access to use the conversion template.
node_convert_convert_action in ./node_convert.module
Implements hook_action, exposing predefined conversion templates as actions.
node_convert_convert_nodes_using_template in ./node_convert.module
Converts a list of nodes using a given template
node_convert_template_info in ./node_convert.admin.inc
Template info page callback.
node_convert_template_load in ./node_convert.module
This is a wildcard loader for the menu item for template editing.

File

./node_convert.module, line 351

Code

function node_convert_load_template($template_id) {

  // Use Ctools export API to fetch all presets from the DB as well as code.
  ctools_include('export');
  if ($template_id) {
    $conditions = array();
    if (is_numeric($template_id)) {
      $conditions['nctid'] = $template_id;
    }
    elseif (is_string($template_id)) {
      $conditions['machine_name'] = $template_id;
    }
    $templates = ctools_export_load_object(NODE_CONVERT_TEMPLATE_TABLE, 'conditions', $conditions);
    $template = !empty($templates) ? array_shift($templates) : FALSE;
    if (is_string($template->data)) {
      $template->data = unserialize($template->data);
    }
    if (!empty($template)) {
      $template = (array) $template;
      return $template;
    }
  }
  return FALSE;
}