1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
64156087
|
Assos Assos
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
85ad3d82
|
Assos Assos
|
/**
|
8 |
|
|
* Implementation of hook_schema().
|
9 |
|
|
*/
|
10 |
|
|
function panels_mini_schema() {
|
11 |
|
|
// This should always point to our 'current' schema. This makes it relatively easy
|
12 |
|
|
// to keep a record of schema as we make changes to it.
|
13 |
|
|
return panels_mini_schema_1();
|
14 |
|
|
}
|
15 |
|
|
|
16 |
|
|
/**
|
17 |
|
|
* Schema version 1 for Panels in D6.
|
18 |
|
|
*/
|
19 |
|
|
function panels_mini_schema_1() {
|
20 |
|
|
$schema = array();
|
21 |
|
|
|
22 |
|
|
$schema['panels_mini'] = array(
|
23 |
|
|
'export' => array(
|
24 |
|
|
'identifier' => 'mini',
|
25 |
|
|
'load callback' => 'panels_mini_load',
|
26 |
|
|
'load all callback' => 'panels_mini_load_all',
|
27 |
|
|
'save callback' => 'panels_mini_save',
|
28 |
|
|
'delete callback' => 'panels_mini_delete',
|
29 |
|
|
'export callback' => 'panels_mini_export',
|
30 |
|
|
'api' => array(
|
31 |
|
|
'owner' => 'panels_mini',
|
32 |
|
|
'api' => 'panels_default',
|
33 |
|
|
'minimum_version' => 1,
|
34 |
|
|
'current_version' => 1,
|
35 |
|
|
),
|
36 |
|
|
),
|
37 |
|
|
'fields' => array(
|
38 |
|
|
'pid' => array(
|
39 |
|
|
'type' => 'serial',
|
40 |
|
|
'not null' => TRUE,
|
41 |
|
|
'no export' => TRUE,
|
42 |
|
|
'description' => 'The primary key for uniqueness.',
|
43 |
|
|
),
|
44 |
|
|
'name' => array(
|
45 |
|
|
'type' => 'varchar',
|
46 |
|
|
'length' => '255',
|
47 |
|
|
'description' => 'The unique name of the mini panel.',
|
48 |
|
|
),
|
49 |
|
|
'category' => array(
|
50 |
|
|
'type' => 'varchar',
|
51 |
|
|
'length' => '64',
|
52 |
|
|
'description' => 'The category this mini panel appears in on the add content pane.',
|
53 |
|
|
),
|
54 |
|
|
'did' => array(
|
55 |
|
|
'type' => 'int',
|
56 |
|
|
'no export' => TRUE,
|
57 |
|
|
'description' => 'The display ID of the panel.',
|
58 |
|
|
),
|
59 |
|
|
'admin_title' => array(
|
60 |
|
|
'type' => 'varchar',
|
61 |
|
|
'length' => '128',
|
62 |
|
|
'description' => 'The administrative title of the mini panel.',
|
63 |
|
|
),
|
64 |
|
|
'admin_description' => array(
|
65 |
|
|
'type' => 'text',
|
66 |
|
|
'size' => 'big',
|
67 |
|
|
'description' => 'Administrative title of this mini panel.',
|
68 |
|
|
'object default' => '',
|
69 |
|
|
),
|
70 |
|
|
'requiredcontexts' => array(
|
71 |
|
|
'type' => 'text',
|
72 |
|
|
'size' => 'big',
|
73 |
|
|
'serialize' => TRUE,
|
74 |
|
|
'object default' => array(),
|
75 |
|
|
'description' => 'An array of required contexts.',
|
76 |
|
|
),
|
77 |
|
|
'contexts' => array(
|
78 |
|
|
'type' => 'text',
|
79 |
|
|
'size' => 'big',
|
80 |
|
|
'serialize' => TRUE,
|
81 |
|
|
'object default' => array(),
|
82 |
|
|
'description' => 'An array of contexts embedded into the panel.',
|
83 |
|
|
),
|
84 |
|
|
'relationships' => array(
|
85 |
|
|
'type' => 'text',
|
86 |
|
|
'size' => 'big',
|
87 |
|
|
'serialize' => TRUE,
|
88 |
|
|
'object default' => array(),
|
89 |
|
|
'description' => 'An array of relationships embedded into the panel.',
|
90 |
|
|
),
|
91 |
|
|
),
|
92 |
|
|
'primary key' => array('pid'),
|
93 |
|
|
'unique keys' => array(
|
94 |
|
|
'name' => array('name'),
|
95 |
|
|
),
|
96 |
|
|
);
|
97 |
|
|
|
98 |
|
|
return $schema;
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
/**
|
102 |
|
|
* Implementation of hook_uninstall().
|
103 |
|
|
*/
|
104 |
|
|
function panels_mini_uninstall() {
|
105 |
|
|
$panels_exists = db_table_exists('panels_display');
|
106 |
|
|
|
107 |
|
|
$result = db_query("SELECT * FROM {panels_mini}");
|
108 |
|
|
$deltas = array();
|
109 |
|
|
foreach ($result as $panel_mini) {
|
110 |
|
|
// Delete all associated displays.
|
111 |
|
|
if (!function_exists('panels_delete_display')) {
|
112 |
64156087
|
Assos Assos
|
require_once drupal_get_path('module', 'panels') . '/panels.module';
|
113 |
85ad3d82
|
Assos Assos
|
}
|
114 |
|
|
if ($panels_exists) {
|
115 |
|
|
panels_delete_display($panel_mini->did);
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
$deltas[] = $panel_mini->pid;
|
119 |
|
|
}
|
120 |
|
|
|
121 |
136a805a
|
Assos Assos
|
if (db_table_exists('block') && $deltas) {
|
122 |
85ad3d82
|
Assos Assos
|
// Delete all configured blocks.
|
123 |
|
|
db_delete('block')
|
124 |
|
|
->condition('module', 'panels_mini')
|
125 |
|
|
->condition('delta', $deltas)
|
126 |
|
|
->execute();
|
127 |
|
|
}
|
128 |
|
|
}
|
129 |
136a805a
|
Assos Assos
|
|
130 |
|
|
/**
|
131 |
|
|
* Implements hook_update_dependencies().
|
132 |
|
|
*/
|
133 |
|
|
function panels_mini_update_dependencies() {
|
134 |
64156087
|
Assos Assos
|
// Update 7301 requires panels storage support.
|
135 |
136a805a
|
Assos Assos
|
$dependencies['panels_mini'][7301] = array(
|
136 |
|
|
'panels' => 7305,
|
137 |
|
|
);
|
138 |
|
|
|
139 |
|
|
return $dependencies;
|
140 |
|
|
}
|
141 |
|
|
|
142 |
|
|
/**
|
143 |
|
|
* Set the storage type and id on existing mini panels.
|
144 |
|
|
*/
|
145 |
|
|
function panels_mini_update_7301() {
|
146 |
|
|
if (!isset($sandbox['progress'])) {
|
147 |
64156087
|
Assos Assos
|
// Initialize batch update information.
|
148 |
|
|
$sandbox['progress'] = (float) 0;
|
149 |
|
|
$sandbox['current_did'] = -1;
|
150 |
|
|
$sandbox['max'] = db_query("SELECT COUNT(pd.did)
|
151 |
136a805a
|
Assos Assos
|
FROM {panels_display} pd
|
152 |
|
|
JOIN {panels_mini} pm ON pm.did = pd.did
|
153 |
|
|
WHERE pd.storage_type = ''")->fetchField();
|
154 |
64156087
|
Assos Assos
|
}
|
155 |
136a805a
|
Assos Assos
|
|
156 |
|
|
// Set a limit of how many rows to process per batch.
|
157 |
|
|
$limit = 1000;
|
158 |
|
|
|
159 |
64156087
|
Assos Assos
|
// Run the query.
|
160 |
136a805a
|
Assos Assos
|
$result = db_query_range("SELECT pd.did, pm.name
|
161 |
|
|
FROM {panels_display} pd
|
162 |
|
|
JOIN {panels_mini} pm ON pm.did = pd.did
|
163 |
|
|
WHERE pd.storage_type = '' AND pd.did > :current_did", 0, $limit, array(':current_did' => $sandbox['current_did']));
|
164 |
|
|
|
165 |
|
|
foreach ($result as $row) {
|
166 |
|
|
db_update('panels_display')
|
167 |
|
|
->fields(array(
|
168 |
|
|
'storage_type' => 'panels_mini',
|
169 |
|
|
'storage_id' => $row->name,
|
170 |
|
|
))
|
171 |
|
|
->condition('did', $row->did)
|
172 |
|
|
->execute();
|
173 |
|
|
|
174 |
|
|
// Update our progress information.
|
175 |
|
|
$sandbox['progress']++;
|
176 |
|
|
$sandbox['current_did'] = $row->did;
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
// Set the "finished" status, to tell batch engine whether this function
|
180 |
|
|
// needs to run again.
|
181 |
|
|
$sandbox['#finished'] = ($sandbox['progress'] >= $sandbox['max']) ? TRUE : ($sandbox['progress'] / $sandbox['max']);
|
182 |
|
|
|
183 |
|
|
if ($sandbox['#finished']) {
|
184 |
|
|
return t('Added the storage type for panels_mini to relevant panels displays');
|
185 |
|
|
}
|
186 |
|
|
} |