function _lexicon_create_valid_id in Lexicon 6
Same name and namespace in other branches
- 7 lexicon.module \_lexicon_create_valid_id()
4 calls to _lexicon_create_valid_id()
- lexicon_overview in ./
lexicon.module - theme_lexicon_block_term in ./
lexicon.module - theme_lexicon_overview_item in ./
lexicon.module - _lexicon_filter_process in ./
lexicon.module - Mark lexicon vocabulary terms in the body text.
File
- ./
lexicon.module, line 1301 - Lexicon is used to create lists of terms and definitions to use on a website and optionally mark them in the content with an indicator.
Code
function _lexicon_create_valid_id($name) {
$allowed_chars = '-A-Za-z0-9._:';
$id = preg_replace(array(
'/ |\\s/',
'/\'/',
'/—/',
'/&/',
'/&[a-z]+;/',
'/[^' . $allowed_chars . ']/',
'/^[-0-9._:]+/',
'/__+/',
), array(
'_',
// and spaces
'-',
// apostrophe, so it makes things slightly more readable
'--',
// —
'and',
// &
'',
// any other entity
'',
// any character that is invalid as an ID name
'',
// any digits at the start of the name
'_',
), strip_tags($name));
return $id;
}