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