/**
 * Implements hook_form_FORM_ID_alter().
 */
function foundation_access_form_system_theme_settings_alter(&$form, &$form_state)
{
    $form['zurb_foundation']['foundation_access'] = array('#type' => 'fieldset', '#title' => t('Foundation Access'));
    // system label
    $distro = elmsln_core_get_profile_key();
    $reg = _cis_connector_build_registry($distro);
    $system = theme_get_setting('foundation_access_system_label');
    $form['zurb_foundation']['foundation_access']['foundation_access_system_label'] = array('#type' => 'textfield', '#title' => t('Service label'), '#description' => t('The name displayed at the top left to indicate to users what system they are using. Defaults to the one provided by the registry.'), '#default_value' => empty($system) ? $reg['default_title'] : $system);
    // allow for jquery colorpicker selection widget
    if (module_exists('jquery_colorpicker')) {
        $fieldtype = 'jquery_colorpicker';
    } else {
        $fieldtype = 'textfield';
    }
    $form['zurb_foundation']['foundation_access']['foundation_access_primary_color'] = array('#type' => $fieldtype, '#size' => 6, '#maxlength' => 6, '#title' => t('Primary Color'), '#description' => t('Primary color to apply throughout the system'), '#default_value' => theme_get_setting('foundation_access_primary_color'), '#id' => 'foundation_access_primary_color', '#suffix' => '<div>' . l(t('Clear'), '#', array('html' => TRUE, 'attributes' => array('onclick' => 'jQuery(\'#foundation_access_primary_color\').val(\'\'); jQuery(\'#foundation_access_primary_color\').parents(\'.color_picker\').css("backgroundColor", "#FFF"); return false'))) . '</div>');
    $form['zurb_foundation']['foundation_access']['foundation_access_secondary_color'] = array('#type' => $fieldtype, '#size' => 6, '#maxlength' => 6, '#title' => t('Secondary Color'), '#description' => t('A Secondary color to apply throughout the system'), '#default_value' => theme_get_setting('foundation_access_secondary_color'), '#id' => 'foundation_access_secondary_color', '#suffix' => '<div>' . l(t('Clear'), '#', array('html' => TRUE, 'attributes' => array('onclick' => 'jQuery(\'#foundation_access_secondary_color\').val(\'\'); jQuery(\'#foundation_access_secondary_color\').parents(\'.color_picker\').css("backgroundColor", "#FFF"); return false'))) . '</div>');
    $form['zurb_foundation']['foundation_access']['foundation_access_required_color'] = array('#type' => $fieldtype, '#size' => 6, '#maxlength' => 6, '#title' => t('Required Color'), '#description' => t('Tasks and lists that are required will pick up this color'), '#default_value' => theme_get_setting('foundation_access_required_color'), '#id' => 'foundation_access_required_color', '#suffix' => '<div>' . l(t('Clear'), '#', array('html' => TRUE, 'attributes' => array('onclick' => 'jQuery(\'#foundation_access_required_color\').val(\'\'); jQuery(\'#foundation_access_required_color\').parents(\'.color_picker\').css("backgroundColor", "#FFF"); return false'))) . '</div>');
    $form['zurb_foundation']['foundation_access']['foundation_access_optional_color'] = array('#type' => $fieldtype, '#size' => 6, '#maxlength' => 6, '#title' => t('Optional Color'), '#description' => t('Tasks and lists that are optional will pick up this color'), '#id' => 'foundation_access_optional_color', '#suffix' => '<div>' . l(t('Clear'), '#', array('html' => TRUE, 'attributes' => array('onclick' => 'jQuery(\'#foundation_access_optional_color\').val(\'\'); jQuery(\'#foundation_access_optional_color\').parents(\'.color_picker\').css("backgroundColor", "#FFF"); return false'))) . '</div>');
    $form['zurb_foundation']['foundation_access']['foundation_access_logo_options'] = array('#type' => 'radios', '#options' => array('fullwidth' => 'Full Width', 'left' => 'Left', 'center' => 'Center', 'right' => 'Right'), '#title' => t('Logo Style Options'), '#description' => t('Choose a logo style that you prefer.'), '#default_value' => theme_get_setting('foundation_access_logo_options'));
}
/**
 * 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);
}
Example #3
0
/**
 * Implements template_menu_link.
 */
function foundation_access_menu_link(&$variables)
{
    $element = $variables['element'];
    $sub_menu = '';
    $title = check_plain($element['#title']);
    if ($element['#below']) {
        $sub_menu = drupal_render($element['#below']);
    }
    // special handling for node based menu items
    if ($element['#original_link']['router_path'] == 'node/%') {
        $element['#localized_options']['html'] = TRUE;
        if ($element['#below']) {
            $element['#localized_options']['attributes']['class'][] = 'has-children';
        }
        // see if we have a localized override
        if (isset($element['#localized_options']['fa_icon'])) {
            $icon = $element['#localized_options']['fa_icon'];
        }
        // prefix node based titles with an icon
        if (isset($icon) && !empty($icon)) {
            $title = '<div class="elmsln-icon icon-' . $icon . ' outline-nav-icon"></div>' . $title;
        } else {
            $title = '<div class="outline-nav-icon"></div>' . $title;
        }
    }
    // support for add menu to get floating classes
    if ($element['#original_link']['menu_name'] == 'menu-elmsln-add') {
        $element['#localized_options']['attributes']['class'][] = 'btn-floating';
        $element['#localized_options']['attributes']['class'][] = 'elmsln-btn-floating';
        // load up a map of icons and color associations
        $icon_map = _elmsln_core_icon_map();
        $icon = str_replace(' ', '_', drupal_strtolower($title));
        if (isset($icon_map[$icon])) {
            if (strpos($element['#href'], 'elmsln/redirect') === 0) {
                $element['#localized_options']['attributes']['class'][] = 'elmsln-core-external-context-apply';
            }
            $element['#localized_options']['attributes']['class'][] = $icon_map[$icon]['color'];
            $title = '<i class="material-icons white-text left">' . $icon_map[$icon]['icon'] . '</i>' . $title;
            $element['#localized_options']['html'] = TRUE;
        } else {
            $lmsless_classes = _cis_lmsless_get_distro_classes(elmsln_core_get_profile_key());
            $element['#localized_options']['attributes']['class'][] = $lmsless_classes['color'];
            $element['#localized_options']['attributes']['class'][] = 'black-text';
            $element['#localized_options']['attributes']['class'][] = $lmsless_classes['light'];
        }
    }
    // @todo apply tabs here when we get the targetting / style figured out
    if ($element['#original_link']['menu_name'] == 'menu-elmsln-navigation') {
        $lmsless_classes = _cis_lmsless_get_distro_classes(elmsln_core_get_profile_key());
        $element['#attributes']['class'][] = 'tab';
        $element['#localized_options']['attributes']['class'][] = $lmsless_classes['text'];
        $element['#localized_options']['attributes']['target'] = '_self';
    }
    $output = l($title, $element['#href'], $element['#localized_options']);
    return '<li' . drupal_attributes($element['#attributes']) . '>' . $output . $sub_menu . "</li>\n";
}
Example #4
0
/**
 * Default theme function for video.
 */
function mooc_foundation_access_read_time($variables)
{
    $lmsless_classes = _cis_lmsless_get_distro_classes(elmsln_core_get_profile_key());
    $defaults = read_time_defaults();
    $node = $variables['node'];
    // add in the children element to all totals if they exist
    if (isset($node->read_time['metadata']['children'])) {
        foreach ($node->read_time['metadata']['children'] as $key => $value) {
            if (!isset($node->read_time[$key])) {
                $node->read_time[$key] = 0;
            }
            $node->read_time[$key] += $value;
        }
    }
    // Get read time bundle settings.
    $format = variable_get('read_time_format_' . $node->type, $defaults['format']);
    $display = variable_get('read_time_display_' . $node->type, $defaults['display']);
    $wpm = variable_get('read_time_wpm_' . $node->type, $defaults['wpm']);
    // convert words into time
    if (isset($node->read_time['words'])) {
        $time = round($node->read_time['words'] / $wpm, 3);
    } else {
        $time = 0;
    }
    // Format read time.
    if (in_array($format, array('hour_short', 'hour_long'))) {
        $hours = floor($time / 60);
        $minutes = ceil(fmod($time, 60));
    } else {
        $minutes = ceil($time);
    }
    if (in_array($format, array('hour_long', 'min_long'))) {
        $hour_suffix = 'hour';
        $min_suffix = 'minute';
    } else {
        $hour_suffix = 'hr';
        $min_suffix = 'min';
    }
    $minute_format = format_plural($minutes, '1 ' . $min_suffix, '@count ' . $min_suffix . 's');
    if (!empty($hours)) {
        $hour_format = format_plural($hours, '1 ' . $hour_suffix, '@count ' . $hour_suffix . 's');
        $read_time = format_string('@h, @m', array('@h' => $hour_format, '@m' => $minute_format));
    } else {
        $read_time = $minute_format;
    }
    $node->read_time['words'] = $read_time;
    // chip read time is different
    $output = '<div class="read-time-wrapper">';
    // pick out the chips
    foreach ($node->read_time as $key => $value) {
        if ($value != 0 && $key != 'metadata') {
            $label = '';
            switch ($key) {
                case 'words':
                    $label = t('Reading');
                    $icon = '<i class="tiny material-icons ' . $lmsless_classes['text'] . '">library_books</i>';
                    break;
                case 'audio':
                    $label = t('Audio');
                    $value .= ' ' . $label;
                    // support for duration if we've got it assembled
                    if (isset($node->read_time['metadata']['audio']['duration']) || isset($node->read_time['metadata']['children']['audio_duration'])) {
                        $duration = 0;
                        if (isset($node->read_time['metadata']['audio']['duration'])) {
                            $duration += $node->read_time['metadata']['audio']['duration'];
                        }
                        if (isset($node->read_time['metadata']['children']['audio_duration'])) {
                            $duration += $node->read_time['metadata']['children']['audio_duration'];
                        }
                        // account for possibility of not reading duration off media
                        if ($duration == 0) {
                        } elseif ($duration < 60) {
                            $value .= ' ' . t('(@duration sec)', array('@duration' => $duration));
                        } elseif ($duration < 3600) {
                            $value .= ' ' . t('(@duration mins)', array('@duration' => round($duration / 60, 1)));
                        } else {
                            $value .= ' ' . t('(@duration hours)', array('@duration' => round($duration / 3600, 1)));
                        }
                    }
                    $icon = '<i class="tiny material-icons ' . $lmsless_classes['text'] . '">library_music</i>';
                    break;
                case 'iframe':
                    $icon = '<i class="tiny material-icons ' . $lmsless_classes['text'] . '">launch</i>';
                    break;
                case 'img':
                    $label = t('Image');
                    $value = format_plural($value, '1 ' . $label, '@count ' . $label . 's');
                    $icon = '<i class="tiny material-icons ' . $lmsless_classes['text'] . '">perm_media</i>';
                    break;
                case 'svg':
                    $label = t('Multimedia');
                    $value = $value . ' ' . $label;
                    $icon = '<i class="tiny material-icons ' . $lmsless_classes['text'] . '">assessment</i>';
                    break;
                case 'video':
                    $label = t('Video');
                    $value = format_plural($value, '1 ' . $label, '@count ' . $label . 's');
                    // support for duration if we've got it assembled
                    if (isset($node->read_time['metadata']['video']['duration']) || isset($node->read_time['metadata']['children']['video_duration'])) {
                        $duration = 0;
                        if (isset($node->read_time['metadata']['video']['duration'])) {
                            $duration += $node->read_time['metadata']['video']['duration'];
                        }
                        if (isset($node->read_time['metadata']['children']['video_duration'])) {
                            $duration += $node->read_time['metadata']['children']['video_duration'];
                        }
                        // account for possibility of not reading duration off media
                        if ($duration == 0) {
                        } elseif ($duration < 60) {
                            $value .= ' ' . t('(@duration sec)', array('@duration' => $duration));
                        } elseif ($duration < 3600) {
                            $value .= ' ' . t('(@duration mins)', array('@duration' => round($duration / 60, 1)));
                        } else {
                            $value .= ' ' . t('(@duration hours)', array('@duration' => round($duration / 3600, 1)));
                        }
                    }
                    $icon = '<i class="tiny material-icons ' . $lmsless_classes['text'] . '">video_library</i>';
                    break;
                default:
                    $icon = '';
                    $value = '';
                    break;
            }
            // make sure there's something to render
            if (!empty($value)) {
                $output .= '<div class="chip ' . $lmsless_classes['color'] . ' ' . $lmsless_classes['light'] . '">' . $icon . check_plain(empty($label) ? $value . ' ' . ucwords($key) : $value) . '</div>';
            }
        }
    }
    $output .= '</div>';
    return '<span class="read-time">' . $output . '</span>';
}