You are here

opengraph_meta.install in Open Graph meta tags 6

Same filename and directory in other branches
  1. 7.2 opengraph_meta.install
  2. 7 opengraph_meta.install

File

opengraph_meta.install
View source
<?php

require_once 'opengraph_meta.common.inc';

/**
 * Add the 'type' meta tag field to the meta tags table.
 * @see http://drupal.org/node/975350
 */
function opengraph_meta_update_6001() {
  $result = array();
  db_add_field($result, OPENGRAPH_META_TABLE, OpenGraphMeta::TYPE, array(
    'type' => 'varchar',
    'length' => '255',
    'not null' => TRUE,
    'default' => '',
  ));
  return $result;
}

/**
 * Add an 'optional_tags' field for additional tags.
 * @see http://drupal.org/node/983512
 */
function opengraph_meta_update_6002() {
  $result = array();
  db_add_field($result, OPENGRAPH_META_TABLE, OpenGraphMeta::__OPTIONAL_DB_FIELD, array(
    'type' => 'text',
    'not null' => FALSE,
    'serialize' => TRUE,
  ));
  return $result;
}
function opengraph_meta_schema() {
  $schema[OPENGRAPH_META_TABLE] = array(
    'description' => 'Stores Open Graph meta tag info useful for when sharing nodes on social networking sites, e.g. Facebook.',
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      OpenGraphMeta::TITLE => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      OpenGraphMeta::DESCRIPTION => array(
        'type' => 'text',
        'not null' => TRUE,
        'size' => 'big',
      ),
      OpenGraphMeta::IMAGE => array(
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      OpenGraphMeta::TYPE => array(
        'type' => 'varchar',
        'length' => '255',
        'not null' => TRUE,
        'default' => '',
      ),
      OpenGraphMeta::__OPTIONAL_DB_FIELD => array(
        'type' => 'text',
        'not null' => FALSE,
        'serialize' => TRUE,
      ),
    ),
    'primary key' => array(
      'nid',
    ),
  );
  return $schema;
}
function opengraph_meta_install() {
  drupal_install_schema('opengraph_meta');
}
function opengraph_meta_uninstall() {
  drupal_uninstall_schema('opengraph_meta');
  variable_del(OPENGRAPH_META_VAR_CONTENT_TYPES_ENABLED);
  variable_del(OPENGRAPH_META_VAR_SITE_NAME);
  variable_del(OPENGRAPH_META_VAR_FALLBACK_IMG);
  variable_del(OPENGRAPH_META_VAR_OPTIONAL_TAGS);
  $types = node_get_types();
  foreach ($types as $id => $d) {
    variable_del(OPENGRAPH_META_VAR_CONTENT_TYPE_ . $id);
    variable_del(OPENGRAPH_META_VAR_CONTENT_TYPE_CCK_ . $id);
  }
}

Functions

Namesort descending Description
opengraph_meta_install
opengraph_meta_schema
opengraph_meta_uninstall
opengraph_meta_update_6001 Add the 'type' meta tag field to the meta tags table.
opengraph_meta_update_6002 Add an 'optional_tags' field for additional tags.