/[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.5, Thu Sep 24 01:12:50 2009 UTC revision 1.2.2.6, Thu Sep 24 01:29:20 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  /* $Id: nodewords_nodetype.module,v 1.2.2.4 2009/06/01 18:38:18 hanoii Exp $ */  /* $Id: nodewords_nodetype.module,v 1.2.2.5 2009/09/24 01:12:50 hanoii Exp $ */
3    
4    /**
5     * Implementation of hook_form_alter().
6     */
7  function nodewords_nodetype_form_alter(&$form, &$form_state, $form_id) {  function nodewords_nodetype_form_alter(&$form, &$form_state, $form_id) {
8    if ($form_id == 'node_type_form' && isset($form['#node_type'])) {    if ($form_id == 'node_type_form' && isset($form['#node_type'])) {
9      $form['nodewords_nodetype'] = array(      $form['nodewords_nodetype'] = array(
# Line 75  function nodewords_nodetype_form_alter(& Line 78  function nodewords_nodetype_form_alter(&
78  }  }
79    
80  /**  /**
81   * Implementation of hook_nodewords().   * Implementation of hook_nodewords_tags_alter().
82   */   */
83  function nodewords_nodetype_nodewords_tags_alter(&$output_tags, $tag_options) {  function nodewords_nodetype_nodewords_tags_alter(&$output_tags, $tag_options) {
84    if ($tag_options['type'] == 'node') {    if ($tag_options['type'] == 'node') {
85      $node = node_load($tag_options['ids'][0]);      $node = node_load($tag_options['ids'][0]);
86    
87        // Keywords
88      if ( ( $keywords = variable_get('nodewords_nodetype_keywords_'. $node->type, '') ) !== '' ) {      if ( ( $keywords = variable_get('nodewords_nodetype_keywords_'. $node->type, '') ) !== '' ) {
89        $output_tags['keywords'] .= ($output_tags['keywords'] !== '' ? ',' : '' ). $keywords;        $output_tags['keywords'] .= ($output_tags['keywords'] !== '' ? ',' : '' ). $keywords;
90        $output_tags['keywords'] = nodewords_unique($output_tags['keywords']);        $output_tags['keywords'] = nodewords_unique($output_tags['keywords']);
91      }      }
92      // description field  
93        // Dsecription
94      if ( ( $description = variable_get('nodewords_nodetype_description_'. $node->type, '') ) !== '' ) {      if ( ( $description = variable_get('nodewords_nodetype_description_'. $node->type, '') ) !== '' ) {
95        $meta_description = token_replace($description, 'node', $node);        $meta_description = token_replace($description, 'node', $node);
96      }      }
97      // description php field  
98      if ( ( $description_php = variable_get('nodewords_nodetype_desc_php_'. $node->type, '') ) !== '' ) {      if ( ( $description_php = variable_get('nodewords_nodetype_desc_php_'. $node->type, '') ) !== '' ) {
99        $description_php = token_replace($description_php, 'node', $node);        $description_php = token_replace($description_php, 'node', $node);
100        $variables['%description'] = $meta_description;        $variables['%description'] = $meta_description;
101        $variables['%php_description'] = '$description = \'' . str_replace('\'', '\\\'', $meta_description) . '\';';        $variables['%php_description'] = '$description = \'' . str_replace('\'', '\\\'', $meta_description) . '\';';
102        $meta_description = drupal_eval(strtr($description_php, $variables));        $meta_description = drupal_eval(strtr($description_php, $variables));
103      }      }
104    
105      if ( $meta_description != '' ) {      if ( $meta_description != '' ) {
106        $output_tags['description'] = $meta_description;        $output_tags['description'] = $meta_description;
107      }      }
108    
109        // Robots
110      $robots = variable_get('nodewords_nodetype_robots_'. $node->type, array());      $robots = variable_get('nodewords_nodetype_robots_'. $node->type, array());
111      if (!empty($robots)) {      if (!empty($robots)) {
112        $value = array_filter($robots);        $value = array_filter($robots);

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

  ViewVC Help
Powered by ViewVC 1.1.2