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

Diff of /contributions/modules/nodewords_nodetype/nodewords_nodetype.module

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

revision 1.2.2.6, Thu Sep 24 01:29:20 2009 UTC revision 1.2.2.7, Thu Sep 24 14:08:07 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /* $Id: nodewords_nodetype.module,v 1.2.2.5 2009/09/24 01:12:50 hanoii Exp $ */  /* $Id: nodewords_nodetype.module,v 1.2.2.6 2009/09/24 01:29:20 hanoii Exp $ */
3    
4  /**  /**
5   * Implementation of hook_form_alter().   * Implementation of hook_form_alter().
# Line 16  function nodewords_nodetype_form_alter(& Line 16  function nodewords_nodetype_form_alter(&
16        '#type' => 'checkboxes',        '#type' => 'checkboxes',
17        '#title' => t('Default "robots" meta tag'),        '#title' => t('Default "robots" meta tag'),
18        '#options' => array(        '#options' => array(
19          'noindex' => t('NOINDEX'),        'noindex' => t('NOINDEX'),
20          'nofollow' => t('NOFOLLOW'),        'nofollow' => t('NOFOLLOW'),
21          'noarchive' => t('NOARCHIVE'),        'noarchive' => t('NOARCHIVE'),
22          'noopd' => t('NOOPD'),        'noopd' => t('NOOPD'),
23          'nosnippet' => t('NOSNIPPET'),        'nosnippet' => t('NOSNIPPET'),
24          'noydir' => t('NOYDIR'),        'noydir' => t('NOYDIR'),
25        ),        ),
26        '#checkall' => TRUE,        '#checkall' => TRUE,
27        '#default_value' => variable_get('nodewords_nodetype_robots_'. $form['#node_type']->type, array()),        '#default_value' => variable_get('nodewords_nodetype_robots_'. $form['#node_type']->type, array()),
# Line 33  function nodewords_nodetype_form_alter(& Line 33  function nodewords_nodetype_form_alter(&
33        '#default_value' => variable_get('nodewords_nodetype_keywords_'. $form['#node_type']->type, ''),        '#default_value' => variable_get('nodewords_nodetype_keywords_'. $form['#node_type']->type, ''),
34        '#size' => 60,        '#size' => 60,
35        '#maxlength' => variable_get('nodewords_max_size', 255),        '#maxlength' => variable_get('nodewords_max_size', 255),
36        '#description' => t('This keywords will be appended after the global keywords and before the page kewords. Enter a comma separated list of keywords for this page. Avoid duplication of words as this will lower your search engine ranking.'),        '#description' => t('Tokens are supported. This keywords will be appended after the global keywords and before the page kewords. Enter a comma separated list of keywords for this page. Avoid duplication of words as this will lower your search engine ranking.'),
37      );      );
38    
39      $form['nodewords_nodetype']['description'] = array(      $form['nodewords_nodetype']['description'] = array(
# Line 46  function nodewords_nodetype_form_alter(& Line 46  function nodewords_nodetype_form_alter(&
46        '#type' => 'textarea',        '#type' => 'textarea',
47        '#title' => t('Default "description" meta tag'),        '#title' => t('Default "description" meta tag'),
48        '#default_value' => variable_get('nodewords_nodetype_description_'. $form['#node_type']->type, ''),        '#default_value' => variable_get('nodewords_nodetype_description_'. $form['#node_type']->type, ''),
49        '#description' => t('Enter a description. Limit your description to about 20 words, with a maximum of %count characters. It should not contain any HTML tags or other formatting.', array('%count' => variable_get('nodewords_max_size', 255))) . (variable_get('basic_metatags_use_teaser', FALSE) ? ' ' . t('When you leave this field empty, the teaser will be used as description.') : ''),        '#description' => t('Tokens are supported. Enter a description. Limit your description to about 20 words, with a maximum of %count characters. It should not contain any HTML tags or other formatting.', array('%count' => variable_get('nodewords_max_size', 255))) . (variable_get('basic_metatags_use_teaser', FALSE) ? ' ' . t('When you leave this field empty, the teaser will be used as description.') : ''),
50      );      );
51    
52      $form['nodewords_nodetype']['nodewords_nodetype_token'] = array(      $form['nodewords_nodetype']['nodewords_nodetype_token'] = array(
# Line 85  function nodewords_nodetype_nodewords_ta Line 85  function nodewords_nodetype_nodewords_ta
85      $node = node_load($tag_options['ids'][0]);      $node = node_load($tag_options['ids'][0]);
86    
87      // Keywords      // Keywords
88        // keywords are appended to the node\'s and global ones.
89      if ( ( $keywords = variable_get('nodewords_nodetype_keywords_'. $node->type, '') ) !== '' ) {      if ( ( $keywords = variable_get('nodewords_nodetype_keywords_'. $node->type, '') ) !== '' ) {
90        $output_tags['keywords'] .= ($output_tags['keywords'] !== '' ? ',' : '' ). $keywords;        $meta_keywords = token_replace($keywords, 'node', $node);
91          $output_tags['keywords'] .= ($output_tags['keywords'] !== '' ? ',' : '' ) . $meta_keywords;
92        $output_tags['keywords'] = nodewords_unique($output_tags['keywords']);        $output_tags['keywords'] = nodewords_unique($output_tags['keywords']);
93      }      }
94    
95      // Dsecription      // Description
96      if ( ( $description = variable_get('nodewords_nodetype_description_'. $node->type, '') ) !== '' ) {      // Don't replace per node meta description
97        $meta_description = token_replace($description, 'node', $node);      if ($node->nodewords['description']['value'] !== '' ) {
98      }        if ( ( $description = variable_get('nodewords_nodetype_description_'. $node->type, '') ) !== '' ) {
99            $meta_description = token_replace($description, 'node', $node);
100          }
101    
102      if ( ( $description_php = variable_get('nodewords_nodetype_desc_php_'. $node->type, '') ) !== '' ) {        if ( ( $description_php = variable_get('nodewords_nodetype_desc_php_'. $node->type, '') ) !== '' ) {
103        $description_php = token_replace($description_php, 'node', $node);          $description_php = token_replace($description_php, 'node', $node);
104        $variables['%description'] = $meta_description;          $variables['%description'] = $meta_description;
105        $variables['%php_description'] = '$description = \'' . str_replace('\'', '\\\'', $meta_description) . '\';';          $variables['%php_description'] = '$description = \'' . str_replace('\'', '\\\'', $meta_description) . '\';';
106        $meta_description = drupal_eval(strtr($description_php, $variables));          $meta_description = drupal_eval(strtr($description_php, $variables));
107      }        }
108    
109      if ( $meta_description != '' ) {        if ( $meta_description != '' ) {
110        $output_tags['description'] = $meta_description;          $output_tags['description'] = $meta_description;
111          }
112      }      }
113    
114      // Robots      // Robots
115      $robots = variable_get('nodewords_nodetype_robots_'. $node->type, array());      // Don't replace per node meta robots
116      if (!empty($robots)) {      $node_robots = array_filter($node->nodewords['robots']['value']);
117        $value = array_filter($robots);      if (empty($node_robots) && !$node->nodewords['robots']['use_default']) {
118        if (!empty($value)) {        $robots = variable_get('nodewords_nodetype_robots_'. $node->type, array());
119          $output_tags['robots'] = implode(', ', $value);        if (!empty($robots)) {
120            $value = array_filter($robots);
121            if (!empty($value)) {
122              $output_tags['robots'] = implode(', ', $value);
123            }
124        }        }
125      }      }
126    }    }

Legend:
Removed from v.1.2.2.6  
changed lines
  Added in v.1.2.2.7

  ViewVC Help
Powered by ViewVC 1.1.2