本文整理汇总了PHP中variable_get函数的典型用法代码示例。如果您正苦于以下问题:PHP variable_get函数的具体用法?PHP variable_get怎么用?PHP variable_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了variable_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mooc_foundation_access_preprocess_page
/**
* Implements template_preprocess_page.
*/
function mooc_foundation_access_preprocess_page(&$variables)
{
// speedreader is enabled
if (module_exists('speedreader')) {
$variables['speedreader'] = TRUE;
}
// mespeak is enabled
if (module_exists('mespeak')) {
$variables['mespeak'] = TRUE;
}
// support for add child page shortcut
$node = menu_get_object();
if ($node && user_access('access printer-friendly version')) {
$variables['tabs_extras'][200][] = '<hr>';
$variables['tabs_extras'][200][] = l(t('Print'), 'book/export/html/' . arg(1));
}
$child_type = variable_get('book_child_type', 'book');
if ($node && !empty($node->book) && (user_access('add content to books') || user_access('administer book outlines')) && node_access('create', $child_type) && $node->status == 1 && isset($node->book['depth']) && $node->book['depth'] < MENU_MAX_DEPTH) {
$variables['tabs_extras'][200][] = '<hr>';
$variables['tabs_extras'][200][] = l(t('Add child page'), 'node/add/' . str_replace('_', '-', $child_type), array('query' => array('parent' => $node->book['mlid'])));
}
if (user_access('access contextual links')) {
$variables['tabs_extras'][0][] = '<li class="cis_accessibility_check"></li>';
}
}
示例2: hook_twitter_accounts
/**
* Retrieves what Twitter accounts the given user can post to.
*/
function hook_twitter_accounts($drupal_user, $full_access = FALSE) {
$accounts = array();
if (user_access('use global twitter account') &&
($name = variable_get('twitter_global_name', NULL)) &&
($pass = variable_get('twitter_global_password', NULL))) {
$accounts[$name] = array(
'screen_name' => $name,
'password' => $pass,
);
}
$sql = " SELECT ta.*, tu.uid, tu.password, tu.import FROM {twitter_user} tu ";
$sql .= "LEFT JOIN {twitter_account} ta ON (tu.screen_name = ta.screen_name) ";
$sql .= "WHERE tu.uid = %d";
if ($full_access) {
$sql .= " AND tu.password IS NOT NULL";
}
$args = array($drupal_user->uid);
$results = db_query($sql, $args);
while ($account = db_fetch_array($results)) {
$accounts[$account['screen_name']] = $account;
}
return $accounts;
}
示例3: odsherredweb_preprocess_page
/**
* implements hook_preprocess_page()
*
**/
function odsherredweb_preprocess_page(&$variables)
{
$current_theme = variable_get('theme_default', 'none');
// Search form
$variables['simple_navigation_search'] = module_invoke('search', 'block_view', 'search');
// Navigation
$variables['sidebar_borger'] = _bellcom_generate_menu('menu-indhold', 'sidebar');
$variables['sidebar_erhverv'] = _bellcom_generate_menu('menu-erhverv', 'sidebar');
$variables['sidebar_politik'] = _bellcom_generate_menu('menu-politik', 'sidebar');
// Add the site structure term id to the page div
$node = node_load(arg(1));
if (is_object($node) && isset($node->field_os2web_spotbox_sitestruct)) {
$termParents = taxonomy_get_parents($node->field_os2web_spotbox_sitestruct[LANGUAGE_NONE][0]['tid']);
$termId = 'tid-' . $node->field_os2web_spotbox_sitestruct[LANGUAGE_NONE][0]['tid'];
$termIdParent = "";
if (!empty($termParents)) {
$termIdParent = 'tid-' . key($termParents);
}
$variables['attributes_array']['class'] = $termIdParent . ' ' . $termId;
}
// Paths
$variables['path_js'] = base_path() . drupal_get_path('theme', $current_theme) . '/js';
$variables['path_img'] = base_path() . drupal_get_path('theme', $current_theme) . '/images';
$variables['path_css'] = base_path() . drupal_get_path('theme', $current_theme) . '/css';
$variables['path_font'] = base_path() . drupal_get_path('theme', $current_theme) . '/font';
}
示例4: fusion_core_initialize_theme_settings
/**
* Initialize theme settings if needed
*/
function fusion_core_initialize_theme_settings($theme_name)
{
$theme_settings = theme_get_settings($theme_name);
if (is_null($theme_settings['theme_font_size']) || $theme_settings['rebuild_registry'] == 1) {
// Rebuild theme registry & notify user
if ($theme_settings['rebuild_registry'] == 1) {
drupal_rebuild_theme_registry();
drupal_set_message(t('Theme registry rebuild completed. <a href="!link">Turn off</a> this feature for production websites.', array('!link' => url('admin/build/themes/settings/' . $GLOBALS['theme']))), 'warning');
}
// Retrieve saved or site-wide theme settings
$theme_setting_name = str_replace('/', '_', 'theme_' . $theme_name . '_settings');
$settings = variable_get($theme_setting_name, FALSE) ? theme_get_settings($theme_name) : theme_get_settings();
// Skip toggle_node_info_ settings
if (module_exists('node')) {
foreach (node_get_types() as $type => $name) {
unset($settings['toggle_node_info_' . $type]);
}
}
// Retrieve default theme settings
$defaults = fusion_core_default_theme_settings();
// Set combined default & saved theme settings
variable_set($theme_setting_name, array_merge($defaults, $settings));
// Force theme settings refresh
theme_get_setting('', TRUE);
}
}
示例5: moveUploadedFile
/**
* Helper function that moves an uploaded file.
*
* @param string $filename
* The path of the file to move.
* @param string $uri
* The path where to move the file.
*
* @return bool
* TRUE if the file was moved. FALSE otherwise.
*/
protected static function moveUploadedFile($filename, $uri)
{
if (drupal_move_uploaded_file($filename, $uri)) {
return TRUE;
}
return variable_get('restful_insecure_uploaded_flag', FALSE) && (bool) file_unmanaged_move($filename, $uri);
}
示例6: strip_dangerous_protocols
function strip_dangerous_protocols($uri)
{
static $allowed_protocols;
if (!isset($allowed_protocols)) {
$allowed_protocols = array_flip(variable_get('filter_allowed_protocols', array('ftp', 'http', 'https', 'irc', 'mailto', 'news', 'nntp', 'rtsp', 'sftp', 'ssh', 'tel', 'telnet', 'webcal')));
}
// Iteratively remove any invalid protocol found.
do {
$before = $uri;
$colonpos = strpos($uri, ':');
if ($colonpos > 0) {
// We found a colon, possibly a protocol. Verify.
$protocol = substr($uri, 0, $colonpos);
// If a colon is preceded by a slash, question mark or hash, it cannot
// possibly be part of the URL scheme. This must be a relative URL, which
// inherits the (safe) protocol of the base document.
if (preg_match('![/?#]!', $protocol)) {
break;
}
// Check if this is a disallowed protocol. Per RFC2616, section 3.2.3
// (URI Comparison) scheme comparison must be case-insensitive.
if (!isset($allowed_protocols[strtolower($protocol)])) {
$uri = substr($uri, $colonpos + 1);
}
}
} while ($before != $uri);
return $uri;
}
示例7: deco_preprocess_page
function deco_preprocess_page(&$vars)
{
$vars['sidebar_triple'] = FALSE;
if (!empty($vars['page']['sidebar_second']) && !empty($vars['page']['sidebar_right_sec']) && !empty($vars['page']['sidebar_first'])) {
$vars['classes_array'][] .= ' sidebar-triple';
$vars['sidebar_triple'] = TRUE;
}
if (!empty($vars['page']['sidebar_right_sec']) && empty($vars['page']['sidebar_second'])) {
$vars['page']['sidebar_second'] = $vars['page']['sidebar_right_sec'];
$vars['page']['sidebar_right_sec'] = '';
}
// set variables for the logo and slogan
$site_fields = array();
if ($vars['site_name']) {
$site_fields[] = check_plain($vars['site_name']);
}
if ($vars['site_slogan']) {
$site_fields[] = '- ' . check_plain($vars['site_slogan']);
}
$vars['site_title'] = implode(' ', $site_fields);
if (isset($site_fields[0])) {
$site_fields[0] = '<span class="site-name">' . $site_fields[0] . '</span>';
}
if (isset($site_fields[1])) {
$site_fields[1] = '<span class="site-slogan">' . $site_fields[1] . '</span>';
}
$vars['site_title_html'] = implode(' ', $site_fields);
$vars['primary_menu'] = str_replace('class="menu"', 'class="links primary-links"', render(menu_tree(variable_get('menu_main_links_source', 'main-menu'))));
$vars['secondary_menu'] = str_replace('class="menu"', 'class="links secondary-links"', render(menu_tree(variable_get('menu_secondary_links_source', 'secondary-menu'))));
}
示例8: garland_preprocess_page
/**
* Override or insert variables into the page template.
*/
function garland_preprocess_page(&$vars)
{
$vars['tabs2'] = menu_secondary_local_tasks();
if (isset($vars['main_menu'])) {
$vars['primary_nav'] = theme('links__system_main_menu', array('links' => $vars['main_menu'], 'attributes' => array('class' => array('links', 'main-menu')), 'heading' => array('text' => t('Main menu'), 'level' => 'h2', 'class' => array('element-invisible'))));
} else {
$vars['primary_nav'] = FALSE;
}
if (isset($vars['secondary_menu'])) {
$vars['secondary_nav'] = theme('links__system_secondary_menu', array('links' => $vars['secondary_menu'], 'attributes' => array('class' => array('links', 'secondary-menu')), 'heading' => array('text' => t('Secondary menu'), 'level' => 'h2', 'class' => array('element-invisible'))));
} else {
$vars['secondary_nav'] = FALSE;
}
// Prepare header.
$site_fields = array();
if (!empty($vars['site_name'])) {
$site_fields[] = check_plain($vars['site_name']);
}
if (!empty($vars['site_slogan'])) {
$site_fields[] = check_plain($vars['site_slogan']);
}
$vars['site_title'] = implode(' ', $site_fields);
if (!empty($site_fields)) {
$site_fields[0] = '<span>' . $site_fields[0] . '</span>';
}
$vars['site_html'] = implode(' ', $site_fields);
// Set a variable for the site name title and logo alt attributes text.
$slogan_text = filter_xss_admin(variable_get('site_slogan', ''));
$site_name_text = filter_xss_admin(variable_get('site_name', 'Drupal'));
$vars['site_name_and_slogan'] = $site_name_text . ' ' . $slogan_text;
}
示例9: local_storage_admin_form
/**
* Form callback for "admin/config/administration/local_storage".
*/
function local_storage_admin_form($form, &$form_state)
{
$form['local_storage_enable'] = array('#type' => 'checkbox', '#title' => t('Enable Local Storage'), '#description' => t('Enable automatic storing of entered data for all new fields by default.'), '#default_value' => variable_get('local_storage_enable', 0));
$form['local_storage_default'] = array('#type' => 'checkbox', '#title' => t('Show default (original) value by default'), '#description' => t('Show default (original) value by default for all new fields by default.'), '#default_value' => variable_get('local_storage_default', 0));
$form['local_storage_expire'] = array('#type' => 'select', '#options' => drupal_map_assoc(range(1, 48)), '#title' => t('Expiration time'), '#description' => t('Set default expiration time for stored data (in hours).'), '#default_value' => variable_get('local_storage_expire', 48));
return system_settings_form($form);
}
示例10: cac_preprocess_node
/**
* @file
* Template overrides as well as (pre-)process and alter hooks for the
* cac theme.
*/
function cac_preprocess_node(&$vars)
{
if (variable_get('node_submitted_' . $vars['node']->type, TRUE)) {
$date = format_date($vars['node']->created, 'date_type');
$vars['submitted'] = t('Submitted by !username on !datetime', array('!username' => 'editor', '!datetime' => $date));
}
}
示例11: razorDrupal_process_page
function razorDrupal_process_page(&$variables)
{
// Hook into color.module.
if (module_exists('color')) {
_color_page_alter($variables);
}
// Always print the site name and slogan, but if they are toggled off, we'll
// just hide them visually.
$variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
$variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
if ($variables['hide_site_name']) {
// If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
$variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
}
if ($variables['hide_site_slogan']) {
// If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
$variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
}
// Since the title and the shortcut link are both block level elements,
// positioning them next to each other is much simpler with a wrapper div.
if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
// Add a wrapper div using the title_prefix and title_suffix render elements.
$variables['title_prefix']['shortcut_wrapper'] = array('#markup' => '<div class="shortcut-wrapper clearfix">', '#weight' => 100);
$variables['title_suffix']['shortcut_wrapper'] = array('#markup' => '</div>', '#weight' => -99);
// Make sure the shortcut link is the first item in title_suffix.
$variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
}
}
示例12: bootstrap_status_messages
/**
* Returns HTML for status and/or error messages, grouped by type.
*
* An invisible heading identifies the messages for assistive technology.
* Sighted users see a colored box. See http://www.w3.org/TR/WCAG-TECHS/H69.html
* for info.
*
* @param array $variables
* An associative array containing:
* - display: (optional) Set to 'status' or 'error' to display only messages
* of that type.
*
* @return string
* The constructed HTML.
*
* @see theme_status_messages()
*
* @ingroup theme_functions
*/
function bootstrap_status_messages($variables)
{
$display = $variables['display'];
$output = '';
$status_heading = array('status' => t('Status message'), 'error' => t('Error message'), 'warning' => t('Warning message'), 'info' => t('Informative message'));
// Map Drupal message types to their corresponding Bootstrap classes.
// @see http://twitter.github.com/bootstrap/components.html#alerts
$status_class = array('status' => 'success', 'error' => 'danger', 'warning' => 'warning', 'info' => 'info');
// Retrieve messages.
$message_list = drupal_get_messages($display);
// Allow the disabled_messages module to filter the messages, if enabled.
if (module_exists('disable_messages') && variable_get('disable_messages_enable', '1')) {
$message_list = disable_messages_apply_filters($message_list);
}
foreach ($message_list as $type => $messages) {
$class = isset($status_class[$type]) ? ' alert-' . $status_class[$type] : '';
$output .= "<div class=\"alert alert-block{$class} messages {$type}\">\n";
$output .= " <a class=\"close\" data-dismiss=\"alert\" href=\"#\">×</a>\n";
if (!empty($status_heading[$type])) {
$output .= '<h4 class="element-invisible">' . $status_heading[$type] . "</h4>\n";
}
if (count($messages) > 1) {
$output .= " <ul>\n";
foreach ($messages as $message) {
$output .= ' <li>' . $message . "</li>\n";
}
$output .= " </ul>\n";
} else {
$output .= $messages[0];
}
$output .= "</div>\n";
}
return $output;
}
示例13: __construct
public function __construct()
{
parent::__construct();
// Map fields that don't need extra definitions.
$field_names = array('id', 'weekday', 'hour_from', 'hour_to', 'cap');
$this->addSimpleMappings($field_names);
$this->addFieldMapping('meter_nid', 'meter_nid')->sourceMigration(array('NegawattIecMeterMigrate', 'NegawattModbusMeterMigrate'));
$this->description = t('Import @type - from CSV file.', array('@type' => $this->entityType));
// Create a map object for tracking the relationships between source rows
$key = array('id' => array('type' => 'int', 'not null' => TRUE));
$destination_handler = new MigrateDestinationEntityAPI($this->entityType, $this->bundle);
$this->map = new MigrateSQLMap($this->machineName, $key, $destination_handler->getKeySchema($this->entityType));
// Create a MigrateSource object.
$sql_migrate = variable_get('negawatt_migrate_sql', FALSE);
if ($sql_migrate) {
// SQL migration.
$query = db_select('_negawatt_power_cap_analyzer_info_migrate', $this->bundle)->fields($this->bundle, $field_names);
$this->source = new MigrateSourceSQL($query);
} else {
// CSV migration.
// Allow using variable to set path other than default.
$csv_path = variable_get('negawatt_migrate_csv_path', drupal_get_path('module', 'negawatt_migrate') . '/csv');
$this->source = new MigrateSourceCSV($csv_path . '/normalizer/' . $this->entityType . '.csv', $this->csvColumns, array('header_rows' => 1));
}
$this->destination = new MigrateDestinationEntityAPI($this->entityType, $this->bundle);
}
示例14: quickdrupal_username
/**
* Override theme_username() function.
* Removes the text '(not verified)' for anonymous users.
*/
function quickdrupal_username($object)
{
if ($object->uid && $object->name) {
if (drupal_strlen($object->name) > 20) {
$name = drupal_substr($object->name, 0, 15) . '...';
} else {
$name = $object->name;
}
if (user_access('access user profiles')) {
$output = l($name, 'user/' . $object->uid, array('attributes' => array('title' => t('View user profile.'))));
} else {
$output = check_plain($name);
}
} else {
if ($object->name) {
if (!empty($object->homepage)) {
$output = l($object->name, $object->homepage, array('attributes' => array('rel' => 'nofollow')));
} else {
$output = check_plain($object->name);
}
} else {
$output = check_plain(variable_get('anonymous', t('Anonymous')));
}
}
return $output;
}
示例15: arthemia_primary
/**
* Return a full tree of the expanded menu. Thank you multiflex-3 for this code!
*/
function arthemia_primary()
{
$output = '<div id="page-bar">';
$output .= menu_tree(variable_get('menu_primary_links_source', 'primary-links'));
$output .= '</div>';
return $output;
}