/[drupal]/contributions/modules/contaxe/contaxe.module
ViewVC logotype

Diff of /contributions/modules/contaxe/contaxe.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.9, Tue Feb 26 14:27:17 2008 UTC revision 1.10, Tue Feb 26 17:09:15 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: contaxe.module,v 1.8 2008/02/26 09:42:00 salgar Exp $  // $Id: contaxe.module,v 1.9 2008/02/26 14:27:17 salgar Exp $
3    
4  /*  /*
5    http://drupal.org/project/jquery_update    http://drupal.org/project/jquery_update
# Line 1485  function contaxe_process_tags($text) { Line 1485  function contaxe_process_tags($text) {
1485   */   */
1486  function contaxe_nodeapi(&$node, $op, $teaser, $page) {  function contaxe_nodeapi(&$node, $op, $teaser, $page) {
1487    if ($op != 'view') return;    if ($op != 'view') return;
1488    // TODO check if page matches    if (variable_get(CONTAXE_INJECTOR_NODETYPE . $node->type, FALSE)) return;
1489    // TODO check if the current    // TODO PAGELIST check if page matches
   // TODO check if $node->type is valid for injection  
1490    if (isset($page)) { // normal view    if (isset($page)) { // normal view
1491        if (!variable_get('contaxe_injector_body_enable', FALSE)) return;
1492        $minwords = variable_get('contaxe_injector_minwords', 75);
1493        $cntwords = contaxe_count_words($node->content['body']['#value'], $minwords);
1494        if ($cntwords < $minwords) return;
1495        $template = variable_get('contaxe_injector_body_template', CONTAXE_INJECTOR_DEFAULT_BODY_TEMPLATE);
1496        $template = contaxe_process_tags($template);
1497        $node->body = $node->content['body']['#value'] = strtr($template, array('%body' => $node->content['body']['#value']));
1498        return;
1499      }
1500      if (isset($teaser)) { // list
1501        if (!variable_get('contaxe_injector_list_enable', FALSE)) return;
1502        $template = variable_get('contaxe_injector_list_template', CONTAXE_INJECTOR_DEFAULT_LIST_TEMPLATE);
1503        $template = contaxe_process_tags($template);
1504        $node->content['body']['#value'] = strtr($template, array('%teaser' => $node->teaser));
1505        return;
1506    }    }
   else if (isset($teaser)) { // list  
   }  
1507  }  }
1508    
1509    /**
1510     * Count words in a string.
1511     * @param $str ref to a string (ref so no copy)
1512     * @param $max max # of words we care about.  Return value will never exceed this.
1513     * @return the count of words, where delimiter is one or more spaces
1514     * @todo Efficiency, find better way to do this
1515     */
1516    function contaxe_count_words(&$str, $max) {
1517      return count(explode(' ', $str, $max)); // lifted from node.module node_validate() function.
1518    }
1519    
1520    
1521  function contaxe_display($id) {  function contaxe_display($id) {
1522    list ($ret, $output) = contaxe_show_banner($id);    list ($ret, $output) = contaxe_show_banner($id);
1523    return $output;    return $output;

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.2