Example #1
0
/**
 * 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>';
    }
}
Example #2
0
/**
 * 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;
}
Example #3
0
/**
 * 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';
}
Example #4
0
/**
 * 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);
    }
}
 /**
  * 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);
 }
Example #6
0
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;
}
Example #7
0
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'))));
}
Example #8
0
/**
 * 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;
}
/**
 * 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);
}
Example #10
0
/**
 * @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));
    }
}
Example #11
0
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;
    }
}
Example #12
0
/**
 * 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=\"#\">&times;</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;
}
 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);
 }
Example #14
0
/**
 * 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;
}
Example #15
0
/**
 * 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;
}
 protected function sendRequest($identifiers)
 {
     $ids = array();
     foreach ($identifiers as $i) {
         $ids = array_merge($ids, array_values($i));
     }
     $authInfo = array('authenticationUser' => $this->username, 'authenticationGroup' => $this->group, 'authenticationPassword' => $this->password);
     if (preg_match('/moreinfo.addi.dk/', $this->wsdlUrl)) {
         // New moreinfo service.
         $client = new SoapClient($this->wsdlUrl . '/moreinfo.wsdl');
         $method = 'moreInfo';
     } else {
         // Legacy additionalInformation service.
         $client = new SoapClient($this->wsdlUrl);
         $method = 'additionalInformation';
     }
     $startTime = explode(' ', microtime());
     $response = $client->{$method}(array('authentication' => $authInfo, 'identifier' => $identifiers));
     $stopTime = explode(' ', microtime());
     $time = floatval($stopTime[1] + $stopTime[0] - ($startTime[1] + $startTime[0]));
     //Drupal specific code - consider moving this elsewhere
     if (variable_get('addi_enable_logging', false)) {
         watchdog('addi', 'Completed request (' . round($time, 3) . 's): Ids: %ids', array('%ids' => implode(', ', $ids)), WATCHDOG_DEBUG, 'http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
     }
     if ($response->requestStatus->statusEnum != 'ok') {
         throw new AdditionalInformationServiceException($response->requestStatus->statusEnum . ': ' . $response->requestStatus->errorText);
     }
     if (!is_array($response->identifierInformation)) {
         $response->identifierInformation = array($response->identifierInformation);
     }
     return $response;
 }
/**
 * Configuration form for the mongodb_block_ui.
 *
 * @param string $delta
 *   Which mongodb_block_ui to return. This is a descriptive string used to
 *   identify mongodb_block_uis within each module and also within the theme
 *   system.
 *   The $delta for each mongodb_block_ui is defined within the array that your
 *   module returns when the hook_mongodb_block_ui_info() implementation is
 *   called.
 *
 * @return array
 *   Optionally return the configuration form.
 *
 * For a detailed usage example, see mongodb_block_ui_example.module.
 */
function hook_mongodb_block_ui_configure($delta = '')
{
    if ($delta == 'exciting') {
        $form['items'] = array('#type' => 'select', '#title' => t('Number of items'), '#default_value' => variable_get('mymodule_mongodb_block_ui_items', 0), '#options' => array('1', '2', '3'));
        return $form;
    }
}
Example #18
0
/**
 * Alter mapping targets for taxonomy terms. Use this hook to add additional
 * target options to the mapping form of Taxonomy term processor.
 *
 * For an example implementation, look at geotaxnomy module.
 * http://drupal.org/project/geotaxonomy
 *
 * @param &$targets
 *   Array containing the targets to be offered to the user. Add to this array
 *   to expose additional options. Remove from this array to suppress options.
 *   Remove with caution.
 * @param $vid
 *   The vocabulary id
 */
function hook_feeds_term_processor_targets_alter(&$targets, $vid)
{
    if (variable_get('mymodule_vocabulary_' . $vid, 0)) {
        $targets['lat'] = array('name' => t('Latitude'), 'description' => t('Latitude of the term.'));
        $targets['lon'] = array('name' => t('Longitude'), 'description' => t('Longitude of the term.'));
    }
}
Example #19
0
function get_url($url)
{
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
    //curl_setopt($ch,CURLOPT_HTTPPROXYTUNNEL, 1);
    $proxy_internet = variable_get('proxy_internet', null);
    $proxy_internet_userpwd = variable_get('proxy_internet_userpwd', null);
    if ($proxy_internet != null && $proxy_internet_userpwd != null) {
        curl_setopt($ch, CURLOPT_PROXY, $proxy_internet);
        curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_internet_userpwd);
    }
    $content = curl_exec($ch);
    /*On a une erreur alors on la lève*/
    if ($content === false) {
        trigger_error('Erreur curl : ' . curl_error($ch) . "--url--" . $url, E_USER_WARNING);
    }
    /*Si tout c'est bien passé on affiche le contenu de la requête*/
    /*On ferme la ressource*/
    curl_close($ch);
    return $content;
}
Example #20
0
/**
 * Respond to a custom menu deletion.
 *
 * This hook is used to notify modules that a custom menu along with all links
 * contained in it (if any) has been deleted. Contributed modules may use the
 * information to perform actions based on the information entered into the menu
 * system.
 *
 * @param $menu
 *   An array representing a custom menu:
 *   - menu_name: The unique name of the custom menu.
 *   - title: The human readable menu title.
 *   - description: The custom menu description.
 *
 * @see hook_menu_insert()
 * @see hook_menu_update()
 */
function hook_menu_delete($menu)
{
    // Delete the record from our variable.
    $my_menus = variable_get('my_module_menus', array());
    unset($my_menus[$menu['menu_name']]);
    variable_set('my_module_menus', $my_menus);
}
/**
 * Initialize theme settings if needed
 */
function fusion_core_initialize_theme_settings($theme_name)
{
    $theme_settings = theme_get_settings($theme_name);
    if (!isset($theme_settings['primary_menu_dropdown']) || $theme_settings['rebuild_registry'] == 1) {
        static $registry_rebuilt = false;
        // avoid multiple rebuilds per page
        // Rebuild theme registry & notify user
        if (isset($theme_settings['rebuild_registry']) && $theme_settings['rebuild_registry'] == 1 && !$registry_rebuilt) {
            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');
            $registry_rebuilt = true;
        }
        // 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]);
            }
        }
        // Combine default theme settings from .info file & theme-settings.php
        $theme_data = list_themes();
        // get theme data for all themes
        $info_theme_settings = $theme_name ? $theme_data[$theme_name]->info['settings'] : array();
        $defaults = array_merge(fusion_core_default_theme_settings(), $info_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);
    }
}
Example #22
0
 function process()
 {
     global $dbh;
     $data = array('Order ID');
     foreach ($this->formbuilder->_questions as $question) {
         $data[] = $question->qkey;
     }
     if (empty($data)) {
         error_exit('No survey details available for download.');
     }
     header('Content-type: text/x-csv');
     header("Content-Disposition: attachment; filename=\"{$this->event->name}_survey.csv\"");
     $out = fopen('php://output', 'w');
     fputcsv($out, $data);
     $sth = $dbh->prepare('SELECT order_id FROM registrations r WHERE r.registration_id = ?  ORDER BY order_id');
     $sth->execute(array($this->event->registration_id));
     while ($row = $sth->fetch()) {
         $data = array(sprintf(variable_get('order_id_format', '%d'), $row['order_id']));
         // Add all of the answers
         $fsth = $dbh->prepare('SELECT akey FROM registration_answers WHERE order_id = ?  AND qkey = ?');
         foreach ($this->formbuilder->_questions as $question) {
             $fsth->execute(array($row['order_id'], $question->qkey));
             $foo = $fsth->fetchColumn();
             $data[] = preg_replace('/\\s\\s+/', ' ', $foo);
         }
         fputcsv($out, $data);
     }
     fclose($out);
     exit;
 }
Example #23
0
/**
 * Implements theme_links() targeting the main menu topbar.
 * Override base template, which would add the class of "left",which  we don't need
 */
function qualiceutics__topbar_main_menu($variables)
{
    // We need to fetch the links ourselves because we need the entire tree.
    $links = menu_tree_output(menu_tree_all_data(variable_get('menu_main_links_source', 'main-menu')));
    $output = _zurb_foundation_links($links);
    return '<ul' . drupal_attributes($variables['attributes']) . '>' . $output . '</ul>';
}
 /**
  * Create a token for a user, and return its value.
  */
 public function getOrCreateToken()
 {
     $entity_type = $this->getEntityType();
     $account = $this->getAccount();
     // Check if there is a token that did not expire yet.
     /* @var DataProviderEntityInterface $data_provider */
     $data_provider = $this->getDataProvider();
     $query = $data_provider->EFQObject();
     $result = $query->entityCondition('entity_type', $entity_type)->entityCondition('bundle', 'access_token')->propertyCondition('uid', $account->uid)->range(0, 1)->execute();
     $token_exists = FALSE;
     if (!empty($result[$entity_type])) {
         $id = key($result[$entity_type]);
         $access_token = entity_load_single($entity_type, $id);
         $token_exists = TRUE;
         if (!empty($access_token->expire) && $access_token->expire < REQUEST_TIME) {
             if (variable_get('restful_token_auth_delete_expired_tokens', TRUE)) {
                 // Token has expired, so we can delete this token.
                 $access_token->delete();
             }
             $token_exists = FALSE;
         }
     }
     if (!$token_exists) {
         /* @var \Drupal\restful_token_auth\Entity\RestfulTokenAuthController $controller */
         $controller = entity_get_controller($this->getEntityType());
         $access_token = $controller->generateAccessToken($account->uid);
         $id = $access_token->id;
     }
     $output = $this->view($id);
     return $output;
 }
 /**
  *  method that returns the list of available rdf available to use
  */
 public function get_rdf_list($action = NULL)
 {
     //grabs the variable from the rdf set in the db
     $variable_name = 'getty_biblio_wrapper_rdf';
     $all_value = variable_get($variable_name, '');
     $rdf = array();
     //only continue if its not empty
     if (!empty($all_value)) {
         //does for each value
         foreach ($all_value as $key => $value) {
             //gets the element
             $first_element = key($value);
             switch ($action) {
                 //returns the rdf and term
                 case 'rdf_term':
                     if (!empty($value[$first_element])) {
                         $rdf[$value[$first_element]] = $first_element;
                     }
                     break;
                 default:
                     $rdf[$first_element] = $value[$first_element];
                     break;
             }
         }
     }
     return $rdf;
 }
Example #26
0
/**
 * Override or insert variables into the html template.
 * @param $vars
 *   An array of variables to pass to the theme template.
 */
function gavias_laikafood_preprocess_html(&$vars)
{
    global $theme, $base_url;
    global $parent_root;
    $skin = theme_get_setting('theme_skin');
    drupal_add_css(drupal_get_path('theme', 'gavias_laikafood') . '/css/' . ($skin ? 'skins/' . $skin . '/' : '') . 'template.css', array('group' => CSS_DEFAULT, 'type' => 'file'));
    drupal_add_css(drupal_get_path('theme', 'gavias_laikafood') . '/css/' . ($skin ? 'skins/' . $skin . '/' : '') . 'bootstrap.css', array('group' => CSS_DEFAULT, 'type' => 'file'));
    if (module_exists('gavias_themer') && theme_get_setting('frontend_panel') == '1' && user_access('gavias_customize_preview')) {
        gavias_load_fontend();
    }
    if (theme_get_setting('enable_custom_style') == 1 && trim(variable_get('gavias_profile'))) {
        drupal_add_css(drupal_get_path('theme', 'gavias_laikafood') . '/customize/save/' . variable_get('gavias_profile') . '.css', array('group' => CSS_DEFAULT, 'type' => 'file'));
    }
    $viewport = array('#type' => 'html_tag', '#tag' => 'meta', '#attributes' => array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1, maximum-scale=1'), '#weight' => 1);
    drupal_add_html_head($viewport, 'viewport');
    // Add boxed class if layout is set that way.
    if (theme_get_setting('site_layout') == 'boxed') {
        $vars['classes_array'][] = 'boxed';
    }
    if (theme_get_setting('preloader') == '1') {
        $vars['classes_array'][] = 'js-preloader';
    } else {
        $vars['classes_array'][] = 'not-preloader';
    }
}
 /**
  * Modify the url and add headers appropriate to authenticate to Acquia Search.
  *
  * @return
  *  The nonce used in the request.
  */
 protected function prepareRequest(&$url, &$options, $use_data = TRUE)
 {
     // Add a unique request ID to the URL.
     $id = uniqid();
     if (!stristr($url, '?')) {
         $url .= "?";
     } else {
         $url .= "&";
     }
     $url .= 'request_id=' . $id;
     // If we're hosted on Acquia, and have an Acquia request ID,
     // append it to the request so that we map Solr queries to Acquia search requests.
     if (isset($_ENV['HTTP_X_REQUEST_ID'])) {
         $xid = empty($_ENV['HTTP_X_REQUEST_ID']) ? '-' : $_ENV['HTTP_X_REQUEST_ID'];
         $url .= '&x-request-id=' . rawurlencode($xid);
     }
     if ($use_data && isset($options['data'])) {
         list($cookie, $nonce) = acquia_search_auth_cookie($url, $options['data'], NULL, $this->env_id);
     } else {
         list($cookie, $nonce) = acquia_search_auth_cookie($url, NULL, NULL, $this->env_id);
     }
     if (empty($cookie)) {
         throw new Exception('Invalid authentication string - subscription keys expired or missing.');
     }
     $options['headers']['Cookie'] = $cookie;
     $options['headers'] += array('User-Agent' => 'acquia_search/' . variable_get('acquia_search_version', '7.x'));
     $options['context'] = acquia_agent_stream_context_create($url, 'acquia_search');
     if (!$options['context']) {
         throw new Exception(t("Could not create stream context"));
     }
     return $nonce;
 }
/**
 * @file
 * Admin functions for simple geo
 */
function simple_geo_settings()
{
    $form = array();
    $form['position_set'] = array('#type' => 'fieldset', '#title' => t('Default position'), '#after_build' => array('simple_geo_add_form_js'));
    $form['position_set']['simple_geo_default_position'] = array('#type' => 'textfield', '#title' => t('Coordinates'), '#default_value' => variable_get('simple_geo_default_position', ''), '#prefix' => '<div class="map-placeholder"></div><div id="edit-simple-geo-position-wrapper">', '#suffix' => '</div>', '#attributes' => array('id' => 'edit-simple-geo-position'));
    $form['user_set'] = array('#type' => 'fieldset', '#title' => t('Users'));
    $form['user_set']['simple_geo_position_users'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_position_users', 1), '#title' => t('Enable user positioning'));
    $form['user_set']['simple_geo_search_address'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_search_address', 1), '#title' => t('Enable "Search for address" field'));
    $form['user_set']['simple_geo_search_address_icon'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_search_address_icon', 1), '#title' => t('Enable marker icon for search result'));
    $form['node_set'] = array('#type' => 'fieldset', '#title' => t('Node rendering'));
    $form['node_set']['simple_geo_show_map_link'] = array('#type' => 'select', '#title' => t('Show map links for nodes'), '#options' => array('always' => t('Always'), 'teaser' => t('In teaser'), 'full' => t('When viewing full node'), 'never' => t('Never')), '#default_value' => variable_get('simple_geo_show_map_link', 'always'));
    $form['node_set']['simple_geo_add_microformat_tag'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_add_microformat_tag', 1), '#title' => t('Show microformat tag for node positions'));
    $form['micromap_set'] = array('#type' => 'fieldset', '#title' => t('Micromap'));
    $form['micromap_set']['simple_geo_use_microformat_map'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_use_microformat_map', 1), '#title' => t('Use map to display microformat positions'));
    $form['micromap_set']['simple_geo_micromap_parent'] = array('#type' => 'textfield', '#default_value' => variable_get('simple_geo_micromap_parent', '#main-inner'), '#title' => t('Parent element'), '#description' => t('The jQuery expression that should be used to find the micromap parent'));
    $form['micromap_set']['simple_geo_use_microformat_map'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_use_microformat_map', 1), '#title' => t('Use map to display microformat positions'));
    $form['micromap_set']['simple_geo_micromap_add_mode'] = array('#type' => 'select', '#title' => t('Add method'), '#options' => array('prepend' => t('Prepend'), 'append' => t('Append')), '#default_value' => variable_get('simple_geo_micromap_add_mode', 'prepend'));
    $form['micromap_set']['simple_geo_geocoding_suffix'] = array('#type' => 'textfield', '#default_value' => variable_get('simple_geo_geocoding_suffix', ''), '#title' => t('Geocoding suffix'), '#description' => t('Any suffix entered here will be appended to the address with a separating comma before a geocoding lookup is performed'));
    $array = drupal_map_assoc(range(1, 17));
    $form['micromap_set']['simple_geo_max_zoom'] = array('#type' => 'select', '#title' => t('Max zoom level'), '#options' => $array, '#default_value' => variable_get('simple_geo_max_zoom', 14), '#description' => t('This affects only the zoom level that\'s automatically chosen by the micromap'));
    $form['micromap_set']['simple_geo_min_zoom'] = array('#type' => 'select', '#title' => t('Minimum zoom level'), '#options' => $array, '#default_value' => variable_get('simple_geo_min_zoom', 1), '#description' => t('This affects only the zoom level that\'s automatically chosen by the micromap'));
    $form['google'] = array('#type' => 'fieldset', '#title' => t('Google maps'), '#description' => t('Google Maps must be configured for most of the simple_geo functionality'));
    $form['google']['simple_geo_manually_load'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_manually_load', 1), '#title' => t('Automatically load Google Maps scripts'));
    $form['google']['gmaps_api_key'] = array('#type' => 'textfield', '#default_value' => variable_get('gmaps_api_key', ''), '#title' => t('Your google maps api key'));
    $form['google']['simple_geo_add_google_jsapi'] = array('#type' => 'checkbox', '#default_value' => variable_get('simple_geo_add_google_jsapi', 1), '#title' => t('Add the Google AJAX API Loader to the page'), '#description' => t('Adds a script tag that loads the Google AJAX API Loader from Google. Disable this if another module or theme already handles this'));
    return system_settings_form($form);
}
Example #29
0
function libya_cron_subscription_mail($data)
{
    // subscription node
    $mail = $data[0];
    $nids = $data[1];
    // watchdog('actions', 'Cron subscription vars', func_get_args());
    global $siteName, $isMail, $base_url;
    $isMail = TRUE;
    $body = '<h1 style="font-size:1.25em;">Your alert subscription results from ' . $siteName . '</h1>
	<p class="no-margin">The following results match your subscription alert.</p>';
    foreach ($nids as $nid) {
        $N = node_load($nid);
        $content = strip_tags($N->body['und'][0]['value']);
        if (strlen($content) > 200) {
            $content = substr($content, 0, 200);
        }
        $CL = strrpos($content, ' ');
        $content = substr($content, 0, $CL) . '...';
        $body .= '<h2 style="font-size:1.25em;">' . l($N->title, 'node/' . $N->nid, array('attributes' => array('style' => array('text-decoration' => 'none')))) . '</h2><p>' . $content . '</p>
		<p>' . t('read more: ') . l($base_url . '/' . drupal_lookup_path('alias', 'node/' . $N->nid), 'node/' . $N->nid, array('absolute' => TRUE)) . '</p>
		<hr/>';
    }
    $data['message'] = 'Mail sent';
    $to = $mail['mail'];
    $from = variable_get('site_mail', '*****@*****.**');
    $params = array('body' => $body, 'rand' => $mail['rand'], 'to' => $to);
    $sent = drupal_mail('libya', 'subscription_alert_mail', $to, language_default(), $params, $from, TRUE);
}
Example #30
0
/**
 * Return the name of a default shortcut set for the provided user account.
 *
 * This hook allows modules to define default shortcut sets for a particular
 * user that differ from the site-wide default (for example, a module may want
 * to define default shortcuts on a per-role basis).
 *
 * The default shortcut set is used only when the user does not have any other
 * shortcut set explicitly assigned to them.
 *
 * Note that only one default shortcut set can exist per user, so when multiple
 * modules implement this hook, the last (i.e., highest weighted) module which
 * returns a valid shortcut set name will prevail.
 *
 * @param $account
 *   The user account whose default shortcut set is being requested.
 * @return
 *   The name of the shortcut set that this module recommends for that user, if
 *   there is one.
 */
function hook_shortcut_default_set($account)
{
    // Use a special set of default shortcuts for administrators only.
    if (in_array(variable_get('user_admin_role', 0), $account->roles)) {
        return variable_get('mymodule_shortcut_admin_default_set');
    }
}