- <?php
-
- * @file
- * Install, update, and uninstall functions for the Filter module.
- */
-
- * Implements hook_schema().
- */
- function filter_schema() {
- $schema['cache_filter'] = backdrop_get_schema_unprocessed('system', 'cache');
- $schema['cache_filter']['description'] = 'Cache table for the Filter module to store already filtered pieces of text, identified by text format and hash of the text.';
-
- return $schema;
- }
-
- * @addtogroup updates-7.x-to-1.x
- * @{
- */
-
- * Convert filter formats to configuration.
- */
- function filter_update_1000() {
- if (!db_table_exists('filter_format')) {
- return;
- }
-
- $result = db_query('SELECT format, name, cache, status, weight FROM {filter_format}', array(), array('fetch' => PDO::FETCH_ASSOC));
- foreach ($result as $format) {
- $format_name = $format['format'];
-
-
- $format['roles'] = array_keys(user_roles(FALSE, 'use text format ' . $format['format']));
-
-
- $filters = db_query('SELECT name, module, status, weight, settings FROM {filter} WHERE format = :format ORDER BY weight, module, name', array(':format' => $format_name), array('fetch' => PDO::FETCH_ASSOC))->fetchAllAssoc('name');
- foreach ($filters as $name => &$filter) {
-
- unset($filter['name']);
- if ($filter['settings']) {
- $filter['settings'] = unserialize($filter['settings']);
- }
- }
- $format['filters'] = $filters;
-
-
- $config = config('filter.format.' . $format_name);
- $config->setData($format);
- $config->save();
- }
-
- db_drop_table('filter_format');
- db_drop_table('filter');
- }
-
- * Add a separate permission for image upload access.
- */
- function filter_update_1001() {
- user_role_grant_permissions(BACKDROP_AUTHENTICATED_ROLE, array('upload editor images'));
-
-
-
- $format_configs = config_get_names_with_prefix('filter.format.');
-
- foreach ($format_configs as $config_name) {
- $config = config($config_name);
- if ($config->get('editor')) {
- $editor_settings = (array) $config->get('editor_settings');
- $upload_settings = isset($editor_settings['image_upload']) ? $editor_settings['image_upload'] : array();
- $upload_settings['status'] = 1;
- $upload_settings += array(
- 'dimensions' => array('max_width' => '', 'max_height' => ''),
- 'max_size' => NULL,
- 'scheme' => 'public',
- 'directory' => 'inline-images',
- );
- $editor_settings['image_upload'] = $upload_settings;
- $config->set('editor_settings', $editor_settings);
- $config->save();
- }
- }
- }
-
- * Import the image_library view.
- */
- function filter_update_1002() {
- $view_config = array(
- 'name' => 'image_library',
- 'description' => 'Displays recently uploaded images for selection when creating content.',
- 'tag' => 'default',
- 'storage' => 4,
- 'disabled' => FALSE,
- 'base_table' => 'file_managed',
- 'human_name' => 'Image Library',
- 'core' => '1.7',
- 'display' => array(
- 'default' => array(
- 'display_title' => 'Master',
- 'display_plugin' => 'default',
- 'display_options' => array(
- 'query' => array(
- 'type' => 'views_query',
- 'options' => array(),
- ),
- 'access' => array(
- 'type' => 'perm',
- ),
- 'cache' => array(
- 'type' => 'none',
- ),
- 'exposed_form' => array(
- 'type' => 'basic',
- ),
- 'pager' => array(
- 'type' => 'mini',
- 'options' => array(
- 'items_per_page' => '20',
- 'offset' => '0',
- 'id' => '0',
- 'total_pages' => '',
- 'tags' => array(
- 'previous' => '‹ previous',
- 'next' => 'next ›',
- ),
- 'expose' => array(
- 'items_per_page' => 0,
- 'items_per_page_label' => 'Items per page',
- 'items_per_page_options' => '5, 10, 20, 40, 60',
- 'items_per_page_options_all' => 0,
- 'items_per_page_options_all_label' => '- All -',
- 'offset' => 0,
- 'offset_label' => 'Offset',
- ),
- ),
- ),
- 'style_plugin' => 'default',
- 'row_plugin' => 'fields',
- 'fields' => array(
- 'uri' => array(
- 'id' => 'uri',
- 'table' => 'file_managed',
- 'field' => 'uri',
- 'relationship' => 'none',
- 'group_type' => 'group',
- 'ui_name' => 'File: Path (thumbnail)',
- 'label' => '',
- 'exclude' => 1,
- 'alter' => array(
- 'alter_text' => 0,
- 'text' => '',
- 'make_link' => 0,
- 'path' => '',
- 'absolute' => 0,
- 'external' => 0,
- 'replace_spaces' => 0,
- 'path_case' => 'none',
- 'trim_whitespace' => 0,
- 'alt' => '',
- 'rel' => '',
- 'link_class' => '',
- 'prefix' => '',
- 'suffix' => '',
- 'target' => '',
- 'nl2br' => 0,
- 'max_length' => '',
- 'word_boundary' => 1,
- 'ellipsis' => 1,
- 'more_link' => 0,
- 'more_link_text' => '',
- 'more_link_path' => '',
- 'strip_tags' => 0,
- 'trim' => 0,
- 'preserve_tags' => '',
- 'html' => 0,
- ),
- 'element_type' => '',
- 'element_class' => '',
- 'element_label_type' => '',
- 'element_label_class' => '',
- 'element_label_colon' => FALSE,
- 'element_wrapper_type' => '',
- 'element_wrapper_class' => '',
- 'element_default_classes' => 1,
- 'empty' => '',
- 'hide_empty' => 0,
- 'empty_zero' => 0,
- 'hide_alter_empty' => 1,
- 'link_to_file' => 0,
- 'file_download_path' => 1,
- 'image_style' => 'thumbnail',
- ),
- 'uri_1' => array(
- 'id' => 'uri_1',
- 'table' => 'file_managed',
- 'field' => 'uri',
- 'relationship' => 'none',
- 'group_type' => 'group',
- 'ui_name' => 'File: Path (full)',
- 'label' => '',
- 'exclude' => 1,
- 'alter' => array(
- 'alter_text' => 0,
- 'text' => '',
- 'make_link' => 0,
- 'path' => '',
- 'absolute' => 0,
- 'external' => 0,
- 'replace_spaces' => 0,
- 'path_case' => 'none',
- 'trim_whitespace' => 0,
- 'alt' => '',
- 'rel' => '',
- 'link_class' => '',
- 'prefix' => '',
- 'suffix' => '',
- 'target' => '',
- 'nl2br' => 0,
- 'max_length' => '',
- 'word_boundary' => 1,
- 'ellipsis' => 1,
- 'more_link' => 0,
- 'more_link_text' => '',
- 'more_link_path' => '',
- 'strip_tags' => 0,
- 'trim' => 0,
- 'preserve_tags' => '',
- 'html' => 0,
- ),
- 'element_type' => '',
- 'element_class' => '',
- 'element_label_type' => '',
- 'element_label_class' => '',
- 'element_label_colon' => FALSE,
- 'element_wrapper_type' => '',
- 'element_wrapper_class' => '',
- 'element_default_classes' => 1,
- 'empty' => '',
- 'hide_empty' => 0,
- 'empty_zero' => 0,
- 'hide_alter_empty' => 1,
- 'link_to_file' => 0,
- 'file_download_path' => 1,
- 'image_style' => '',
- ),
- 'fid' => array(
- 'id' => 'fid',
- 'table' => 'file_managed',
- 'field' => 'fid',
- 'relationship' => 'none',
- 'group_type' => 'group',
- 'ui_name' => '',
- 'label' => '',
- 'exclude' => 0,
- 'alter' => array(
- 'alter_text' => 1,
- 'text' => '<img class="image-library-image" src="[uri]" data-file-url="[uri_1]" data-fid="[fid]" />',
- 'make_link' => 0,
- 'path' => '',
- 'absolute' => 0,
- 'external' => 0,
- 'replace_spaces' => 0,
- 'path_case' => 'none',
- 'trim_whitespace' => 0,
- 'alt' => '',
- 'rel' => '',
- 'link_class' => '',
- 'prefix' => '',
- 'suffix' => '',
- 'target' => '',
- 'nl2br' => 0,
- 'max_length' => '',
- 'word_boundary' => 1,
- 'ellipsis' => 1,
- 'more_link' => 0,
- 'more_link_text' => '',
- 'more_link_path' => '',
- 'strip_tags' => 0,
- 'trim' => 0,
- 'preserve_tags' => '',
- 'html' => 0,
- ),
- 'element_type' => '0',
- 'element_class' => '',
- 'element_label_type' => '',
- 'element_label_class' => '',
- 'element_label_colon' => FALSE,
- 'element_wrapper_type' => '0',
- 'element_wrapper_class' => '',
- 'element_default_classes' => 0,
- 'empty' => '',
- 'hide_empty' => 0,
- 'empty_zero' => 0,
- 'hide_alter_empty' => 1,
- 'link_to_file' => 0,
- ),
- 'filename' => array(
- 'id' => 'filename',
- 'table' => 'file_managed',
- 'field' => 'filename',
- 'relationship' => 'none',
- 'group_type' => 'group',
- 'ui_name' => '',
- 'label' => '',
- 'exclude' => 0,
- 'alter' => array(
- 'alter_text' => 0,
- 'text' => '',
- 'make_link' => 0,
- 'path' => '',
- 'absolute' => 0,
- 'external' => 0,
- 'replace_spaces' => 0,
- 'path_case' => 'none',
- 'trim_whitespace' => 0,
- 'alt' => '',
- 'rel' => '',
- 'link_class' => '',
- 'prefix' => '',
- 'suffix' => '',
- 'target' => '',
- 'nl2br' => 0,
- 'max_length' => '',
- 'word_boundary' => 0,
- 'ellipsis' => 0,
- 'more_link' => 0,
- 'more_link_text' => '',
- 'more_link_path' => '',
- 'strip_tags' => 0,
- 'trim' => 0,
- 'preserve_tags' => '',
- 'html' => 0,
- ),
- 'element_type' => 'p',
- 'element_class' => 'image-library-filename',
- 'element_label_type' => '',
- 'element_label_class' => '',
- 'element_label_colon' => FALSE,
- 'element_wrapper_type' => '',
- 'element_wrapper_class' => '',
- 'element_default_classes' => 0,
- 'empty' => '',
- 'hide_empty' => 0,
- 'empty_zero' => 0,
- 'hide_alter_empty' => 1,
- 'link_to_file' => 0,
- ),
- ),
- 'filters' => array(
- 'filemime' => array(
- 'id' => 'filemime',
- 'table' => 'file_managed',
- 'field' => 'filemime',
- 'relationship' => 'none',
- 'group_type' => 'group',
- 'ui_name' => '',
- 'operator' => 'starts',
- 'value' => 'image/',
- 'group' => '1',
- 'exposed' => FALSE,
- 'expose' => array(
- 'operator_id' => FALSE,
- 'label' => '',
- 'description' => '',
- 'use_operator' => FALSE,
- 'operator' => '',
- 'identifier' => '',
- 'required' => FALSE,
- 'remember' => FALSE,
- 'multiple' => FALSE,
- 'remember_roles' => array(
- 'authenticated' => 'authenticated',
- ),
- ),
- 'is_grouped' => FALSE,
- 'group_info' => array(
- 'label' => '',
- 'description' => '',
- 'identifier' => '',
- 'optional' => TRUE,
- 'widget' => 'select',
- 'multiple' => FALSE,
- 'remember' => 0,
- 'default_group' => 'All',
- 'default_group_multiple' => array(),
- 'group_items' => array(),
- ),
- ),
- 'uri' => array(
- 'id' => 'uri',
- 'table' => 'file_managed',
- 'field' => 'uri',
- 'relationship' => 'none',
- 'group_type' => 'group',
- 'ui_name' => '',
- 'operator' => 'starts',
- 'value' => 'public://',
- 'group' => '1',
- 'exposed' => FALSE,
- 'expose' => array(
- 'operator_id' => FALSE,
- 'label' => '',
- 'description' => '',
- 'use_operator' => FALSE,
- 'operator' => '',
- 'identifier' => '',
- 'required' => FALSE,
- 'remember' => FALSE,
- 'multiple' => FALSE,
- 'remember_roles' => array(
- 'authenticated' => 'authenticated',
- ),
- ),
- 'is_grouped' => FALSE,
- 'group_info' => array(
- 'label' => '',
- 'description' => '',
- 'identifier' => '',
- 'optional' => TRUE,
- 'widget' => 'select',
- 'multiple' => FALSE,
- 'remember' => 0,
- 'default_group' => 'All',
- 'default_group_multiple' => array(),
- 'group_items' => array(),
- ),
- ),
- ),
- 'sorts' => array(),
- 'style_options' => array(
- 'grouping' => array(),
- 'row_class' => 'image-library-choose-file',
- 'default_row_class' => 0,
- 'row_class_special' => 0,
- ),
- 'use_ajax' => TRUE,
- 'header' => array(),
- 'row_options' => array(
- 'default_field_elements' => 0,
- 'inline' => array(),
- 'separator' => '',
- 'hide_empty' => 0,
- ),
- 'empty' => array(
- 'area' => array(
- 'id' => 'area',
- 'table' => 'views',
- 'field' => 'area',
- 'relationship' => 'none',
- 'group_type' => 'group',
- 'ui_name' => '',
- 'label' => '',
- 'empty' => TRUE,
- 'content' => "<p>No available images.</p>\r\n",
- 'format' => 'filtered_html',
- 'tokenize' => 0,
- ),
- ),
- ),
- ),
- ),
- );
- $config = config('views.view.image_library');
- if ($config->isNew()) {
- $config->setData($view_config);
- $config->save();
- }
- }
-
- * Make the image_library view module-provided.
- */
- function filter_update_1003() {
- $config = config('views.view.image_library');
- $config->set('module', 'filter');
- $config->save();
- }
-
- * Add an exposed filename filter to the image_library view.
- */
- function filter_update_1004() {
-
- $config = config('views.view.image_library');
-
-
- if ($config->get('storage') == VIEWS_STORAGE_DEFAULT) {
- $view_config = $config->get();
- $view_config['display']['default']['display_options']['exposed_form'] = array(
- 'type' => 'basic',
- 'options' => array(
- "reset_button" => 0,
- "reset_button_label" => "Reset",
- "exposed_sorts_label" => "Sort by",
- "expose_sort_order" => 1,
- "sort_asc_label" => "Asc",
- "sort_desc_label" => "Desc",
- "autosubmit" => 0,
- "autosubmit_hide" => 1
- ),
- );
- $view_config['display']['default']['display_options']['filters']['filename'] = array(
- 'id' => 'filename',
- 'table' => 'file_managed',
- 'field' => 'filename',
- 'relationship' => 'none',
- 'group_type' => 'group',
- 'ui_name' => '',
- 'operator' => 'contains',
- 'value' => '',
- 'group' => '1',
- 'exposed' => TRUE,
- 'expose' => array(
- 'operator_id' => 'filename_op',
- 'label' => 'Filename',
- 'description' => '',
- 'use_operator' => FALSE,
- 'operator' => 'filename_op',
- 'identifier' => 'filename',
- 'required' => FALSE,
- 'remember' => FALSE,
- 'multiple' => FALSE,
- 'remember_roles' => array(
- 'authenticated' => 'authenticated',
- ),
- ),
- 'is_grouped' => FALSE,
- 'group_info' => array(
- 'label' => '',
- 'description' => '',
- 'identifier' => '',
- 'optional' => TRUE,
- 'widget' => 'select',
- 'multiple' => FALSE,
- 'remember' => 0,
- 'default_group' => 'All',
- 'default_group_multiple' => array(),
- 'group_items' => array(),
- ),
- );
- $view_config['display']['default']['display_options']['hide_admin_links'] = TRUE;
- $config->setData($view_config);
- $config->save();
- }
- }
-
- * @} End of "addtogroup updates-7.x-to-1.x"
- * The next series of updates should start at 2000.
- */