source: sipes/modules_contrib/panels/panels.install @ 4f375e3

stableversion-3.0
Last change on this file since 4f375e3 was 4f375e3, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el modulo panels

  • Propiedad mode establecida a 100644
File size: 48.0 KB
Línea 
1<?php
2
3/**
4 * Test requirements for installation and running.
5 */
6function panels_requirements($phase) {
7  $function = "panels_requirements_$phase";
8  return function_exists($function) ? $function() : array();
9}
10
11/**
12 * Check install-time requirements.
13 */
14function panels_requirements_install() {
15  $requirements = array();
16  $t = get_t();
17  // Assume that if the user is running an installation profile that both
18  // Panels and CTools are the same release.
19  if (!(defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install')) {
20    // apparently the install process doesn't include .module files,
21    // so we need to force the issue in order for our versioning
22    // check to work.
23    if (!defined('PANELS_REQUIRED_CTOOLS_API')) {
24      include_once drupal_get_path('module', 'panels') . '/panels.module';
25    }
26
27    // In theory we should check module_exists, but Drupal's gating should
28    // actually prevent us from getting here otherwise.
29    if (!defined('CTOOLS_API_VERSION')) {
30      include_once drupal_get_path('module', 'ctools') . '/ctools.module';
31    }
32    if (!module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) {
33       $requirements['panels_ctools'] = array(
34         'title' => $t('CTools API Version'),
35         'value' => CTOOLS_API_VERSION,
36         'severity' => REQUIREMENT_ERROR,
37         'description' => t('The CTools API version is too old for Panels. Panels needs at least %version.', array('%version' => PANELS_REQUIRED_CTOOLS_API))
38       );
39    }
40  }
41  return $requirements;
42}
43
44/**
45 * Check runtime requirements (status report).
46 */
47function panels_requirements_runtime() {
48  $requirements = array();
49  $legacy = panels_get_legacy_state();
50  $t = get_t();
51  $state = $legacy->getStatus();
52  if (empty($state)) {
53    $requirements['panels_legacy'] = array(
54      'title' => $t('Panels operating normally'),
55      'value' => NULL,
56      'severity' => REQUIREMENT_OK,
57      'description' => $t('Panels is operating normally - no out-of-date plugins or modules are forcing it into legacy mode'),
58    );
59  }
60  else {
61    $description = $t("Panels is operating in Legacy mode due to the following issues:\n");
62
63    // Add the reasons why Panels is acting in legacy mode.
64    $list = array();
65    foreach ($state as $values) {
66      $modules = array();
67      foreach ($values['modules'] as $module => $type) {
68        $modules[] = array('data' => check_plain($module) . ' - ' . $type);
69      }
70
71      $list[] = array('data' => $values['explanation'] ."\n" . theme('item_list', $modules));
72    }
73
74    $description .= theme('item_list', $list);
75
76    $requirements['panels_legacy'] = array(
77      'title' => $t('Panels operating in Legacy mode'),
78      'value' => NULL,
79      'severity' => REQUIREMENT_WARNING,
80      'description' => $description,
81    );
82  }
83  return $requirements;
84}
85
86/**
87 * Implementation of hook_schema().
88 */
89function panels_schema() {
90  // This should always point to our 'current' schema. This makes it relatively easy
91  // to keep a record of schema as we make changes to it.
92  return panels_schema_3();
93}
94
95/**
96 * Schema that adds the panels_layout table.
97 */
98function panels_schema_3() {
99  // Schema 3 is now locked. If you need to make changes, please create
100  // schema 4 and add them.
101  $schema = panels_schema_2();
102
103  $schema['panels_renderer_pipeline'] = array(
104    'description' => 'Contains renderer pipelines for Panels. Each pipeline contains one or more renderers and access rules to select which renderer gets used.',
105    'export' => array(
106      'identifier' => 'pipeline',
107      'bulk export' => TRUE,
108      'primary key' => 'rpid',
109      'api' => array(
110        'owner' => 'panels',
111        'api' => 'pipelines',
112        'minimum_version' => 1,
113        'current_version' => 1,
114      ),
115    ),
116    'fields' => array(
117      'rpid' => array(
118        'type' => 'serial',
119        'description' => 'A database primary key to ensure uniqueness.',
120        'not null' => TRUE,
121        'no export' => TRUE,
122      ),
123      'name' => array(
124        'type' => 'varchar',
125        'length' => '255',
126        'description' => 'Unique ID for this content. Used to identify it programmatically.',
127      ),
128      'admin_title' => array(
129        'type' => 'varchar',
130        'length' => '255',
131        'description' => 'Administrative title for this pipeline.',
132      ),
133      'admin_description' => array(
134        'type' => 'text',
135        'size' => 'big',
136        'description' => 'Administrative description for this pipeline.',
137        'object default' => '',
138      ),
139      'weight' => array(
140        'type' => 'int',
141        'size' => 'small',
142        'default' => 0,
143      ),
144      'settings' => array(
145        'type' => 'text',
146        'size' => 'big',
147        'description' => 'Serialized settings for the actual pipeline. The contents of this field are up to the plugin that uses it.',
148        'serialize' => TRUE,
149        'object default' => array(),
150      ),
151    ),
152    'primary key' => array('rpid'),
153  );
154
155  $schema['panels_layout'] = array(
156    'description' => 'Contains exportable customized layouts for this site.',
157    'export' => array(
158      'identifier' => 'layout',
159      'bulk export' => TRUE,
160      'primary key' => 'lid',
161      'api' => array(
162        'owner' => 'panels',
163        'api' => 'layouts',
164        'minimum_version' => 1,
165        'current_version' => 1,
166      ),
167    ),
168    'fields' => array(
169      'lid' => array(
170        'type' => 'serial',
171        'description' => 'A database primary key to ensure uniqueness.',
172        'not null' => TRUE,
173        'no export' => TRUE,
174      ),
175      'name' => array(
176        'type' => 'varchar',
177        'length' => '255',
178        'description' => 'Unique ID for this content. Used to identify it programmatically.',
179      ),
180      'admin_title' => array(
181        'type' => 'varchar',
182        'length' => '255',
183        'description' => 'Administrative title for this layout.',
184      ),
185      'admin_description' => array(
186        'type' => 'text',
187        'size' => 'big',
188        'description' => 'Administrative description for this layout.',
189        'object default' => '',
190      ),
191      'category' => array(
192        'type' => 'varchar',
193        'length' => '255',
194        'description' => 'Administrative category for this layout.',
195      ),
196      'plugin' => array(
197        'type' => 'varchar',
198        'length' => '255',
199        'description' => 'The layout plugin that owns this layout.',
200      ),
201      'settings' => array(
202        'type' => 'text',
203        'size' => 'big',
204        'description' => 'Serialized settings for the actual layout. The contents of this field are up to the plugin that uses it.',
205        'serialize' => TRUE,
206        'object default' => array(),
207      ),
208    ),
209    'primary key' => array('lid'),
210  );
211
212  $schema['cache_panels'] = drupal_get_schema_unprocessed('system', 'cache');
213
214  return $schema;
215}
216
217/**
218 * Schema that adds the title_pane field.
219 */
220function panels_schema_2() {
221  $schema = panels_schema_1();
222
223  $schema['panels_display']['fields']['title_pane'] = array(
224    'type' => 'int',
225    'default' => 0,
226    'no export' => TRUE,
227  );
228
229  return $schema;
230}
231
232/**
233 * Schema version 1 for Panels in D6.
234 *
235 * Schema v1 is now LOCKED; any changes should be done via panels_schema_2.
236 */
237function panels_schema_1() {
238  $schema = array();
239
240  $schema['panels_display'] = array(
241    'export' => array(
242      'object' => 'panels_display',
243      'bulk export' => FALSE,
244      'export callback' => 'panels_export_display',
245      'can disable' => FALSE,
246      'identifier' => 'display',
247    ),
248    'fields' => array(
249      'did' => array(
250        'type' => 'serial',
251        'not null' => TRUE,
252        'no export' => TRUE,
253      ),
254      'layout' => array(
255        'type' => 'varchar',
256        'length' => '255',
257        'default' => '',
258      ),
259      'layout_settings' => array(
260        'type' => 'text',
261        'size' => 'big',
262        'serialize' => TRUE,
263        'object default' => array(),
264        'initial ' => array(),
265      ),
266      'panel_settings' => array(
267        'type' => 'text',
268        'size' => 'big',
269        'serialize' => TRUE,
270        'object default' => array(),
271        'initial ' => array(),
272      ),
273      'cache' => array(
274        'type' => 'text',
275        'serialize' => TRUE,
276        'object default' => array(),
277        'initial ' => array(),
278      ),
279      'title' => array(
280        'type' => 'varchar',
281        'length' => '255',
282        'default' => '',
283      ),
284      'hide_title' => array(
285        'type' => 'int',
286        'size' => 'tiny',
287        'default' => 0,
288        'no export' => TRUE,
289      ),
290    ),
291    'primary key' => array('did'),
292  );
293
294  $schema['panels_pane'] = array(
295    'export' => array(
296      'can disable' => FALSE,
297      'identifier' => 'pane',
298      'bulk export' => FALSE,
299    ),
300    'fields' => array(
301      'pid' => array(
302        'type' => 'serial',
303        'not null' => TRUE,
304      ),
305      'did' => array(
306        'type' => 'int',
307        'not null' => TRUE,
308        'default' => 0,
309        'no export' => TRUE,
310      ),
311      'panel' => array(
312        'type' => 'varchar',
313        'length' => '32',
314        'default' => '',
315      ),
316      'type' => array(
317        'type' => 'varchar',
318        'length' => '32',
319        'default' => '',
320      ),
321      'subtype' => array(
322        'type' => 'varchar',
323        'length' => '64',
324        'default' => '',
325      ),
326      'shown' => array(
327        'type' => 'int',
328        'size' => 'tiny',
329        'default' => 1,
330      ),
331      'access' => array(
332        'type' => 'text',
333        'size' => 'big',
334        'serialize' => TRUE,
335        'object default' => array(),
336        'initial ' => array(),
337      ),
338      'configuration' => array(
339        'type' => 'text',
340        'size' => 'big',
341        'serialize' => TRUE,
342        'object default' => array(),
343        'initial ' => array(),
344      ),
345      'cache' => array(
346        'type' => 'text',
347        'size' => 'big',
348        'serialize' => TRUE,
349        'object default' => array(),
350        'initial ' => array(),
351      ),
352      'style' => array(
353        'type' => 'text',
354        'size' => 'big',
355        'serialize' => TRUE,
356        'object default' => array(),
357        'initial ' => array(),
358      ),
359      'css' => array(
360        'type' => 'text',
361        'size' => 'big',
362        'serialize' => TRUE,
363        'object default' => array(),
364        'initial ' => array(),
365      ),
366      'extras' => array(
367        'type' => 'text',
368        'size' => 'big',
369        'serialize' => TRUE,
370        'object default' => array(),
371        'initial ' => array(),
372      ),
373      'position' => array(
374        'type' => 'int',
375        'size' => 'small',
376        'default' => 0,
377      ),
378    ),
379    'primary key' => array('pid'),
380    'indexes' => array(
381      'did_idx' => array('did')
382    ),
383  );
384
385  return $schema;
386}
387
388/**
389 * Implementation of hook_install().
390 */
391function panels_install() {
392  drupal_install_schema('panels');
393}
394
395/**
396 * Implementation of hook_uninstall().
397 */
398function panels_uninstall() {
399  drupal_uninstall_schema('panels');
400}
401
402function panels_update_1000() {
403  // Panels D6 2 had *no* update functions in it, so the schema version is
404  // completely wrong. If we run this update with no schema version, we
405  // were actually that version and we must therefore skip to the proper
406  // update.
407  if (db_table_exists('panels_pane')) {
408    $GLOBALS['SKIP_PANELS_UPDATES'] = TRUE;
409    return array();
410  }
411  $ret   = array();
412
413  $ret[] = update_sql("ALTER TABLE {panels_info} RENAME {panels_page}");
414  $ret[] = update_sql("ALTER TABLE {panels_page} CHANGE COLUMN did pid int(10) NOT NULL DEFAULT 0;");
415  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN did int(10) NOT NULL DEFAULT 0 AFTER pid");
416  $ret[] = update_sql("UPDATE {panels_page} SET did = pid");
417
418  $max_pid = db_result(db_query("SELECT MAX(pid) FROM {panels_page}"));
419  if ($max_pid) {
420    $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_page}_pid', $max_pid)");
421  }
422
423  $ret[]  = update_sql("ALTER TABLE {panels_area} RENAME {panels_pane}");
424  $ret[]  = update_sql("ALTER TABLE {panels_pane} ADD COLUMN pid int(10) NOT NULL DEFAULT 0 FIRST");
425  $ret[]  = update_sql("ALTER TABLE {panels_pane} CHANGE area panel varchar(32)");
426  $result = db_query("SELECT * FROM {panels_pane}");
427  while ($pane = db_fetch_object($result)) {
428    $count++;
429    $ret[] = update_sql("UPDATE {panels_pane} SET pid = $count WHERE did = $pane->did AND panel = '$pane->panel' AND position = $pane->position");
430  }
431  if ($count) {
432    $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_pane}_pid', $count)");
433  }
434
435  $ret[] = update_sql(<<<EOT
436    CREATE TABLE {panels_display} (
437      did INT(10) NOT NULL DEFAULT 0 PRIMARY KEY,
438      layout VARCHAR(32)
439    ) /*!40100 DEFAULT CHARACTER SET utf8 */
440EOT
441  );
442  $result = db_query("SELECT did, layout FROM {panels_page}");
443  $max_did = 0;
444  while ($display = db_fetch_object($result)) {
445    $ret[] = update_sql("INSERT INTO {panels_display} VALUES ($display->did, '$display->layout')");
446    if ($display->did > $max_did) {
447      $max_did = $display->did;
448    }
449  }
450  $ret[] = update_sql("ALTER TABLE {panels_page} DROP COLUMN layout");
451  if ($max_did) {
452    $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_display}_did', $max_did)");
453  }
454  return $ret;
455}
456
457function panels_update_1001() {
458  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
459    return array();
460  }
461  $ret   = array();
462  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN no_blocks int(1)");
463  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu int(1) DEFAULT 0");
464  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab int(1)");
465  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab_weight int(4)");
466  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_title varchar(255)");
467  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab_default int(1)");
468  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_tab_default_parent_type varchar(10)");
469  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_parent_title varchar(255)");
470  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN menu_parent_tab_weight int(4)");
471  return $ret;
472}
473
474// Create a field for the layout settings
475function panels_update_1002() {
476  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
477    return array();
478  }
479  $ret   = array();
480  $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN layout_settings longtext");
481  $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN access varchar(128) AFTER type");
482  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN css longtext AFTER css_id");
483  return $ret;
484}
485
486// Create a field for the panel settings.
487function panels_update_1003() {
488  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
489    return array();
490  }
491  $ret = array();
492  $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN panel_settings longtext");
493  return $ret;
494}
495
496// Kept up updates from older versions of Panels 2 for D5 to smooth updates.
497// Create a field for the panel settings.
498// Renumbering to proper numbering scheme.
499function panels_update_5204() {
500  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
501    return array();
502  }
503  $ret   = array();
504  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN name varchar(255) UNIQUE");
505  $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN name varchar(255) UNIQUE");
506  // Give all our panels a name.
507  $ret[] = update_sql("UPDATE {panels_page} SET name = CONCAT('panel_page_', pid)");
508  $ret[] = update_sql("UPDATE {panels_display} SET name = CONCAT('display_', did)");
509  return $ret;
510}
511
512// Add the arguments field
513function panels_update_5205() {
514  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
515    return array();
516  }
517  $ret = array();
518  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN arguments longtext");
519  return $ret;
520}
521
522// Add a field so that panes can remember their subtype so we can retrieve
523// context information about it.
524function panels_update_5206() {
525  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
526    return array();
527  }
528  $ret = array();
529  $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN subtype varchar(64)");
530  return $ret;
531}
532
533// Add fields for displays and extra contexts
534function panels_update_5207() {
535  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
536    return array();
537  }
538  $ret   = array();
539  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN displays longtext");
540  $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN contexts longtext");
541  return $ret;
542}
543
544// Correct the mistaken {panels_display}_id when it should be {panels_display}_did
545function panels_update_5208() {
546  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
547    return array();
548  }
549  $ret   = array();
550  $count = db_result(db_query("SELECT MAX(did) FROM {panels_display}"));
551  $ret[] = update_sql("DELETE FROM {sequences} WHERE name = '{panels_display}_did'");
552  $ret[] = update_sql("DELETE FROM {sequences} WHERE name = '{panels_display}_id'");
553  if ($count) {
554    $ret[] = update_sql("INSERT INTO {sequences} (name, id) VALUES ('{panels_display}_did',
555    $count)");
556  }
557
558  return $ret;
559}
560
561// Update argument, relationship and context code to be more correct.
562function panels_update_5209() {
563  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
564    return array();
565  }
566  $ret    = array();
567  $ret[]  = update_sql("ALTER TABLE {panels_page} ADD COLUMN relationships longtext");
568  $result = db_query("SELECT * FROM {panels_page}");
569
570  // This code removed due to call to panels_get_argument(). People with
571  // older versions will just have to suffer.
572  return $ret;
573  ctools_include('plugins', 'panels');
574
575  while ($page = db_fetch_object($result)) {
576    $args = unserialize($page->arguments);
577    $arguments = $ids = $keywords = array();
578    if (!empty($args)) {
579      // Update each argument
580      foreach ($args as $id => $argument) {
581        $name = $argument['name'];
582        $info = panels_get_argument($name);
583        if (!$info) {
584          continue;
585        }
586        // Make sure the id is valid
587        if (empty($argument['id'])) {
588          if (empty($ids[$name])) {
589            $ids[$name] = 1;
590          }
591          else {
592            $ids[$name]++;
593          }
594
595          $argument['id'] = $ids[$name];
596        }
597
598        // Give it an identifier if it doesn't already have one
599        if (empty($argument['identifier'])) {
600          $argument['identifier'] = $info['title'] . ($id > 1 ? ' ' . $id : '');
601        }
602
603        // Give it a unique keyword if it doesn't already have one
604        if (empty($argument['keyword'])) {
605          $keyword = $base = $info['keyword'];
606          $count = 0;
607          while (!empty($keywords[$keyword])) {
608            $keyword = $base . '_' . ++$count;
609          }
610          $keywords[$keyword] = TRUE;
611          $argument['keyword'] = $keyword;
612        }
613        $arguments[$id] = $argument;
614      }
615    }
616    // Move old relationships (stored as contexts) to relationships, where
617    // the belong
618    $rels = unserialize($page->contexts);
619    // Not resetting $keywords!
620    $relationships = $ids = array();
621    if (!empty($rels)) {
622      foreach ($rels as $id => $relationship) {
623        $name = $relationship['name'];
624        $info = panels_get_relationship($name);
625        if (!$info) {
626          continue;
627        }
628        // Make sure the id is valid
629        if (empty($relationship['id'])) {
630          if (empty($ids[$name])) {
631            $ids[$name] = 1;
632          }
633          else {
634            $ids[$name]++;
635          }
636
637          $relationship['id'] = $ids[$name];
638        }
639
640        // Give it an identifier if it doesn't already have one
641        if (empty($relationship['identifier'])) {
642          $relationship['identifier'] = $info['title'] . ($id > 1 ? ' ' . $id : '');
643        }
644
645        // Give it a unique keyword if it doesn't already have one
646        if (empty($relationship['keyword'])) {
647          $keyword = $base = $info['keyword'];
648          $count = 0;
649          while (!empty($keywords[$keyword])) {
650            $keyword = $base . '_' . ++$count;
651          }
652          $keywords[$keyword] = TRUE;
653          $relationship['keyword'] = $keyword;
654        }
655        $relationships[$id] = $relationship;
656      }
657    }
658    db_query("UPDATE {panels_page} " .
659      "SET arguments = '%s', " .
660      "relationships = '%s', " .
661      "contexts = '%s' " .
662      "WHERE pid = $page->pid", serialize($arguments), serialize($relationships), serialize(array()), $page->pid
663    );
664  }
665  return $ret;
666}
667
668function panels_update_5210() {
669  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
670    return array();
671  }
672  $ret = array();
673  $ret[] = update_sql("UPDATE {system} SET weight = 10 WHERE name = 'panels'");
674  return $ret;
675}
676
677/**
678 * Force a menu update
679 */
680function panels_update_5211() {
681//  menu_rebuild();
682  return array();
683}
684
685/**
686 * Add a field to store pane caching information.
687 */
688function panels_update_5213() {
689  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
690    return array();
691  }
692  $ret = array();
693  switch ($GLOBALS['db_type']) {
694    case 'mysql':
695    case 'mysqli':
696      $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN cache longtext AFTER configuration");
697      $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN cache longtext AFTER panel_settings");
698      break;
699
700    case 'pgsql':
701      db_add_column($ret, 'panels_pane', 'cache', 'text');
702      db_add_column($ret, 'panels_display', 'cache', 'text');
703  }
704  return $ret;
705}
706
707/**
708 * Create a new table for object caching. This isn't part of the cache
709 * system.
710 */
711function panels_update_5214() {
712  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
713    return array();
714  }
715  $ret = array();
716  return $ret;
717  switch ($GLOBALS['db_type']) {
718    case 'mysql':
719    case 'mysqli':
720      $ret[] = update_sql(<<<EOT
721        CREATE TABLE {panels_object_cache} (
722          sid varchar(64),
723          did integer,
724          obj varchar(255),
725          timestamp integer,
726          data text,
727          KEY (sid, obj, did),
728          KEY (timestamp)
729        ) /*!40100 DEFAULT CHARACTER SET utf8 */
730EOT
731      );
732    case 'pgsql':
733  }
734  return !empty($ret) ? $ret : $ret;
735}
736
737/**
738 * Increase the size of the data column in the {panels_object_cache} table
739 * on MySQL.
740 *
741 * Also gets rid of some duplicate indexes resulting the CREATE TABLE queries
742 * in the install() of schema 5214
743 */
744function panels_update_5215() {
745  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
746    return array();
747  }
748  $ret = array();
749  switch ($GLOBALS['db_type']) {
750    case 'mysql':
751    case 'mysqli':
752      $ret[] = update_sql("ALTER TABLE {panels_pane} ADD PRIMARY KEY (pid)");
753      break;
754
755    case 'pgsql':
756      $ret[] = update_sql("ALTER TABLE {panels_pane} ADD PRIMARY KEY (pid)");
757  }
758  return $ret;
759}
760
761/**
762 * Adds the 'shown' field to the panels_pane table in order to accomodate
763 * the new show/hide panes feature.
764 */
765function panels_update_5216() {
766  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
767    return array();
768  }
769  $ret = array();
770  switch ($GLOBALS['db_type']) {
771    case 'mysql':
772    case 'mysqli':
773      $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN shown int(1) DEFAULT 1 AFTER subtype");
774      $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN title varchar(128) AFTER cache");
775      $ret[] = update_sql("ALTER TABLE {panels_display} ADD COLUMN hide_title int(1) AFTER title");
776      $ret[] = update_sql("ALTER TABLE {panels_display} DROP COLUMN name");
777      $ret[] = update_sql("ALTER TABLE {panels_pane} ADD COLUMN visibility text AFTER access");
778      break;
779
780    case 'pgsql':
781      db_add_column($ret, 'panels_pane', 'shown', 'tinyint', array('default' => 1));
782      db_add_column($ret, 'panels_display', 'title', 'varchar(128)');
783      db_add_column($ret, 'panels_display', 'hide_title', 'tinyint', array('default' => 0));
784      $ret = update_sql("ALTER TABLE {panels_display} DROP name");
785      db_add_column($ret, 'panels_pane', 'visibility', 'text');
786  }
787  return $ret;
788}
789
790/**
791 * Add the switcher fields to the database
792 */
793function panels_update_5217() {
794  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
795    return array();
796  }
797  $ret = array();
798  switch ($GLOBALS['db_type']) {
799    case 'mysql':
800    case 'mysqli':
801      $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN switcher_type varchar(128) AFTER no_blocks");
802      $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN switcher_name varchar(128) AFTER no_blocks");
803      $ret[] = update_sql("ALTER TABLE {panels_page} ADD COLUMN switcher_options longtext AFTER switcher_type");
804      break;
805
806    case 'pgsql':
807      db_add_column($ret, 'panels_page', 'switcher_type', 'varchar(128)');
808      db_add_column($ret, 'panels_page', 'switcher_name', 'varchar(128)');
809      db_add_column($ret, 'panels_page', 'switcher_options', 'text');
810  }
811  return $ret;
812}
813
814
815/**
816 * Oversight in 5216: 'tinyint' is not a field type in pgsql; the type we wanted
817 * was 'smallint.'
818 */
819function panels_update_5218() {
820  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
821    return array();
822  }
823  $ret = array();
824  switch ($GLOBALS['db_type']) {
825    case 'mysql':
826    case 'mysqli':
827      $ret[] = array('success' => TRUE, 'query' => t('Update #5218 only has changes for PostgreSQL. There are no updates for MySQL databases - since you\'re running MySQL, you should consider this update successful.'));
828      break;
829
830    case 'pgsql':
831      db_add_column($ret, 'panels_pane', 'shown', 'smallint', array('default' => 1));
832      db_add_column($ret, 'panels_display', 'hide_title', 'smallint', array('default' => 0));
833      $ret[] = array('success' => TRUE, 'query' => t('You can disregard failed attempts to add new columns in update #5216 as long as the two queries preceding this text were successful.'));
834  }
835  return $ret;
836}
837
838/**
839 * Update from 5.x v2
840 */
841function panels_update_5299() {
842  if (!empty($GLOBALS['SKIP_PANELS_UPDATES'])) {
843    return array();
844  }
845  $ret = array();
846  // Fetch schema version 1.
847  $schema = panels_schema_1();
848
849  // Certain really old versions of Panels had errors that would cause invalid
850  // panes to be written. This wipes them so that the conversion won't fail:
851  $ret[] = update_sql("DELETE FROM {panels_pane} WHERE pid = 0");
852
853  // update pid and did to be serial
854  db_drop_primary_key($ret, 'panels_pane');
855  db_change_field($ret, 'panels_pane', 'pid', 'pid', $schema['panels_pane']['fields']['pid'], array('primary key' => array('pid')));
856  db_drop_primary_key($ret, 'panels_display');
857  db_change_field($ret, 'panels_display', 'did', 'did', $schema['panels_display']['fields']['did'], array('primary key' => array('did')));
858
859  drupal_set_message(t('Please note that the Panels upgrade from Drupal 5 to Drupal 6 is far from perfect, especially where Views and CCK are involved. Please check all your panels carefully and compare them against the originals. You may need to do some rework to regain your original functionality.'));
860
861  return $ret;
862}
863
864/**
865 * Update from 6.x v2.
866 */
867function panels_update_6290() {
868  $ret = array();
869  if (!module_exists('panels')) {
870    $ret['#abort'] = array('success' => FALSE, 'query' => t('The Panels module cannot be updated while disabled. If you wish to update Panels, please enable it. If you do not wish to update Panels, please uninstall it.'));
871    return $ret;
872  }
873
874  // Fetch schema version 1.
875  $schema = panels_schema_1();
876
877  // Update size of pane 'access' field.
878  db_change_field($ret, 'panels_pane', 'access', 'access', $schema['panels_pane']['fields']['access']);
879
880  // Remove the no longer used visibility field
881  if (db_column_exists('panels_pane', 'visibility')) {
882    db_drop_field($ret, 'panels_pane', 'visibility');
883  }
884
885  // Remove panels_object_cache table
886  if (db_table_exists('panels_object_cache')) {
887    db_drop_table($ret, 'panels_object_cache');
888  }
889
890  // Doublecheck that ctools is enabled. If not, automatically disable the module.
891  if (!module_exists('ctools')) {
892    // Try to enable it:
893    drupal_install_modules(array('ctools'));
894
895    // If that fails, shut off all Panels.
896    if (!module_exists('ctools')) {
897      drupal_set_message(t('Panels now requires the Chaos Tool Suite (ctools) module to function. Panels has been disabled until you can add this module.'));
898      module_disable(array('panels', 'panels_mini', 'panels_export', 'panels_node', 'panels_simple_cache'));
899    }
900  }
901
902  if (!module_exists('page_manager') && db_table_exists('panels_page')) {
903    drupal_set_message('Page manager module has been automatically enabled to replace the Panels pages module.');
904    drupal_install_modules(array('page_manager'));
905  }
906
907  $ret[] = update_sql("DELETE FROM {system} WHERE name IN ('panels_page', 'panels_views')");
908
909  return $ret;
910}
911
912/**
913 * Special update function for the alpha2 to alpha3 transition after
914 * I messed it up.
915 */
916function panels_update_6291() {
917  $ret = array();
918  if (!module_exists('panels')) {
919    $ret['#abort'] = array('success' => FALSE, 'query' => t('The Panels module cannot be updated while disabled. If you wish to update Panels, please enable it. If you do not wish to update Panels, please uninstall it.'));
920    return $ret;
921  }
922
923  // Fetch schema version 1.
924  $schema = panels_schema_1();
925
926
927  // Add some new fields
928  db_add_field($ret, 'panels_pane', 'style', $schema['panels_pane']['fields']['style']);
929  db_add_field($ret, 'panels_pane', 'css', $schema['panels_pane']['fields']['css']);
930  db_add_field($ret, 'panels_pane', 'extras', $schema['panels_pane']['fields']['extras']);
931
932  return $ret;
933}
934
935/**
936 * Update panels pane fields using batch API.
937 */
938function panels_update_6292(&$sandbox) {
939  $ret = array();
940  if (!module_exists('panels')) {
941    $ret['#abort'] = array('success' => FALSE, 'query' => t('The Panels module cannot be updated while disabled. If you wish to update Panels, please enable it. If you do not wish to update Panels, please uninstall it.'));
942    return $ret;
943  }
944
945  if (!isset($sandbox['progress'])) {
946    $sandbox['progress'] = 0;
947    // We'll -1 to disregard the uid 0...
948    $sandbox['max'] = db_result(db_query('SELECT COUNT(*) FROM {panels_pane}'));
949  }
950
951  // configuration
952  $result = db_query_range("SELECT pid, access, configuration FROM {panels_pane} ORDER BY pid ASC", $sandbox['progress'], 20);
953  while ($pane = db_fetch_object($result)) {
954    // access
955    if (!empty($pane->access)) {
956      $rids = explode(', ', $pane->access);
957      // For safety, eliminate any non-numeric rids, as we occasionally had
958      // problems with nulls and such getting in here:
959      foreach ($rids as $id => $rid) {
960        if (!is_numeric($rid)) {
961          unset($rids[$id]);
962        }
963      }
964
965      if (empty($rids)) {
966        $pane->access = array();
967      }
968      else {
969        // The old access style was just a role based system, so let's convert
970        // it to that.
971        $pane->access = array(
972          'plugins' => array(
973            array(
974              'name' => 'role',
975              'context' => 'logged-in-user',
976              'settings' => array(
977                'rids' => array_values($rids),
978              )
979            ),
980          ),
981        );
982      }
983    }
984    else {
985      $pane->access = array();
986    }
987
988    // Move style from configuration.
989    $pane->configuration = unserialize($pane->configuration);
990    $pane->style = array();
991    if (!empty($pane->configuration['style'])) {
992      $pane->style['style'] = $pane->configuration['style'];
993      unset($pane->configuration['style']);
994    }
995
996    $pane->css = array();
997    // Move css configuration from configuration
998    if (isset($pane->configuration['css_id'])) {
999      $pane->css['css_id'] = $pane->configuration['css_id'];
1000      unset($pane->configuration['css_id']);
1001    }
1002
1003    if (isset($pane->configuration['css_class'])) {
1004      $pane->css['css_class'] = $pane->configuration['css_class'];
1005      unset($pane->configuration['css_class']);
1006    }
1007
1008    // Make sure extras is an array. This isn't used by anything in Panels
1009    // yet, so an empty array is just fine.
1010    $pane->extras = array();
1011    db_query("UPDATE {panels_pane} SET " .
1012      "access = '%s', css = '%s', style = '%s', configuration = '%s', extras = '%s'" .
1013      " WHERE pid = %d",
1014      serialize($pane->access),
1015      serialize($pane->css),
1016      serialize($pane->style),
1017      serialize($pane->configuration),
1018      serialize($pane->extras),
1019      $pane->pid);
1020
1021    $sandbox['progress']++;
1022  }
1023
1024  $ret['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
1025  if ($ret['#finished'] === 1) {
1026    $ret[] = array('success' => TRUE, 'query' => t('Panel panes were updated'));
1027  }
1028  return $ret;
1029}
1030
1031/**
1032 * Update panels display fields using batch API.
1033 */
1034function panels_update_6293(&$sandbox) {
1035  $ret = array();
1036  if (!module_exists('panels')) {
1037    $ret['#abort'] = array('success' => FALSE, 'query' => t('The Panels module cannot be updated while disabled. If you wish to update Panels, please enable it. If you do not wish to update Panels, please uninstall it.'));
1038    return $ret;
1039  }
1040
1041  if (!isset($sandbox['progress'])) {
1042    $sandbox['progress'] = 0;
1043    // We'll -1 to disregard the uid 0...
1044    $sandbox['max'] = db_result(db_query('SELECT COUNT(*) FROM {panels_display}'));
1045  }
1046
1047  // configuration
1048  $result = db_query_range("SELECT did, panel_settings FROM {panels_display} ORDER BY did ASC", $sandbox['progress'], 20);
1049  while ($display = db_fetch_object($result)) {
1050    if (empty($display->panel_settings)) {
1051      $display->panel_settings = array();
1052    }
1053    else {
1054      $display->panel_settings = unserialize($display->panel_settings);
1055      if (!is_array($display->panel_settings)) {
1056        $display->panel_settings = array();
1057      }
1058    }
1059
1060    if (isset($display->panel_settings['panel'])) {
1061      foreach ($display->panel_settings['panel'] as $key => $settings) {
1062        $display->panel_settings[$key] = $settings;
1063      }
1064      unset($display->panel_settings['panel']);
1065    }
1066
1067    if (isset($display->panel_settings['individual'])) {
1068      unset($display->panel_settings['individual']);
1069    }
1070
1071    db_query("UPDATE {panels_display} SET " .
1072      "panel_settings = '%s'" .
1073      " WHERE did = %d",
1074      serialize($display->panel_settings),
1075      $display->did);
1076
1077     $sandbox['progress']++;
1078  }
1079
1080  $ret['#finished'] = empty($sandbox['max']) ? 1 : ($sandbox['progress'] / $sandbox['max']);
1081  if ($ret['#finished'] === 1) {
1082    $ret[] = array('success' => TRUE, 'query' => t('Panel displays were updated'));
1083  }
1084  return $ret;
1085}
1086
1087/**
1088 * Establish a baseline schema version for 6.x-3.x
1089 */
1090function panels_update_6300() {
1091  return array();
1092}
1093
1094function panels_update_6302() {
1095  $ret = array();
1096  if (!module_exists('panels')) {
1097    $ret['#abort'] = array('success' => FALSE, 'query' => t('The Panels module cannot be updated while disabled. If you wish to update Panels, please enable it. If you do not wish to update Panels, please uninstall it.'));
1098    return $ret;
1099  }
1100
1101  if (!module_exists('page_manager') && db_table_exists('panels_page')) {
1102    $ret['#abort'] = array('success' => FALSE, 'query' => t('Conversion of panels pages cannot be completed without page manager module from CTools installed. Please install CTools, activate page manager, and attempt the update again.'));
1103    return $ret;
1104  }
1105
1106  if (!db_table_exists('panels_page')) {
1107    return $ret;
1108  }
1109
1110  // Store the node edit handlers because we merged the edit/add path and we
1111  // need to be able to keep these together to make sure the names work ok.
1112  $node_edit_handlers = array();
1113  page_manager_get_task('page');
1114  $result = db_query("SELECT * FROM {panels_page}");
1115  while ($p = db_fetch_object($result)) {
1116    $page = page_manager_page_new();
1117    $page->default_handlers = array();
1118    // Should we check for uniqueness here? It doesn't seem really
1119    // plausible that there could be page manager pages already.
1120    $page->name = $p->name;
1121    $page->task = 'page'; // could become custom later.
1122    $page->subtask = $p->name;
1123    $page->admin_title = $p->name;
1124    $page->path = $p->path;
1125    // convert access
1126    if (!empty($p->access)) {
1127      $rids = explode(', ', $p->access);
1128      // For safety, eliminate any non-numeric rids, as we occasionally had
1129      // problems with nulls and such getting in here:
1130      foreach ($rids as $id => $rid) {
1131        if (!is_numeric($rid)) {
1132          unset($rids[$id]);
1133        }
1134      }
1135
1136      if (empty($rids)) {
1137        $page->access = array();
1138      }
1139      else {
1140        // The old access style was just a role based system, so let's convert
1141        // it to that.
1142        $page->access = array(
1143          'plugins' => array(
1144            array(
1145              'name' => 'role',
1146              'context' => 'logged-in-user',
1147              'settings' => array(
1148                'rids' => array_values($rids),
1149              )
1150            ),
1151          ),
1152        );
1153      }
1154    }
1155
1156    // Convert menu stuff.
1157    $page->menu = array(
1158      'type' => 'none',
1159      'title' => '',
1160      'weight' => 0,
1161      'name' => 'navigation',
1162      'parent' => array(
1163        'type' => 'none',
1164        'title' => '',
1165        'weight' => 0,
1166        'name' => 'navigation',
1167      ),
1168    );
1169
1170    if ($p->menu) {
1171      if ($p->menu_tab) {
1172        if ($p->menu_tab_default) {
1173          $page->menu['type'] = 'default tab';
1174          $page->menu['parent']['type'] = $p->menu_tab_default_parent_type;
1175          $page->menu['parent']['title'] = $p->menu_parent_title;
1176          $page->menu['parent']['weight'] = $p->menu_parent_tab_weight;
1177        }
1178        else {
1179          $page->menu['type'] = 'tab';
1180        }
1181      }
1182      else {
1183        $page->menu['type'] = 'normal';
1184      }
1185
1186      $page->menu['title'] = $p->menu_title;
1187      $page->menu['weight'] = $p->menu_tab_weight;
1188    }
1189
1190    $page->conf = array();
1191    $displays = unserialize($p->displays);
1192    $arguments = unserialize($p->arguments);
1193
1194    foreach ($arguments as $id => $argument) {
1195      $page->arguments[$argument['keyword']] = array(
1196        'name' => $argument['name'],
1197        'identifier' => $argument['identifier'],
1198        'title' => $argument['title'],
1199        'id' => $argument['id'],
1200        'settings' => isset($argument['argument_settings']) ? $argument['argument_settings'] : array(),
1201      );
1202
1203      $match = FALSE;
1204      $bits = explode('/', $page->path);
1205      foreach ($bits as $pos => $bit) {
1206        if ($bit == '%') {
1207          $bits[$pos] = '%' . $argument['keyword'];
1208          $match = TRUE;
1209          $page->path = implode('/', $bits);
1210          break;
1211        }
1212      }
1213
1214      if (!$match) {
1215        if ($argument['default'] == '404') {
1216          $page->path .= '/%' . $argument['keyword'];
1217        }
1218        else {
1219          $page->path .= '/!' . $argument['keyword'];
1220        }
1221      }
1222
1223      // save this for later use.
1224      $arguments[$id]['context'] = 'argument_' . $argument['name'] . '_' . $argument['id'];
1225    }
1226
1227    // Reset the task type here if it's one of our overrides. This ensures
1228    // that we get the right names.
1229    switch ($p->path) {
1230      case 'node/%':
1231        $page->task = 'node_view';
1232        $page->subtask = '';
1233        variable_set('page_manager_node_view_disabled', FALSE);
1234        break;
1235      case 'node/add/%':
1236        // It seems nearly impossible to actually upgrade this properly.
1237        continue;
1238      case 'node/%/edit':
1239        // Could we get conflicts here if they had both?
1240        $page->task = 'node_edit';
1241        $page->subtask = '';
1242        variable_set('page_manager_node_edit_disabled', FALSE);
1243        break;
1244      case 'taxonomy/term':
1245      case 'taxonomy/term/%':
1246        $page->task = 'term_view';
1247        $page->subtask = '';
1248        if ($arguments[0]['name'] == 'term') {
1249          variable_set('page_manager_term_view_type', 'single');
1250        }
1251        variable_set('page_manager_term_view_disabled', FALSE);
1252        break;
1253      case 'user/%':
1254        $page->task = 'user_view';
1255        $page->subtask = '';
1256        variable_set('page_manager_user_view_disabled', FALSE);
1257        break;
1258      // There is no default here.
1259    }
1260
1261    if (empty($displays)) {
1262      // only one display on this panel, mak
1263      $cache = new stdClass();
1264      if ($page->task != 'node_edit') {
1265        $cache->handlers = array();
1266      }
1267      else {
1268        $cache->handlers = $node_edit_handlers;
1269      }
1270      _panels_update_create_handler($page, $p, NULL, array('did' => $p->did, 'title' => t('Panel')), $arguments, 0, $cache);
1271      $page->default_handlers = $cache->handlers;
1272    }
1273    else {
1274      // for each display we need to create a new handler.
1275      $weight = 0;
1276      $cache = new stdClass();
1277      if ($page->task != 'node_edit') {
1278        $cache->handlers = array();
1279      }
1280      else {
1281        $cache->handlers = $node_edit_handlers;
1282        $weight = count($cache->handlers) + 1;
1283      }
1284      foreach ($displays as $origin => $info) {
1285        if (!isset($info['argument_id'])) {
1286          $info['argument_id'] = 0;
1287        }
1288
1289        _panels_update_create_handler($page, $p, $origin, $info, $arguments, $weight++, $cache);
1290      }
1291
1292      // Also add the primary display as a default with no selector.
1293//      _panels_update_create_handler($page, $p, NULL, array('did' => $p->did, 'title' => t('Default')), $arguments, $weight++, $cache);
1294      $page->default_handlers = $cache->handlers;
1295    }
1296
1297    if ($page->task != 'page') {
1298      // just save the handlers.
1299      foreach ($cache->handlers as $name => $handler) {
1300        page_manager_save_task_handler($handler);
1301
1302        // Keep all node edit handlers for later use.
1303        if ($page->task == 'node_edit') {
1304          $node_edit_handlers[$name] = $handler;
1305        }
1306      }
1307    }
1308    else {
1309      page_manager_page_save($page);
1310    }
1311  }
1312
1313  $ret[] = update_sql("DROP TABLE {panels_page}");
1314
1315  // Update a couple of pane types that changed and are easily moved:
1316  switch ($GLOBALS['db_type']) {
1317    case 'mysql':
1318    case 'mysqli':
1319      $ret[] = update_sql("UPDATE {panels_pane} SET type = CONCAT(type, '_', subtype) WHERE type = 'node_form'");
1320      break;
1321
1322    case 'pgsql':
1323      $ret[] = update_sql("UPDATE {panels_pane} SET type = type || '_' || subtype WHERE type = 'node_form'");
1324  }
1325  $ret[] = update_sql("UPDATE {panels_pane} SET type = 'node_form_path' WHERE type = 'node_form_url_path'");
1326
1327  if (module_exists('ctools') && !module_exists('views_content') && db_result(db_query("SELECT pid FROM {panels_pane} WHERE type = 'views'"))) {
1328    drupal_install_modules(array('views_content'));
1329  }
1330
1331  return $ret;
1332}
1333
1334function _panels_update_create_handler($page, $p, $origin, $info, $arguments, $weight, &$cache) {
1335  $task = page_manager_get_task($page->task);
1336  $task_name = 'page-' . $page->name;
1337  $plugin = page_manager_get_task_handler('panel_context');
1338  $handler = page_manager_new_task_handler($plugin);
1339
1340  $handler->weight = $weight;
1341  $handler->task = $page->task;
1342  if ($page->task == 'page') {
1343    $handler->subtask = $page->name;
1344  }
1345  $handler->export_type = EXPORT_IN_DATABASE;
1346  $handler->type = t('Normal');
1347
1348  $handler->name = page_manager_handler_get_name($task_name, $cache->handlers, $handler);
1349
1350  $handler->conf['css'] = $p->css;
1351  $handler->conf['css_id'] = $p->css_id;
1352  $handler->conf['no_blocks'] = $p->no_blocks;
1353  if (!empty($info['did']) && is_numeric($info['did'])) {
1354    $handler->conf['did'] = $info['did'];
1355  }
1356  else {
1357    $d = panels_load_display($p->did);
1358    if ($d) {
1359      $display_code = panels_export_display($d);
1360      eval($display_code);
1361
1362      $handler->conf['did'] = 'new';
1363      $handler->conf['display'] = $display;
1364    }
1365  }
1366  $handler->conf['title'] = !empty($info['title']) ? $info['title'] : '';
1367  $handler->conf['contexts'] = unserialize($p->contexts);
1368  $handler->conf['relationships'] = unserialize($p->relationships);
1369
1370  if ($origin && strpos($origin, '-')) {
1371    $handler->conf['access'] = array(
1372      'logic' => 'and',
1373      'plugins' => array(),
1374    );
1375
1376    // Only 4 types of arguments supported having their own displays:
1377    // nid, node_add_form, node_edit_form and term. 3 of those simply used
1378    // node type and the last simply used vocabulary.
1379    list($junk, $key) = explode('-', $origin);
1380    if ($key && $key != 'default') {
1381      if ($arguments[$info['argument_id']]['name'] == 'term') {
1382        $handler->conf['access']['plugins'][] = array(
1383          'name' => 'term_vocabulary',
1384          'context' => $arguments[$info['argument_id']]['context'],
1385          'settings' => array(
1386            'vids' => array($key),
1387           ),
1388         );
1389      }
1390      else {
1391        $handler->conf['access']['plugins'][] = array(
1392          'name' => 'node_type',
1393          'context' => $arguments[$info['argument_id']]['context'],
1394          'settings' => array(
1395            'type' => array($key),
1396           ),
1397         );
1398      }
1399    }
1400    else {
1401      // make sure defaults float to the bottom:
1402      $handler->weight += 100;
1403    }
1404  }
1405  $cache->handlers[$handler->name] = $handler;
1406
1407  return $handler;
1408}
1409
1410/**
1411 * Ensure the panels_simple_cache module does not exist.
1412 */
1413function panels_update_6303() {
1414  $ret = array();
1415  if (module_exists('panels_simple_cache')) {
1416    drupal_set_message(t('Your installation contains a module that no longer exists. When updating modules, you should always remove the module directory first, then replace it with the new code. The "Panels Simple Cache" module is being automatically disabled for you. Please do not re-enable it as it will cause your system to crash.'));
1417    $ret[] = update_sql("DELETE FROM {system} WHERE name = 'panels_simple_cache'");
1418  }
1419
1420  return $ret;
1421}
1422
1423/**
1424 * Ensure that users are informed about the page manager module.
1425 */
1426function panels_update_6304() {
1427  if (!module_exists('page_manager')) {
1428    drupal_set_message(t('The delegator module has been replaced by the Page Manager module. You should enable the page manager module to ensure that any panel pages you have will not be lost.'));
1429  }
1430
1431  return array();
1432}
1433
1434/**
1435 * Add the title_pane field.
1436 */
1437function panels_update_6305() {
1438  $ret = array();
1439
1440  // Fetch schema version 2.
1441  $schema = panels_schema_2();
1442
1443  // Add new field
1444  db_add_field($ret, 'panels_display', 'title_pane', $schema['panels_display']['fields']['title_pane']);
1445
1446  return $ret;
1447}
1448
1449/**
1450 * Drop a table that should have been gone long ago.
1451 */
1452function panels_update_6306() {
1453  $ret = array();
1454
1455  if (db_table_exists('panels_page_router_store')) {
1456    db_drop_table($ret, 'panels_page_router_store');
1457  }
1458
1459  return $ret;
1460}
1461
1462/**
1463 * This update function does nothing, it was committed in error and is
1464 * left in to prevent update problems.
1465 */
1466function panels_update_6307() {
1467  return array();
1468}
1469
1470/**
1471 * Add the panels_layout table
1472 */
1473function panels_update_6308() {
1474  $ret = array();
1475
1476  // Schema 3 is locked and should not be changed.
1477  $schema = panels_schema_3();
1478
1479  db_create_table($ret, 'panels_layout', $schema['panels_layout']);
1480  return $ret;
1481}
1482
1483/**
1484 * Add the panels_renderer_pipeline table
1485 */
1486function panels_update_6309() {
1487  $ret = array();
1488
1489  // Schema 3 is locked and should not be changed.
1490  $schema = panels_schema_3();
1491
1492  db_create_table($ret, 'panels_renderer_pipeline', $schema['panels_renderer_pipeline']);
1493  return $ret;
1494}
1495
1496/**
1497 * Move stylizer data from Panels to CTools.
1498 */
1499function panels_update_6310() {
1500  $ret = array();
1501  // load the module files, if possible
1502  if (!defined('PANELS_REQUIRED_CTOOLS_API')) {
1503    include_once drupal_get_path('module', 'panels') . '/panels.module';
1504  }
1505  if (!defined('CTOOLS_API_VERSION')) {
1506    include_once drupal_get_path('module', 'ctools') . '/ctools.module';
1507  }
1508  // Safety: go away if CTools is not at an appropriate version.
1509  if (!module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) {
1510    $ret['#abort'] = array('success' => FALSE, 'query' => t('Panels cannot be updated because CTools 1.7 (API v1.7.2) is required. Please update CTools and then try update.php again.'));
1511    return $ret;
1512  }
1513
1514  // Enable the stylizer module to make everything as seamless as possible.
1515  drupal_install_modules(array('stylizer'));
1516  return $ret;
1517}
1518
1519/**
1520 * Change panels_display.layout to match the size of panels_layout.name.
1521 */
1522function panels_update_6311() {
1523  $ret = array();
1524
1525  // Clear the schema cache so the change is picked up.
1526  cache_clear_all('schema', 'cache');
1527
1528  // Load the schema.
1529  $schema = panels_schema();
1530  $table = 'panels_display';
1531  $field = 'layout';
1532  $spec = $schema[$table]['fields'][$field];
1533
1534  // Re-define the column.
1535  db_change_field($ret, $table, $field, $field, $spec);
1536
1537  $ret[] = array('success' => TRUE, 'query' => t('Changed the panels_display.layout field to the correct size.'));
1538
1539  return $ret;
1540}
1541
1542/**
1543 * Add a custom cache table for Panels.
1544 */
1545function panels_update_6312() {
1546  $ret = array();
1547
1548  $table_name = 'cache_panels';
1549  if (!db_table_exists($table_name)) {
1550    $ret = array();
1551    $schema = drupal_get_schema_unprocessed('system', 'cache');
1552    db_create_table($ret, $table_name, $schema);
1553  }
1554
1555  $ret[] = array('success' => TRUE, 'query' => t('Added a cache panels table.'));
1556
1557  return $ret;
1558}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.