Ejemplo n.º 1
0
 /**
  * Presents an administrative comment listing.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The request of the page.
  * @param string $type
  *   The type of the overview form ('approval' or 'new') default to 'new'.
  *
  * @return array
  *   Then comment multiple delete confirmation form or the comments overview
  *   administration form.
  */
 public function adminPage(Request $request, $type = 'new')
 {
     if ($request->request->get('operation') == 'delete' && $request->request->get('comments')) {
         return $this->formBuilder->getForm('\\Drupal\\comment\\Form\\ConfirmDeleteMultiple', $request);
     } else {
         return $this->formBuilder->getForm('\\Drupal\\comment\\Form\\CommentAdminOverview', $type);
     }
 }
Ejemplo n.º 2
0
 /**
  * Constructs a morse request object.
  */
 public function morse(Request $request, $type)
 {
     if ($type == "morse") {
         return $this->formBuilder->getForm('\\Drupal\\morse\\Form\\MorseConverter', $request);
     } else {
         return $this->formBuilder->getForm('\\Drupal\\morse\\Form\\AlphaNumericConverter', $request);
     }
 }
Ejemplo n.º 3
0
 /**
  * Displays a listing of database log messages.
  *
  * Messages are truncated at 56 chars.
  * Full-length messages can be viewed on the message details page.
  *
  * @return array
  *   A render array as expected by drupal_render().
  *
  * @see dblog_clear_log_form()
  * @see dblog_event()
  */
 public function overview()
 {
     $filter = $this->buildFilterQuery();
     $rows = array();
     $classes = static::getLogLevelClassMap();
     $this->moduleHandler->loadInclude('dblog', 'admin.inc');
     $build['dblog_filter_form'] = $this->formBuilder->getForm('Drupal\\dblog\\Form\\DblogFilterForm');
     $build['dblog_clear_log_form'] = $this->formBuilder->getForm('Drupal\\dblog\\Form\\DblogClearLogForm');
     $header = array('', array('data' => $this->t('Type'), 'field' => 'w.type', 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)), array('data' => $this->t('Date'), 'field' => 'w.wid', 'sort' => 'desc', 'class' => array(RESPONSIVE_PRIORITY_LOW)), $this->t('Message'), array('data' => $this->t('User'), 'field' => 'u.name', 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)), array('data' => $this->t('Operations'), 'class' => array(RESPONSIVE_PRIORITY_LOW)));
     $query = $this->database->select('watchdog', 'w')->extend('\\Drupal\\Core\\Database\\Query\\PagerSelectExtender')->extend('\\Drupal\\Core\\Database\\Query\\TableSortExtender');
     $query->fields('w', array('wid', 'uid', 'severity', 'type', 'timestamp', 'message', 'variables', 'link'));
     if (!empty($filter['where'])) {
         $query->where($filter['where'], $filter['args']);
     }
     $result = $query->limit(50)->orderByHeader($header)->execute();
     foreach ($result as $dblog) {
         $message = $this->formatMessage($dblog);
         if ($message && isset($dblog->wid)) {
             // Truncate link_text to 56 chars of message.
             $log_text = Unicode::truncate(Xss::filter($message, array()), 56, TRUE, TRUE);
             $message = $this->l($log_text, 'dblog.event', array('event_id' => $dblog->wid), array('html' => TRUE));
         }
         $username = array('#theme' => 'username', '#account' => user_load($dblog->uid));
         $rows[] = array('data' => array(array('class' => array('icon')), $this->t($dblog->type), $this->dateFormatter->format($dblog->timestamp, 'short'), $message, array('data' => $username), Xss::filter($dblog->link)), 'class' => array(drupal_html_class('dblog-' . $dblog->type), $classes[$dblog->severity]));
     }
     $build['dblog_table'] = array('#type' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => array('id' => 'admin-dblog', 'class' => array('admin-dblog')), '#empty' => $this->t('No log messages available.'), '#attached' => array('library' => array('dblog/drupal.dblog')));
     $build['dblog_pager'] = array('#theme' => 'pager');
     return $build;
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function viewElements(FieldItemListInterface $items, $langcode)
 {
     // @todo Use a lazy_builder.
     $product = $items->getEntity();
     $settings = $this->getSettings();
     return $this->formBuilder->getForm('\\Drupal\\commerce_product\\Form\\AddToCartForm', $product, $settings);
 }
 /**
  * Displays a listing of database log messages.
  *
  * Messages are truncated at 56 chars.
  * Full-length messages can be viewed on the message details page.
  *
  * @return array
  *   A render array as expected by drupal_render().
  *
  * @see dblog_clear_log_form()
  * @see dblog_event()
  */
 public function overview()
 {
     $filter = $this->buildFilterQuery();
     $rows = array();
     $classes = static::getLogLevelClassMap();
     $this->moduleHandler->loadInclude('dblog', 'admin.inc');
     $build['dblog_filter_form'] = $this->formBuilder->getForm('Drupal\\dblog\\Form\\DblogFilterForm');
     $build['dblog_clear_log_form'] = $this->formBuilder->getForm('Drupal\\dblog\\Form\\DblogClearLogForm');
     $header = array('', array('data' => $this->t('Type'), 'field' => 'w.type', 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)), array('data' => $this->t('Date'), 'field' => 'w.wid', 'sort' => 'desc', 'class' => array(RESPONSIVE_PRIORITY_LOW)), $this->t('Message'), array('data' => $this->t('User'), 'field' => 'ufd.name', 'class' => array(RESPONSIVE_PRIORITY_MEDIUM)), array('data' => $this->t('Operations'), 'class' => array(RESPONSIVE_PRIORITY_LOW)));
     $query = $this->database->select('watchdog', 'w')->extend('\\Drupal\\Core\\Database\\Query\\PagerSelectExtender')->extend('\\Drupal\\Core\\Database\\Query\\TableSortExtender');
     $query->fields('w', array('wid', 'uid', 'severity', 'type', 'timestamp', 'message', 'variables', 'link'));
     $query->leftJoin('users_field_data', 'ufd', 'w.uid = ufd.uid');
     if (!empty($filter['where'])) {
         $query->where($filter['where'], $filter['args']);
     }
     $result = $query->limit(50)->orderByHeader($header)->execute();
     foreach ($result as $dblog) {
         $message = $this->formatMessage($dblog);
         if ($message && isset($dblog->wid)) {
             $title = Unicode::truncate(Html::decodeEntities(strip_tags($message)), 256, TRUE, TRUE);
             $log_text = Unicode::truncate($title, 56, TRUE, TRUE);
             // The link generator will escape any unsafe HTML entities in the final
             // text.
             $message = $this->l($log_text, new Url('dblog.event', array('event_id' => $dblog->wid), array('attributes' => array('title' => $title))));
         }
         $username = array('#theme' => 'username', '#account' => $this->userStorage->load($dblog->uid));
         $rows[] = array('data' => array(array('class' => array('icon')), $this->t($dblog->type), $this->dateFormatter->format($dblog->timestamp, 'short'), $message, array('data' => $username), array('data' => array('#markup' => $dblog->link))), 'class' => array(Html::getClass('dblog-' . $dblog->type), $classes[$dblog->severity]));
     }
     $build['dblog_table'] = array('#type' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => array('id' => 'admin-dblog', 'class' => array('admin-dblog')), '#empty' => $this->t('No log messages available.'), '#attached' => array('library' => array('dblog/drupal.dblog')));
     $build['dblog_pager'] = array('#type' => 'pager');
     return $build;
 }
Ejemplo n.º 6
0
 /**
  * Form based configuration data inspection.
  *
  * @param string $name
  *   Configuration name.
  *
  * @return array
  *   A render array for a form view.
  */
 public function getForm($name)
 {
     $config_schema = $this->configInspectorManager->getConfigSchema($name);
     $output = $this->formBuilder->getForm('\\Drupal\\config_inspector\\Form\\ConfigInspectorItemForm', $config_schema);
     $output['#title'] = $this->t('Raw configuration data for %name', array('%name' => $name));
     return $output;
 }
 /**
  * Act on entities being assembled before rendering.
  *
  * This is a hook bridge.
  *
  * @see hook_entity_view()
  * @see EntityFieldManagerInterface::getExtraFields()
  */
 public function entityView(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode)
 {
     if (!$this->moderationInfo->isModeratableEntity($entity)) {
         return;
     }
     if (!$this->moderationInfo->isLatestRevision($entity)) {
         return;
     }
     /** @var ContentEntityInterface $entity */
     if ($entity->isDefaultRevision()) {
         return;
     }
     $component = $display->getComponent('workbench_moderation_control');
     if ($component) {
         $build['workbench_moderation_control'] = $this->formBuilder->getForm(EntityModerationForm::class, $entity);
         $build['workbench_moderation_control']['#weight'] = $component['weight'];
     }
 }
 /**
  * {@inheritdoc}
  */
 public function build()
 {
     $build = [];
     if ($accounts = $this->getUsers()) {
         $build['devel_links'] = $this->buildUserList($accounts);
         if ($this->configuration['show_form']) {
             $build['devel_form'] = $this->formBuilder->getForm('\\Drupal\\devel\\Form\\SwitchUserForm');
         }
     }
     return $build;
 }
 /**
  * {@inheritdoc}
  */
 public function build()
 {
     $links = $this->switchUserList();
     if (!empty($links)) {
         $build = array('devel_links' => array('#theme' => 'links', '#links' => $links), '#attached' => array('css' => array(drupal_get_path('module', 'devel') . '/css/devel.css')));
         if ($this->configuration['show_form']) {
             $build['devel_form'] = $this->formBuilder->getForm('\\Drupal\\devel\\Form\\SwitchUserForm');
         }
         return $build;
     }
 }
Ejemplo n.º 10
0
 public function addRelationship(array &$form, FormStateInterface $form_state)
 {
     $relationship = $form_state->getValue('relationships');
     $content = $this->formBuilder->getForm($this->getRelationshipClass(), $relationship, $this->getTempstoreId(), $this->machine_name);
     $content['#attached']['library'][] = 'core/drupal.dialog.ajax';
     $cached_values = $form_state->getTemporaryValue('wizard');
     list(, $route_parameters) = $this->getRelationshipOperationsRouteInfo($cached_values, $this->machine_name, $relationship);
     $content['submit']['#attached']['drupalSettings']['ajax'][$content['submit']['#id']]['url'] = $this->url($this->getRelationshipAddRoute($cached_values), $route_parameters, ['query' => [FormBuilderInterface::AJAX_FORM_REQUEST => TRUE]]);
     $response = new AjaxResponse();
     $response->addCommand(new OpenModalDialogCommand($this->t('Configure Relationship'), $content, array('width' => '700')));
     return $response;
 }
Ejemplo n.º 11
0
 /**
  *
  *
  * @return array
  *   A render array.
  */
 public function show()
 {
     $build['#tree'] = TRUE;
     // Form that provides operations.
     $build['file_action_form'] = $this->formBuilder->getForm('Drupal\\uc_file\\Form\\FileActionForm');
     // Table of files to operate on.
     $header = array('filename' => array('data' => $this->t('File'), 'field' => 'f.filename', 'sort' => 'asc'), 'title' => array('data' => $this->t('Product'), 'field' => 'n.title'), 'model' => array('data' => $this->t('SKU'), 'field' => 'fp.model', 'class' => array(RESPONSIVE_PRIORITY_LOW)));
     // Create pager.
     $query = $this->database->select('uc_files', 'f')->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')->extend('Drupal\\Core\\Database\\Query\\TableSortExtender')->orderByHeader($header)->limit(UC_FILE_PAGER_SIZE);
     $query->leftJoin('uc_file_products', 'fp', 'f.fid = fp.fid');
     $query->leftJoin('uc_product_features', 'pf', 'fp.pfid = pf.pfid');
     $query->leftJoin('node_field_data', 'n', 'pf.nid = n.nid');
     $query->addField('n', 'nid');
     $query->addField('f', 'filename');
     $query->addField('n', 'title');
     $query->addField('fp', 'model');
     $query->addField('f', 'fid');
     $query->addField('pf', 'pfid');
     $count_query = $this->database->select('uc_files');
     $count_query->addExpression('COUNT(*)');
     $query->setCountQuery($count_query);
     $result = $query->execute();
     $options = array();
     foreach ($result as $file) {
         // All files are shown here, including files which are not attached to products.
         if (isset($file->nid)) {
             $options[$file->fid] = array('filename' => array('data' => array('#plain_text' => $file->filename), 'class' => is_dir(uc_file_qualify_file($file->filename)) ? array('uc-file-directory-view') : array()), 'title' => array('data' => array('#type' => 'link', '#title' => $file->title, '#url' => Url::fromRoute('entity.node.canonical', ['node' => $file->nid]))), 'model' => array('data' => array('#plain_text' => $file->model)));
         } else {
             $options[$file->fid] = array('filename' => array('data' => array('#plain_text' => $file->filename), 'class' => is_dir(uc_file_qualify_file($file->filename)) ? array('uc-file-directory-view') : array()), 'title' => '', 'model' => '');
         }
     }
     // Create checkboxes for each file.
     $build['file_select'] = array('#type' => 'tableselect', '#header' => $header, '#options' => $options, '#empty' => $this->t('No file downloads available.'));
     $build['file_select_pager'] = array('#type' => 'pager');
     return $build;
 }
Ejemplo n.º 12
0
 /**
  * {@inheritdoc}
  */
 public function build()
 {
     $build['#cache'] = ['max-age' => 0];
     //    $headers = array(
     //      array('data' => t('node'), 'style' => 'text-align:right;'),
     //      array('data' => t('prio'), 'style' => 'text-align:right;'),
     //      t('status'),
     //      t('realm'),
     //      array('data' => t('gid'), 'style' => 'text-align:right;'),
     //      t('view'),
     //      t('update'),
     //      t('delete'),
     //      t('explained'),
     //    );
     //    $rows[] = array('data' => array(array('data' => 1, 'style' => 'background-color: red; color: blue'),
     //                                    "CACHE 5", 3, 4, 5));
     if (empty(self::visibleNodes())) {
         $request_uri = \Drupal::request()->getRequestUri();
         if ($request_uri === '/' || $request_uri === '/node') {
             $build['#markup'] = t('@node_access information is not available for the nodes on this page due to caching — flush your caches to display it.', self::NODE_ACCESS);
         }
         return $build;
     }
     $build['#title'] = t('@node_access entries for nodes shown on this page', self::NODE_ACCESS);
     //    $build['test_table'] = array(
     //      '#type' => 'table',
     //      '#header' => $headers,
     //      //      array(
     //      //        t('Column 0'),
     //      //        array('data' => t('Active'), 'colspan' => '2'),
     //      //        array('data' => t('Staged'), 'colspan' => '2'),
     //      //      ),
     //      '#rows' => $rows,
     //      '#empty' => $this->t('No records found!'),
     //      '#responsive' => FALSE,
     //      '#attributes' => array(
     //        'class'       => array(),
     //        'style'       => 'text-align: left;',
     //      ),
     //    );
     $build['dna_form'] = $this->formBuilder->getForm('\\Drupal\\devel_node_access\\Form\\DnaForm');
     return $build;
 }
Ejemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 public function build()
 {
     return $this->formBuilder->getForm('Drupal\\form_test\\Form\\RedirectBlockForm');
 }
 /**
  * {@inheritdoc}
  *
  * @param string|null $theme
  *   (optional) The theme to display the blocks for. If NULL, the current
  *   theme will be used.
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The current request.
  *
  * @return array
  *   The block list as a renderable array.
  */
 public function render($theme = NULL, Request $request = NULL)
 {
     $this->request = $request;
     $this->theme = $theme;
     return $this->formBuilder->getForm($this);
 }
Ejemplo n.º 15
0
 /**
  * {@inheritdoc}
  */
 public function build()
 {
     return $this->formBuilder->getForm('Drupal\\masquerade\\Form\\MasqueradeForm');
 }
Ejemplo n.º 16
0
 /**
  * Returns a theme listing.
  *
  * @return string
  *   An HTML string of the theme listing page.
  *
  * @todo Move into ThemeController.
  */
 public function themesPage()
 {
     $config = $this->config('system.theme');
     // Get all available themes.
     $themes = $this->themeHandler->rebuildThemeData();
     uasort($themes, 'system_sort_modules_by_info_name');
     $theme_default = $config->get('default');
     $theme_groups = array('installed' => array(), 'uninstalled' => array());
     $admin_theme = $config->get('admin');
     $admin_theme_options = array();
     foreach ($themes as &$theme) {
         if (!empty($theme->info['hidden'])) {
             continue;
         }
         $theme->is_default = $theme->getName() == $theme_default;
         $theme->is_admin = $theme->getName() == $admin_theme || $theme->is_default && $admin_theme == '0';
         // Identify theme screenshot.
         $theme->screenshot = NULL;
         // Create a list which includes the current theme and all its base themes.
         if (isset($themes[$theme->getName()]->base_themes)) {
             $theme_keys = array_keys($themes[$theme->getName()]->base_themes);
             $theme_keys[] = $theme->getName();
         } else {
             $theme_keys = array($theme->getName());
         }
         // Look for a screenshot in the current theme or in its closest ancestor.
         foreach (array_reverse($theme_keys) as $theme_key) {
             if (isset($themes[$theme_key]) && file_exists($themes[$theme_key]->info['screenshot'])) {
                 $theme->screenshot = array('uri' => $themes[$theme_key]->info['screenshot'], 'alt' => $this->t('Screenshot for !theme theme', array('!theme' => $theme->info['name'])), 'title' => $this->t('Screenshot for !theme theme', array('!theme' => $theme->info['name'])), 'attributes' => array('class' => array('screenshot')));
                 break;
             }
         }
         if (empty($theme->status)) {
             // Ensure this theme is compatible with this version of core.
             // Require the 'content' region to make sure the main page
             // content has a common place in all themes.
             $theme->incompatible_core = !isset($theme->info['core']) || $theme->info['core'] != \DRUPAL::CORE_COMPATIBILITY || !isset($theme->info['regions']['content']);
             $theme->incompatible_php = version_compare(phpversion(), $theme->info['php']) < 0;
             // Confirmed that the base theme is available.
             $theme->incompatible_base = isset($theme->info['base theme']) && !isset($themes[$theme->info['base theme']]);
             // Confirm that the theme engine is available.
             $theme->incompatible_engine = isset($theme->info['engine']) && !isset($theme->owner);
         }
         $theme->operations = array();
         if (!empty($theme->status) || !$theme->incompatible_core && !$theme->incompatible_php && !$theme->incompatible_base && !$theme->incompatible_engine) {
             // Create the operations links.
             $query['theme'] = $theme->getName();
             if ($this->themeAccess->checkAccess($theme->getName())) {
                 $theme->operations[] = array('title' => $this->t('Settings'), 'url' => Url::fromRoute('system.theme_settings_theme', ['theme' => $theme->getName()]), 'attributes' => array('title' => $this->t('Settings for !theme theme', array('!theme' => $theme->info['name']))));
             }
             if (!empty($theme->status)) {
                 if (!$theme->is_default) {
                     $theme_uninstallable = TRUE;
                     if ($theme->getName() == $admin_theme) {
                         $theme_uninstallable = FALSE;
                     }
                     // Check it isn't the base of theme of an installed theme.
                     foreach ($theme->required_by as $themename => $dependency) {
                         if (!empty($themes[$themename]->status)) {
                             $theme_uninstallable = FALSE;
                         }
                     }
                     if ($theme_uninstallable) {
                         $theme->operations[] = array('title' => $this->t('Uninstall'), 'url' => Url::fromRoute('system.theme_uninstall'), 'query' => $query, 'attributes' => array('title' => $this->t('Uninstall !theme theme', array('!theme' => $theme->info['name']))));
                     }
                     $theme->operations[] = array('title' => $this->t('Set as default'), 'url' => Url::fromRoute('system.theme_set_default'), 'query' => $query, 'attributes' => array('title' => $this->t('Set !theme as default theme', array('!theme' => $theme->info['name']))));
                 }
                 $admin_theme_options[$theme->getName()] = $theme->info['name'];
             } else {
                 $theme->operations[] = array('title' => $this->t('Install'), 'url' => Url::fromRoute('system.theme_install'), 'query' => $query, 'attributes' => array('title' => $this->t('Install !theme theme', array('!theme' => $theme->info['name']))));
                 $theme->operations[] = array('title' => $this->t('Install and set as default'), 'url' => Url::fromRoute('system.theme_set_default'), 'query' => $query, 'attributes' => array('title' => $this->t('Install !theme as default theme', array('!theme' => $theme->info['name']))));
             }
         }
         // Add notes to default and administration theme.
         $theme->notes = array();
         if ($theme->is_default) {
             $theme->notes[] = $this->t('default theme');
         }
         if ($theme->is_admin) {
             $theme->notes[] = $this->t('admin theme');
         }
         // Sort installed and uninstalled themes into their own groups.
         $theme_groups[$theme->status ? 'installed' : 'uninstalled'][] = $theme;
     }
     // There are two possible theme groups.
     $theme_group_titles = array('installed' => $this->formatPlural(count($theme_groups['installed']), 'Installed theme', 'Installed themes'));
     if (!empty($theme_groups['uninstalled'])) {
         $theme_group_titles['uninstalled'] = $this->formatPlural(count($theme_groups['uninstalled']), 'Uninstalled theme', 'Uninstalled themes');
     }
     uasort($theme_groups['installed'], 'system_sort_themes');
     $this->moduleHandler()->alter('system_themes_page', $theme_groups);
     $build = array();
     $build[] = array('#theme' => 'system_themes_page', '#theme_groups' => $theme_groups, '#theme_group_titles' => $theme_group_titles);
     $build[] = $this->formBuilder->getForm('Drupal\\system\\Form\\ThemeAdminForm', $admin_theme_options);
     return $build;
 }
Ejemplo n.º 17
0
 /**
  * {@inheritdoc}
  */
 public function build()
 {
     return $this->formBuilder->getForm($this);
 }