'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_MT_TYPE_DEFAULT, NODEWORDS_MT_TYPE_NODE), 'tag:db:type' => 'string', 'tag:function:prefix' => 'nodewords_extra_dc_contributor', 'tag:template' => array('dc.contributor' => NODEWORDS_META), 'tag:tokens' => TRUE, 'widget:label' => t('Dublin Core contributor'), 'widget:permission' => 'edit meta tag Dublin Core CONTRIBUTOR', ), 'dc.creator' => array( 'tag:context:allowed' => array(NODEWORDS_MT_TYPE_DEFAULT, NODEWORDS_MT_TYPE_NODE), 'tag:db:type' => 'string', 'tag:function:prefix' => 'nodewords_extra_dc_creator', 'tag:template' => array('dc.creator' => NODEWORDS_META), 'tag:tokens' => TRUE, 'widget:label' => t('Dublin Core creator'), ), 'dc.date' => array( 'tag:context:allowed' => array(NODEWORDS_MT_TYPE_NODE), '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:context:allowed' => 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'), ), 'dc.publisher' => array( 'tag:context:allowed' => array(NODEWORDS_MT_TYPE_DEFAULT), 'tag:db:type' => 'string', 'tag:function:prefix' => 'nodewords_extra_dc_publisher', 'tag:template' => array('dc.publisher' => NODEWORDS_META), 'tag:tokens' => TRUE, 'widget:label' => t('Dublin Core publisher'), 'widget:permission' => 'edit meta tag Dublin Core PUBLISHER', ), 'dc.title' => array( 'tag:context:denied' => array(NODEWORDS_MT_TYPE_DEFAULT, NODEWORDS_MT_TYPE_PAGER), 'tag:db:type' => 'string', 'tag:function:prefix' => 'nodewords_extra_dc_title', 'tag:template' => array('dc.title' => NODEWORDS_META), 'tag:tokens' => TRUE, 'widget:label' => t('Dublin Core title'), 'widget:permission' => 'edit meta tag Dublin Core TITLE', ), 'location' => array( 'tag:context:denied' => array(NODEWORDS_MT_TYPE_PAGER), '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_MT_TYPE_DEFAULT, NODEWORDS_MT_TYPE_NODE), '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', ), 'schema.dc' => array( 'tag:context:allowed' => array(''), 'tag:db:type' => 'string', 'tag:function:prefix' => 'nodewords_extra_dc_schema', 'tag:template' => array('schema.dc' => NODEWORDS_LINK_REL), 'tag:weight' => array('schema.dc' => -20), 'widget:label' => t('Dublin Core schema'), ), ); return $tags; } /** * 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 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( '#type' => 'fieldset', '#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.'), '#collapsible' => TRUE, '#collapsed' => !(empty($content['value']) && empty($options['default']['dc.contributor']['value'])), '#tree' => TRUE, ); $form['dc.contributor']['value'] = array( '#type' => 'textfield', '#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) { $value = empty($content['value']) ? (!empty($options['default']['dc.contributor']['value']) ? $options['default']['dc.contributor']['value'] : '') : $content['value']; $tags['dc.contributor'] = nodewords_replace_tokens($options['type'], $options['ids'], $value); } /** * 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( '#type' => 'fieldset', '#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.'), '#collapsible' => TRUE, '#collapsed' => !(empty($content['value']) && empty($options['default']['dc.creator']['value'])), '#tree' => TRUE, ); $form['dc.creator']['value'] = array( '#type' => 'textfield', '#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) { $value = empty($content['value']) ? (!empty($options['default']['dc.creator']['value']) ? $options['default']['dc.creator']['value'] : '') : $content['value']; $tags['dc.creator'] = nodewords_replace_tokens($options['type'], $options['ids'], $value); } /** * 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( '#type' => 'fieldset', '#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.'), '#collapsible' => TRUE, '#collapsed' => !empty($content['value']), '#tree' => TRUE, ); $form['dc.date']['value'] = array( '#type' => 'date', '#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 meta tag content. */ function nodewords_extra_dc_description_prepare(&$tags, $content, $options) { if (!empty($tags['description'])) { $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( '#type' => 'fieldset', '#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.'), '#collapsible' => TRUE, '#collapsed' => !empty($options['default']['dc.publisher']['value']), '#tree' => TRUE, ); $form['dc.publisher']['value'] = array( '#type' => 'textfield', '#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) { $value = empty($options['default']['dc.publisher']['value']) ? '' : $options['default']['dc.publisher']['value']; $tags['dc.publisher'] = nodewords_replace_tokens($options['type'], $options['ids'], $value); } /** * Set the meta tag content. */ function nodewords_extra_dc_schema_prepare(&$tags, $content, $options) { $tags['schema.dc'] = 'http://purl.org/dc/elements/1.1/'; } /** * 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( '#type' => 'fieldset', '#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.'), '#collapsible' => TRUE, '#collapsed' => !empty($content['value']), '#tree' => TRUE, ); $form['dc.title']['value'] = array( '#type' => 'textfield', '#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) { $value = empty($content['value']) ? '' : $content['value']; $tags['dc.title'] = nodewords_replace_tokens($options['type'], $options['ids'], $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( '#type' => 'fieldset', '#title' => t('Location coordinates'), '#description' => t('Enter first the latitude, and then the longitude.'), '#collapsible' => TRUE, '#collapsed' => !((empty($content['latitude']) || empty($content['longitude'])) && (empty($options['default']['location']['latitude']) || empty($options['default']['location']['longitude']))), '#tree' => TRUE, ); $form['location']['latitude'] = array( '#type' => 'textfield', '#title' => '', '#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' => '
', '#latitude' => TRUE, ); $form['location']['longitude'] = array( '#type' => 'textfield', '#title' => '', '#default_value' => empty($content['longitude']) ? (!empty($options['default']['location']['longitude']) ? $options['default']['location']['longitude'] : '') : $content['longitude'], '#size' => 14, '#element_validate' => array('nodewords_extra_location_form_validate'), '#maxlength' => 14, '#suffix' => '
', ); } /** * Set the meta tag content. */ function nodewords_extra_location_prepare(&$tags, $content, $options) { if ((empty($content['longitude']) || empty($content['longitude'])) && $options['type'] == NODEWORDS_MT_TYPE_NODE && count($options['ids']) == 1 && module_exists('location')) { $node = node_load(array('vid' => $options['ids'][0])); if ($node && isset($node->locations[0]['latitude']) && isset($node->locations[0]['longitude'])) { $content['latitude'] = $node->locations[0]['latitude']; $content['longitude'] = $node->locations[0]['longitude']; } } if (empty($content['latitude']) || empty($content['longitude'])) { $content['latitude'] = !empty($options['default']['location']['latitude']) ? $options['default']['location']['latitude'] : ''; $content['longitude'] = !empty($options['default']['location']['longitude']) ? $options['default']['location']['longitude'] : ''; } if (!empty($content['longitude']) && !empty($content['longitude'])) { $tags['location:geo.position'] = $content['latitude'] . ';' . $content['longitude']; $tags['location:icbm'] = $content['latitude'] . ',' . $content['longitude']; } } /** * Validate the values passed as latitude, and longitude. */ function nodewords_extra_location_form_validate($element, &$form_state) { if (isset($element['#latitude'])) { if (!empty($element['#value']) && (!is_numeric($element['#value']) || $element['#value'] < -90.0 || $element['#value'] > 90.0)) { form_error($element, t('Latitude must be a number between -90.0 and 90.0 (extrems included).')); } } else { if (!empty($element['#value']) && (!is_numeric($element['#value']) || $element['#value'] < -180.0 || $element['#value'] > 180.0)) { form_error($element, t('Longitude must be a number between -180.0 and 180.0 (extrems included).')); } } } /** * Set the form fields used to implement the options for the meta tag. */ function nodewords_extra_pics_form(&$form, $content, $options) { $form['pics-label'] = array( '#type' => 'fieldset', '#title' => t('PICS labels'), '#description' => t('Enter the ICRA PICS labels only, without any extra characters; ICRA PICS labels should be something similar to %icra-pics-example. You can use the online ICRA label generator.', array('%icra-pics-example' => 'n 0 s 0 v 0 l 0 oa 0 ob 0 oc 0 od 0 oe 0 of 0 og 0 oh 0 c 1', '@icra-label-generator' => 'http://www.icra.org/label/generator/')), '#collapsible' => TRUE, '#collapsed' => !(empty($content['value']) && empty($options['default']['pics-label']['value'])), '#tree' => TRUE, ); $form['pics-label']['value'] = array( '#type' => 'textfield', '#default_value' => empty($content['value']) ? (!empty($options['default']['pics-label']['value']) ? $options['default']['pics-label']['value'] : '') : $content['value'], '#size' => 60, '#maxlength' => variable_get('nodewords_max_size', 350), ); } /** * Set the meta tag content. */ function nodewords_extra_pics_prepare(&$tags, $content, $options) { if (empty($content['value'])) { $content['value'] = !empty($options['default']['pics-label']['value']) ? $options['default']['pics-label']['value'] : ''; } if (!empty($content['value'])) { if ($options['type'] == NODEWORDS_MT_TYPE_NODE && count($options['ids']) == 1) { $tags['pics-label'] = strtr( '(pics-1.1 "http://www.icra.org/pics/vocabularyv03/" l gen true for %url r (%pics))', array( '%url' => url("node/{$options['ids'][0]}", array('absolute' => TRUE)), '%pics' => $content['value'], ) ); } } if (variable_get('nodewords_icra_validation_content', '')) { $tags['pics-label:meta'] = url('labels.rdf', array('absolute' => TRUE)); } } function nodewords_extra_pics_settings_form(&$form, $form_id, $options) { if ($form_id == 'advanced_settings') { $form['advanced']['nodewords_icra_validation_content'] = array( '#type' => 'textarea', '#title' => t('IRCA validation content'), '#description' => t('Enter the validation content IRCA sent you. Leave this field empty if you do not know what a IRCA validation file is. For more information, see The Family Online Safety Institute: Protecting your online future.', array('@irca-url' => 'http://www.icra.org/support/')), '#default_value' => variable_get('nodewords_icra_validation_content', ''), '#size' => 60, ); } } /** * @} End of "addtogroup nodewords_extra". */