You are here

function pdf_to_imagefield_nodeapi in PDF to ImageField 6.2

hook_nodeapi

When saving a node, see if it's got a PDF that needs converting. Pass processing to individual op handlers, D7-style

Sometimes we do the process immediately (single page) Sometimes we start a batch early (re-save an existing node) Sometimes we have to wait till after (save new node) and start a batch then.

  • this might be reduced to two cases, but not sure..

File

./pdf_to_imagefield.module, line 258
PDF to ImageField core hooks and menu callbacks.

Code

function pdf_to_imagefield_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {

  // First check if this node has one of our widgets active.
  $source_filefield_def = pdf_to_imagefield_source_filefield($node);
  if (!$source_filefield_def) {
    return;
  }
  switch ($op) {
    case 'presave':

      // Single operations happen at presave,
      // because then we can let filefield do the saving.
      return pdf_to_imagefield_node_presave($node);
      break;
    case 'insert':

      // Batch operations happen at postsave, because we need to have a nid.
      // Batch ops trigger their own save (which by then is an update)
      // Beware of cycles - don't set a batch in update, or it will loop.
      return pdf_to_imagefield_node_insert($node);
      break;
  }

  // /switch
}