linkit_profiles.class.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * @file
  4. * Contains the Linkit profile export UI integration code.
  5. */
  6. /**
  7. * Linktit profile export UI class handler for Views UI.
  8. */
  9. class linkit_profiles extends ctools_export_ui {
  10. /**
  11. * @TODO: Can we call parent:list_build_row and then just add linkit specific
  12. * columns?
  13. */
  14. function list_build_row($item, &$form_state, $operations) {
  15. // Set up sorting
  16. $name = $item->{$this->plugin['export']['key']};
  17. $schema = ctools_export_get_schema($this->plugin['schema']);
  18. // Note: $item->{$schema['export']['export type string']} should have already been set up by export.inc so
  19. // we can use it safely.
  20. switch ($form_state['values']['order']) {
  21. case 'disabled':
  22. $this->sorts[$name] = empty($item->disabled) . $name;
  23. break;
  24. case 'title':
  25. $this->sorts[$name] = $item->{$this->plugin['export']['admin_title']};
  26. break;
  27. case 'name':
  28. $this->sorts[$name] = $name;
  29. break;
  30. case 'storage':
  31. $this->sorts[$name] = $item->{$schema['export']['export type string']} . $name;
  32. break;
  33. }
  34. $this->rows[$name]['data'] = array();
  35. $this->rows[$name]['class'] = !empty($item->disabled) ? array('ctools-export-ui-disabled') : array('ctools-export-ui-enabled');
  36. // If we have an admin title, make it the first row.
  37. if (!empty($this->plugin['export']['admin_title'])) {
  38. $this->rows[$name]['data'][] = array('data' => check_plain($item->{$this->plugin['export']['admin_title']}), 'class' => array('ctools-export-ui-title'));
  39. }
  40. // Profile type.
  41. $this->rows[$name]['data'][] = array('data' => linkit_get_profile_type($item->profile_type), 'class' => array('linkit-export-ui-profile-type'));
  42. // Storage.
  43. $this->rows[$name]['data'][] = array('data' => check_plain($item->{$schema['export']['export type string']}), 'class' => array('ctools-export-ui-storage'));
  44. // Operations.
  45. $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
  46. $this->rows[$name]['data'][] = array('data' => $ops, 'class' => array('ctools-export-ui-operations'));
  47. // Add an automatic mouseover of the description if one exists.
  48. $this->rows[$name]['title'] = $item->{$this->plugin['export']['admin_description']};
  49. }
  50. function list_table_header() {
  51. $header = array();
  52. $header[] = array('data' => t('Title'), 'class' => array('ctools-export-ui-title'));
  53. $header[] = array('data' => t('Profile type'), 'class' => array('ctools-export-ui-profile-type'));
  54. $header[] = array('data' => t('Storage'), 'class' => array('ctools-export-ui-storage'));
  55. $header[] = array('data' => t('Operations'), 'class' => array('ctools-export-ui-operations'));
  56. return $header;
  57. }
  58. }