diff --git a/fieldable_panels_panes.module b/fieldable_panels_panes.module index 0437e1f..944c7f3 100644 --- a/fieldable_panels_panes.module +++ b/fieldable_panels_panes.module @@ -406,6 +406,14 @@ function fieldable_panels_panes_menu() { 'type' => MENU_LOCAL_ACTION, ) + $base; + // Settings + $items['admin/structure/fieldable-panels-panes/settings'] = array( + 'title' => 'Settings', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('fieldable_panels_panes_settings'), + 'type' => MENU_LOCAL_TASK, + ) + $base; + return $items; } @@ -735,6 +743,43 @@ function fieldable_panels_panes_views_api() { } // ------------------------------------------------------------------------- +// Block hooks + +/** + * Implements hook_block_info(). + */ +function fieldable_panels_panes_block_info() { + $blocks = array(); + if (variable_get('fieldable_panels_panes_expose_as_blocks', FALSE) == TRUE) { + $ids = db_query('SELECT fpid FROM {fieldable_panels_panes} WHERE reusable = 1')->fetchCol(); + $entities = fieldable_panels_panes_load_multiple($ids); + foreach ($entities as $entity) { + $blocks[$entity->fpid]['info'] = 'FPP (' . $entity->bundle . '): ' . entity_label('fieldable_panels_pane', $entity); + } + } + return $blocks; +} + +/** + * Implements hook_block_view(). + */ + +function fieldable_panels_panes_block_view($delta = '') { + $block = array(); + if (variable_get('fieldable_panels_panes_expose_as_blocks', FALSE) == TRUE) { + $entity = fieldable_panels_panes_load($delta); + $block['subject'] = ''; + $block['content'] = ''; + if ($entity->reusable == TRUE) { + $content = fieldable_panels_panes_view($entity); + $block['subject'] = check_plain($entity->title); + $block['content'] = $content; + } + } + return $block; +} + +// ------------------------------------------------------------------------- // Theming /** diff --git a/includes/admin.inc b/includes/admin.inc index fa62511..396cee4 100644 --- a/includes/admin.inc +++ b/includes/admin.inc @@ -6,6 +6,21 @@ */ /** + * Page callback for settings page. + */ + +function fieldable_panels_panes_settings() { + $form = array(); + $form['fieldable_panels_panes_expose_as_blocks'] = array( + '#type' => 'checkbox', + '#title' => t('Make field entity panes available as blocks'), + '#description' => t('Field entity panes that are resuable will be made available as blocks'), + '#default_value' => variable_get('fieldable_panels_panes_expose_as_blocks', FALSE), + ); + return system_settings_form($form); +} + +/** * List all entities for the given type. */ function fieldable_panels_panes_entities_list_page($type) {