本文整理汇总了PHP中drupal_html_class函数的典型用法代码示例。如果您正苦于以下问题:PHP drupal_html_class函数的具体用法?PHP drupal_html_class怎么用?PHP drupal_html_class使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drupal_html_class函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: basetpl_preprocess_node
/**
* Implements theme_preprocess_node().
*/
function basetpl_preprocess_node(&$variables)
{
/* classes */
$classes = array();
$classes[] = drupal_html_class('node-' . $variables['node']->type);
$classes[] = drupal_html_class($variables['view_mode']);
if (isset($variables['title_suffix']['contextual_links'])) {
$classes[] = 'contextual-links-region';
}
$variables['title_attributes_array']['class'] = 'node-title';
$variables['classes_array'] = $classes;
/* theme hook suggestions */
$variables['theme_hook_suggestions'][] = 'node__' . $variables['view_mode'];
$variables['theme_hook_suggestions'][] = 'node__' . $variables['node']->type . '__' . $variables['view_mode'];
/* node footer */
$variables['footer'] = TRUE;
/* node links
if(!empty($variables['content']['links']['node']['#links']) || !empty($variables['content']['links']['comment']['#links'])) {
$variables['content']['links']['#prefix'] = '<div class="inline-menu">';
$variables['content']['links']['#suffix'] = '</div>';
$variables['content']['links']['#attributes']['class'] = array('menu','node-links');
if(isset($variables['content']['links']['node']['#links']['node-readmore'])) {
$variables['content']['links']['node']['#links']['node-readmore']['attributes']['class'] = array('read-more');
}
if(isset($variables['content']['links']['comment']['#links']['comment-add'])) {
$variables['content']['links']['comment']['#links']['comment-add']['attributes']['class'] = array('add-comment');
}
}
*/
}
示例2: glisseo_preprocess_node
/**
* Implements template_preprocess_node().
*/
function glisseo_preprocess_node(&$variables)
{
// New classes. More clear then defaults.
$variables['clean_classes_array'] = array();
$variables['clean_classes_array'][] = drupal_html_class($variables['type']);
$variables['clean_classes_array'][] = drupal_html_class($variables['view_mode']);
// We add 'teaser' class, if content is teaser and don't have 'teaser' vew mode.
if ($variables['teaser'] && !in_array('teaser', $variables['clean_classes_array'])) {
$variables['clean_classes_array'][] = drupal_html_class('teaser');
}
// If content is sticky, we add special class.
if ($variables['sticky']) {
$variables['clean_classes_array'][] = drupal_html_class('sticky');
}
// We add that class only when contextual links enabled.
if (module_exists('contextual')) {
$variables['clean_classes_array'][] = drupal_html_class('contextual-links-region');
}
// Generate clean classes variable.
$variables['clean_classes'] = implode(' ', $variables['clean_classes_array']);
// Work with Node object.
$node = $variables['node'];
// Save field values to variables.
foreach ($node as $label => $data) {
// Is label is field.
if (preg_match("/field_(.*)?/i", $label, $matches)) {
$variables[$label] = field_get_items('node', $node, $label);
}
}
}
示例3: bootstrap_filter_tips
/**
* Returns HTML for a set of filter tips.
*
* @param array $variables
* An associative array containing:
* - tips: An array containing descriptions and a CSS ID in the form of
* 'module-name/filter-id' (only used when $long is TRUE) for each
* filter in one or more text formats. Example:
* @code
* array(
* 'Full HTML' => array(
* 0 => array(
* 'tip' => 'Web page addresses and e-mail addresses turn into links automatically.',
* 'id' => 'filter/2',
* ),
* ),
* );
* @endcode
* - long: (optional) Whether the passed-in filter tips contain extended
* explanations, i.e. intended to be output on the path 'filter/tips'
* (TRUE), or are in a short format, i.e. suitable to be displayed below a
* form element. Defaults to FALSE.
*
* @return string
* The constructed HTML.
*
* @see theme_filter_tips()
* @see _filter_tips()
*
* @ingroup theme_functions
*/
function bootstrap_filter_tips($variables)
{
$format_id = arg(2);
$current_path = current_path();
$tips = _filter_tips(-1, TRUE);
// Create a place holder for the tabs.
$build['tabs'] = array('#theme' => 'item_list', '#items' => array(), '#attributes' => array('class' => array('nav', 'nav-tabs'), 'role' => 'tablist'));
// Create a placeholder for the panes.
$build['panes'] = array('#theme_wrappers' => array('container'), '#attributes' => array('class' => array('tab-content')));
foreach ($tips as $name => $list) {
$machine_name = str_replace('-', '_', drupal_html_class($name));
$tab = array('data' => array('#type' => 'link', '#title' => check_plain($name), '#href' => $current_path, '#attributes' => array('role' => 'tab', 'data-toggle' => 'tab'), '#options' => array('fragment' => $machine_name)));
if (!$format_id || $format_id === $machine_name) {
$tab['class'][] = 'active';
$format_id = $machine_name;
}
$build['tabs']['#items'][] = $tab;
// Extract the actual tip.
$tiplist = array();
foreach ($list as $tip) {
$tiplist[] = $tip['tip'];
}
// Construct the pane.
$pane = array('#theme_wrappers' => array('container'), '#attributes' => array('class' => array('tab-pane', 'fade'), 'id' => $machine_name), 'list' => array('#theme' => 'item_list', '#items' => $tiplist));
if ($format_id === $machine_name) {
$pane['#attributes']['class'][] = 'active';
$pane['#attributes']['class'][] = 'in';
$format_id = $machine_name;
}
$build['panes'][] = $pane;
}
return drupal_render($build);
}
示例4: jollyness_preprocess_html
function jollyness_preprocess_html(&$vars)
{
//Process portfolio color
if ($portfolio_category = taxonomy_vocabulary_machine_name_load('portfolio_category')) {
$terms = taxonomy_get_tree($portfolio_category->vid);
$less = new lessc();
$css = '';
$color = '';
$class = '';
foreach ($terms as $t) {
$term = taxonomy_term_load($t->tid);
$class = drupal_html_class($t->name);
if (!empty($term->field_color)) {
foreach ($term->field_color as $v) {
$color = $v[0]['value'];
break;
}
}
if ($color) {
$css .= ".dexp-masonry-filter,.dexp-portfolio-filter{.{$class} span:before{background-color: {$color} !important;}}";
$css .= ".{$class} .portfolio-item-overlay{background-color: rgba(red({$color}), green({$color}), blue({$color}), 0.7) !important;}";
}
}
$css = $less->compile($css);
drupal_add_css($css, array('type' => 'inline'));
}
}
示例5: bootstork_preprocess_html
function bootstork_preprocess_html(&$variables)
{
//puts user roles into html tag
foreach ($variables['user']->roles as $role) {
$variables['classes_array'][] = 'role-' . drupal_html_class($role);
}
}
示例6: preBuild
/**
* {@inheritdoc}
*/
public function preBuild(array &$build, ObjectInterface $context = NULL)
{
$map_id = $context->getId();
$layers = $this->getOption('layers', array());
$items = array();
$map_layers = $context->getObjects('layer');
$element_type = $this->getOption('multiselect', FALSE) ? 'checkbox' : 'radio';
// Only handle layers available in the map and configured in the control.
// @TODO: use Form API (with form_process_* and stuff)
$labels = $this->getOption('layer_labels', array());
foreach ($map_layers as $i => $map_layer) {
if (isset($layers[$map_layer->getMachineName()])) {
$classes = array(drupal_html_class($map_layer->getMachineName()));
$checked = '';
if ($element_type == 'checkbox') {
if ($map_layer->getOption('visible', 1)) {
$checked = 'checked ';
$classes[] = 'active';
}
}
$label = $map_layer->getName();
if (isset($labels[$map_layer->getMachineName()])) {
$label = openlayers_i18n_string('openlayers:layerswitcher:' . $this->getMachineName() . ':' . $map_layer->getMachineName() . ':label', $labels[$map_layer->getMachineName()], array('sanitize' => TRUE));
}
$items[] = array('data' => '<label><input type="' . $element_type . '" name="layer" ' . $checked . 'value="' . $map_layer->getMachineName() . '">' . $label . '</label>', 'id' => drupal_html_id($map_id . '-' . $map_layer->getMachineName()), 'class' => $classes);
}
}
$title = openlayers_i18n_string('openlayers:layerswitcher:' . $this->getMachineName() . ':title', $this->getOption('label', 'Layers'), array('sanitize' => TRUE));
$layerswitcher = array('#theme' => 'item_list', '#type' => 'ul', '#title' => $title, '#items' => $items, '#attributes' => array('id' => drupal_html_id($this->getMachineName() . '-items')));
$this->setOption('element', '<div id="' . drupal_html_id($this->getMachineName()) . '" class="' . drupal_html_class($this->getMachineName()) . ' layerswitcher">' . drupal_render($layerswitcher) . '</div>');
// Allow the parent class to perform it's pre-build actions.
parent::preBuild($build, $context);
}
示例7: glisseo_preprocess_node
/**
* Implements template_preprocess_node().
*/
function glisseo_preprocess_node(&$variables)
{
$is_contextual = in_array('contextual-links-region', $variables['classes_array']);
// Clear default classes.
if (theme_get_setting('glisseo_replace_node_classes')) {
$variables['classes_array'] = array();
$variables['classes_array'][] = drupal_html_class($variables['type'] . '-' . $variables['view_mode']);
// If content is sticky, we add special class.
if ($variables['sticky']) {
$variables['classes_array'][] = drupal_html_class('sticky');
}
// We add that class only when contextual links enabled.
if ($is_contextual) {
$variables['classes_array'][] = drupal_html_class('contextual-links-region');
}
}
// Work with Node object.
$node = $variables['node'];
// Save field values to variables.
foreach ($node as $label => $data) {
// Is label is field.
if (preg_match("/field_(.*)?/i", $label, $matches)) {
$variables[$label] = field_get_items('node', $node, $label);
}
}
}
示例8: foundation_access_preprocess_html
/**
* Adds CSS classes based on user roles
* Implements template_preprocess_html().
*
*/
function foundation_access_preprocess_html(&$variables)
{
// loop through our system specific colors
$colors = array('primary', 'secondary', 'required', 'optional');
$css = '';
foreach ($colors as $current) {
$color = theme_get_setting('foundation_access_' . $current . '_color');
// allow other projects to override the FA colors
drupal_alter('foundation_access_colors', $color, $current);
// see if we have something that could be valid hex
if (strlen($color) == 6 || strlen($color) == 3) {
$complement = '#' . _foundation_access_complement($color);
$color = '#' . $color;
$css .= '.foundation_access-' . $current . "_color{color:{$color};}";
// specialized additions for each wheel value
switch ($current) {
case 'primary':
$css .= ".etb-book h1,.etb-book h2 {color: {$color};}";
break;
case 'secondary':
$css .= ".etb-book h3,.etb-book h4,.etb-book h5 {color: {$color};}";
break;
case 'required':
$css .= "div.textbook_box_required li:hover:before{border-color: {$color};} div.textbook_box_required li:before {color: {$complement}; background: {$color};} div.textbook_box_required { border: 2px solid {$color};} .textbook_box_required h3 {color: {$color};}";
break;
case 'optional':
$css .= "div.textbook_box_optional li:hover:before{border-color: {$color};} div.textbook_box_optional li:before {color: {$complement}; background: {$color};} div.textbook_box_optional { border: 2px solid {$color};} .textbook_box_optional h3 {color: {$color};}";
break;
}
}
}
drupal_add_css($css, array('type' => 'inline', 'group' => CSS_THEME, 'weight' => 1000));
drupal_add_css('//fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic,700italic|Open+Sans:300,600,700)', array('type' => 'external', 'group' => CSS_THEME));
// theme path shorthand should be handled here
$variables['theme_path'] = base_path() . drupal_get_path('theme', 'foundation_access');
foreach ($variables['user']->roles as $role) {
$variables['classes_array'][] = 'role-' . drupal_html_class($role);
}
// add page level variables into scope for the html tpl file
$variables['site_name'] = check_plain(variable_get('site_name', 'ELMSLN'));
$variables['logo'] = theme_get_setting('logo');
$variables['logo_img'] = '';
// make sure we have a logo before trying to render a real one to screen
if (!empty($variables['logo'])) {
$variables['logo_img'] = l(theme('image', array('path' => $variables['logo'], 'alt' => strip_tags($variables['site_name']) . ' ' . t('logo'), 'title' => strip_tags($variables['site_name']) . ' ' . t('Home'), 'attributes' => array('class' => array('logo__img')))), '<front>', array('html' => TRUE));
}
// add logo style classes to the logo element
$logo_classes = array();
$logo_option = theme_get_setting('foundation_access_logo_options');
if (isset($logo_option) && !is_null($logo_option)) {
$logo_classes[] = 'logo--' . $logo_option;
}
$variables['logo_classes'] = implode(' ', $logo_classes);
// support in-domain XSS exceptions
if (module_exists('cis_connector')) {
$variables['parent_origin'] = _cis_connector_parent_domain();
}
}
示例9: outreach_preprocess_html
/**
* Preprocess variables for the html template.
*/
function outreach_preprocess_html(&$vars)
{
global $theme_key;
$theme_name = $theme_key;
// Add a class for the active color scheme
if (module_exists('color')) {
$class = check_plain(get_color_scheme_name($theme_name));
$vars['classes_array'][] = 'color-scheme-' . drupal_html_class($class);
}
}
示例10: _base_get_section_class
/**
* Get the section class.
*
* @return string
*/
function _base_get_section_class()
{
$class = '';
// Add the Page's first argument as body class.
$path_arguments = explode('/', drupal_get_path_alias(implode('/', arg())));
if (isset($path_arguments[0])) {
$class = drupal_html_class($path_arguments[0]);
}
return $class;
}
示例11: boson_preprocess_html
function boson_preprocess_html(&$vars)
{
$bgklasa = theme_get_setting('theme_bg_pattern');
$vars['classes_array'][] = drupal_html_class($bgklasa);
drupal_add_css(path_to_theme() . '/css/main.css');
//Add PinIt JS
drupal_add_js('http://assets.pinterest.com/js/pinit.js');
// The Color Palette.
$file = theme_get_setting('theme_color_palette');
drupal_add_css(path_to_theme() . '/css/color-scheme/' . $file . '.css');
}
示例12: pixture_reloaded_preprocess_html
/**
* Override or insert variables into the html template.
*/
function pixture_reloaded_preprocess_html(&$vars)
{
global $theme_key;
$theme_name = 'pixture_reloaded';
$path_to_theme = drupal_get_path('theme', $theme_name);
// Load the media queries styles
$media_queries_css = array($theme_name . '.responsive.style.css', $theme_name . '.responsive.gpanels.css');
load_subtheme_media_queries($media_queries_css, $theme_name);
// Add a class for the active color scheme
if (module_exists('color')) {
$class = check_plain(get_color_scheme_name($theme_key));
$vars['classes_array'][] = 'color-scheme-' . drupal_html_class($class);
}
// Add class for the active theme
$vars['classes_array'][] = drupal_html_class($theme_key);
// Add theme settings classes
$settings_array = array('font_size', 'box_shadows', 'body_background', 'menu_bullets', 'menu_bar_position', 'corner_radius', 'image_alignment');
foreach ($settings_array as $setting) {
$vars['classes_array'][] = theme_get_setting($setting);
}
// Fonts
$fonts = array('bf' => 'base_font', 'snf' => 'site_name_font', 'ssf' => 'site_slogan_font', 'ptf' => 'page_title_font', 'ntf' => 'node_title_font', 'ctf' => 'comment_title_font', 'btf' => 'block_title_font');
$families = get_font_families($fonts, $theme_key);
if (!empty($families)) {
foreach ($families as $family) {
$vars['classes_array'][] = $family;
}
}
// Add Noggin module settings extra classes, not all designs can support header images
if (module_exists('noggin')) {
if (variable_get('noggin:use_header', FALSE)) {
$va = theme_get_setting('noggin_image_vertical_alignment');
$ha = theme_get_setting('noggin_image_horizontal_alignment');
$vars['classes_array'][] = 'ni-a-' . $va . $ha;
$vars['classes_array'][] = theme_get_setting('noggin_image_repeat');
$vars['classes_array'][] = theme_get_setting('noggin_image_width');
}
}
// Special case for PIE htc rounded corners, not all themes include this
if (theme_get_setting('ie_corners') == 1) {
drupal_add_css($path_to_theme . '/css/ie-htc.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE), 'preprocess' => FALSE));
}
// Headings styles
if (theme_get_setting('headings_styles_caps') == 1) {
$vars['classes_array'][] = 'hs-caps';
}
if (theme_get_setting('headings_styles_weight') == 1) {
$vars['classes_array'][] = 'hs-fwn';
}
if (theme_get_setting('headings_styles_shadow') == 1) {
$vars['classes_array'][] = 'hs-ts';
}
}
示例13: md_hosoren_commerce_price_formatted_components
/**
* Just use the theme function to translate order total
*/
function md_hosoren_commerce_price_formatted_components($variables)
{
// Override default commerce Order total title
$variables['components']['commerce_price_formatted_amount']['title'] = t('Order total');
// Add the CSS styling to the table.
drupal_add_css(drupal_get_path('module', 'commerce_price') . '/theme/commerce_price.theme.css');
// Build table rows out of the components.
$rows = array();
foreach ($variables['components'] as $name => $component) {
$rows[] = array('data' => array(array('data' => $component['title'], 'class' => array('component-title')), array('data' => $component['formatted_price'], 'class' => array('component-total'))), 'class' => array(drupal_html_class('component-type-' . $name)));
}
return theme('table', array('rows' => $rows, 'attributes' => array('class' => array('commerce-price-formatted-components'))));
}
示例14: koop2_menu_link__main_menu
function koop2_menu_link__main_menu($variables)
{
$element = $variables['element'];
$sub_menu = '';
// Add menu-item name as class
$element['#attributes']['class'][] = drupal_html_class($element['#title']);
if (in_array('active-trail', $element['#attributes']['class']) || in_array('active', $element['#attributes']['class'])) {
$element['#attributes']['class'][] = 'selected';
}
if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
$output = l($element['#title'], $element['#href'], $element['#localized_options']);
return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . '</li>';
}
示例15: bootstrap_preprocess_bootstrap_modal
/**
* Pre-processes variables for the "bootstrap_modal" theme hook.
*
* See template for list of available variables.
*
* @see bootstrap-modal.tpl.php
*
* @ingroup theme_preprocess
*
* @todo: Replace with "bootstrap_effect_fade" theme setting.
*/
function bootstrap_preprocess_bootstrap_modal(&$variables)
{
if (empty($variables['attributes']['id'])) {
$variables['attributes']['id'] = drupal_html_id(strip_tags($variables['heading']));
}
$variables['attributes']['class'][] = 'modal';
$variables['attributes']['class'][] = 'fade';
$variables['attributes']['tabindex'] = -1;
$variables['attributes']['role'] = 'dialog';
$variables['attributes']['aria-hidden'] = 'true';
$variables['heading'] = $variables['html_heading'] ? $variables['heading'] : check_plain($variables['heading']);
$variables['dialog_attributes']['class'][] = 'modal-dialog';
if (!empty($variables['size'])) {
$variables['dialog_attributes']['class'][] = drupal_html_class('modal-' . $variables['size']);
}
}