View source
<?php
module_load_include('inc', 'bean_admin_ui', 'includes/features');
function bean_admin_ui_menu() {
$items = array();
$items['admin/structure/block-types'] = array(
'title' => 'Block types',
'description' => 'Manage block types, including fields, settings, etc.',
'page callback' => 'bean_admin_ui_admin_page',
'access arguments' => array(
'administer bean types',
),
'file' => 'bean_admin_ui.admin.inc',
);
$items['admin/structure/block-types/list'] = array(
'title' => 'List',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items['admin/structure/block-types/add'] = array(
'title' => 'Add block type',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'bean_admin_ui_type_form',
),
'access arguments' => array(
'administer bean types',
),
'type' => MENU_LOCAL_ACTION,
'file' => 'bean_admin_ui.admin.inc',
);
$items['admin/structure/block-types/manage/%bean_type'] = array(
'title' => 'Edit block type',
'title arguments' => array(
4,
),
'title callback' => 'bean_admin_ui_page_title',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'bean_admin_ui_type_form',
4,
),
'access arguments' => array(
'administer bean types',
),
'file' => 'bean_admin_ui.admin.inc',
);
$items['admin/structure/block-types/manage/%bean_type/edit'] = array(
'title' => 'Edit',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/structure/block-types/manage/%bean_type/delete'] = array(
'title' => 'Delete',
'page arguments' => array(
'bean_admin_ui_type_op_confirm',
'delete',
4,
),
'access arguments' => array(
'administer bean types',
),
'file' => 'bean_admin_ui.admin.inc',
);
$items['admin/structure/block-types/manage/%bean_type/revert'] = array(
'title' => 'Delete',
'page arguments' => array(
'bean_admin_ui_type_op_confirm',
'revert',
4,
),
'access arguments' => array(
'administer bean types',
),
'file' => 'bean_admin_ui.admin.inc',
);
return $items;
}
function bean_admin_ui_page_title($block_type) {
$beantype = bean_fetch_plugin_info($block_type->type);
return check_plain($beantype['label']);
}
function bean_admin_ui_bean_types_api_info() {
return array(
'api' => bean_current_version(),
);
}
function bean_admin_ui_bean_types() {
$plugins = array();
$bean_types = bean_admin_ui_get_types();
foreach ($bean_types as $bean_type) {
$plugins[$bean_type->name] = array(
'label' => $bean_type->label,
'description' => empty($bean_type->description) ? '' : $bean_type->description,
'type' => $bean_type->name,
'export_status' => $bean_type->type,
);
$plugins[$bean_type->name] += _bean_admin_default_plugin();
}
return $plugins;
}
function bean_admin_ui_get_types() {
ctools_include('export');
return ctools_export_load_object('bean_type');
}
function bean_admin_ui_bean_cache_clear() {
ctools_include('export');
ctools_export_load_object_reset('bean_type');
cache_clear_all('bean_types', 'cache');
}
function _bean_admin_default_plugin() {
return array(
'label' => '',
'description' => '',
'type' => '',
'editable' => TRUE,
'handler' => array(
'info_file' => TRUE,
'class' => 'BeanCustom',
'parent' => 'bean',
'file' => 'BeanCustom.class.php',
'path' => drupal_get_path('module', 'bean_admin_ui') . '/plugins',
),
);
}
function bean_admin_ui_features_api() {
static $api = FALSE;
if (!$api) {
module_load_include('inc', 'features', 'includes/features.ctools');
$api = ctools_component_features_api('bean_admin_ui');
$api['bean_type']['name'] = 'Bean types';
$api['bean_type']['file'] = drupal_get_path('module', 'bean_admin_ui') . '/includes/features.inc';
}
return $api;
}
function bean_admin_ui_modules_enabled($modules) {
$beans_found = FALSE;
foreach ($modules as $module) {
if (function_exists($module . '_bean_types')) {
$beans_found = TRUE;
}
}
if ($beans_found) {
bean_reset();
}
}