You are here

function ed_readmore_nodeapi in Read More Link (Drupal 6 and earlier) 6.2

Same name and namespace in other branches
  1. 5 ed_readmore.module \ed_readmore_nodeapi()
  2. 6.5 ed_readmore.module \ed_readmore_nodeapi()
  3. 6.3 ed_readmore.module \ed_readmore_nodeapi()

File

./ed_readmore.module, line 67

Code

function ed_readmore_nodeapi(&$node, $op, $teaser, $page) {
  $enabled = variable_get('ed_readmore_readmore_tweak', 1);
  $inlineflag = variable_get('ed_readmore_readmore_inline', 1);
  $strong = variable_get('ed_readmore_readmore_strong', 1);
  if ($strong) {
    $strong_l = '<strong>';
    $strong_r = '</strong>';
  }
  else {
    $strong_l = '';
    $strong_r = '';
  }
  $options = array(
    'html' => true,
  );
  $readmore_url = l($strong_l . t(variable_get('ed_readmore_text', ED_READMORE_TEXT_DEFAULT)) . $strong_r, "node/{$node->nid}", $options);
  if ($enabled) {
    if ($op == 'rss item') {
      $item_length = variable_get('feed_item_length', 'teaser');

      // from node.module node_feed() code
      switch ($item_length) {
        case 'teaser':
          if (strlen($node->teaser) < strlen($node->body)) {
            $node->teaser = _ed_readmore_place_readmore_link($node->teaser, $readmore_url, $inlineflag);
          }
          break;
      }
      return;
    }
    if ($op == 'view') {
      if ($teaser && $node->readmore) {
        $node->readmore = false;

        //
        // since we are blowing away some of the implicit info ($node->readmore) let's remember that this was a teaser
        $node->is_teaser = TRUE;
        $node->content['body']['#value'] = _ed_readmore_place_readmore_link($node->content['body']['#value'], $readmore_url, $inlineflag);
      }
    }
  }
}