function styleguide_sentence in Style Guide 7
Same name and namespace in other branches
- 6 styleguide.module \styleguide_sentence()
Generate a random sentence.
Parameters
string $link: The link to add to the sentence.
4 calls to styleguide_sentence()
- search_styleguide in modules/
search.inc - Implements hook_styleguide().
- styleguide_form in ./
styleguide.module - Sample form, showing all elements.
- styleguide_menu_item in ./
styleguide.module - Generate a random menu item
- styleguide_styleguide in ./
styleguide.styleguide.inc - Implements hook_styleguide().
File
- ./
styleguide.module, line 421
Code
function styleguide_sentence($link = FALSE) {
$graph = strip_tags(styleguide_paragraph());
$explode = explode('.', $graph);
$rand = array_rand($explode);
$sentence = trim($explode[$rand]);
if ($link) {
$explode = explode(' ', $sentence);
$link = array(
'#theme' => 'link',
'#text' => $explode[0],
'#path' => $link,
'#options' => array(
'attributes' => array(),
'html' => FALSE,
),
);
$explode[0] = render($link);
$sentence = implode(' ', $explode);
}
return $sentence . '.';
}