Ejemplo n.º 1
0
/**
 * Returns an indexed array of weekday rotated according to $first_day_of_week.
 * 
 * @param bool $abbr: if TRUE returns abbreviated weekday names.
 * @param int $first_day_of_week: index.
 */
function wcs3_get_indexed_weekdays($abbr = FALSE, $first_day_of_week = 0)
{
    $weekdays = wcs3_get_weekdays($abbr);
    $weekdays = array_flip($weekdays);
    if ($first_day_of_week > 0) {
        // Rotate array based on first day of week setting.
        $slice1 = array_slice($weekdays, $first_day_of_week);
        $slice2 = array_slice($weekdays, 0, $first_day_of_week);
        $weekdays = array_merge($slice1, $slice2);
    }
    $weekdays = apply_filters('wcs3_filter_indexed_weekdays', $weekdays);
    return $weekdays;
}
Ejemplo n.º 2
0
/**
 * Renders list layout
 * 
 * @param array $classes: classes array as returned by wcs3_get_classes().
 * @param string $location: location to render.
 * @param int $first_day_of_week: index.
 */
function wcs3_render_list_schedule($classes, $location, $weekdays)
{
    if (empty($classes)) {
        $output = '<div class="wcs3-no-classes-message">' . __('No classes scheduled') . '</div>';
        return $output;
    }
    $wcs3_options = wcs3_load_settings();
    $weekdays_dict = wcs3_get_weekdays();
    $template = $wcs3_options['details_template'];
    $output = '<div class="wcs3-schedule-list-layout">';
    // Classes are grouped by indexed weekdays.
    foreach ($weekdays as $day => $index) {
        $day = $weekdays_dict[$index];
        $day_classes = $classes[$index];
        if (!empty($day_classes)) {
            $output .= "<h3>{$day}</h3>";
            $output .= '<ul class="wcs3-weekday-list wcs3-weekday-list-' . $index . '">';
            foreach ($day_classes as $class) {
                $output .= '<li class="wcs3-list-item-class">';
                $output .= wcs3_process_template($class, $template);
                $output .= '</li>';
            }
            $output .= '</ul>';
            echo '';
        }
    }
    $output .= '</div>';
    return $output;
}
Ejemplo n.º 3
0
/**
 * Generates a select list of weekdays.
 */
function wcs3_generate_weekday_select_list($name = '', $default = NULL)
{
    $days = wcs3_get_weekdays();
    return wcs3_select_list($days, $name, $default);
}