panels.install 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <?php
  2. /**
  3. * Test requirements for installation and running.
  4. */
  5. function panels_requirements($phase) {
  6. $function = "panels_requirements_$phase";
  7. return function_exists($function) ? $function() : array();
  8. }
  9. /**
  10. * Check install-time requirements.
  11. */
  12. function panels_requirements_install() {
  13. $requirements = array();
  14. $t = get_t();
  15. // Assume that if the user is running an installation profile that both
  16. // Panels and CTools are the same release.
  17. if (!(defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'install')) {
  18. // apparently the install process doesn't include .module files,
  19. // so we need to force the issue in order for our versioning
  20. // check to work.
  21. if (!defined('PANELS_REQUIRED_CTOOLS_API')) {
  22. include_once drupal_get_path('module', 'panels') . '/panels.module';
  23. }
  24. // In theory we should check module_exists, but Drupal's gating should
  25. // actually prevent us from getting here otherwise.
  26. if (!defined('CTOOLS_API_VERSION')) {
  27. include_once drupal_get_path('module', 'ctools') . '/ctools.module';
  28. }
  29. if (!module_invoke('ctools', 'api_version', PANELS_REQUIRED_CTOOLS_API)) {
  30. $requirements['panels_ctools'] = array(
  31. 'title' => $t('CTools API Version'),
  32. 'value' => CTOOLS_API_VERSION,
  33. 'severity' => REQUIREMENT_ERROR,
  34. 'description' => t('The CTools API version is too old for Panels. Panels needs at least %version.', array('%version' => PANELS_REQUIRED_CTOOLS_API))
  35. );
  36. }
  37. }
  38. return $requirements;
  39. }
  40. /**
  41. * Implementation of hook_schema().
  42. */
  43. function panels_schema() {
  44. // This should always point to our 'current' schema. This makes it relatively easy
  45. // to keep a record of schema as we make changes to it.
  46. return panels_schema_4();
  47. }
  48. function panels_schema_4() {
  49. $schema = panels_schema_3();
  50. $schema['panels_pane']['fields']['locks'] = array(
  51. 'type' => 'text',
  52. 'size' => 'big',
  53. 'serialize' => TRUE,
  54. 'object default' => array(),
  55. 'initial' => array(),
  56. );
  57. return $schema;
  58. }
  59. /**
  60. * Schema from the D6 version.
  61. */
  62. function panels_schema_3() {
  63. // Schema 3 is now locked. If you need to make changes, please create
  64. // schema 4 and add them.
  65. $schema = array();
  66. $schema['panels_display'] = array(
  67. 'export' => array(
  68. 'object' => 'panels_display',
  69. 'bulk export' => FALSE,
  70. 'export callback' => 'panels_export_display',
  71. 'can disable' => FALSE,
  72. 'identifier' => 'display',
  73. ),
  74. 'fields' => array(
  75. 'did' => array(
  76. 'type' => 'serial',
  77. 'not null' => TRUE,
  78. 'no export' => TRUE,
  79. ),
  80. 'layout' => array(
  81. 'type' => 'varchar',
  82. 'length' => '255',
  83. 'default' => '',
  84. ),
  85. 'layout_settings' => array(
  86. 'type' => 'text',
  87. 'size' => 'big',
  88. 'serialize' => TRUE,
  89. 'object default' => array(),
  90. 'initial' => array(),
  91. ),
  92. 'panel_settings' => array(
  93. 'type' => 'text',
  94. 'size' => 'big',
  95. 'serialize' => TRUE,
  96. 'object default' => array(),
  97. 'initial' => array(),
  98. ),
  99. 'cache' => array(
  100. 'type' => 'text',
  101. 'serialize' => TRUE,
  102. 'object default' => array(),
  103. 'initial' => array(),
  104. ),
  105. 'title' => array(
  106. 'type' => 'varchar',
  107. 'length' => '255',
  108. 'default' => '',
  109. ),
  110. 'hide_title' => array(
  111. 'type' => 'int',
  112. 'size' => 'tiny',
  113. 'default' => 0,
  114. 'no export' => TRUE,
  115. ),
  116. 'title_pane' => array(
  117. 'type' => 'int',
  118. 'default' => 0,
  119. 'no export' => TRUE,
  120. ),
  121. ),
  122. 'primary key' => array('did'),
  123. );
  124. $schema['panels_pane'] = array(
  125. 'export' => array(
  126. 'can disable' => FALSE,
  127. 'identifier' => 'pane',
  128. 'bulk export' => FALSE,
  129. ),
  130. 'fields' => array(
  131. 'pid' => array(
  132. 'type' => 'serial',
  133. 'not null' => TRUE,
  134. ),
  135. 'did' => array(
  136. 'type' => 'int',
  137. 'not null' => TRUE,
  138. 'default' => 0,
  139. 'no export' => TRUE,
  140. ),
  141. 'panel' => array(
  142. 'type' => 'varchar',
  143. 'length' => '32',
  144. 'default' => '',
  145. ),
  146. 'type' => array(
  147. 'type' => 'varchar',
  148. 'length' => '32',
  149. 'default' => '',
  150. ),
  151. 'subtype' => array(
  152. 'type' => 'varchar',
  153. 'length' => '64',
  154. 'default' => '',
  155. ),
  156. 'shown' => array(
  157. 'type' => 'int',
  158. 'size' => 'tiny',
  159. 'default' => 1,
  160. ),
  161. 'access' => array(
  162. 'type' => 'text',
  163. 'size' => 'big',
  164. 'serialize' => TRUE,
  165. 'object default' => array(),
  166. 'initial' => array(),
  167. ),
  168. 'configuration' => array(
  169. 'type' => 'text',
  170. 'size' => 'big',
  171. 'serialize' => TRUE,
  172. 'object default' => array(),
  173. 'initial' => array(),
  174. ),
  175. 'cache' => array(
  176. 'type' => 'text',
  177. 'size' => 'big',
  178. 'serialize' => TRUE,
  179. 'object default' => array(),
  180. 'initial' => array(),
  181. ),
  182. 'style' => array(
  183. 'type' => 'text',
  184. 'size' => 'big',
  185. 'serialize' => TRUE,
  186. 'object default' => array(),
  187. 'initial' => array(),
  188. ),
  189. 'css' => array(
  190. 'type' => 'text',
  191. 'size' => 'big',
  192. 'serialize' => TRUE,
  193. 'object default' => array(),
  194. 'initial' => array(),
  195. ),
  196. 'extras' => array(
  197. 'type' => 'text',
  198. 'size' => 'big',
  199. 'serialize' => TRUE,
  200. 'object default' => array(),
  201. 'initial' => array(),
  202. ),
  203. 'position' => array(
  204. 'type' => 'int',
  205. 'size' => 'small',
  206. 'default' => 0,
  207. ),
  208. ),
  209. 'primary key' => array('pid'),
  210. 'indexes' => array(
  211. 'did_idx' => array('did')
  212. ),
  213. );
  214. $schema['panels_renderer_pipeline'] = array(
  215. 'description' => 'Contains renderer pipelines for Panels. Each pipeline contains one or more renderers and access rules to select which renderer gets used.',
  216. 'export' => array(
  217. 'identifier' => 'pipeline',
  218. 'bulk export' => TRUE,
  219. 'primary key' => 'rpid',
  220. 'api' => array(
  221. 'owner' => 'panels',
  222. 'api' => 'pipelines',
  223. 'minimum_version' => 1,
  224. 'current_version' => 1,
  225. ),
  226. ),
  227. 'fields' => array(
  228. 'rpid' => array(
  229. 'type' => 'serial',
  230. 'description' => 'A database primary key to ensure uniqueness.',
  231. 'not null' => TRUE,
  232. 'no export' => TRUE,
  233. ),
  234. 'name' => array(
  235. 'type' => 'varchar',
  236. 'length' => '255',
  237. 'description' => 'Unique ID for this content. Used to identify it programmatically.',
  238. ),
  239. 'admin_title' => array(
  240. 'type' => 'varchar',
  241. 'length' => '255',
  242. 'description' => 'Administrative title for this pipeline.',
  243. ),
  244. 'admin_description' => array(
  245. 'type' => 'text',
  246. 'size' => 'big',
  247. 'description' => 'Administrative description for this pipeline.',
  248. 'object default' => '',
  249. ),
  250. 'weight' => array(
  251. 'type' => 'int',
  252. 'size' => 'small',
  253. 'default' => 0,
  254. ),
  255. 'settings' => array(
  256. 'type' => 'text',
  257. 'size' => 'big',
  258. 'description' => 'Serialized settings for the actual pipeline. The contents of this field are up to the plugin that uses it.',
  259. 'serialize' => TRUE,
  260. 'object default' => array(),
  261. ),
  262. ),
  263. 'primary key' => array('rpid'),
  264. );
  265. $schema['panels_layout'] = array(
  266. 'description' => 'Contains exportable customized layouts for this site.',
  267. 'export' => array(
  268. 'identifier' => 'layout',
  269. 'bulk export' => TRUE,
  270. 'primary key' => 'lid',
  271. 'api' => array(
  272. 'owner' => 'panels',
  273. 'api' => 'layouts',
  274. 'minimum_version' => 1,
  275. 'current_version' => 1,
  276. ),
  277. ),
  278. 'fields' => array(
  279. 'lid' => array(
  280. 'type' => 'serial',
  281. 'description' => 'A database primary key to ensure uniqueness.',
  282. 'not null' => TRUE,
  283. 'no export' => TRUE,
  284. ),
  285. 'name' => array(
  286. 'type' => 'varchar',
  287. 'length' => '255',
  288. 'description' => 'Unique ID for this content. Used to identify it programmatically.',
  289. ),
  290. 'admin_title' => array(
  291. 'type' => 'varchar',
  292. 'length' => '255',
  293. 'description' => 'Administrative title for this layout.',
  294. ),
  295. 'admin_description' => array(
  296. 'type' => 'text',
  297. 'size' => 'big',
  298. 'description' => 'Administrative description for this layout.',
  299. 'object default' => '',
  300. ),
  301. 'category' => array(
  302. 'type' => 'varchar',
  303. 'length' => '255',
  304. 'description' => 'Administrative category for this layout.',
  305. ),
  306. 'plugin' => array(
  307. 'type' => 'varchar',
  308. 'length' => '255',
  309. 'description' => 'The layout plugin that owns this layout.',
  310. ),
  311. 'settings' => array(
  312. 'type' => 'text',
  313. 'size' => 'big',
  314. 'description' => 'Serialized settings for the actual layout. The contents of this field are up to the plugin that uses it.',
  315. 'serialize' => TRUE,
  316. 'object default' => array(),
  317. ),
  318. ),
  319. 'primary key' => array('lid'),
  320. );
  321. return $schema;
  322. }
  323. /**
  324. * Change panels_display.layout to match the size of panels_layout.name.
  325. */
  326. function panels_update_7300() {
  327. // Load the schema.
  328. $schema = panels_schema_3();
  329. $table = 'panels_display';
  330. $field = 'layout';
  331. $spec = $schema[$table]['fields'][$field];
  332. // Re-define the column.
  333. db_change_field($table, $field, $field, $spec);
  334. return t('Changed the panels_display.layout field to the correct size.');
  335. }
  336. /**
  337. * Add lock field to panels_pane table.
  338. */
  339. function panels_update_7301() {
  340. // Load the schema.
  341. // Due to a previous failure, the field may already exist:
  342. $schema = panels_schema_4();
  343. $table = 'panels_pane';
  344. $field = 'locks';
  345. if (!db_field_exists($table, $field)) {
  346. $spec = $schema[$table]['fields'][$field];
  347. // Core does not properly respect 'initial' and 'serialize'.
  348. unset($spec['initial']);
  349. // Re-define the column.
  350. db_add_field($table, $field, $spec);
  351. return t('Added panels_pane.lock field.');
  352. }
  353. return t('panels_pane.lock field already existed, update skipped.');
  354. }