コード例 #1
0
 /**
  * Prints a listing of admin tasks, organized by module.
  *
  * @return array
  *   A render array containing the listing.
  */
 public function index()
 {
     $module_info = system_get_info('module');
     foreach ($module_info as $module => $info) {
         $module_info[$module] = new \stdClass();
         $module_info[$module]->info = $info;
     }
     uasort($module_info, 'system_sort_modules_by_info_name');
     $menu_items = array();
     foreach ($module_info as $module => $info) {
         // Only display a section if there are any available tasks.
         if ($admin_tasks = system_get_module_admin_tasks($module, $info->info)) {
             // Sort links by title.
             uasort($admin_tasks, array('\\Drupal\\Component\\Utility\\SortArray', 'sortByTitleElement'));
             // Move 'Configure permissions' links to the bottom of each section.
             $permission_key = "user.admin_permissions.{$module}";
             if (isset($admin_tasks[$permission_key])) {
                 $permission_task = $admin_tasks[$permission_key];
                 unset($admin_tasks[$permission_key]);
                 $admin_tasks[$permission_key] = $permission_task;
             }
             $menu_items[$info->info['name']] = array($info->info['description'], $admin_tasks);
         }
     }
     $output = array('#theme' => 'system_admin_index', '#menu_items' => $menu_items);
     return $output;
 }
コード例 #2
0
ファイル: Extension.php プロジェクト: hugronaphor/cornel
 /**
  * {@inheritdoc}
  *
  * @todo Determine whether this needs to be cached.
  */
 public function getLibraryDependencies()
 {
     // @todo Make this unit-testable.
     $info = system_get_info($this->getType(), $this->getName());
     assert('!empty($info)');
     return isset($info['library_dependencies']) ? $info['library_dependencies'] : [];
 }
コード例 #3
0
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state, $bundle_name = NULL) {
    $this->currentBundle = $this->assigner->loadBundle($bundle_name);

    $settings = $this->currentBundle->getAssignmentSettings(self::METHOD_ID);
    $this->setTypeSelect($form, $settings['types'], $this->t('exclude'));

    $module_settings = $settings['module'];
    $curated_settings = $settings['curated'];

    $form['curated'] = array(
      '#type' => 'checkbox',
      '#title' => t('Exclude designated site-specific configuration'),
      '#default_value' => $curated_settings,
      '#description' => $this->t('Select this option to exclude from packaging items on a curated list of site-specific configuration.'),
    );

    $form['module'] = array(
      '#type' => 'container',
      '#tree' => TRUE,
    );
    $form['module']['enabled'] = array(
      '#type' => 'checkbox',
      '#title' => t('Exclude module-provided entity configuration'),
      '#default_value' => $module_settings['enabled'],
      '#description' => $this->t('Select this option to exclude from packaging any configuration that is provided by already enabled modules. Note that <a href="!url">simple configuration</a> will not be excluded as it is always module-provided.', array('!url' => 'http://www.drupal.org/node/1809490')),
      '#attributes' => array(
        'data-module-enabled' => 'status',
      ),
    );

    $show_if_module_enabled_checked = array(
      'visible' => array(
        ':input[data-module-enabled="status"]' => array('checked' => TRUE),
      ),
    );

    $info = system_get_info('module', drupal_get_profile());
    $form['module']['profile'] = array(
      '#type' => 'checkbox',
      '#title' => t("Don't exclude install profile's configuration"),
      '#default_value' => $module_settings['profile'],
      '#description' => $this->t("Select this option to not exclude from packaging any configuration that is provided by this site's install profile, %profile.", array('%profile' => $info['name'])),
      '#states' => $show_if_module_enabled_checked,
    );

    $machine_name = $this->currentBundle->getMachineName();
    $machine_name = !empty($machine_name) ? $machine_name : t('none');
    $form['module']['namespace'] = array(
      '#type' => 'checkbox',
      '#title' => t("Don't exclude configuration by namespace"),
      '#default_value' => $module_settings['namespace'],
      '#description' => $this->t("Select this option to not exclude from packaging any configuration that is provided by modules with the package namespace (currently %namespace).", array('%namespace' => $machine_name)),
      '#states' => $show_if_module_enabled_checked,
    );

    $this->setActions($form);

    return $form;
  }
コード例 #4
0
ファイル: Extension.php プロジェクト: eloiv/botafoc.cat
 /**
  * {@inheritdoc}
  *
  * @todo Determine whether this needs to be cached.
  */
 public function getLibraryDependencies() {
   // @todo Make this unit-testable.
   $type = $this->getType();
   // system_get_info() lists profiles as type "module"
   $type = $type == 'profile' ? 'module' : $type;
   $info = system_get_info($type, $this->getName());
   assert('!empty($info)');
   return isset($info['library_dependencies']) ? $info['library_dependencies'] : [];
 }
コード例 #5
0
 /**
  * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::defineOptions().
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $modules = system_get_info('module');
     $names = array();
     foreach ($modules as $name => $module) {
         $names[$name] = $module['name'];
     }
     $form['data_module'] = array('#title' => $this->t('Module name'), '#type' => 'select', '#description' => $this->t('The module which sets this user data.'), '#default_value' => $this->options['data_module'], '#options' => $names);
     $form['data_name'] = array('#title' => $this->t('Name'), '#type' => 'textfield', '#description' => $this->t('The name of the data key.'), '#default_value' => $this->options['data_name']);
 }
コード例 #6
0
ファイル: BlockManager.php プロジェクト: anatalsceo/en-classe
 /**
  * Gets the name of the module.
  *
  * @param string $module
  *   The machine name of a module.
  *
  * @return string
  *   The human-readable module name if it exists, otherwise the
  *   machine-readable module name.
  */
 protected function getModuleName($module)
 {
     // Gather module data.
     if (!isset($this->moduleData)) {
         $this->moduleData = system_get_info('module');
     }
     // If the module exists, return its human-readable name.
     if (isset($this->moduleData[$module])) {
         return $this->t($this->moduleData[$module]['name']);
     }
     // Otherwise, return the machine name.
     return $module;
 }
コード例 #7
0
 public function getValueOptions()
 {
     if (!isset($this->valueOptions)) {
         $module_info = system_get_info('module');
         $permissions = $this->permissionHandler->getPermissions();
         foreach ($permissions as $perm => $perm_item) {
             $provider = $perm_item['provider'];
             $display_name = $module_info[$provider]['name'];
             $this->valueOptions[$display_name][$perm] = String::checkPlain(strip_tags($perm_item['title']));
         }
     } else {
         return $this->valueOptions;
     }
 }
コード例 #8
0
ファイル: Permission.php プロジェクト: alnutile/drunatra
 public function buildOptionsForm(&$form, &$form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $perms = array();
     $module_info = system_get_info('module');
     // Get list of permissions
     foreach (\Drupal::moduleHandler()->getImplementations('permission') as $module) {
         $permissions = \Drupal::moduleHandler()->invoke($module, 'permission');
         foreach ($permissions as $name => $perm) {
             $perms[$module_info[$module]['name']][$name] = strip_tags($perm['title']);
         }
     }
     ksort($perms);
     $form['perm'] = array('#type' => 'select', '#options' => $perms, '#title' => t('Permission'), '#default_value' => $this->options['perm'], '#description' => t('Only users with the selected permission flag will be able to access this display. Note that users with "access all views" can see any view, regardless of other permissions.'));
 }
コード例 #9
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     $form['type'] = array('#type' => 'radios', '#title' => t('Type of user filter value to allow'), '#options' => array('uid' => t('Only allow numeric UIDs'), 'name' => t('Only allow string usernames'), 'either' => t('Allow both numeric UIDs and string usernames')), '#default_value' => $this->options['type']);
     $perms = array();
     $module_info = system_get_info('module');
     // Get list of permissions
     $module_handler = \Drupal::moduleHandler();
     foreach ($module_handler->getImplementations('permission') as $module) {
         $permissions = $module_handler->invoke($module, 'permission');
         foreach ($permissions as $name => $perm) {
             $perms[$module_info[$module]['name']][$name] = strip_tags($perm['title']);
         }
     }
     asort($perms);
     $form['perm'] = array('#type' => 'select', '#options' => $perms, '#title' => t('Permission'), '#default_value' => $this->options['perm'], '#description' => t('Users with the selected permission flag will be able to bypass validation.'));
 }
コード例 #10
0
 /**
  * Assert that core required modules cannot be disabled.
  */
 function testDisableRequired()
 {
     $module_info = system_get_info('module');
     $this->drupalGet('admin/modules');
     foreach ($module_info as $module => $info) {
         // Check to make sure the checkbox for each required module is disabled
         // and checked (or absent from the page if the module is also hidden).
         if (!empty($info['required'])) {
             $field_name = "modules[{$info['package']}][{$module}][enable]";
             if (empty($info['hidden'])) {
                 $this->assertFieldByXPath("//input[@name='{$field_name}' and @disabled='disabled' and @checked='checked']", '', format_string('Field @name was disabled and checked.', array('@name' => $field_name)));
             } else {
                 $this->assertNoFieldByName($field_name);
             }
         }
     }
 }
コード例 #11
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $bundle_name = NULL)
 {
     $this->currentBundle = $this->assigner->loadBundle($bundle_name);
     $settings = $this->currentBundle->getAssignmentSettings(self::METHOD_ID);
     $this->setConfigTypeSelect($form, $settings['types']['config'], $this->t('exclude'));
     $module_settings = $settings['module'];
     $curated_settings = $settings['curated'];
     $form['curated'] = array('#type' => 'checkbox', '#title' => $this->t('Exclude designated site-specific configuration'), '#default_value' => $curated_settings, '#description' => $this->t('Select this option to exclude from packaging items on a curated list of site-specific configuration.'));
     $form['module'] = array('#type' => 'container', '#tree' => TRUE);
     $form['module']['installed'] = array('#type' => 'checkbox', '#title' => $this->t('Exclude installed module-provided entity configuration'), '#default_value' => $module_settings['installed'], '#description' => $this->t('Select this option to exclude from packaging any configuration that is provided by already installed modules.'), '#attributes' => array('data-module-installed' => 'status'));
     $show_if_module_installed_checked = array('visible' => array(':input[data-module-installed="status"]' => array('checked' => TRUE)));
     $info = system_get_info('module', drupal_get_profile());
     $form['module']['profile'] = array('#type' => 'checkbox', '#title' => $this->t("Don't exclude install profile's configuration"), '#default_value' => $module_settings['profile'], '#description' => $this->t("Select this option to not exclude from packaging any configuration that is provided by this site's install profile, %profile.", array('%profile' => $info['name'])), '#states' => $show_if_module_installed_checked);
     $machine_name = $this->currentBundle->getMachineName();
     $machine_name = !empty($machine_name) ? $machine_name : t('none');
     $form['module']['namespace'] = array('#type' => 'checkbox', '#title' => $this->t("Don't exclude non-installed configuration by namespace"), '#default_value' => $module_settings['namespace'], '#description' => $this->t("Select this option to not exclude from packaging any configuration that is provided by non-installed modules with the package namespace (currently %namespace).", array('%namespace' => $machine_name)), '#states' => $show_if_module_installed_checked, '#attributes' => array('data-namespace' => 'status'));
     $show_if_namespace_checked = array('visible' => array(':input[data-namespace="status"]' => array('checked' => TRUE), ':input[data-module-installed="status"]' => array('checked' => TRUE)));
     $form['module']['namespace_any'] = array('#type' => 'checkbox', '#title' => $this->t("Don't exclude ANY configuration by namespace"), '#default_value' => $module_settings['namespace_any'], '#description' => $this->t("Select this option to not exclude from packaging any configuration that is provided by ANY modules with the package namespace (currently %namespace).\n        Warning: Can cause installed configuration to be reassigned to different packages.", array('%namespace' => $machine_name)), '#states' => $show_if_namespace_checked);
     $this->setActions($form);
     return $form;
 }
コード例 #12
0
ファイル: Permissions.php プロジェクト: anatalsceo/en-classe
 public function getValueOptions()
 {
     if (!isset($this->value_options)) {
         $module_info = system_get_info('module');
         // Get a list of all the modules implementing a hook_permission() and sort by
         // display name.
         $modules = array();
         foreach ($this->moduleHandler->getImplementations('permission') as $module) {
             $modules[$module] = $module_info[$module]['name'];
         }
         asort($modules);
         $this->value_options = array();
         foreach ($modules as $module => $display_name) {
             if ($permissions = $this->moduleHandler->invoke($module, 'permission')) {
                 foreach ($permissions as $perm => $perm_item) {
                     $this->value_options[$display_name][$perm] = String::checkPlain(strip_tags($perm_item['title']));
                 }
             }
         }
     } else {
         return $this->value_options;
     }
 }
コード例 #13
0
 /**
  * Implements Mollom::getClientInformation().
  */
 public function getClientInformation()
 {
     // Retrieve Drupal distribution and installation profile information.
     $profile = drupal_get_profile();
     $profile_info = system_get_info('module', $profile) + array('distribution_name' => 'Drupal', 'version' => \Drupal::VERSION);
     // Retrieve Mollom module information.
     $mollom_info = system_get_info('module', 'mollom');
     if (empty($mollom_info['version'])) {
         // Manually build a module version string for repository checkouts.
         $mollom_info['version'] = \Drupal::CORE_COMPATIBILITY . '-1.x-dev';
     }
     $data = array('platformName' => $profile_info['distribution_name'], 'platformVersion' => $profile_info['version'], 'clientName' => $mollom_info['name'], 'clientVersion' => $mollom_info['version']);
     return $data;
 }
コード例 #14
0
ファイル: ModuleHandler.php プロジェクト: aWEBoLabs/taxi
 /**
  * {@inheritdoc}
  */
 public function getName($module)
 {
     $info = system_get_info('module', $module);
     return isset($info['name']) ? $info['name'] : $module;
 }
コード例 #15
0
/**
 * Returns the module version as defined in the .info file for this module
 * @return unknown
 */
function get_vals_version()
{
    $info_data = system_get_info('module', 'vals_soc');
    return $info_data['version'];
}
コード例 #16
0
 /**
  * Tests that theme info can be altered by a module.
  *
  * @see module_test_system_info_alter()
  */
 function testThemeInfoAlter()
 {
     $name = 'seven';
     $this->container->get('state')->set('module_test.hook_system_info_alter', TRUE);
     $module_handler = $this->container->get('module_handler');
     $this->themeHandler()->enable(array($name));
     $themes = $this->themeHandler()->listInfo();
     $this->assertFalse(isset($themes[$name]->info['regions']['test_region']));
     $module_handler->install(array('module_test'), FALSE);
     $this->assertTrue($module_handler->moduleExists('module_test'));
     $themes = $this->themeHandler()->listInfo();
     $this->assertTrue(isset($themes[$name]->info['regions']['test_region']));
     // Legacy assertions.
     // @todo Remove once theme initialization/info has been modernized.
     // @see https://drupal.org/node/2228093
     $info = system_get_info('theme', $name);
     $this->assertTrue(isset($info['regions']['test_region']));
     $regions = system_region_list($name);
     $this->assertTrue(isset($regions['test_region']));
     $system_list = system_list('theme');
     $this->assertTrue(isset($system_list[$name]->info['regions']['test_region']));
     $module_handler->uninstall(array('module_test'));
     $this->assertFalse($module_handler->moduleExists('module_test'));
     $themes = $this->themeHandler()->listInfo();
     $this->assertFalse(isset($themes[$name]->info['regions']['test_region']));
     // Legacy assertions.
     // @todo Remove once theme initialization/info has been modernized.
     // @see https://drupal.org/node/2228093
     $info = system_get_info('theme', $name);
     $this->assertFalse(isset($info['regions']['test_region']));
     $regions = system_region_list($name);
     $this->assertFalse(isset($regions['test_region']));
     $system_list = system_list('theme');
     $this->assertFalse(isset($system_list[$name]->info['regions']['test_region']));
 }
コード例 #17
0
ファイル: template.php プロジェクト: rtdean93/tbytam
/**
 * Retrieves the value associated with the specified key from the current theme.
 * If the key is not found, the specified default value will be returned instead.
 *
 * @param <string> $key
 *   The name of the key.
 * @param <mixed> $default
 *   The default value, returned if the property key is not found in the current
 *   theme.
 * @return <mixed>
 *   The value associated with the specified key, or the default value.
 */
function _carbon_variable_get($key, $default) {
  global $theme;
  $themes_info =& drupal_static(__FUNCTION__);
  if (!isset($themes_info[$theme])) {
    $themes_info = system_get_info('theme');
  }

  $value = $themes_info[$theme];
  foreach (explode('/', $key) as $part) {
    if (!isset($value[$part])) {
      return $default;
    }
    $value = $value[$part];
  }
  return $value;
}
コード例 #18
0
ファイル: HelpController.php プロジェクト: scratch/gai
 /**
  * Prints a page listing general help for a module.
  *
  * @param string $name
  *   A module name to display a help page for.
  *
  * @return array
  *   A render array as expected by drupal_render().
  *
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 public function helpPage($name)
 {
     $build = array();
     if ($this->moduleHandler()->implementsHook($name, 'help')) {
         $module_name = $this->moduleHandler()->getName($name);
         $build['#title'] = SafeMarkup::checkPlain($module_name);
         $temp = $this->moduleHandler()->invoke($name, 'help', array("help.page.{$name}", $this->routeMatch));
         if (empty($temp)) {
             $build['top']['#markup'] = $this->t('No help is available for module %module.', array('%module' => $module_name));
         } else {
             $build['top']['#markup'] = $temp;
         }
         // Only print list of administration pages if the module in question has
         // any such pages associated with it.
         $admin_tasks = system_get_module_admin_tasks($name, system_get_info('module', $name));
         if (!empty($admin_tasks)) {
             $links = array();
             foreach ($admin_tasks as $task) {
                 $link['url'] = $task['url'];
                 $link['title'] = $task['title'];
                 $links[] = $link;
             }
             $build['links'] = array('#theme' => 'links__help', '#heading' => array('level' => 'h3', 'text' => $this->t('@module administration pages', array('@module' => $module_name))), '#links' => $links);
         }
         return $build;
     } else {
         throw new NotFoundHttpException();
     }
 }
コード例 #19
0
ファイル: theme-settings.php プロジェクト: joshirohit100/dcd2
/**
 * Implements hook_form_FORM_alter().
 */
function omega_form_system_theme_settings_alter(&$form, &$form_state, $form_id = NULL)
{
    // General "alters" use a form id. Settings should not be set here. The only
    // thing useful about this is if you need to alter the form for the running
    // theme and *not* the the me setting. @see http://drupal.org/node/943212
    if (isset($form_id)) {
        return;
    }
    if (variable_get('theme_' . $GLOBALS['theme_key'] . '_settings')) {
        // Alert the user that the theme settings are served from a variable.
        drupal_set_message(t('The settings for this theme are currently served from a variable. You might want to export them to your .info file.'), 'warning', FALSE);
    }
    $form['omega_enable_warning'] = array('#type' => 'checkbox', '#title' => t('Show a warning if Omega is used directly'), '#description' => t('You can disable this warning message permanently, however, please be aware that Omega is a base theme and should not be used directly. You should always create a sub-theme instead.'), '#default_value' => omega_theme_get_setting('omega_enable_warning', TRUE), '#weight' => -20, '#access' => $GLOBALS['theme_key'] === 'omega');
    // Include the template.php and theme-settings.php files for all the themes in
    // the theme trail.
    foreach (omega_theme_trail() as $theme => $name) {
        $path = drupal_get_path('theme', $theme);
        $filename = DRUPAL_ROOT . '/' . $path . '/template.php';
        if (file_exists($filename)) {
            require_once $filename;
        }
        $filename = DRUPAL_ROOT . '/' . $path . '/theme-settings.php';
        if (file_exists($filename)) {
            require_once $filename;
        }
    }
    // Get the admin theme so we can set a class for styling this form.
    $admin = drupal_html_class(variable_get('admin_theme', $GLOBALS['theme']));
    $form['#prefix'] = '<div class="admin-theme-' . $admin . '">';
    $form['#suffix'] = '</div>';
    // Add some custom styling and functionality to our theme settings form.
    $form['#attached']['css'][] = drupal_get_path('theme', 'omega') . '/css/omega.admin.css';
    $form['#attached']['js'][] = drupal_get_path('theme', 'omega') . '/js/omega.admin.min.js';
    // Collapse all the core theme settings tabs in order to have the form actions
    // visible all the time without having to scroll.
    foreach (element_children($form) as $key) {
        if ($form[$key]['#type'] == 'fieldset') {
            $form[$key]['#collapsible'] = TRUE;
            $form[$key]['#collapsed'] = TRUE;
        }
    }
    if ($extensions = omega_extensions(NULL, TRUE)) {
        $form['omega'] = array('#type' => 'vertical_tabs', '#weight' => -10);
        // Load the theme settings for all enabled extensions.
        foreach ($extensions as $extension => $info) {
            $form['omega'][$extension] = array('#type' => 'fieldset', '#title' => $info['info']['name'], '#attributes' => array('class' => array('omega-extension')));
            $errors = array();
            if (!empty($info['info']['dependencies'])) {
                foreach ($info['info']['dependencies'] as $dependency) {
                    $dependency = drupal_parse_dependency($dependency);
                    // Check if the module exists.
                    if (!($module = system_get_info('module', $dependency['name']))) {
                        $errors[] = t('This extension requires the @module module.', array('@module' => ucwords(str_replace('_', ' ', $dependency['name']))));
                    } elseif (($version = omega_check_incompatibility($dependency, $module['version'])) !== NULL) {
                        $errors[] = t('This extension requires @module @version. The currently installed version is @installed.', array('@module' => $module['name'], '@version' => $version, '@installed' => !empty($module['version']) ? $module['version'] : t('undetermined')));
                    }
                }
                if (!empty($errors)) {
                    $form['omega'][$extension]['errors'] = array('#type' => 'item', '#title' => t('Missing requirements'), '#markup' => '<ul><li>' . implode('</li><li>', $errors) . '</li></ul>', '#weight' => -20, '#name' => 'omega-requirements');
                }
            }
            // Disable all options if there were any errors.
            $form['omega'][$extension]['#disabled'] = !empty($errors) || variable_get('omega_toggle_extension_' . $extension) !== NULL;
            $form['omega'][$extension]['omega_toggle_extension_' . $extension] = array('#type' => 'checkbox', '#title' => t('Enable @extension extension', array('@extension' => $info['info']['name'])) . (variable_get('omega_toggle_extension_' . $extension) !== NULL ? ' <span class="marker">(' . t('overridden') . ')</span>' : ''), '#description' => t('This setting can be overridden with an equally named variable (@name) so you can control it on a per-environment basis by setting it in your settings.php file.', array('@name' => 'omega_toggle_extension_' . $extension)), '#default_value' => omega_extension_enabled($extension), '#weight' => -10);
            $element = array();
            // Load the implementation for this extensions and invoke the according
            // hook.
            $file = $info['path'] . '/' . $extension . '.settings.inc';
            if (is_file($file)) {
                require_once $file;
            }
            $function = $info['theme'] . '_extension_' . $extension . '_settings_form';
            if (function_exists($function)) {
                // By default, each extension resides in a vertical tab.
                $element = $function($element, $form, $form_state) + array('#type' => 'fieldset', '#title' => t('@extension extension configuration', array('@extension' => $info['info']['name'])), '#description' => $info['info']['description'], '#attributes' => array('class' => array('omega-extension-settings')), '#states' => array('disabled' => array('input[name="omega_toggle_extension_' . $extension . '"]' => array('checked' => FALSE))));
            }
            drupal_alter('extension_' . $extension . '_settings_form', $element, $form, $form_state);
            if (element_children($element)) {
                // Append the extension form to the theme settings form if it has any
                // children.
                $form['omega'][$extension]['settings'] = $element;
            }
        }
    }
    // Custom option for toggling the main content blog on the front page.
    $form['theme_settings']['omega_toggle_front_page_content'] = array('#type' => 'checkbox', '#title' => t('Front page content'), '#description' => t('Allow the main content block to be rendered on the front page.'), '#default_value' => omega_theme_get_setting('omega_toggle_front_page_content', TRUE));
    // We need a custom form submit handler for processing some of the values.
    $form['#submit'][] = 'omega_theme_settings_form_submit';
    // Store the extensions in an array so we can loop over them in the submit
    // callback.
    $form_state['extensions'] = array_keys($extensions);
}
コード例 #20
0
 /**
  * {@inheritdoc}
  *
  * Sets the admin configs for each field.
  *
  * @param array &$form The brafton config form.
  * @param object $form_state the FormStateInterface object containing current state of form.
  *
  * @return method parent::submitForm Submits the form.
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $config = $this->config('brafton_importer.settings');
     // Permanently save the CTA images
     $file_value = $form_state->getValue('brafton_video_end_cta_button_image');
     if ($file_value) {
         $file = file_load($file_value[0]);
         $file_usage = \Drupal::service('file.usage');
         $file_usage->add($file, 'brafton_importer', 'node', $file->id());
         $config->set('brafton_importer.brafton_video_end_cta_button_image_url', $file->getFileUri());
     }
     $file_value = $form_state->getValue('brafton_video_end_cta_background');
     if ($file_value) {
         $file = file_load($file_value[0]);
         $file_usage = \Drupal::service('file.usage');
         $file_usage->add($file, 'brafton_importer', 'node', $file->id());
         $config->set('brafton_importer.brafton_video_end_cta_background_url', $file->getFileUri());
     }
     foreach ($form['brafton_general_options'] as $field => $field_value) {
         $config->set('brafton_importer.' . $field, $form_state->getValue($field));
     }
     foreach ($form['brafton_article_options'] as $field => $field_value) {
         $config->set('brafton_importer.' . $field, $form_state->getValue($field));
     }
     foreach ($form['brafton_video_options'] as $field => $field_value) {
         $config->set('brafton_importer.' . $field, $form_state->getValue($field));
     }
     foreach ($form['brafton_cta_options'] as $field => $field_value) {
         $config->set('brafton_importer.' . $field, $form_state->getValue($field));
     }
     foreach ($form['brafton_error_options'] as $field => $field_value) {
         $config->set('brafton_importer.' . $field, $form_state->getValue($field));
     }
     $config->save();
     $module_info = system_get_info('module', 'brafton_importer');
     debug($module_info);
     return parent::submitForm($form, $form_state);
 }
コード例 #21
0
 private static function getDrupalModuleVersion()
 {
     $info = system_get_info('module', 'opcache');
     return $info['version'];
 }
コード例 #22
0
 /**
  * Get Acquia subscription from Acquia Network.
  *
  * @param string $id Network ID
  * @param string $key Network Key
  * @param array $body
  *   (optional)
  *
  * @return array|false or throw Exception
  *
  * @throws \Exception
  */
 public function getSubscription($id, $key, array $body = array())
 {
     $body['identifier'] = $id;
     // There is an identifier and key, so attempt communication.
     $subscription = array();
     $subscription['timestamp'] = REQUEST_TIME;
     // Include version number information.
     acquia_connector_load_versions();
     if (IS_ACQUIA_DRUPAL) {
         $body['version'] = ACQUIA_DRUPAL_VERSION;
         $body['series'] = ACQUIA_DRUPAL_SERIES;
         $body['branch'] = ACQUIA_DRUPAL_BRANCH;
         $body['revision'] = ACQUIA_DRUPAL_REVISION;
     }
     // Include Acquia Search for Search API module version number.
     if (\Drupal::moduleHandler()->moduleExists('acquia_search')) {
         foreach (array('acquia_search', 'search_api', 'search_api_solr') as $name) {
             $info = system_get_info('module', $name);
             // Send the version, or at least the core compatibility as a fallback.
             $body['search_version'][$name] = isset($info['version']) ? (string) $info['version'] : (string) $info['core'];
         }
     }
     try {
         $response = $this->nspiCall('/agent-api/subscription', $body);
         if (!empty($response['result']['authenticator']) && $this->validateResponse($key, $response['result'], $response['authenticator'])) {
             $subscription += $response['result']['body'];
             // Subscription activated.
             if (is_numeric($this->config->get('subscription_data')) && is_array($response['result']['body'])) {
                 \Drupal::moduleHandler()->invokeAll('acquia_subscription_status', [$subscription]);
                 \Drupal::configFactory()->getEditable('acquia_connector.settings')->set('subscription_data', $subscription)->save();
             }
             return $subscription;
         }
     } catch (ConnectorException $e) {
         drupal_set_message(t('Error occurred while retrieving Acquia subscription information. See logs for details.'), 'error');
         if ($e->isCustomized()) {
             \Drupal::logger('acquia connector')->error($e->getCustomMessage() . '. Response data: @data', array('@data' => json_encode($e->getAllCustomMessages())));
         } else {
             \Drupal::logger('acquia connector')->error($e->getMessage());
         }
         throw $e;
     }
     return FALSE;
 }
コード例 #23
0
 /**
  * Prints a page listing general help for a module.
  *
  * @param string $name
  *   A module name to display a help page for.
  *
  * @return array
  *   A render array as expected by drupal_render().
  *
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 public function helpPage($name)
 {
     $build = array();
     if ($this->moduleHandler()->implementsHook($name, 'help')) {
         $module_name = $this->moduleHandler()->getName($name);
         $build['#title'] = $module_name;
         $info = system_get_info('module', $name);
         if ($info['package'] === 'Core (Experimental)') {
             drupal_set_message($this->t('This module is experimental. <a href=":url">Experimental modules</a> are provided for testing purposes only. Use at your own risk.', [':url' => 'https://www.drupal.org/core/experimental']), 'warning');
         }
         $temp = $this->moduleHandler()->invoke($name, 'help', array("help.page.{$name}", $this->routeMatch));
         if (empty($temp)) {
             $build['top'] = ['#markup' => $this->t('No help is available for module %module.', array('%module' => $module_name))];
         } else {
             if (!is_array($temp)) {
                 $temp = ['#markup' => $temp];
             }
             $build['top'] = $temp;
         }
         // Only print list of administration pages if the module in question has
         // any such pages associated with it.
         $admin_tasks = system_get_module_admin_tasks($name, system_get_info('module', $name));
         if (!empty($admin_tasks)) {
             $links = array();
             foreach ($admin_tasks as $task) {
                 $link['url'] = $task['url'];
                 $link['title'] = $task['title'];
                 $links[] = $link;
             }
             $build['links'] = array('#theme' => 'links__help', '#heading' => array('level' => 'h3', 'text' => $this->t('@module administration pages', array('@module' => $module_name))), '#links' => $links);
         }
         return $build;
     } else {
         throw new NotFoundHttpException();
     }
 }
コード例 #24
0
 /**
  * Only expose this plugin, if Background Process is 1.x.
  */
 public function isValid($job = NULL)
 {
     static $correct_version;
     if (!isset($correct_version)) {
         $correct_version = FALSE;
         // Interimistic way of determining version of Background Process.
         // Background Process 1.x has a dependency on the Progress module.
         if (module_exists('background_process')) {
             $info = system_get_info('module', 'background_process');
             if (!empty($info['dependencies']) && in_array('progress', $info['dependencies'])) {
                 $correct_version = TRUE;
             }
         }
     }
     return $correct_version && parent::isValid($job);
 }
コード例 #25
0
 /**
  * Create the filter/sort form at the top of a list of exports.
  *
  * This handles the very default conditions, and most lists are expected
  * to override this and call through to parent::list_form() in order to
  * get the base form and then modify it as necessary to add search
  * gadgets for custom fields.
  */
 public function list_form(&$form, &$form_state)
 {
     parent::list_form($form, $form_state);
     $class = _ultimate_cron_get_class('job');
     $lock_ids = $class::isLockedMultiple($this->items);
     $log_entries = $class::loadLatestLogEntries($this->items);
     $progresses = $class::getProgressMultiple($this->items);
     foreach ($this->items as $name => $item) {
         $item->log_entry = isset($item->log_entry) ? $item->log_entry : $log_entries[$name];
         $item->progress = isset($item->progress) ? $item->progress : $progresses[$name];
         $item->lock_id = isset($item->lock_id) ? $item->lock_id : $lock_ids[$name];
     }
     $form['#attached']['js'][] = drupal_get_path('module', 'ultimate_cron') . '/js/ultimate_cron.js';
     if (module_exists('nodejs')) {
         $settings = _ultimate_cron_plugin_load('settings', 'general')->getDefaultSettings();
         if (!empty($settings['nodejs'])) {
             nodejs_send_content_channel_token('ultimate_cron');
             $form['#attached']['js'][] = drupal_get_path('module', 'ultimate_cron') . '/js/ultimate_cron.nodejs.js';
         }
     }
     // There's no normal for Ultimate Cron!
     unset($form['top row']['storage']['#options'][t('Normal')]);
     $all = array('all' => t('- All -'));
     $options = $all + array('running' => 'running', -1 => 'no info') + watchdog_severity_levels();
     $form['top row']['status'] = array('#type' => 'select', '#title' => t('Status'), '#options' => $options, '#default_value' => 'all', '#weight' => -2);
     $jobs = ultimate_cron_get_hooks();
     $modules = array();
     foreach ($jobs as $job) {
         $info = system_get_info('module', $job['module']);
         $modules[$job['module']] = $info && !empty($info['name']) ? $info['name'] : $job['module'];
     }
     $form['top row']['module'] = array('#type' => 'select', '#title' => t('Module'), '#options' => $all + $modules, '#default_value' => 'all', '#weight' => -1);
     $form['bottom row']['reload'] = array('#type' => 'submit', '#id' => 'ctools-export-ui-list-items-reload', '#value' => t('Reload'), '#attributes' => array('class' => array('use-ajax-submit')));
 }
コード例 #26
0
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     $module_info = system_get_info('module');
     // Get list of permissions
     $perms = [];
     $permissions = $this->permissionHandler->getPermissions();
     foreach ($permissions as $perm => $perm_item) {
         $provider = $perm_item['provider'];
         $display_name = $module_info[$provider]['name'];
         $perms[$display_name][$perm] = String::checkPlain(strip_tags($perm_item['title']));
     }
     $form['perm'] = array('#type' => 'select', '#options' => $perms, '#title' => $this->t('Permission'), '#default_value' => $this->options['perm'], '#description' => $this->t('Only users with the selected permission flag will be able to access this display. Note that users with "access all views" can see any view, regardless of other permissions.'));
 }
コード例 #27
0
ファイル: HelpTest.php プロジェクト: komejo/article-test
 /**
  * Verifies the logged in user has access to the various help nodes.
  *
  * @param integer $response
  *   An HTTP response code.
  */
 protected function verifyHelp($response = 200)
 {
     $this->drupalGet('admin/index');
     $this->assertResponse($response);
     if ($response == 200) {
         $this->assertText('This page shows you all available administration tasks for each module.');
     } else {
         $this->assertNoText('This page shows you all available administration tasks for each module.');
     }
     foreach ($this->getModuleList() as $module => $name) {
         // View module help node.
         $this->drupalGet('admin/help/' . $module);
         $this->assertResponse($response);
         if ($response == 200) {
             $this->assertTitle($name . ' | Drupal', format_string('%module title was displayed', array('%module' => $module)));
             $this->assertRaw('<h1 class="page-title">' . t($name) . '</h1>', format_string('%module heading was displayed', array('%module' => $module)));
             $admin_tasks = system_get_module_admin_tasks($module, system_get_info('module', $module));
             if (!empty($admin_tasks)) {
                 $this->assertText(t('@module administration pages', array('@module' => $name)));
             }
             foreach ($admin_tasks as $task) {
                 $this->assertLink($task['title']);
                 // Ensure there are no double escaped '&' or '<' characters.
                 $this->assertNoEscaped('&amp;', 'The help text does not have double escaped &amp;.');
                 $this->assertNoEscaped('&lt;', 'The help text does not have double escaped &lt;.');
                 // Ensure there are no escaped '<' characters.
                 $this->assertNoEscaped('<', 'The help text does not have single escaped &lt;.');
             }
             // Ensure there are no double escaped '&' or '<' characters.
             $this->assertNoEscaped('&amp;');
             $this->assertNoEscaped('&lt;');
             // Ensure there are no escaped '<' characters.
             $this->assertNoEscaped('<');
         }
     }
 }
コード例 #28
0
  /**
   * Builds the render array for the required version column.
   *
   * @param string $contraint
   *   The package constraint.
   * @param array $required_by
   *   The names of dependent packages.
   *
   * @return array
   *   The requirements render array.
   */
  protected function buildRequiredVersion($constraint, array $required_by) {
    // Filter out non-Drupal packages.
    $drupal_required_by = array_filter($required_by, function($package_name) {
      return strpos($package_name, 'drupal/') !== FALSE;
    });

    if (empty($required_by)) {
      $constraint = $this->t('No longer required');
      $description = $this->t('Package will be removed on the next Composer update');
    }
    elseif (empty($drupal_required_by)) {
      // The package is here as a requirement of other packages, list them.
      $constraint = $this->t('N/A');
      $description = $this->t('Required by: ') . implode(', ', $required_by);
    }
    else {
      if (!isset($this->moduleData)) {
        $this->moduleData = system_get_info('module');
      }

      $modules = [];
      foreach ($drupal_required_by as $package_name) {
        $name_parts = explode('/', $package_name);
        $module_name = $name_parts[1];

        if ($module_name == 'core') {
          $modules[] = $this->t('Drupal');
        }
        elseif (isset($this->moduleData[$module_name])) {
          $modules[] = $this->moduleData[$module_name]['name'];
        }
        else {
          $modules[] = $module_name;
        }
      }

      $description = $this->t('Required by: ') . implode(', ', $modules);
    }

    $required_version = [];
    $required_version[] = [
      '#plain_text' => $constraint,
    ];
    $required_version[] = [
      '#prefix' => '<div class="description">',
      '#plain_text' => $description,
      '#suffix' => '</div>',
    ];

    return $required_version;
  }
コード例 #29
0
 public function printEmptyTable()
 {
     $module_info = system_get_info('module');
     $perm_padding = str_pad('', $this->width_perm + 10);
     $role_line = '';
     $rids = array();
     $i = 0;
     $perm_null_line = '';
     foreach ($this->roles as $rid => $role) {
         $rids[] = $rid;
         $role_line .= str_pad("'{$role}', ", $this->width_role[$i] + 4);
         $perm_null_line .= str_pad("NULL,", $this->width_role[$i++] + 4);
     }
     $lines = array();
     foreach ($this->perms as $module => $perms) {
         $lines[] = "  ),";
         $lines[] = "  // {$module_info[$module]['name']}";
         $lines[] = "  '{$module}' => array(";
         foreach ($perms as $i => $perm) {
             $p = str_pad("'{$perm}'", $this->width_perm + 2);
             $lines[] = "    {$p} => array({$perm_null_line}),";
         }
     }
     array_push($lines, array_shift($lines));
     $lines = implode("\n", $lines);
     echo "<?php\n\n";
     echo "\$roles = array(\n";
     echo "  {$perm_padding}    {$role_line}\n";
     echo ");\n";
     echo "\$matrix = array(\n";
     echo "{$lines}\n";
     echo ");\n";
 }
コード例 #30
0
ファイル: FormFormBase.php プロジェクト: isramv/camp-gdl
 /**
  * Return registered forms as an array suitable for a 'checkboxes' form element #options property.
  */
 protected function getProtectableFormOptions()
 {
     // Retrieve all registered forms.
     $form_list = FormController::getProtectableForms();
     // Remove already configured form ids.
     $result = $this->entity->loadMultiple();
     foreach ($result as $form_id) {
         unset($form_list[$form_id->id()]);
     }
     // If all registered forms are configured already, output a message, and
     // redirect the user back to overview.
     if (empty($form_list)) {
         drupal_set_message(t('All available forms are protected already.'));
     }
     // Load module information.
     $module_info = system_get_info('module');
     // Transform form information into an associative array suitable for #options.
     $options = array();
     foreach ($form_list as $form_id => $info) {
         // system_get_info() only supports enabled modules. Default to the module's
         // machine name in case it is disabled.
         $module = $info['module'];
         if (!isset($module_info[$module])) {
             $module_info[$module]['name'] = $module;
         }
         $options[$form_id] = t('@module: @form-title', array('@form-title' => $info['title'], '@module' => t($module_info[$module]['name'])));
     }
     // Sort form options by title.
     asort($options);
     return $options;
 }