'checkbox', '#title' => t('Add the Dublin Core schema meta tag'), '#default_value' => variable_get('nodewords_add_dc_schema', FALSE), ); } /** * Implementation of hook_menu(). */ function nodewords_extra_menu() { $items = array(); $items['labels.rdf'] = array( 'title' => 'ICRA labels', 'page callback' => 'nodewords_extra_verification_content', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); return $items; } /** * Implementation of hook_nodewords_api(). */ function nodewords_extra_nodewords_api() { return array( 'version' => 1.1, ); } /** * Implementation of hook_nodewords_tags_info(). */ function nodewords_extra_nodewords_tags_info() { $tags = array( 'dc.contributor' => array( 'tag:context:allowed' => array( NODEWORDS_TYPE_DEFAULT, NODEWORDS_TYPE_NODE, NODEWORDS_TYPE_PAGE, ), 'tag:db:type' => 'string', 'tag:function:prefix' => 'nodewords_extra_dc_contributor', 'tag:template' => array('dc.contributor' => NODEWORDS_META), 'widget:label' => t('Dublin Core contributor'), 'widget:permission' => 'edit meta tag Dublin Core CONTRIBUTOR', ), 'dc.creator' => array( 'tag:context:allowed' => array( NODEWORDS_TYPE_DEFAULT, NODEWORDS_TYPE_NODE, NODEWORDS_TYPE_PAGE, ), 'tag:db:type' => 'string', 'tag:function:prefix' => 'nodewords_extra_dc_creator', 'tag:template' => array('dc.creator' => NODEWORDS_META), 'widget:label' => t('Dublin Core creator'), ), 'dc.date' => array( 'tag:context:allowed' => array( NODEWORDS_TYPE_NODE, NODEWORDS_TYPE_PAGE, ), 'tag:db:type' => 'array', 'tag:function:prefix' => 'nodewords_extra_dc_date', 'tag:template' => array('dc.date' => NODEWORDS_META), 'widget:label' => t('Dublin Core date'), 'widget:permission' => 'edit meta tag Dublin Core DATE', ), 'dc.description' => array( 'tag:db:type' => 'string', 'tag:function:prefix' => 'nodewords_extra_dc_description', 'tag:template' => array('dc.description' => NODEWORDS_META), 'widget:label' => t('Dublin Core description'), 'widget:permission' => 'edit meta tag Dublin Core DESCRIPTION', ), 'dc.publisher' => array( 'tag:context:allowed' => array( NODEWORDS_TYPE_DEFAULT, NODEWORDS_TYPE_PAGE, ), 'tag:db:type' => 'string', 'tag:function:prefix' => 'nodewords_extra_dc_publisher', 'tag:template' => array('dc.publisher' => NODEWORDS_META), 'widget:label' => t('Dublin Core publisher'), 'widget:permission' => 'edit meta tag Dublin Core PUBLISHER', ), 'dc.title' => array( 'tag:context:denied' => array(NODEWORDS_TYPE_DEFAULT), 'tag:db:type' => 'string', 'tag:function:prefix' => 'nodewords_extra_dc_title', 'tag:template' => array('dc.title' => NODEWORDS_META), 'widget:label' => t('Dublin Core title'), 'widget:permission' => 'edit meta tag Dublin Core TITLE', ), 'location' => array( 'tag:db:type' => 'array', 'tag:function:prefix' => 'nodewords_extra_location', 'tag:template' => array( 'geo.position' => NODEWORDS_META, 'icbm' => NODEWORDS_META, ), 'widget:label' => t('Location'), 'widget:permission' => 'edit location meta tags', ), 'pics-label' => array( 'tag:context:allowed' => array( NODEWORDS_TYPE_DEFAULT, NODEWORDS_TYPE_NODE, NODEWORDS_TYPE_PAGE, ), 'tag:db:type' => 'string', 'tag:attributes' => array( 'meta' => array( 'title' => 'ICRA labels', 'type' => 'application/rdf+xml', ), ), 'tag:function:prefix' => 'nodewords_extra_pics', 'tag:template' => array( 'pics-label' => NODEWORDS_HTTP_EQUIV, 'meta' => NODEWORDS_LINK_REL, ), 'tag:weight' => array('meta' => -10), 'widget:label' => t('PICS labels'), 'widget:permission' => 'edit meta tag PICS-LABEL', ), ); return $tags; } function nodewords_extra_nodewords_tags_output_alter(&$output, $parameters) { $bool = array( variable_get('nodewords_add_dc_schema', FALSE) && isset($parameters['output']) && $parameters['ouput'] == 'head' ); if ($bool) { $output = ( '' . "\n" . $output ); } } /** * Implementation of hook_perm(). */ function nodewords_extra_perm() { return array( 'edit meta tag Dublin Core CONTRIBUTOR', 'edit meta tag Dublin Core CREATOR', 'edit meta tag Dublin Core DATE', 'edit meta tag Dublin Core DESCRIPTION', 'edit meta tag Dublin Core PUBLISHER', 'edit meta tag Dublin Core TITLE', 'edit location meta tags', 'edit meta tag PICS-LABEL', ); } /***************************************************************************** * Menu callbacks / form builders, submit/validate functions. ****************************************************************************/ function nodewords_extra_verification_content() { drupal_set_header('Content-Type: application/rdf+xml; charset=utf-8'); print variable_get('nodewords_icra_validation_content', ''); } /***************************************************************************** * Meta tags implementation functions. ****************************************************************************/ /** * Set the form fields used to implement the options for the meta tag. */ function nodewords_extra_dc_contributor_form(&$form, $content, $options) { $form['dc.contributor'] = array( '#tree' => TRUE, ); $form['dc.contributor']['value'] = array( '#type' => 'textfield', '#title' => t('Dublin Core contributor'), '#description' => t('Enter the name of an entity responsible for making contributions to the resource. Examples of a contributor include a person, an organization, or a service.'), '#default_value' => empty($content['value']) ? (!empty($options['default']['dc.contributor']['value']) ? $options['default']['dc.contributor']['value'] : '') : $content['value'], '#size' => 60, '#maxlength' => variable_get('nodewords_max_size', 350), ); } /** * Set the meta tag content. */ function nodewords_extra_dc_contributor_prepare(&$tags, $content, $options) { if (!empty($content['value'])) { $tags['dc.contributor'] = $content['value']; } elseif (!empty($options['default']['dc.contributor']['value'])) { $tags['dc.contributor'] = $options['default']['dc.contributor']['value']; } else { if ($options['type'] == NODEWORDS_TYPE_NODE && count($options['ids']) == 1) { $bool = ( ($node = node_load($options['ids'][0])) && ($uid = $node->uid) && ($user = user_load($uid)) && $user->name ); if ($bool) { $tags['dc.contributor'] = $user->name; } } } } /** * Set the form fields used to implement the options for the meta tag. */ function nodewords_extra_dc_creator_form(&$form, $content, $options) { $form['dc.creator'] = array( '#tree' => TRUE, ); $form['dc.creator']['value'] = array( '#type' => 'textfield', '#title' => t('Dublin Core creator'), '#description' => t('Enter the name of an entity primarily responsible for making the resource. Examples of a creator include a person, an organization, or a service.'), '#default_value' => empty($content['value']) ? (!empty($options['default']['dc.creator']['value']) ? $options['default']['dc.creator']['value'] : '') : $content['value'], '#size' => 60, '#maxlength' => variable_get('nodewords_max_size', 350), ); } /** * Set the meta tag content. */ function nodewords_extra_dc_creator_prepare(&$tags, $content, $options) { if (!empty($content['value'])) { $tags['dc.creator'] = $content['value']; } elseif (!empty($options['default']['dc.creator']['value'])) { $tags['dc.creator'] = $options['default']['dc.creator']['value']; } else { if ($options['type'] == NODEWORDS_TYPE_NODE && count($options['ids']) == 1) { $bool = ( ($node = node_load($options['ids'][0])) && ($uid = $node->uid) && ($user = user_load($uid)) && $user->name ); if ($bool) { $tags['dc.creator'] = $user->name; } } } } /** * Set the form fields used to implement the options for the meta tag. */ function nodewords_extra_dc_date_form(&$form, $content, $options) { $form['dc.date'] = array( '#tree' => TRUE, ); $form['dc.date']['value'] = array( '#type' => 'date', '#title' => t('Dublin Core date'), '#description' => t('A point or period of time associated with an event in the lifecycle of the resource. The date should be relative to UTC.'), '#default_value' => empty($content['value']) ? array() : $content['value'], ); } /** * Set the meta tag content. */ function nodewords_extra_dc_date_prepare(&$tags, $content, $options) { if (!empty($content['value'])) { $time = mktime(0, 0, 0, $content['value']['month'], $content['value']['day'], $content['value']['year']); if ($time > 0) { $tags['dc.date'] = date('Y-m-d\TH:i:s\Z', $time); } } } /** * Set the form fields used to implement the options for the meta tag. */ function nodewords_extra_dc_description_form(&$form, $content, $options) { if (!isset($form['description'])) { $bool = ( isset($options['node_type']) && variable_get('nodewords_basic_use_teaser_' . $options['node_type'], variable_get('nodewords_basic_use_teaser', FALSE)) ); if (!$bool) { $form['dc.description'] = array( '#tree' => TRUE, ); $form['dc.description']['value'] = array( '#type' => 'textarea', '#title' => t('Description'), '#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', 350))), '#default_value' => empty($content['value']) ? (!empty($options['default']['dc.description']['value']) ? $options['default']['dc.description']['value'] : '') : $content['value'], '#cols' => 60, '#rows' => 6, ); } } } /** * Set the meta tag content. */ function nodewords_extra_dc_description_prepare(&$tags, $content, $options) { if (empty($tags['description'])) { if (empty($content['value'])) { if (!empty($options['default']['dc.description']['value'])) { $value = $options['default']['dc.description']['value']; } elseif (!empty($options['default']['description']['value'])) { $value = $options['default']['description']['value']; } else { $value = ''; } } else { $value = $content['value']; } $tags['dc.description'] = $value; } else { $tags['dc.description'] = $tags['description']; } } /** * Set the form fields used to implement the options for the meta tag. */ function nodewords_extra_dc_publisher_form(&$form, $content, $options) { $form['dc.publisher'] = array( '#tree' => TRUE, ); $form['dc.publisher']['value'] = array( '#type' => 'textfield', '#title' => t('Dublin Core publisher'), '#description' => t('Enter a name of an entity responsible for making the resource available. Examples of a publisher include a person, an organization, or a service.'), '#default_value' => empty($options['default']['dc.publisher']['value']) ? '' : $options['default']['dc.publisher']['value'], '#size' => 60, '#maxlength' => variable_get('nodewords_max_size', 350), ); } /** * Set the meta tag content. */ function nodewords_extra_dc_publisher_prepare(&$tags, $content, $options) { $tags['dc.publisher'] = empty($options['default']['dc.publisher']['value']) ? '' : $options['default']['dc.publisher']['value']; } /** * Set the form fields used to implement the options for the meta tag. */ function nodewords_extra_dc_title_form(&$form, $content, $options) { $form['dc.title'] = array( '#tree' => TRUE, ); $form['dc.title']['value'] = array( '#type' => 'textfield', '#title' => t('Dublin Core title'), '#description' => t('Enter an alternative title. Do not use the value already used for the HTML tag TITLE, or you will probably get warning reports about duplicated titles from the search engines.'), '#default_value' => empty($content['value']) ? '' : $content['value'], '#size' => 60, '#maxlength' => variable_get('nodewords_max_size', 350), ); } /** * Set the meta tag content. */ function nodewords_extra_dc_title_prepare(&$tags, $content, $options) { if (empty($content['value'])) { if ($options['type'] == NODEWORDS_TYPE_NODE && count($options['ids']) == 1) { if ($node = node_load($options['ids'][0])) { $content['value'] = $node->title; } } } $tags['dc.title'] = empty($content['value']) ? '' : $content['value']; } /** * Set the form fields used to implement the options for the meta tag. */ function nodewords_extra_location_form(&$form, $content, $options) { $form['location'] = array( '#tree' => TRUE, ); $form['location']['latitude'] = array( '#type' => 'textfield', '#title' => t('Location coordinates (latitude, longitude)'), '#default_value' => empty($content['latitude']) ? (!empty($options['default']['location']['latitude']) ? $options['default']['location']['latitude'] : '') : $content['latitude'], '#element_validate' => array('nodewords_extra_location_form_validate'), '#size' => 14, '#maxlength' => 14, '#prefix' => '