Exemplo n.º 1
0
/**
 * Pre-processes variables for the "html" theme hook.
 *
 * See template for list of available variables.
 *
 * @see html.tpl.php
 *
 * @ingroup theme_preprocess
 */
function bootstrap_preprocess_html(&$variables)
{
    // Backport from Drupal 8 RDFa/HTML5 implementation.
    // @see https://www.drupal.org/node/1077566
    // @see https://www.drupal.org/node/1164926
    // HTML element attributes.
    $variables['html_attributes_array'] = array('lang' => $variables['language']->language, 'dir' => $variables['language']->dir);
    // Override existing RDF namespaces to use RDFa 1.1 namespace prefix bindings.
    if (function_exists('rdf_get_namespaces')) {
        $rdf = array('prefix' => array());
        foreach (rdf_get_namespaces() as $prefix => $uri) {
            $rdf['prefix'][] = $prefix . ': ' . $uri;
        }
        if (!$rdf['prefix']) {
            $rdf = array();
        }
        $variables['rdf_namespaces'] = drupal_attributes($rdf);
    }
    // BODY element attributes.
    $variables['body_attributes_array'] = array('class' => &$variables['classes_array']);
    $variables['body_attributes_array'] += $variables['attributes_array'];
    // Navbar position.
    switch (bootstrap_setting('navbar_position')) {
        case 'fixed-top':
            $variables['body_attributes_array']['class'][] = 'navbar-is-fixed-top';
            break;
        case 'fixed-bottom':
            $variables['body_attributes_array']['class'][] = 'navbar-is-fixed-bottom';
            break;
        case 'static-top':
            $variables['body_attributes_array']['class'][] = 'navbar-is-static-top';
            break;
    }
}
 /**
  * Tests getting RDF namespaces.
  */
 function testGetRdfNamespaces()
 {
     // Get all RDF namespaces.
     $ns = rdf_get_namespaces();
     $this->assertEqual($ns['rdfs'], 'http://www.w3.org/2000/01/rdf-schema#', 'A prefix declared once is included.');
     $this->assertEqual($ns['foaf'], 'http://xmlns.com/foaf/0.1/', 'The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.');
     $this->assertEqual($ns['foaf1'], 'http://xmlns.com/foaf/0.1/', 'Two prefixes can be assigned the same namespace.');
     // Enable rdf_conflicting_namespaces to ensure that an exception is thrown
     // when RDF namespaces are conflicting.
     \Drupal::moduleHandler()->install(array('rdf_conflicting_namespaces'), TRUE);
     try {
         $ns = rdf_get_namespaces();
         $this->fail('Expected exception not thrown for conflicting namespace declaration.');
     } catch (\Exception $e) {
         $this->pass('Expected exception thrown: ' . $e->getMessage());
     }
 }
Exemplo n.º 3
0
 public function render($row)
 {
     static $row_index;
     if (!isset($row_index)) {
         $row_index = 0;
     }
     if (function_exists('rdf_get_namespaces')) {
         // Merge RDF namespaces in the XML namespaces in case they are used
         // further in the RSS content.
         $xml_rdf_namespaces = array();
         foreach (rdf_get_namespaces() as $prefix => $uri) {
             $xml_rdf_namespaces['xmlns:' . $prefix] = $uri;
         }
         $this->view->style_plugin->namespaces += $xml_rdf_namespaces;
     }
     // Create the RSS item object.
     $item = new \stdClass();
     $item->title = $this->getField($row_index, $this->options['title_field']);
     // @todo Views should expect and store a leading /. See:
     //   https://www.drupal.org/node/2423913
     $item->link = Url::fromUserInput('/' . $this->getField($row_index, $this->options['link_field']))->setAbsolute()->toString();
     $field = $this->getField($row_index, $this->options['description_field']);
     $item->description = is_array($field) ? $field : ['#markup' => $field];
     $item->elements = array(array('key' => 'pubDate', 'value' => $this->getField($row_index, $this->options['date_field'])), array('key' => 'dc:creator', 'value' => $this->getField($row_index, $this->options['creator_field']), 'namespace' => array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/')));
     $guid_is_permalink_string = 'false';
     $item_guid = $this->getField($row_index, $this->options['guid_field_options']['guid_field']);
     if ($this->options['guid_field_options']['guid_field_is_permalink']) {
         $guid_is_permalink_string = 'true';
         // @todo Enforce GUIDs as system-generated rather than user input? See
         //   https://www.drupal.org/node/2430589.
         $item_guid = Url::fromUserInput('/' . $item_guid)->setAbsolute()->toString();
     }
     $item->elements[] = array('key' => 'guid', 'value' => $item_guid, 'attributes' => array('isPermaLink' => $guid_is_permalink_string));
     $row_index++;
     foreach ($item->elements as $element) {
         if (isset($element['namespace'])) {
             $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $element['namespace']);
         }
     }
     $build = array('#theme' => $this->themeFunctions(), '#view' => $this->view, '#options' => $this->options, '#row' => $item, '#field_alias' => isset($this->field_alias) ? $this->field_alias : '');
     return $build;
 }
Exemplo n.º 4
0
/**
 * Implements hook_preprocess_html()
 */
function accessible_theme_preprocess_html(&$vars)
{
    $vars['base_path'] = base_path();
    $vars['path_to_accessible_theme'] = drupal_get_path('theme', 'accessible_theme');
    $variables['skip_link_anchor'] = check_plain(theme_get_setting('accessible_theme_skip_link_anchor'));
    $variables['skip_link_text'] = check_plain(theme_get_setting('accessible_theme_skip_link_text'));
    // Viewport!
    $viewport = array('#tag' => 'meta', '#attributes' => array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0'));
    drupal_add_html_head($viewport, 'viewport');
    // Force IE to use most up-to-date render engine.
    $xua = array('#tag' => 'meta', '#attributes' => array('http-equiv' => 'X-UA-Compatible', 'content' => 'IE=edge'));
    drupal_add_html_head($xua, 'x-ua-compatible');
    //////////////////////////////
    // HTML5 Base Theme Forwardport
    //
    // Backports the following changes made to Drupal 8:
    // - #1077566: Convert html.tpl.php to HTML5.
    //////////////////////////////
    // Initializes attributes which are specific to the html and body elements.
    $vars['html_attributes_array'] = array();
    $vars['rdf_attributes_array'] = array();
    $vars['body_attributes_array'] = array();
    // HTML element attributes.
    $vars['html_attributes_array']['lang'] = $GLOBALS['language']->language;
    $vars['html_attributes_array']['dir'] = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
    /*
      // Return early, so the maintenance page does not call any of the code below.
      if ($hook != 'html') {
        return;
      }
    */
    // Update RDF Namespacing
    if (module_exists('rdf')) {
        // Adds RDF namespace prefix bindings in the form of an RDFa 1.1 prefix
        // attribute inside the html element.
        $prefixes = array();
        foreach (rdf_get_namespaces() as $prefix => $uri) {
            $vars['rdf_attributes_array']['prefix'][] = $prefix . ': ' . $uri . "\n";
        }
    }
}
Exemplo n.º 5
0
function pulp_preprocess_html(&$variables)
{
    // Attributes for html element.
    $variables['html_attributes_array'] = array('lang' => $variables['language']->language, 'dir' => $variables['language']->dir);
    // RDF attributes for html element.
    if (module_exists('rdf')) {
        // Adds RDF namespace prefix bindings in the form of an RDFa 1.1 prefix
        // attribute inside the html element.
        $prefixes = array();
        foreach (rdf_get_namespaces() as $prefix => $uri) {
            $variables['html_attributes_array']['prefix'][] = $prefix . ': ' . $uri . "\n";
        }
    }
    // Store the menu item since it has some useful information.
    $variables['menu_item'] = menu_get_item();
    // Add class if a views page
    switch ($variables['menu_item']['page_callback']) {
        case 'views_page':
            // Is this a Views page?
            $variables['classes_array'][] = 'page-views';
            break;
    }
    // Add class if a panels page
    $panel_page_callbacks = array('page_manager_page_execute', 'page_manager_node_view', 'page_manager_node_view_page', 'page_manager_contact_site');
    if (in_array($variables['menu_item']['page_callback'], $panel_page_callbacks)) {
        $variables['classes_array'][] = 'page-panels';
    } else {
        $variables['classes_array'][] = 'page-not-panels';
    }
    // Add classes based on path
    $path = drupal_get_path_alias($_GET['q']);
    $sections = explode('/', $path);
    foreach ($sections as $key => $value) {
        $prefix = str_repeat("sub-", $key) . 'section-';
        $variables['classes_array'][] = drupal_html_class($prefix . $value);
        if ($key == 1) {
            break;
        }
    }
}
Exemplo n.º 6
0
 public function render($row)
 {
     static $row_index;
     if (!isset($row_index)) {
         $row_index = 0;
     }
     if (function_exists('rdf_get_namespaces')) {
         // Merge RDF namespaces in the XML namespaces in case they are used
         // further in the RSS content.
         $xml_rdf_namespaces = array();
         foreach (rdf_get_namespaces() as $prefix => $uri) {
             $xml_rdf_namespaces['xmlns:' . $prefix] = $uri;
         }
         $this->view->style_plugin->namespaces += $xml_rdf_namespaces;
     }
     // Create the RSS item object.
     $item = new \stdClass();
     $item->title = $this->getField($row_index, $this->options['title_field']);
     $item->link = _url($this->getField($row_index, $this->options['link_field']), array('absolute' => TRUE));
     $item->description = $this->getField($row_index, $this->options['description_field']);
     $item->elements = array(array('key' => 'pubDate', 'value' => $this->getField($row_index, $this->options['date_field'])), array('key' => 'dc:creator', 'value' => $this->getField($row_index, $this->options['creator_field']), 'namespace' => array('xmlns:dc' => 'http://purl.org/dc/elements/1.1/')));
     $guid_is_permalink_string = 'false';
     $item_guid = $this->getField($row_index, $this->options['guid_field_options']['guid_field']);
     if ($this->options['guid_field_options']['guid_field_is_permalink']) {
         $guid_is_permalink_string = 'true';
         $item_guid = _url($item_guid, array('absolute' => TRUE));
     }
     $item->elements[] = array('key' => 'guid', 'value' => $item_guid, 'attributes' => array('isPermaLink' => $guid_is_permalink_string));
     $row_index++;
     foreach ($item->elements as $element) {
         if (isset($element['namespace'])) {
             $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $element['namespace']);
         }
     }
     $build = array('#theme' => $this->themeFunctions(), '#view' => $this->view, '#options' => $this->options, '#row' => $item, '#field_alias' => isset($this->field_alias) ? $this->field_alias : '');
     return drupal_render($build);
 }
Exemplo n.º 7
0
 public function render($row)
 {
     global $base_url;
     $nid = $row->{$this->field_alias};
     if (!is_numeric($nid)) {
         return;
     }
     $display_mode = $this->options['view_mode'];
     if ($display_mode == 'default') {
         $display_mode = \Drupal::config('system.rss')->get('items.view_mode');
     }
     // Load the specified node:
     /** @var \Drupal\node\NodeInterface $node */
     $node = $this->nodes[$nid];
     if (empty($node)) {
         return;
     }
     $description_build = [];
     $node->link = $node->url('canonical', array('absolute' => TRUE));
     $node->rss_namespaces = array();
     $node->rss_elements = array(array('key' => 'pubDate', 'value' => gmdate('r', $node->getCreatedTime())), array('key' => 'dc:creator', 'value' => $node->getOwner()->getUsername()), array('key' => 'guid', 'value' => $node->id() . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false')));
     // The node gets built and modules add to or modify $node->rss_elements
     // and $node->rss_namespaces.
     $build_mode = $display_mode;
     $build = node_view($node, $build_mode);
     unset($build['#theme']);
     if (!empty($node->rss_namespaces)) {
         $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $node->rss_namespaces);
     } elseif (function_exists('rdf_get_namespaces')) {
         // Merge RDF namespaces in the XML namespaces in case they are used
         // further in the RSS content.
         $xml_rdf_namespaces = array();
         foreach (rdf_get_namespaces() as $prefix => $uri) {
             $xml_rdf_namespaces['xmlns:' . $prefix] = $uri;
         }
         $this->view->style_plugin->namespaces += $xml_rdf_namespaces;
     }
     if ($display_mode != 'title') {
         // We render node contents.
         $description_build = $build;
     }
     $item = new \stdClass();
     $item->description = $description_build;
     $item->title = $node->label();
     $item->link = $node->link;
     // Provide a reference so that the render call in
     // template_preprocess_views_view_row_rss() can still access it.
     $item->elements =& $node->rss_elements;
     $item->nid = $node->id();
     $build = array('#theme' => $this->themeFunctions(), '#view' => $this->view, '#options' => $this->options, '#row' => $item);
     return $build;
 }
Exemplo n.º 8
0
function evental_preprocess_html(&$vars)
{
    global $user, $language;
    // Add role name classes (to allow css based show for admin/hidden from user)
    foreach ($user->roles as $role) {
        $vars['classes_array'][] = 'role-' . evental_id_safe($role);
    }
    // HTML Attributes
    // Use a proper attributes array for the html attributes.
    $vars['html_attributes'] = array();
    $vars['html_attributes']['lang'][] = $language->language;
    $vars['html_attributes']['dir'][] = $language->dir;
    // Convert RDF Namespaces into structured data using drupal_attributes.
    $vars['rdf_namespaces'] = array();
    if (function_exists('rdf_get_namespaces')) {
        foreach (rdf_get_namespaces() as $prefix => $uri) {
            $prefixes[] = $prefix . ': ' . $uri;
        }
        $vars['rdf_namespaces']['prefix'] = implode(' ', $prefixes);
    }
    // Flatten the HTML attributes and RDF namespaces arrays.
    $vars['html_attributes'] = drupal_attributes($vars['html_attributes']);
    $vars['rdf_namespaces'] = drupal_attributes($vars['rdf_namespaces']);
    if (!$vars['is_front']) {
        // Add unique classes for each page and website section
        $path = drupal_get_path_alias($_GET['q']);
        list($section, ) = explode('/', $path, 2);
        $vars['classes_array'][] = 'with-subnav';
        $vars['classes_array'][] = evental_id_safe('page-' . $path);
        $vars['classes_array'][] = evental_id_safe('section-' . $section);
        if (arg(0) == 'node') {
            if (arg(1) == 'add') {
                if ($section == 'node') {
                    // Remove 'section-node'
                    array_pop($vars['classes_array']);
                }
                // Add 'section-node-add'
                $vars['classes_array'][] = 'section-node-add';
            } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
                if ($section == 'node') {
                    // Remove 'section-node'
                    array_pop($vars['classes_array']);
                }
                // Add 'section-node-edit' or 'section-node-delete'
                $vars['classes_array'][] = 'section-node-' . arg(2);
            }
        }
    }
    //for normal un-themed edit pages
    if (arg(0) == 'node' && arg(2) == 'edit') {
        $vars['template_files'][] = 'page';
    }
    // Add IE classes.
    if (theme_get_setting('evental_ie_enabled')) {
        $evental_ie_enabled_versions = theme_get_setting('evental_ie_enabled_versions');
        if (in_array('ie8', $evental_ie_enabled_versions, TRUE)) {
            drupal_add_css(path_to_theme() . '/css/ie8.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 8', '!IE' => FALSE), 'preprocess' => FALSE));
            drupal_add_js(path_to_theme() . '/js/build/selectivizr-min.js');
        }
        if (in_array('ie9', $evental_ie_enabled_versions, TRUE)) {
            drupal_add_css(path_to_theme() . '/css/ie9.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 9', '!IE' => FALSE), 'preprocess' => FALSE));
        }
        if (in_array('ie10', $evental_ie_enabled_versions, TRUE)) {
            drupal_add_css(path_to_theme() . '/css/ie10.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 10', '!IE' => FALSE), 'preprocess' => FALSE));
        }
    }
}
Exemplo n.º 9
0
/**
 * HTML preprocessing
 */
function webpro_core_preprocess_html(&$vars)
{
    global $theme_key, $user;
    // Add to array of helpful body classes.
    if (isset($vars['node'])) {
        // For full nodes.
        $vars['classes_array'][] = $vars['node'] ? 'full-node' : '';
        // For forums.
        $vars['classes_array'][] = $vars['node']->type == 'forum' || arg(0) == 'forum' ? 'forum' : '';
    } else {
        // Forums.
        $vars['classes_array'][] = arg(0) == 'forum' ? 'forum' : '';
    }
    if (module_exists('panels') && function_exists('panels_get_current_page_display')) {
        $vars['classes_array'][] = panels_get_current_page_display() ? 'panels' : '';
    }
    $vars['classes_array'][] = theme_get_setting('theme_font') != 'none' ? theme_get_setting('theme_font') : '';
    $vars['classes_array'][] = theme_get_setting('theme_font_size');
    $vars['classes_array'][] = user_access('administer blocks', $user) && theme_get_setting('grid_mask') ? 'grid-mask-enabled' : '';
    // Add grid classes
    $grid = webpro_core_grid_info();
    // Fixed or fluid.
    $vars['classes_array'][] = 'grid-type-' . $grid['type'];
    // Number of units in the grid (12, 16, etc.)
    $vars['classes_array'][] = 'grid-width-' . sprintf("%02d", $grid['width']);
    // Fluid grid width in %.
    $vars['classes_array'][] = $grid['type'] == 'fluid' ? theme_get_setting('fluid_grid_width') : '';
    // Remove any empty elements in the array.
    $vars['classes_array'] = array_filter($vars['classes_array']);
    // Serialize RDF namespaces into an RDFa 1.1 prefix attribute.
    if (function_exists('rdf_get_namespaces')) {
        foreach (rdf_get_namespaces() as $prefix => $uri) {
            $prefixes[] = $prefix . ': ' . $uri;
        }
        $vars['rdf_namespaces'] = ' prefix="' . implode(' ', $prefixes) . '"';
    }
    $themes = webpro_core_theme_paths($theme_key);
    $file = theme_get_setting('theme_grid') . '.css';
    $cache = cache_get('webpro');
    $new_cache = array();
    $vars['mobile_friendly'] = FALSE;
    $vars['classes_array'][] = theme_get_setting('sidebar_layout');
    foreach ($themes as $name => $path) {
        if (empty($cache->data['grid_css'][$name][$file])) {
            if (file_exists($path . '/css/' . $file)) {
                drupal_add_css($path . '/css/' . $file, array('group' => CSS_THEME, 'preprocess' => TRUE));
                $new_cache['grid_css'][$name][$file] = TRUE;
            } else {
                $new_cache['grid_css'][$name][$file] = WEBPRO_FILE_NOT_FOUND;
            }
        } else {
            if ($cache->data['grid_css'][$name][$file] === TRUE) {
                drupal_add_css($path . '/css/' . $file, array('group' => CSS_THEME, 'preprocess' => TRUE));
            }
        }
    }
    // Include any instances of local.css.
    foreach ($themes as $name => $path) {
        // Include any instances of local.css.
        if (empty($cache->data['local_css'][$path])) {
            if (file_exists($path . '/css/local.css')) {
                drupal_add_css($path . '/css/local.css', array('group' => CSS_THEME, 'preprocess' => TRUE));
                $new_cache['local_css'][$path] = TRUE;
            } else {
                $new_cache['local_css'][$path] = WEBPRO_FILE_NOT_FOUND;
            }
        } else {
            if ($cache->data['local_css'][$path] === TRUE) {
                drupal_add_css($path . '/css/local.css', array('group' => CSS_THEME, 'preprocess' => TRUE));
            }
        }
    }
    // Add a unique page id.
    $vars['body_id'] = 'pid-' . drupal_clean_css_identifier(drupal_get_path_alias($_GET['q']));
    // Update cache, if necessary.
    if ($new_cache) {
        cache_set('webpro', $new_cache, 'cache', CACHE_TEMPORARY);
    }
}
Exemplo n.º 10
0
 public function render($row)
 {
     // For the most part, this code is taken from node_feed() in node.module
     global $base_url;
     $nid = $row->{$this->field_alias};
     if (!is_numeric($nid)) {
         return;
     }
     $display_mode = $this->options['view_mode'];
     if ($display_mode == 'default') {
         $display_mode = \Drupal::config('system.rss')->get('items.view_mode');
     }
     // Load the specified node:
     /** @var \Drupal\node\NodeInterface $node */
     $node = $this->nodes[$nid];
     if (empty($node)) {
         return;
     }
     $item_text = '';
     $node->link = $node->url('canonical', array('absolute' => TRUE));
     $node->rss_namespaces = array();
     $node->rss_elements = array(array('key' => 'pubDate', 'value' => gmdate('r', $node->getCreatedTime())), array('key' => 'dc:creator', 'value' => $node->getOwner()->getUsername()), array('key' => 'guid', 'value' => $node->id() . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false')));
     // The node gets built and modules add to or modify $node->rss_elements
     // and $node->rss_namespaces.
     $build_mode = $display_mode;
     $build = node_view($node, $build_mode);
     unset($build['#theme']);
     if (!empty($node->rss_namespaces)) {
         $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $node->rss_namespaces);
     } elseif (function_exists('rdf_get_namespaces')) {
         // Merge RDF namespaces in the XML namespaces in case they are used
         // further in the RSS content.
         $xml_rdf_namespaces = array();
         foreach (rdf_get_namespaces() as $prefix => $uri) {
             $xml_rdf_namespaces['xmlns:' . $prefix] = $uri;
         }
         $this->view->style_plugin->namespaces += $xml_rdf_namespaces;
     }
     // Hide the links if desired.
     if (!$this->options['links']) {
         hide($build['links']);
     }
     if ($display_mode != 'title') {
         // We render node contents and force links to be last.
         $build['links']['#weight'] = 1000;
         $item_text .= drupal_render($build);
     }
     $item = new \stdClass();
     $item->description = SafeMarkup::set($item_text);
     $item->title = $node->label();
     $item->link = $node->link;
     $item->elements = $node->rss_elements;
     $item->nid = $node->id();
     $theme_function = array('#theme' => $this->themeFunctions(), '#view' => $this->view, '#options' => $this->options, '#row' => $item);
     return drupal_render($theme_function);
 }
Exemplo n.º 11
0
  /**
   * Extracts properties of a given type.
   *
   * @param string $type
   *   Schema.Org type of which the properties should be listed.
   *   (eg. "schema:Person").
   *
   * @return array|null
   *   List of properties.
   */
  public function getTypeProperties($type) {
    $tokens = explode(":", $type);
    $prefixes = rdf_get_namespaces();
    $uri = $prefixes[$tokens[0]] . $tokens[1];

    $options = array();
    $options += $this->getProperties($uri);
    asort($options);
    return $options;
  }
Exemplo n.º 12
0
/**
 * HTML preprocessing
 */
function fusion_core_preprocess_html(&$vars)
{
    global $theme_key, $user;
    // Add to array of helpful body classes.
    if (isset($vars['node'])) {
        // For full nodes.
        $vars['classes_array'][] = $vars['node'] ? 'full-node' : '';
        // For forums.
        $vars['classes_array'][] = $vars['node']->type == 'forum' || arg(0) == 'forum' ? 'forum' : '';
    } else {
        // Forums.
        $vars['classes_array'][] = arg(0) == 'forum' ? 'forum' : '';
    }
    if (module_exists('panels') && function_exists('panels_get_current_page_display')) {
        $vars['classes_array'][] = panels_get_current_page_display() ? 'panels' : '';
    }
    $vars['classes_array'][] = theme_get_setting('theme_font') != 'none' ? theme_get_setting('theme_font') : '';
    $vars['classes_array'][] = theme_get_setting('theme_font_size');
    $vars['classes_array'][] = user_access('administer blocks', $user) && theme_get_setting('grid_mask') ? 'grid-mask-enabled' : '';
    // Add grid classes
    $grid = fusion_core_grid_info();
    // Fixed or fluid.
    $vars['classes_array'][] = 'grid-type-' . $grid['type'];
    // Number of units in the grid (12, 16, etc.)
    $vars['classes_array'][] = 'grid-width-' . sprintf("%02d", $grid['width']);
    // Fluid grid width in %.
    $vars['classes_array'][] = $grid['type'] == 'fluid' ? theme_get_setting('fluid_grid_width') : '';
    // Remove any empty elements in the array.
    $vars['classes_array'] = array_filter($vars['classes_array']);
    // Serialize RDF namespaces into an RDFa 1.1 prefix attribute.
    if (function_exists('rdf_get_namespaces')) {
        foreach (rdf_get_namespaces() as $prefix => $uri) {
            $prefixes[] = $prefix . ': ' . $uri;
        }
        $vars['rdf_namespaces'] = ' prefix="' . implode(' ', $prefixes) . '"';
    }
    $themes = fusion_core_theme_paths($theme_key);
    $file = theme_get_setting('theme_grid') . '.css';
    $cache = cache_get('fusion');
    $new_cache = array();
    if (module_exists('fusion_accelerator') && theme_get_setting('responsive_enabled')) {
        $responsive_path = variable_get($theme_key . '_responsive_path');
        $responsive_file = variable_get($theme_key . '_responsive_css');
        if (empty($cache->data['grid_generated'])) {
            $rebuild_css = FALSE;
            if (!$responsive_path || $responsive_file) {
                // Variables are missing, either because the settings have never been accessed
                // or they've been manually deleted.
                $rebuild_css = TRUE;
            } elseif (!file_exists($responsive_path . '/' . $responsive_css)) {
                $rebuild_css = TRUE;
            }
            if ($rebuild_css) {
                // rebuild responsive CSS based on theme defaults.
                $responsive_options = _fusion_accelerator_get_responsive_options($theme_key);
                $options = array();
                foreach ($responsive_options as $op) {
                    if ($setting = theme_get_setting($op, $theme_key)) {
                        $options[$op] = $setting;
                    }
                }
                $options['theme'] = $theme_key;
                $options['units'] = $options['responsive_columns'];
                $options['responsive'] = TRUE;
                _fusion_accelerator_save_grid($options);
                $new_cache['grid_generated'] = TRUE;
            }
        }
        // Add classes to indicate the sidebar widths across all responsive layouts.
        // Consolidate information about various layouts.
        $vars['mobile_friendly'] = TRUE;
        $vars['show_current_grid'] = theme_get_setting('grid_mask') ? TRUE : FALSE;
        // Fetch responsive grid.
        $path = variable_get($theme_key . '_responsive_path');
        $responsive_css = variable_get($theme_key . '_responsive_css');
        if ($path && $responsive_css) {
            // Generated by theme settings.
            drupal_add_css($path . '/' . $responsive_css);
        }
    } else {
        // Fusion Accelerator does not exist, or responsive has been disabled.
        // Search themes for grid files, and use those.
        $vars['mobile_friendly'] = FALSE;
        $vars['classes_array'][] = theme_get_setting('sidebar_layout');
        foreach ($themes as $name => $path) {
            if (empty($cache->data['grid_css'][$name][$file])) {
                if (file_exists($path . '/css/' . $file)) {
                    drupal_add_css($path . '/css/' . $file, array('group' => CSS_THEME, 'preprocess' => TRUE));
                    $new_cache['grid_css'][$name][$file] = TRUE;
                } else {
                    $new_cache['grid_css'][$name][$file] = FUSION_FILE_NOT_FOUND;
                }
            } else {
                if ($cache->data['grid_css'][$name][$file] === TRUE) {
                    drupal_add_css($path . '/css/' . $file, array('group' => CSS_THEME, 'preprocess' => TRUE));
                }
            }
        }
    }
    // Include any instances of local.css.
    foreach ($themes as $name => $path) {
        // Include any instances of local.css.
        if (empty($cache->data['local_css'][$path])) {
            if (file_exists($path . '/css/local.css')) {
                drupal_add_css($path . '/css/local.css', array('group' => CSS_THEME, 'preprocess' => TRUE));
                $new_cache['local_css'][$path] = TRUE;
            } else {
                $new_cache['local_css'][$path] = FUSION_FILE_NOT_FOUND;
            }
        } else {
            if ($cache->data['local_css'][$path] === TRUE) {
                drupal_add_css($path . '/css/local.css', array('group' => CSS_THEME, 'preprocess' => TRUE));
            }
        }
        // If responsive is enabled, include any instances of responsive.css.
        if (module_exists('fusion_accelerator') && theme_get_setting('responsive_enabled')) {
            if (empty($cache->data['responsive_css'][$path])) {
                if (file_exists($path . '/css/responsive.css')) {
                    drupal_add_css($path . '/css/responsive.css', array('group' => CSS_THEME, 'preprocess' => TRUE));
                    $new_cache['responsive_css'][$path] = TRUE;
                } else {
                    $new_cache['responsive_css'][$path] = FUSION_FILE_NOT_FOUND;
                }
            } else {
                if ($cache->data['responsive_css'][$path] === TRUE) {
                    drupal_add_css($path . '/css/responsive.css', array('group' => CSS_THEME, 'preprocess' => TRUE));
                }
            }
        }
    }
    // Add a unique page id.
    $vars['body_id'] = 'pid-' . drupal_clean_css_identifier(drupal_get_path_alias($_GET['q']));
    // Update cache, if necessary.
    if ($new_cache) {
        cache_set('fusion', $new_cache, 'cache', CACHE_TEMPORARY);
    }
}
Exemplo n.º 13
0
/**
 * Implements preprocess_html().
 */
function travel_preprocess_html(&$vars)
{
    global $language;
    // HTML Attributes
    // Use a proper attributes array for the html attributes.
    $vars['html_attributes'] = array();
    $vars['html_attributes']['lang'][] = $language->language;
    $vars['html_attributes']['dir'][] = $language->dir;
    // Convert RDF Namespaces into structured data using drupal_attributes.
    $vars['rdf_namespaces'] = array();
    if (function_exists('rdf_get_namespaces')) {
        foreach (rdf_get_namespaces() as $prefix => $uri) {
            $prefixes[] = $prefix . ': ' . $uri;
        }
        $vars['rdf_namespaces']['prefix'] = implode(' ', $prefixes);
    }
    // Flatten the HTML attributes and RDF namespaces arrays.
    $vars['html_attributes'] = drupal_attributes($vars['html_attributes']);
    $vars['rdf_namespaces'] = drupal_attributes($vars['rdf_namespaces']);
    // Add IE classes.
    if (theme_get_setting('basic_ie_enabled')) {
        $travel_ie_enabled_versions = theme_get_setting('travel_ie_enabled_versions');
        if (in_array('ie8', $travel_ie_enabled_versions, TRUE)) {
            drupal_add_css(path_to_theme() . '/css/ie8.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 8', '!IE' => FALSE), 'preprocess' => FALSE));
            drupal_add_js(path_to_theme() . '/js/vendor/selectivizr-min.js');
        }
        if (in_array('ie9', $travel_ie_enabled_versions, TRUE)) {
            drupal_add_css(path_to_theme() . '/css/ie9.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 9', '!IE' => FALSE), 'preprocess' => FALSE));
        }
        if (in_array('ie10', $travel_ie_enabled_versions, TRUE)) {
            drupal_add_css(path_to_theme() . '/css/ie10.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 10', '!IE' => FALSE), 'preprocess' => FALSE));
        }
    }
}
Exemplo n.º 14
0
/**
 * Implements hook_preprocess_html()
 */
function aurora_preprocess_html(&$vars)
{
    // Viewport!
    $viewport = array('#tag' => 'meta', '#attributes' => array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0'));
    drupal_add_html_head($viewport, 'viewport');
    // Force IE to use most up-to-date render engine.
    $xua = array('#tag' => 'meta', '#attributes' => array('http-equiv' => 'X-UA-Compatible', 'content' => 'IE=edge'));
    drupal_add_html_head($xua, 'x-ua-compatible');
    $vars['minie'] = theme_get_setting('aurora_min_ie_support');
    //////////////////////////////
    // HTML5 Base Theme Forwardport
    //
    // Backports the following changes made to Drupal 8:
    // - #1077566: Convert html.tpl.php to HTML5.
    //////////////////////////////
    // Initializes attributes which are specific to the html and body elements.
    $vars['html_attributes_array'] = array();
    $vars['rdf_attributes_array'] = array();
    $vars['body_attributes_array'] = array();
    // HTML element attributes.
    $vars['html_attributes_array']['lang'] = $GLOBALS['language']->language;
    $vars['html_attributes_array']['dir'] = $GLOBALS['language']->direction ? 'rtl' : 'ltr';
    // Update RDF Namespacing
    if (module_exists('rdf')) {
        // Adds RDF namespace prefix bindings in the form of an RDFa 1.1 prefix
        // attribute inside the html element.
        $prefixes = array();
        foreach (rdf_get_namespaces() as $prefix => $uri) {
            $vars['rdf_attributes_array']['prefix'][] = $prefix . ': ' . $uri . "\n";
        }
    }
    //////////////////////////////
    // LiveReload Integration
    //////////////////////////////
    $livereload_port = theme_get_setting('aurora_livereload');
    if ($livereload_port) {
        if ($livereload_port == 'snugug') {
            $livereload_port = theme_get_setting('aurora_livereload_port');
            if (is_null($livereload_port)) {
                $livereload_port = 35729;
            }
        }
        drupal_add_js("document.write('<script src=\"http://' + (location.host || 'localhost').split(':')[0] + ':{$livereload_port}/livereload.js?snipver=1\"></' + 'script>')", array('type' => 'inline', 'scope' => 'footer', 'weight' => 9999));
    }
    //////////////////////////////
    // Add in TypeKit Code.
    //////////////////////////////
    if (theme_get_setting('aurora_typekit_id')) {
        drupal_add_js('(function(){var e={kitId:"' . theme_get_setting('aurora_typekit_id') . '",scriptTimeout:3e3},t=document.getElementsByTagName("html")[0];t.className+=" wf-loading";var n=setTimeout(function(){t.className=t.className.replace(/(\\s|^)wf-loading(\\s|$)/g," "),t.className+=" wf-inactive"},e.scriptTimeout),r=document.createElement("script"),i=!1;r.src="//use.typekit.net/"+e.kitId+".js",r.type="text/javascript",r.async="true",r.onload=r.onreadystatechange=function(){var t=this.readyState;if(i||t&&t!="complete"&&t!="loaded")return;i=!0,clearTimeout(n);try{Typekit.load(e)}catch(r){}};var s=document.getElementsByTagName("script")[0];s.parentNode.insertBefore(r,s)})()', array('type' => 'inline', 'force header' => true));
    }
}
Exemplo n.º 15
0
function mnts_preprocess_html(&$vars)
{
    global $user;
    drupal_add_css('http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700|Open+Sans+Condensed:300,700|Raleway:400,300,600,700', array('type' => 'external'));
    drupal_add_css('http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.min.css', array('type' => 'external'));
    drupal_add_js('http://code.jquery.com/ui/1.10.3/jquery-ui.min.js', 'external');
    //agregar jquery
    // drupal_add_js('http://code.jquery.com/jquery-1.11.0.js');
    // Add role name classes (to allow css based show for admin/hidden from user)
    foreach ($user->roles as $role) {
        $vars['classes_array'][] = 'role-' . mnts_id_safe($role);
    }
    // HTML Attributes
    // Use a proper attributes array for the html attributes.
    $vars['html_attributes'] = array();
    //$vars['html_attributes']['lang'][] = $language->language;
    //$vars['html_attributes']['dir'][] = $language->dir;
    // Convert RDF Namespaces into structured data using drupal_attributes.
    $vars['rdf_namespaces'] = array();
    if (function_exists('rdf_get_namespaces')) {
        foreach (rdf_get_namespaces() as $prefix => $uri) {
            $prefixes[] = $prefix . ': ' . $uri;
        }
        $vars['rdf_namespaces']['prefix'] = implode(' ', $prefixes);
    }
    // Flatten the HTML attributes and RDF namespaces arrays.
    $vars['html_attributes'] = drupal_attributes($vars['html_attributes']);
    $vars['rdf_namespaces'] = drupal_attributes($vars['rdf_namespaces']);
    if (!$vars['is_front']) {
        // Add unique classes for each page and website section
        $path = drupal_get_path_alias($_GET['q']);
        list($section, ) = explode('/', $path, 2);
        $vars['classes_array'][] = 'with-subnav';
        $vars['classes_array'][] = mnts_id_safe('page-' . $path);
        $vars['classes_array'][] = mnts_id_safe('section-' . $section);
        if (arg(0) == 'node') {
            if (arg(1) == 'add') {
                if ($section == 'node') {
                    // Remove 'section-node'
                    array_pop($vars['classes_array']);
                }
                // Add 'section-node-add'
                $vars['classes_array'][] = 'section-node-add';
            } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
                if ($section == 'node') {
                    // Remove 'section-node'
                    array_pop($vars['classes_array']);
                }
                // Add 'section-node-edit' or 'section-node-delete'
                $vars['classes_array'][] = 'section-node-' . arg(2);
            }
        }
    }
    //for normal un-themed edit pages
    if (arg(0) == 'node' && arg(2) == 'edit') {
        $vars['template_files'][] = 'page';
    }
    // Add IE classes.
    if (theme_get_setting('mnts_ie_enabled')) {
        $mnts_ie_enabled_versions = theme_get_setting('mnts_ie_enabled_versions');
        if (in_array('ie8', $mnts_ie_enabled_versions, TRUE)) {
            drupal_add_css(path_to_theme() . '/css/ie8.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 8', '!IE' => FALSE), 'preprocess' => FALSE));
            drupal_add_js(path_to_theme() . '/js/selectivizr-min.js');
        }
        if (in_array('ie9', $mnts_ie_enabled_versions, TRUE)) {
            drupal_add_css(path_to_theme() . '/css/ie9.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 9', '!IE' => FALSE), 'preprocess' => FALSE));
        }
        if (in_array('ie10', $mnts_ie_enabled_versions, TRUE)) {
            drupal_add_css(path_to_theme() . '/css/ie10.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 10', '!IE' => FALSE), 'preprocess' => FALSE));
        }
    }
    $node = node_load(arg(1));
    $results = taxonomy_node_get_terms($node);
    if (is_array($results)) {
        foreach ($results as $item) {
            $vars['classes_array'][] = "taxonomy-" . replace_specials_characters(strtolower(drupal_clean_css_identifier($item->name)));
        }
    }
    if (arg(0) == 'taxonomy' && arg(1) == 'term') {
        $term = taxonomy_term_load(arg(2));
        $vars['classes_array'][] = 'vocabulary-' . strtolower($term->vocabulary_machine_name);
    }
}