/** * Test successful execution of hook_requirements() during install/enable. * * Function module_enable() does not check requirements, unlike normal * enabling, so we need to invoke the hook manually to simulate it. */ public function testEnable() { module_load_install(static::MODULE); module_invoke(static::MODULE, 'requirements', 'install'); module_enable([static::MODULE], FALSE); $this->pass('Successfully enabled mongodb.module.'); }
function update_script_selection_form() { $form = array(); $form['start'] = array('#tree' => TRUE, '#type' => 'fieldset', '#title' => 'Select versions', '#collapsible' => TRUE, '#collapsed' => TRUE); // Ensure system.module's updates appear first $form['start']['system'] = array(); $modules = drupal_get_installed_schema_version(NULL, FALSE, TRUE); foreach ($modules as $module => $schema_version) { $updates = drupal_get_schema_versions($module); // Skip incompatible module updates completely, otherwise test schema versions. if (!update_check_incompatibility($module) && $updates !== FALSE && $schema_version >= 0) { // module_invoke returns NULL for nonexisting hooks, so if no updates // are removed, it will == 0. $last_removed = module_invoke($module, 'update_last_removed'); if ($schema_version < $last_removed) { $form['start'][$module] = array('#value' => '<em>' . $module . '</em> module can not be updated. Its schema version is ' . $schema_version . '. Updates up to and including ' . $last_removed . ' have been removed in this release. In order to update <em>' . $module . '</em> module, you will first <a href="http://drupal.org/upgrade">need to upgrade</a> to the last version in which these updates were available.', '#prefix' => '<div class="warning">', '#suffix' => '</div>'); $form['start']['#collapsed'] = FALSE; continue; } $updates = drupal_map_assoc($updates); $updates[] = 'No updates available'; $default = $schema_version; foreach (array_keys($updates) as $update) { if ($update > $schema_version) { $default = $update; break; } } $form['start'][$module] = array('#type' => 'select', '#title' => $module . ' module', '#default_value' => $default, '#options' => $updates); } } $form['has_js'] = array('#type' => 'hidden', '#default_value' => FALSE); $form['submit'] = array('#type' => 'submit', '#value' => 'Update'); return $form; }
/** * Render a Drupal block */ public function doRenderBlock($module, $delta) { // $block = block_load($module, $delta); $blocks = module_invoke($module, 'block_info'); if (!isset($blocks[$delta])) { return; } $block = (object) $blocks[$delta]; $block->module = $module; $block->delta = $delta; $block->status = 1; $block->region = 'content'; $block->weight = 0; $block->theme = $GLOBALS['theme_key']; // Those won't serve any purpose but avoid nasty PHP warnings $block->title = ''; $block->pages = ''; $block->visibility = 0; // BLOCK_VISIBILITY_NOTLISTED (block module could be disabled) $block->custom = null; $blockList = [$block]; drupal_alter('block_list', $blockList); $render_array = _block_get_renderable_array(_block_render_blocks($blockList)); return drupal_render($render_array); }
public function actionSearch() { if (isset($_POST['keyword'])) { $keyword = $_POST['keyword']; } else { $basic = new basic(); $basic->error_code = 1; $basic->error_msg = "no input parameters"; $jsonObj = CJSON::encode($basic); echo $jsonObj; die(0); } $info = search_get_default_module_info(); $contentTypes = ' type:article,multi,_xinwen'; $results = module_invoke('search', 'data', $keyword . $contentTypes, $info['module']); $searchback['error_code'] = 0; $list = array(); if ($results['#results']) { foreach ($results['#results'] as $result) { //var_dump($result); $search['title'] = $result['title']; if ($result['type'] == '(类型2)多图新闻') { $search['type'] = 2; } else { $search['type'] = 1; } $search['createtime'] = date('Y-m-d H:i:s', $result['date']); $search['nid'] = $result['node']->nid; array_push($list, $search); } } $searchback['results'] = $list; $jsonObj = CJSON::encode($searchback); echo $jsonObj; }
function blendedmalts_viewadjust(&$vars, $mode = "node") { // Get the node object $node =& $vars['node']; include_once 'sites/all/modules/wisski_pathbuilder/wisski_pathbuilder.inc'; if (!empty($node) && !empty($node->title)) { $groupid = wisski_pathbuilder_getGroupIDForIndividual(wisski_store_getObj()->wisski_ARCAdapter_delNamespace($node->title)); } if (!$groupid || !isset($groupid)) { return; } if ($mode == "page") { $vars['maltedtitle'] = wisski_pathbuilder_generateGroupName($node->title, $groupid); } else { if ($mode == "node") { // this relies on the output of wisski_view() char by char // so first see there or in alter hooks if something broke if (strpos($vars['content'], '<div id="wki-content-other"></div>') !== FALSE) { // this is for the newest wisski_view() version (39ee47a0ef) // we wrap the div wki-content-other around all other/following content // (e.g. file attachments) $vars['maltedcontent'] = str_replace('<div id="wki-content-other"></div>', '<div id="wki-content-other">', $vars['content']) . '</div>'; } elseif (strpos($vars['content'], '<div id="wki-content-right">') === FALSE) { // this is for the very old wisski_view() (fbb0f44f66) which effectively // does nothing. construct the wisski content in the old fashion and add // further content. $block2 = module_invoke('wisski_pathbuilder', 'block', 'view', 0); $block1 = module_invoke('wisski_pathbuilder', 'block', 'view', 1); $vars['maltedcontent'] = '<div id="wki-content-right">' . $block2['content'] . '</div>' . '<div id="wki-content-left">' . $block1['content'] . '</div><div id="wki-content-other">' . $vars['content'] . '</div>'; } // for the version in between we do nothing and let the default theming put // the content together } } }
/** * Generate a settings form for this handler. */ public function settingsForm($field, $instance) { $field_name = $field['field_name']; $form['action'] = array('#type' => 'select', '#title' => t('Action'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'disable' => t('Disable field')), '#description' => t('Action to take when prepopulating field with values via URL.')); $form['action_on_edit'] = array('#type' => 'checkbox', '#title' => t('Apply action on edit'), '#description' => t('Apply action when editing an existing entity.'), '#states' => array('invisible' => array(':input[name="instance[settings][behaviors][prepopulate][action]"]' => array('value' => 'none')))); $form['fallback'] = array('#type' => 'select', '#title' => t('Fallback behaviour'), '#description' => t('Determine what should happen if no values are provided via URL.'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'form_error' => t('Set form error'), 'redirect' => t('Redirect'))); // Get list of permissions. $perms = array(); $perms[0] = t('- None -'); foreach (module_list(FALSE, FALSE, TRUE) as $module) { // By keeping them keyed by module we can use optgroups with the // 'select' type. if ($permissions = module_invoke($module, 'permission')) { foreach ($permissions as $id => $permission) { $perms[$module][$id] = strip_tags($permission['title']); } } } $form['skip_perm'] = array('#type' => 'select', '#title' => t('Skip access permission'), '#description' => t('Set a permission that will not be affected by the fallback behavior.'), '#options' => $perms); $description = t('Determine if values that should be prepopulated should "listen" to the OG-context.'); if ($disabled = !module_exists('og_context') || !og_is_group_audience_field($field_name)) { $description .= '<br / >' . t('Organic groups integration: Enable OG-context and set "Entity selection mode" to "Organic groups" to enable this selection.'); } $form['og_context'] = array('#type' => 'checkbox', '#title' => t('OG context'), '#description' => $description, '#disabled' => $disabled); return $form; }
/** * 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'; }
/** * Override EntityReferenceHandler::settingsForm(). */ public function settingsForm($field, $instance) { $form = parent::settingsForm($field, $instance); $settings = !empty($instance['settings']['behaviors']['og_widget']) ? $instance['settings']['behaviors']['og_widget'] : array(); $settings += array('default' => array('widget_type' => 'options_select', 'widget_settings' => array()), 'admin' => array('widget_type' => 'entityreference_autocomplete', 'widget_settings' => array())); $field_types = array('default' => array('title' => t('Default widget type'), 'description' => t('The widget type of the field as it will appear to the user.')), 'admin' => array('title' => t('Administrator widget type'), 'description' => t('The widget type of the field that will appear only to a user with "Administer group" permission.'))); module_load_include('inc', 'field_ui', 'field_ui.admin'); $widget_types = field_ui_widget_type_options('entityreference'); unset($widget_types['og_complex']); $field_info_widget_types = field_info_widget_types(); foreach ($field_types as $field_type => $value) { $settings_id = 'og-' . $field_type . '-settings'; $form[$field_type]['widget_type'] = array('#type' => 'select', '#title' => $value['title'], '#required' => TRUE, '#options' => $widget_types, '#default_value' => $settings[$field_type]['widget_type'], '#description' => $value['description'], '#ajax' => array('callback' => 'og_' . $field_type . '_settings_form_ajax', 'wrapper' => $settings_id, 'method' => 'replace', 'event' => 'change')); $form[$field_type]['widget_settings'] = array('#type' => 'fieldset', '#title' => t('@title Settings', array('@title' => $value['title'])), '#tree' => TRUE, '#attributes' => array('id' => $settings_id)); if ($settings[$field_type]['widget_type'] && !empty($field_info_widget_types[$settings[$field_type]['widget_type']])) { $widget_type = $field_info_widget_types[$settings[$field_type]['widget_type']]; $current_settings = isset($settings[$field_type]['widget_settings']) ? $settings[$field_type]['widget_settings'] : array(); $fake_instance = array('widget' => array('type' => $settings[$field_type]['widget_type'], 'module' => $widget_type['module'], 'settings' => $current_settings) + $instance['widget']) + $instance; $additions = module_invoke($widget_type['module'], 'field_widget_settings_form', $field, $fake_instance); if ($additions) { $form[$field_type]['widget_settings'] += $additions; } } } // Field access settings. $form['access_override'] = array('#title' => t('Allow entity access to control field access'), '#description' => t('By default, the <em>administer group</em> permission is required to directly edit this field. Selecting this option will allow access to anybody with access to edit the entity.'), '#type' => 'checkbox', '#default_value' => isset($settings['access_override']) ? $settings['access_override'] : FALSE); return $form; }
/** * Return a list of valid addresses where key = email address and value = associated UID. * EG. $array['*****@*****.**'] = 1 * * @return list of valid addresses */ private function get_valid_address_list() { // Define a hook -- this plugin is intended to be used with mailhandler_singlebox // but it could be implemented using another email address to uid mapping function. $addresses = array(); foreach (module_implements('mailhandler_sendto_addresses') as $module) { $addresses += module_invoke($module, 'mailhandler_sendto_addresses'); } return $addresses; }
/** * Get data from other modules via hook_groupadmin_ functions. */ function _groupadmin_get_modules($op) { $hook = 'hook_groupadmin_' . $op; $modules = module_implements($hook); //drupal_set_message('modules: ' . print_r($modules, 1)); $data = array(); foreach ($modules as $module) { $data = array_merge($data, module_invoke($module, $hook)); } return $data; }
/** * Implements hook_preprocess_page(). */ function shelter_preprocess_page(&$variables) { // Put the language switcher in a variable. $block = module_invoke('locale', 'block_view', 'language_content'); $variables['language_switcher'] = $block['content']; global $base_url; $variables['base_url'] = $base_url; $current_path = current_path(); // Adding the viewport for mobile view. $viewport = array('#tag' => 'meta', '#attributes' => array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1, maximum-scale=1, minimal-ui')); drupal_add_html_head($viewport, 'viewport'); libraries_load('underscore'); drupal_add_library('system', 'jquery.cookie'); $variables['hot_responses'] = FALSE; $variables['is_regions_and_countries'] = FALSE; $variables['is_user_profile_pages'] = FALSE; $variables['is_search_documents'] = FALSE; $variables['global_docs_search_page_link'] = l(t('Search all documents'), 'search-documents', array('attributes' => array('class' => array('search-documents-link')), 'query' => array('sort' => 'date', 'sort_direction' => 'DESC'))); $variables['global_events_page'] = FALSE; $variables['recent_documents'] = FALSE; if ($variables['is_front']) { $variables['hot_responses'] = cluster_og_hot_responses(); $variables['upcoming_events'] = cluster_events_upcoming(); $variables['recent_documents'] = cluster_docs_recent(); } if ($current_path == 'regions-countries') { $variables['is_regions_and_countries'] = TRUE; } if ($current_path == 'search-documents') { $variables['is_search_documents'] = TRUE; $variables['hot_responses'] = cluster_og_hot_responses(); $variables['upcoming_events'] = NULL; } if ($current_path == 'events') { $variables['hot_responses'] = cluster_og_hot_responses(); $variables['global_events_page'] = TRUE; } if (arg(0) == 'user') { $variables['is_user_profile_pages'] = TRUE; } $variables['extra'] = FALSE; if (isset($variables['page']['content']['system_main']['side-column'])) { $variables['extra'] = $variables['page']['content']['system_main']['side-column']; unset($variables['page']['content']['system_main']['side-column']); } elseif ($node = menu_get_object()) { if (isset($variables['page']['content']['system_main']['nodes'][$node->nid][0]['side-column'])) { $variables['extra'] = $variables['page']['content']['system_main']['nodes'][$node->nid][0]['side-column']; unset($variables['page']['content']['system_main']['nodes'][$node->nid][0]['side-column']); } } }
/** * Helper function to find and render a block by Jeremy Cerda @FreighthouseNYC * PS. - Necessary to support i18n */ function render_block_content($module, $delta) { $output = ''; if ($block = block_load($module, $delta)) { if ($build = module_invoke($module, 'block_view', $delta)) { $delta = str_replace('-', '_', $delta); drupal_alter(array('block_view', "block_view_{$module}_{$delta}"), $build, $block); if (!empty($build['content'])) { return is_array($build['content']) ? render($build['content']) : $build['content']; } } } return $output; }
/** * Generate a settings form for this handler. */ public function settingsForm($field, $instance) { $form['action'] = array('#type' => 'select', '#title' => t('Action'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'disable' => t('Disable field')), '#description' => t('Action to take when prepopulating field with values via URL.')); $form['action_on_edit'] = array('#type' => 'checkbox', '#title' => t('Apply action on edit'), '#description' => t('Apply action when editing an existing entity.'), '#states' => array('invisible' => array(':input[name="instance[settings][behaviors][prepopulate][action]"]' => array('value' => 'none')))); $form['fallback'] = array('#type' => 'select', '#title' => t('Fallback behaviour'), '#description' => t('Determine what should happen if no values are provided via URL.'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'form_error' => t('Set form error'), 'redirect' => t('Redirect'))); // Get list of permissions. $perms = array(); $perms[0] = t('- None -'); foreach (module_list(FALSE, FALSE, TRUE) as $module) { // By keeping them keyed by module we can use optgroups with the // 'select' type. if ($permissions = module_invoke($module, 'permission')) { foreach ($permissions as $id => $permission) { $perms[$module][$id] = strip_tags($permission['title']); } } } $form['skip_perm'] = array('#type' => 'select', '#title' => t('Skip access permission'), '#description' => t('Set a permission that will not be affected by the fallback behavior.'), '#options' => $perms); $form['providers'] = array('#type' => 'container', '#theme' => 'entityreference_prepopulate_providers_table', '#element_validate' => array('entityreference_prepopulate_providers_validate')); $providers = entityreference_prepopulate_providers_info(); // Sort providers by weight. $providers_names = !empty($instance['settings']['behaviors']['prepopulate']['providers']) ? array_keys($instance['settings']['behaviors']['prepopulate']['providers']) : array(); $providers_names = drupal_array_merge_deep($providers_names, array_keys($providers)); $weight = 0; foreach ($providers_names as $name) { // Validate that the provider exists. if (!isset($providers[$name])) { continue; } $provider = $providers[$name]; // Set default values. $provider += array('disabled' => FALSE); $form['providers']['title'][$name] = array('#type' => 'item', '#markup' => filter_xss($provider['title']), '#description' => filter_xss($provider['description'])); if (!isset($instance['settings']['behaviors']['prepopulate']['providers'][$name])) { // backwards compatibility with version 1.4. if ($name == 'url') { // Enable the URL provider is it is not set in the instance yet. $default_value = TRUE; } elseif ($name == 'og_context') { $default_value = !empty($instance['settings']['behaviors']['prepopulate']['og_context']); } } else { $default_value = !empty($instance['settings']['behaviors']['prepopulate']['providers'][$name]); } $form['providers']['enabled'][$name] = array('#type' => 'checkbox', '#disabled' => $provider['disabled'], '#default_value' => $default_value); $form['providers']['weight'][$name] = array('#type' => 'weight', '#default_value' => $weight, '#attributes' => array('class' => array('provider-weight'))); ++$weight; } return $form; }
function hyx_preprocess_page(&$variables) { if (!empty($variables['node']) && !empty($variables['node']->type)) { $variables['theme_hook_suggestions'][] = 'page__node__' . $variables['node']->type; } // block de locale $variables['locale'] = module_invoke('locale', 'block_view', 'language'); // block panier $variables['cart'] = module_invoke('hyx_content', 'block_view', 'hyx_cart'); // block de recherche $variables['search_block_form'] = module_invoke('search_api_page', 'block_view', 'hyxsearchpage'); // menu user //$variables['menu_user'] = menu_tree('user-menu'); //$variables['logo'] = image_style_url('my_image_style', $variables['logo']); }
/** * Override or insert variables into the node template. */ function redcrackle_preprocess_node(&$variables) { $variables['theme_hook_suggestions'][] = 'node__' . $variables['type'] . '__' . strtolower($variables['title']); if ($variables['type'] == 'blog') { $author = user_load($variables['uid']); $author_name = field_get_items('user', $author, 'field_name'); $author_name = $author_name[0]['value']; $author_name = l($author_name, 'blog/' . $author->uid); $variables['author_name'] = $author_name; if ($variables['view_mode'] == 'full') { $block = module_invoke('mailchimp_signup', 'block_view', 'mailchimp_signup_1'); $variables['newsletter_block'] = $block; } } }
/** * This reproduces the node_access() function algorithm, skipping a few * modules and dropping caches. * * Please note */ private function nodeAccess($node, $op, $account) { if (user_access('bypass node access', $account)) { return VoterInterface::ACCESS_GRANTED; } if (!user_access('access content', $account)) { return VoterInterface::ACCESS_DENIED; } $vote = VoterInterface::ACCESS_ABSTAIN; foreach (module_implements('node_access') as $module) { // Our ACL module implements it own logic which already exists as // Symfony voter, running it code in here would mean it would be // run twice during this isGranted() call. if ('sf_acl' === $module) { continue; } $access = module_invoke($module, 'node_access', $node, $op, $account); // Order is DENY, ALLOW, default is IGNORE if (NODE_ACCESS_DENY === $access) { return VoterInterface::ACCESS_DENIED; } if (NODE_ACCESS_ALLOW === $access) { $vote = VoterInterface::ACCESS_GRANTED; } } if ($vote !== VoterInterface::ACCESS_ABSTAIN) { return $vote; } // Check if authors can view their own unpublished nodes. if ($op == 'view' && !$node->status && user_access('view own unpublished content', $account) && $account->uid == $node->uid && $account->uid != 0) { return VoterInterface::ACCESS_GRANTED; } // If modules do implement the hook_node_grants() we are supposed to do // an SQL query on the {node_access} table, since the whole point of this // API is actually to let live the ACLs into the ACL component, skip that // and just abstain. if (module_implements('node_grants')) { return VoterInterface::ACCESS_ABSTAIN; } // If no modules implement hook_node_grants(), the default behavior is to // allow all users to view published nodes, so reflect that here. if ($op == 'view' && $node->status) { return VoterInterface::ACCESS_GRANTED; } return VoterInterface::ACCESS_ABSTAIN; }
/** * Get cron queues and static cache them. * * Works like module_invoke_all('cron_queue_info'), but adds * a 'module' to each item. * * @return array * Cron queue definitions. */ private function get_queues() { if (!isset(self::$queues)) { $queues = array(); foreach (module_implements('cron_queue_info') as $module) { $items = module_invoke($module, 'cron_queue_info'); if (is_array($items)) { foreach ($items as &$item) { $item['module'] = $module; } $queues += $items; } } drupal_alter('cron_queue_info', $queues); self::$queues = $queues; } return $queues; }
public function check(&$output, &$perf) { $status = PROD_MONITORING_OK; $messages = array(); $output = ''; $perf = ''; $checkers = module_implements('prod_nagios_check'); foreach ($checkers as $i => $module) { $result = module_invoke($module, 'prod_nagios_check'); // Check output format if (!is_array($result) || !array_key_exists('status', $result)) { throw new MonitoringException($module . ' has invalid output format'); } // Collect messages if (array_key_exists('message', $result)) { $messages[] = $result['message']; } // Collect perfdata // TODO (via arrays?) switch ($result['status']) { case PROD_MONITORING_CRITICAL: $status = $result['status']; // stop processing modules and exit right now break 2; case PROD_MONITORING_WARNING: if (PROD_MONITORING_OK === $status || PROD_MONITORING_PENDING === $status || PROD_MONITORING_UNKNOWN === $status) { $status = $result['status']; } break; case PROD_MONITORING_UNKNOWN: if (PROD_MONITORING_OK === $status || PROD_MONITORING_PENDING === $status) { $status = $result['status']; } break; case PROD_MONITORING_PENDING: if (PROD_MONITORING_OK === $status) { $status = $result['status']; } break; } } $output = implode('; ', $messages); return $status; }
/** * Generate a settings form for this handler. */ public function settingsForm($field, $instance) { $form['action'] = array('#type' => 'select', '#title' => t('Action'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'disable' => t('Disable field')), '#description' => t('Action to take when prepopulating field with values via URL.')); $form['fallback'] = array('#type' => 'select', '#title' => t('Fallback behaviour'), '#description' => t('Determine what should happen if no values are provided via URL.'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'form_error' => t('Set form error'), 'redirect' => t('Redirect'))); // Get list of permissions. $perms = array(); $perms[0] = t('- None -'); foreach (module_list(FALSE, FALSE, TRUE) as $module) { // By keeping them keyed by module we can use optgroups with the // 'select' type. if ($permissions = module_invoke($module, 'permission')) { foreach ($permissions as $id => $permission) { $perms[$module][$id] = strip_tags($permission['title']); } } } $form['skip_perm'] = array('#type' => 'select', '#title' => t('Skip access permission'), '#description' => t('Set a permission that will not be affected by the fallback behavior.'), '#options' => $perms); return $form; }
public function render() { $reporters = module_implements('prod_monitor_summary'); $lines = array(); // D7 hooks foreach ($reporters as $i => $module) { $new_lines = module_invoke($module, 'prod_monitor_summary'); if (!is_array($new_lines)) { throw new MonitoringException($module . ' has invalid output format'); } $lines = array_merge($lines, new_lines); } // Listeners should call AddOutputLine() on ourself $this->notify(ProdObservable::SIGNAL_MONITOR_SUMMARY); $lines = array_merge($lines, $this->_lines); foreach ($lines as $line) { drush_print($line, 0, NULL, TRUE); } }
/** * Override or insert variables into the page template. */ function bluez_preprocess_page(&$vars) { $vars['twitter'] = theme_get_setting('twitter', 'bluez'); $vars['facebook'] = theme_get_setting('facebook', 'bluez'); $vars['linkedin'] = theme_get_setting('linkedin', 'bluez'); $vars['theme_path_social'] = base_path() . drupal_get_path('theme', 'bluez'); $vars['display'] = theme_get_setting('display', 'bluez'); $vars['footer_copyright'] = theme_get_setting('footer_copyright'); $vars['footer_developed'] = theme_get_setting('footer_developed'); $vars['footer_developedby_url'] = filter_xss_admin(theme_get_setting('footer_developedby_url', 'bluez')); $vars['footer_developedby'] = filter_xss_admin(theme_get_setting('footer_developedby', 'bluez')); $vars['searchblock'] = module_invoke('search', 'block_view', 'form'); if (module_exists('i18n_menu')) { $vars['main_menu_tree'] = i18n_menu_translated_tree(variable_get('menu_main_links_source', 'main-menu')); } else { $vars['main_menu_tree'] = menu_tree(variable_get('menu_main_links_source', 'main-menu')); } // Frontpage variables. $vars['slideshow_display'] = theme_get_setting('slideshow_display', 'bluez'); $vars['slide1_title'] = theme_get_setting('slide1_title', 'bluez'); $vars['slide2_title'] = theme_get_setting('slide2_title', 'bluez'); $vars['slide3_title'] = theme_get_setting('slide3_title', 'bluez'); $vars['slide1_desc'] = theme_get_setting('slide1_desc', 'bluez'); $vars['slide2_desc'] = theme_get_setting('slide2_desc', 'bluez'); $vars['slide3_desc'] = theme_get_setting('slide3_desc', 'bluez'); $vars['wtitle'] = filter_xss_admin(theme_get_setting('welcome_title', 'bluez')); $vars['wtext'] = filter_xss_admin(theme_get_setting('welcome_text', 'bluez')); $vars['col1'] = filter_xss_admin(theme_get_setting('colone', 'bluez')); $vars['col1title'] = filter_xss_admin(theme_get_setting('colonetitle', 'bluez')); $vars['col2'] = filter_xss_admin(theme_get_setting('coltwo', 'bluez')); $vars['col2title'] = filter_xss_admin(theme_get_setting('coltwotitle', 'bluez')); $vars['col3'] = filter_xss_admin(theme_get_setting('colthree', 'bluez')); $vars['col3title'] = filter_xss_admin(theme_get_setting('colthreetitle', 'bluez')); $vars['img1'] = base_path() . drupal_get_path('theme', 'bluez') . '/images/slideshow/slide-image-1.jpg'; $vars['img2'] = base_path() . drupal_get_path('theme', 'bluez') . '/images/slideshow/slide-image-2.jpg'; $vars['img3'] = base_path() . drupal_get_path('theme', 'bluez') . '/images/slideshow/slide-image-3.jpg'; $image1var = array('path' => $vars['img1'], 'alt' => $vars['slide1_title'], 'title' => $vars['slide1_title'], 'attributes' => array('class' => 'slide-img')); $vars['slideimage1'] = theme('image', $image1var); $image2var = array('path' => $vars['img2'], 'alt' => $vars['slide2_title'], 'title' => $vars['slide2_title'], 'attributes' => array('class' => 'slide-img')); $vars['slideimage2'] = theme('image', $image2var); $image3var = array('path' => $vars['img3'], 'alt' => $vars['slide3_title'], 'title' => $vars['slide3_title'], 'attributes' => array('class' => 'slide-img')); $vars['slideimage3'] = theme('image', $image3var); }
/** * Render a Drupal block */ public function doRenderBlock($module, $delta) { // $block = block_load($module, $delta); $blocks = module_invoke($module, 'block_info'); if (!isset($blocks[$delta])) { return; } $block = (object) $blocks[$delta]; $block->module = $module; $block->delta = $delta; $block->status = 1; $block->region = 'content'; $block->weight = 0; $block->theme = $GLOBALS['theme_key']; $blockList = [$block]; drupal_alter('block_list', $blockList); $render_array = _block_get_renderable_array(_block_render_blocks($blockList)); return drupal_render($render_array); }
/** * Invoke hook_module_builder_info(). */ function invokeInfoHook() { $major_version = $this->major_version; // TODO: just get ours if no bootstrap? $mask = '/\\.module_builder.inc$/'; $mb_files = drupal_system_listing($mask, 'modules'); //print_r($mb_files); $module_data = array(); foreach ($mb_files as $file) { // Our system listing wrapper ensured that there is a uri property on all versions. include_once $file->uri; // Use a property of the (badly-documented!) $file object that is common to both D6 and D7. $module = str_replace('.module_builder', '', $file->name); // Note that bad data got back from the hook breaks things. if ($result = module_invoke($module, 'module_builder_info', $major_version)) { $module_data = array_merge($module_data, $result); } } return $module_data; }
function footmali_preprocess_page(&$variables) { if (isset($variables['main_menu'])) { $menu_tree_array = menu_build_tree('main-menu'); $main_links = ''; foreach ($menu_tree_array as $menu) { $main_links .= '<li><a href="' . url($menu['link']['link_path']) . '"><span>' . $menu['link']['link_title'] . '</span></a>'; if (count($menu['below']) > 0) { $main_links .= '<ul class="sub-menu">'; foreach ($menu['below'] as $sub_menu) { $main_links .= '<li><a href="/' . drupal_get_path_alias($sub_menu['link']['link_path']) . '">' . $sub_menu['link']['link_title'] . '</a></li>'; } $main_links .= '</ul>'; } $main_links .= '</li>'; } $variables['main_links'] = $main_links; } $search_block = module_invoke('search', 'block_view', 'search'); $variables['search_block'] = $search_block; }
/** * Implements template_preprocess_page(). */ function oa_radix_preprocess_page(&$vars) { // Rework search_form to our liking. $vars['search_form'] = ''; if (module_exists('search') && user_access('search content')) { $search_box_form = drupal_get_form('search_form'); $search_box_form['basic']['keys']['#title'] = ''; $search_box_form['basic']['keys']['#attributes'] = array('placeholder' => 'Search'); $search_box_form['basic']['keys']['#attributes']['class'][] = 'search-query'; $search_box_form['basic']['submit']['#value'] = t('Search'); $search_box_form['#attributes']['class'][] = 'navbar-form'; $search_box_form['#attributes']['class'][] = 'pull-right'; $search_box = drupal_render($search_box_form); $vars['search_form'] = user_access('search content') ? $search_box : NULL; } // Add user_badge to header. $vars['user_badge'] = ''; if (module_exists('oa_dashboard')) { $user_badge = module_invoke('oa_dashboard', 'block_view', 'oa_user_badge'); $vars['user_badge'] = $user_badge['content']; } $toolbar = panels_mini_block_view('oa_toolbar_panel'); $vars['oa_toolbar_panel'] = isset($toolbar) ? $toolbar['content'] : ''; $footer = panels_mini_block_view('oa_footer_panel'); $vars['oa_footer_panel'] = isset($footer) ? $footer['content'] : ''; ctools_include('content'); $banner = ctools_content_render('oa_space_banner', '', array('banner_position' => 2)); if (!empty($banner->content)) { $vars['oa_banner'] = $banner->content; } $vars['oa_space_menu'] = ''; $space_id = oa_core_get_space_context(); if (variable_get('oa_space_menu_' . $space_id, TRUE)) { $space_menu = ctools_content_render('oa_space_menu', '', array(), array()); if (!empty($space_menu->content)) { $vars['oa_space_menu'] = $space_menu->content; } } }
/** * Generate a settings form for this handler. */ public function settingsForm($field, $instance) { $field_name = $field['field_name']; $form['action'] = array('#type' => 'select', '#title' => t('Action'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'disable' => t('Disable field')), '#description' => t('Action to take when prepopulating field with values via Current Entity(Menu Object).')); $form['action_on_edit'] = array('#type' => 'checkbox', '#title' => t('Apply action on edit'), '#description' => t('Apply action when editing an existing entity.'), '#states' => array('invisible' => array(':input[name="instance[settings][behaviors][current][action]"]' => array('value' => 'none')))); $form['fallback'] = array('#type' => 'select', '#title' => t('Fallback behaviour'), '#description' => t('Determine what should happen if no values are provided via via Current Entity(Menu Object).'), '#options' => array('none' => t('Do nothing'), 'hide' => t('Hide field'), 'form_error' => t('Set form error'), 'redirect' => t('Redirect'))); // Get list of permissions. $perms = array(); $perms[0] = t('- None -'); foreach (module_list(FALSE, FALSE, TRUE) as $module) { // By keeping them keyed by module we can use optgroups with the // 'select' type. if ($permissions = module_invoke($module, 'permission')) { foreach ($permissions as $id => $permission) { $perms[$module][$id] = strip_tags($permission['title']); } } } $form['skip_perm'] = array('#type' => 'select', '#title' => t('Skip access permission'), '#description' => t('Set a permission that will not be affected by the fallback behavior.'), '#options' => $perms); $form['use_uid'] = array('#type' => 'checkbox', '#title' => t('Use the Author for an entity if target type is user.'), '#description' => t('If the target type is User but the current page is a Node select the Author as the entity.')); return $form; }
/** * {@inheritDoc} */ protected function write(array $record) { // Pre-bootstrap errors if (!function_exists('module_implements')) { return; } $request = \Drupal::requestStack()->getCurrentRequest(); // Remove unwanted stuff from the context, do not attempt to serialize // potential PDO instances of stuff like that may lie into unserialized // exceptions in there $message = empty($record['formatted']) ? $record['message'] : $record['formatted']; foreach ($record['context'] as $key => $value) { // @todo temporary avoir Array to string conversion warnings if (!is_array($value)) { $record['context'][$key] = (string) $value; } } // If you are dblogging stuff, using <br/> tags is advised for readability $message = nl2br($message); $entry = ['severity' => self::monologToDrupal($record['level']), 'type' => 'monolog', 'message' => $message, 'variables' => $record['context'], 'link' => '', 'user' => null, 'uid' => \Drupal::currentUser()->id(), 'request_uri' => $request->getRequestUri(), 'referer' => $request->headers->get('referer'), 'ip' => $request->getClientIp(), 'timestamp' => $record['datetime']->getTimestamp()]; foreach (module_implements('watchdog') as $module) { module_invoke($module, 'watchdog', $entry); } }
/** * Execute a search for a set of key words. * * We call do_search() with the keys, the module name, and extra SQL fragments * to use when searching. See hook_update_index() for more information. * * @param $keys * The search keywords as entered by the user. * * @return * An array of search results. To use the default search result * display, each item should have the following keys': * - 'link': Required. The URL of the found item. * - 'type': The type of item. * - 'title': Required. The name of the item. * - 'user': The author of the item. * - 'date': A timestamp when the item was last modified. * - 'extra': An array of optional extra information items. * - 'snippet': An excerpt or preview to show with the result (can be * generated with search_excerpt()). * * @ingroup search */ function hook_search_execute($keys = NULL) { // Build matching conditions $query = db_search()->extend('PagerDefault'); $query->join('node', 'n', 'n.nid = i.sid'); $query->condition('n.status', 1)->addTag('node_access')->searchExpression($keys, 'node'); // Insert special keywords. $query->setOption('type', 'n.type'); $query->setOption('language', 'n.language'); if ($query->setOption('term', 'ti.tid')) { $query->join('taxonomy_index', 'ti', 'n.nid = ti.nid'); } // Only continue if the first pass query matches. if (!$query->executeFirstPass()) { return array(); } // Add the ranking expressions. _node_rankings($query); // Add a count query. $inner_query = clone $query; $count_query = db_select($inner_query->fields('i', array('sid'))); $count_query->addExpression('COUNT(*)'); $query->setCountQuery($count_query); $find = $query->limit(10)->execute(); // Load results. $results = array(); foreach ($find as $item) { // Build the node body. $node = node_load($item->sid); node_build_content($node, 'search_result'); $node->body = drupal_render($node->content); // Fetch comments for snippet. $node->rendered .= ' ' . module_invoke('comment', 'node_update_index', $node); // Fetch terms for snippet. $node->rendered .= ' ' . module_invoke('taxonomy', 'node_update_index', $node); $extra = module_invoke_all('node_search_result', $node); $results[] = array('link' => url('node/' . $item->sid, array('absolute' => TRUE)), 'type' => check_plain(node_type_get_name($node)), 'title' => $node->title, 'user' => theme('username', array('account' => $node)), 'date' => $node->changed, 'node' => $node, 'extra' => $extra, 'score' => $item->calculated_score, 'snippet' => search_excerpt($keys, $node->body)); } return $results; }
* - $page['header']: Items for the header region. * - $page['footer']: Items for the footer region. * * @see template_preprocess() * @see template_preprocess_page() * @see template_process() * @see html.tpl.php * * @ingroup themeable */ include __DIR__ . '/partials/homeHeader.inc'; ?> <div class="cob-portalSearch"> <div class="cob-portalSearch-container"> <?php $search = module_invoke('search', 'block_view', 'form'); #print_r($search); $search['content']['search_block_form']['#attributes']['placeholder'] = 'Search all of Bloomington.in.gov'; echo render($search['content']); ?> </div> </div> <header class="cob-portalHeader"> <div class="cob-portalHeader-container"> <?php echo $messages; include __DIR__ . '/partials/siteAdminBar.inc'; $term =& $page['content']['system_main']['term_heading']['term']['#term']; $title = $term->name; ?> <h1 class="cob-portalHeader-title"><?php
/** * Implements template_preprocess_page(). * 1. Check if sidebars have content; Add boolean to $variables * 2. Setup the user menu (by default displayed in header) */ function bear_skin_preprocess_page(&$variables) { $page = $variables['page']; // set the page title for the homepage // for accessibility purposes $title = drupal_get_title(); if (drupal_is_front_page() && empty($title)) { $variables['bear_page_title'] = variable_get('site_name', '') . ' Homepage'; } else { $variables['bear_page_title'] = $title; } // check if there is content in the sidebars $variables['has_sidebar_first'] = FALSE; $variables['has_sidebar_second'] = FALSE; if (!empty($page['sidebar_first'])) { $variables['has_sidebar_first'] = TRUE; } if (!empty($page['sidebar_second'])) { $variables['has_sidebar_second'] = TRUE; } // setup the user menu to display in the header $variables['user_menu'] = theme('links__user_menu', array('links' => menu_navigation_links('user-menu'), 'attributes' => array('class ' => array('nav-user__list'), 'aria-labelledby' => 'userMenuLabel'))); // include the basic search form if one exists if (module_exists('search')) { $bear_search_form = module_invoke('search', 'block_view', 'search'); $variables['page']['bear_search_form'] = render($bear_search_form); } }