#196410 report by daniel.soneira, patch by myself, tested by Freso: several fixes to url() generation and path aliasing, fixing path aliases for node paths and front page links in themes
							parent
							
								
									c99dd5c206
								
							
						
					
					
						commit
						5bb6927e18
					
				| 
						 | 
				
			
			@ -1220,6 +1220,15 @@ function format_date($timestamp, $type = 'medium', $format = '', $timezone = NUL
 | 
			
		|||
 *       Whether the given path is an alias already.
 | 
			
		||||
 *     'external'
 | 
			
		||||
 *       Whether the given path is an external URL.
 | 
			
		||||
 *     'language'
 | 
			
		||||
 *       An optional language object. Used to build the URL to link to and
 | 
			
		||||
 *       look up the proper alias for the link.
 | 
			
		||||
 *     'base_url'
 | 
			
		||||
 *       Only used internally, to modify the base URL when a language dependent
 | 
			
		||||
 *       URL requires so.
 | 
			
		||||
 *     'prefix'
 | 
			
		||||
 *       Only used internally, to modify the path when a language dependent URL
 | 
			
		||||
 *       requires so.
 | 
			
		||||
 * @return
 | 
			
		||||
 *   A string containing a URL to the given path.
 | 
			
		||||
 *
 | 
			
		||||
| 
						 | 
				
			
			@ -1233,6 +1242,7 @@ function url($path = NULL, $options = array()) {
 | 
			
		|||
    'query' => '',
 | 
			
		||||
    'absolute' => FALSE,
 | 
			
		||||
    'alias' => FALSE,
 | 
			
		||||
    'prefix' => ''
 | 
			
		||||
  );
 | 
			
		||||
  if (!isset($options['external'])) {
 | 
			
		||||
    // Return an external link if $path contains an allowed absolute URL.
 | 
			
		||||
| 
						 | 
				
			
			@ -1297,33 +1307,39 @@ function url($path = NULL, $options = array()) {
 | 
			
		|||
  // The special path '<front>' links to the default front page.
 | 
			
		||||
  if (!empty($path) && $path != '<front>') {
 | 
			
		||||
    if (!$options['alias']) {
 | 
			
		||||
      $path = drupal_get_path_alias($path, isset($options['langcode']) ? $options['langcode'] : '');
 | 
			
		||||
      $path = drupal_get_path_alias($path, isset($options['language']) ? $options['language']->language : '');
 | 
			
		||||
    }
 | 
			
		||||
    if (function_exists('custom_url_rewrite_outbound')) {
 | 
			
		||||
      // Modules may alter outbound links by reference.
 | 
			
		||||
      custom_url_rewrite_outbound($path, $options, $original_path);
 | 
			
		||||
    }
 | 
			
		||||
    $path = drupal_urlencode($path);
 | 
			
		||||
    if (!$clean_url) {
 | 
			
		||||
      if ($options['query']) {
 | 
			
		||||
        return $base . $script .'?q='. $path .'&'. $options['query'] . $options['fragment'];
 | 
			
		||||
      }
 | 
			
		||||
      else {
 | 
			
		||||
        return $base . $script .'?q='. $path . $options['fragment'];
 | 
			
		||||
      }
 | 
			
		||||
    $path = drupal_urlencode($options['prefix'] . $path);
 | 
			
		||||
  }
 | 
			
		||||
  else {
 | 
			
		||||
    // Will be empty if there is no language prefix.
 | 
			
		||||
    $path = trim($options['prefix'], '/');
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  if ($clean_url) {
 | 
			
		||||
    // With Clean URLs.
 | 
			
		||||
    if ($options['query']) {
 | 
			
		||||
      return $base . $path .'?'. $options['query'] . $options['fragment'];
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
      if ($options['query']) {
 | 
			
		||||
        return $base . $path .'?'. $options['query'] . $options['fragment'];
 | 
			
		||||
      }
 | 
			
		||||
      else {
 | 
			
		||||
        return $base . $path . $options['fragment'];
 | 
			
		||||
      }
 | 
			
		||||
      return $base . $path . $options['fragment'];
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  else {
 | 
			
		||||
    if ($options['query']) {
 | 
			
		||||
      return $base . $script .'?'. $options['query'] . $options['fragment'];
 | 
			
		||||
    // Without Clean URLs.
 | 
			
		||||
    $variables = array();
 | 
			
		||||
    if (!empty($path)) {
 | 
			
		||||
      $variables[] = 'q='. $path;
 | 
			
		||||
    }
 | 
			
		||||
    if (!empty($options['query'])) {
 | 
			
		||||
      $variables[] = $options['query'];
 | 
			
		||||
    }   
 | 
			
		||||
    if ($query = join('&', $variables)) {
 | 
			
		||||
      return $base . $script .'?'. $query . $options['fragment'];
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
      return $base . $options['fragment'];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -103,37 +103,36 @@ function language_url_rewrite(&$path, &$options) {
 | 
			
		|||
  if (!$options['external']) {
 | 
			
		||||
 | 
			
		||||
    // Language can be passed as an option, or we go for current language.
 | 
			
		||||
    $path_language = isset($options['language']) ? $options['language'] : $language;
 | 
			
		||||
    if (!isset($options['language'])) {
 | 
			
		||||
      $options['language'] = $language;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    switch (variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE)) {
 | 
			
		||||
 | 
			
		||||
      case LANGUAGE_NEGOTIATION_NONE:
 | 
			
		||||
        // No language dependent path allowed in this mode.
 | 
			
		||||
        unset($options['language']);
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LANGUAGE_NEGOTIATION_DOMAIN:
 | 
			
		||||
        if ($path_language->domain) {
 | 
			
		||||
        if ($options['language']->domain) {
 | 
			
		||||
          // Ask for an absolute URL with our modified base_url.
 | 
			
		||||
          $options['absolute'] = TRUE;
 | 
			
		||||
          $options['base_url'] = $path_language->domain;
 | 
			
		||||
          // Ensure that path alias generation will use this language.
 | 
			
		||||
          $options['langcode'] = $path_language->language;
 | 
			
		||||
          $options['base_url'] = $options['language']->domain;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LANGUAGE_NEGOTIATION_PATH_DEFAULT:
 | 
			
		||||
        $default = language_default();
 | 
			
		||||
        if ($path_language->language == $default->language) {
 | 
			
		||||
        if ($options['language']->language == $default->language) {
 | 
			
		||||
          break;
 | 
			
		||||
        }
 | 
			
		||||
        // Intentionally no break here.
 | 
			
		||||
 | 
			
		||||
      case LANGUAGE_NEGOTIATION_PATH:
 | 
			
		||||
        if (isset($path_language->prefix) && $path_language->prefix) {
 | 
			
		||||
          // Ensure that path alias generation will use this language.
 | 
			
		||||
          $options['langcode'] = $path_language->language;
 | 
			
		||||
          $path = (empty($path) || ($path == '<front>')) ? $path_language->prefix : $path_language->prefix .'/'. $path;
 | 
			
		||||
        if (!empty($options['language']->prefix)) {
 | 
			
		||||
          $options['prefix'] = $options['language']->prefix .'/';
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1701,6 +1701,7 @@ function template_preprocess_page(&$variables) {
 | 
			
		|||
  }
 | 
			
		||||
  $variables['head_title']        = implode(' | ', $head_title);
 | 
			
		||||
  $variables['base_path']         = base_path();
 | 
			
		||||
  $variables['front_page']        = url();
 | 
			
		||||
  $variables['breadcrumb']        = theme('breadcrumb', drupal_get_breadcrumb());
 | 
			
		||||
  $variables['feed_icons']        = drupal_get_feeds();
 | 
			
		||||
  $variables['footer_message']    = filter_xss_admin(variable_get('site_footer', FALSE));
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -380,16 +380,18 @@ function node_admin_nodes() {
 | 
			
		|||
    '#submit' => array('node_admin_nodes_submit'),
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  $languages = language_list(); 
 | 
			
		||||
  $destination = drupal_get_destination();
 | 
			
		||||
  $nodes = array();
 | 
			
		||||
  while ($node = db_fetch_object($result)) {
 | 
			
		||||
    $nodes[$node->nid] = '';
 | 
			
		||||
    $form['title'][$node->nid] = array('#value' => l($node->title, 'node/'. $node->nid) .' '. theme('mark', node_mark($node->nid, $node->changed)));
 | 
			
		||||
    $options = empty($node->language) ? array() : array('language' => $languages[$node->language]);
 | 
			
		||||
    $form['title'][$node->nid] = array('#value' => l($node->title, 'node/'. $node->nid, $options) .' '. theme('mark', node_mark($node->nid, $node->changed)));
 | 
			
		||||
    $form['name'][$node->nid] =  array('#value' => check_plain(node_get_types('name', $node)));
 | 
			
		||||
    $form['username'][$node->nid] = array('#value' => theme('username', $node));
 | 
			
		||||
    $form['status'][$node->nid] =  array('#value' =>  ($node->status ? t('published') : t('not published')));
 | 
			
		||||
    if ($multilanguage) {
 | 
			
		||||
      $form['language'][$node->nid] = array('#value' => empty($node->language) ? t('Language neutral') : module_invoke('locale', 'language_name', $node->language));
 | 
			
		||||
      $form['language'][$node->nid] = array('#value' => empty($node->language) ? t('Language neutral') : t($languages[$node->language]->name));
 | 
			
		||||
    }
 | 
			
		||||
    $form['operations'][$node->nid] = array('#value' => l(t('edit'), 'node/'. $node->nid .'/edit', array('query' => $destination)));
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,6 +32,8 @@
 | 
			
		|||
 *   path, whether the user is logged in, and so on.
 | 
			
		||||
 *
 | 
			
		||||
 * Site identity:
 | 
			
		||||
 * - $front_page: The URL of the front page. Use this instead of $base_path, 
 | 
			
		||||
 *   when linking to the front page. This includes the language domain or prefix.
 | 
			
		||||
 * - $logo: The path to the logo image, as defined in theme configuration.
 | 
			
		||||
 * - $site_name: The name of the site, empty when display has been disabled
 | 
			
		||||
 *   in theme settings.
 | 
			
		||||
| 
						 | 
				
			
			@ -89,7 +91,7 @@
 | 
			
		|||
      <div id="logo-title">
 | 
			
		||||
 | 
			
		||||
        <?php if (!empty($logo)): ?>
 | 
			
		||||
          <a href="<?php print $base_path; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
 | 
			
		||||
          <a href="<?php print $front_page; ?>" title="<?php print t('Home'); ?>" rel="home" id="logo">
 | 
			
		||||
            <img src="<?php print $logo; ?>" alt="<?php print t('Home'); ?>" />
 | 
			
		||||
          </a>
 | 
			
		||||
        <?php endif; ?>
 | 
			
		||||
| 
						 | 
				
			
			@ -97,7 +99,7 @@
 | 
			
		|||
        <div id="name-and-slogan">
 | 
			
		||||
          <?php if (!empty($site_name)): ?>
 | 
			
		||||
            <h1 id="site-name">
 | 
			
		||||
              <a href="<?php print $base_path ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
 | 
			
		||||
              <a href="<?php print $front_page ?>" title="<?php print t('Home'); ?>" rel="home"><span><?php print $site_name; ?></span></a>
 | 
			
		||||
            </h1>
 | 
			
		||||
          <?php endif; ?>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -164,11 +164,12 @@ function translation_link($type, $node = NULL, $teaser = FALSE) {
 | 
			
		|||
  if ($type == 'node' && ($node->tnid) && $translations = translation_node_get_translations($node->tnid)) {
 | 
			
		||||
    // Do not show link to the same node.
 | 
			
		||||
    unset($translations[$node->language]);
 | 
			
		||||
    $languages = locale_language_list('native');
 | 
			
		||||
    $languages = language_list();
 | 
			
		||||
    foreach ($translations as $language => $translation) {
 | 
			
		||||
      $links["node_translation_$language"] = array(
 | 
			
		||||
        'title' => $languages[$language],
 | 
			
		||||
        'title' => $languages[$language]->native,
 | 
			
		||||
        'href' => "node/$translation->nid",
 | 
			
		||||
        'language' => $languages[$language],
 | 
			
		||||
        'attributes' => array('title' => $translation->title, 'class' => 'translation-link')
 | 
			
		||||
      );
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,8 +16,8 @@
 | 
			
		|||
<table border="0" cellpadding="0" cellspacing="0" id="header">
 | 
			
		||||
  <tr>
 | 
			
		||||
    <td id="logo">
 | 
			
		||||
      <?php if ($logo) { ?><a href="<?php print $base_path ?>" title="<?php print t('Home') ?>"><img src="<?php print $logo ?>" alt="<?php print t('Home') ?>" /></a><?php } ?>
 | 
			
		||||
      <?php if ($site_name) { ?><h1 class='site-name'><a href="<?php print $base_path ?>" title="<?php print t('Home') ?>"><?php print $site_name ?></a></h1><?php } ?>
 | 
			
		||||
      <?php if ($logo) { ?><a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><img src="<?php print $logo ?>" alt="<?php print t('Home') ?>" /></a><?php } ?>
 | 
			
		||||
      <?php if ($site_name) { ?><h1 class='site-name'><a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><?php print $site_name ?></a></h1><?php } ?>
 | 
			
		||||
      <?php if ($site_slogan) { ?><div class='site-slogan'><?php print $site_slogan ?></div><?php } ?>
 | 
			
		||||
    </td>
 | 
			
		||||
    <td id="menu">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,7 +38,7 @@ function chameleon_page($content, $show_blocks = TRUE, $show_messages = TRUE) {
 | 
			
		|||
  $output .= " <div id=\"header\">";
 | 
			
		||||
 | 
			
		||||
  if ($logo = theme_get_setting('logo')) {
 | 
			
		||||
    $output .= "  <a href=\"". base_path() ."\" title=\"". t('Home') ."\"><img src=\"$logo\" alt=\"". t('Home') ."\" /></a>";
 | 
			
		||||
    $output .= "  <a href=\"". url() ."\" title=\"". t('Home') ."\"><img src=\"$logo\" alt=\"". t('Home') ."\" /></a>";
 | 
			
		||||
  }
 | 
			
		||||
  if (theme_get_setting('toggle_name')) {
 | 
			
		||||
    $output .= "  <h1 class=\"site-name title\">". l(variable_get('site_name', 'drupal'), "") ."</h1>";
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -38,7 +38,7 @@
 | 
			
		|||
          $site_html = implode(' ', $site_fields);
 | 
			
		||||
 | 
			
		||||
          if ($logo || $site_title) {
 | 
			
		||||
            print '<h1><a href="'. check_url($base_path) .'" title="'. $site_title .'">';
 | 
			
		||||
            print '<h1><a href="'. check_url($front_page) .'" title="'. $site_title .'">';
 | 
			
		||||
            if ($logo) {
 | 
			
		||||
              print '<img src="'. check_url($logo) .'" alt="'. $site_title .'" id="logo" />';
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,13 +18,13 @@
 | 
			
		|||
  <tr>
 | 
			
		||||
    <td id="home" width="10%">
 | 
			
		||||
      <?php if ($logo) : ?>
 | 
			
		||||
        <a href="<?php print $base_path ?>" title="<?php print t('Home') ?>"><img src="<?php print($logo) ?>" alt="<?php print t('Home') ?>" border="0" /></a>
 | 
			
		||||
        <a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><img src="<?php print($logo) ?>" alt="<?php print t('Home') ?>" border="0" /></a>
 | 
			
		||||
      <?php endif; ?>
 | 
			
		||||
    </td>
 | 
			
		||||
 | 
			
		||||
    <td id="site-info" width="20%">
 | 
			
		||||
      <?php if ($site_name) : ?>
 | 
			
		||||
        <div class='site-name'><a href="<?php print $base_path ?>" title="<?php print t('Home') ?>"><?php print($site_name) ?></a></div>
 | 
			
		||||
        <div class='site-name'><a href="<?php print $front_page ?>" title="<?php print t('Home') ?>"><?php print($site_name) ?></a></div>
 | 
			
		||||
      <?php endif;?>
 | 
			
		||||
      <?php if ($site_slogan) : ?>
 | 
			
		||||
        <div class='site-slogan'><?php print($site_slogan) ?></div>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue