| 1 |
<?php
|
| 2 |
// $Id: iframe.install,v 1.1 2008/08/20 22:36:18 neffets Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_install().
|
| 6 |
*/
|
| 7 |
function iframe_install() {
|
| 8 |
content_notify('install', 'iframe');
|
| 9 |
}
|
| 10 |
|
| 11 |
/**
|
| 12 |
* Implementation of hook_uninstall().
|
| 13 |
*/
|
| 14 |
function iframe_uninstall() {
|
| 15 |
content_notify('uninstall', 'iframe');
|
| 16 |
}
|
| 17 |
|
| 18 |
/**
|
| 19 |
* Implementation of hook_enable().
|
| 20 |
*/
|
| 21 |
function iframe_enable() {
|
| 22 |
content_notify('enable', 'iframe');
|
| 23 |
}
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Implementation of hook_disable().
|
| 27 |
*/
|
| 28 |
function iframe_disable() {
|
| 29 |
content_notify('disable', 'iframe');
|
| 30 |
}
|
| 31 |
|
| 32 |
/**
|
| 33 |
* Removed iframe.module created tables, move data to content.module tables
|
| 34 |
* attributes will contain width,heigth,...
|
| 35 |
*/
|
| 36 |
function iframe_update_1() {
|
| 37 |
$ret = array();
|
| 38 |
|
| 39 |
include_once(drupal_get_path('module', 'content') .'/content.module');
|
| 40 |
include_once(drupal_get_path('module', 'content') .'/includes/content.admin.inc');
|
| 41 |
|
| 42 |
$fields = content_fields();
|
| 43 |
|
| 44 |
if (FALSE) foreach ($fields as $field) {
|
| 45 |
switch ($field['type']) {
|
| 46 |
case 'iframe':
|
| 47 |
$columns = array(
|
| 48 |
'url' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => "''"),
|
| 49 |
'title' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => "''"),
|
| 50 |
'attributes' => array('type' => 'mediumtext', 'not null' => FALSE),
|
| 51 |
'width' => array('type' => 'mediumtext', 'not null' => FALSE),
|
| 52 |
'height' => array('type' => 'mediumtext', 'not null' => FALSE),
|
| 53 |
);
|
| 54 |
/*
|
| 55 |
content_alter_db_field(array(), array(), $field, $columns);
|
| 56 |
*/
|
| 57 |
content_alter_db($columns['url'], $columns['url']);
|
| 58 |
content_alter_db($columns['title'], $columns['title']);
|
| 59 |
content_alter_db($columns['attributes'], $columns['attributes']);
|
| 60 |
content_alter_db($columns['width'], '');
|
| 61 |
content_alter_db($columns['height'], '');
|
| 62 |
|
| 63 |
$db_info = content_database_info($field);
|
| 64 |
if ($field['multiple']) {
|
| 65 |
$ret[] = update_sql('INSERT INTO {'. $db_info['table'] .'} (vid, delta, nid, '.
|
| 66 |
$field['field_name'] .'_url, '.
|
| 67 |
$field['field_name'] .'_title, '.
|
| 68 |
$field['field_name'] ."_attributes) '.
|
| 69 |
'SELECT vid, delta, nid, '.
|
| 70 |
'field_url, '
|
| 71 |
'field_title, '.
|
| 72 |
'attributes FROM {node_field_iframe_data} '.
|
| 73 |
'WHERE field_name = '". $field['field_name'] ."'");
|
| 74 |
}
|
| 75 |
else {
|
| 76 |
$ret[] = update_sql('UPDATE {'. $db_info['table'] .'} c, {node_field_iframe_data} l SET '.
|
| 77 |
'c.'. $field['field_name'] .'_url = l.field_url, '.
|
| 78 |
'c.'. $field['field_name'] .'_title = l.field_title, '.
|
| 79 |
'c.'. $field['field_name'] ."_attributes = l.attributes '.
|
| 80 |
'WHERE l.field_name = '". $field['field_name'] ."' AND c.vid = l.vid AND c.nid = l.nid");
|
| 81 |
}
|
| 82 |
}
|
| 83 |
}
|
| 84 |
|
| 85 |
//$ret[] = update_sql('DROP TABLE {node_field_iframe_data}');
|
| 86 |
$ret[] = update_sql('SELECT 1=1');
|
| 87 |
|
| 88 |
db_query('DELETE FROM {cache}');
|
| 89 |
return $ret;
|
| 90 |
}
|
| 91 |
|
| 92 |
function iframe_update_6010() {
|
| 93 |
$ret = array();
|
| 94 |
|
| 95 |
include_once(drupal_get_path('module', 'content') .'/content.module');
|
| 96 |
include_once(drupal_get_path('module', 'content') .'/includes/content.admin.inc');
|
| 97 |
include_once(drupal_get_path('module', 'content') .'/includes/content.crud.inc');
|
| 98 |
|
| 99 |
/* 1. update the general settings for iframe-field */
|
| 100 |
$fields = content_fields();
|
| 101 |
|
| 102 |
foreach ($fields as $field) {
|
| 103 |
switch ($field['type']) {
|
| 104 |
case 'iframe':
|
| 105 |
$field_name = $field['field_name'];
|
| 106 |
$field['columns']['url']['length'] = 1024;
|
| 107 |
|
| 108 |
content_field_instance_update($field);
|
| 109 |
$ret[] = update_sql('#growing url field to 1024 chars');
|
| 110 |
}
|
| 111 |
}
|
| 112 |
|
| 113 |
db_query('DELETE FROM {cache}');
|
| 114 |
return $ret;
|
| 115 |
}
|
| 116 |
|