<?php

function incubator_social_metatag_config_default_alter(array &$configs) {
  foreach ($configs as &$config) {
    switch ($config->instance) {

// =====================================================================
      case 'global':
// Metatag
//    'title' => array('value' => '[current-page:title] | [site:name]'),
//    'generator' => array('value' => 'Drupal 7 (http://drupal.org)'),
//    'canonical' => array('value' => '[current-page:url:absolute]'),
//    'shortlink' => array('value' => '[current-page:url:unaliased]'),
// Opengraph
//      'og:type' => array('value' => 'article'),
//      'og:title' => array('value' => '[current-page:title]'),
//      'og:site_name' => array('value' => '[site:name]'),
//      'og:url' => array('value' => '[current-page:url:absolute]'),
// Twitter
//      'twitter:card' => array('value' => 'summary'),
//      'twitter:description' => array('value' => '[site:slogan]'),
//      'twitter:title' => array('value' => '[site:name]'),
//      'twitter:url' => array('value' => '[current-page:url:absolute]'),
        $config->config += array(
          'og:image' => array('value' => '[site:social-image-url]'),
          'image_src' => array('value' => '[site:social-image-url]'),
          'twitter:title' => array('value' => '[current-page:title]'),
          'twitter:description' => array('value' => ''),
        );
        break;
// =====================================================================
      case 'global:frontpage':
// Metatag
//    'title' => array('value' => variable_get('site_slogan') ? '[site:name] | [site:slogan]' : '[site:name]'),
//    'canonical' => array('value' => '[site:url]'),
//    'shortlink' => array('value' => '[site:url]'),
// Opengraph
//      'og:type' => array('value' => 'website'),
//      'og:title' => array('value' => '[site:name]'),
//      'og:url' => array('value' => '[site:url]'),
// Twitter
//      'twitter:description' => array('value' => ''),
        $config->config += array(
          'title' => array('value' => '[site:name]'),
          'description' =>  array('value' => '[site:slogan]'),
          'twitter:title' => array('value' => '[site:name]'),
          'twitter:description' => array('value' => '[site:slogan]'),
          'og:description' => array('value' => '[site:slogan]'),
        );
        break;
// =====================================================================
      case 'node':
// Metatag
//    'title' => array('value' => '[node:title] | [site:name]'),
//    'description' => array('value' => '[node:summary]'),
// Opengraph
//      'og:title' => array('value' => '[node:title]'),
//      'og:description' => array('value' => '[node:summary]'),
// Twitter
//      'twitter:card' => array('value' => 'summary'),
//      'twitter:description' => array('value' => '[node:summary]'),
//      'twitter:title' => array('value' => '[node:title]'),
        $config->config += array(
          'og:image' => array('value' => '[node:field_main_image]'),
          'image_src' => array('value' => '[node:field_main_image]'),
          'twitter:image' => array('value' => '[node:field_main_image]'),
        );
        break;
// =====================================================================
      case 'taxonomy_term':
// Metatag
//    'title' => array('value' => '[term:name] | [site:name]'),
//    'description' => array('value' => '[term:description]'),
// Opengraph
//      'og:title' => array('value' => '[term:name]'),
//      'og:description' => array('value' => '[term:description]'),
// Twitter
//      'twitter:card' => array('value' => 'summary'),
//      'twitter:title'=> array('value' => '[term:name]'),
        $config->config += array(
          'og:image' => array('value' => '[term:field_main_image]'),
          'image_src' => array('value' => '[term:field_main_image]'),
          'twitter:description' => array('value' => '[term:description]'),
          'twitter:image' => array('value' => '[term:field_main_image]'),
        );
        break;
// =====================================================================
      case 'user':
// Metatag
//    'title' => array('value' => '[user:name] | [site:name]'),
// Opengraph
//      'og:type' => array('value' => 'profile'),
//      'og:title' => array('value' => '[user:name]'),
//      'og:image' => array('value' => '[user:picture:url]'),
        break;
// =====================================================================
      case 'view':
// Views
//    'title' => array('value' => '[view:title] | [site:name]'),
//    'description' => array('value' => '[view:description]'),
//    'canonical' => array('value' => '[view:url]'),
        $config->config += array(
          'og:title' => array('value' => '[view:title]'),
          'og:description' => array('value' => '[view:description]'),
          'twitter:title' => array('value' => '[view:title]'),
          'twitter:description' => array('value' => '[view:description]'),
        );
        break;
    }
  }
}
