当前位置: 首页>>代码示例>>PHP>>正文


PHP Link::fromTextAndUrl方法代码示例

本文整理汇总了PHP中Drupal\Core\Link::fromTextAndUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Link::fromTextAndUrl方法的具体用法?PHP Link::fromTextAndUrl怎么用?PHP Link::fromTextAndUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Link的用法示例。


在下文中一共展示了Link::fromTextAndUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: render

 /**
  * Adds some descriptive text to our entity list.
  *
  * @return array
  *   Renderable array.
  */
 public function render()
 {
     $build['description'] = array('#markup' => $this->t("<p>This is a list of the countries currently" . " defined for use on your Drupal site. This country data adheres to" . " the @iso standard for country and zone naming used by payment" . " providers and package couriers.</p>" . "<p>To make a country available for use at checkout or in a user's" . " address book, 'Enable' the country using the widget in the" . " 'Operations' for that country. You may also 'Disable' a country to" . " prevent customers from selecting that country as a billing or" . " shipping address.</p>" . "<p>You may also use the 'Edit' widget in the 'Operations' column to" . " edit a country's name or address format.</p>", ['@iso' => Link::fromTextAndUrl('ISO 3166', Url::fromUri('http://en.wikipedia.org/wiki/ISO_3166'))->toString()]));
     $build += parent::render();
     $build['table']['#empty'] = $this->t('No countries have been configured yet.');
     return $build;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:13,代码来源:CountryListBuilder.php

示例2: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $enabled_link = Link::fromTextAndUrl(t('enabled'), Url::fromRoute('system.modules_list'));
     $form['#attached']['library'][] = 'system/drupal.system';
     $form['exclude_node_title_search'] = ['#type' => 'checkbox', '#title' => $this->t('Remove node title from search pages'), '#description' => $this->t('Select if you wish to remove title from search pages. You need to have Search module @link.', ['@link' => $enabled_link]), '#default_value' => $this->excludeNodeTitleManager->isSearchExcluded(), '#disabled' => !\Drupal::moduleHandler()->moduleExists('search')];
     $form['content_type'] = ['#type' => 'fieldset', '#title' => $this->t('Exclude title by content types'), '#description' => $this->t('Define title excluding settings for each content type.'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#tree' => TRUE];
     foreach ($this->bundleInfo->getBundleInfo('node') as $node_type => $node_type_info) {
         $form['#attached']['drupalSettings']['exclude_node_title']['content_types'][$node_type] = $node_type_info['label'];
         $form['content_type'][$node_type]['content_type_value'] = ['#type' => 'select', '#title' => $node_type_info['label'], '#default_value' => $this->excludeNodeTitleManager->getBundleExcludeMode($node_type), '#options' => ['none' => $this->t('None'), 'all' => $this->t('All nodes...'), 'user' => $this->t('User defined nodes...')]];
         $entity_view_modes = $this->entityDisplayRepository->getViewModes('node');
         $modes = [];
         foreach ($entity_view_modes as $view_mode_name => $view_mode_info) {
             $modes[$view_mode_name] = $view_mode_info['label'];
         }
         $modes += ['nodeform' => $this->t('Node form')];
         switch ($form['content_type'][$node_type]['content_type_value']['#default_value']) {
             case 'all':
                 $title = $this->t('Exclude title from all nodes in the following view modes:');
                 break;
             case 'user defined':
                 $title = $this->t('Exclude title from user defined nodes in the following view modes:');
                 break;
             default:
                 $title = $this->t('Exclude from:');
         }
         $form['content_type'][$node_type]['content_type_modes'] = ['#type' => 'checkboxes', '#title' => $title, '#default_value' => $this->excludeNodeTitleManager->getExcludedViewModes($node_type), '#options' => $modes, '#states' => ['invisible' => ['select[name="content_type[' . $node_type . '][content_type_value]"]' => ['value' => 'none']]]];
     }
     $form['#attached']['library'][] = 'exclude_node_title/drupal.exclude_node_title.admin';
     return parent::buildForm($form, $form_state);
 }
开发者ID:seongbae,项目名称:AsianChamber-Web,代码行数:33,代码来源:ExcludeNodeTitleAdminSettingsForm.php

示例3: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $config = \Drupal::config('uc_cart.settings');
     $text = $config->get('breadcrumb_text');
     $links[] = Link::createFromRoute($this->t('Home'), '<front>');
     $links[] = Link::fromTextAndUrl($text, Url::fromUri('internal:/' . $config->get('breadcrumb_url'), ['absolute' => TRUE]));
     $breadcrumb = new Breadcrumb();
     $breadcrumb->setLinks($links);
     return $breadcrumb;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:13,代码来源:CartBreadcrumbBuilder.php

示例4: buildConfigurationForm

 /**
  * {@inheritdoc}
  */
 public function buildConfigurationForm(array $form, FormStateInterface $form_state)
 {
     $form['wps_email'] = array('#type' => 'email', '#title' => $this->t('PayPal e-mail address'), '#description' => $this->t('The e-mail address you use for the PayPal account you want to receive payments.'), '#default_value' => $this->configuration['wps_email']);
     $form['wpp_server'] = array('#type' => 'select', '#title' => $this->t('API server'), '#description' => $this->t('Sign up for and use a Sandbox account for testing.'), '#options' => array('https://api-3t.sandbox.paypal.com/nvp' => $this->t('Sandbox'), 'https://api-3t.paypal.com/nvp' => $this->t('Live')), '#default_value' => $this->configuration['wpp_server']);
     $form['api'] = array('#type' => 'details', '#title' => $this->t('API credentials'), '#description' => $this->t('@link for information on obtaining credentials.  You need to acquire an API Signature.  If you have already requested API credentials, you can review your settings under the API Access section of your PayPal profile.', ['@link' => Link::fromTextAndUrl($this->t('Click here'), Url::fromUri('https://developer.paypal.com/docs/classic/api/apiCredentials/'))->toString()]), '#open' => TRUE);
     $form['api']['api_username'] = array('#type' => 'textfield', '#title' => $this->t('API username'), '#default_value' => $this->configuration['api']['api_username']);
     $form['api']['api_password'] = array('#type' => 'textfield', '#title' => $this->t('API password'), '#default_value' => $this->configuration['api']['api_password']);
     $form['api']['api_signature'] = array('#type' => 'textfield', '#title' => $this->t('Signature'), '#default_value' => $this->configuration['api']['api_signature']);
     return $form;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:13,代码来源:PayPalPaymentMethodPluginBase.php

示例5: listOrderPackages

 /**
  * Displays a list of an order's packaged products.
  *
  * @param \Drupal\uc_order\OrderInterface $uc_order
  *   The order.
  *
  * @return array|\Symfony\Component\HttpFoundation\RedirectResponse
  *   A render array, or a redirect response if there are no packaged products.
  */
 public function listOrderPackages(OrderInterface $uc_order)
 {
     $shipping_type_options = uc_quote_shipping_type_options();
     $header = array($this->t('Package ID'), $this->t('Products'), $this->t('Shipping type'), $this->t('Package type'), $this->t('Shipment ID'), $this->t('Tracking number'), $this->t('Labels'), $this->t('Actions'));
     $rows = array();
     $result = db_query('SELECT package_id FROM {uc_packages} WHERE order_id = :id', [':id' => $uc_order->id()]);
     while ($package_id = $result->fetchField()) {
         $package = Package::load($package_id);
         $row = array();
         // Package ID.
         $row[] = array('data' => array('#plain_text' => $package->package_id));
         $product_list = array();
         $result2 = db_query('SELECT op.order_product_id, pp.qty, op.title, op.model FROM {uc_packaged_products} pp LEFT JOIN {uc_order_products} op ON op.order_product_id = pp.order_product_id WHERE pp.package_id = :id', [':id' => $package->package_id]);
         foreach ($result2 as $product) {
             $product_list[] = $product->qty . ' x ' . $product->model;
         }
         // Products.
         $row[] = array('data' => array('#theme' => 'item_list', '#items' => $product_list));
         // Shipping type.
         $row[] = isset($shipping_type_options[$package->shipping_type]) ? $shipping_type_options[$package->shipping_type] : strtr($package->shipping_type, '_', ' ');
         // Package type.
         $row[] = array('data' => array('#plain_text' => $package->pkg_type));
         // Shipment ID.
         $row[] = isset($package->sid) ? Link::createFromRoute($package->sid, 'uc_fulfillment.view_shipment', ['uc_order' => $uc_order->id(), 'shipment_id' => $package->sid])->toString() : '';
         // Tracking number.
         $row[] = isset($package->tracking_number) ? array('data' => array('#plain_text' => $package->tracking_number)) : '';
         if ($package->label_image && ($image = file_load($package->label_image))) {
             $package->label_image = $image;
         } else {
             unset($package->label_image);
         }
         // Shipping label.
         if (isset($package->sid) && isset($package->label_image)) {
             $method = db_query('SELECT shipping_method FROM {uc_shipments} WHERE sid = :sid', [':sid' => $package->sid])->fetchField();
             $row[] = Link::fromTextAndUrl("image goes here", Url::fromUri('base:admin/store/orders/' . $uc_order->id() . '/shipments/labels/' . $method . '/' . $package->label_image->uri, ['uc_order' => $uc_order->id(), 'method' => $method, 'image_uri' => $package->label_image->uri]))->toString();
         } else {
             $row[] = '';
         }
         // Operations.
         $ops = array('#type' => 'operations', '#links' => array('edit' => array('title' => $this->t('Edit'), 'url' => Url::fromRoute('uc_fulfillment.edit_package', ['uc_order' => $uc_order->id(), 'package_id' => $package->package_id])), 'ship' => array('title' => $this->t('Ship'), 'url' => Url::fromRoute('uc_fulfillment.new_shipment', ['uc_order' => $uc_order->id()], ['query' => ['pkgs' => $package->package_id]])), 'delete' => array('title' => $this->t('Delete'), 'url' => Url::fromRoute('uc_fulfillment.delete_package', ['uc_order' => $uc_order->id(), 'package_id' => $package->package_id]))));
         if ($package->sid) {
             $ops['#links']['cancel'] = array('title' => $this->t('Cancel'), 'url' => Url::fromRoute('uc_fulfillment.cancel_package', ['uc_order' => $uc_order->id(), 'package_id' => $package->package_id]));
         }
         $row[] = array('data' => $ops);
         $rows[] = $row;
     }
     if (empty($rows)) {
         drupal_set_message($this->t("This order's products have not been organized into packages."), 'warning');
         return $this->redirect('uc_fulfillment.new_package', ['uc_order' => $uc_order->id()]);
     }
     $build['packages'] = array('#theme' => 'table', '#header' => $header, '#rows' => $rows);
     return $build;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:62,代码来源:PackageController.php

示例6: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     /* @var $entity \Drupal\search_api_page\SearchApiPageInterface */
     $row['label'] = $entity->label();
     $path = $entity->getPath();
     if (!empty($path)) {
         $row['path'] = Link::fromTextAndUrl($entity->getPath(), Url::fromRoute('search_api_page.' . \Drupal::languageManager()->getDefaultLanguage()->getId() . '.' . $entity->id()));
     } else {
         $row['path'] = '';
     }
     return $row + parent::buildRow($entity);
 }
开发者ID:nB-MDSO,项目名称:mdso-d8blog,代码行数:15,代码来源:SearchApiPageListBuilder.php

示例7: sorry

 /**
  * Text, if the user answered wrong.
  *
  * @param \Drupal\node\NodeInterface $node
  *   The node the client form belongs to.
  * @return array
  */
 public function sorry(NodeInterface $node)
 {
     $config = $this->config('field_quiz.settings');
     $text = $config->get('field_quiz.test_answer_wrong');
     $elements[] = array('#type' => 'html_tag', '#tag' => 'p', '#attributes' => array('style' => 'color: red'), '#value' => $this->t($text));
     $url = Url::fromRoute('entity.node.canonical', array('node' => $node->id()));
     $project_link = Link::fromTextAndUrl(t('Please try again.'), $url);
     $project_link = $project_link->toRenderable();
     // If you need some attributes.
     $project_link['#attributes'] = array('class' => array('button', 'button-action', 'button--primary', 'button--small'));
     $elements[] = array('#type' => 'html_tag', '#tag' => 'p', '#attributes' => array(), '#value' => render($project_link));
     return $elements;
 }
开发者ID:badelas,项目名称:afroweb,代码行数:20,代码来源:FieldQuizController.php

示例8: settingsForm

 /**
  * {@inheritdoc}
  */
 public function settingsForm(array $form, FormStateInterface $form_state)
 {
     $image_styles = image_style_options(FALSE);
     $description_link = Link::fromTextAndUrl($this->t('Configure Image Styles'), Url::fromRoute('entity.image_style.collection'));
     $element['image_style'] = ['#title' => t('Image style'), '#type' => 'select', '#default_value' => $this->getSetting('image_style'), '#empty_option' => t('None (original image)'), '#options' => $image_styles, '#description' => $description_link->toRenderable() + ['#access' => $this->currentUser->hasPermission('administer image styles')]];
     $link_types = array('content' => t('Content'), 'file' => t('File'));
     $element['image_link'] = array('#title' => t('Link image to'), '#type' => 'select', '#default_value' => $this->getSetting('image_link'), '#empty_option' => t('Nothing'), '#options' => $link_types);
     $element['items'] = array('#type' => 'number', '#title' => $this->t('Items'), '#description' => $this->t('Maximum amount of items displayed at a time with the widest browser width.'), '#default_value' => $this->getSetting('items'));
     $element['itemsDesktop'] = array('#type' => 'textfield', '#title' => $this->t('Items Desktop'), '#description' => $this->t('This allows you to preset the number of slides visible with a particular browser width. The format is [x,y] whereby x=browser width and y=number of slides displayed. For example [1199,4] means that if(window<=1199){ show 4 slides per page}'), '#default_value' => $this->getSetting('itemsDesktop'));
     $element['itemsDesktopSmall'] = array('#type' => 'textfield', '#title' => $this->t('Items Desktop Small'), '#description' => $this->t('Example: [979,3]'), '#default_value' => $this->getSetting('itemsDesktopSmall'));
     $element['itemsTablet'] = array('#type' => 'textfield', '#title' => $this->t('Items Tablet'), '#description' => $this->t('Example: [768,2]'), '#default_value' => $this->getSetting('itemsTablet'));
     $element['itemsMobile'] = array('#type' => 'textfield', '#title' => $this->t('Items Mobile'), '#description' => $this->t('Example: [479,1]'), '#default_value' => $this->getSetting('itemsMobile'));
     $element['singleItem'] = array('#type' => 'checkbox', '#title' => $this->t('Single Item'), '#default_value' => $this->getSetting('singleItem'), '#description' => $this->t('Display only one item.'));
     //itemsScaleUp
     $element['itemsScaleUp'] = array('#type' => 'checkbox', '#title' => $this->t('Items ScaleUp'), '#default_value' => $this->getSetting('itemsScaleUp'), '#description' => $this->t('Option to not stretch items when it is less than the supplied items.'));
     //slideSpeed
     $element['slideSpeed'] = array('#type' => 'number', '#title' => $this->t('Slide Speed'), '#default_value' => $this->getSetting('slideSpeed'), '#description' => $this->t('Slide speed in milliseconds.'));
     //paginationSpeed
     $element['paginationSpeed'] = array('#type' => 'number', '#title' => $this->t('Pagination Speed'), '#default_value' => $this->getSetting('paginationSpeed'), '#description' => $this->t('Pagination speed in milliseconds.'));
     //rewindSpeed
     $element['rewindSpeed'] = array('#type' => 'number', '#title' => $this->t('Rewind Speed'), '#default_value' => $this->getSetting('rewindSpeed'), '#description' => $this->t('Rewind speed in milliseconds.'));
     //autoPlay
     $element['autoPlay'] = array('#type' => 'checkbox', '#title' => $this->t('AutoPlay'), '#default_value' => $this->getSetting('autoPlay'));
     //stopOnHover
     $element['stopOnHover'] = array('#type' => 'checkbox', '#title' => $this->t('Stop On Hover'), '#default_value' => $this->getSetting('stopOnHover'), '#description' => $this->t('Stop autoplay on mouse hover.'));
     //navigation
     $element['navigation'] = array('#type' => 'checkbox', '#title' => $this->t('Navigation'), '#default_value' => $this->getSetting('navigation'), '#description' => $this->t('Display "next" and "prev" buttons.'));
     //prevText
     $element['prevText'] = array('#type' => 'textfield', '#title' => $this->t('Prev Text'), '#default_value' => $this->getSetting('prevText'), '#description' => $this->t('Text for navigation prev button'));
     //nextText
     $element['nextText'] = array('#type' => 'textfield', '#title' => $this->t('Next Text'), '#default_value' => $this->getSetting('nextText'), '#description' => $this->t('Text for navigation next button'));
     //rewindNav
     $element['rewindNav'] = array('#type' => 'checkbox', '#title' => $this->t('Rewind Nav'), '#default_value' => $this->getSetting('rewindNav'), '#description' => $this->t('Slide to first item.'));
     //scrollPerPage
     $element['scrollPerPage'] = array('#type' => 'checkbox', '#title' => $this->t('Scroll Per Page'), '#default_value' => $this->getSetting('scrollPerPage'), '#description' => $this->t('Scroll per page not per item. This affect next/prev buttons and mouse/touch dragging.'));
     //pagination
     $element['pagination'] = array('#type' => 'checkbox', '#title' => $this->t('pagination'), '#default_value' => $this->getSetting('pagination'), '#description' => $this->t('Show pagination.'));
     //paginationNumbers
     $element['paginationNumbers'] = array('#type' => 'checkbox', '#title' => $this->t('Pagination Numbers'), '#default_value' => $this->getSetting('paginationNumbers'), '#description' => $this->t('Show numbers inside pagination buttons.'));
     //responsive
     $element['responsive'] = array('#type' => 'checkbox', '#title' => $this->t('Responsive'), '#default_value' => $this->getSetting('responsive'), '#description' => $this->t('Uncheck to use Owl Carousel on desktop-only.'));
     //responsiveRefreshRate
     $element['responsiveRefreshRate'] = array('#type' => 'number', '#title' => $this->t('Responsive Refresh Rate'), '#default_value' => $this->getSetting('responsiveRefreshRate'), '#description' => $this->t('Check window width changes every 200ms for responsive actions.'));
     //mouseDrag
     $element['mouseDrag'] = array('#type' => 'checkbox', '#title' => $this->t('Mouse Drag'), '#default_value' => $this->getSetting('mouseDrag'), '#description' => $this->t('Turn off/on mouse events.'));
     //touchDrag
     $element['touchDrag'] = array('#type' => 'checkbox', '#title' => $this->t('Touch Drag'), '#default_value' => $this->getSetting('touchDrag'), '#description' => $this->t('Turn off/on touch events.'));
     //transitionStyle
     $element['transitionStyle'] = array('#type' => 'select', '#options' => array('fade' => $this->t('Fade'), 'backSlide' => $this->t('Back Slide'), 'goDown' => $this->t('Go Down'), 'scaleUp' => $this->t('ScaleUp')), '#title' => $this->t('Transition Style'), '#default_value' => $this->getSetting('transitionStyle'), '#description' => $this->t('Add CSS3 transition style. Works only with one item on screen.'));
     return $element + parent::settingsForm($form, $form_state);
 }
开发者ID:tabvn,项目名称:owl,代码行数:54,代码来源:OwlFieldFormatter.php

示例9: build

 /**
  * {@inheritdoc}
  */
 public function build()
 {
     $build = [];
     //$path_alias = \Drupal::service('path.alias_manager')->getAliasByPath('');
     //dpm("ALIAS = " . $path_alias);
     //$url = Url::fromRoute('contact.site_page');
     // @todo set internal paths in config
     $url = Url::fromUri('internal:/artists');
     $link = Link::fromTextAndUrl(t('Meet the Chalkers<span>Learn more about us</span>'), $url);
     $link = $link->toRenderable();
     $link['#attributes'] = array('class' => array('internal'));
     $linkMarkup = render($link);
     $output = ['#theme' => 'chalk_display_meet', '#meet_link' => $linkMarkup, '#video' => '', '#attached' => array('library' => array('chalk_display/chalk_display'))];
     $build['chalk_meet_block']['#markup'] = render($output);
     return $build;
 }
开发者ID:r-daneelolivaw,项目名称:chalk,代码行数:19,代码来源:ChalkMeetBlock.php

示例10: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $breadcrumb = new Breadcrumb();
     $node = $route_match->getParameter('node');
     // Homepage link.
     $links[] = Link::createFromRoute($this->t('Home'), '<front>');
     // First assigned tag.
     if (!empty($node->field_tags[0]->target_id)) {
         $tid = $node->field_tags[0]->target_id;
         $term_name = Term::load($tid)->get('name')->value;
         $links[] = Link::createFromRoute($term_name, 'entity.taxonomy_term.canonical', ['taxonomy_term' => $tid]);
     }
     // The node itself.
     $links[] = Link::fromTextAndUrl($node->getTitle(), Url::fromRoute('<current>'));
     $breadcrumb->addCacheContexts(['route']);
     return $breadcrumb->setLinks($links);
 }
开发者ID:hugronaphor,项目名称:cornel,代码行数:20,代码来源:SiteNodeBreadcrumbBuilder.php

示例11: build

 /**
  * {@inheritdoc}
  */
 public function build()
 {
     $build = [];
     // @todo set internal paths in config
     // @todo refactoring needed
     $contactUrl = Url::fromUri('internal:/get-involved');
     $contactLink = Link::fromTextAndUrl(t('Get involved !'), $contactUrl);
     $contactLink = $contactLink->toRenderable();
     $contactLink['#attributes'] = array('class' => array('contact-link', 'internal'));
     $brochureUrl = Url::fromUri('internal:/sites/default/files/brochures/chalk-brochure-2016.pdf');
     $brochureLink = Link::fromTextAndUrl(t('Get our brochure [pdf]'), $brochureUrl);
     $brochureLink = $brochureLink->toRenderable();
     $brochureLink['#attributes'] = array('class' => array('brochure-link', 'internal'));
     $output = ['#theme' => 'chalk_display_footer', '#contact' => $this->contactMarkup(), '#contact_link' => render($contactLink), '#brochure_link' => render($brochureLink), '#social_links' => render($this->socialLinksList()), '#credits' => $this->creditsMarkup()];
     $build['chalk_footer_block']['#markup'] = render($output);
     return $build;
 }
开发者ID:r-daneelolivaw,项目名称:chalk,代码行数:20,代码来源:ChalkFooterBlock.php

示例12: fieldSettingsForm

 /**
  * {@inheritdoc}
  */
 public function fieldSettingsForm(array $form, FormStateInterface $form_state)
 {
     $element = array();
     $field_settings = $this->getSettings();
     $embridge_settings = \Drupal::config('embridge.settings');
     /** @var EmbridgeCatalog[] $entities */
     $entities = EmbridgeCatalog::loadMultiple();
     $options = [];
     foreach ($entities as $entity) {
         $options[$entity->id()] = $entity->label();
     }
     $element['catalog_id'] = array('#type' => 'select', '#title' => t('Catalog'), '#default_value' => $field_settings['catalog_id'], '#options' => $options, '#description' => t("Select the Catalog to source media from for this field."), '#required' => TRUE, '#weight' => 6);
     $libraries_admin = Link::fromTextAndUrl('libraries admin', Url::fromUri($embridge_settings->get('uri') . '/' . $field_settings['catalog_id'] . '/views/modules/library/index.html'));
     $element['library_id'] = array('#type' => 'textfield', '#title' => t('Library'), '#default_value' => $field_settings['library_id'], '#description' => t("Limit uploads via this field to a specific library. This will also provide a default library on the asset search advanced filter. To identify the library ID, select the library on the @libraries_admin page and note the ID.", ['@libraries_admin' => $libraries_admin->toString()]), '#required' => FALSE, '#size' => 10, '#weight' => 6);
     $element['allow_search'] = array('#type' => 'checkbox', '#title' => t('Allow search'), '#default_value' => $field_settings['allow_search'], '#description' => t("Check this to allow users to search EMDB for existing assets, requires <em>search embridge assets</em> permission."), '#weight' => 6);
     return $element + parent::fieldSettingsForm($form, $form_state);
 }
开发者ID:acbramley,项目名称:embridge,代码行数:20,代码来源:EmbridgeAssetItem.php

示例13: preprocessVariables

 /**
  * {@inheritdoc}
  */
 public function preprocessVariables(Variables $variables, $hook, array $info)
 {
     $options = [];
     $file = $variables['file'] instanceof File ? $variables['file'] : File::load($variables['file']->fid);
     $url = file_create_url($file->getFileUri());
     $file_size = $file->getSize();
     $mime_type = $file->getMimeType();
     // Set options as per anchor format described at
     // http://microformats.org/wiki/file-format-examples
     $options['attributes']['type'] = "{$mime_type}; length={$file_size}";
     // Use the description as the link text if available.
     if (empty($variables['description'])) {
         $link_text = $file->getFilename();
     } else {
         $link_text = $variables['description'];
         $options['attributes']['title'] = $file->getFilename();
     }
     // Retrieve the generic mime type from core (mislabeled as "icon_class").
     $generic_mime_type = file_icon_class($mime_type);
     // Map the generic mime types to an icon and state.
     $mime_map = ['application-x-executable' => ['label' => t('binary file'), 'icon' => 'console'], 'audio' => ['label' => t('audio file'), 'icon' => 'headphones'], 'image' => ['label' => t('image'), 'icon' => 'picture'], 'package-x-generic' => ['label' => t('archive'), 'icon' => 'compressed'], 'text' => ['label' => t('document'), 'icon' => 'file'], 'video' => ['label' => t('video'), 'icon' => 'film']];
     // Retrieve the mime map array.
     $mime = isset($mime_map[$generic_mime_type]) ? $mime_map[$generic_mime_type] : ['label' => t('file'), 'icon' => 'file', 'state' => 'primary'];
     // Classes to add to the file field for icons.
     //    $variables->addClass([
     //      'file',
     //      // Add a specific class for each and every mime type.
     //      'file--mime-' . strtr($mime_type, ['/' => '-', '.' => '-']),
     //      // Add a more general class for groups of well known mime types.
     //      'file--' . $generic_mime_type,
     //    ]);
     // Set the icon for the mime type.
     $icon = Materialize::material_icons_font($mime['icon']);
     $variables->icon = Element::create($icon)->addClass('text-primary')->getArray();
     $options['attributes']['title'] = t('Open @mime in new window', ['@mime' => $mime['label']]);
     if ($this->theme->getSetting('tooltip_enabled')) {
         $options['attributes']['data-toggle'] = 'tooltip';
         $options['attributes']['data-placement'] = 'bottom';
     }
     $variables['link'] = Link::fromTextAndUrl($link_text, Url::fromUri($url, $options));
     // Add the file size as a variable.
     $variables->file_size = format_size($file_size);
     // Preprocess attributes.
     $this->preprocessAttributes($variables, $hook, $info);
 }
开发者ID:archual,项目名称:drupal_materialize_theme,代码行数:48,代码来源:FileLink.php

示例14: form

 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $task_item = $this->entity;
     $form['#title'] = $task_item->label();
     $job_item = $task_item->getJobItem();
     $job = $job_item->getJob();
     $form['info'] = array('#type' => 'container', '#attributes' => array('class' => array('tmgmt-local-task-info', 'clearfix')), '#weight' => 0);
     $url = $job_item->getSourceUrl();
     $form['info']['source'] = array('#type' => 'item', '#title' => t('Source'), '#markup' => $url ? Link::fromTextAndUrl($job_item->getSourceLabel(), $url)->toString() : $job_item->getSourceLabel(), '#prefix' => '<div class="tmgmt-ui-source tmgmt-ui-info-item">', '#suffix' => '</div>');
     $form['info']['sourcetype'] = array('#type' => 'item', '#title' => t('Source type'), '#markup' => $job_item->getSourceType(), '#prefix' => '<div class="tmgmt-ui-source-type tmgmt-ui-info-item">', '#suffix' => '</div>');
     $form['info']['source_language'] = array('#type' => 'item', '#title' => t('Source language'), '#markup' => $job_item->getJob()->getSourceLanguage()->getName(), '#prefix' => '<div class="tmgmt-ui-source-language tmgmt-ui-info-item">', '#suffix' => '</div>');
     $form['info']['target_language'] = array('#type' => 'item', '#title' => t('Target language'), '#markup' => $job_item->getJob()->getTargetLanguage()->getName(), '#prefix' => '<div class="tmgmt-ui-target-language tmgmt-ui-info-item">', '#suffix' => '</div>');
     $form['info']['changed'] = array('#type' => 'item', '#title' => t('Last change'), '#value' => $task_item->getChangedTime(), '#markup' => \Drupal::service('date.formatter')->format($task_item->getChangedTime()), '#prefix' => '<div class="tmgmt-ui-changed tmgmt-ui-info-item">', '#suffix' => '</div>');
     $statuses = LocalTaskItem::getStatuses();
     $form['info']['status'] = array('#type' => 'item', '#title' => t('Status'), '#markup' => $statuses[$task_item->getStatus()], '#prefix' => '<div class="tmgmt-ui-task-item-status tmgmt-ui-info-item">', '#suffix' => '</div>', '#value' => $task_item->getStatus());
     $task = $task_item->getTask();
     $url = $task->toUrl();
     $form['info']['task'] = array('#type' => 'item', '#title' => t('Task'), '#markup' => Link::fromTextAndUrl($task->label(), $url)->toString(), '#prefix' => '<div class="tmgmt-ui-task tmgmt-ui-info-item">', '#suffix' => '</div>');
     if ($job->getSetting('job_comment')) {
         $form['job_comment'] = array('#type' => 'item', '#title' => t('Job comment'), '#markup' => Xss::filter($job->getSetting('job_comment')));
     }
     $form['translation'] = array('#type' => 'container');
     // Build the translation form.
     $data = $task_item->getData();
     // Need to keep the first hierarchy. So flatten must take place inside
     // of the foreach loop.
     $zebra = 'even';
     foreach (Element::children($data) as $key) {
         $flattened = \Drupal::service('tmgmt.data')->flatten($data[$key], $key);
         $form['translation'][$key] = $this->formElement($flattened, $task_item, $zebra);
     }
     $form['footer'] = tmgmt_color_local_review_legend();
     $form['#attached']['library'][] = 'tmgmt/admin';
     return $form;
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:39,代码来源:LocalTaskItemForm.php

示例15: buildNodeInfo

 /**
  * Builds and returns the node information.
  *
  * @param bool $debug_mode
  *   The level of detail to include.
  *
  * @return array
  */
 public static function buildNodeInfo($debug_mode)
 {
     global $user;
     $visible_nodes = self::visibleNodes();
     if (count($visible_nodes) == 0) {
         return array();
     } else {
         $single_nid = reset($visible_nodes);
     }
     // Find out whether our DnaUser block is active or not.
     //dpm($blocks = \Drupal::entityTypeManager()->getStorage('block')->load());
     $user_block_active = FALSE;
     //foreach ($blocks as $block) {
     //  if ($block->get('plugin') == 'devel_dna_user_block') {
     //    $user_block_active = TRUE;
     //  }
     //}
     // Include rows where nid == 0.
     $nids = array_merge(array(0 => 0), $visible_nodes);
     $query = \Drupal::database()->select('node_access', 'na');
     $query->fields('na')->condition('na.nid', $nids, 'IN');
     $query->orderBy('na.nid')->orderBy('na.realm')->orderBy('na.gid');
     $nodes = Node::loadMultiple($nids);
     if (!$debug_mode) {
         $headers = array('node', 'realm', 'gid', 'view', 'update', 'delete', 'explained');
         $rows = array();
         foreach ($query->execute() as $row) {
             $explained = \Drupal::moduleHandler()->invokeAll('node_access_explain', [$row]);
             $node_title = self::get_node_title($nodes[$row->nid]);
             $title_attribute = \Drupal::request()->getRequestUri();
             if (Unicode::strlen($node_title) > 20) {
                 $title_attribute = $title_attribute . ': ' . $node_title;
                 $node_title = Unicode::substr($node_title, 0, 18) . '...';
             }
             $rows[] = array(empty($row->nid) ? '0' : Link::fromTextAndUrl($node_title, Url::fromUri(\Drupal::request()->getUri(), ['fragment' => 'node-' . $row->nid, 'attributes' => ['title' => $title_attribute]])), $row->realm, $row->gid, $row->grant_view, $row->grant_update, $row->grant_delete, implode('<br />', $explained));
         }
         $output[] = array('#theme' => 'table', '#header' => $headers, '#rows' => $rows, '#attributes' => array('style' => 'text-align: left'));
     } else {
         $tr = 't';
         $variables = array('!na' => '{node_access}');
         $states = array('default' => array(t('default'), 'ok', t('Default record supplied by core in the absence of any other non-empty records; in !na.', $variables)), 'ok' => array(t('ok'), 'ok', t('Highest priority record; in !na.', $variables)), 'removed' => array(t('removed'), '', t('Was removed in @func; not in !na.', $variables + array('@func' => 'hook_node_access_records_alter()'))), 'static' => array(t('static'), 'ok', t('Non-standard record in !na.', $variables)), 'unexpected' => array(t('unexpected'), 'warning', t('The 0/all/0/... record applies to all nodes and all users -- usually it should not be present in !na if any node access module is active!')), 'ignored' => array(t('ignored'), 'warning', t('Lower priority record; not in !na and thus ignored.', $variables)), 'empty' => array(t('empty'), 'warning', t('Does not grant any access, but could block lower priority records; not in !na.', $variables)), 'wrong' => array(t('wrong'), 'error', t('Is rightfully in !na but at least one access flag is wrong!', $variables)), 'missing' => array(t('missing'), 'error', t("Should be in !na but isn't!", $variables)), 'removed!' => array(t('removed!'), 'error', t('Was removed in @func; should NOT be in !na!', $variables + array('@func' => 'hook_node_access_records_alter()'))), 'illegitimate' => array(t('illegitimate'), 'error', t('Should NOT be in !na because of lower priority!', $variables)), 'alien' => array(t('alien'), 'error', t('Should NOT be in !na because of unknown origin!', $variables)));
         $active_states = array('default', 'ok', 'static', 'unexpected', 'wrong', 'illegitimate', 'alien');
         $headers = array(t('node'), t('prio'), t('status'), t('realm'), t('gid'), t('view'), t('update'), t('delete'), t('explained'));
         $headers = self::format_row($headers);
         $active_records = array();
         foreach ($query->execute() as $active_record) {
             $active_records[$active_record->nid][$active_record->realm][$active_record->gid] = $active_record;
         }
         $all_records = $grants_data = $checked_grants = $grants = array();
         foreach (array('view', 'update', 'delete') as $op) {
             $grants[$op] = self::simulate_module_invoke_all('node_grants', $user, $op);
             // Call all hook_node_grants_alter() implementations.
             $grants_data[$op] = self::simulate_node_grants_alter($grants[$op], $user, $op);
         }
         foreach ($nids as $nid) {
             $top_priority = -99999;
             $acquired_records_nid = array();
             if ($node = Node::load($nid)) {
                 // Check node_access_acquire_grants().
                 $records = self::simulate_module_invoke_all('node_access_records', $node);
                 // Check drupal_alter('node_access_records').
                 $data = self::simulate_node_access_records_alter($records, $node);
                 if (!empty($data)) {
                     foreach ($data as $data_by_realm) {
                         foreach ($data_by_realm as $data_by_realm_gid) {
                             if (isset($data_by_realm_gid['current'])) {
                                 $record = $data_by_realm_gid['current'];
                             } elseif (isset($data_by_realm_gid['original'])) {
                                 $record = $data_by_realm_gid['original'];
                                 $record['#removed'] = 1;
                             } else {
                                 continue;
                             }
                             $priority = intval(isset($record['priority']) ? $record['priority'] : 0);
                             $top_priority = isset($top_priority) ? max($top_priority, $priority) : $priority;
                             $record['priority'] = isset($record['priority']) ? $priority : '&ndash;&nbsp;';
                             $record['history'] = $data_by_realm_gid;
                             $acquired_records_nid[$priority][$record['realm']][$record['gid']] = $record + array('#title' => self::get_node_title($node), '#module' => isset($record['#module']) ? $record['#module'] : '');
                         }
                     }
                     krsort($acquired_records_nid);
                 }
                 //dpm($acquired_records_nid, "acquired_records_nid =");
                 // Check node_access_grants().
                 if ($node->id()) {
                     foreach (array('view', 'update', 'delete') as $op) {
                         $checked_grants[$nid][$op] = array_merge(array('all' => array(0)), $grants[$op]);
                     }
                 }
             }
             // Check for records in the node_access table that aren't returned by
             // node_access_acquire_grants().
//.........这里部分代码省略.........
开发者ID:Nesta,项目名称:ddv8,代码行数:101,代码来源:DnaBlock.php


注:本文中的Drupal\Core\Link::fromTextAndUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。