/[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.4, Mon Jun 1 18:38:18 2009 UTC revision 1.2.2.5, Thu Sep 24 01:12:50 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /* $Id: nodewords_nodetype.module,v 1.2.2.3 2009/06/01 18:31:02 hanoii Exp $ */  /* $Id: nodewords_nodetype.module,v 1.2.2.4 2009/06/01 18:38:18 hanoii Exp $ */
3    
4  function nodewords_nodetype_form_alter(&$form, &$form_state, $form_id) {  function nodewords_nodetype_form_alter(&$form, &$form_state, $form_id) {
5    if ($form_id == 'node_type_form' && isset($form['#node_type'])) {    if ($form_id == 'node_type_form' && isset($form['#node_type'])) {
     $settings = _nodewords_get_settings();  
6      $form['nodewords_nodetype'] = array(      $form['nodewords_nodetype'] = array(
7        '#type' => 'fieldset',        '#type' => 'fieldset',
8        '#title' => t('Meta tags node type'),        '#title' => t('Meta tags node type'),
# Line 11  function nodewords_nodetype_form_alter(& Line 10  function nodewords_nodetype_form_alter(&
10        '#collapsed' => TRUE,        '#collapsed' => TRUE,
11      );      );
12      $form['nodewords_nodetype']['nodewords_nodetype_robots'] = array(      $form['nodewords_nodetype']['nodewords_nodetype_robots'] = array(
13        '#type' => 'select',        '#type' => 'checkboxes',
14        '#title' => t('Default "robots" meta tag'),        '#title' => t('Default "robots" meta tag'),
15        '#options' => array(        '#options' => array(
16          '' => t('Use Meta tags default'),          'noindex' => t('NOINDEX'),
17          'index,follow' => 'ALL=INDEX,FOLLOW',          'nofollow' => t('NOFOLLOW'),
18          'noindex,follow' => 'NOINDEX,FOLLOW',          'noarchive' => t('NOARCHIVE'),
19          'index,nofollow' => 'INDEX,NOFOLLOW',          'noopd' => t('NOOPD'),
20          'noindex,nofollow' => 'NONE=NOINDEX,NOFOLLOW',          'nosnippet' => t('NOSNIPPET'),
21            'noydir' => t('NOYDIR'),
22        ),        ),
23        '#multiple' => FALSE,        '#checkall' => TRUE,
24        '#default_value' => variable_get('nodewords_nodetype_robots_'. $form['#node_type']->type, ''),        '#default_value' => variable_get('nodewords_nodetype_robots_'. $form['#node_type']->type, array()),
25        '#description' => t('The ROBOTS meta tag offers a simple mechanism to indicate to web robots and crawlers wether the page should be indexed (INDEX or NOINDEX) and whether links on the page should be followed (FOLLOW or NOFOLLOW). Here you can enter the default robots meta tag to use for all pages. If unsure, select "ALL=INDEX,FOLLOW".'),        '#description' => t('The ROBOTS meta tag offers a simple mechanism to indicate to web robots and crawlers whether the page should be indexed (INDEX or NOINDEX) and whether links on the page should be followed (FOLLOW or NOFOLLOW).'),
26      );      );
27      $form['nodewords_nodetype']['nodewords_nodetype_keywords'] = array(      $form['nodewords_nodetype']['nodewords_nodetype_keywords'] = array(
28        '#type' => 'textfield',        '#type' => 'textfield',
29        '#title' => t('Default "keywords" meta tag'),        '#title' => t('Default "keywords" meta tag'),
30        '#default_value' => variable_get('nodewords_nodetype_keywords_'. $form['#node_type']->type, ''),        '#default_value' => variable_get('nodewords_nodetype_keywords_'. $form['#node_type']->type, ''),
31        '#size' => 60,        '#size' => 60,
32        '#maxlength' => $settings['max_size'],        '#maxlength' => variable_get('nodewords_max_size', 255),
33        '#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('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.'),
34      );      );
35    
# Line 43  function nodewords_nodetype_form_alter(& Line 43  function nodewords_nodetype_form_alter(&
43        '#type' => 'textarea',        '#type' => 'textarea',
44        '#title' => t('Default "description" meta tag'),        '#title' => t('Default "description" meta tag'),
45        '#default_value' => variable_get('nodewords_nodetype_description_'. $form['#node_type']->type, ''),        '#default_value' => variable_get('nodewords_nodetype_description_'. $form['#node_type']->type, ''),
46        '#description' => t('Enter a global meta tag description for this content type. 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' => $settings['max_size'])) . ($settings['use_teaser'] ? ' ' . t('When you leave this field empty, the teaser will be used as description.') : '') . t('Tokens are allowed, data will be shortened to the max and unallowed tags or caracters will be removed.'),        '#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.') : ''),
47      );      );
48    
49      $form['nodewords_nodetype']['nodewords_nodetype_token'] = array(      $form['nodewords_nodetype']['nodewords_nodetype_token'] = array(
# Line 77  function nodewords_nodetype_form_alter(& Line 77  function nodewords_nodetype_form_alter(&
77  /**  /**
78   * Implementation of hook_nodewords().   * Implementation of hook_nodewords().
79   */   */
80  function nodewords_nodetype_nodewords(&$tags, $op, $type, $ids) {  function nodewords_nodetype_nodewords_tags_alter(&$output_tags, $tag_options) {
81    switch ($op) {    if ($tag_options['type'] == 'node') {
82      case 'prepare':      $node = node_load($tag_options['ids'][0]);
83        if ( $type == 'node' && (!isset($tags['description']) || empty($tags['description'])) && count($ids) == 1) {      if ( ( $keywords = variable_get('nodewords_nodetype_keywords_'. $node->type, '') ) !== '' ) {
84          $meta_description = '';        $output_tags['keywords'] .= ($output_tags['keywords'] !== '' ? ',' : '' ). $keywords;
85          $node = node_load($ids[0]);        $output_tags['keywords'] = nodewords_unique($output_tags['keywords']);
86          // description field      }
87          if ( ( $description = variable_get('nodewords_nodetype_description_'. $node->type, '') ) !== '' ) {      // description field
88            $meta_description = token_replace($description, 'node', $node);      if ( ( $description = variable_get('nodewords_nodetype_description_'. $node->type, '') ) !== '' ) {
89          }        $meta_description = token_replace($description, 'node', $node);
90          // description php field      }
91          if ( ( $description_php = variable_get('nodewords_nodetype_desc_php_'. $node->type, '') ) !== '' ) {      // description php field
92            $description_php = token_replace($description_php, 'node', $node);      if ( ( $description_php = variable_get('nodewords_nodetype_desc_php_'. $node->type, '') ) !== '' ) {
93            $variables['%description'] = $meta_description;        $description_php = token_replace($description_php, 'node', $node);
94            $variables['%php_description'] = '$description = \'' . str_replace('\'', '\\\'', $meta_description) . '\';';        $variables['%description'] = $meta_description;
95            $meta_description = drupal_eval(strtr($description_php, $variables));        $variables['%php_description'] = '$description = \'' . str_replace('\'', '\\\'', $meta_description) . '\';';
96          }        $meta_description = drupal_eval(strtr($description_php, $variables));
97        }
         if ( $meta_description != '' ) {  
           $tags['description']= _nodewords_check_content(html_entity_decode($meta_description, ENT_COMPAT, 'UTF-8'));  
         }  
   
         if ( ( $keywords = variable_get('nodewords_nodetype_keywords_'. $node->type, '') ) !== '' ) {  
           $tags['keywords'] = _nodewords_check_content(token_replace($keywords, 'node', $node));  
         }  
         if ( ( $robots = variable_get('nodewords_nodetype_robots_'. $node->type, '') ) !== '' ) {  
           $tags['robots'] = _nodewords_check_content(token_replace($robots, 'node', $node));  
         }  
       }  
98    
99        break;      if ( $meta_description != '' ) {
100          $output_tags['description'] = $meta_description;
101        }
102    
103        $robots = variable_get('nodewords_nodetype_robots_'. $node->type, array());
104        if (!empty($robots)) {
105          $value = array_filter($robots);
106          if (!empty($value)) {
107            $output_tags['robots'] = implode(', ', $value);
108          }
109        }
110    }    }
111  }  }
112    

Legend:
Removed from v.1.2.2.4  
changed lines
  Added in v.1.2.2.5

  ViewVC Help
Powered by ViewVC 1.1.2