menu_unserialize

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

includes/menu.inc, строка 255

Версии
6
menu_unserialize($data, $map)

The menu system uses serialized arrays stored in the database for arguments. However, often these need to change according to the current path. This function unserializes such an array and does the necessary change.

Integer values are mapped according to the $map parameter. For example, if unserialize($data) is array('view', 1) and $map is array('node', '12345') then 'view' will not be changed because it is not an integer, but 1 will as it is an integer. As $map[1] is '12345', 1 will be replaced with '12345'. So the result will be array('node_load', '12345').

Параметры

@data A serialized array.

@map An array of potential replacements.

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

The $data array unserialized and mapped.

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

▾ 3 функции вызывают menu_unserialize()

menu_get_item in includes/menu.inc
Получает элемент роутера.
_menu_check_access in includes/menu.inc
Проверяет право доступа к пункту меню, используя коллбэк доступа.
_menu_item_localize in includes/menu.inc
Localize the router item title using t() or another callback.

Код

<?php
function menu_unserialize($data, $map) {
  if ($data = unserialize($data)) {
    foreach ($data as $k => $v) {
      if (is_int($v)) {
        $data[$k] = isset($map[$v]) ? $map[$v] : '';
      }
    }
    return $data;
  }
  else {
    return array();
  }
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

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