t('MySite'), 'content_types' => 'panels_admin_content_types_mysite', 'render callback' => 'panels_content_mysite', 'add callback' => 'panels_admin_add_mysite', 'edit callback' => 'panels_admin_edit_mysite', 'title callback' => 'panels_admin_title_mysite', 'add submit callback' => 'panels_admin_submit_mysite', 'edit submit callback' => 'panels_admin_submit_mysite', # 'add validate callback' => 'panels_admin_validate_mysite', # 'edit validate callback' => 'panels_admin_validate_mysite', ); return $items; } /** * Output function for the 'mysite' content type. */ function panels_content_mysite($conf) { $block->module = $conf['type']; $block->delta = $conf['type_id']; if ($conf['override_title_text']) { $block->subject = check_plain($conf['override_title_text']); } else { $block->subject = panels_admin_title_mysite($conf); } $block->content = mysite_display($conf['type'], $conf['type_id'], $conf['uid'], $conf['format']); return $block; } /** * Return all content types available. */ function panels_admin_content_types_mysite() { $list = array(); // Load all MySite includes and get their options. // Admins may wish to enable MySite types not available to the public. $types = mysite_load_includes('types', NULL, TRUE); # SIMPLE VERSION foreach ($types as $type) { // check to be sure that the content type can be activated. $func_check = 'mysite_type_'. $type .'_active'; if (function_exists($func_check)) { $active = $func_check($type); } $options = module_invoke('mysite_type', $type, TRUE); // If it can't be activated, or if no options are available, it can't be used if ($active[$type] && !empty($options['options'])) { $list[$type] = array( 'title' => $options['name'], 'icon' => 'icon_contrib_block.png', 'description' => filter_xss_admin($options['description']), 'category' => array(t('MySite'), -1), ); } } # COMPLEX VERSION /** $items = array(); foreach ($types as $type) { $options = module_invoke('mysite_type', $type, TRUE); // if no options are available, it can't be used if (!empty($options['options'])) { foreach($options['options']['name'] as $key => $value) { $id = $options['options']['type'][$key] .'-'. $options['options']['type_id'][$key]; $items['mysite-'. $id] = array( 'title' => $value, 'icon' => 'icon_contrib_block.png', 'category' => $options['name'] ); } } } return $items; */ ksort($list); return $list; } /** * Returns the form for a new block. */ function panels_admin_add_mysite($id) { $conf['type'] = $id; return panels_admin_edit_mysite($conf); } /** * Returns an edit form for a mysite. */ function panels_admin_edit_mysite($conf) { $form['type'] = array( '#type' => 'value', '#value' => $conf['type'], ); $form['uid'] = array('#type' => 'value', '#value' => 0); mysite_load_includes('types', $conf['type']); // Simple radio version $func = 'mysite_type_'. $conf['type'] .'_options'; $options = $func(); $opts = array(); for ($i = 0; $i < count($options['name']); $i++) { $opts[$options['type_id'][$i]] = $options['name'][$i]; } $form['type_id'] = array( '#type' => 'radios', '#options' => $opts, '#required' => TRUE, '#default_value' => $conf['type_id'] ); // Complex search version /* $search_func = 'mysite_type_'. $conf['type'] .'_search_form'; if (function_exists($search_func)) { $extra = $search_func($uid = 0); $unset = array('submit', '#validate'); foreach ($unset as $key) { unset($extra['add_'. $conf['type']][$key]); } $form['mysite_settings'] = $extra; } $form['mysite_settings']['add_'. $conf['type']][$conf['type'] .'_title']['#required'] = TRUE; */ // formatting $mysite = mysite_get($conf['uid']); // add user styles mysite_load_includes('styles', $mysite->style); // formats for the item -- test the data for format options $func = 'mysite_type_'. $conf['type'] .'_data'; mysite_load_includes('types', $conf['type']); $content = $func($conf['type_id']); // if the content item returns a 'content' element, it cannot be formatted if (empty($content['items'][0]['content'])) { $options = array(); $formats = mysite_load_includes('formats'); // these, too foreach ($formats as $format) { $options[$format] = module_invoke('mysite_theme', $format); } if ($options != array('default')) { $form['format'] = array( '#type' => 'radios', '#title' => t('Content format'), '#default_value' => $conf['format'] ? $conf['format'] : 'default', '#options' => $options, '#description' => t("Select a format") ); } } else { $form['data']['format'] = array( '#type' => 'value', '#value' => $conf['format'] ? $conf['format'] : 'default' ); } $form['aligner_start'] = array( '#value' => '
', ); $form['override_title'] = array( '#type' => 'checkbox', '#default_value' => $conf['override_title'], '#title' => t('Override title'), '#id' => 'override-title-checkbox', ); $form['override_title_text'] = array( '#type' => 'textfield', '#default_value' => $conf['override_title_text'], '#size' => 35, '#id' => 'override-title-textfield', ); $form['aligner_stop'] = array( '#value' => '
', ); return $form; } function panels_admin_submit_mysite(&$form_values) { /* mysite_load_includes('types', $form_values['type']); $func = 'mysite_type_'. $form_values['type'] .'_search_form_submit'; $data = $func($form_values['form_id'], $form_values); drupal_set_message('hello'. $data); */ } function mysite_panels_search_handler($data, $type) { drupal_set_message('handled'); return 'hello'; } /** * Returns the administrative title for a type. */ function panels_admin_title_mysite($conf) { mysite_load_includes('types', $conf['type']); $func = 'mysite_type_'. $conf['type'] .'_title'; $title = $func($conf['type_id']); $title = filter_xss_admin($title); return $title; }