当前位置: 首页>>代码示例>>PHP>>正文


PHP calendar_week_mod函数代码示例

本文整理汇总了PHP中calendar_week_mod函数的典型用法代码示例。如果您正苦于以下问题:PHP calendar_week_mod函数的具体用法?PHP calendar_week_mod怎么用?PHP calendar_week_mod使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了calendar_week_mod函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wpcf_fields_date_get_calendar

/**
 * Calendar view.
 * 
 * @global type $wpdb
 * @global type $m
 * @global type $wp_locale
 * @global type $posts
 * @param type $params
 * @param type $initial
 * @param type $echo
 * @return type 
 */
function wpcf_fields_date_get_calendar($params, $initial = true, $echo = true)
{
    global $wpdb, $m, $wp_locale, $posts;
    // wpcf Set our own date
    $monthnum = date('n', $params['field_value']);
    $year = date('Y', $params['field_value']);
    $wpcf_date = date('j', $params['field_value']);
    $cache = array();
    $key = md5($params['field']['slug'] . $wpcf_date);
    if ($cache = wp_cache_get('get_calendar', 'calendar')) {
        if (is_array($cache) && isset($cache[$key])) {
            if ($echo) {
                echo apply_filters('get_calendar', $cache[$key]);
                return;
            } else {
                return apply_filters('get_calendar', $cache[$key]);
            }
        }
    }
    if (!is_array($cache)) {
        $cache = array();
    }
    if (isset($_GET['w'])) {
        $w = '' . intval($_GET['w']);
    }
    // week_begins = 0 stands for Sunday
    $week_begins = intval(get_option('start_of_week'));
    // Let's figure out when we are
    if (!empty($monthnum) && !empty($year)) {
        $thismonth = '' . zeroise(intval($monthnum), 2);
        $thisyear = '' . intval($year);
    } elseif (!empty($w)) {
        // We need to get the month from MySQL
        $thisyear = '' . intval(substr($m, 0, 4));
        $d = ($w - 1) * 7 + 6;
        //it seems MySQL's weeks disagree with PHP's
        $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL {$d} DAY) ), '%m')");
    } elseif (!empty($m)) {
        $thisyear = '' . intval(substr($m, 0, 4));
        if (strlen($m) < 6) {
            $thismonth = '01';
        } else {
            $thismonth = '' . zeroise(intval(substr($m, 4, 2)), 2);
        }
    } else {
        $thisyear = gmdate('Y', current_time('timestamp'));
        $thismonth = gmdate('m', current_time('timestamp'));
    }
    $unixmonth = mktime(0, 0, 0, $thismonth, 1, $thisyear);
    $last_day = date('t', $unixmonth);
    /* translators: Calendar caption: 1: month name, 2: 4-digit year */
    $calendar_caption = _x('%1$s %2$s', 'calendar caption');
    $calendar_output = '<table id="wp-calendar" summary="' . esc_attr__('Calendar') . '">
	<caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
	<thead>
	<tr>';
    $myweek = array();
    for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
        $myweek[] = $wp_locale->get_weekday(($wdcount + $week_begins) % 7);
    }
    foreach ($myweek as $wd) {
        $day_name = true == $initial ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
        $wd = esc_attr($wd);
        $calendar_output .= "\n\t\t<th scope=\"col\" title=\"{$wd}\">{$day_name}</th>";
    }
    $calendar_output .= '
	</tr>
	</thead>

	<tfoot>
	<tr>';
    $calendar_output .= '
	</tr>
	</tfoot>

	<tbody>
	<tr>';
    // See how much we should pad in the beginning
    $pad = calendar_week_mod(date('w', $unixmonth) - $week_begins);
    if (0 != $pad) {
        $calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr($pad) . '" class="pad">&nbsp;</td>';
    }
    $daysinmonth = intval(date('t', $unixmonth));
    for ($day = 1; $day <= $daysinmonth; ++$day) {
        if (isset($newrow) && $newrow) {
            $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
        }
        $newrow = false;
//.........这里部分代码省略.........
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:101,代码来源:date.php

示例2: get_calendar


//.........这里部分代码省略.........
    $myweek = array();
    for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
        $myweek[] = $wp_locale->get_weekday(($wdcount + $week_begins) % 7);
    }
    foreach ($myweek as $wd) {
        $day_name = true == $initial ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
        echo "\n\t\t<th abbr=\"{$wd}\" scope=\"col\" title=\"{$wd}\">{$day_name}</th>";
    }
    echo '
	</tr>
	</thead>

	<tfoot>
	<tr>';
    if ($previous) {
        echo "\n\t\t" . '<td abbr="' . $wp_locale->get_month($previous->month) . '" colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0, 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
    } else {
        echo "\n\t\t" . '<td colspan="3" id="prev" class="pad">&nbsp;</td>';
    }
    echo "\n\t\t" . '<td class="pad">&nbsp;</td>';
    if ($next) {
        echo "\n\t\t" . '<td abbr="' . $wp_locale->get_month($next->month) . '" colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0, 0, $next->month, 1, $next->year))) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' &raquo;</a></td>';
    } else {
        echo "\n\t\t" . '<td colspan="3" id="next" class="pad">&nbsp;</td>';
    }
    echo '
	</tr>
	</tfoot>

	<tbody>
	<tr>';
    // Get days with posts
    $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)\n\t\tFROM {$wpdb->posts} WHERE MONTH(post_date) = '{$thismonth}'\n\t\tAND YEAR(post_date) = '{$thisyear}'\n\t\tAND post_type = 'post' AND post_status = 'publish'\n\t\tAND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
    if ($dayswithposts) {
        foreach ($dayswithposts as $daywith) {
            $daywithpost[] = $daywith[0];
        }
    } else {
        $daywithpost = array();
    }
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') !== false || strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari') !== false) {
        $ak_title_separator = "\n";
    } else {
        $ak_title_separator = ', ';
    }
    $ak_titles_for_day = array();
    $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " . "FROM {$wpdb->posts} " . "WHERE YEAR(post_date) = '{$thisyear}' " . "AND MONTH(post_date) = '{$thismonth}' " . "AND post_date < '" . current_time('mysql') . "' " . "AND post_type = 'post' AND post_status = 'publish'");
    if ($ak_post_titles) {
        foreach ($ak_post_titles as $ak_post_title) {
            $post_title = apply_filters("the_title", $ak_post_title->post_title);
            $post_title = str_replace('"', '&quot;', wptexturize($post_title));
            if (empty($ak_titles_for_day['day_' . $ak_post_title->dom])) {
                $ak_titles_for_day['day_' . $ak_post_title->dom] = '';
            }
            if (empty($ak_titles_for_day["{$ak_post_title->dom}"])) {
                // first one
                $ak_titles_for_day["{$ak_post_title->dom}"] = $post_title;
            } else {
                $ak_titles_for_day["{$ak_post_title->dom}"] .= $ak_title_separator . $post_title;
            }
        }
    }
    // See how much we should pad in the beginning
    $pad = calendar_week_mod(date('w', $unixmonth) - $week_begins);
    if (0 != $pad) {
        echo "\n\t\t" . '<td colspan="' . $pad . '" class="pad">&nbsp;</td>';
    }
    $daysinmonth = intval(date('t', $unixmonth));
    for ($day = 1; $day <= $daysinmonth; ++$day) {
        if (isset($newrow) && $newrow) {
            echo "\n\t</tr>\n\t<tr>\n\t\t";
        }
        $newrow = false;
        if ($day == gmdate('j', time() + get_option('gmt_offset') * 3600) && $thismonth == gmdate('m', time() + get_option('gmt_offset') * 3600) && $thisyear == gmdate('Y', time() + get_option('gmt_offset') * 3600)) {
            echo '<td id="today">';
        } else {
            echo '<td>';
        }
        if (in_array($day, $daywithpost)) {
            // any posts today?
            echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"{$ak_titles_for_day[$day]}\">{$day}</a>";
        } else {
            echo $day;
        }
        echo '</td>';
        if (6 == calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins)) {
            $newrow = true;
        }
    }
    $pad = 7 - calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins);
    if ($pad != 0 && $pad != 7) {
        echo "\n\t\t" . '<td class="pad" colspan="' . $pad . '">&nbsp;</td>';
    }
    echo "\n\t</tr>\n\t</tbody>\n\t</table>";
    $output = ob_get_contents();
    ob_end_clean();
    echo $output;
    $cache[$key] = $output;
    wp_cache_set('get_calendar', $cache, 'calendar');
}
开发者ID:alx,项目名称:blogsfera,代码行数:101,代码来源:general-template.php

示例3: add_query_arg

    if ($day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp'))) {
        $calendar_output .= '<td id="today">';
    } else {
        $calendar_output .= '<td>';
    }
    if (array_key_exists($day, $daywithpost)) {
        // any posts today?
        $calendar_output .= '<a data-tooltip data-options="disable_for_touch:true" class="has-tip" href="' . (sizeof($daywithpost[$day]) > 1 ? add_query_arg(array('post_type' => 'sp_event'), get_day_link($thisyear, $thismonth, $day)) . '" title="' . sprintf('%s events', sizeof($daywithpost[$day])) : get_post_permalink($daywithpost[$day][0], false, true) . '" title="' . esc_attr($ak_titles_for_day[$day])) . "\">{$day}</a>";
    } else {
        $calendar_output .= $day;
    }
    $calendar_output .= '</td>';
    if (6 == calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins)) {
        $newrow = true;
    }
}
$pad = 7 - calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins);
if ($pad != 0 && $pad != 7) {
    $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr($pad) . '">&nbsp;</td>';
}
$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>\n\t</div>";
if ($id && $show_all_events_link) {
    $calendar_output .= '<a class="sp-calendar-link sp-view-all-link" href="' . get_permalink($id) . '">' . __('View all events', 'sportspress') . '</a>';
}
?>
<div class="sp-template sp-template-event-calendar">
	<?php 
echo $calendar_output;
?>
</div>
开发者ID:ArnaudGuillou,项目名称:SiteESBVolley,代码行数:30,代码来源:event-calendar.php

示例4: wplms_event_calendar


//.........这里部分代码省略.........
                    $monthstring = 'month=12&y=' . $newyear;
                } else {
                    $newmonth = zeroise($thismonth - 1, 2);
                    $newyear = $thisyear;
                    $monthstring = 'month=' . $newmonth;
                    if (isset($_GET['y'])) {
                        $monthstring .= '&y=' . $newyear;
                    }
                }
                $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="?action=events&' . $monthstring . '" title="' . esc_attr(sprintf(__('View Events for %1$s %2$s', 'wplms-events'), $wp_locale->get_month($newmonth), date('Y', mktime(0, 0, 0, $newmonth, 1, $newyear)))) . '" rel="nofollow"> &lsaquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($newmonth)) . '</a></td>';
            } else {
                $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev" class="pad">&nbsp;</td>';
            }
            $calendar_output .= "\n\t\t" . '<td class="pad">&nbsp;</td>';
            if ($next) {
                if ($thismonth == 12) {
                    $newmonth = 01;
                    $newyear = $thisyear + 1;
                    $monthstring = 'month=01&y=' . ($thisyear + 1);
                } else {
                    $newmonth = zeroise($thismonth + 1, 2);
                    $newyear = $thisyear;
                    $monthstring = 'month=' . $newmonth;
                    if (isset($_GET['y'])) {
                        $monthstring .= '&y=' . $newyear;
                    }
                }
                $calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="?action=events&' . $monthstring . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s', 'wplms-events'), $wp_locale->get_month($newmonth), date('Y', mktime(0, 0, 0, $newmonth, 1, $newyear)))) . '"  rel="nofollow"> ' . $wp_locale->get_month_abbrev($wp_locale->get_month($newmonth)) . ' &rsaquo;</a></td>';
            } else {
                $calendar_output .= "\n\t\t" . '<td colspan="3" id="next" class="pad">&nbsp;</td>';
            }
            $calendar_output .= '
            </tr>
            </tfoot>

            <tbody>
            <tr>';
            $result = strtotime("{$thisyear}-{$thismonth}-01");
            $result = strtotime('-1 second', strtotime('+1 month', $result));
            $end_date_month = date('Y-m-d', $result);
            $result = strtotime("{$thisyear}-{$thismonth}-01");
            $start_date_month = date('Y-m-d', $result);
            if (isset($course) && $course != '') {
                $eventdaysquery = $wpdb->get_results($wpdb->prepare("SELECT start.post_id as id, start.meta_value as start_date, end.meta_value as end_date\n                FROM {$wpdb->postmeta} AS start\n                INNER JOIN {$wpdb->postmeta} AS end\n                ON start.post_id=end.post_id\n                WHERE start.post_id IN (SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = 'vibe_event_course' AND meta_value = %d)\n                AND start.meta_key = 'vibe_start_date'\n                AND end.meta_key = 'vibe_end_date'\n                AND start.meta_value <= DATE('{$end_date_month}')\n                AND end.meta_value >=  DATE('{$start_date_month}')\n                ", $course));
            } else {
                $eventdaysquery = $wpdb->get_results("SELECT start.post_id as id, start.meta_value as start_date, end.meta_value as end_date\n                FROM {$wpdb->postmeta} AS start\n                INNER JOIN {$wpdb->postmeta} AS end\n                ON start.post_id=end.post_id\n                WHERE start.meta_key = 'vibe_start_date'\n                AND end.meta_key = 'vibe_end_date'\n                AND start.meta_value <= '{$end_date_month}'\n                AND end.meta_value  >=  '{$start_date_month}'\n                ");
            }
            $eventdays = array();
            foreach ($eventdaysquery as $event) {
                $start = $event->start_date <= $start_date_month ? $start_date_month : $event->start_date;
                $end = $event->end_date >= $end_date_month ? $end_date_month : $event->end_date;
                $startTime = intval(date('d', strtotime($start)));
                $endTime = intval(date('d', strtotime($end)));
                while ($startTime <= $endTime) {
                    if (!isset($eventdays[$startTime])) {
                        $eventdays[$startTime] = 1;
                    } else {
                        $eventdays[$startTime]++;
                    }
                    $startTime++;
                }
            }
            // See how much we should pad in the beginning
            $pad = calendar_week_mod(date('w', $unixmonth) - $week_begins);
            if (0 != $pad) {
                $calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr($pad) . '" class="pad">&nbsp;</td>';
            }
            $daysinmonth = intval(date('t', $unixmonth));
            for ($day = 1; $day <= $daysinmonth; ++$day) {
                if (isset($newrow) && $newrow) {
                    $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
                }
                $newrow = false;
                if ($day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp'))) {
                    $calendar_output .= '<td id="today">';
                } else {
                    $calendar_output .= '<td>';
                }
                if (isset($eventdays[$day])) {
                    // any posts today?
                    $calendar_output .= '<a href="#" class="event_list" data-course="' . (get_post_type() == BP_COURSE_SLUG ? get_the_ID() : '*') . '" data-day="' . $day . '" data-month="' . $thismonth . '" data-year="' . $thisyear . '"  rel="nofollow">' . $day . ' <span>' . $eventdays[$day] . '</span></a>';
                } else {
                    $calendar_output .= $day;
                }
                $calendar_output .= '</td>';
                if (6 == calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins)) {
                    $newrow = true;
                }
            }
            $pad = 7 - calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins);
            if ($pad != 0 && $pad != 7) {
                $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr($pad) . '">&nbsp;</td>';
            }
            $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
            if ($echo) {
                echo apply_filters('wplms_event_calendar', $calendar_output);
            } else {
                return apply_filters('wplms_event_calendar', $calendar_output);
            }
        }
开发者ID:akshayxhtmljunkies,项目名称:brownglock,代码行数:101,代码来源:events_class.php

示例5: wpestate_draw_month_front

function wpestate_draw_month_front($month_no, $reservation_array, $unixmonth, $daywithpost, $thismonth, $thisyear, $last_day)
{
    global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
    $week_begins = intval(get_option('start_of_week'));
    $initial = true;
    $echo = true;
    $table_style = '';
    if ($month_no > 2) {
        $table_style = 'style="display:none;"';
    }
    $calendar_output = '<div class="booking-calendar-wrapper" data-mno="' . $month_no . '" ' . $table_style . '>
            <div class="month-title"> ' . date("F", mktime(0, 0, 0, $thismonth, 10)) . ' ' . $thisyear . ' </div>
            <table class="wp-calendar booking-calendar">
	
	<thead>
	<tr>';
    $myweek = array();
    for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
        $myweek[] = $wp_locale->get_weekday(($wdcount + $week_begins) % 7);
    }
    foreach ($myweek as $wd) {
        $day_name = true == $initial ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
        $wd = esc_attr($wd);
        $calendar_output .= "\n\t\t<th scope=\"col\" title=\"{$wd}\">{$day_name}</th>";
    }
    $calendar_output .= '
	</tr>
	</thead>
        <tbody>
	<tr>';
    // See how much we should pad in the beginning
    $pad = calendar_week_mod(date('w', $unixmonth) - $week_begins);
    if (0 != $pad) {
        $calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr($pad) . '" class="pad">&nbsp;</td>';
    }
    $daysinmonth = intval(date('t', $unixmonth));
    $reserverd_first = '';
    $reserved_last = '';
    for ($day = 1; $day <= $daysinmonth; ++$day) {
        $timestamp = strtotime($day . '-' . $thismonth . '-' . $thisyear) . ' | ';
        $timestamp_java = strtotime($day . '-' . $thismonth . '-' . $thisyear);
        if (isset($newrow) && $newrow) {
            $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
        }
        $newrow = false;
        $has_past_class = '';
        if ($timestamp_java < time() - 24 * 60 * 60) {
            $has_past_class = "has_past";
        } else {
            $has_past_class = "has_future";
        }
        $is_reserved = 0;
        if ($day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp'))) {
            // if is today check for reservation
            if (in_array($timestamp_java, $reservation_array)) {
                $calendar_output .= '<td class="calendar-reserved calendar-today ' . $has_past_class . ' "     data-curent-date="' . $timestamp_java . '">';
            } else {
                $calendar_output .= '<td class="calendar-today ' . $has_past_class . ' "        data-curent-date="' . $timestamp_java . '">';
            }
        } else {
            if (in_array($timestamp_java, $reservation_array)) {
                // check for reservation
                $calendar_output .= '<td class="calendar-reserved ' . $has_past_class . ' "     data-curent-date="' . $timestamp_java . '">';
            } else {
                // is not today and no resrvation
                $calendar_output .= '<td class="calendar-free ' . $has_past_class . '"          data-curent-date="' . $timestamp_java . '">';
            }
        }
        if (in_array($day, $daywithpost)) {
            // any posts today?
            $calendar_output .= '<a href="' . get_day_link($thisyear, $thismonth, $day) . '" title="' . esc_attr($ak_titles_for_day[$day]) . "\">{$day}</a>";
        } else {
            $calendar_output .= $day;
        }
        $calendar_output .= '</td>';
        if (6 == calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins)) {
            $newrow = true;
        }
    }
    $pad = 7 - calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins);
    if ($pad != 0 && $pad != 7) {
        $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr($pad) . '">&nbsp;</td>';
    }
    $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table></div>";
    if ($echo) {
        echo apply_filters('get_calendar', $calendar_output);
    } else {
        return apply_filters('get_calendar', $calendar_output);
    }
}
开发者ID:riddya85,项目名称:rentail_upwrk,代码行数:90,代码来源:show_avalability.php

示例6: get_calendar


//.........这里部分代码省略.........
            get_month_link($previous->year, $previous->month) . '" title="' . sprintf(__('View posts for %1$s %2$s'), $month[zeroise($previous->month, 2)], date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year))) . '">&laquo; ' . $month_abbrev[$month[zeroise($previous->month, 2)]] . '</a></td>';
    } else {
        echo "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
    }

    echo "\n\t\t".'<td class="pad">&nbsp;</td>';

    if ($next) {
        echo "\n\t\t".'<td abbr="' . $month[zeroise($next->month, 2)] . '" colspan="3" id="next"><a href="' .
                get_month_link($next->year, $next->month) . '" title="View posts for ' . $month[zeroise($next->month, 2)] . ' ' .
                date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year)) . '">' . $month_abbrev[$month[zeroise($next->month, 2)]] . ' &raquo;</a></td>';
    } else {
        echo "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
    }

    echo '
    </tr>
    </tfoot>

    <tbody>
    <tr>';

    // Get days with posts
    $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
            FROM $wpdb->posts WHERE MONTH(post_date) = $thismonth
            AND YEAR(post_date) = $thisyear
            AND post_status = 'publish'
            AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
    if ($dayswithposts) {
        foreach ($dayswithposts as $daywith) {
            $daywithpost[] = $daywith[0];
        }
    } else {
        $daywithpost = array();
    }



    if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') ||
          strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') ||
          strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari')) {
        $ak_title_separator = "\n";
    } else {
        $ak_title_separator = ', ';
    }

    $ak_titles_for_day = array();
    $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom "
                                         ."FROM $wpdb->posts "
                                         ."WHERE YEAR(post_date) = '$thisyear' "
                                         ."AND MONTH(post_date) = '$thismonth' "
                                         ."AND post_date < '".current_time('mysql')."' "
                                         ."AND post_status = 'publish'"
                                        );
    if ($ak_post_titles) {
        foreach ($ak_post_titles as $ak_post_title) {
            if (empty($ak_titles_for_day['day_'.$ak_post_title->dom])) {
                $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
            }
            if (empty($ak_titles_for_day["$ak_post_title->dom"])) { // first one
                $ak_titles_for_day["$ak_post_title->dom"] = str_replace('"', '&quot;', wptexturize($ak_post_title->post_title));
            } else {
                $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . str_replace('"', '&quot;', wptexturize($ak_post_title->post_title));
            }
        }
    }


    // See how much we should pad in the beginning
    $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
    if (0 != $pad) echo "\n\t\t".'<td colspan="'.$pad.'" class="pad">&nbsp;</td>';

    $daysinmonth = intval(date('t', $unixmonth));
    for ($day = 1; $day <= $daysinmonth; ++$day) {
        if (isset($newrow) && $newrow)
            echo "\n\t</tr>\n\t<tr>\n\t\t";
        $newrow = false;

        if ($day == gmdate('j', (time() + (get_settings('gmt_offset') * 3600))) && $thismonth == gmdate('m', time()+(get_settings('gmt_offset') * 3600)) && $thisyear == gmdate('Y', time()+(get_settings('gmt_offset') * 3600)))
            echo '<td id="today">';
        else
            echo '<td>';

        if (in_array($day, $daywithpost)) { // any posts today?
            echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"$ak_titles_for_day[$day]\">$day</a>";
        } else {
            echo $day;
        }
        echo '</td>';

	if (6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins))
            $newrow = true;
    }

    $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
    if ($pad != 0 && $pad != 7)
        echo "\n\t\t".'<td class="pad" colspan="'.$pad.'">&nbsp;</td>';

    echo "\n\t</tr>\n\t</tbody>\n\t</table>";
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:101,代码来源:template-functions-general.php

示例7: oplb_events_get_calendar


//.........这里部分代码省略.........
            break;
        case "Νοεμβρίου":
            $month_desc = 'ΝΟΕΜΒΡΙΟΣ';
            break;
        case "Δεκεμβρίου":
            $month_desc = 'ΔΕΚΕΜΒΡΙΟΣ';
            break;
    }
    $calendar_output = '<table id="wp-events-calendar">
  <h3>' . sprintf($calendar_caption, $month_desc, date('Y', $unixmonth)) . '</h3>
  <thead>
  <tr>';
    $myweek = array();
    for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
        $myweek[] = $wp_locale->get_weekday(($wdcount + $week_begins) % 7);
    }
    foreach ($myweek as $wd) {
        $day_name = true == $initial ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
        $wd = esc_attr($wd);
        $calendar_output .= "\n\t\t<th scope=\"col\" title=\"{$wd}\">{$day_name}</th>";
    }
    $calendar_output .= '
  </tr>
  </thead>';
    $calendar_output .= '
    <tbody>
  <tr>';
    // Get days with posts
    $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH( post_date )\n    FROM {$wpdb->posts} WHERE MONTH( post_date ) = '{$thismonth}'\n    AND YEAR( post_date ) = '{$thisyear}'\n    AND post_type IN ( {$post_types} ) AND post_status IN ('publish','future')\n    AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
    if ($dayswithposts) {
        foreach ((array) $dayswithposts as $daywith) {
            $daywithpost[] = $daywith[0];
        }
    } else {
        $daywithpost = array();
    }
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false) {
        $ak_title_separator = "\n";
    } else {
        $ak_title_separator = ', ';
    }
    $ak_titles_for_day = array();
    $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH( post_date ) as dom " . "FROM {$wpdb->posts} " . "WHERE YEAR( post_date ) = '{$thisyear}' " . "AND MONTH( post_date ) = '{$thismonth}' " . "AND post_date < '" . current_time('mysql') . "' " . "AND post_type IN ( {$post_types} ) AND post_status IN ('publish','future')");
    if ($ak_post_titles) {
        foreach ((array) $ak_post_titles as $ak_post_title) {
            $post_title = esc_attr(apply_filters('the_title', $ak_post_title->post_title, $ak_post_title->ID));
            if (empty($ak_titles_for_day['day_' . $ak_post_title->dom])) {
                $ak_titles_for_day['day_' . $ak_post_title->dom] = '';
            }
            if (empty($ak_titles_for_day["{$ak_post_title->dom}"])) {
                // first one
                $ak_titles_for_day["{$ak_post_title->dom}"] = $post_title;
            } else {
                $ak_titles_for_day["{$ak_post_title->dom}"] .= $ak_title_separator . $post_title;
            }
        }
    }
    // See how much we should pad in the beginning
    $pad = calendar_week_mod(date('w', $unixmonth) - $week_begins);
    if (0 != $pad) {
        $calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr($pad) . '" class="pad">&nbsp;</td>';
    }
    $daysinmonth = intval(date('t', $unixmonth));
    for ($day = 1; $day <= $daysinmonth; ++$day) {
        if (isset($newrow) && $newrow) {
            $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
        }
        $newrow = false;
        if ($day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp'))) {
            $calendar_output .= '<td id="today">';
        } else {
            $calendar_output .= '<td>';
        }
        if (in_array($day, $daywithpost)) {
            // any posts today?
            $calendar_output .= '<a href="' . get_day_link($thisyear, $thismonth, $day) . '&post_type=event' . "\" title=\"" . esc_attr($ak_titles_for_day[$day]) . "\">{$day}</a>";
        } else {
            $calendar_output .= $day;
        }
        $calendar_output .= '</td>';
        if (6 == calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins)) {
            $newrow = true;
        }
    }
    $pad = 7 - calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins);
    if ($pad != 0 && $pad != 7) {
        $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr($pad) . '">&nbsp;</td>';
    }
    $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
    $cache[$key] = $calendar_output;
    wp_cache_set('get_calendar', $cache, 'calendar');
    remove_filter('get_calendar', 'oplb_events_get_calendar_filter');
    $output = apply_filters('get_calendar', $calendar_output);
    add_filter('get_calendar', 'oplb_events_get_calendar_filter');
    if ($echo) {
        echo $output;
    } else {
        return $output;
    }
}
开发者ID:eellak,项目名称:OpenLab_Website,代码行数:101,代码来源:functions.php

示例8: wpestate_draw_month_price

function wpestate_draw_month_price($property_price, $month_no, $custom_price_array, $unixmonth, $daywithpost, $thismonth, $thisyear, $last_day)
{
    global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
    $week_begins = intval(get_option('start_of_week'));
    $initial = true;
    $echo = true;
    $table_style = '';
    if ($month_no > 2) {
        $table_style = 'style="display:none;"';
    }
    $calendar_output = '<div class="booking-calendar-wrapper-in-price booking-price col-md-6" data-mno="' . $month_no . '" ' . $table_style . '>
            <div class="month-title"> ' . date("F", mktime(0, 0, 0, $thismonth, 10)) . ' ' . $thisyear . ' </div>
            <table class="wp-calendar booking-calendar">
        <thead>
        <tr>';
    $myweek = array();
    for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
        $myweek[] = $wp_locale->get_weekday(($wdcount + $week_begins) % 7);
    }
    foreach ($myweek as $wd) {
        $day_name = true == $initial ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
        $wd = esc_attr($wd);
        $calendar_output .= "\n\t\t<th scope=\"col\" title=\"{$wd}\">{$day_name}</th>";
    }
    $calendar_output .= '
        </tr>
        </thead>

        <tfoot>
        <tr>';
    $calendar_output .= '
        </tr>
        </tfoot>
        <tbody>
        <tr>';
    // See how much we should pad in the beginning
    $pad = calendar_week_mod(date('w', $unixmonth) - $week_begins);
    if (0 != $pad) {
        $calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr($pad) . '" class="pad">&nbsp;</td>';
    }
    $daysinmonth = intval(date('t', $unixmonth));
    for ($day = 1; $day <= $daysinmonth; ++$day) {
        $timestamp = strtotime($day . '-' . $thismonth . '-' . $thisyear) . ' | ';
        $timestamp_java = strtotime($day . '-' . $thismonth . '-' . $thisyear);
        if (isset($newrow) && $newrow) {
            $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
        }
        $newrow = false;
        $has_past_class = 'has_future';
        $is_reserved = 0;
        $calendar_output .= '<td class="calendar-free ' . $has_past_class . '" data-curent-date="' . $timestamp_java . '">';
        $calendar_output .= '<span class="day-label">' . $day . '</span>';
        if (array_key_exists($timestamp_java, $custom_price_array)) {
            // custom price
            $calendar_output .= '<span class="custom_set_price">' . wpestate_show_price_custom($custom_price_array[$timestamp_java]) . '</span>';
        } else {
            // default price
            $calendar_output .= '<span class="price-day">' . wpestate_show_price_custom($property_price) . '</span>';
        }
        $calendar_output .= '</td>';
        if (6 == calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins)) {
            $newrow = true;
        }
    }
    $pad = 7 - calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins);
    if ($pad != 0 && $pad != 7) {
        $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr($pad) . '">&nbsp;</td>';
    }
    $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table></div>";
    if ($echo) {
        echo apply_filters('get_calendar', $calendar_output);
    } else {
        return apply_filters('get_calendar', $calendar_output);
    }
}
开发者ID:riddya85,项目名称:rentail_upwrk,代码行数:75,代码来源:property_price.php

示例9: grav_get_post_calendar


//.........这里部分代码省略.........

	<thead>
	<tr class="thead-top-row">';
    if ($previous) {
        $calendar_output .= "\n\t\t" . '<td colspan="1" id="prev"><a href="?cy=' . $previous->year . '&amp;cm=' . $previous->month . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0, 0, $previous->month, 1, $previous->year)))) . '">&lt;</a></td>';
    } else {
        $calendar_output .= "\n\t\t" . '<td colspan="1" id="prev" class="pad">&nbsp;</td>';
    }
    $calendar_output .= "\n\t\t" . '<td class="month" colspan="5">' . $wp_locale->get_month($thismonth) . '</td>';
    if ($next) {
        $calendar_output .= "\n\t\t" . '<td colspan="1" id="next"><a href="?cy=' . $next->year . '&amp;cm=' . $next->month . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0, 0, $next->month, 1, $next->year)))) . '">&gt;</a></td>';
    } else {
        $calendar_output .= "\n\t\t" . '<td colspan="1" id="next" class="pad">&nbsp;</td>';
    }
    $calendar_output .= '
	</tr>
	<tr class="thead-bottom-row">';
    $myweek = array();
    for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
        $myweek[] = $wp_locale->get_weekday(($wdcount + $week_begins) % 7);
    }
    foreach ($myweek as $wd) {
        $day_name = $wp_locale->get_weekday_abbrev($wd);
        $wd = esc_attr($wd);
        $calendar_output .= "\n\t\t<th scope=\"col\" title=\"{$wd}\">" . substr($day_name, 0, 1) . '<span class="calendar-weekday-abbreviation">' . substr($day_name, 1) . '</span></th>';
    }
    $calendar_output .= '
	</tr>
	</thead>
	<tbody>
	<tr>';
    // Get days with posts
    $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(" . $field . ")\n\t\tFROM {$wpdb->posts}" . $linkage . ">= '{$thisyear}-{$thismonth}-01 00:00:00'\n\t\tAND post_type = '" . $post_type . "' AND post_status = 'publish'\n\t\tAND " . $field . " <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
    if ($dayswithposts) {
        foreach ((array) $dayswithposts as $daywith) {
            $daywithpost[] = $daywith[0];
        }
    } else {
        $daywithpost = array();
    }
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false) {
        $ak_title_separator = "\n";
    } else {
        $ak_title_separator = ', ';
    }
    $ak_titles_for_day = array();
    $ak_ids_for_day = array();
    $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(" . $field . ") as dom " . "FROM {$wpdb->posts}" . $linkage . ">= '{$thisyear}-{$thismonth}-01 00:00:00' " . "AND " . $field . " <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' " . "AND post_type = '" . $post_type . "' AND post_status = 'publish'");
    if ($ak_post_titles) {
        foreach ((array) $ak_post_titles as $ak_post_title) {
            /** This filter is documented in wp-includes/post-template.php */
            $post_title = esc_attr(apply_filters('the_title', $ak_post_title->post_title, $ak_post_title->ID));
            if (empty($ak_titles_for_day['day_' . $ak_post_title->dom])) {
                $ak_titles_for_day['day_' . $ak_post_title->dom] = '';
                $ak_ids_for_day['day_' . $ak_post_title->dom] = '';
            }
            if (empty($ak_titles_for_day["{$ak_post_title->dom}"])) {
                $ak_titles_for_day["{$ak_post_title->dom}"] = $post_title;
                $ak_ids_for_day["{$ak_post_title->dom}"] = $ak_post_title->ID;
            } else {
                $ak_titles_for_day["{$ak_post_title->dom}"] .= $ak_title_separator . $post_title;
            }
        }
    }
    // See how much we should pad in the beginning
    $pad = calendar_week_mod(date('w', $unixmonth) - $week_begins);
    if (0 != $pad) {
        $calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr($pad) . '" class="pad">&nbsp;</td>';
    }
    $daysinmonth = intval(date('t', $unixmonth));
    for ($day = 1; $day <= $daysinmonth; ++$day) {
        if (isset($newrow) && $newrow) {
            $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
        }
        $newrow = false;
        if ($day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp'))) {
            $calendar_output .= '<td id="today">';
        } else {
            $calendar_output .= '<td' . (in_array($day, $daywithpost) ? ' class="event"' : '') . '>';
        }
        if (in_array($day, $daywithpost)) {
            $event_class = '';
            $calendar_output .= '<a' . $event_class . ' href="' . get_permalink($ak_ids_for_day[$day]) . '" title="' . esc_attr($ak_titles_for_day[$day]) . "\">{$day}</a>";
        } else {
            $calendar_output .= $day;
        }
        $calendar_output .= '</td>';
        if (6 == calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins)) {
            $newrow = true;
        }
    }
    $pad = 7 - calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins);
    if ($pad != 0 && $pad != 7) {
        $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr($pad) . '">&nbsp;</td>';
    }
    $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
    $cache[$key] = $calendar_output;
    wp_cache_set('get_calendar', $cache, 'calendar');
    return apply_filters('get_calendar', $calendar_output);
}
开发者ID:nomadicmarc,项目名称:goodbay,代码行数:101,代码来源:grav_functions.php

示例10: vicuna_calendar


//.........这里部分代码省略.........
        echo '&laquo;';
    }
    printf(__(' %1$s %2$s ', 'vicuna'), $wp_locale->get_month($thismonth), date('Y', $unixmonth));
    if ($next) {
        echo '<a href="' . get_month_link($next->year, $next->month) . '" title="Newer">&raquo;</a>';
    } else {
        echo '&raquo;';
    }
    $myweek = array();
    for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
        $myweek[] = $weekday[($wdcount + $week_begins) % 7];
    }
    ?>
</caption>
				<tr>
<?php 
    foreach ($myweek as $wd) {
        // $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
        $day_name = mb_substr($wd, 0, 1);
        if ($day_name == "S") {
            echo "\t\t\t\t\t<th class=\"" . strtolower(substr($wd, 0, 3)) . "\" title=\"" . __($wd, 'vicuna') . "\">{$day_name}</th>\n";
        } else {
            echo "\t\t\t\t\t<th title=\"" . __($wd, 'vicuna') . "\">{$day_name}</th>\n";
        }
    }
    ?>
				</tr>
				<tr>
<?php 
    // Get days with posts
    $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)\n\t\tFROM {$wpdb->posts} WHERE MONTH(post_date) = '{$thismonth}'\n\t\tAND YEAR(post_date) = '{$thisyear}'\n\t\tAND post_type = 'post' AND post_status = 'publish'\n\t\tAND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
    if ($dayswithposts) {
        foreach ($dayswithposts as $daywith) {
            $daywithpost[] = $daywith[0];
        }
    } else {
        $daywithpost = array();
    }
    if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari')) {
        $ak_title_separator = "\n";
    } else {
        $ak_title_separator = ', ';
    }
    $ak_titles_for_day = array();
    $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " . "FROM {$wpdb->posts} " . "WHERE YEAR(post_date) = '{$thisyear}' " . "AND MONTH(post_date) = '{$thismonth}' " . "AND post_date < '" . current_time('mysql') . "' " . "AND post_type = 'post' AND post_status = 'publish'");
    if ($ak_post_titles) {
        foreach ($ak_post_titles as $ak_post_title) {
            if (empty($ak_titles_for_day['day_' . $ak_post_title->dom])) {
                $ak_titles_for_day['day_' . $ak_post_title->dom] = '';
            }
            if (empty($ak_titles_for_day["{$ak_post_title->dom}"])) {
                // first one
                $ak_titles_for_day["{$ak_post_title->dom}"] = str_replace('"', '&quot;', wptexturize($ak_post_title->post_title));
            } else {
                $ak_titles_for_day["{$ak_post_title->dom}"] .= $ak_title_separator . str_replace('"', '&quot;', wptexturize($ak_post_title->post_title));
            }
        }
    }
    // See how much we should pad in the beginning
    $pad = calendar_week_mod(date('w', $unixmonth) - $week_begins);
    if (0 != $pad) {
        for ($i = 0; $i < $pad; $i++) {
            echo "\t\t\t\t\t<td>&nbsp;</td>\n";
        }
    }
    $daysinmonth = intval(date('t', $unixmonth));
    for ($day = 1; $day <= $daysinmonth; ++$day) {
        if (isset($newrow) && $newrow) {
            echo "\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
        }
        $newrow = false;
        if ($day == gmdate('j', time() + get_option('gmt_offset') * 3600) && $thismonth == gmdate('m', time() + get_option('gmt_offset') * 3600) && $thisyear == gmdate('Y', time() + get_option('gmt_offset') * 3600)) {
            echo "\t\t\t\t\t<td class=\"today\">";
        } else {
            echo "\t\t\t\t\t<td>";
        }
        if (in_array($day, $daywithpost)) {
            // any posts today?
            echo '<a href="' . get_day_link($thisyear, $thismonth, $day) . "\" title=\"{$ak_titles_for_day[$day]}\">{$day}</a>";
        } else {
            echo $day;
        }
        echo "</td>\n";
        if (6 == calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins)) {
            $newrow = true;
        }
    }
    $pad = 7 - calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins);
    if ($pad != 0 && $pad != 7) {
        for ($i = 0; $i < $pad; $i++) {
            echo "\t\t\t\t\t<td>&nbsp;</td>\n";
        }
    }
    echo "\t\t\t\t</tr>\n\t\t\t</table>\n";
    $output = ob_get_contents();
    ob_end_clean();
    echo $output;
    $cache[$key] = $output;
    wp_cache_set('vicuna_calendar', $cache, 'calendar');
}
开发者ID:nakaji0213,项目名称:wp.vicuna.ext,代码行数:101,代码来源:functions.php

示例11: wp_get_pcalendar


//.........这里部分代码省略.........
        </tr>
        </thead>
	
        <tfoot>
	    <tr>';
    if ($previous) {
        $previous_month = $jthismonth - 1;
        $previous_year = $jthisyear;
        if ($previous_month == 0) {
            $previous_month = 12;
            $previous_year--;
        }
        $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link($previous_year, $previous_month) . '">&laquo; ' . $pd->persian_month_names[$previous_month] . '</a></td>';
    } else {
        $calendar_output .= "\n\t\t" . '<td colspan="3" id="prev" class="pad">&nbsp;</td>';
    }
    $calendar_output .= "\n\t\t" . '<td class="pad">&nbsp;</td>';
    if ($next) {
        $next_month = $jthismonth + 1;
        $next_year = $jthisyear;
        if ($next_month == 13) {
            $next_month = 1;
            $next_year++;
        }
        $calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link($next_year, $next_month) . '">' . $pd->persian_month_names[$next_month] . ' &raquo;</a></td>';
    } else {
        $calendar_output .= "\n\t\t" . '<td colspan="3" id="next" class="pad">&nbsp;</td>';
    }
    $calendar_output .= '
        </tr>
        </tfoot>
	
        <tbody>
        <tr>';
    //____________________________________________________________________________________________________________________________________
    $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date),MONTH(post_date),YEAR(post_date)\n        FROM {$wpdb->posts} \n       \tWHERE post_date > '{$start}' AND post_date < '{$end}'\n        AND post_status = 'publish'", ARRAY_N);
    if ($dayswithposts) {
        foreach ($dayswithposts as $daywith) {
            $daywithpost[] = $pd->persian_date('j', "{$daywith['2']}-{$daywith['1']}-{$daywith['0']}", 'eng');
        }
    } else {
        $daywithpost = array();
    }
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false) {
        $ak_title_separator = "\n";
    } else {
        $ak_title_separator = ', ';
    }
    $ak_titles_for_day = array();
    $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom, MONTH(post_date) as month, YEAR(post_date) as year \n        FROM {$wpdb->posts} WHERE post_date >= '{$start}' \n        AND post_date <= '{$end}' \n        AND post_type = 'post' AND post_status = 'publish'", ARRAY_N);
    if ($ak_post_titles) {
        foreach ($ak_post_titles as $ak_post_title) {
            /** This filter is documented in wp-includes/post-template.php */
            $post_title = esc_attr(apply_filters('the_title', $ak_post_title->post_title, $ak_post_title->ID));
            $ak_post_title[2] = $pd->persian_date('j', "{$ak_post_title['4']}-{$ak_post_title['3']}-{$ak_post_title['2']}", 'eng');
            if (empty($ak_titles_for_day['day_' . $ak_post_title->dom])) {
                $ak_titles_for_day['day_' . $ak_post_title->dom] = '';
            }
            if (empty($ak_titles_for_day[$ak_post_title->dom])) {
                // first one
                $ak_titles_for_day[$ak_post_title->dom] = $post_title;
            } else {
                $ak_titles_for_day[$ak_post_title->dom] .= $ak_title_separator . $post_title;
            }
        }
    }
    $pad = calendar_week_mod(date('w', strtotime($unixmonth)) - $week_begins);
    if (0 != $pad) {
        $calendar_output .= "\n\t\t" . '<td colspan="' . $pad . '" class="pad">&nbsp;</td>';
    }
    $daysinmonth = intval($pd->persian_date('t', $unixmonth, 'eng'));
    for ($day = 1; $day <= $daysinmonth; ++$day) {
        list($thiyear, $thismonth, $thisday) = $pd->persian_to_gregorian($jthisyear, $jthismonth, $day);
        if (isset($newrow) && $newrow) {
            $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
        }
        $newrow = false;
        if ($thisday == gmdate('j', time() + get_option('gmt_offset') * 3600) && $thismonth == gmdate('m', time() + get_option('gmt_offset') * 3600) && $thisyear == gmdate('Y', time() + get_option('gmt_offset') * 3600)) {
            $calendar_output .= '<td id="today">';
        } else {
            $calendar_output .= '<td>';
        }
        $p_day = empty($val['sep_datesnum']) ? $day : per_number($day);
        if (in_array($day, $daywithpost)) {
            // any posts today?
            $calendar_output .= '<a href="' . get_day_link($jthisyear, $jthismonth, $day) . "\" title=\"{$ak_titles_for_day[$day]}\">{$p_day}</a>";
        } else {
            $calendar_output .= $p_day;
        }
        $calendar_output .= '</td>';
        if (6 == calendar_week_mod($pd->gregurian_date('w', "{$jthisyear}-{$jthismonth}-{$day}") - $week_begins)) {
            $newrow = true;
        }
    }
    $pad = 7 - calendar_week_mod($pd->gregurian_date('w', "{$jthisyear}-{$jthismonth}-{$day}", 'eng') - $week_begins);
    if ($pad != 0 && $pad != 7) {
        $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . $pad . '">&nbsp;</td>';
    }
    echo $calendar_output . "\n\t</tr>\n\t</tbody>\n\t</table>";
}
开发者ID:ediablo77,项目名称:wp-parsidate,代码行数:101,代码来源:wp-parsidate.php

示例12: ztjalali_calendar_widget


//.........这里部分代码省略.........
    }
    $calendar_output .= '
	</tr>
	</tfoot>

	<tbody>
	<tr>';
    // Get days with posts
    $dayswithposts = $wpdb->get_results("SELECT DISTINCT post_date\n\t\tFROM {$wpdb->posts} WHERE post_date >= '{$startdate} 00:00:00'\n\t\tAND post_type = 'post' AND post_status = 'publish'\n\t\tAND post_date <= '{$enddate} 23:59:59'", ARRAY_N);
    if ($dayswithposts) {
        foreach ((array) $dayswithposts as $daywith) {
            $jdaywithpost[] = jdate('j', strtotime($daywith[0]), FALSE, FALSE);
        }
    } else {
        $jdaywithpost = array();
    }
    if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false) {
        $ak_title_separator = "\n";
    } else {
        $ak_title_separator = ', ';
    }
    $ak_titles_for_day = array();
    $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, post_date as dom " . "FROM {$wpdb->posts} " . "WHERE post_date >= '{$startdate} 00:00:00' " . "AND post_date <= '{$enddate} 23:59:59' " . "AND post_type = 'post' AND post_status = 'publish'");
    if ($ak_post_titles) {
        foreach ((array) $ak_post_titles as $ak_post_title) {
            /** This filter is documented in wp-includes/post-template.php */
            $post_title = esc_attr(apply_filters('the_title', $ak_post_title->post_title, $ak_post_title->ID));
            $jdom = $jdaywithpost[] = jdate('j', strtotime($ak_post_title->dom), FALSE, FALSE);
            if (empty($ak_titles_for_day['day_' . $jdom])) {
                $ak_titles_for_day['day_' . $jdom] = '';
            }
            if (empty($ak_titles_for_day["{$jdom}"])) {
                // first one
                $ak_titles_for_day["{$jdom}"] = $post_title;
            } else {
                $ak_titles_for_day["{$jdom}"] .= $ak_title_separator . $post_title;
            }
        }
    }
    // See how much we should pad in the beginning
    $pad = calendar_week_mod(jdate('w', $unixmonth, false, false) - $week_begins);
    $pad--;
    if ($pad < 0) {
        $pad = 6;
    }
    if (0 != $pad) {
        $calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr($pad) . '" class="pad">&nbsp;</td>';
    }
    $jdaysinmonth = (int) jdate('t', $unixmonth, FALSE, FALSE);
    for ($jday = 1; $jday <= $jdaysinmonth; ++$jday) {
        if (isset($newrow) && $newrow) {
            $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
        }
        $newrow = false;
        if ($jday == jdate('j', time(), FALSE, FALSE) && $jthismonth == jdate('m', time(), FALSE, FALSE) && $jthisyear == jdate('Y', time(), FALSE, FALSE)) {
            $calendar_output .= '<td id="today">';
        } else {
            $calendar_output .= '<td>';
        }
        if (in_array($jday, $jdaywithpost)) {
            // any posts today?
            $day = jalali_to_gregorian($jthisyear, $jthismonth, $jday);
            if ($ztjalali_option['change_url_date_to_jalali']) {
                $calendar_output .= '<a href="' . get_day_link($jthisyear, $jthismonth, $jday) . '" title="' . esc_attr($ak_titles_for_day[$jday]) . "\">{$jday}</a>";
            } else {
                $calendar_output .= '<a href="' . get_day_link($day[0], $day[1], $day[2]) . '" title="' . esc_attr($ak_titles_for_day[$jday]) . "\">{$jday}</a>";
            }
        } else {
            $calendar_output .= $jday;
        }
        $calendar_output .= '</td>';
        jdate('w', jmktime(0, 0, 0, $jthismonth, $jday, $jthisyear), FALSE, FALSE);
        if (6 == calendar_week_mod(date('w', jmktime(0, 0, 0, $jthismonth, $jday, $jthisyear)) - $week_begins)) {
            $newrow = true;
        }
    }
    $pad = 7 - calendar_week_mod(date('w', jmktime(0, 0, 0, $jthismonth, $jday, $jthisyear)) - $week_begins);
    if ($pad != 0 && $pad != 7) {
        $calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr($pad) . '">&nbsp;</td>';
    }
    $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
    $cache[$key] = $calendar_output;
    wp_cache_set('ztjalali_calendar', $cache, 'calendar');
    if ($ztjalali_option['change_jdate_number_to_persian']) {
        $calendar_output = ztjalali_persian_num($calendar_output);
    }
    if ($echo) {
        /**
         * Filter the HTML calendar output.
         *
         * @since 3.0.0
         *
         * @param string $calendar_output HTML output of the calendar.
         */
        echo apply_filters('ztjalali_calendar', $calendar_output);
    } else {
        /** This filter is documented in wp-includes/general-template.php */
        return apply_filters('ztjalali_calendar', $calendar_output);
    }
}
开发者ID:vah7id,项目名称:wp-persian-openshift,代码行数:101,代码来源:widget_calendar.php

示例13: axiom_get_calendar

 function axiom_get_calendar($onlyFirstLetter = false, $get_month = 0, $get_year = 0, $opt = array())
 {
     global $m, $monthnum, $year, $wp_locale, $posts;
     if (isset($_GET['w'])) {
         $w = '' . intval($_GET['w']);
     }
     // week_begins = 0 stands for Sunday
     $week_begins = intval(get_option('start_of_week'));
     // Let's figure out when we are
     if (!empty($get_month) && !empty($get_year)) {
         $thismonth = '' . zeroise(intval($get_month), 2);
         $thisyear = '' . intval($get_year);
     } else {
         if (!empty($monthnum) && !empty($year)) {
             $thismonth = '' . zeroise(intval($monthnum), 2);
             $thisyear = '' . intval($year);
         } elseif (!empty($w)) {
             $thisyear = '' . intval(substr($m, 0, 4));
             $thismonth = strtotime("+{$w} weeks", "{$thisyear}-01-01");
         } elseif (!empty($m)) {
             $thisyear = '' . intval(substr($m, 0, 4));
             if (strlen($m) < 6) {
                 $thismonth = '01';
             } else {
                 $thismonth = '' . zeroise(intval(substr($m, 4, 2)), 2);
             }
         } else {
             $thisyear = gmdate('Y', current_time('timestamp'));
             $thismonth = gmdate('m', current_time('timestamp'));
         }
     }
     $unixmonth = mktime(0, 0, 0, $thismonth, 1, $thisyear);
     $last_day = date('t', $unixmonth);
     // Post types in array
     $posts_types = explode(',', !empty($opt['post_type']) ? $opt['post_type'] : 'post');
     // Translators: Calendar caption: 1: month name, 2: 4-digit year
     $calendar_caption = _x('%1$s %2$s', 'calendar caption', 'axiom');
     $calendar_output = '<table id="wp-calendar-' . str_replace('.', '', mt_rand()) . '" class="wp-calendar"><thead><tr>';
     // Get the previous month and year with at least one post
     $prev = apply_filters('axiom_filter_calendar_get_prev_month', array(), array('posts_types' => $posts_types, 'year' => $thisyear, 'month' => $thismonth, 'last_day' => $last_day));
     $prev_month = !empty($prev) ? $prev['month'] : 0;
     $prev_year = !empty($prev) ? $prev['year'] : 0;
     $calendar_output .= '<th class="month_prev">';
     if ($prev_year + $prev_month > 0) {
         $calendar_output .= '<a href="#" data-type="' . esc_attr(join(',', $posts_types)) . '" data-year="' . esc_attr($prev_year) . '" data-month="' . esc_attr($prev_month) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s', 'axiom'), $wp_locale->get_month($prev_month), date('Y', mktime(0, 0, 0, $prev_month, 1, $prev_year)))) . '">' . '</a>';
     } else {
         $calendar_output .= '&nbsp;';
     }
     $calendar_output .= '</th>';
     // Get days with posts
     $posts = apply_filters('axiom_filter_calendar_get_curr_month_posts', array(), array('posts_types' => $posts_types, 'year' => $thisyear, 'month' => $thismonth, 'last_day' => $last_day));
     if (count($posts) > (!empty($posts['done']) ? 1 : 0)) {
         // Get the current month and year
         $link = apply_filters('axiom_filter_calendar_get_month_link', '', array('posts_types' => $posts_types, 'year' => $thisyear, 'month' => $thismonth, 'last_day' => $last_day));
     } else {
         $link = '';
     }
     $calendar_output .= '<th class="month_cur" colspan="5">' . ($link ? '<a href="' . esc_url($link) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s', 'axiom'), $wp_locale->get_month($thismonth), date('Y', mktime(0, 0, 0, $thismonth, 1, $thisyear)))) . '">' : '') . sprintf($calendar_caption, $wp_locale->get_month($thismonth), '<span>' . date('Y', $unixmonth) . '</span>') . ($link ? '</a>' : '') . '</th>';
     // Get the next month and year with at least one post
     $next = apply_filters('axiom_filter_calendar_get_next_month', array(), array('posts_types' => $posts_types, 'year' => $thisyear, 'month' => $thismonth, 'last_day' => $last_day));
     $next_month = !empty($next) ? $next['month'] : 0;
     $next_year = !empty($next) ? $next['year'] : 0;
     $calendar_output .= '<th class="month_next">';
     if ($next_year + $next_month > 0) {
         $calendar_output .= '<a href="#" data-type="' . esc_attr(join(',', $posts_types)) . '" data-year="' . esc_attr($next_year) . '" data-month="' . esc_attr($next_month) . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s', 'axiom'), $wp_locale->get_month($next_month), date('Y', mktime(0, 0, 0, $next_month, 1, $next_year)))) . '">' . '</a>';
     } else {
         $calendar_output .= '&nbsp;';
     }
     $calendar_output .= '</th></tr><tr>';
     // Show Week days
     $myweek = array();
     for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
         $myweek[] = $wp_locale->get_weekday(($wdcount + $week_begins) % 7);
     }
     foreach ($myweek as $wd) {
         $day_name = $onlyFirstLetter ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
         $wd = esc_attr($wd);
         $calendar_output .= "<th class=\"weekday\" scope=\"col\" title=\"{$wd}\">{$day_name}</th>";
     }
     $calendar_output .= '</tr></thead><tbody><tr>';
     // See how much we should pad in the beginning
     $pad = calendar_week_mod(date('w', $unixmonth) - $week_begins);
     if ($pad != 0) {
         $calendar_output .= '<td colspan="' . esc_attr($pad) . '" class="pad"><span class="day_wrap">&nbsp;</span></td>';
     }
     $daysinmonth = intval(date('t', $unixmonth));
     for ($day = 1; $day <= $daysinmonth; ++$day) {
         if (isset($newrow) && $newrow) {
             $calendar_output .= "</tr><tr>";
         }
         $newrow = false;
         if ($day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp'))) {
             $calendar_output .= '<td class="today">';
         } else {
             $calendar_output .= '<td class="day">';
         }
         if (!empty($posts[$day])) {
             $calendar_output .= '<a class="day_wrap" href="' . esc_url(!empty($posts[$day]['link']) ? $posts[$day]['link'] : get_day_link($thisyear, $thismonth, $day)) . '" title="' . esc_attr(is_int($posts[$day]['titles']) ? $posts[$day]['titles'] . ' ' . __('items', 'axiom') : $posts[$day]['titles']) . "\">{$day}</a>";
         } else {
             $calendar_output .= '<span class="day_wrap">' . $day . '</span>';
//.........这里部分代码省略.........
开发者ID:pcuervo,项目名称:odc,代码行数:101,代码来源:core.wp.php

示例14: getThemeRexCalendar


//.........这里部分代码省略.........
            $wd = esc_attr($wd);
            $calendar_output .= "\n\t\t\t\t\t<th scope=\"col\" title=\"{$wd}\">{$day_name}</th>";
        }
        $calendar_output .= '
				</tr>
			</thead>

			<tbody>
				<tr>';
        // Get days with posts
        $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH({$sql_date})\n\t\t\tFROM {$sql_from}\n\t\t\tWHERE {$sql_status} AND\n\t\t\t\t(" . (!empty($post_type) ? "({$sql_post_type} AND {$wpdb->posts}.post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' AND {$wpdb->posts}.post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59')" : '') . ($events_present ? (!empty($post_type) ? ' OR ' : '') . "\n\t\t\t\t\t\t\t{$wpdb->posts}.post_type = 'tribe_events' AND {$wpdb->postmeta}.meta_key = '_EventStartDate'\n\t\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t\t({$wpdb->postmeta}.meta_value >= '{$thisyear}-{$thismonth}-01 00:00:00' AND {$wpdb->postmeta}.meta_value <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59')\n\t\t\t\t\t\t\t\tOR (tribe_event_end_date.meta_value >= '{$thisyear}-{$thismonth}-01 00:00:00' AND tribe_event_end_date.meta_value <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59')\n\t\t\t\t\t\t\t\tOR ({$wpdb->postmeta}.meta_value < '{$thisyear}-{$thismonth}-01' AND tribe_event_end_date.meta_value >= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59')\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t" : '') . ")", ARRAY_N);
        if ($dayswithposts) {
            foreach ((array) $dayswithposts as $daywith) {
                $daywithpost[] = $daywith[0];
            }
        } else {
            $daywithpost = array();
        }
        if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false) {
            $ak_title_separator = "\n";
        } else {
            $ak_title_separator = ', ';
        }
        $ak_titles_for_day = array();
        $ak_post_titles = $wpdb->get_results("SELECT {$wpdb->posts}.ID, {$wpdb->posts}.post_title, DAYOFMONTH({$sql_date}) as dom\n\t\t\tFROM {$sql_from}\n\t\t\tWHERE {$sql_status} AND\n\t\t\t\t(" . (!empty($post_type) ? "({$sql_post_type} AND {$wpdb->posts}.post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' AND {$wpdb->posts}.post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59')" : '') . ($events_present ? (!empty($post_type) ? ' OR ' : '') . "\n\t\t\t\t\t\t\t{$wpdb->posts}.post_type = 'tribe_events' AND {$wpdb->postmeta}.meta_key = '_EventStartDate'\n\t\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t\t({$wpdb->postmeta}.meta_value >= '{$thisyear}-{$thismonth}-01 00:00:00' AND {$wpdb->postmeta}.meta_value <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59')\n\t\t\t\t\t\t\t\tOR (tribe_event_end_date.meta_value >= '{$thisyear}-{$thismonth}-01 00:00:00' AND tribe_event_end_date.meta_value <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59')\n\t\t\t\t\t\t\t\tOR ({$wpdb->postmeta}.meta_value < '{$thisyear}-{$thismonth}-01' AND tribe_event_end_date.meta_value >= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59')\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t" : '') . ")");
        if ($ak_post_titles) {
            foreach ((array) $ak_post_titles as $ak_post_title) {
                /** This filter is documented in wp-includes/post-template.php */
                $post_title = esc_attr(apply_filters('the_title', $ak_post_title->post_title, $ak_post_title->ID));
                if (empty($ak_titles_for_day['day_' . $ak_post_title->dom])) {
                    $ak_titles_for_day['day_' . $ak_post_title->dom] = '';
                }
                if (empty($ak_titles_for_day["{$ak_post_title->dom}"])) {
                    // first one
                    $ak_titles_for_day["{$ak_post_title->dom}"] = $post_title;
                } else {
                    $ak_titles_for_day["{$ak_post_title->dom}"] .= $ak_title_separator . $post_title;
                }
            }
        }
        // See how much we should pad in the beginning
        $pad = calendar_week_mod(date('w', $unixmonth) - $week_begins);
        if (0 != $pad) {
            $calendar_output .= '
					<td colspan="' . esc_attr($pad) . '" class="pad">&nbsp;</td>';
        }
        $daysinmonth = intval(date('t', $unixmonth));
        for ($day = 1; $day <= $daysinmonth; ++$day) {
            if (isset($newrow) && $newrow) {
                $calendar_output .= "\n\t\t\t\t</tr>\n\t\t\t\t<tr>";
            }
            $newrow = false;
            if ($day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp'))) {
                $calendar_output .= '
					<td class="today">';
            } else {
                $calendar_output .= '
					<td>';
            }
            if (in_array($day, $daywithpost)) {
                // any posts today?
                $calendar_output .= '<a href="' . (empty($post_type) && $events_present ? $events->getLink('day', $thisyear . '-' . $thismonth . '-' . $day, null) : get_day_link($thisyear, $thismonth, $day)) . '" title="' . esc_attr($ak_titles_for_day[$day]) . "\">{$day}</a>";
            } else {
                $calendar_output .= '<span>' . $day . '</span>';
            }
            $calendar_output .= '</td>';
            if (6 == calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins)) {
                $newrow = true;
            }
        }
        $pad = 7 - calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins);
        if ($pad != 0 && $pad != 7) {
            $calendar_output .= '
					<td class="pad" colspan="' . esc_attr($pad) . '">&nbsp;</td>';
        }
        $calendar_output .= "\n\t\t\t\t</tr>\n\t\t\t</tbody>\n\t\t";
        $calendar_output .= '<tfoot>
                    <tr>
				<th colspan="4" class="prevMonth">';
        if ($prev_year + $prev_month > 0) {
            $calendar_output .= '<div class="left"><a href="#" data-type="' . esc_attr($post_type_full) . '" data-year="' . $prev_year . '" data-month="' . $prev_month . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s', 'themerex'), $wp_locale->get_month($prev_month), date('Y', mktime(0, 0, 0, $prev_month, 1, $prev_year)))) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($prev_month)) . '</a></div>';
        } else {
            $calendar_output .= '&nbsp;';
        }
        $calendar_output .= '
				</th>
				<th colspan="3" class="nextMonth">';
        if ($next_year + $next_month > 0) {
            $calendar_output .= '<div class="right"><a href="#" data-type="' . esc_attr($post_type_full) . '" data-year="' . $next_year . '" data-month="' . $next_month . '" title="' . esc_attr(sprintf(__('View posts for %1$s %2$s', 'themerex'), $wp_locale->get_month($next_month), date('Y', mktime(0, 0, 0, $next_month, 1, $next_year)))) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . '</a></div>';
        } else {
            $calendar_output .= '&nbsp;';
        }
        $calendar_output .= '
				</th>
			</tr>
		</tfoot>
			';
        $calendar_output .= "</table>";
        return $calendar_output;
    }
开发者ID:WestBayResidential,项目名称:wbrsorg,代码行数:101,代码来源:_wp_utils.php

示例15: get_future_calendar

function get_future_calendar($thismonth = '', $thisyear = '', $onclick = 1, $initial = true)
{
    global $wpdb, $timedifference, $wp_locale;
    $unixmonth = mktime(0, 0, 0, $thismonth, 1, $thisyear);
    // week_begins = 0 stands for Sunday
    $week_begins = intval(get_option('start_of_week'));
    $add_hours = intval(get_option('gmt_offset'));
    $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours));
    echo '<table id="wp-calendar">
	<caption><em>' . $wp_locale->get_month($thismonth) . ' ' . $thisyear . '</em></caption>
	<thead>
	<tr>';
    $myweek = array();
    for ($wdcount = 0; $wdcount <= 6; $wdcount++) {
        $myweek[] = $wp_locale->get_weekday(($wdcount + $week_begins) % 7);
    }
    foreach ($myweek as $wd) {
        $day_name = true == $initial ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
        echo "\n\t\t<th abbr=\"{$wd}\" scope=\"col\" title=\"{$wd}\">{$day_name}</th>";
    }
    echo '
	</tr>
	</thead>
	<tbody>
	<tr>';
    // Get days with posts
    $dayswithposts = $wpdb->get_results("\r\n\t\tSELECT \r\n\t\tDISTINCT DAYOFMONTH(meta_value)\r\n\t\tFROM {$wpdb->posts} \r\n    \t\tINNER JOIN {$wpdb->postmeta} \r\n\t\tWHERE MONTH({$wpdb->postmeta}.meta_value) = '{$thismonth}'\r\n\t\tAND YEAR({$wpdb->postmeta}.meta_value) = '{$thisyear}'\r\n\t\tAND {$wpdb->posts}.post_type = 'appointment' \r\n\t\tAND {$wpdb->posts}.post_status = 'publish'\r\n\t\tAND {$wpdb->postmeta}.meta_value > '" . current_time('mysql') . '\'', ARRAY_N);
    if ($dayswithposts) {
        foreach ($dayswithposts as $daywith) {
            $daywithpost[] = $daywith[0];
        }
    } else {
        $daywithpost = array();
    }
    if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'camino') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'safari')) {
        $ak_title_separator = "\n";
    } else {
        $ak_title_separator = ', ';
    }
    $ak_titles_for_day = array();
    //sets the Density Thermometer
    $ak_posts_for_day = array();
    $ak_post_titles = $wpdb->get_results("\r\n\t\tSELECT post_title, DAYOFMONTH(meta_value) as dom \r\n\t\tFROM {$wpdb->posts} \r\n    \t\tINNER JOIN {$wpdb->postmeta} \r\n\t\tWHERE YEAR({$wpdb->postmeta}.meta_value) = '{$thisyear}' \r\n\t\tAND MONTH({$wpdb->postmeta}.meta_value) = '{$thismonth}' \r\n\t\tAND {$wpdb->postmeta}.meta_value > '" . current_time('mysql') . "' \r\n\t\tAND {$wpdb->posts}.post_type = 'appointment' AND {$wpdb->posts}.post_status = 'publish'");
    if ($ak_post_titles) {
        foreach ($ak_post_titles as $ak_post_title) {
            if (empty($ak_titles_for_day['day_' . $ak_post_title->dom])) {
                $ak_titles_for_day['day_' . $ak_post_title->dom] = '';
            }
            if (empty($ak_titles_for_day["{$ak_post_title->dom}"])) {
                // first one
                $ak_titles_for_day["{$ak_post_title->dom}"] = str_replace('"', '&quot;', wptexturize($ak_post_title->post_title));
            } else {
                $ak_titles_for_day["{$ak_post_title->dom}"] .= $ak_title_separator . str_replace('"', '&quot;', wptexturize($ak_post_title->post_title));
            }
            $ak_posts_for_day["{$ak_post_title->dom}"] += 1;
        }
    }
    // See how much we should pad in the beginning
    $pad = calendar_week_mod(date('w', $unixmonth) - $week_begins);
    if (0 != $pad) {
        echo "\n\t\t" . '<td colspan="' . $pad . '" class="pad">&nbsp;</td>';
    }
    //Determines the Density Thermometer colors
    $thermo = array("#BDFFBE", "#7AFFDE", "#2FEEFF", "#108BFF", "#0E72FF");
    $daysinmonth = intval(date('t', $unixmonth));
    for ($day = 1; $day <= $daysinmonth; ++$day) {
        if (isset($newrow) && $newrow) {
            echo "\n\t</tr>\n\t<tr>\n\t\t";
        }
        $newrow = false;
        if ($day == gmdate('j', time() + get_option('gmt_offset') * 3600) && $thismonth == gmdate('m', time() + get_option('gmt_offset') * 3600) && $thisyear == gmdate('Y', time() + get_option('gmt_offset') * 3600)) {
            echo '<td style="font-weight:bold;">';
        } else {
            echo '<td>';
        }
        if ($onclick == 1) {
            $onclick1 = 'onclick="fcal_set_date(' . $day . ',' . ($thismonth - 1) . ',' . $thisyear . ')"';
        }
        // any posts on that day?
        if (in_array($day, $daywithpost)) {
            //Outputs the Density Thermometer along with the day...
            echo '<span style="padding:5px;background-color:' . ($ak_posts_for_day[$day] <= Count($thermo) ? $thermo[$ak_posts_for_day[$day] - 1] : $thermo[Count($thermo) - 1]) . ';" title="' . $ak_titles_for_day[$day] . ' ' . $onclick1 . '">' . $day . '</span>';
        } else {
            echo '<span ' . $onclick1 . ' >' . $day . '</span>';
        }
        echo '</td>';
        if (6 == calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins)) {
            $newrow = true;
        }
    }
    $pad = 7 - calendar_week_mod(date('w', mktime(0, 0, 0, $thismonth, $day, $thisyear)) - $week_begins);
    if ($pad != 0 && $pad != 7) {
        echo "\n\t\t" . '<td class="pad" colspan="' . $pad . '">&nbsp;</td>';
    }
    echo "\n\t</tr>\n\t</tbody>\n\t</table>";
}
开发者ID:basoro,项目名称:dentix,代码行数:96,代码来源:widgets.php


注:本文中的calendar_week_mod函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。