Example #1
0
/**
 * View function.
 * 
 * @param type $params 
 */
function wpcf_fields_date_view($params)
{
    global $wp_locale;
    $defaults = array('format' => get_option('date_format'));
    $params = wp_parse_args($params, $defaults);
    $output = '';
    switch ($params['style']) {
        case 'calendar':
            $output .= wpcf_fields_date_get_calendar($params, true, false);
            break;
        default:
            $field_name = '';
            // Extract the Full month and Short month from the format.
            // We'll replace with the translated months if possible.
            $format = $params['format'];
            $format = str_replace('F', '#111111#', $format);
            $format = str_replace('M', '#222222#', $format);
            // Same for the Days
            $format = str_replace('D', '#333333#', $format);
            $format = str_replace('l', '#444444#', $format);
            $date_out = date($format, intval($params['field_value']));
            $month = date('m', intval($params['field_value']));
            $month_full = $wp_locale->get_month($month);
            $date_out = str_replace('#111111#', $month_full, $date_out);
            $month_short = $wp_locale->get_month_abbrev($month_full);
            $date_out = str_replace('#222222#', $month_short, $date_out);
            $day = date('w', intval($params['field_value']));
            $day_full = $wp_locale->get_weekday($day);
            $date_out = str_replace('#333333#', $day_full, $date_out);
            $day_short = $wp_locale->get_weekday_abbrev($day_full);
            $date_out = str_replace('#444444#', $day_short, $date_out);
            $output = $date_out;
            break;
    }
    return $output;
}
Example #2
0
/**
 * View function.
 * 
 * @param type $params 
 */
function wpcf_fields_date_view($params)
{
    global $wp_locale;
    $defaults = array('format' => get_option('date_format'), 'style' => '');
    $params = wp_parse_args($params, $defaults);
    $output = '';
    // Make sure value is right
    $__timestamp = wpcf_fields_date_value_get_filter($params['field_value'], $params['field'], 'timestamp');
    if (is_null($__timestamp)) {
        return '';
    } else {
        $params['field_value'] = $__timestamp;
    }
    switch ($params['style']) {
        case 'calendar':
            $output .= wpcf_fields_date_get_calendar($params, true, false);
            break;
        default:
            $field_name = '';
            // Extract the Full month and Short month from the format.
            // We'll replace with the translated months if possible.
            $format = $params['format'];
            //$format = str_replace( 'F', '#111111#', $format );
            //$format = str_replace( 'M', '#222222#', $format );
            // Same for the Days
            //$format = str_replace( 'D', '#333333#', $format );
            //$format = str_replace( 'l', '#444444#', $format );
            $date_out = adodb_date($format, $params['field_value']);
            //$month = adodb_date( 'm', $params['field_value'] );
            //$month_full = $wp_locale->get_month( $month );
            //$date_out = str_replace( '#111111#', $month_full, $date_out );
            //$month_short = $wp_locale->get_month_abbrev( $month_full );
            //$date_out = str_replace( '#222222#', $month_short, $date_out );
            //$day = adodb_date( 'w', $params['field_value'] );
            //$day_full = $wp_locale->get_weekday( $day );
            //$date_out = str_replace( '#444444#', $day_full, $date_out );
            //$day_short = $wp_locale->get_weekday_abbrev( $day_full );
            //$date_out = str_replace( '#333333#', $day_short, $date_out );
            $output .= $date_out;
            break;
    }
    return $output;
}