Skip to content
Snippets Groups Projects
Commit e7d28693 authored by Richard Buchanan's avatar Richard Buchanan
Browse files

Added X Autoload module as dependency

parent 9956f1cf
No related branches found
No related tags found
No related merge requests found
UIkit Components 7.x-2.x, 08-07-2017 (development version)
-----------------------
Added the X Autoload module as a dependency.
- The X Autoload module is now required by both UIkit Components and UIkit
Views. This adds support for Drupal-8-style PSR-4 autoloading of classes.
- https://www.drupal.org/project/xautoload
* If X Autoload is already installed and enabled, there is nothing you need
to do.
* Users who currently have the X Autoload module installed but not enabled
need to run Updates on their sites using update.php or drush up.
* Otherwise you will need to download and enable X Autoload.
See https://www.drupal.org/node/2893283
UIkit Components 7.x-2.x, 08-07-2017 (development version)
-----------------------
Added the Elements module as a dependency.
- The Elements module is now required by both UIkit Components and UIkit Views.
This adds support for newer HTML5 elements, which will be added to both UIkit
......@@ -10,7 +27,7 @@ Added the Elements module as a dependency.
* If Elements is already installed and enabled, there is nothing you need to
do.
* Users who currently have the Elements module installed but not enabled need
* to run Updates on their sites using update.php or drush up.
to run Updates on their sites using update.php or drush up.
* Otherwise you will need to download and enable Elements.
See https://www.drupal.org/node/2893280
......
<?php
namespace Drupal\uikit_components;
use Drupal\uikit\UIkit;
/**
* Provides helper functions for the UIkit Components module.
*/
class UIkitComponents {
/**
* Retrieves individual UIkit CDN asset using the UIkit::getCdnAsset() method.
*
* @param string $component
* The component to retrieve CDN assets for.
*/
public static function getUIkitAsset($component = NULL) {
if (!path_is_admin(current_path()) || self::isAdminThemeUIkitSubtheme()) {
UIkit::getCdnAsset($component);
}
}
/**
* Determines whether the admin theme is a UIkit sub-theme.
*
* @return bool
* Returns TRUE if the admin theme is a UIkit sub-theme, otherwise returns
* FALSE.
*/
private function isAdminThemeUIkitSubtheme() {
$admin_theme = variable_get('admin_theme','none');
$admin_theme_info_file = drupal_get_path('theme', $admin_theme) . "/$admin_theme.info";
$admin_theme_info = drupal_parse_info_file($admin_theme_info_file);
if (isset($admin_theme_info['base theme']) && $admin_theme_info['base theme'] == 'uikit') {
return TRUE;
}
else {
return FALSE;
}
}
}
......@@ -5,5 +5,6 @@ package = UIkit
dependencies[] = menu
dependencies[] = elements
dependencies[] = xautoload
configure = admin/config/user-interface/uikit-components
......@@ -125,6 +125,7 @@ function theme_uikit_navbar($variables) {
function uikit_components_preprocess_html(&$variables) {
$t_args = array(
'@elements' => 'https://www.drupal.org/project/elements',
'@xautoload' => 'https://www.drupal.org/project/xautoload',
'@update' => '/update.php',
);
......@@ -132,6 +133,11 @@ function uikit_components_preprocess_html(&$variables) {
$message = t('<em class="placeholder">UIkit Components</em> requires the <a href="@elements">Elements</a> module. Please download and install <em class="placeholder">Elements</em> and run <a href="@update">update.php</a>.', $t_args);
drupal_set_message($message, 'error');
}
if (!module_exists('xautoload') && !module_enable(array('xautoload'))) {
$message = t('<em class="placeholder">UIkit Components</em> requires the <a href="@xautoload">X Autoload</a> module. Please download and install <em class="placeholder">X Autoload</em> and run <a href="@update">update.php</a>.', $t_args);
drupal_set_message($message, 'error');
}
}
/**
......
......@@ -5,8 +5,7 @@
* Preprocessors and helper functions to make theming easier.
*/
include_once drupal_get_path('theme', 'uikit') . '/src/UIkit.php';
include_once drupal_get_path('theme', 'uikit') . '/includes/get.inc';
use Drupal\uikit_components\UIkitComponents;
/**
* Prepares variables for UIkit Accordion templates.
......@@ -19,6 +18,7 @@ include_once drupal_get_path('theme', 'uikit') . '/includes/get.inc';
* - rows: The raw row data.
*/
function template_preprocess_uikit_view_accordion(&$variables) {
UIkitComponents::getUIkitAsset('accordion');
$view = $variables['view'];
$handler = $view->style_plugin;
$options = $handler->options;
......@@ -59,11 +59,6 @@ function template_preprocess_uikit_view_accordion(&$variables) {
$selectors = '/[.#\[\]]/i';
$variables['accordion_toggle'] = preg_replace($selectors, '', $options['toggle']);
$variables['accordion_container'] = preg_replace($selectors, '', $options['containers']);
// Only add accordion assets if not viewing an administrative page.
if (!path_is_admin(current_path())) {
uikit_views_load_uikit_assets('accordion');
}
}
/**
......@@ -91,7 +86,6 @@ function template_process_uikit_view_accordion(&$variables) {
* - rows: The raw row data.
*/
function template_preprocess_uikit_view_grid(&$variables) {
uikit_views_load_uikit_assets();
$view = $variables['view'];
$options = $view->style_plugin->options;
$grid_classes = ['uk-grid'];
......@@ -147,7 +141,6 @@ function template_process_uikit_view_grid(&$variables) {
* - rows: The raw row data.
*/
function template_preprocess_uikit_view_list(&$variables) {
uikit_views_load_uikit_assets();
$handler = $variables['view']->style_plugin;
$options = $handler->options;
......@@ -184,7 +177,6 @@ function template_process_uikit_view_list(&$variables) {
* - rows: The raw row data.
*/
function template_preprocess_uikit_view_table(&$variables) {
uikit_views_load_uikit_assets();
$view = $variables['view'];
// We need the raw data for this grouping, which is passed in as $variables['rows'].
......@@ -414,6 +406,10 @@ function template_preprocess_uikit_view_table(&$variables) {
* @return bool
* Returns TRUE if the admin theme is a UIkit sub-theme, otherwise returns
* FALSE.
*
* @deprecated in UIkit Components 7.x-2.2, will be removed before 7.x-2.5.
*
* @see https://www.drupal.org/node/2893283
*/
function is_admin_theme_uikit_subtheme() {
$admin_theme = variable_get('admin_theme','none');
......@@ -434,6 +430,11 @@ function is_admin_theme_uikit_subtheme() {
* @param string $component
* The additional component assets to load. If this is omitted, only the UIkit
* core assets will be loaded if the admin theme is not a UIkit sub-theme.
*
* @deprecated in UIkit Components 7.x-2.2, will be removed before 7.x-2.5.
* Use \Drupal\uikit_components\UIkitComponents::getUIkitAsset();
*
* @see https://www.drupal.org/node/2893283
*/
function uikit_views_load_uikit_assets($component = NULL) {
if (!is_admin_theme_uikit_subtheme()) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment