url

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

includes/common.inc, строка 1269

Версии
5
url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE)
6
url($path = NULL, $options = array())

Генерирует URL из указанного пути меню. Также поддерживает уже существующие URL.

Для создания ссылок в модулях лучше вместо url() использовать функцию l().

Параметры

$path Путь меню, на который будет указывать URL, например 'admin/content/node', или уже существующий URL, например 'http://drupal.org/'.

$query Строка запроса, присоединяемая к адресу.

$fragment Идентификатор фрагмента (или именованный якорь), присоединяемый к адресу. Если в качестве исходника используется готовый URL с идентификатором фрагмента, этот идентификатор будет заменен на заданный. Не добавляйте символ '#'.

$absolute Определяет, будет ли полученый URL абсолютным (т.е. начанаться с 'http:'). Это полезно для ссылок, которые будут показываться в материалах вне сайта, например, при генерации ленты RSS.

Возвращаемое значение

Строка, содержащая URL для заданного пути.

Связанные темы

▾ 99 функции вызывают url()

aggregator_help in modules/aggregator/aggregator.module
Реализация hook_help().
aggregator_page_category in modules/aggregator/aggregator.module
Menu callback; displays all the items aggregated in a particular category.
aggregator_page_last in modules/aggregator/aggregator.module
Menu callback; displays the most recent items gathered from any feed.
aggregator_page_rss in modules/aggregator/aggregator.module
Коллбэк меню. Генерирует фид из материалов аггергатора или категорий в формате RSS 0.92.
aggregator_page_sources in modules/aggregator/aggregator.module
Коллбэк меню; показывает все фиды, используемые аггрегатором.
block_admin_display in modules/block/block.module
Generate main block administration form.
block_box_form in modules/block/block.module
block_help in modules/block/block.module
Реализация hook_help().
blogapi_blogger_get_users_blogs in modules/blogapi/blogapi.module
blogapi_blogger_get_user_info in modules/blogapi/blogapi.module
Коллбэк Blogging API. Возвращает информацию о профиле пользователя.
blogapi_help in modules/blogapi/blogapi.module
Реализация hook_help().
blogapi_menu in modules/blogapi/blogapi.module
blogapi_rsd in modules/blogapi/blogapi.module
blog_feed_last in modules/blog/blog.module
Displays an RSS feed containing recent blog entries of all users.
blog_feed_user in modules/blog/blog.module
Displays an RSS feed containing recent blog entries of a given user.
blog_page_last in modules/blog/blog.module
Коллбэк меню. Показывает страницу Друпал с последними записями в блогах пользователей.
blog_page_user in modules/blog/blog.module
Показывает страницу Друпал с последними записями в блоге данного пользователя.
book_help in modules/book/book.module
Реализация hook_help().
color_form_alter in modules/color/color.module
Реализация hook_form_alter().
color_help in modules/color/color.module
Implementation of hook_help
comment_admin_settings in modules/comment/comment.module
Menu callback; presents the comment settings page.
comment_form in modules/comment/comment.module
comment_nodeapi in modules/comment/comment.module
Реализация hook_nodeapi().
contact_admin_settings in modules/contact/contact.module
contact_help in modules/contact/contact.module
Реализация hook_help().
contact_mail_page_submit in modules/contact/contact.module
Process the site-wide contact page form submission.
contact_mail_user_submit in modules/contact/contact.module
Process the personal contact page form submission.
contact_user in modules/contact/contact.module
Реализация hook_user().
contact_user_page in modules/contact/contact.module
Страница персональных контактов.
drupal_goto in includes/common.inc
Перенаправляет пользователя на другую страницу сайта на Друпале.
drupal_help in modules/drupal/drupal.module
Реализация hook_help().
drupal_sites_registry_settings in modules/drupal/drupal.module
file_create_url in includes/file.inc
Формирует путь для скачивания файла.
filter_help in modules/filter/filter.module
Реализация hook_help().
forum_overview in modules/forum/forum.module
Returns an overview list of existing forums and containers
help_help in modules/help/help.module
Реализация hook_help().
help_main in modules/help/help.module
Menu callback; prints a page listing a glossary of Drupal terminology.
hook_help in developer/hooks/core.php
Предоставляет контекстную справку для пользователей.
hook_ping in developer/hooks/core.php
Отправляет ping-запрос на другой сервер.
hook_requirements in developer/hooks/install.php
Check installation requirements that need to be satisfied.
hook_search in developer/hooks/core.php
Определяет пользовательскую функцию поиска.
install_complete in ./install.php
Page displayed when the installation is complete. Called from install.php.
l in includes/common.inc
Оформляет ссылки.
locale_help in modules/locale/locale.module
Реализация hook_help().
menu_configure in modules/menu/menu.module
Menu callback; presents menu configuration options.
menu_form_alter in modules/menu/menu.module
Implementation of hook_form_alter(). Add menu item fields to the node form.
menu_get_active_help in includes/menu.inc
Возвращает справку связанную с активизированным пунктом меню.
menu_help in modules/menu/menu.module
Реализация hook_help().
node_admin_search in modules/node/node.module
node_block in modules/node/node.module
Реализация hook_block().
node_feed in modules/node/node.module
A generic function for generating RSS feeds from a set of nodes.
node_page_default in modules/node/node.module
Menu callback; Generate a listing of promoted nodes.
node_search in modules/node/node.module
Implementation of hook_search().
path_form in modules/path/path.module
Return a form for editing or creating an individual URL alias.
phptemplate_node in themes/engines/phptemplate/phptemplate.engine
Prepare the values passed to the theme_node function to be passed into a pluggable template engine.
poll_cancel_form in modules/poll/poll.module
poll_help in modules/poll/poll.module
Реализация hook_help().
poll_view_voting in modules/poll/poll.module
Generates the voting form for a poll.
profile_block in modules/profile/profile.module
Реализация hook_block().
profile_field_delete in modules/profile/profile.module
Menu callback; deletes a field from all user profiles.
search_form in modules/search/search.module
Render a search form.
statistics_access_log in modules/statistics/statistics.module
statistics_help in modules/statistics/statistics.module
Реализация hook_help().
system_error_reporting_settings in modules/system/system.module
system_help in modules/system/system.module
Реализация hook_help().
system_main_admin_page in modules/system/system.module
Provide the administration overview page.
system_modules in modules/system/system.module
Menu callback; provides module enable/disable interface.
system_modules_uninstall in modules/system/system.module
Builds a form of currently disabled modules.
system_requirements in modules/system/system.install
Test and report Drupal installation requirements.
system_site_information_settings in modules/system/system.module
system_site_maintenance_settings in modules/system/system.module
system_themes_submit in modules/system/system.module
system_update_177 in modules/system/system.install
taxonomy_form_term in modules/taxonomy/taxonomy.module
taxonomy_form_vocabulary in modules/taxonomy/taxonomy.module
Выводит форму для добавления и редактирования словарей.
taxonomy_rss_item in modules/taxonomy/taxonomy.module
Provides category information for RSS feeds.
taxonomy_term_page in modules/taxonomy/taxonomy.module
Menu callback; displays all nodes associated with a term.
theme_book_navigation in modules/book/book.module
Prepares the links to children (TOC) and forward/backward navigation for a node presented as a book page.
theme_comment_post_forbidden in modules/comment/comment.module
Темизирует уведомление "вы не можете оставить комментарий".
theme_forum_display in modules/forum/forum.module
Format the forum body.
theme_image in includes/theme.inc
Возвращает темизированную картинку.
theme_textfield in includes/form.inc
Форматирует однострочное текстовое поле ввода.
upload_form_alter in modules/upload/upload.module
upload_help in modules/upload/upload.module
Реализация hook_help().
upload_nodeapi in modules/upload/upload.module
Implementation of hook_nodeapi().
user_admin in modules/user/user.module
user_help in modules/user/user.module
Реализация hook_help().
user_login_block in modules/user/user.module
user_login_validate in modules/user/user.module
user_pass_reset in modules/user/user.module
Menu callback; process one time login link and redirects to the user page on success.
user_pass_reset_url in modules/user/user.module
user_pass_submit in modules/user/user.module
user_register in modules/user/user.module
user_register_submit in modules/user/user.module
user_search in modules/user/user.module
Реализация hook_search().
_blogapi_get_post in modules/blogapi/blogapi.module
_locale_add_language in includes/locale.inc
Helper function to add a language
_upload_form in modules/upload/upload.module
_user_edit_validate in modules/user/user.module

Код

<?php
function url($path = NULL, $query = NULL, $fragment = NULL, $absolute = FALSE) {
  if (isset($fragment)) {
    $fragment = '#'. $fragment;
  }

  // Return an external link if $path contains an allowed absolute URL.
  // Only call the slow filter_xss_bad_protocol if $path contains a ':' before any / ? or #.
  $colonpos = strpos($path, ':');
  if ($colonpos !== FALSE && !preg_match('![/?#]!', substr($path, 0, $colonpos)) && filter_xss_bad_protocol($path, FALSE) == check_plain($path)) {
    // Split off the fragment
    if (strpos($path, '#') !== FALSE) {
      list($path, $old_fragment) = explode('#', $path, 2);
      if (isset($old_fragment) && !isset($fragment)) {
        $fragment = '#'. $old_fragment;
      }
    }
    // Append the query
    if (isset($query)) {
      $path .= (strpos($path, '?') !== FALSE ? '&' : '?') . $query;
    }
    // Reassemble
    return $path . $fragment;
  }

  global $base_url;
  static $script;
  static $clean_url;

  if (!isset($script)) {
    // On some web servers, such as IIS, we can't omit "index.php". So, we
    // generate "index.php?q=foo" instead of "?q=foo" on anything that is not
    // Apache.
    $script = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') === FALSE) ? 'index.php' : '';
  }

  // Cache the clean_url variable to improve performance.
  if (!isset($clean_url)) {
    $clean_url = (bool)variable_get('clean_url', '0');
  }

  $base = ($absolute ? $base_url . '/' : base_path());

  // The special path '<front>' links to the default front page.
  if (!empty($path) && $path != '<front>') {
    $path = drupal_get_path_alias($path);
    $path = drupal_urlencode($path);
    if (!$clean_url) {
      if (isset($query)) {
        return $base . $script .'?q='. $path .'&'. $query . $fragment;
      }
      else {
        return $base . $script .'?q='. $path . $fragment;
      }
    }
    else {
      if (isset($query)) {
        return $base . $path .'?'. $query . $fragment;
      }
      else {
        return $base . $path . $fragment;
      }
    }
  }
  else {
    if (isset($query)) {
      return $base . $script .'?'. $query . $fragment;
    }
    else {
      return $base . $fragment;
    }
  }
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему