Commit b6947042 authored by vadim's avatar vadim

#1087212 by dealancer: refactored code, solved issue with caching, added more...

#1087212 by dealancer: refactored code, solved issue with caching, added more comments, solved issue with spaces in menu path
parent 83fb2dfd
<?php
/*
* @file
*
* Helper functions of menu_token.
*
*/
/*
* Load menu token configuration for menu item from database.
*
* @param $mlid
* Menu item id.
*
* @return array
* Options array.
*
*/
function menu_token_get($mlid) {
global $menu_token_conf;
if (!$mlid) {
return NULL;
}
if (!isset($menu_token_conf[$mlid])) {
$item_conf = db_fetch_array(db_query('SELECT * FROM {menu_token} WHERE mlid = %d', $mlid));
$menu_token_conf[$mlid] = empty($item_conf) ? NULL : $item_conf;
}
return $menu_token_conf[$mlid];
}
/*
* Insert/update menu token configuration for menu item to database.
*
* @param $mlid
* Menu item id.
*
* @param $options
* Options array (mlid, link_path).
*
*/
function menu_token_set($mlid, $options) {
global $menu_token_conf;
db_query('DELETE FROM {menu_token} WHERE mlid = %d', $mlid);
$options['mlid'] = $mlid;
$record = (object) $options;
drupal_write_record('menu_token', $record);
unset ($menu_token_conf[$mlid]);
}
/*
* Delete menu token configuration for menu item from database.
*
* @param $mlid
* Menu item id.
*
*/
function menu_token_unset($mlid) {
global $menu_token_conf;
db_query('DELETE FROM {menu_token} WHERE mlid = %d', $mlid);
unset ($menu_token_conf[$mlid]);
}
/**
* Returns true if menu item is being generated by menu administration modules.
*
* @see menu_overview_form().
*/
function _menu_token_menu_admin($item) {
global $menu_admin;
return $menu_admin;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment