Example #1
0
 /**
  * Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::render().
  *
  * Renders the contextual fields.
  *
  * @param \Drupal\views\ResultRow $values
  *   The values retrieved from a single row of a view's query result.
  *
  * @see contextual_preprocess()
  * @see contextual_contextual_links_view_alter()
  */
 public function render(ResultRow $values)
 {
     $links = array();
     foreach ($this->options['fields'] as $field) {
         $rendered_field = $this->view->style_plugin->getField($this->view->row_index, $field);
         if (empty($rendered_field)) {
             continue;
         }
         $title = $this->view->field[$field]->last_render_text;
         $path = '';
         if (!empty($this->view->field[$field]->options['alter']['path'])) {
             $path = $this->view->field[$field]->options['alter']['path'];
         }
         if (!empty($title) && !empty($path)) {
             // Make sure that tokens are replaced for this paths as well.
             $tokens = $this->getRenderTokens(array());
             $path = strip_tags(decode_entities(strtr($path, $tokens)));
             $links[$field] = array('href' => $path, 'title' => $title);
             if (!empty($this->options['destination'])) {
                 $links[$field]['query'] = drupal_get_destination();
             }
         }
     }
     // Renders a contextual links placeholder.
     if (!empty($links)) {
         $contextual_links = array('contextual' => array('', array(), array('contextual-views-field-links' => UrlHelper::encodePath(Json::encode($links)))));
         $element = array('#type' => 'contextual_links_placeholder', '#id' => _contextual_links_to_id($contextual_links));
         return drupal_render($element);
     } else {
         return '';
     }
 }
/**
 * Alter content in Administration menu bar before it is rendered.
 *
 * @param $content
 *   A structured array suitable for drupal_render(), at the very least
 *   containing the keys 'menu' and 'links'.  Most implementations likely want
 *   to alter or add to 'links'.
 *
 * $content['menu'] contains the HTML representation of the 'admin_menu' menu
 * tree.
 * @see admin_menu_menu_alter()
 *
 * $content['links'] contains additional top-level links in the Administration
 * menu, such as the icon menu or the logout link. You can add more items here
 * or play with the #weight attribute to customize them.
 * @see theme_admin_menu_links()
 * @see admin_menu_links_icon()
 * @see admin_menu_links_user()
 */
function hook_admin_menu_output_alter(&$content)
{
    // Add new top-level item.
    $content['menu']['myitem'] = array('#title' => t('My item'), '#attributes' => array('class' => array('mymodule-myitem')), '#href' => 'mymodule/path', '#options' => array('query' => drupal_get_destination()), '#weight' => 50);
    // Add link to manually run cron.
    $content['menu']['myitem']['cron'] = array('#title' => t('Run cron'), '#access' => user_access('administer site configuration'), '#href' => 'admin/reports/status/run-cron');
}
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $entity = NULL, $bundle = NULL)
 {
     $this->entity_type = $entity;
     $this->bundle_type = $bundle;
     $config = $this->config('xmlsitemap.settings');
     $request = $this->getRequest();
     if (!$request->isXmlHttpRequest() && ($admin_path = xmlsitemap_get_bundle_path($entity, $bundle))) {
         // If this is a non-ajax form, redirect to the bundle administration page.
         $destination = drupal_get_destination();
         $request->query->remove('destination');
         $url = Url::fromUri($admin_path, array('query' => array($destination)));
         return new RedirectResponse($url);
     } else {
         $form['#title'] = $this->t('@bundle XML sitemap settings', array('@bundle' => $bundle));
     }
     xmlsitemap_add_link_bundle_settings($form, $form_state, $entity, $bundle);
     $form['xmlsitemap']['#type'] = 'markup';
     $form['xmlsitemap']['#value'] = '';
     $form['xmlsitemap']['#access'] = TRUE;
     $form['xmlsitemap']['#show_message'] = TRUE;
     $destination = $request->get('destination');
     $form['actions']['cancel'] = array('#type' => 'link', '#title' => $this->t('Cancel'), '#href' => isset($destination) ? $destination : 'admin/config/search/xmlsitemap/settings', '#weight' => 10);
     $form = parent::buildForm($form, $form_state);
     return $form;
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function getOperations(EntityInterface $entity)
 {
     $operations = parent::getOperations($entity);
     $destination = drupal_get_destination();
     $default = $entity->isDefault();
     $id = $entity->id();
     // Get CSRF token service.
     $token_generator = \Drupal::csrfToken();
     // @TODO: permission checks.
     if ($entity->status() && !$default) {
         $operations['disable'] = array('title' => $this->t('Disable'), 'url' => Url::fromRoute('domain.inline_action', array('op' => 'disable', 'domain' => $id)), 'weight' => 50);
     } elseif (!$default) {
         $operations['enable'] = array('title' => $this->t('Enable'), 'url' => Url::fromRoute('domain.inline_action', array('op' => 'enable', 'domain' => $id)), 'weight' => 40);
     }
     if (!$default) {
         $operations['default'] = array('title' => $this->t('Make default'), 'url' => Url::fromRoute('domain.inline_action', array('op' => 'default', 'domain' => $id)), 'weight' => 30);
         $operations['delete'] = array('title' => $this->t('Delete'), 'url' => Url::fromRoute('entity.domain.delete_form', array('domain' => $id)), 'weight' => 20);
     }
     // @TODO: inject this service?
     $operations += \Drupal::moduleHandler()->invokeAll('domain_operations', array($entity));
     foreach ($operations as $key => $value) {
         if (isset($value['query']['token'])) {
             $operations[$key]['query'] += $destination;
         }
     }
     $default = \Drupal::service('domain.loader')->loadDefaultDomain();
     // Deleting the site default domain is not allowed.
     if ($id == $default->id()) {
         unset($operations['delete']);
     }
     return $operations;
 }
Example #5
0
 /**
  * Gets the list of links used by this field.
  *
  * @return array
  *   The links which are used by the render function.
  */
 protected function getLinks()
 {
     $links = array();
     foreach ($this->options['fields'] as $field) {
         if (empty($this->view->field[$field]->last_render_text)) {
             continue;
         }
         $title = $this->view->field[$field]->last_render_text;
         $path = '';
         $url = NULL;
         if (!empty($this->view->field[$field]->options['alter']['path'])) {
             $path = $this->view->field[$field]->options['alter']['path'];
         } elseif (!empty($this->view->field[$field]->options['alter']['url']) && $this->view->field[$field]->options['alter']['url'] instanceof UrlObject) {
             $url = $this->view->field[$field]->options['alter']['url'];
         }
         // Make sure that tokens are replaced for this paths as well.
         $tokens = $this->getRenderTokens(array());
         $path = strip_tags(String::decodeEntities($this->viewsTokenReplace($path, $tokens)));
         $links[$field] = array('url' => $path ? UrlObject::fromUri('internal:/' . $path) : $url, 'title' => $title);
         if (!empty($this->options['destination'])) {
             $links[$field]['query'] = drupal_get_destination();
         }
     }
     return $links;
 }
 function add_meta()
 {
     ctools_include('display-edit', 'panels');
     ctools_include('content');
     if (empty($this->display->cache_key)) {
         $this->cache = panels_edit_cache_get_default($this->display);
     }
     // @todo we may need an else to load the cache, but I am not sure we
     // actually need to load it if we already have our cache key, and doing
     // so is a waste of resources.
     ctools_include('cleanstring');
     $this->clean_key = ctools_cleanstring($this->display->cache_key);
     $button = array('#type' => 'link', '#title' => t('Customize this page'), '#href' => $this->get_url('save_form'), '#options' => array('query' => drupal_get_destination()), '#id' => 'panels-ipe-customize-page', '#attributes' => array('class' => array('panels-ipe-startedit', 'panels-ipe-pseudobutton')), '#ajax' => array('progress' => 'throbber', 'ipe_cache_key' => $this->clean_key), '#prefix' => '<div class="panels-ipe-pseudobutton-container">', '#suffix' => '</div>');
     panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-startedit', $button);
     // @todo this actually should be an IPE setting instead.
     if (user_access('change layouts in place editing')) {
         $button = array('#type' => 'link', '#title' => t('Change layout'), '#href' => $this->get_url('change_layout'), '#options' => array('query' => drupal_get_destination()), '#attributes' => array('class' => array('panels-ipe-change-layout', 'panels-ipe-pseudobutton', 'ctools-modal-layout')), '#ajax' => array('progress' => 'throbber', 'ipe_cache_key' => $this->clean_key), '#prefix' => '<div class="panels-ipe-pseudobutton-container">', '#suffix' => '</div>');
         panels_ipe_toolbar_add_button($this->clean_key, 'panels-ipe-change-layout', $button);
     }
     ctools_include('ajax');
     ctools_include('modal');
     ctools_modal_add_js();
     ctools_add_css('panels_dnd', 'panels');
     ctools_add_css('panels_admin', 'panels');
     ctools_add_js('panels-base', 'panels');
     ctools_add_js('panels_ipe', 'panels_ipe');
     ctools_add_css('panels_ipe', 'panels_ipe');
     drupal_add_js(array('PanelsIPECacheKeys' => array($this->clean_key)), 'setting');
     drupal_add_library('system', 'ui.draggable');
     drupal_add_library('system', 'ui.droppable');
     drupal_add_library('system', 'ui.sortable');
     parent::add_meta();
 }
 /**
  * {@inheritdoc}
  */
 public function view(OrderInterface $order, array $form, FormStateInterface $form_state)
 {
     $user = \Drupal::currentUser();
     $cart_config = \Drupal::config('uc_cart.settings');
     if ($user->isAuthenticated()) {
         $email = $user->getEmail();
         $contents['#description'] = $this->t('Order information will be sent to your account e-mail listed below.');
         $contents['primary_email'] = array('#type' => 'hidden', '#value' => $email);
         $contents['email_text'] = array('#markup' => '<div>' . $this->t('<b>E-mail address:</b> @email (<a href=":url">edit</a>)', ['@email' => $email, ':url' => Url::fromRoute('entity.user.edit_form', ['user' => $user->id()], ['query' => drupal_get_destination()])->toString()]) . '</div>');
     } else {
         $email = $order->getEmail();
         $contents['#description'] = $this->t('Enter a valid email address for this order or <a href=":url">click here</a> to login with an existing account and return to checkout.', [':url' => Url::fromRoute('user.login', [], ['query' => drupal_get_destination()])->toString()]);
         $contents['primary_email'] = array('#type' => 'email', '#title' => $this->t('E-mail address'), '#default_value' => $email, '#required' => TRUE);
         if ($cart_config->get('email_validation')) {
             $contents['primary_email_confirm'] = array('#type' => 'email', '#title' => $this->t('Confirm e-mail address'), '#default_value' => $email, '#required' => TRUE);
         }
         $contents['new_account'] = array();
         if ($cart_config->get('new_account_name')) {
             $contents['new_account']['name'] = array('#type' => 'textfield', '#title' => $this->t('Username'), '#default_value' => isset($order->data->new_user_name) ? $order->data->new_user_name : '', '#maxlength' => 60, '#size' => 32);
         }
         if ($cart_config->get('new_account_password')) {
             $contents['new_account']['pass'] = array('#type' => 'password', '#title' => $this->t('Password'), '#maxlength' => 32, '#size' => 32);
             $contents['new_account']['pass_confirm'] = array('#type' => 'password', '#title' => $this->t('Confirm password'), '#description' => $this->t('Passwords must match to proceed.'), '#maxlength' => 32, '#size' => 32);
         }
         if (!empty($contents['new_account'])) {
             $contents['new_account'] += array('#type' => 'details', '#title' => $this->t('New account details'), '#description' => $this->t('<b>Optional.</b> New customers may supply custom account details.<br />We will create these for you if no values are entered.'), '#open' => TRUE);
         }
     }
     return $contents;
 }
 /**
  * Renders a list with all custom links.
  *
  * @return array
  *   The list to be rendered.
  */
 public function render()
 {
     $build['xmlsitemap_add_custom'] = array('#type' => 'link', '#title' => t('Add custom link'), '#href' => 'admin/config/search/xmlsitemap/custom/add');
     $header = array('loc' => array('data' => t('Location'), 'field' => 'loc', 'sort' => 'asc'), 'priority' => array('data' => t('Priority'), 'field' => 'priority'), 'changefreq' => array('data' => t('Change frequency'), 'field' => 'changefreq'), 'language' => array('data' => t('Language'), 'field' => 'language'), 'operations' => array('data' => t('Operations')));
     $rows = array();
     $destination = drupal_get_destination();
     $query = db_select('xmlsitemap');
     $query->fields('xmlsitemap');
     $query->condition('type', 'custom');
     $query->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')->limit(50);
     $query->extend('Drupal\\Core\\Database\\Query\\TableSortExtender')->orderByHeader($header);
     $result = $query->execute();
     foreach ($result as $link) {
         $language = $this->languageManager->getLanguage($link->language);
         $row = array();
         $row['loc'] = $this->l($link->loc, Url::fromUri($link->loc));
         $row['priority'] = number_format($link->priority, 1);
         $row['changefreq'] = $link->changefreq ? drupal_ucfirst(xmlsitemap_get_changefreq($link->changefreq)) : t('None');
         if (isset($header['language'])) {
             $row['language'] = t($language->name);
         }
         $operations['edit'] = array('title' => t('Edit'), 'route_name' => 'xmlsitemap_custom.edit', 'route_parameters' => array('link' => $link->id));
         $operations['delete'] = array('title' => t('Delete'), 'route_name' => 'xmlsitemap_custom.delete', 'route_parameters' => array('link' => $link->id));
         $row['operations'] = array('data' => array('#type' => 'operations', '#theme' => 'links', '#links' => $operations, '#attributes' => array('class' => array('links', 'inline'))));
         $rows[] = $row;
     }
     // @todo Convert to tableselect
     $build['xmlsitemap_custom_table'] = array('#type' => 'tableselect', '#theme' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => $this->t('No custom links available. <a href="@custom_link">Add custom link</a>', array('@custom_link' => Url::fromRoute('xmlsitemap_custom.add', [], array('query' => $destination)))));
     $build['xmlsitemap_custom_pager'] = array('#theme' => 'pager');
     return $build;
 }
Example #9
0
function horizontal_login_block($form)
{
    $form['#action'] = url($_GET['q'], array('query' => drupal_get_destination()));
    $form['#id'] = 'horizontal-login-block';
    $form['#validate'] = user_login_default_validators();
    $form['#submit'][] = 'user_login_submit';
    $form['#prefix'] = '
	';
    $form['#suffix'] = '
	';
    $form['name'] = array('#type' => 'textfield', '#prefix' => '<div class="usericon">', '#suffix' => '</div>', '#maxlength' => USERNAME_MAX_LENGTH, '#size' => 15, '#required' => TRUE, '#default_value' => 'Username', '#attributes' => array('onblur' => "if (this.value == '') {this.value = 'Username';}", 'onfocus' => "if (this.value == 'Username') {this.value = '';}"));
    $form['pass'] = array('#type' => 'password', '#maxlength' => 60, '#size' => 15, '#required' => TRUE, '#prefix' => '<div class="passicon">', '#suffix' => '</div>');
    $form['actions'] = array('#type' => 'actions');
    $form['actions']['submit'] = array('#type' => 'submit', '#value' => '');
    /* 
    * We comment this because I don´t know how to render the links in a new line, so 
    * I do it from the login_bar function 
    * 
    * 
    	$attributes = array('class' => 'cboxElement');
    	$form['links'][] = array(
     	  '#type' => 'markup',
       	//'#markup' => l(t('Register'), 'user/register'));
       	'#markup' => l("<br/>".t('Register | '), 'colorbox/form/user_register_form',
    		array('attributes' => $attributes,
    		'query' => array('width' => '300', 'height' => 'auto'))));
    	$form['links'][] = array(
     	  	'#type' => 'markup',
    		'#markup' => l(t('Forgot Password'), 'colorbox/form/user_pass',
    			array('attributes' => $attributes,
    			'query' => array('width' => '300', 'height' => '150'))));
    */
    return $form;
}
Example #10
0
 /**
  * Submits the delete form.
  */
 public function deleteSubmit(array &$form, array &$form_state)
 {
     $form_state['redirect_route'] = new Url('path.delete', array('pid' => $form_state['values']['pid']));
     if ($this->getRequest()->query->has('destination')) {
         $form_state['redirect_route']->setOption('query', drupal_get_destination());
         $this->getRequest()->query->remove('destination');
     }
 }
function _scratchy_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_per_page)
{
    global $user;
    // forum list, topics list, topic browser and 'add new topic' link
    $vocabulary = taxonomy_get_vocabulary(variable_get('forum_nav_vocabulary', ''));
    $title = $vocabulary->name;
    // Breadcrumb navigation:
    $breadcrumb = array();
    if ($tid) {
        $breadcrumb[] = array('path' => 'forum', 'title' => $title);
    }
    if ($parents) {
        $parents = array_reverse($parents);
        foreach ($parents as $p) {
            if ($p->tid == $tid) {
                $title = $p->name;
            } else {
                $breadcrumb[] = array('path' => 'forum/' . $p->tid, 'title' => $p->name);
            }
        }
    }
    drupal_set_title(check_plain($title));
    $breadcrumb[] = array('path' => $_GET['q']);
    menu_set_location($breadcrumb);
    if (count($forums) || count($parents)) {
        $output = '<div class="node">
  <div class="boxtop"><div class="bc ctr"></div><div class="bc ctl"></div></div>
  <div class="boxcontent">
    <div class="subboxcontent"><div class="content"><div id="forum"><ul style="margin-top:0">';
        if (user_access('create forum topics')) {
            $output .= '<li>' . l(t('Post new forum topic.'), "node/add/forum/{$tid}") . '</li>';
        } else {
            if ($user->uid) {
                $output .= '<li>' . t('You are not allowed to post a new forum topic.') . '</li>';
            } else {
                $output .= '<li>' . t('<a href="@login">Login</a> to post a new forum topic.', array('@login' => url('user/login', drupal_get_destination()))) . '</li>';
            }
        }
        $output .= '</ul>';
        $output .= theme('forum_list', $forums, $parents, $tid);
        if ($tid && !in_array($tid, variable_get('forum_containers', array()))) {
            $output .= theme('forum_topic_list', $tid, $topics, $sortby, $forum_per_page);
            drupal_add_feed(url('taxonomy/term/' . $tid . '/0/feed'), 'RSS - ' . $title);
        }
        $output .= '</div></div></div>
  </div>
  <div class="boxbtm">
    <div class="bc cbr"></div>
    <div class="bc cbl"></div>
  </div>
</div>';
    } else {
        drupal_set_title(t('No forums defined'));
        $output = '';
    }
    return $output;
}
Example #12
0
 /**
  * Private method to store the required publication info to get it back later
  * when returning from Facebook authorization
  *
  * @param $publication
  *   The publication array
  * @param $destination
  *   The URI the user will be redirected after the publication
  */
 public function storePublication($publication, $destination = NULL)
 {
     $_SESSION['fb_autopost_authorization_required'] = array('publication' => $publication, 'target' => 'me');
     if ($destination) {
         $_SESSION['fb_autopost_authorization_required']['destination'] = $destination;
     } else {
         $_SESSION['fb_autopost_authorization_required'] += drupal_get_destination();
     }
 }
Example #13
0
 /**
  * Prepares the link for deleting the comment.
  *
  * @param \Drupal\Core\Entity\EntityInterface $data
  *   The comment entity.
  * @param \Drupal\views\ResultRow $values
  *   The values retrieved from a single row of a view's query result.
  *
  * @return string
  *   Returns a string for the link text.
  */
 protected function renderLink($data, ResultRow $values)
 {
     $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Delete');
     $comment = $this->getEntity($values);
     $this->options['alter']['make_link'] = TRUE;
     $this->options['alter']['url'] = $comment->urlInfo('delete-form');
     $this->options['alter']['query'] = drupal_get_destination();
     return $text;
 }
Example #14
0
 /**
  * Submits the delete form.
  */
 public function deleteSubmit(array &$form, FormStateInterface $form_state)
 {
     $url = new Url('path.delete', array('pid' => $form_state['values']['pid']));
     if ($this->getRequest()->query->has('destination')) {
         $url->setOption('query', drupal_get_destination());
         $this->getRequest()->query->remove('destination');
     }
     $form_state->setRedirectUrl($url);
 }
Example #15
0
 /**
  * {@inheritdoc}
  */
 protected function renderLink(EntityInterface $entity, ResultRow $values)
 {
     if ($entity && $entity->access('update')) {
         $this->options['alter']['make_link'] = TRUE;
         $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Edit');
         $this->options['alter']['url'] = $entity->urlInfo('edit-form', ['query' => ['destination' => drupal_get_destination()]]);
         return $text;
     }
 }
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $destination = drupal_get_destination();
     $search = $this->getRequest()->get('search');
     $form['#attributes'] = array('class' => array('search-form'));
     // The following requires the dblog module. If it's not available, provide a message.
     if (!\Drupal::moduleHandler()->moduleExists('dblog')) {
         $form['message'] = ['#type' => 'markup', '#markup' => t('This page requires the Database Logging (dblog) module, which is currently not installed.')];
         return $form;
     }
     $form['basic'] = array('#type' => 'fieldset', '#title' => t('Filter 404s'), '#attributes' => array('class' => array('container-inline')));
     $form['basic']['filter'] = array('#type' => 'textfield', '#title' => '', '#default_value' => $search, '#maxlength' => 128, '#size' => 25);
     $form['basic']['submit'] = array('#type' => 'submit', '#value' => t('Filter'), '#action' => 'filter');
     if ($search) {
         $form['basic']['reset'] = array('#type' => 'submit', '#value' => t('Reset'), '#action' => 'reset');
     }
     $header = array(array('data' => t('Page'), 'field' => 'message'), array('data' => t('Count'), 'field' => 'count', 'sort' => 'desc'), array('data' => t('Last accessed'), 'field' => 'timestamp'), array('data' => t('Operations')));
     $count_query = db_select('watchdog', 'w');
     $count_query->addExpression('COUNT(DISTINCT(w.message))');
     $count_query->leftJoin('redirect', 'r', 'w.message = r.redirect_source__path');
     $count_query->condition('w.type', 'page not found');
     $count_query->isNull('r.rid');
     $this->filterQuery($count_query, array('w.message'), $search);
     $query = db_select('watchdog', 'w')->extend('Drupal\\Core\\Database\\Query\\TableSortExtender')->orderByHeader($header)->extend('Drupal\\Core\\Database\\Query\\PagerSelectExtender')->limit(25);
     $query->fields('w', array('message', 'variables'));
     $query->addExpression('COUNT(wid)', 'count');
     $query->addExpression('MAX(timestamp)', 'timestamp');
     $query->leftJoin('redirect', 'r', 'w.message = r.redirect_source__path');
     $query->isNull('r.rid');
     $query->condition('w.type', 'page not found');
     $query->groupBy('w.message');
     $query->groupBy('w.variables');
     $this->filterQuery($query, array('w.message'), $search);
     $query->setCountQuery($count_query);
     $results = $query->execute();
     $rows = array();
     foreach ($results as $result) {
         // @todo Detect the language from the url.
         $url = SafeMarkup::format($result->message, unserialize($result->variables));
         $request = Request::create($url, 'GET', [], [], [], \Drupal::request()->server->all());
         $path = ltrim($request->getPathInfo(), '/');
         $row = array();
         $row['source'] = \Drupal::l($url, Url::fromUri('base:' . $path, array('query' => $destination)));
         $row['count'] = $result->count;
         $row['timestamp'] = format_date($result->timestamp, 'short');
         $operations = array();
         if (\Drupal::entityManager()->getAccessControlHandler('redirect')->createAccess()) {
             $operations['add'] = array('title' => t('Add redirect'), 'url' => Url::fromRoute('redirect.add', [], ['query' => array('source' => $path) + $destination]));
         }
         $row['operations'] = array('data' => array('#theme' => 'links', '#links' => $operations, '#attributes' => array('class' => array('links', 'inline', 'nowrap'))));
         $rows[] = $row;
     }
     $form['redirect_404_table'] = array('#theme' => 'table', '#header' => $header, '#rows' => $rows, '#empty' => t('No 404 pages without redirects found.'));
     $form['redirect_404_pager'] = array('#type' => 'pager');
     return $form;
 }
Example #17
0
 /**
  * {@inheritdoc}
  */
 protected function renderLink(EntityInterface $entity, ResultRow $values)
 {
     if ($entity && $entity->access('update')) {
         $this->options['alter']['make_link'] = TRUE;
         $text = !empty($this->options['text']) ? $this->options['text'] : t('Edit');
         $this->options['alter']['path'] = $entity->getSystemPath('edit-form');
         $this->options['alter']['query'] = drupal_get_destination();
         return $text;
     }
 }
Example #18
0
 /**
  * {@inheritdoc}
  */
 protected function renderLink(EntityInterface $entity, ResultRow $values)
 {
     if ($entity && $entity->access('delete')) {
         $this->options['alter']['make_link'] = TRUE;
         $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Cancel account');
         $this->options['alter']['url'] = $entity->urlInfo('cancel-form');
         $this->options['alter']['query'] = drupal_get_destination();
         return $text;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function delete(array $form, FormStateInterface $form_state)
 {
     $destination = array();
     $request = $this->getRequest();
     if ($request->query->has('destination')) {
         $destination = drupal_get_destination();
         $request->query->remove('destination');
     }
     $form_state->setRedirect('xmlsitemap.admin_delete', array('xmlsitemap' => $this->entity->id()));
 }
/**
 * Allow modules to restrict credit for a course.
 *
 * @param object $node
 *   The course node.
 * @param object $user
 *   The user who may take the course.
 *
 * @return array
 *   A course restriction array, containing:
 *    - takecourse: boolean, whether or not the user may take the course.
 *    - message: translated string to display to the user.
 */
function hook_course_restrict($node, $user)
{
    // Example: only allow authenticated users to receive credit.
    if (!$user->uid) {
        $messages = array(t('Only logged in users may claim credit.'));
        $destination = drupal_get_destination();
        $args = array('@login' => url('user/login', $destination), '@register' => url('user/register', $destination));
        $messages[] = variable_get('user_register', 1) ? t('<a href="@login">Login</a> or <a href="@register">register</a> to receive credit', $args) : t('<a href="@login">Login</a> to receive credit', $args);
        return array('takecourse' => FALSE, 'message' => implode(' ', $messages));
    }
}
Example #21
0
/**
 * Intercept page template variables
 *
 * @param $vars
 *   A sequential array of variables passed to the theme function.
 */
function vozmob_white_label_preprocess_page(&$vars)
{
    global $user;
    $headers = drupal_set_header();
    if (strpos($headers, 'HTTP/1.1 403 Forbidden') && !$user->uid) {
        $vars['content'] .= "\n" . l(t('Please login to continue'), 'user/login', array('query' => drupal_get_destination()));
    }
    // Add drupal menu for footer links
    $footer_links_source = menu_navigation_links(variable_get('menu_footer_links_source', 'menu-footer-links'));
    $vars['footer_links'] = theme('links', $footer_links_source, array('class' => 'footer-links'));
}
Example #22
0
 /**
  * Renders the link.
  */
 protected function renderLink($feed, ResultRow $values)
 {
     // Ensure user has access to edit this feed.
     if (!$feed->access('import')) {
         return;
     }
     $this->options['alter']['make_link'] = TRUE;
     $this->options['alter']['path'] = 'feed/' . $feed->id() . '/import';
     $this->options['alter']['query'] = drupal_get_destination();
     $text = !empty($this->options['text']) ? $this->options['text'] : t('import');
     return $text;
 }
Example #23
0
function netsound2_preprocess_page(&$vars, $hook)
{
    global $user;
    if (arg(0) == 'min_side' && $user->uid == 0) {
        drupal_goto('user/login', drupal_get_destination());
    }
    if (arg(3) == 'stream' || arg(3) == 'download' || $_GET['clean'] == 1) {
        $vars['template_files'] = array('page-clean');
        $vars['css']['all']['theme']['sites/all/themes/netsound2/css/style.css'] = false;
    }
    //krumo($vars);
}
 /**
  * Prepares the link to delete a node.
  *
  * @param \Drupal\Core\Entity\EntityInterface $node
  *   The node entity this field belongs to.
  * @param \Drupal\views\ResultRow $values
  *   The values retrieved from the view's result set.
  *
  * @return string
  *   Returns a string for the link text.
  */
 protected function renderLink($node, ResultRow $values)
 {
     // Ensure user has access to delete this node.
     if (!$node->access('delete')) {
         return;
     }
     $this->options['alter']['make_link'] = TRUE;
     $this->options['alter']['path'] = $node->getSystemPath('delete-form');
     $this->options['alter']['query'] = drupal_get_destination();
     $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Delete');
     return $text;
 }
 /**
  * Prepares the link to the node.
  *
  * @param \Drupal\Core\Entity\EntityInterface $node
  *   The node entity this field belongs to.
  * @param ResultRow $values
  *   The values retrieved from the view's result set.
  *
  * @return string
  *   Returns a string for the link text.
  */
 protected function renderLink($node, ResultRow $values)
 {
     // Ensure user has access to edit this node.
     if (!$node->access('update')) {
         return;
     }
     $this->options['alter']['make_link'] = TRUE;
     $this->options['alter']['path'] = "node/" . $node->id() . "/edit";
     $this->options['alter']['query'] = drupal_get_destination();
     $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Edit');
     return $text;
 }
Example #26
0
function infopeople_form_user_login_block_alter(&$form, &$form_state)
{
    $pre = '<div id="toboggan-container" class="toboggan-container">';
    $options = array('attributes' => array('id' => 'toboggan-login-link', 'class' => array('toboggan-login-link', 'btn', 'btn-info')), 'query' => drupal_get_destination(), 'html' => TRUE);
    $pre .= '<div id="toboggan-login-link-container" class="toboggan-login-link-container">';
    $pre .= l('<i class="icon-user visible-phone"></i><span class="hidden-phone"> ' . theme('lt_login_link') . "</span>", 'user/login', $options);
    $pre .= '</div>';
    //the block that will be toggled
    $pre .= '<div id="toboggan-login" class="user-login-block">';
    $form['pre'] = array('#markup' => $pre, '#weight' => -300);
    return $form;
}
 /**
  * {@inheritdoc}
  */
 public function render(ResultRow $values)
 {
     // Check there is an actual value, as on a relationship there may not be.
     if ($tid = $this->getValue($values, 'tid')) {
         // Mock a term object for taxonomy_term_access(). Use machine name and
         // vid to ensure compatibility with vid based and machine name based
         // access checks. See http://drupal.org/node/995156
         $term = entity_create('taxonomy_term', array('vid' => $values->{$this->aliases['vid']}));
         if ($term->access('update')) {
             $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Edit');
             return \Drupal::l($text, new Url('entity.taxonomy.edit_form', ['taxonomy_term' => $tid], array('query' => drupal_get_destination())));
         }
     }
 }
Example #28
0
 /**
  * Prepares the link pointing for approving the comment.
  *
  * @param \Drupal\Core\Entity\EntityInterface $data
  *   The comment entity.
  * @param \Drupal\views\ResultRow $values
  *   The values retrieved from a single row of a view's query result.
  *
  * @return string
  *   Returns a string for the link text.
  */
 protected function renderLink($data, ResultRow $values)
 {
     $status = $this->getValue($values, 'status');
     // Don't show an approve link on published comment.
     if ($status == CommentInterface::PUBLISHED) {
         return;
     }
     $text = !empty($this->options['text']) ? $this->options['text'] : $this->t('Approve');
     $comment = $this->get_entity($values);
     $this->options['alter']['make_link'] = TRUE;
     $this->options['alter']['url'] = Url::fromRoute('comment.approve', ['comment' => $comment->id()]);
     $this->options['alter']['query'] = drupal_get_destination() + array('token' => \Drupal::csrfToken()->get($this->options['alter']['url']->toString()));
     return $text;
 }
 /**
  * Prepares the link to delete a node revision.
  *
  * @param \Drupal\Core\Entity\EntityInterface $data
  *   The node revision entity this field belongs to.
  * @param \Drupal\views\ResultRow $values
  *   The values retrieved from the view's result set.
  *
  * @return string
  *   Returns a string for the link text.
  */
 protected function renderLink($data, ResultRow $values)
 {
     list($node, $vid) = $this->get_revision_entity($values, 'delete');
     if (!isset($vid)) {
         return;
     }
     // Current revision cannot be deleted.
     if ($node->isDefaultRevision()) {
         return;
     }
     $this->options['alter']['make_link'] = TRUE;
     $this->options['alter']['url'] = Url::fromRoute('node.revision_delete_confirm', ['node' => $node->id(), 'node_revision' => $vid]);
     $this->options['alter']['query'] = drupal_get_destination();
     return !empty($this->options['text']) ? $this->options['text'] : $this->t('Delete');
 }
 /**
  * Prepares the link to delete a node revision.
  *
  * @param \Drupal\Core\Entity\EntityInterface $data
  *   The node revision entity this field belongs to.
  * @param \Drupal\views\ResultRow $values
  *   The values retrieved from the view's result set.
  *
  * @return string
  *   Returns a string for the link text.
  */
 protected function renderLink($data, ResultRow $values)
 {
     list($node, $vid) = $this->get_revision_entity($values, 'delete');
     if (!isset($vid)) {
         return;
     }
     // Current revision cannot be deleted.
     if ($node->isDefaultRevision()) {
         return;
     }
     $this->options['alter']['make_link'] = TRUE;
     $this->options['alter']['path'] = 'node/' . $node->id() . "/revisions/{$vid}/delete";
     $this->options['alter']['query'] = drupal_get_destination();
     return !empty($this->options['text']) ? $this->options['text'] : t('Delete');
 }