Esempio n. 1
0
/**
 * This is an example call that will snake a vset across everything in the network.
 * The example is silly but it illustrates a non-blocking snake that you can kick off
 * for high performance network propegation of data without invoking N+1 load
 * against the system. This is an intentional recursive call that will spider
 * the call against everything in the snake that kicks it off. This is awesome.
 *
 * In your data you need
 * __snake_stack      array   array of tool machine names to hit in the order of occurance
 * __course_context   string  the initial course context to send the call from.
 */
function _example_module_to_snake_a_call()
{
    // grab the registry keys
    $settings = _cis_connector_build_registry();
    // remove the current item
    unset($settings[elmsln_core_get_profile_key()]);
    // build the snake off the keys
    $snake = array_keys($settings);
    // abstract the first bucket to call our snake
    $bucket = array_pop($snake);
    // if a service, hit service address, if not hit root
    if (_cis_connector_system_type($bucket) == 'service') {
        $path = '/' . _cis_connector_course_context() . '/';
    } else {
        $path = '/';
    }
    // prep the head of the snake
    $request = array('method' => 'POST', 'api' => '1', 'bucket' => $bucket, 'path' => $path, 'data' => array('elmsln_module' => 'elmsln_api', 'elmsln_callback' => 'vset', 'name' => 'site_name', 'value' => 'asdd', '__snake_stack' => $snake, '__course_context' => _cis_connector_course_context()));
    _elmsln_api_request($request);
}
Esempio n. 2
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]);
            }
        }
    }
}