You are here

function _ai_process_auto_insertions in Content Injector (formerly AdSense Injector) 7.3

Same name and namespace in other branches
  1. 6.3 adsense_injector.module \_ai_process_auto_insertions()

Process automatic insertions.

Parameters

unknown_type $node The node to operate on.:

1 call to _ai_process_auto_insertions()
adsense_injector_node_view in ./adsense_injector.module
Implements hook_node_view().

File

./adsense_injector.module, line 169
Inject adsense ads into node content automatically.

Code

function _ai_process_auto_insertions(&$node, $skipList = null) {

  //
  // Get the minimum node body wordcount for insertion.
  $minwords = _ai_node_body_view_minwords();

  // Count words in a string.
  // lifted from node.module node_validate() function.
  $text = $node->content['body'][0]['#markup'];
  $wordcount = count(explode(' ', $text, $minwords));
  if ($wordcount >= $minwords) {
    $node->content['body'][0]['#markup'] = adsense_injector_process_body($text, $node, $skipList);
  }
  else {
    $node->content['body'][0]['#markup'] .= _ai_html_comment('AutoInsertion', "Body has {$wordcount} words ({$minwords} required), insertion skipped");
  }
}