diff --git a/bean_all/bean_all.info b/bean_all/bean_all.info deleted file mode 100644 index ad4df77..0000000 --- a/bean_all/bean_all.info +++ /dev/null @@ -1,8 +0,0 @@ -name = Bean All -description = Integrate all blocks with beans. -core = 7.x -files[] = plugins/all.inc -dependencies[] = bean -dependencies[] = block -dependencies[] = menu -package = Bean diff --git a/bean_all/bean_all.install b/bean_all/bean_all.install deleted file mode 100644 index 45d9273..0000000 --- a/bean_all/bean_all.install +++ /dev/null @@ -1,39 +0,0 @@ - 'Bean Settings', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('bean_all_settings_form'), - 'access arguments' => array('administer bean settings'), - 'type' => MENU_NORMAL_ITEM, - ); - - return $items; -} - -/** - * Implements hook_bean_types(). - */ -function bean_all_bean_types() { - $running = &drupal_static(__FUNCTION__ . "_running", FALSE); - - $plugins = array(); - - if (!$running) { - $running = TRUE; - foreach (module_implements('block_info') as $module) { - if ($module !== 'bean') { - _bean_all_bean_types($plugins, $module); - } - } - $running = FALSE; - } - - return $plugins; -} - -function _bean_all_bean_types(&$plugins, $module) { - $default = array( - 'file' => 'all.inc', - 'path' => drupal_get_path('module', 'bean_all') . '/plugins', - 'handler' => array( - 'class' => 'BeanAll', - 'parent' => 'bean', - 'file' => 'all.inc', - 'path' => drupal_get_path('module', 'bean_all') . '/plugins', - ), - ); - - $module_blocks = module_invoke($module, 'block_info'); - - if (!empty($module_blocks)) { - bean_all_filter_blocks($module_blocks, $module); - foreach ($module_blocks as $delta => $block) { - $block = (object) $block; - $block->module = $module; - $block->delta = $delta; - $name = "{$module}_{$delta}"; - $plugins[$name] = array( - 'label' => $block->info, - 'description' => $block->info, - 'name' => "$module-$delta", - 'block' => $block - ) + $default; - } - } -} - -/** - * Implements hook_bean_types_api_info(). - */ -function bean_all_bean_types_api_info() { - return array( - 'api' => 5, - ); -} - -/** - * Get the block blacklist - * - * @param $module - * The module to pull the blacklist of - * - * @return array - * if the array is empty then no blocks are allowed - */ -function bean_all_get_blacklist($module) { - $variable_name = bean_all_build_variable_name($module); - - return variable_get($variable_name); -} - -function bean_all_build_variable_name($module) { - $variable_name = "bean_all_blacklist"; - - if (isset($module)) { - $variable_name .= "_{$module}"; - } - - return $variable_name; -} - - -/** - * Implements hook_block_info_alter(). - * - * Remove the ability to place the blocks in admin/structure/blocks - */ -function bean_all_block_info_alter(&$blocks, $theme, $code_blocks) { - foreach ($blocks as $module => $module_blocks) { - bean_all_filter_blocks($module_blocks, $module); - foreach ($module_blocks as $delta => $block) { - $blocks[$module][$delta]['status'] = FALSE; - $blocks[$module][$delta]['disabled'] = FALSE; - } - } -} - -/** - * Filter a list of blocks for a module - */ -function bean_all_filter_blocks(&$blocks, $module) { - $black_list = bean_all_get_blacklist($module); - - if ($black_list === TRUE) { - $blocks = array(); - } - elseif (is_array($black_list)) { - $black_list = array_combine($black_list, $black_list); - $blocks = array_diff_key($blocks, $black_list); - } -} - -function bean_all_settings_form($form, &$form_state) { - $form = array(); - $module_info = system_rebuild_module_data(); - - drupal_set_title(t('Select Blocks to not appear as Block Types'), PASS_THROUGH); - - foreach (module_implements('block_info') as $module) { - if ($module !== 'bean') { - $module_blocks = module_invoke($module, 'block_info'); - $variable_name = bean_all_build_variable_name($module); - $form[$variable_name] = array( - '#title' => $module_info[$module]->info['name'], - '#type' => 'vertical_tabs', - ); - $form[$variable_name][$variable_name] = array( - '#type' => 'checkboxes', - '#default_value' => variable_get($variable_name, array()), - ); - - $options = array(); - foreach ($module_blocks as $delta => $block) { - $options[$delta] = $block['info']; - } - - $form[$variable_name][$variable_name]['#options'] = $options; - } - } - - return system_settings_form($form); -} diff --git a/bean_all/plugins/all.inc b/bean_all/plugins/all.inc deleted file mode 100644 index ef79392..0000000 --- a/bean_all/plugins/all.inc +++ /dev/null @@ -1,69 +0,0 @@ -block_info = $plugin_info['block']; - parent::__construct($plugin_info); - } - - public function values() { - $this->loadBlockConfig(); - $values = array_fill_keys(array_keys($this->block_config_form), array()); - foreach ($values as $key => $nothing) { - $values[$key] = isset($this->block_config_form[$key]['#default_value']) ? - $this->block_config_form[$key]['#default_value'] : ''; - } - - return $values; - } - - public function form($bean, $form, &$form_state) { - return $this->loadBlockConfig()->block_config_form; - } - - public function view($bean, $content, $view_mode = 'default', $langcode = NULL) { - $block_object = $this->getBlockInfo(); - $block_object->title = $block_object->info; - $block_object->enabled = $block_object->page_match = TRUE; - $blocks[$this->getBlockInfo('module') . "_" . $this->getBlockInfo('delta')] = $block_object; - - module_load_include('module', 'block', 'block'); - $block_content = _block_render_blocks($blocks); - $content += _block_get_renderable_array($block_content); - - $build[$this->getBlockInfo('module') . "_" . $this->getBlockInfo('delta')]['#contextual_links']['block'] - = array('block', array($bean->delta)); - - return $content; - } - - public function submit(Bean $bean) { - $bean_values = (array) $bean; - module_invoke($this->getBlockInfo('module'), 'block_save', $this->getBlockInfo('delta'), $bean_values); - return $this; - } - - protected function getBlockInfo($key = NULL) { - if (!empty($key) && isset($this->block_info->$key)) { - return $this->block_info->$key; - } - - return $this->block_info; - } - - protected function loadBlockConfig() { - if (!isset($this->block_config_form)) { - $this-> block_config_form = array(); - if ($settings = module_invoke($this->getBlockInfo('module'), 'block_configure', $this->getBlockInfo('delta'))) { - foreach ($settings as $k => $v) { - $this-> block_config_form[$k] = $v; - } - } - } - - return $this; - } -}