3 class ctools_custom_content_ui
extends ctools_export_ui
{
5 function edit_form(&$form, &$form_state) {
6 // Correct for an error that came in because filter format changed.
7 if (is_array($form_state['item']->settings
['body'])) {
8 $form_state['item']->settings
['format'] = $form_state['item']->settings
['body']['format'];
9 $form_state['item']->settings
['body'] = $form_state['item']->settings
['body']['value'];
11 parent
::edit_form($form, $form_state);
13 $form['category'] = array(
14 '#type' => 'textfield',
15 '#title' => t('Category'),
16 '#description' => t('What category this content should appear in. If left blank the category will be "Miscellaneous".'),
17 '#default_value' => $form_state['item']->category
,
20 $form['title'] = array(
21 '#type' => 'textfield',
22 '#default_value' => $form_state['item']->settings
['title'],
23 '#title' => t('Title'),
26 $form['body'] = array(
27 '#type' => 'text_format',
28 '#title' => t('Body'),
29 '#default_value' => $form_state['item']->settings
['body'],
30 '#format' => $form_state['item']->settings
['format'],
33 $form['substitute'] = array(
34 '#type' => 'checkbox',
35 '#title' => t('Use context keywords'),
36 '#description' => t('If checked, context keywords will be substituted in this content.'),
37 '#default_value' => !empty($form_state['item']->settings
['substitute']),
41 function edit_form_submit(&$form, &$form_state) {
42 parent
::edit_form_submit($form, $form_state);
44 // Since items in our settings are not in the schema, we have to do these manually:
45 $form_state['item']->settings
['title'] = $form_state['values']['title'];
46 $form_state['item']->settings
['body'] = $form_state['values']['body']['value'];
47 $form_state['item']->settings
['format'] = $form_state['values']['body']['format'];
48 $form_state['item']->settings
['substitute'] = $form_state['values']['substitute'];
51 function list_form(&$form, &$form_state) {
52 parent
::list_form($form, $form_state);
54 $options = array('all' => t('- All -'));
55 foreach ($this->items
as $item) {
56 $options[$item->category
] = $item->category
;
59 $form['top row']['category'] = array(
61 '#title' => t('Category'),
62 '#options' => $options,
63 '#default_value' => 'all',
68 function list_filter($form_state, $item) {
69 if ($form_state['values']['category'] != 'all' && $form_state['values']['category'] != $item->category
) {
73 return parent
::list_filter($form_state, $item);
76 function list_sort_options() {
78 'disabled' => t('Enabled, title'),
79 'title' => t('Title'),
81 'category' => t('Category'),
82 'storage' => t('Storage'),
86 function list_build_row($item, &$form_state, $operations) {
88 switch ($form_state['values']['order']) {
90 $this->sorts
[$item->name
] = empty($item->disabled
) . $item->admin_title
;
93 $this->sorts
[$item->name
] = $item->admin_title
;
96 $this->sorts
[$item->name
] = $item->name
;
99 $this->sorts
[$item->name
] = $item->category
;
102 $this->sorts
[$item->name
] = $item->type
. $item->admin_title
;
106 $ops = theme('links__ctools_dropbutton', array('links' => $operations, 'attributes' => array('class' => array('links', 'inline'))));
108 $this->rows
[$item->name
] = array(
110 array('data' => check_plain($item->name
), 'class' => array('ctools-export-ui-name')),
111 array('data' => check_plain($item->admin_title
), 'class' => array('ctools-export-ui-title')),
112 array('data' => check_plain($item->category
), 'class' => array('ctools-export-ui-category')),
113 array('data' => $ops, 'class' => array('ctools-export-ui-operations')),
115 'title' => check_plain($item->admin_description
),
116 'class' => array(!empty($item->disabled
) ?
'ctools-export-ui-disabled' : 'ctools-export-ui-enabled'),
120 function list_table_header() {
122 array('data' => t('Name'), 'class' => array('ctools-export-ui-name')),
123 array('data' => t('Title'), 'class' => array('ctools-export-ui-title')),
124 array('data' => t('Category'), 'class' => array('ctools-export-ui-category')),
125 array('data' => t('Operations'), 'class' => array('ctools-export-ui-operations')),