annotate sites/all/modules/schemaorg/schemaorg.module @ 9:830c812b520f

added smtp module
author root <root@paio.local>
date Mon, 28 Oct 2013 15:34:27 +0000
parents ce11bbd8f642
children
rev   line source
danielebarchiesi@4 1 <?php
danielebarchiesi@4 2
danielebarchiesi@4 3 /**
danielebarchiesi@4 4 * @file
danielebarchiesi@4 5 * Enables administrators to annotate their structured content with vocabularies
danielebarchiesi@4 6 * from schema.org
danielebarchiesi@4 7 */
danielebarchiesi@4 8
danielebarchiesi@4 9 /**
danielebarchiesi@4 10 * Implements hook_help().
danielebarchiesi@4 11 */
danielebarchiesi@4 12 function schemaorg_help($path, $arg) {
danielebarchiesi@4 13 switch ($path) {
danielebarchiesi@4 14 case 'admin/help#schemaorg':
danielebarchiesi@4 15 $output = '';
danielebarchiesi@4 16 $output .= '<h3>' . t('About') . '</h3>';
danielebarchiesi@4 17 $output .= '<p>' . t('<a href="@schemaorg">Schema.org</a> provides a collection of schemas useful for site builders and administrators to annotate their pages in ways recognized by major search engines including Bing, Google and Yahoo!. These semantic annotations allow search providers to improve the display of search results, making it easier for people to find what they are looking for on the Web. ', array('@schemaorg' => 'http://schema.org/')) . '</p>';
danielebarchiesi@4 18 $output .= '<p>' . t('Each of your <a href="@content_types">content types</a> and their fields can be mapped to schema.org vocabularies. The type (e.g. Event) and the property of the title (e.g. name) are defined in the edit form of each content type, in the "Schema.org" vertical tab. The property of each field can be set when editing a field, in the schema.org fieldset.', array('@content_types' => url('admin/structure/types'))) . '</p>';
danielebarchiesi@4 19 return $output;
danielebarchiesi@4 20 }
danielebarchiesi@4 21 }
danielebarchiesi@4 22
danielebarchiesi@4 23 /**
danielebarchiesi@4 24 * Implements hook_entity_view().
danielebarchiesi@4 25 */
danielebarchiesi@4 26 function schemaorg_entity_view($entity, $type, $view_mode, $langcode) {
danielebarchiesi@4 27 // Adds the schema.org url to the entity content as RDF metadata.
danielebarchiesi@4 28 if (!empty($entity->rdf_mapping['url']['predicates'])) {
danielebarchiesi@4 29 $attributes = rdf_rdfa_attributes($entity->rdf_mapping['url']);
danielebarchiesi@4 30 $uri = entity_uri($type, $entity);
danielebarchiesi@4 31 $attributes['resource'] = url($uri['path'], $uri['options']);
danielebarchiesi@4 32 $entity->content['schemaorg_url'] = array(
danielebarchiesi@4 33 '#markup' => theme('rdf_metadata', array('metadata' => array('span' => $attributes))),
danielebarchiesi@4 34 '#weight' => 100,
danielebarchiesi@4 35 );
danielebarchiesi@4 36 }
danielebarchiesi@4 37
danielebarchiesi@4 38 // It seems parsers are expecting to find the title/name of the entity within
danielebarchiesi@4 39 // the main content of the entity. Drupal displays the title outside the main
danielebarchiesi@4 40 // content on full entity display, so we assert it as hidden RDF metadata.
danielebarchiesi@4 41 foreach (array('title', 'subject', 'name') as $field_name) {
danielebarchiesi@4 42 if (!empty($entity->{$field_name})) {
danielebarchiesi@4 43 $label_field = $field_name;
danielebarchiesi@4 44 break;
danielebarchiesi@4 45 }
danielebarchiesi@4 46 }
danielebarchiesi@4 47 if (isset($label_field) && !empty($entity->rdf_mapping[$label_field]['predicates'])) {
danielebarchiesi@4 48 $attributes = rdf_rdfa_attributes($entity->rdf_mapping[$label_field]);
danielebarchiesi@4 49 $attributes['content'] = $entity->{$label_field};
danielebarchiesi@4 50 $entity->content['schemaorg_name'] = array(
danielebarchiesi@4 51 '#markup' => theme('rdf_metadata', array('metadata' => array('span' => $attributes))),
danielebarchiesi@4 52 '#weight' => 100,
danielebarchiesi@4 53 );
danielebarchiesi@4 54 }
danielebarchiesi@4 55 }
danielebarchiesi@4 56
danielebarchiesi@4 57 /**
danielebarchiesi@4 58 * Implements hook_rdf_namespaces().
danielebarchiesi@4 59 */
danielebarchiesi@4 60 function schemaorg_rdf_namespaces() {
danielebarchiesi@4 61 return array(
danielebarchiesi@4 62 'schema' => 'http://schema.org/',
danielebarchiesi@4 63 );
danielebarchiesi@4 64 }
danielebarchiesi@4 65
danielebarchiesi@4 66 /**
danielebarchiesi@4 67 * Implementation of hook_features_api().
danielebarchiesi@4 68 */
danielebarchiesi@4 69 function schemaorg_features_api() {
danielebarchiesi@4 70 return array(
danielebarchiesi@4 71 'schemaorg' => array(
danielebarchiesi@4 72 'name' => t('Schema.org mappings'),
danielebarchiesi@4 73 'default_hook' => 'rdf_default_mappings',
danielebarchiesi@4 74 'file' => drupal_get_path('module', 'schemaorg') .'/schemaorg.features.inc',
danielebarchiesi@4 75 ),
danielebarchiesi@4 76 );
danielebarchiesi@4 77 }