home | career | drupal | java | mac | mysql | perl | php | scala | uml | unix

Drupal example source code file (optionwidgets.install)

This example Drupal source code file (optionwidgets.install) is included in the DevDaily.com "Drupal Source Code Warehouse" project. The intent of this project is to help you "Learn Drupal by Example".

PHP - Drupal tags/keywords

abort, content, content_instance_tablename, database, function, optionwidgets, php, ret, return, set, update, update_sql, where, widget_type

The optionwidgets.install Drupal example source code

<?php
// $Id: optionwidgets.install,v 1.23.2.7 2008/10/04 13:14:22 karens Exp $

/**
 * @file
 * Implementation of hook_install().
 */
function optionwidgets_install() {
  drupal_load('module', 'content');
  content_notify('install', 'optionwidgets');
}

/**
 * Implementation of hook_uninstall().
 */
function optionwidgets_uninstall() {
  drupal_load('module', 'content');
  content_notify('uninstall', 'optionwidgets');
}

/**
 * Implementation of hook_enable().
 *
 * Notify content module when this module is enabled.
 */
function optionwidgets_enable() {
  drupal_load('module', 'content');
  content_notify('enable', 'optionwidgets');
}

/**
 * Implementation of hook_disable().
 *
 * Notify content module when this module is disabled.
 */
function optionwidgets_disable() {
  drupal_load('module', 'content');
  content_notify('disable', 'optionwidgets');
}

function optionwidgets_update_last_removed() {
  return 1;
}

/**
 * Rename widgets from 'options_xxx' to 'optionwidgets_xxx' so hook_elements
 * and hook_themes items are prefixed with module name as they should be.
 *
 * The change in widget types will keep content_update_6000() from correctly updating
 * the module names in the field and instance tables, so do it here.
 */
function optionwidgets_update_6000() {
  if ($abort = content_check_update('optionwidgets')) {
    return $abort;
  }

  $ret = array();

  drupal_load('module', 'content');
  $ret[] = update_sql("UPDATE {". content_instance_tablename() ."} SET widget_type = 'optionwidgets_select' WHERE widget_type = 'options_select'");
  $ret[] = update_sql("UPDATE {". content_instance_tablename() ."} SET widget_type = 'optionwidgets_onoff' WHERE widget_type = 'options_onoff'");
  $ret[] = update_sql("UPDATE {". content_instance_tablename() ."} SET widget_type = 'optionwidgets_buttons' WHERE widget_type = 'options_buttons'");

  content_associate_fields('optionwidgets');
  return $ret;
}

/**
 * Update 6000 was possibly broken if it was executed while
 * the modules were still disabled, so we re-run it.
 * Having it run a second time on sites that got updated correctly has no
 * side-effect (see http://drupal.org/node/310873).
 */
function optionwidgets_update_6001() {
  return optionwidgets_update_6000();
}

Other Drupal examples (source code examples)

Here is a short list of links related to this Drupal optionwidgets.install source code file:

new blog posts

"Drupal" is a registered trademark of Dries Buytaert.

my drupal tutorials and examples  

Copyright 1998-2016 Alvin Alexander, alvinalexander.com
All Rights Reserved.

Beginning in 2016, a portion of the proceeds from pages under the '/drupal-code-examples/' URI will be donated to charity.