本文整理汇总了PHP中drupal_alter函数的典型用法代码示例。如果您正苦于以下问题:PHP drupal_alter函数的具体用法?PHP drupal_alter怎么用?PHP drupal_alter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drupal_alter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getHandlers
public static function getHandlers()
{
if (self::$handlers !== null) {
return self::$handlers;
}
self::$handlers = array();
// Register handlers.
self::$handlers[] = new TaxonomyReferenceHandler();
self::$handlers[] = new UserHandler();
self::$handlers[] = new EntityReferenceHandler();
self::$handlers[] = new FileReferenceHandler();
self::$handlers[] = new ChangedHandler();
self::$handlers[] = new MenuLinkHandler();
self::$handlers[] = new MenuLinkPathHandler();
self::$handlers[] = new FileHandler();
self::$handlers[] = new TextAreaFileReferenceHandler();
self::$handlers[] = new TextAreaLinkReferenceHandler();
self::$handlers[] = new IDHandler();
if (module_exists('imagefield_crop')) {
self::$handlers[] = new ImageCropFieldHandler();
}
if (module_exists('workbench_moderation')) {
self::$handlers[] = new WorkbenchModerationHandler();
}
// Allow modules to modify this.
drupal_alter('publisher_definition_handlers', self::$handlers);
return self::$handlers;
}
示例2: match
/**
* {@inheritDocs}
*/
public function match($pathinfo)
{
// The 'q' variable is pervasive in Drupal, so it's best to just keep
// it even though it's very un-Symfony.
$path = drupal_get_normal_path(substr($pathinfo, 1));
if (variable_get('menu_rebuild_needed', FALSE) || !variable_get('menu_masks', array())) {
menu_rebuild();
}
$original_map = arg(NULL, $path);
$parts = array_slice($original_map, 0, MENU_MAX_PARTS);
$ancestors = menu_get_ancestors($parts);
$router_item = db_query_range('SELECT * FROM {menu_router} WHERE path IN (:ancestors) ORDER BY fit DESC', 0, 1, array(':ancestors' => $ancestors))->fetchAssoc();
if ($router_item) {
// Allow modules to alter the router item before it is translated and
// checked for access.
drupal_alter('menu_get_item', $router_item, $path, $original_map);
// The requested path is an unalaised Drupal route.
return array('_drupal' => true, '_controller' => function ($_router_item) {
$router_item = $_router_item;
if (!$router_item['access']) {
throw new AccessDeniedException();
}
if ($router_item['include_file']) {
require_once DRUPAL_ROOT . '/' . $router_item['include_file'];
}
return call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
}, '_route' => $router_item['path']);
}
throw new ResourceNotFoundException();
}
示例3: doRenderBlock
/**
* 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);
}
示例4: compile
public function compile($page_id = NULL)
{
$pages = $this->getData()->get();
if ($page_id && array_key_exists($page_id, $pages)) {
$pages = array($pages[$page_id]);
}
$build = '';
foreach ($pages as $page_id => $data) {
$vars['#ExportData'] = $this;
$vars['#page_id'] = $page_id;
$vars['attributes'] = array();
$vars['caption'] = $page_id;
$vars['header'] = array();
$column_no = 1;
foreach ($this->getHeader($page_id) as $header_key => $value) {
$header_classes = array();
$header_classes[] = 'column-' . $column_no;
if ($column_no === count($row) - 1) {
$header_classes[] = 'last';
} elseif ($column_no === 0) {
$header_classes[] = 'first';
}
$string = preg_replace('/[^a-z0-9\\-\\.]/', '-', strtolower($header_key));
$string = preg_replace('/^\\d/', 'c-\\0', $string);
$header_classes[] = preg_replace('/-{2,}/', '-', $string);
$vars['header'][] = array('data' => t($value), 'class' => implode(' ', $header_classes));
$column_no++;
}
$vars['rows'] = array();
foreach (array_values($data) as $row_no => $row) {
$row_classes = array();
$row_classes[] = 'row-' . $row_no;
if ($row_no === count($data) - 1) {
$row_classes[] = 'last';
} elseif ($row_no === 0) {
$row_classes[] = 'first';
}
$columns = array();
$array_keys = array_keys($row);
foreach (array_values($row) as $column_no => $column) {
$column_classes = array();
$column_classes[] = 'column-' . $column_no;
if ($column_no === count($row) - 1) {
$column_classes[] = 'last';
} elseif ($column_no === 0) {
$column_classes[] = 'first';
}
$string = preg_replace('/[^a-z0-9\\-\\.]/', '-', strtolower($array_keys[$column_no]));
$string = preg_replace('/^\\d/', 'c-\\0', $string);
$column_classes[] = preg_replace('/-{2,}/', '-', $string);
$columns[] = array('data' => $column, 'class' => implode(' ', $column_classes));
}
$vars['rows'][] = array('data' => $columns, 'class' => implode(' ', $row_classes));
}
$build['table'] = array('#theme' => 'table', '#rows' => $vars['rows'], '#header' => $vars['header'], '#attributes' => $vars['attributes'], '#caption' => $vars['caption']);
drupal_alter('loft_data_grids_table', $build, $this, $page_id);
}
$this->output = drupal_render($build);
}
示例5: getQueues
/**
* {@inheritdoc}
*/
public function getQueues()
{
if (!isset(static::$queues)) {
static::$queues = module_invoke_all('cron_queue_info');
drupal_alter('cron_queue_info', static::$queues);
}
return static::$queues;
}
示例6: foundation_access_preprocess_html
/**
* Adds CSS classes based on user roles
* Implements template_preprocess_html().
*
*/
function foundation_access_preprocess_html(&$variables)
{
// loop through our system specific colors
$colors = array('primary', 'secondary', 'required', 'optional');
$css = '';
foreach ($colors as $current) {
$color = theme_get_setting('foundation_access_' . $current . '_color');
// allow other projects to override the FA colors
drupal_alter('foundation_access_colors', $color, $current);
// see if we have something that could be valid hex
if (strlen($color) == 6 || strlen($color) == 3) {
$complement = '#' . _foundation_access_complement($color);
$color = '#' . $color;
$css .= '.foundation_access-' . $current . "_color{color:{$color};}";
// specialized additions for each wheel value
switch ($current) {
case 'primary':
$css .= ".etb-book h1,.etb-book h2 {color: {$color};}";
break;
case 'secondary':
$css .= ".etb-book h3,.etb-book h4,.etb-book h5 {color: {$color};}";
break;
case 'required':
$css .= "div.textbook_box_required li:hover:before{border-color: {$color};} div.textbook_box_required li:before {color: {$complement}; background: {$color};} div.textbook_box_required { border: 2px solid {$color};} .textbook_box_required h3 {color: {$color};}";
break;
case 'optional':
$css .= "div.textbook_box_optional li:hover:before{border-color: {$color};} div.textbook_box_optional li:before {color: {$complement}; background: {$color};} div.textbook_box_optional { border: 2px solid {$color};} .textbook_box_optional h3 {color: {$color};}";
break;
}
}
}
drupal_add_css($css, array('type' => 'inline', 'group' => CSS_THEME, 'weight' => 1000));
drupal_add_css('//fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic,700italic|Open+Sans:300,600,700)', array('type' => 'external', 'group' => CSS_THEME));
// theme path shorthand should be handled here
$variables['theme_path'] = base_path() . drupal_get_path('theme', 'foundation_access');
foreach ($variables['user']->roles as $role) {
$variables['classes_array'][] = 'role-' . drupal_html_class($role);
}
// add page level variables into scope for the html tpl file
$variables['site_name'] = check_plain(variable_get('site_name', 'ELMSLN'));
$variables['logo'] = theme_get_setting('logo');
$variables['logo_img'] = '';
// make sure we have a logo before trying to render a real one to screen
if (!empty($variables['logo'])) {
$variables['logo_img'] = l(theme('image', array('path' => $variables['logo'], 'alt' => strip_tags($variables['site_name']) . ' ' . t('logo'), 'title' => strip_tags($variables['site_name']) . ' ' . t('Home'), 'attributes' => array('class' => array('logo__img')))), '<front>', array('html' => TRUE));
}
// add logo style classes to the logo element
$logo_classes = array();
$logo_option = theme_get_setting('foundation_access_logo_options');
if (isset($logo_option) && !is_null($logo_option)) {
$logo_classes[] = 'logo--' . $logo_option;
}
$variables['logo_classes'] = implode(' ', $logo_classes);
// support in-domain XSS exceptions
if (module_exists('cis_connector')) {
$variables['parent_origin'] = _cis_connector_parent_domain();
}
}
示例7: drupal_alter
/**
* Overwrites LazyPluginCollection::get().
*/
public function &get($instance_id)
{
/* @var \Drupal\restful\Plugin\resource\ResourceInterface $resource */
$resource = parent::get($instance_id);
// Allow altering the resource, this way we can read the resource's
// definition to return a different class that is using composition.
drupal_alter('restful_resource', $resource);
$resource = $resource->isEnabled() ? $resource : NULL;
return $resource;
}
示例8: foundation_access_menu_link_alter
/**
* Implements hook_menu_link_alter().
*
* Allow Foundation Access to affect the menu links table
* so that we can allow other projects to store an icon
* representation of what we're working on or status information
* about it.
*
*/
function foundation_access_menu_link_alter(&$item)
{
// this allows other projects to influence the icon seletion for menu items
$icon = 'page';
// #href proprety expected for use in the FA menu item icon
$item['#href'] = $item['link_path'];
// support for the primary theme used with MOOC platform
drupal_alter('foundation_access_menu_item_icon', $icon, $item);
// store the calculated icon here
$item['options']['fa_icon'] = $icon;
}
示例9: __construct
public function __construct()
{
// Allow other modules to add stuff in there
$this->map = module_invoke_all('usync_path_map');
drupal_alter('usync_path_map', $this->map);
foreach ($this->map as $pattern => $class) {
if (!class_exists($class)) {
unset($this->pathMap[$pattern]);
trigger_error(sprintf("Class '%s' does not exist", $class), E_USER_ERROR);
}
}
}
示例10: getEditorAttachments
/**
* Implements QuickEditEditorSelectorInterface::getEditorAttachments().
*/
public function getEditorAttachments(array $editor_ids)
{
$attachments = array();
$editor_ids = array_unique($editor_ids);
// Editor plugins' attachments.
foreach ($editor_ids as $editor_id) {
$editor_plugin = _quickedit_get_editor_plugin($editor_id);
$attachments[$editor_id] = $editor_plugin->getAttachments();
// Allows contrib to declare additional dependencies for the editor.
drupal_alter('quickedit_editor_attachments', $attachments[$editor_id], $editor_id);
}
return drupal_array_merge_deep_array($attachments);
}
示例11: settingsForm
/**
* Implements Drupal\field\Plugin\Type\Widget\WidgetInterface::settingsForm().
*/
public function settingsForm(array $form, array &$form_state)
{
$field = $this->field;
$instance = $this->instance;
if (empty($settings['date_date_format'])) {
$settings['date_date_format'] = variable_get('date_format_html_date', 'Y-m-d') . ' ' . variable_get('date_format_html_time', 'H:i:s');
}
$element = array('#element_validate' => array('date_field_widget_settings_form_validate'));
$element['year_range'] = array('#type' => 'date_year_range', '#default_value' => $this->getSetting('year_range'), '#fieldset' => 'date_format', '#weight' => 6);
$element['increment'] = array('#type' => 'select', '#title' => t('Time increments'), '#default_value' => $this->getSetting('increment'), '#options' => array(1 => t('1 minute'), 5 => t('5 minute'), 10 => t('10 minute'), 15 => t('15 minute'), 30 => t('30 minute')), '#weight' => 7, '#fieldset' => 'date_format');
$context = array('field' => $field, 'instance' => $instance);
drupal_alter('date_field_widget_settings_form', $element, $context);
return $element;
}
示例12: render_block_content
/**
* 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;
}
示例13: getQueues
/**
* {@inheritdoc}
*/
public function getQueues()
{
if (!isset(static::$queues)) {
static::$queues = module_invoke_all('cron_queue_info');
drupal_alter('cron_queue_info', static::$queues);
// Merge in queues from modules that implement hook_queue_info.
// Currently only defined by the queue_ui module.
$info_queues = module_invoke_all('queue_info');
foreach ($info_queues as $name => $queue) {
static::$queues[$name]['worker callback'] = $queue['cron']['callback'];
if (isset($queue['cron']['time'])) {
static::$queues[$name]['time'] = $queue['cron']['time'];
}
}
}
return static::$queues;
}
示例14: viewElements
/**
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
*
*
* Useful values:
*
* $entity->date_id
* If set, this will show only an individual date on a field with
* multiple dates. The value should be a string that contains
* the following values, separated with periods:
* - module name of the module adding the item
* - node nid
* - field name
* - delta value of the field to be displayed
* - other information the module's custom theme might need
*
* Used by the calendar module and available for other uses.
* example: 'date:217:field_date:3:test'
*
* $entity->date_repeat_show
* If true, tells the theme to show all the computed values
* of a repeating date. If not true or not set, only the
* start date and the repeat rule will be displayed.
*/
public function viewElements(EntityInterface $entity, $langcode, array $items)
{
$field = $this->field;
$instance = $this->instance;
$settings = $this->settings;
$view_mode = $this->viewMode;
$weight = $this->weight;
$label = $this->label;
$definition = $this->getDefinition();
$formatter = $definition['id'];
$elements = array();
$variables = array('entity' => $entity, 'field' => $field, 'instance' => $instance, 'langcode' => $langcode, 'items' => $items, 'dates' => array(), 'attributes' => array(), 'rdf_mapping' => array(), 'add_rdf' => module_exists('rdf'));
// If there is an RDf mapping for this date field, pass it down to the theme.
$rdf_mapping = array();
if (!empty($entity->rdf_mapping) && function_exists('rdf_rdfa_attributes')) {
if (!empty($entity->rdf_mapping[$field['field_name']])) {
$variables['rdf_mapping'] = $rdf_mapping = $entity->rdf_mapping[$field['field_name']];
}
}
// Give other modules a chance to prepare the entity before formatting it.
drupal_alter('date_formatter_pre_view', $entity, $variables);
// See if we are only supposed to display a selected
// item from multiple value date fields.
$selected_deltas = array();
if (!empty($entity->date_id)) {
foreach ((array) $entity->date_id as $key => $id) {
list($module, $nid, $field_name, $selected_delta, $other) = explode('.', $id . '.');
if ($field_name == $field['field_name']) {
$selected_deltas[] = $selected_delta;
}
}
}
foreach ($items as $delta => $item) {
if (!empty($entity->date_id) && !in_array($delta, $selected_deltas)) {
continue;
} else {
if (empty($item['value2']) || $item['value'] == $item['value2']) {
$elements[$delta] = array('#markup' => $item['value']);
} else {
$elements[$delta] = array('#markup' => t('!start-date to !end-date', array('!start-date' => $item['value'], '!end-date' => $item['value2'])));
}
}
}
return $elements;
}
示例15: get_queues
/**
* 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;
}