/** * Prepares variables for page templates. * * @see page.tpl.php */ function bartik_css_alter(&$css) { // If using the legacy "Blue lagoon" color scheme, load the legacy stylesheet. $theme_path = backdrop_get_path('theme', 'bartik'); if (theme_get_setting('color_legacy') && isset($css[$theme_path . '/css/colors.css'])) { $css[$theme_path . '/css/colors.css']['data'] = $theme_path . '/css/colors-legacy.css'; } }
/** * Implements hook_preprocess_maintenance_page(). */ function materialize_preprocess_maintenance_page(&$variables) { backdrop_add_css(backdrop_get_path('theme', 'bartik') . '/css/maintenance-page.css'); }
/** * Determines if the current user is allowed to run update.php. * * @return * TRUE if the current user should be granted access, or FALSE otherwise. */ function update_access_allowed() { global $user; // Allow the global variable in settings.php to override the access check. if (settings_get('update_free_access')) { return TRUE; } // Calls to user_access() might fail during the update process, // so we fall back on requiring that the user be logged in as user #1. try { require_once BACKDROP_ROOT . '/' . backdrop_get_path('module', 'user') . '/user.module'; return user_access('administer software updates'); } catch (Exception $e) { return $user->uid == 1; } }
/** * Register View API information. * * This is required for your module to have its include files loaded; for * example, when implementing hook_views_default_views(). * * @return * An array with the following possible keys: * - api: (required) The version of the Views API the module implements. * - path: (optional) If includes are stored somewhere other than within the * root module directory, specify its path here. * - template path: (optional) A path where the module has stored it's views * template files. When you have specificed this key views automatically * uses the template files for the views. You can use the same naming * conventions like for normal views template files. */ function hook_views_api() { return array('api' => 3, 'path' => backdrop_get_path('module', 'example') . '/includes/views', 'template path' => backdrop_get_path('module', 'example') . '/templates'); }
function zurb_foundation_6_subtheme_css_alter(&$css) { $css_to_remove = array(); if (theme_get_setting('zurb_foundation_6_subtheme_cdn_css') > 0) { $css_to_remove[] = backdrop_get_path('theme', 'zurb_foundation_6') . '/css/foundation.min.css'; } if (theme_get_setting('sass') > 0) { $css_to_remove[] = backdrop_get_path('theme', 'zurb_foundation_6') . '/css/style.css'; $css_to_remove[] = backdrop_get_path('theme', 'zurb_foundation_6') . '/css/foundation.min.css'; } foreach ($css_to_remove as $index => $css_file) { unset($css[$css_file]); } }
function afterlight_tribute_subtheme_css_alter(&$css) { $css_to_remove = array(); if (theme_get_setting('sass', 'afterlight_tribute_subtheme') > 0) { $css_to_remove[] = backdrop_get_path('theme', 'afterlight_tribute') . '/css/style.css'; } foreach ($css_to_remove as $index => $css_file) { unset($css[$css_file]); } }
/** * Prepare variables for node template */ function borg_preprocess_node(&$variables) { // For news posts, change the username to a real name. if ($variables['node']->type == 'post') { // Change the submitted by language. $author = user_load($variables['node']->uid); $lang = $author->langcode; if (!empty($author->field_name[$lang])) { $variables['name'] = l($author->field_name[$lang][0]['safe_value'], 'user/' . $author->uid); } } // Change the submitted by language. $variables['submitted'] = t('Posted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date'])); // Add a picture to blog posts. if ($variables['type'] == 'post' && $variables['view_mode'] == 'full') { // Get the profile photo. $author = user_load($variables['uid']); $langcode = $author->langcode; $variables['user_picture'] = theme('image_style', array('style_name' => 'medium', 'uri' => $author->field_photo[$langcode][0]['uri'])); } if (substr($variables['type'], 0, 8) == 'project_') { $path = backdrop_get_path('theme', 'borg'); $variables['content']['project_release_downloads']['#prefix'] = '<h2>' . t('Downloads') . '</h2>'; $variables['content']['project_release_downloads']['#weight'] = -10; backdrop_add_css($path . '/css/project-styles.css'); } }
function commandfile_searchpaths($phase, $phase_max = FALSE) { if (!$phase_max) { $phase_max = $phase; } $searchpath = array(); switch ($phase) { case BackdropBoot::BOOTSTRAP_ROOT: $backdrop_root = drush_get_context('DRUSH_SELECTED_BACKDROP_ROOT'); $searchpath[] = $backdrop_root . '/../drush'; $searchpath[] = $backdrop_root . '/drush'; $searchpath[] = $backdrop_root . '/sites/all/drush'; // Add the drupalboot.drush.inc commandfile. // $searchpath[] = __DIR__; break; case BackdropBoot::BOOTSTRAP_SITE: // If we are going to stop bootstrapping at the site, then // we will quickly add all commandfiles that we can find for // any extension associated with the site, whether it is enabled // or not. If we are, however, going to continue on to bootstrap // all the way to DRUSH_BOOTSTRAP_DRUPAL_FULL, then we will // instead wait for that phase, which will more carefully add // only those Drush commandfiles that are associated with // enabled modules. if ($phase_max < BackdropBoot::BOOTSTRAP_FULL) { $searchpath = array_merge($searchpath, $this->contrib_modules_paths()); // Adding commandfiles located within /profiles. Try to limit to one // profile for speed. Note that Backdrop allows enabling modules from // a non-active profile so this logic is kinda dodgy. $cid = $this->install_profile_cid(); if ($cached = drush_cache_get($cid)) { $profile = $cached->data; $searchpath[] = "profiles/{$profile}/modules"; $searchpath[] = "profiles/{$profile}/themes"; } else { // If install_profile is not available, scan all profiles. $searchpath[] = "profiles"; $searchpath[] = "sites/all/profiles"; } $searchpath = array_merge($searchpath, $this->contrib_themes_paths()); } break; case BackdropBoot::BOOTSTRAP_CONFIGURATION: // Nothing to do here anymore. Left for documentation. break; case BackdropBoot::BOOTSTRAP_FULL: // Add enabled module paths, excluding the install profile. Since we are // bootstrapped we can use the Backdrop API. $ignored_modules = drush_get_option_list('ignored-modules', array()); $cid = $this->install_profile_cid(); if ($cached = drush_cache_get($cid)) { $ignored_modules[] = $cached->data; } foreach (array_diff($this->module_list(), $ignored_modules) as $module) { $filepath = backdrop_get_path('module', $module); if ($filepath && $filepath != '/') { $searchpath[] = $filepath; } } $searchpath[] = backdrop_get_path('theme', config_get('system.core', 'theme_default')); $searchpath[] = backdrop_get_path('theme', config_get('system.core', 'theme_admin')); break; } return $searchpath; }
/** * Implements hook_preprocess_maintenance_page(). */ function afterlight_tribute_preprocess_maintenance_page(&$variables) { backdrop_add_css(backdrop_get_path('theme', 'bartik') . '/css/maintenance-page.css'); }
<?php /** * @file * Theme the button for the date component date popup. */ ?> <input type="image" src="<?php print base_path() . backdrop_get_path('module', 'webform') . '/images/calendar.png'; ?> " class="<?php print implode(' ', $calendar_classes); ?> " alt="<?php print t('Open popup calendar'); ?> " title="<?php print t('Open popup calendar'); ?> " />
/** * Modify the list of CSS files that will be added to a CKEditor instance. * * Modules may use this hook to provide their own custom CSS file without * providing a CKEditor plugin. This list of CSS files is only used in the * iframe versions of CKEditor. * * Note that because this hook is only called for modules and the active theme, * front-end themes will not be able to use this hook to add their own CSS files * if a different admin theme is active. Instead, front-end themes and base * themes may specify CSS files to be used in iframe instances of CKEditor * through an entry in their .info file: * * @code * ckeditor_stylesheets[] = css/ckeditor-iframe.css * @endcode * * @param $css * An array of CSS files, passed by reference. This is a flat list of file * paths relative to the Backdrop root. * @param $format * The corresponding text format object as returned by filter_format_load() * for which the current text editor is being displayed. * * @see _ckeditor_theme_css() */ function hook_ckeditor_css_alter(array &$css, $format) { $css[] = backdrop_get_path('module', 'mymodule') . '/css/mymodule-ckeditor.css'; }
/** * Alter any of the styles registered with Responsive Menus. * * This is a very powerful hook that can allow you to: * -Bypass a library's requirements. * --e.g. Remove a style's requirement on jquery_update or libraries module. * -Provide your own libraries or files. * -Include additional files to load with a style. * -Use a different form function for a style's settings. * -Use a different function for building javascript settings. * * @param array $styles * Array of all the currently known styles. * Options: * name: string - Style's name. * form: string - Function name to return Backdrop FAPI array. * js_files: array - Array of paths to JS files to load for this style. * css_files: array - Array of paths to CSS files to load for this style. * js_settings: string - Function name to build JS settings passed to backdrop_add_js(). * jquery_version: float - Minimum required jQuery version for this style. * -- Note: This setting will require jquery_update module enabled unless the * -- user checks "I will provide my own jQuery Library". * use_libraries: boolean - TRUE / FALSE to use the Libraries module. * library: string - Name of the library, used for Libraries module. * selector: string - Text for the admin page describing which selector to use. * file: string - Optional file with the form & js_settings callback functions. * * Other notes: * If you want to bypass the requirement on the Libraries module for a style, * you can set 'use_libraries' => FALSE, and then use js_files & css_files to * provide the path(s) to the files. * * See the 2 examples below. * First, showing all the available options. Note including js_files, css_files * AND specifying use_libraries => TRUE would result in the Libraries module * first trying to load the library, then Responsive Menus would backdrop_add_[type] * the files in js_files & css_files settings. * * Second example is showing how to override the sidr style to lift Libraries * module requirement to include your own files. * */ function hook_responsive_menus_styles_alter(&$styles) { // Example showing all of the currently available fields. // Note, js_folder & css_folder are excluded until an alternative to glob() is // built into RM. $path = backdrop_get_path('module', 'my_style_module') . '/styles'; $styles['my_style'] = array('name' => t('My Style'), 'form' => 'responsive_menus_my_style_settings', 'js_files' => array($path . '/my_style/my_style.js', $path . '/my_style/my_other_style.js'), 'css_files' => array($path . '/my_style/my_style.css'), 'js_settings' => 'responsive_menus_my_style_js_settings', 'jquery_version' => 1.7, 'use_libraries' => TRUE, 'library' => 'my_style', 'selector' => t('Text describing what selector to use. e.g. ul'), 'file' => $path . '/my_style/my_style.inc'); // In this next example, I will override the Sidr style to bypass the Libraries // module and provide my own files in my_module/responsive_menus_alter/sidr/. $path = backdrop_get_path('module', 'my_module') . '/responsive_menus_alter'; $styles['sidr'] = array('use_libraries' => FALSE, 'js_files' => array($path . '/sidr/my_sidr.js'), 'css_files' => array($path . '/sidr/my_sidr.css')); }
/** * Define language negotiation providers. * * @return * An associative array of language negotiation provider definitions. The keys * are provider identifiers, and the values are associative arrays defining * each provider, with the following elements: * - types: An array of allowed language types. If a language negotiation * provider does not specify which language types it should be used with, it * will be available for all the configurable language types. * - callbacks: An associative array of functions that will be called to * perform various tasks. Possible elements are: * - language: (required) Name of the callback function that determines the * language value. * - switcher: (optional) Name of the callback function that determines * links for a language switcher block associated with this provider. See * language_switcher_url() for an example. * - url_rewrite: (optional) Name of the callback function that provides URL * rewriting, if needed by this provider. * - file: The file where callback functions are defined (this file will be * included before the callbacks are invoked). * - weight: The default weight of the provider. * - name: The translated human-readable name for the provider. * - description: A translated longer description of the provider. * - config: An internal path pointing to the provider's configuration page. * - cache: The value Backdrop's page cache should be set to for the current * provider to be invoked. * * @see hook_language_negotiation_info_alter() * @ingroup language_negotiation */ function hook_language_negotiation_info() { return array('custom_language_provider' => array('callbacks' => array('language' => 'custom_language_provider_callback', 'switcher' => 'custom_language_switcher_callback', 'url_rewrite' => 'custom_language_url_rewrite_callback'), 'file' => backdrop_get_path('module', 'custom') . '/custom.module', 'weight' => -4, 'types' => array('custom_language_type'), 'name' => t('Custom language negotiation provider'), 'description' => t('This is a custom language negotiation provider.'), 'cache' => 0)); }
/** * Print the skin (CSS) * * @return boolean * @access private * @static */ private static function _css() { static $_css = false; // already set ? // if ($_css) { return true; } $css = ''; // DEVEL: changed for Drupal variables system $skin = config_get('devel.settings', 'krumo_skin'); // custom selected skin ? // $_ = KRUMO_DIR . "skins/{$skin}/skin.css"; if ($fp = @fopen($_, 'r', 1)) { $css = fread($fp, filesize($_)); fclose($fp); } // defautl skin ? // if (!$css && $skin != 'default') { $skin = 'default'; $_ = KRUMO_DIR . "skins/default/skin.css"; $css = join('', @file($_)); } // print ? // if ($_css = $css != '') { // fix the urls // // DEVEL: changed for Drupal path system. $css_url = file_create_url(backdrop_get_path('module', 'devel') . "/lib/krumo/skins/{$skin}/"); $css = preg_replace('~%url%~Uis', $css_url, $css); // the CSS // ?> <!-- Using Krumo Skin: <?php echo preg_replace('~^' . preg_quote(realpath(KRUMO_DIR) . DIRECTORY_SEPARATOR) . '~Uis', '', realpath($_)); ?> --> <style type="text/css"> <!--/**/ <?php echo $css; ?> /**/--> </style> <?php // the JS // ?> <script type="text/javascript"> <!--// <?php echo join(file(KRUMO_DIR . "krumo.js")); ?> //--> </script> <?php } return $_css; }
function teamwork_15_subtheme_css_alter(&$css) { $css_to_remove = array(); if (theme_get_setting('teamwork_15_subtheme_cdn') > 0) { $css_to_remove[] = backdrop_get_path('theme', 'teamwork_15') . '/css/pure.min.css'; } if (theme_get_setting('teamwork_15_subtheme_sass') > 0) { $css_to_remove[] = backdrop_get_path('theme', 'teamwork_15') . '/css/style.css'; $css_to_remove[] = backdrop_get_path('theme', 'teamwork_15') . '/css/pure.min.css'; } foreach ($css_to_remove as $index => $css_file) { unset($css[$css_file]); } }
/** * Prepare variables for node template */ function borg_preprocess_node(&$variables) { $path = backdrop_get_path('theme', 'borg'); if (substr($variables['type'], 0, 8) == 'project_') { $variables['content']['project_release_downloads']['#prefix'] = '<h2>' . t('Downloads') . '</h2>'; $variables['content']['project_release_downloads']['#weight'] = -10; backdrop_add_css($path . '/css/project-styles.css'); } }
/** * Return additional themes provided by modules. * * Only use this hook for testing purposes. Use a hidden MYMODULE_test.module * to implement this hook. Testing themes should be hidden, too. * * This hook is invoked from _system_rebuild_theme_data() and allows modules to * register additional themes outside of the regular 'themes' directories of a * Backdrop installation. * * @return * An associative array. Each key is the system name of a theme and each value * is the corresponding path to the theme's .info file. */ function hook_system_theme_info() { $themes['mymodule_test_theme'] = backdrop_get_path('module', 'mymodule') . '/mymodule_test_theme/mymodule_test_theme.info'; return $themes; }
/** * Implements hook_css_alter(). */ function seven_css_alter(&$css) { // Use Seven's vertical tabs style instead of the default one. if (isset($css['core/misc/vertical-tabs.css'])) { $css['core/misc/vertical-tabs.css']['data'] = backdrop_get_path('theme', 'seven') . '/css/vertical-tabs.css'; $css['core/misc/vertical-tabs.css']['type'] = 'file'; } // Use Seven's jQuery UI theme style instead of the default one. if (isset($css['core/misc/ui/jquery.ui.theme.css'])) { $css['core/misc/ui/jquery.ui.theme.css']['data'] = backdrop_get_path('theme', 'seven') . '/css/jquery.ui.theme.css'; $css['core/misc/ui/jquery.ui.theme.css']['type'] = 'file'; $css['core/misc/ui/jquery.ui.theme.css']['weight'] = 10; } }
/** * Get a list files that can be used in tests. * * @param $type * File type, possible values: 'binary', 'html', 'image', 'javascript', 'php', 'sql', 'text'. * @param $size * File size in bytes to match. Please check the tests/files folder. * @return * List of files that match filter. */ protected function backdropGetTestFiles($type, $size = NULL) { if (empty($this->generatedTestFiles)) { // Generate binary test files. $lines = array(64, 1024); $count = 0; foreach ($lines as $line) { simpletest_generate_file('binary-' . $count++, 64, $line, 'binary'); } // Generate text test files. $lines = array(16, 256, 1024, 2048, 20480); $count = 0; foreach ($lines as $line) { simpletest_generate_file('text-' . $count++, 64, $line); } // Copy other test files from simpletest. $original = backdrop_get_path('module', 'simpletest') . '/files'; $files = file_scan_directory($original, '/(html|image|javascript|php|sql)-.*/'); foreach ($files as $file) { file_unmanaged_copy($file->uri, config_get('system.core', 'file_public_path')); } $this->generatedTestFiles = TRUE; } $files = array(); // Make sure type is valid. if (in_array($type, array('binary', 'html', 'image', 'javascript', 'php', 'sql', 'text'))) { $files = file_scan_directory('public://', '/' . $type . '\\-.*/'); // If size is set then remove any files that are not of that size. if ($size !== NULL) { foreach ($files as $file) { $stats = stat($file->uri); if ($stats['size'] != $size) { unset($files[$file->uri]); } } } } usort($files, array($this, 'backdropCompareFiles')); return $files; }
/** * Module specific instance of hook_theme(). * * This allows each Webform component to add information into hook_theme(). If * you specify a file to include, you must define the path to the module that * this file belongs to. */ function _webform_theme_component() { return array('webform_grid' => array('render element' => 'element', 'file' => 'components/grid.inc', 'path' => backdrop_get_path('module', 'webform')), 'webform_display_grid' => array('render element' => 'element', 'file' => 'components/grid.inc', 'path' => backdrop_get_path('module', 'webform'))); }