/**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL, $fid = NULL, $pfid = NULL)
 {
     $this->node = $node;
     $this->featureId = $fid;
     $this->feature = uc_product_feature_load($pfid);
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, PageInterface $page = NULL, $display_variant_id = NULL, $block_id = NULL)
 {
     $this->page = $page;
     $this->displayVariant = $this->page->getVariant($display_variant_id);
     $this->block = $this->displayVariant->getBlock($block_id);
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, PageInterface $page = NULL, $display_variant_id = NULL, $condition_id = NULL)
 {
     $this->page = $page;
     $this->displayVariant = $this->page->getVariant($display_variant_id);
     $this->selectionCondition = $this->displayVariant->getSelectionCondition($condition_id);
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $results = $_POST;
     $form['method'] = array('#type' => 'hidden', '#value' => $results['method']);
     if (!isset($results['reset'])) {
         $results['reset'] = 0;
     }
     $form['all'] = array('#type' => 'hidden', '#value' => $results['all']);
     if (isset($results['all'])) {
         // Only carry reset value through if delete all nodes is set
         $form['reset'] = array('#type' => 'hidden', '#value' => $results['reset']);
         $form['all_warning'] = array('#markup' => '<p>' . $this->t('All content in all content types will be deleted. Be sure to have a backup of any important data!') . '</p>');
         if (!empty($results['reset'])) {
             if ($results['all']) {
                 $form['all_reset'] = array('#markup' => '<p>' . $this->t('Node, revision and comment counts will be reset.') . '</p>');
             }
         }
     } elseif (isset($results['types'])) {
         if (is_array($results['types'])) {
             foreach ($results['types'] as $key_type => $type) {
                 /**
                  * @TODO, if we use the form array the value doesn't exist in the submit
                  */
                 $_SESSION['nodes_type'][$key_type] = $type;
                 $info = node_type_get_types('type', $type);
                 $info = $info[$type];
                 $form[$type . '_warning'] = array('#markup' => '<p>' . $this->t('All content in the %type content type will be deleted. Be sure to have a backup of any important data!', array('%type' => $info->get('name'))) . '</p>');
             }
         }
         if ($results['reset']) {
             $form['all_reset'] = array('#markup' => '<p>' . $this->t('Sorry, we can\'t reset the counters because you are not deleting all nodes.') . '</p>');
         }
     }
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, NodeInterface $node = NULL, $component = NULL)
 {
     $this->node = $node;
     // @todo $component should be a fully loaded object, need to make our own ParamConverterInterface.
     $this->component = isset($node->webform['components'][$component]) ? $node->webform['components'][$component] : FALSE;
     return parent::buildForm($form, $form_state);
 }
Пример #6
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $tempstore_id = NULL, $machine_name = NULL, $context_id = NULL)
 {
     $this->tempstore_id = $tempstore_id;
     $this->machine_name = $machine_name;
     $this->context_id = $context_id;
     return parent::buildForm($form, $form_state);
 }
Пример #7
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $actions = NULL)
 {
     $cart_links_config = $this->config('uc_cart_links.settings');
     $this->actions = $actions;
     // Fail if the link is restricted.
     $data = $cart_links_config->get('restrictions');
     if (!empty($data)) {
         $restrictions = explode("\n", $cart_links_config->get('restrictions'));
         $restrictions = array_map('trim', $restrictions);
         if (!empty($restrictions) && !in_array($this->actions, $restrictions)) {
             unset($_GET['destination']);
             $path = $cart_links_config->get('invalid_page');
             if (empty($path)) {
                 return $this->redirect('<front>', [], ['absolute' => TRUE]);
             }
             return new RedirectResponse(Url::fromUri('internal:/' . $path, ['absolute' => TRUE])->toString());
         }
     }
     // Confirm with the user if the form contains a destructive action.
     $cart = Cart::create(\Drupal::getContainer());
     $items = $cart->getContents();
     if ($cart_links_config->get('empty') && !empty($items)) {
         $actions = explode('-', urldecode($this->actions));
         foreach ($actions as $action) {
             $action = Unicode::substr($action, 0, 1);
             if ($action == 'e' || $action == 'E') {
                 $form = parent::buildForm($form, $form_state);
                 $form['actions']['cancel']['#href'] = $cart_links_config->get('invalid_page');
                 return $form;
             }
         }
     }
     // No destructive actions, so process the link immediately.
     return $this->submitForm($form, $form_state);
 }
Пример #8
0
 /**
  * {@inheritdoc}
  *
  * @param string $ban_id
  *   The IP address record ID to unban.
  */
 public function buildForm(array $form, FormStateInterface $form_state, $ban_id = '')
 {
     if (!($this->banIp = $this->ipManager->findById($ban_id))) {
         throw new NotFoundHttpException();
     }
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state, $browser_langcode = NULL)
 {
     $this->browserLangcode = $browser_langcode;
     $form = parent::buildForm($form, $form_state);
     // @todo Convert to getCancelRoute() after http://drupal.org/node/2082071.
     $form['actions']['cancel']['#href'] = 'admin/config/regional/language/detection/browser';
     return $form;
 }
 /**
  * Builds the form array.
  *
  * Note that when adding arguments to buildForm(), you need to give
  * them default values, to avoid PHP errors.
  */
 public function buildForm(array $form, FormStateInterface $form_state, $id = '')
 {
     // Sanitize and save the ID.
     $id = (int) $id;
     $this->to_delete_id = $id;
     $form = parent::buildForm($form, $form_state);
     return $form;
 }
Пример #11
0
 /**
  * Overrides \Drupal\Core\Form\ConfirmFormBase::buildForm().
  */
 public function buildForm(array $form, array &$form_state, $pid = NULL)
 {
     $this->pathAlias = $this->aliasStorage->load(array('pid' => $pid));
     $form = parent::buildForm($form, $form_state);
     // @todo Convert to getCancelRoute() after http://drupal.org/node/1987802.
     $form['actions']['cancel']['#href'] = 'admin/config/search/path';
     return $form;
 }
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state,
                            FlagInterface $flag = NULL, $entity_id = NULL) {

    $this->flag = $flag;
    $flag_service = \Drupal::service('flag');
    $this->entity = $flag_service->getFlaggableById($this->flag, $entity_id);
    return parent::buildForm($form, $form_state);
  }
 /**
  * {@inheritdoc}
  *
  * @param int $id
  *   (optional) The ID of the item to be deleted.
  */
 public function buildForm(array $form, FormStateInterface $form_state, $file = '') {
   // @todo update access!
   $this->id = $file;
   if (!$this->id) {
     throw new NotFoundHttpException();
   }
   // @todo set album type?
   return parent::buildForm($form, $form_state);
 }
Пример #14
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, OrderInterface $uc_order = NULL, $payment = NULL)
 {
     $this->payment = uc_payment_load($payment);
     // Make sure the payment is for the specified order.
     if ($this->payment->order_id != $uc_order->id()) {
         throw new NotFoundHttpException();
     }
     return parent::buildForm($form, $form_state);
 }
Пример #15
0
  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state, ProfileInterface $linkit_profile = NULL, $plugin_instance_id = NULL) {
    $this->linkitProfile = $linkit_profile;

    if (!$this->linkitProfile->getAttributes()->has($plugin_instance_id)) {
      throw new NotFoundHttpException();
    }

    $this->linkitAttribute = $this->linkitProfile->getAttribute($plugin_instance_id);
    return parent::buildForm($form, $form_state);
  }
Пример #16
0
 /**
  * @param array $form
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  * @param null $backup_migrate_destination
  * @param null $backup_id
  * @return array
  */
 public function buildForm(array $form, FormStateInterface $form_state, $backup_migrate_destination = NULL, $backup_id = NULL)
 {
     $this->destination = $backup_migrate_destination;
     $this->backup_id = $backup_id;
     $bam = backup_migrate_get_service_object();
     $form['source_id'] = DrupalConfigHelper::getPluginSelector($bam->sources(), $this->t('Restore To'));
     $conf_schema = $bam->plugins()->map('configSchema', array('operation' => 'restore'));
     $form += DrupalConfigHelper::buildFormFromSchema($conf_schema, $bam->plugins()->config());
     return parent::buildForm($form, $form_state);
 }
Пример #17
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = parent::buildForm($form, $form_state);
     // Remove the cancel button if this is an AJAX request since Drupals built
     // in modal dialogues does not handle buttons that are not a primary
     // button very well.
     if ($this->getRequest()->isXmlHttpRequest()) {
         unset($form['actions']['cancel']);
     }
     return $form;
 }
Пример #18
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $user = NULL, $role = NULL)
 {
     $expiration = db_query('SELECT expiration FROM {uc_roles_expirations} WHERE uid = :uid AND rid = :rid', [':uid' => $user->id(), ':rid' => $role])->fetchField();
     if ($expiration) {
         $role_name = _uc_role_get_name($role);
         $form['user'] = array('#type' => 'value', '#value' => $user->getUsername());
         $form['uid'] = array('#type' => 'value', '#value' => $user->id());
         $form['role'] = array('#type' => 'value', '#value' => $role_name);
         $form['rid'] = array('#type' => 'value', '#value' => $role);
     }
     return parent::buildForm($form, $form_state);
 }
Пример #19
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state, PageInterface $page = NULL, $page_variant_id = NULL, $layout_region_id = NULL, $block_id = NULL)
 {
     $this->page = $page;
     $this->displayVariant = $this->page->getVariant($page_variant_id);
     $this->displayVariant->init($this->page->getExecutable());
     $this->block = $this->displayVariant->getBlock($block_id);
     $form = parent::buildForm($form, $form_state, $page, $page_variant_id, $layout_region_id, $block_id);
     if ($this->getRequest()->isXmlHttpRequest()) {
         $form['actions']['submit']['#ajax'] = array('callback' => array($this, 'submitForm'));
     }
     return $form;
 }
Пример #20
0
 public function buildForm(array $form, FormStateInterface $form_state, $field_group_name = NULL, $entity_type_id = NULL, $bundle = NULL, $context = NULL)
 {
     if ($context == 'form') {
         $mode = $this->getRequest()->attributes->get('form_mode_name');
     } else {
         $mode = $this->getRequest()->attributes->get('view_mode_name');
     }
     if (empty($mode)) {
         $mode = 'default';
     }
     $this->fieldGroup = field_group_load_field_group($field_group_name, $entity_type_id, $bundle, $context, $mode);
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     parent::validateForm($form, $form_state);
     // Only authenticated users can leave a collection.
     /** @var \Drupal\user\UserInterface $user */
     $user = User::load($this->currentUser()->id());
     if ($user->isAnonymous()) {
         $form_state->setErrorByName('user', $this->t('<a href=":login">Log in</a> or <a href=":register">register</a> to change your group membership.', [':login' => Url::fromRoute('user.login'), ':register' => Url::fromRoute('user.register')]));
     }
     // Check if the user is a member of the collection.
     if (!Og::isMember($this->collection, $user)) {
         $form_state->setErrorByName('collection', $this->t('You are not a member of this collection. You cannot leave it.'));
     }
 }
Пример #22
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL, MegaMenuInterface $mega_menu = NULL, $block_id = NULL)
 {
     $form_state->set('link', $request->query->get('link'));
     $this->megaMenu = $mega_menu;
     $this->block = $this->megaMenu->getBlock($form_state->get('link'), $block_id);
     $form = parent::buildForm($form, $form_state);
     // Remove the cancel button if this is an AJAX request since Drupals built
     // in modal dialogues does not handle buttons that are not a primary
     // button very well.
     if ($this->getRequest()->isXmlHttpRequest()) {
         unset($form['actions']['cancel']);
     }
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $entry_id = NULL)
 {
     try {
         $this->entry = BlacklistStorage::getEntry($entry_id);
     } catch (\Exception $e) {
         drupal_set_message(t('There was an error loading the entry to delete.'));
         return array();
     }
     if (empty($this->entry)) {
         drupal_set_message(t('There was an error loading the entry to delete.'));
         return array();
     }
     $form = parent::buildForm($form, $form_state);
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $link = '')
 {
     $query = db_select('xmlsitemap');
     $query->fields('xmlsitemap');
     $query->condition('type', 'custom');
     $query->condition('id', $link);
     $result = $query->execute();
     $link = $result->fetchAssoc();
     if (!$link) {
         drupal_set_message(t('No valid custom link specified.'), 'error');
         return new RedirectResponse('/admin/config/search/xmlsitemap/custom/');
     } else {
         $this->custom_link = $link;
     }
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state)
 {
     // Retrieve the list of modules from the key value store.
     $account = $this->currentUser()->id();
     $this->modules = $this->keyValueExpirable->get($account);
     // Prevent this page from showing when the module list is empty.
     if (empty($this->modules)) {
         return new RedirectResponse('/admin/modules/uninstall');
     }
     $data = system_rebuild_module_data();
     $form['text']['#markup'] = '<p>' . $this->t('The following modules will be completely uninstalled from your site, and <em>all data from these modules will be lost</em>!') . '</p>';
     $form['modules'] = array('#theme' => 'item_list', '#items' => array_map(function ($module) use($data) {
         return $data[$module]->info['name'];
     }, $this->modules));
     $form['entities'] = array('#type' => 'details', '#title' => $this->t('Configuration deletions'), '#description' => $this->t('The listed configuration will be deleted.'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#access' => FALSE);
     // Get the dependent entities.
     $entity_types = array();
     $dependent_entities = $this->configManager->findConfigEntityDependentsAsEntities('module', $this->modules);
     foreach ($dependent_entities as $entity) {
         $entity_type_id = $entity->getEntityTypeId();
         if (!isset($form['entities'][$entity_type_id])) {
             $entity_type = $this->entityManager->getDefinition($entity_type_id);
             // Store the ID and label to sort the entity types and entities later.
             $label = $entity_type->getLabel();
             $entity_types[$entity_type_id] = $label;
             $form['entities'][$entity_type_id] = array('#theme' => 'item_list', '#title' => $label, '#items' => array());
         }
         $form['entities'][$entity_type_id]['#items'][] = $entity->label();
     }
     if (!empty($dependent_entities)) {
         $form['entities']['#access'] = TRUE;
         // Add a weight key to the entity type sections.
         asort($entity_types, SORT_FLAG_CASE);
         $weight = 0;
         foreach ($entity_types as $entity_type_id => $label) {
             $form['entities'][$entity_type_id]['#weight'] = $weight;
             // Sort the list of entity labels alphabetically.
             sort($form['entities'][$entity_type_id]['#items'], SORT_FLAG_CASE);
             $weight++;
         }
     }
     return parent::buildForm($form, $form_state);
 }
Пример #26
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $this->profiles = $this->privateTempStoreFactory->get('profile_multiple_delete_confirm')->get(\Drupal::currentUser()->id());
     if (empty($this->profiles)) {
         return new RedirectResponse(\Drupal::url('admin/config/people/profiles', ['absolute' => TRUE]));
     }
     $form['profiles'] = ['#theme' => 'item_list', '#items' => array_map(function ($profile) {
         return $profile->label();
     }, $this->profiles)];
     $form = parent::buildForm($form, $form_state);
     return $form;
 }
Пример #27
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state, $node_revision = NULL)
 {
     $this->revision = $this->nodeStorage->loadRevision($node_revision);
     $form = parent::buildForm($form, $form_state);
     // @todo Convert to getCancelRoute() after http://drupal.org/node/1863906.
     $form['actions']['cancel']['#href'] = 'node/' . $this->revision->id() . '/revisions';
     return $form;
 }
Пример #28
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $file_ids = array_filter($form_state->getValue('file_select'));
     $form['file_ids'] = array('#type' => 'value', '#value' => $file_ids);
     $form['action'] = array('#type' => 'value', '#value' => $form_state->getValue(['uc_file_action', 'action']));
     $file_ids = _uc_file_sort_names(_uc_file_get_dir_file_ids($file_ids, FALSE));
     $affected_list = $this->buildJsFileDisplay($file_ids);
     $has_directory = FALSE;
     foreach ($file_ids as $file_id) {
         // Gather a list of user-selected filenames.
         $file = uc_file_get_by_id($file_id);
         $filename = $file->filename;
         $file_list[] = substr($filename, -1) == "/" ? $filename . ' (' . $this->t('directory') . ')' : $filename;
         // Determine if there are any directories in this list.
         $path = uc_file_qualify_file($filename);
         if (is_dir($path)) {
             $has_directory = TRUE;
         }
     }
     // Base files/dirs the user selected.
     $form['selected_files'] = array('#theme' => 'item_list', '#items' => $file_list, '#attributes' => array('class' => array('selected-file-name')));
     // Don't even show the recursion checkbox unless we have any directories.
     if ($has_directory && $affected_list[TRUE] !== FALSE) {
         $form['recurse_directories'] = array('#type' => 'checkbox', '#title' => $this->t('Delete selected directories and their sub directories'));
         // Default to FALSE. Although we have the JS behavior to update with the
         // state of the checkbox on load, this should improve the experience of
         // users who don't have JS enabled over not defaulting to any info.
         $form['affected_files'] = array('#theme' => 'item_list', '#items' => $affected_list[FALSE], '#title' => $this->t('Affected files'), '#attributes' => array('class' => array('affected-file-name')));
     }
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, PageInterface $page = NULL, $condition_id = NULL)
 {
     $this->page = $page;
     $this->accessCondition = $page->getAccessCondition($condition_id);
     return parent::buildForm($form, $form_state);
 }
Пример #30
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state)
 {
     // Retrieve the accounts to be canceled from the temp store.
     $accounts = $this->tempStoreFactory->get('user_user_operations_cancel')->get($this->currentUser()->id());
     if (!$accounts) {
         return new RedirectResponse($this->url('user.admin_account', [], ['absolute' => TRUE]));
     }
     $form['accounts'] = array('#prefix' => '<ul>', '#suffix' => '</ul>', '#tree' => TRUE);
     foreach ($accounts as $uid => $account) {
         // Prevent user 1 from being canceled.
         if ($uid <= 1) {
             continue;
         }
         $form['accounts'][$uid] = array('#type' => 'hidden', '#value' => $uid, '#prefix' => '<li>', '#suffix' => String::checkPlain($account->label()) . "</li>\n");
     }
     // Output a notice that user 1 cannot be canceled.
     if (isset($accounts[1])) {
         $redirect = count($accounts) == 1;
         $message = $this->t('The user account %name cannot be canceled.', array('%name' => $accounts[1]->label()));
         drupal_set_message($message, $redirect ? 'error' : 'warning');
         // If only user 1 was selected, redirect to the overview.
         if ($redirect) {
             return new RedirectResponse($this->url('user.admin_account', [], ['absolute' => TRUE]));
         }
     }
     $form['operation'] = array('#type' => 'hidden', '#value' => 'cancel');
     $form['user_cancel_method'] = array('#type' => 'radios', '#title' => $this->t('When cancelling these accounts'));
     $form['user_cancel_method'] += user_cancel_methods();
     // Allow to send the account cancellation confirmation mail.
     $form['user_cancel_confirm'] = array('#type' => 'checkbox', '#title' => $this->t('Require email confirmation to cancel account.'), '#default_value' => FALSE, '#description' => $this->t('When enabled, the user must confirm the account cancellation via email.'));
     // Also allow to send account canceled notification mail, if enabled.
     $form['user_cancel_notify'] = array('#type' => 'checkbox', '#title' => $this->t('Notify user when account is canceled.'), '#default_value' => FALSE, '#access' => $this->config('user.settings')->get('notify.status_canceled'), '#description' => $this->t('When enabled, the user will receive an email notification after the account has been canceled.'));
     $form = parent::buildForm($form, $form_state);
     return $form;
 }