ds_extras.admin.inc

  1. cis7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.admin.inc
  2. cle7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.admin.inc
  3. ecd7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.admin.inc
  4. elmsmedia7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.admin.inc
  5. harmony7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.admin.inc
  6. icor7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.admin.inc
  7. meedjum_blog7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.admin.inc
  8. mooc7 sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.admin.inc

Display Suite Extras administrative functions.

Functions

Namesort descending Description
ds_extras_block_submit Submit callback: manage block regions.
ds_extras_ds_field_format_summary Implements hook_ds_field_format_summary().
ds_extras_ds_field_settings_form Implements hook_ds_field_settings_form().
ds_extras_field_template_settings_form Field template settings form
ds_extras_field_ui_alter Alter Manage display screen.
ds_extras_region_to_block_unique Return unique region to block.
ds_extras_settings Menu callback: Display Suite extras settings.
ds_extras_settings_submit Submit callback: Extras settings screen.
ds_extras_settings_validate Validate callback: Extras settings screen.
ds_extras_vd_field_ui_submit Submit callback after Field UI submission of a views display.
_ds_extras_page_title_options Helper function to show the page title options.

File

sites/all/modules/ulmus/ds/modules/ds_extras/includes/ds_extras.admin.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Display Suite Extras administrative functions.
  5. */
  6. /**
  7. * Menu callback: Display Suite extras settings.
  8. */
  9. function ds_extras_settings($form) {
  10. $form['additional_settings'] = array(
  11. '#type' => 'vertical_tabs',
  12. '#theme_wrappers' => array('vertical_tabs'),
  13. '#prefix' => '<div>',
  14. '#suffix' => '</div>',
  15. '#tree' => TRUE,
  16. );
  17. $form['additional_settings']['fs1'] = array(
  18. '#type' => 'fieldset',
  19. '#title' => t('Field Templates'),
  20. );
  21. $form['additional_settings']['fs1']['ds_extras_field_template'] = array(
  22. '#type' => 'checkbox',
  23. '#title' => t('Enable Field Templates'),
  24. '#description' => t('Customize the labels and the HTML output of your fields.'),
  25. '#default_value' => variable_get('ds_extras_field_template', FALSE),
  26. );
  27. $theme_functions = module_invoke_all('ds_field_theme_functions_info');
  28. $form['additional_settings']['fs1']['ft-default'] = array(
  29. '#type' => 'select',
  30. '#title' => t('Default Field Template'),
  31. '#options' => $theme_functions,
  32. '#default_value' => variable_get('ft-default', 'theme_field'),
  33. '#description' => t('Default will output the field as defined in Drupal Core.<br />Reset will strip all HTML.<br />Minimal adds a simple wrapper around the field.<br/>There is also an Expert Field Template that gives full control over the HTML, but can only be set per field.<br /><br />You can override this setting per field on the "Manage display" screens or when creating fields on the instance level.<br /><br /><strong>Template suggestions</strong><br />You can create .tpl files as well for these field theme functions, e.g. field--reset.tpl.php, field--minimal.tpl.php<br /><br /><label>CSS classes</label>You can add custom CSS classes on the <a href="!url">classes form</a>. Display Suite UI needs to be enabled for this. These classes can be added to fields using the Default Field Template.<br /><br /><label>Advanced</label>You can create your own custom field templates which need to be defined with hook_ds_field_theme_functions_info(). See ds.api.php for an example.', array('!url' => url('admin/structure/ds/classes'))),
  34. '#states' => array(
  35. 'visible' => array(
  36. 'input[name="additional_settings[fs1][ds_extras_field_template]"]' => array('checked' => TRUE),
  37. ),
  38. ),
  39. );
  40. $form['additional_settings']['fs1']['ft-kill-colon'] = array(
  41. '#type' => 'checkbox',
  42. '#title' => t('Hide colon'),
  43. '#default_value' => variable_get('ft-kill-colon', FALSE),
  44. '#description' => t('Hide the colon on the reset field template.'),
  45. '#states' => array(
  46. 'visible' => array(
  47. 'select[name="additional_settings[fs1][ft-default]"]' => array('value' => 'theme_ds_field_reset'),
  48. 'input[name="additional_settings[fs1][ds_extras_field_template]"]' => array('checked' => TRUE),
  49. ),
  50. ),
  51. );
  52. $form['additional_settings']['fs2'] = array(
  53. '#type' => 'fieldset',
  54. '#title' => t('Extra fields'),
  55. );
  56. $form['additional_settings']['fs2']['ds_extras_fields_extra'] = array(
  57. '#type' => 'checkbox',
  58. '#title' => t('Enable extra fields'),
  59. '#description' => t('Make fields from other modules available on the "Manage display" screens.'),
  60. '#default_value' => variable_get('ds_extras_fields_extra', FALSE),
  61. );
  62. $form['additional_settings']['fs2']['ds_extras_fields_extra_list'] = array(
  63. '#type' => 'textarea',
  64. '#description' => t('Enter fields line by line, where each line is a combination of entity type, bundle and field name. E.g. node|article|tweetbutton. It might be possible that the actual content of the field depends on configuration of that field/module.'),
  65. '#default_value' => variable_get('ds_extras_fields_extra_list', FALSE),
  66. '#states' => array(
  67. 'visible' => array(
  68. 'input[name="additional_settings[fs2][ds_extras_fields_extra]"]' => array('checked' => TRUE),
  69. ),
  70. ),
  71. );
  72. $form['additional_settings']['fs4'] = array(
  73. '#type' => 'fieldset',
  74. '#title' => t('Other'),
  75. );
  76. $form['additional_settings']['fs4']['ds_extras_switch_view_mode'] = array(
  77. '#type' => 'checkbox',
  78. '#title' => t('View mode per node'),
  79. '#description' => t('Change view modes for individual nodes. A new tab \'Display settings\' will appear on the content create form.<br />You can also pass the name of a view mode through the URL, eg node/x?v=full.<br />If you install the Page manager module and override the node view, Page manager will win.'),
  80. '#default_value' => variable_get('ds_extras_switch_view_mode', FALSE),
  81. );
  82. $form['additional_settings']['fs4']['ds_extras_hide_page_title'] = array(
  83. '#type' => 'checkbox',
  84. '#title' => t('Page title options'),
  85. '#description' => t('Hide or manually set the page title of the "Full content" view mode.'),
  86. '#default_value' => variable_get('ds_extras_hide_page_title', FALSE),
  87. );
  88. $form['additional_settings']['fs4']['ds_extras_hide_page_sidebars'] = array(
  89. '#type' => 'checkbox',
  90. '#title' => t('Disable Drupal blocks/regions'),
  91. '#description' => t('Add ability to disable all sidebar regions displayed in the theme. Note that some themes support this setting better than others. If in doubt, try with stock themes to see.'),
  92. '#default_value' => variable_get('ds_extras_hide_page_sidebars', FALSE),
  93. );
  94. $form['additional_settings']['fs4']['ds_extras_field_permissions'] = array(
  95. '#type' => 'checkbox',
  96. '#title' => t('Field permissions'),
  97. '#description' => t('Enables view permissions on all Display Suite fields.'),
  98. '#default_value' => variable_get('ds_extras_field_permissions', FALSE),
  99. );
  100. if (module_exists('block')) {
  101. $form['additional_settings']['fs4']['ds_extras_region_to_block'] = array(
  102. '#type' => 'checkbox',
  103. '#title' => t('Region to block'),
  104. '#description' => t('Create additional regions exposed as block. Note: this will not work on the default view mode.'),
  105. '#default_value' => variable_get('ds_extras_region_to_block', FALSE),
  106. );
  107. }
  108. if (module_exists('views')) {
  109. $form['additional_settings']['fs4']['ds_extras_vd'] = array(
  110. '#type' => 'checkbox',
  111. '#title' => t('Views displays'),
  112. '#description' => t('Manage the layout of your Views layout with Field UI at !url.', array('!url' => l(url('admin/structure/ds/vd', array('absolute' => TRUE)), 'admin/structure/ds/vd'))),
  113. '#default_value' => variable_get('ds_extras_vd', FALSE),
  114. );
  115. }
  116. if (module_exists('flag')) {
  117. $form['additional_settings']['fs4']['ds_extras_flag'] = array(
  118. '#type' => 'checkbox',
  119. '#title' => t('Flag'),
  120. '#description' => t('Expose flags as fields on nodes.'),
  121. '#default_value' => variable_get('ds_extras_flag', FALSE),
  122. );
  123. }
  124. $form['additional_settings']['fs4']['ds_extras_switch_field'] = array(
  125. '#type' => 'checkbox',
  126. '#title' => t('View mode switcher'),
  127. '#description' => t('Adds a field with links to switch view modes inline with Ajax. Only works for nodes at this time.'),
  128. '#default_value' => variable_get('ds_extras_switch_field', FALSE),
  129. );
  130. $form['additional_settings']['fs4']['ds_extras_hidden_region'] = array(
  131. '#type' => 'checkbox',
  132. '#title' => t('Hidden region'),
  133. '#description' => t('Add a hidden region to the layouts. Fields will be built but not printed.'),
  134. '#default_value' => variable_get('ds_extras_hidden_region', FALSE),
  135. );
  136. $form['#attached']['js'][] = drupal_get_path('module', 'ds_extras') . '/js/ds_extras.admin.js';
  137. $form = system_settings_form($form);
  138. $form['#submit'][] = 'ds_extras_settings_submit';
  139. return $form;
  140. }
  141. /**
  142. * Validate callback: Extras settings screen.
  143. */
  144. function ds_extras_settings_validate($form, &$form_state) {
  145. foreach ($form_state['values']['additional_settings'] as $tab => $value) {
  146. if (is_array($value)) {
  147. foreach ($value as $variable => $val) {
  148. $form_state['values'][$variable] = $val;
  149. }
  150. }
  151. unset($form_state['values']['additional_settings'][$tab]);
  152. }
  153. unset($form_state['values']['additional_settings']);
  154. }
  155. /**
  156. * Submit callback: Extras settings screen.
  157. */
  158. function ds_extras_settings_submit($form, &$form_state) {
  159. cache_clear_all('ds_fields:', 'cache', TRUE);
  160. cache_clear_all('entity_info:', 'cache', TRUE);
  161. cache_clear_all('theme_registry:', 'cache', TRUE);
  162. cache_clear_all('module_implements', 'cache_bootstrap');
  163. cache_clear_all('field_info_fields', 'cache_field');
  164. variable_set('menu_rebuild_needed', TRUE);
  165. }
  166. /**
  167. * Alter Manage display screen.
  168. */
  169. function ds_extras_field_ui_alter(&$form, &$form_state) {
  170. // Attach js.
  171. $form['#attached']['js'][] = drupal_get_path('module', 'ds_extras') . '/js/ds_extras.admin.js';
  172. // Views displays.
  173. if ($form['#entity_type'] == 'ds_views') {
  174. // Add an additional submit callback so we can ditch the extra title
  175. // which is added by ds_extras_field_extra_fields().
  176. $form['#submit'] = array_merge(array('ds_extras_vd_field_ui_submit'), $form['#submit']);
  177. }
  178. // Page title functionality, currently only works on nodes, users and taxonomy terms.
  179. if (variable_get('ds_extras_hide_page_title', FALSE) && isset($form['#ds_layout']) && (in_array($form['#entity_type'], array('node', 'user', 'taxonomy_term', 'profile2')) && ($form['#view_mode'] == 'full' || $form['#view_mode'] == 'revision' || (variable_get('ds_extras_switch_view_mode', FALSE) && $form['#entity_type'] == 'node')) || $form['#entity_type'] == 'ds_views' || $form['#entity_type'] == 'profile2')) {
  180. $form['additional_settings']['ds_page_title'] = array(
  181. '#type' => 'fieldset',
  182. '#title' => t('Custom page title'),
  183. );
  184. $form['additional_settings']['ds_page_title']['ds_page_title_options'] = _ds_extras_page_title_options($form['#ds_layout']->settings, $form['#entity_type']);
  185. }
  186. // Disable page regions.
  187. if (variable_get('ds_extras_hide_page_sidebars', FALSE) && isset($form['#ds_layout']) && $form['#view_mode'] != 'form') {
  188. $form['additional_settings']['ds_layouts']['hide_sidebars'] = array(
  189. '#type' => 'checkbox',
  190. '#title' => t('Disable Drupal blocks/regions'),
  191. '#default_value' => isset($form['#ds_layout']->settings['hide_sidebars']) ? $form['#ds_layout']->settings['hide_sidebars'] : FALSE,
  192. '#weight' => 3,
  193. );
  194. }
  195. // Region to block only fires if there is a layout and we're working on the
  196. // a view mode which is not equal to default.
  197. if (isset($form['#ds_layout']) && $form['#view_mode'] != 'default' && variable_get('ds_extras_region_to_block', FALSE)) {
  198. $layout = $form['#ds_layout'];
  199. // Get the entity_type, bundle and view mode.
  200. $entity_type = $form['#entity_type'];
  201. $bundle = $form['#bundle'];
  202. $view_mode = $form['#view_mode'];
  203. $region_blocks_options = array();
  204. $region_blocks = variable_get('ds_extras_region_blocks', array());
  205. foreach ($region_blocks as $key => $block) {
  206. if ($block['info'] == "{$entity_type}_{$bundle}_{$view_mode}") {
  207. $region_blocks_options[$key] = t('Remove') . ' ' . $block['title'];
  208. }
  209. }
  210. $form['additional_settings']['region_to_block'] = array(
  211. '#type' => 'fieldset',
  212. '#title' => t('Block regions'),
  213. '#description' => t('Create additional regions in this layout which will be exposed as blocks. Note that preprocess fields will fail to print.')
  214. );
  215. $form['additional_settings']['region_to_block']['new_block_region'] = array(
  216. '#type' => 'textfield',
  217. '#title' => t('Region name'),
  218. '#description' => t('Enter a name to create a new region.'),
  219. );
  220. $form['additional_settings']['region_to_block']['new_block_region_key'] = array(
  221. '#title' => t('Machine name'),
  222. '#type' => 'machine_name',
  223. '#default_value' => '',
  224. '#maxlength' => 32,
  225. '#required' => FALSE,
  226. '#description' => t('The machine-readable name of this block region. This name must contain only lowercase letters and underscores. This name must be unique.'),
  227. '#disabled' => FALSE,
  228. '#machine_name' => array(
  229. 'exists' => 'ds_extras_region_to_block_unique',
  230. 'source' => array('additional_settings', 'region_to_block', 'new_block_region'),
  231. ),
  232. );
  233. if (!empty($region_blocks_options)) {
  234. $form['additional_settings']['region_to_block']['remove_block_region'] = array(
  235. '#type' => 'checkboxes',
  236. '#title' => t('Existing block regions'),
  237. '#options' => $region_blocks_options,
  238. '#description' => t('Check the regions you want to remove.'),
  239. );
  240. }
  241. $form['#submit'][] = 'ds_extras_block_submit';
  242. }
  243. }
  244. /**
  245. * Field template settings form
  246. */
  247. function ds_extras_field_template_settings_form(array &$form, array &$form_state, array $context) {
  248. $functions = module_invoke_all('ds_field_theme_functions_info');
  249. $default_field_function = variable_get('ft-default', 'theme_field');
  250. $key = $context['instance']['field_name'];
  251. $field_settings = isset($form_state['formatter_settings'][$key]) ? $form_state['formatter_settings'][$key]['ft'] : array();
  252. $field_function = isset($field_settings['func']) ? $field_settings['func'] : $default_field_function;
  253. $field_classes = _ds_classes('ds_classes_fields');
  254. $form['ft'] = array(
  255. '#weight' => 20,
  256. );
  257. // Functions.
  258. $form['ft']['func'] = array(
  259. '#title' => t('Choose a Field Template'),
  260. '#type' => 'select',
  261. '#options' => $functions,
  262. '#default_value' => $field_function,
  263. '#attributes' => array(
  264. 'class' => array('ds-extras-field-template'),
  265. ),
  266. );
  267. // Field classes.
  268. if (!empty($field_classes)) {
  269. $field_classes_select = array(
  270. '#type' => 'select',
  271. '#multiple' => TRUE,
  272. '#options' => $field_classes,
  273. '#title' => t('Choose additional CSS classes for the field'),
  274. '#default_value' => isset($field_settings['classes']) ? explode(' ', $field_settings['classes']) : array(),
  275. '#prefix' => '<div class="field-classes">',
  276. '#suffix' => '</div>',
  277. );
  278. $form['ft']['classes'] = $field_classes_select;
  279. }
  280. else {
  281. $form['ft']['classes'] = array(
  282. '#type' => 'value',
  283. '#value' => array(''),
  284. );
  285. }
  286. // Wrappers and label.
  287. $wrappers = array(
  288. 'lb' => array('title' => t('Label')),
  289. 'ow' => array('title' => t('Outer wrapper')),
  290. 'fis' => array('title' => t('Field items')),
  291. 'fi' => array('title' => t('Field item')),
  292. );
  293. foreach ($wrappers as $wrapper_key => $value) {
  294. $classes = array(
  295. 'field-name-' . strtr($key, '_', '-'),
  296. );
  297. $form['ft'][$wrapper_key] = array(
  298. '#type' => 'checkbox',
  299. '#title' => $value['title'],
  300. '#prefix' => '<div class="ft-group ' . $wrapper_key . '">',
  301. '#default_value' => isset($field_settings[$wrapper_key]) ? $field_settings[$wrapper_key] : FALSE,
  302. );
  303. $form['ft'][$wrapper_key . '-el'] = array(
  304. '#type' => 'textfield',
  305. '#title' => t('Element'),
  306. '#size' => '10',
  307. '#description' => t('E.g. div, span, h2 etc.'),
  308. '#default_value' => isset($field_settings[$wrapper_key . '-el']) ? $field_settings[$wrapper_key . '-el'] : '',
  309. );
  310. $form['ft'][$wrapper_key . '-cl'] = array(
  311. '#type' => 'textfield',
  312. '#title' => t('Classes'),
  313. '#size' => '10',
  314. '#default_value' => isset($field_settings[$wrapper_key . '-cl']) ? $field_settings[$wrapper_key . '-cl'] : '',
  315. '#description' => t('E.g.') .' ' . implode(', ', $classes),
  316. );
  317. $form['ft'][$wrapper_key . '-at'] = array(
  318. '#type' => 'textfield',
  319. '#title' => t('Attributes'),
  320. '#size' => '20',
  321. '#default_value' => isset($field_settings[$wrapper_key . '-at']) ? $field_settings[$wrapper_key . '-at'] : '',
  322. '#description' => t('E.g. name="anchor"'),
  323. );
  324. // Hide colon.
  325. if ($wrapper_key == 'lb') {
  326. $form['ft']['lb-col'] = array(
  327. '#type' => 'checkbox',
  328. '#title' => t('Hide label colon'),
  329. '#default_value' => isset($field_settings['lb-col']) ? $field_settings['lb-col'] : FALSE,
  330. '#attributes' => array(
  331. 'class' => array('colon-checkbox'),
  332. ),
  333. );
  334. }
  335. if ($wrapper_key == 'fi') {
  336. $form['ft']['fi-odd-even'] = array(
  337. '#type' => 'checkbox',
  338. '#title' => t('Add odd/even classes'),
  339. '#default_value' => isset($field_settings['fi-odd-even']) ? $field_settings['fi-odd-even'] : FALSE,
  340. );
  341. }
  342. $form['ft'][$wrapper_key . '-def-at'] = array(
  343. '#type' => 'checkbox',
  344. '#title' => t('Add default attributes'),
  345. '#default_value' => isset($field_settings[$wrapper_key . '-def-at']) ? $field_settings[$wrapper_key . '-def-at'] : FALSE,
  346. '#suffix' => ($wrapper_key == 'ow') ? '' : '</div><div class="clearfix"></div>',
  347. );
  348. // Default classes for outer wrapper.
  349. if ($wrapper_key == 'ow') {
  350. $form['ft'][$wrapper_key . '-def-cl'] = array(
  351. '#type' => 'checkbox',
  352. '#title' => t('Add default classes'),
  353. '#default_value' => isset($field_settings[$wrapper_key . '-def-cl']) ? $field_settings[$wrapper_key . '-def-cl'] : FALSE,
  354. '#suffix' => '</div><div class="clearfix"></div>',
  355. );
  356. }
  357. }
  358. // Another label needs some other stuff.
  359. unset($form['ft']['lb']['#description']);
  360. $form['ft']['lb']['#type'] = 'textfield';
  361. $form['ft']['lb']['#size'] = '10';
  362. $form['ft']['lb']['#attributes'] = array('class' => array('label-change'));
  363. $form['ft']['lb']['#default_value'] = isset($field_settings['lb']) ? $field_settings['lb'] : '';
  364. }
  365. /**
  366. * Implements hook_ds_field_format_summary().
  367. */
  368. function ds_extras_ds_field_format_summary($field) {
  369. if (isset($field['formatter_settings'])) {
  370. foreach ($field['formatter_settings'] as $key => $value) {
  371. if (!empty($value)) {
  372. return t('Configured');
  373. break;
  374. }
  375. }
  376. }
  377. return t('Not configured');
  378. }
  379. /**
  380. * Implements hook_ds_field_settings_form().
  381. */
  382. function ds_extras_ds_field_settings_form($field) {
  383. $form = array();
  384. // Switch field.
  385. if (variable_get('ds_extras_switch_field') && $field['name'] == 'ds_switch_field') {
  386. $entity_type = $field['entity_type'];
  387. $bundle = $field['bundle'];
  388. $view_mode = $field['view_mode'];
  389. $settings = isset($field['formatter_settings']['vms']) ? $field['formatter_settings']['vms'] : array();
  390. $view_modes = ds_entity_view_modes($entity_type);
  391. $form['info'] = array(
  392. '#markup' => t('Enter a label for the link for the view modes you want to switch to.<br />Leave empty to hide link. They will be localized.'),
  393. );
  394. foreach ($view_modes as $key => $value) {
  395. $view_mode_settings = field_view_mode_settings($entity_type, $bundle);
  396. $visible = !empty($view_mode_settings[$key]['custom_settings']);
  397. if ($visible) {
  398. $form['vms'][$key] = array(
  399. '#type' => 'textfield',
  400. '#default_value' => isset($settings[$key]) ? $settings[$key] : '',
  401. '#size' => 20,
  402. '#title' => check_plain($value['label']),
  403. );
  404. }
  405. }
  406. }
  407. return $form;
  408. }
  409. /**
  410. * Submit callback after Field UI submission of a views display.
  411. */
  412. function ds_extras_vd_field_ui_submit($form, &$form_state) {
  413. // Add the 'type' key to the extra title key so we can ditch the notice.
  414. $form_state['values']['fields']['title']['type'] = 'hidden';
  415. }
  416. /**
  417. * Submit callback: manage block regions.
  418. */
  419. function ds_extras_block_submit($form, &$form_state) {
  420. // Create new region.
  421. if (!empty($form_state['values']['additional_settings']['region_to_block']['new_block_region'])) {
  422. // Get the entity_type, bundle and view mode.
  423. $entity_type = $form['#entity_type'];
  424. $bundle = $form['#bundle'];
  425. $view_mode = $form['#view_mode'];
  426. $block = array(
  427. 'title' => $form_state['values']['additional_settings']['region_to_block']['new_block_region'],
  428. 'info' => "{$entity_type}_{$bundle}_{$view_mode}",
  429. );
  430. $block_key = $form_state['values']['additional_settings']['region_to_block']['new_block_region_key'];
  431. $region_blocks = variable_get('ds_extras_region_blocks', array());
  432. $region_blocks[$block_key] = $block;
  433. variable_set('ds_extras_region_blocks', $region_blocks);
  434. }
  435. // Remove a region.
  436. if (isset($form_state['values']['additional_settings']['region_to_block']['remove_block_region'])) {
  437. $variable_set = FALSE;
  438. $region_blocks = variable_get('ds_extras_region_blocks', array());
  439. $remove = $form_state['values']['additional_settings']['region_to_block']['remove_block_region'];
  440. foreach ($remove as $key => $value) {
  441. if ($key === $value) {
  442. $variable_set = TRUE;
  443. db_delete('block')
  444. ->condition('delta', $key)
  445. ->condition('module', 'ds_extras')
  446. ->execute();
  447. unset($region_blocks[$key]);
  448. }
  449. }
  450. if ($variable_set) {
  451. variable_set('ds_extras_region_blocks', $region_blocks);
  452. }
  453. }
  454. }
  455. /**
  456. * Return unique region to block.
  457. */
  458. function ds_extras_region_to_block_unique($name) {
  459. $region_blocks = variable_get('ds_extras_region_blocks', array());
  460. $value = strtr($name, array('-' => '_'));
  461. return isset($region_blocks[$value]) ? TRUE : FALSE;
  462. }
  463. /**
  464. * Helper function to show the page title options.
  465. */
  466. function _ds_extras_page_title_options($settings, $entity_type) {
  467. $return['page_option_type'] = array(
  468. '#type' => 'select',
  469. '#title' => t('Page title'),
  470. '#options' => array(
  471. '0' => t('Show'),
  472. '1' => t('Hide'),
  473. '2' => t('Manually set'),
  474. ),
  475. '#default_value' => isset($settings['hide_page_title']) ? $settings['hide_page_title'] : FALSE,
  476. '#weight' => 100,
  477. );
  478. // Display Suite Views currently only supports hiding the page title.
  479. if ($entity_type == 'ds_views') {
  480. unset($return['page_option_type']['#options'][2]);
  481. }
  482. $contexts = ds_get_entity_context($entity_type);
  483. $rows = array();
  484. foreach ($contexts as $context) {
  485. foreach (ctools_context_get_converters('%' . check_plain($context->keyword) . ':', $context) as $keyword => $title) {
  486. $rows[] = array(
  487. check_plain($keyword),
  488. t('@identifier: @title', array('@title' => $title, '@identifier' => $context->identifier)),
  489. );
  490. }
  491. }
  492. $return['page_option_title'] = array(
  493. '#type' => 'textfield',
  494. '#title' => t('Title'),
  495. '#default_value' => isset($settings['page_option_title']) ? $settings['page_option_title'] : '',
  496. '#description' => t('The title, you may use substitutions in this title.'),
  497. '#weight' => 101,
  498. '#access' => $entity_type != 'ds_views',
  499. '#states' => array(
  500. 'visible' => array(
  501. array(':input[name="page_option_type"]' => array('value' => '2')),
  502. array(':input[name="additional_settings[ds_page_title][ds_page_title_options][page_option_type]"]' => array('value' => '2')),
  503. ),
  504. ),
  505. );
  506. $header = array(t('Keyword'), t('Value'));
  507. $return['page_option_contexts'] = array(
  508. '#type' => 'fieldset',
  509. '#title' => t('Substitutions'),
  510. // Doesn't work because of http://drupal.org/node/1015798
  511. //'#collapsible' => TRUE,
  512. //'#collapsed' => TRUE,
  513. '#value' => theme('table', array('header' => $header, 'rows' => $rows)),
  514. '#weight' => 102,
  515. '#access' => $entity_type != 'ds_views',
  516. '#states' => array(
  517. 'visible' => array(
  518. array(':input[name="page_option_type"]' => array('value' => '2')),
  519. array(':input[name="additional_settings[ds_page_title][ds_page_title_options][page_option_type]"]' => array('value' => '2')),
  520. ),
  521. ),
  522. );
  523. return $return;
  524. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.