t('MySite Content'), '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', //'validate callback' => 'panels_admin_validate_mysite', ); return $items; } /** * Output function for the 'mysite' content type. Outputs a block * based on the module and delta supplied in the configuration. */ function panels_content_mysite($conf) { return 'hello'; } /** * Return all content types available. */ function panels_admin_content_types_mysite() { $list = array(); // load the active MySite includes and get their options $types = mysite_load_includes('types'); # SIMPLE VERSION 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'])) { $list[$type] = array( 'title' => $options['name'], 'icon' => 'icon_contrib_block.png', 'category' => t('MySite') ); } } # 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 $list; # return $items; } /** * Returns the form for a new block. */ function panels_admin_add_mysite($id) { $conf['type'] = $id; $conf['module'] = 'mysite'; return panels_admin_edit_mysite($conf); } /** * Returns an edit form for a mysite. */ function panels_admin_edit_mysite($conf) { $form['module'] = array( '#type' => 'value', '#value' => $conf['module'], ); $form['delta'] = array( '#type' => 'value', '#value' => $conf['delta'], ); $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' => '
', ); mysite_load_includes('types', $conf['id']); $data = module_invoke('mysite_type', $conf['id']); $options = array(); foreach ($data['options'] as $key => $value) { $options[$key] = $value; } $form['mysite_test'] = array( '#title' => 'test', '#type' => 'radios', '#options' => $options, ); return $form; } function panels_admin_submit_mysite(&$form_values) { if (!empty($form_values['mysite_settings'])) { module_invoke($form_values['module'], 'mysite', 'save', $form_values['delta'], $form_values['mysite_settings']); } } /** * Because form api cannot collapse just part of a tree, and the block settings * assume no tree, we have to collapse the tree ourselves. */ function panels_admin_fix_mysite_tree(&$form, $key = NULL) { if ($key) { if (!empty($form['#parents'])) { $form['#parents'] = array_merge(array('configuration', 'mysite_settings'), $form['#parents']); } else if (empty($form['#tree'])) { $form['#parents'] = array('configuration', 'mysite_settings', $key); } } if ($form['#type'] == 'textarea' && !empty($form['#rows']) && $form['#rows'] > 10) { $form['#rows'] = 10; } foreach (element_children($form) as $key) { panels_admin_fix_mysite_tree($form[$key], $key); } } /** * Returns the administrative title for a type. */ function panels_admin_title_mysite($conf) { $block = module_invoke($conf['module'], 'block', 'list'); $title = filter_xss_admin($block[$conf['delta']]['info']); return $title; }