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;
 }
Exemplo n.º 2
0
 /**
  * {@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();
 }
 /**
  * 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);
 }
Exemplo n.º 4
0
 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);
 }
Exemplo n.º 5
0
 /**
  * {@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;
 }
Exemplo n.º 6
0
/**
 * 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();
    }
}
 /**
  * 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;
 }
Exemplo n.º 8
0
/**
 * 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;
}
 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);
         }
     }
 }
Exemplo n.º 10
0
 /**
  * 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);
 }
Exemplo n.º 11
0
 /**
  * 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;
 }
Exemplo n.º 12
0
/**
 * 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;
}
Exemplo n.º 13
0
 /**
  * {@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;
 }
 /**
  * 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;
 }
Exemplo n.º 15
0
 /**
  * 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;
 }
 /**
  * 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);
 }
Exemplo n.º 17
0
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $request = $event->getRequest();
     if (null === $this->matcher || $this->matcher->matches($request)) {
         $exception = $event->getException();
         $code = $exception instanceof HttpExceptionInterface ? $exception->getStatusCode() : 500;
         switch ($code) {
             case 403:
                 $page_callback_result = MENU_ACCESS_DENIED;
                 break;
             case 404:
                 $page_callback_result = MENU_NOT_FOUND;
                 break;
             case 503:
                 $page_callback_result = MENU_SITE_OFFLINE;
                 break;
             default:
                 return;
         }
         $router_item = $request->attributes->get('router_item', array());
         $default_delivery_callback = NULL;
         if (!isset($default_delivery_callback)) {
             $default_delivery_callback = $router_item['delivery_callback'];
         }
         $delivery_callback = !empty($default_delivery_callback) ? $default_delivery_callback : 'drupal_deliver_html_page';
         // Give modules a chance to alter the delivery callback used, based on
         // request-time context (e.g., HTTP request headers).
         drupal_alter('page_delivery_callback', $delivery_callback);
         if (function_exists($delivery_callback)) {
             $delivery_callback = function ($page_callback_result) use($delivery_callback) {
                 ob_start();
                 $delivery_callback($page_callback_result);
                 return new Response((string) ob_get_clean());
             };
             $event->setResponse($delivery_callback($page_callback_result));
         } else {
             // If a delivery callback is specified, but doesn't exist as a function,
             // something is wrong, but don't print anything, since it's not known
             // what format the response needs to be in.
             watchdog('delivery callback not found', 'callback %callback not found: %q.', array('%callback' => $delivery_callback, '%q' => $_GET['q']), WATCHDOG_ERROR);
         }
     }
 }
Exemplo n.º 18
0
/**
 * Filter known errors so do not log them to Sentry again and again.
 *
 * @param array $error
 *   A reference to array containing error info.
 */
function hook_raven_error_filter_alter(array &$error)
{
    $known_errors = array();
    drupal_alter('raven_known_php_errors', $known_errors);
    // Filter known errors to prevent spamming the Sentry server.
    foreach ($known_errors as $known_error) {
        $check = TRUE;
        foreach ($known_error as $key => $value) {
            if ($error[$key] != $value) {
                $check = FALSE;
                break;
            }
        }
        if ($check) {
            $error['process'] = FALSE;
            break;
        }
    }
}
 /**
  *  @method:
  *    this method is used to standardize the data before returning the items to the processor
  *    allows others to modify the data before saving to ensure that there fields that are filled out
  */
 public function _getty_bib_standardized_handler(&$items, $type = NULL)
 {
     $required_fields = array('title' => 'Getty - Bib - No Title - @time', '_import_type' => $type);
     //allows other modules to alter this before it comes out
     drupal_alter('getty_bib_required_parser', $required_fields, $type);
     //does for each items
     foreach ($items as $key => $values) {
         $diff = array_diff($required_fields, $values);
         //only continue if diff is not empty
         if (!empty($diff)) {
             foreach ($diff as $required_field => $field_value) {
                 if (empty($items[$key][$required_field])) {
                     $items[$key][$required_field] = t($field_value, array('@time' => REQUEST_TIME));
                 }
             }
         }
     }
     //allows other modules to hook in and alter the items before processor
     drupal_alter('getty_bib_items_parser', $items, $type);
 }
Exemplo n.º 20
0
 /**
  * Overrides MessageDigest::aggregate().
  *
  * Collects notifications waiting to be sent based on the current day/time
  * and how the recipient wants to be notified.
  */
 public function aggregate()
 {
     $user_frequencies = $this->getRecipientFrequencies();
     // Preload user objects to save some queries.
     $users = user_load_multiple(array_keys($user_frequencies));
     $rows = db_select('message_digest', 'm')->fields('m')->condition('sent', FALSE)->condition('notifier', $this->plugin['name'])->execute();
     // Collect all notifications waiting to be sent and group by user.
     $message_groups = array();
     foreach ($rows as $row) {
         $account = user_load($row->receiver);
         $context = array('account' => $account, 'data' => $row, 'gid' => $row->gid, 'plugin' => $this->plugin);
         drupal_alter('message_digest_aggregate', $context);
         $message_groups[$row->receiver][$row->gid][] = $row->mid;
     }
     $time_to_send_daily = $this->isTimeForDaily();
     $time_to_send_weekly = $this->isTimeForWeekly();
     // Check user preference for notification frequency and hold all messages
     // that are not ready to be sent.
     foreach ($message_groups as $uid => $groups) {
         $user = user_load($uid);
         $user_frequency = $user_frequencies[$uid];
         // If the user is no longer valid or does not want notifications
         // we just clear out all the waiting notifications.
         if (!$user || $user_frequency == NOTIFICATION_FREQUENCY_NEVER) {
             unset($message_groups[$uid]);
             $this->markSent($uid, $this->plugin['name']);
         }
         if ($user_frequency == NOTIFICATION_FREQUENCY_DAILY && !$time_to_send_daily) {
             unset($message_groups[$uid]);
         }
         if ($user_frequency == NOTIFICATION_FREQUENCY_WEEKLY && !$time_to_send_weekly) {
             unset($message_groups[$uid]);
         }
         if ($user_frequency == NOTIFICATION_FREQUENCY_IMMEDIATE) {
             // The user has changed their preference, let a digest be sent now.
         }
     }
     return $message_groups;
 }
Exemplo n.º 21
0
 /**
  * Execute the search for current page.
  */
 protected function execute($params)
 {
     // Add start index (page number we want)
     $this->start = $params['page'] * $this->resultsPerPage;
     $this->parameters[] = new Parameter\Start($this->start);
     // Add items / page.
     $this->parameters[] = new Parameter\Rows($this->resultsPerPage);
     // Add grouping so returned data is not duplicate.
     $this->parameters[] = new Parameter\Group($this->group);
     // Add spellcheck if needed
     if (!empty($this->query[0])) {
         $this->parameters[] = new Parameter\Parameter('spellcheck', 'true');
         $this->parameters[] = new Parameter\Parameter('spellcheckQuery', $this->query[0]);
     } else {
         $this->parameters[] = new Parameter\Parameter('spellcheck', 'false');
     }
     drupal_alter('culturefeed_search_page_query', $this);
     // Prepare the search query and add to the search parameters.
     $this->parameters[] = $this->prepareQuery();
     $this->result = culturefeed_get_search_service()->searchPages($this->parameters);
     $this->facetComponent->obtainResults($this->result);
 }
Exemplo n.º 22
0
 function XlmsSession($id = NULL, $result_id = NULL)
 {
     if ($id) {
         $result = db_query("SELECT * FROM {xlms_session} WHERE id=:id", array(':id' => $id));
     }
     if ($result_id) {
         $result = db_query("SELECT * FROM {xlms_session} WHERE result_id=:result_id", array(':result_id' => $result_id));
     }
     if (is_object($result)) {
         foreach ($result->fetchObject() as $property => $value) {
             if (property_exists($this, $property)) {
                 $this->{$property} = $value;
             }
         }
         if (isset($this->session_data)) {
             $this->session_data = unserialize($this->session_data);
         }
         $this->kurento_url = $this->kurentoUrl();
         $this->kurento_video_directory = $this->kurentoVideoDirectory();
     }
     drupal_alter('xlms_session_load', $this);
 }
 /**
  * Implements \Drupal\block\BlockBase::build().
  */
 public function build()
 {
     // Get the current slider settings.
     $config = config('nivo_slider.settings');
     $build = array('#type' => 'markup', '#theme' => 'nivo_slider_wrapper', '#attached' => array('libraries_load' => array(array('nivo-slider')), 'js' => array(array('data' => drupal_get_path('module', 'nivo_slider') . '/js/nivo_slider.js', 'type' => 'file'), array('data' => array('nivo_slider' => array('effect' => check_plain($config->get('options.effect')), 'slices' => (int) check_plain($config->get('options.slices')), 'boxCols' => (int) check_plain($config->get('options.box_columns')), 'boxRows' => (int) check_plain($config->get('options.box_rows')), 'animSpeed' => (int) check_plain($config->get('options.animation_speed')), 'pauseTime' => (int) check_plain($config->get('options.pause_time')), 'startSlide' => (int) check_plain($config->get('options.start_slide')), 'directionNav' => check_plain($config->get('options.directional_navigation')) == 1 ? TRUE : FALSE, 'controlNav' => check_plain($config->get('options.control_navigation')) == 1 ? TRUE : FALSE, 'controlNavThumbs' => check_plain($config->get('options.control_nav_thumbs')) == 1 ? TRUE : FALSE, 'pauseOnHover' => check_plain($config->get('options.pause_on_hover')) == 1 ? TRUE : FALSE, 'manualAdvance' => check_plain($config->get('options.manual_advance')) == 1 ? TRUE : FALSE, 'prevText' => check_plain($config->get('options.previous_text')), 'nextText' => check_plain($config->get('options.next_text')), 'randomStart' => check_plain($config->get('options.random_start')) == 1 ? TRUE : FALSE)), 'type' => 'setting')), 'css' => array()));
     // Collect all themes
     $themes = module_invoke_all('nivo_slider_theme_info');
     // Allow theme information to be altered
     drupal_alter('nivo_slider_theme_info', $themes);
     // Find the currently selected theme
     $current_theme = $config->get('options.theme');
     // Get the current theme's settings
     $theme = $themes[$current_theme];
     // Add the theme's resources
     foreach (array('js', 'css') as $type) {
         if (!empty($theme['resources'][$type])) {
             foreach ($theme['resources'][$type] as $file_path) {
                 $build['content']['#attached'][$type][] = $file_path;
             }
         }
     }
     return $build;
 }
 /**
  * Helper method: pass a query to the alteration system again.
  *
  * This allow Entity Reference to add a tag to an existing query, to ask
  * access control mechanisms to alter it again.
  */
 protected function reAlterQuery(SelectQueryInterface $query, $tag, $base_table)
 {
     // Save the old tags and metadata.
     // For some reason, those are public.
     $old_tags = $query->alterTags;
     $old_metadata = $query->alterMetaData;
     $query->alterTags = array($tag => TRUE);
     $query->alterMetaData['base_table'] = $base_table;
     drupal_alter(array('query', 'query_' . $tag), $query);
     // Restore the tags and metadata.
     $query->alterTags = $old_tags;
     $query->alterMetaData = $old_metadata;
 }
Exemplo n.º 25
0
 /**
  * {@inheritdoc}
  */
 public function postBuild(array &$build, ObjectInterface $context = NULL)
 {
     foreach ($this->getCollection()->getFlatList() as $object) {
         if ($object !== $this) {
             $object->postBuild($build, $context);
         }
     }
     drupal_alter('openlayers_object_postprocess', $build, $this);
 }
 /**
  * Render the panels display for a given panelizer entity.
  *
  * @param stdClass $entity
  *   A fully-loaded entity object controlled by panelizer.
  * @param array $args
  *   Optional array of arguments to pass to the panels display.
  * @param string $address
  *   An optional address to send to the renderer to use for addressable
  *   content.
  * @param array $extra_contexts
  *   An optional array of extra context objects that will be added to the
  *   display.
  *
  * @return array
  *   If the entity isn't panelized, this returns NULL. Otherwise, it returns an
  *   associative array as meant for use with CTools with the following keys:
  *   - 'content': String containing the rendered panels display output.
  *   - 'no_blocks': Boolean defining if the panels display wants to hide core
  *      blocks or not when being rendered.
  */
 function render_entity($entity, $view_mode, $langcode = NULL, $args = array(), $address = NULL, $extra_contexts = array())
 {
     if (empty($entity->panelizer[$view_mode]) || empty($entity->panelizer[$view_mode]->display)) {
         return FALSE;
     }
     list($entity_id, $revision_id, $bundle) = entity_extract_ids($this->entity_type, $entity);
     $panelizer = $entity->panelizer[$view_mode];
     $display = $panelizer->display;
     $display->context = $this->get_contexts($panelizer, $entity) + $extra_contexts;
     $display->args = $args;
     $display->css_id = $panelizer->css_id;
     // This means the IPE will use our cache which means it will get appropriate
     // allowed content should it be selected.
     $display->cache_key = implode(':', array_filter(array('panelizer', $this->entity_type, $entity_id, $view_mode, $revision_id)));
     // Check to see if there is any CSS.
     if (!empty($panelizer->css)) {
         ctools_include('css');
         $filename = ctools_css_retrieve($display->cache_key);
         if (!$filename) {
             $filename = ctools_css_store($display->cache_key, $panelizer->css);
         }
         drupal_add_css($filename, array('group' => CSS_THEME));
     }
     if ($view_mode == 'page_manager') {
         // We think this is handled as a page, so set the current page display.
         panels_get_current_page_display($display);
     }
     // Allow applications to alter the panelizer and the display before rendering them.
     drupal_alter('panelizer_pre_render', $panelizer, $display, $entity);
     ctools_include('plugins', 'panels');
     $renderer = panels_get_renderer($panelizer->pipeline, $display);
     // If the IPE is enabled, but the user does not have access to edit
     // the entity, load the standard renderer instead.
     // Use class_parents so we don't try to autoload the class we are testing.
     $parents = class_parents($renderer);
     if (!empty($parents['panels_renderer_editor']) && (!$this->panelizer_access('content', $entity, $view_mode) && !$this->entity_access('update', $entity))) {
         $renderer = panels_get_renderer_handler('standard', $display);
     }
     $renderer->address = $address;
     $info = array('title' => $panelizer->display->get_title(), 'content' => panels_render_display($display, $renderer), 'no_blocks' => !empty($panelizer->no_blocks));
     $info['classes_array'] = array();
     if (!empty($panelizer->css_class)) {
         foreach (explode(' ', $panelizer->css_class) as $class) {
             $class = ctools_context_keyword_substitute($class, array(), $display->context);
             if ($class) {
                 $info['classes_array'][] = drupal_html_class($class);
             }
         }
     }
     if (!empty($parents['panels_renderer_editor'])) {
         $path = drupal_get_path('module', 'panelizer');
         ctools_add_js('panelizer-ipe', 'panelizer');
         drupal_add_js($path . "/js/panelizer-ipe.js", array('group' => JS_LIBRARY));
         drupal_add_css($path . "/css/panelizer-ipe.css");
     }
     return $info;
 }
Exemplo n.º 27
0
/**
 * Implements template_preprocess_page.
 */
function foundation_access_preprocess_page(&$variables)
{
    $variables['contentwrappers'] = _elmsln_core_path_is_wrapped(current_path());
    $menu_item = menu_get_item();
    // allow modules to supply accessibility enhancements to the menu
    $a11y = module_invoke_all('fa_a11y');
    drupal_alter('fa_a11y', $a11y);
    // add in the form api wrapper meta properties to render as materialize collapse
    $a11y['#type'] = 'fieldset';
    $a11y['#materialize'] = array('type' => 'collapsible_wrapper');
    $a11y['#attributes'] = array('class' => array('collapsible'), 'data-collapsible' => 'accordion');
    $variables['a11y'] = drupal_render($a11y);
    // sniff out if this is a view
    if ($menu_item['page_callback'] == 'views_page') {
        // try and auto append exposed filters to our local_subheader region
        $bid = '-exp-' . $menu_item['page_arguments'][0] . '-' . (is_array($menu_item['page_arguments'][1]) ? $menu_item['page_arguments'][1][0] : $menu_item['page_arguments'][1]);
        $block = module_invoke('views', 'block_view', $bid);
        $variables['page']['local_subheader'][$bid] = $block['content'];
    }
    $variables['distro'] = elmsln_core_get_profile_key();
    // make sure we have lmsless enabled so we don't WSOD
    $variables['cis_lmsless'] = array('active' => array('title' => ''));
    // support for lmsless since we don't require it
    if (module_exists('cis_lmsless')) {
        $variables['cis_lmsless'] = _cis_lmsless_theme_vars();
    }
    // support for cis_shortcodes
    if (module_exists('cis_shortcodes')) {
        $block = cis_shortcodes_block_view('cis_shortcodes_block');
        if (!empty($block['content'])) {
            $variables['cis_shortcodes'] = $block['content'];
        } else {
            $variables['cis_shortcodes'] = '';
        }
    } else {
        $variables['cis_shortcodes'] = '';
    }
    // support for entity_iframe
    if (module_exists('entity_iframe')) {
        $block = entity_iframe_block_view('entity_iframe_block');
        if (!empty($block['content'])) {
            $variables['cis_shortcodes'] .= $block['content'];
        }
    }
    // wrap non-node content in an article tag
    if (isset($variables['page']['content']['system_main']['main'])) {
        $variables['page']['content']['system_main']['main']['#markup'] = '<article class="l12 col view-mode-full">' . $variables['page']['content']['system_main']['main']['#markup'] . '</article>';
    }
    /**
     * @todo Get rid of this logic and put it somewhere else
     *       based on the new design.
     */
    // add a sharing url to view the specific section
    if (module_exists('cis_connector')) {
        $url_options = array('absolute' => TRUE);
        // check for setting section context
        $current_section = _cis_connector_section_context();
        if (isset($current_section) && $current_section) {
            $url_options['query']['elmsln_active_section'] = $current_section;
        }
        // check for setting course context
        $current_course = _cis_connector_course_context();
        if (isset($current_course) && $current_course) {
            $url_options['query']['elmsln_active_course'] = $current_course;
        }
        $current_page = url(current_path(), $url_options);
        // establish the fieldset container for shortcodes
        $field['cis_section_share'] = array('#type' => 'fieldset', '#collapsed' => FALSE, '#collapsible' => TRUE, '#title' => t('Share this page'));
        $field['cis_section_share']['cis_section_share_link'] = array('#title' => t('Page URL'), '#value' => $current_page, '#type' => 'textfield', '#weight' => 0);
        $variables['cis_section_share'] = $field;
    }
    // attempt to find an edit path for the current page
    if (isset($variables['tabs']) && is_array($variables['tabs']['#primary'])) {
        $edit_path = arg(0) . '/' . arg(1) . '/edit';
        foreach ($variables['tabs']['#primary'] as $key => $tab) {
            if (isset($tab['#link']['href']) && $tab['#link']['href'] == $edit_path) {
                $variables['edit_path'] = base_path() . $edit_path;
                // hide the edit tab cause our on canvas pencil does this
                unset($variables['tabs']['#primary'][$key]);
            }
        }
    }
}
Exemplo n.º 28
0
 /**
  * NOT TESTED
  * add a group entry
  *
  * @param string $group_dn as ldap dn
  * @param array $attributes in key value form
  *    $attributes = array(
  *      "attribute1" = "value",
  *      "attribute2" = array("value1", "value2"),
  *      )
  * @return boolean success
  */
 public function groupAddGroup($group_dn, $attributes = array())
 {
     //debug("this->dnExists(   $group_dn, boolean)"); debug($this->dnExists($group_dn, 'boolean'));
     // debug("this->dnExists(   $group_dn, boolean)"); debug($this->dnExists($group_dn));
     if ($this->dnExists($group_dn, 'boolean')) {
         return FALSE;
     }
     $attributes = array_change_key_case($attributes, CASE_LOWER);
     $objectclass = empty($attributes['objectclass']) ? $this->groupObjectClass : $attributes['objectclass'];
     $attributes['objectclass'] = $objectclass;
     /**
      * 2. give other modules a chance to add or alter attributes
      */
     $context = array('action' => 'add', 'corresponding_drupal_data' => array($group_dn => $attributes), 'corresponding_drupal_data_type' => 'group');
     $ldap_entries = array($group_dn => $attributes);
     drupal_alter('ldap_entry_pre_provision', $ldap_entries, $this, $context);
     $attributes = $ldap_entries[$group_dn];
     /**
      * 4. provision ldap entry
      *   @todo how is error handling done here?
      */
     $ldap_entry_created = $this->createLdapEntry($attributes, $group_dn);
     /**
      * 5. allow other modules to react to provisioned ldap entry
      *   @todo how is error handling done here?
      */
     if ($ldap_entry_created) {
         module_invoke_all('ldap_entry_post_provision', $ldap_entries, $this, $context);
         return TRUE;
     } else {
         return FALSE;
     }
 }
Exemplo n.º 29
0
 /**
  * decide if a username is excluded or not
  *
  * @param string $name as proposed drupal username
  * @param array $ldap_user where top level keys are 'dn','attr','mail'
  * @return boolean FALSE means NOT allow; TRUE means allow
  *
  * @todo.  this function should simply invoke hook_ldap_authentication_allowuser_results_alter
  *   and most of this function should go in ldap_authentication_allowuser_results_alter
  */
 public function allowUser($name, $ldap_user)
 {
     /**
      * do one of the exclude attribute pairs match
      */
     $ldap_user_conf = ldap_user_conf();
     // if user does not already exists and deferring to user settings AND user settings only allow
     $user_register = variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
     foreach ($this->excludeIfTextInDn as $test) {
         if (stripos($ldap_user['dn'], $test) !== FALSE) {
             return FALSE;
             //  if a match, return FALSE;
         }
     }
     /**
      * evaluate php if it exists
      */
     if ($this->allowTestPhp) {
         if (module_exists('php')) {
             global $_name, $_ldap_user_entry;
             $_name = $name;
             $_ldap_user_entry = $ldap_user;
             $code = '<?php ' . "global \$_name; \n  global \$_ldap_user_entry; \n" . $this->allowTestPhp . ' ?>';
             $code_result = php_eval($code);
             $_name = NULL;
             $_ldap_user_entry = NULL;
             if ((bool) $code_result == FALSE) {
                 return FALSE;
             }
         } else {
             drupal_set_message(t(LDAP_AUTHENTICATION_DISABLED_FOR_BAD_CONF_MSG), 'warning');
             $tokens = array('!ldap_authentication_config' => l(t('LDAP Authentication Configuration'), 'admin/config/people/ldap/authentication'));
             watchdog('ldap_authentication', 'LDAP Authentication is configured to deny users based on php execution with php_eval function, but php module is not enabled. Please enable php module or remove php code at !ldap_authentication_config .', $tokens);
             return FALSE;
         }
     }
     /**
      * do one of the allow attribute pairs match
      */
     if (count($this->allowOnlyIfTextInDn)) {
         $fail = TRUE;
         foreach ($this->allowOnlyIfTextInDn as $test) {
             if (stripos($ldap_user['dn'], $test) !== FALSE) {
                 $fail = FALSE;
             }
         }
         if ($fail) {
             return FALSE;
         }
     }
     /**
      * is excludeIfNoAuthorizations option enabled and user not granted any groups
      */
     if ($this->excludeIfNoAuthorizations) {
         if (!module_exists('ldap_authorization')) {
             drupal_set_message(t(LDAP_AUTHENTICATION_DISABLED_FOR_BAD_CONF_MSG), 'warning');
             $tokens = array('!ldap_authentication_config' => l(t('LDAP Authentication Configuration'), 'admin/config/people/ldap/authentication'));
             watchdog('ldap_authentication', 'LDAP Authentication is configured to deny users without LDAP Authorization mappings, but LDAP Authorization module is not enabled.  Please enable and configure LDAP Authorization or disable this option at !ldap_authentication_config .', $tokens);
             return FALSE;
         }
         $user = new stdClass();
         $user->name = $name;
         $user->ldap_authenticated = TRUE;
         // fake user property added for query
         $consumers = ldap_authorization_get_consumers();
         $has_enabled_consumers = FALSE;
         $has_ldap_authorizations = FALSE;
         foreach ($consumers as $consumer_type => $consumer_config) {
             $consumer_obj = ldap_authorization_get_consumer_object($consumer_type);
             if ($consumer_obj->consumerConf->status) {
                 $has_enabled_consumers = TRUE;
                 list($authorizations, $notifications) = ldap_authorizations_user_authorizations($user, 'query', $consumer_type, 'test_if_authorizations_granted');
                 if (isset($authorizations[$consumer_type]) && count($authorizations[$consumer_type]) > 0) {
                     $has_ldap_authorizations = TRUE;
                 }
             }
         }
         if (!$has_enabled_consumers) {
             drupal_set_message(t(LDAP_AUTHENTICATION_DISABLED_FOR_BAD_CONF_MSG), 'warning');
             $tokens = array('!ldap_consumer_config' => l(t('LDAP Authorization Configuration'), 'admin/config/people/ldap/authorization'));
             watchdog('ldap_authentication', 'LDAP Authentication is configured to deny users without LDAP Authorization mappings, but 0 LDAP Authorization consumers are configured:  !ldap_consumer_config .', $tokens);
             return FALSE;
         } elseif (!$has_ldap_authorizations) {
             return FALSE;
         }
     }
     // allow other modules to hook in and refuse if they like
     $hook_result = TRUE;
     drupal_alter('ldap_authentication_allowuser_results', $ldap_user, $name, $hook_result);
     if ($hook_result === FALSE) {
         watchdog('ldap_authentication', "Authentication Allow User Result=refused for %name", array('%name' => $name), WATCHDOG_NOTICE);
         return FALSE;
     }
     /**
      * default to allowed
      */
     return TRUE;
 }
Exemplo n.º 30
0
/**
 * Implements hook_page_alter().
 */
function alpha_page_alter(&$vars)
{
    $theme = alpha_get_theme();
    $theme->settings['debug']['access'] = alpha_debug_access($GLOBALS['user'], $theme->settings['debug']['roles']);
    // If no module has taken care of the main content, add it to the page now.
    // This allows the site to still be usable even if no modules that
    // control page regions (for example, the Block module) are enabled.
    if (!drupal_static('system_main_content_added', FALSE)) {
        $vars['content']['system_main'] = drupal_set_page_content();
    }
    if (($theme->settings['debug']['access'] || $GLOBALS['user']->uid == 1) && ($theme->settings['debug']['grid'] || $theme->settings['debug']['block'])) {
        drupal_add_css(drupal_get_path('theme', 'alpha') . '/css/alpha-debug.css', array('group' => CSS_THEME, 'weight' => -5));
        drupal_add_js(drupal_get_path('theme', 'alpha') . '/js/alpha-debug.js', array('group' => JS_THEME, 'weight' => -5));
        if ($theme->settings['responsive']) {
            $vars['page_bottom']['alpha_resize_indicator'] = array('#type' => 'markup', '#markup' => '<div class="alpha-resize-indicator"></div>');
        }
        if ($theme->settings['debug']['grid']) {
            $vars['page_bottom']['alpha_grid_toggle'] = array('#type' => 'markup', '#markup' => '<a class="alpha-grid-toggle" href="#"></a>');
        }
        if ($theme->settings['debug']['block']) {
            $vars['page_bottom']['alpha_block_toggle'] = array('#type' => 'markup', '#markup' => '<a class="alpha-block-toggle" href="#"></a>');
            foreach ($theme->regions as $region => $item) {
                if ($item['enabled']) {
                    if (empty($vars[$region])) {
                        $vars[$region]['#region'] = $region;
                        $vars[$region]['#theme_wrappers'] = array('region');
                    }
                    if (isset($vars[$region]['#theme_wrappers']) && array_search('region', $vars[$region]['#theme_wrappers']) !== FALSE) {
                        $vars[$region] = array('alpha_debug_' . $region => array('#type' => 'markup', '#markup' => '<div class="alpha-debug-block"><h2>' . $item['name'] . '</h2><p>' . t('This is a debugging block') . '</p></div>', '#weight' => -999)) + $vars[$region];
                    }
                }
            }
        }
    }
    if (!module_implements('alpha_page_structure_alter')) {
        alpha_alter('alpha_page_structure', $vars, $theme->theme);
    } else {
        drupal_alter('alpha_page_structure', $vars, $theme->theme);
    }
}