You are here

function template_preprocess_om_maximenu_modal_links in OM Maximenu 6

Same name and namespace in other branches
  1. 8 inc/om_maximenu.render.inc \template_preprocess_om_maximenu_modal_links()
  2. 7 inc/om_maximenu.render.inc \template_preprocess_om_maximenu_modal_links()

Process variables for om_maximenu_modal_links.tpl.php

File

inc/om_maximenu.render.inc, line 603
OM Maximenu Render

Code

function template_preprocess_om_maximenu_modal_links(&$vars) {
  $content = $vars['content'];

  // user roles and permissions
  $vars['permission'] = om_maximenu_link_visible($vars['content']['roles']);

  // php on title
  if (isset($content['php_option']) && $content['php_option'] == 1) {
    ob_start();
    $content['link_title'] = eval($content['link_title']);

    //$output = ob_get_contents();
    ob_end_clean();
  }

  // span id
  $span_id = !empty($content['id']) ? ' id="' . om_string_name($content['id']) . '"' : '';

  // span title
  $span_title = !empty($content['description']) && $content['description_option'] == 'hover' ? 'title="' . check_plain($content['description']) . '"' : '';

  // link content
  $link_option = om_maximenu_link_option($content);

  // a link attributes
  $attributes = om_maximenu_link_attrib($content);

  // link is disabled when it's on its page
  $uri = trim($_SERVER['REQUEST_URI']);
  $path_relative = base_path() . $content['path'];

  // Drupal doesn't accept # as valid path on field input
  $options = array();
  $options['query'] = isset($content['path_query']) ? $content['path_query'] : '';
  $options['fragment'] = isset($content['path_fragment']) ? $content['path_fragment'] : '';

  // title with javascript should have div tag
  $script_link = om_string_name($content['link_title'], FALSE);

  // title contains some block elements
  if (isset($content['php_option']) && $content['php_option'] == 1 || $script_link == 'Script Link') {

    // any link with scripts cannot be processed as modal
    $vars['om_link'] = '<div' . $span_id . ' class="' . $attributes['class'] . '" ' . $span_title . '>' . $link_option . '</div>';
  }
  else {

    // useful when you just want a button for getting the content to show and not actually linking to anything
    $vars['om_link'] = '<a' . $span_id . ' href="#om-modal-content-' . $vars['code'] . '-' . $vars['key'] . '" rel="om-maximenu-modal" class="' . $attributes['class'] . '" ' . $span_title . '>' . $link_option . '</a>';
  }
  $vars['template_files'][] = 'om-maximenu-modal-links__' . $vars['maximenu_name'];
  $vars['template_files'][] = 'om-maximenu-modal-links__' . $vars['maximenu_name'] . '-' . $vars['key'];
  $vars['template_files'][] = 'om-maximenu-modal-links__' . om_string_name($content['link_title']);
}