function my_calendar_insert($atts, $content = null) { extract(shortcode_atts(array('name' => 'all', 'format' => 'calendar', 'category' => 'all', 'time' => 'month', 'ltype' => '', 'lvalue' => '', 'author' => 'all', 'host' => 'all', 'id' => 'jd-calendar', 'template' => '', 'above' => '', 'below' => ''), $atts, 'my_calendar')); if ($format != 'mini') { if (isset($_GET['format'])) { $format = esc_sql($_GET['format']); } } global $user_ID; if ($author == 'current') { $author = apply_filters('mc_display_author', $user_ID, 'main'); } if ($host == 'current') { $host = apply_filters('mc_display_host', $user_ID, 'main'); } return my_calendar($name, $format, $category, $time, $ltype, $lvalue, $id, $template, $content, $author, $host, $above, $below); }
function my_calendar_print() { $url = plugin_dir_url(__FILE__); $time = isset($_GET['time']) ? $_GET['time'] : 'month'; $category = isset($_GET['mcat']) ? $_GET['mcat'] : ''; // these are sanitized elsewhere $ltype = isset($_GET['ltype']) ? $_GET['ltype'] : ''; $lvalue = isset($_GET['lvalue']) ? $_GET['lvalue'] : ''; header('Content-Type: ' . get_bloginfo('html_type') . '; charset=' . get_bloginfo('charset')); echo '<!DOCTYPE html> <!--[if IE 7]> <html id="ie7" dir="' . get_bloginfo('text_direction') . '" lang="' . get_bloginfo('language') . '"> <![endif]--> <!--[if IE 8]> <html id="ie8" dir="' . get_bloginfo('text_direction') . '" lang="' . get_bloginfo('language') . '"> <![endif]--> <!--[if !(IE 6) | !(IE 7) | !(IE 8) ]><!--> <html dir="' . get_bloginfo('text_direction') . '" lang="' . get_bloginfo('language') . '"> <!--<![endif]--> <head> <meta charset="' . get_bloginfo('charset') . '" /> <meta name="viewport" content="width=device-width" /> <title>' . get_bloginfo('name') . ' - ' . __('Calendar: Print View', 'my-calendar') . '</title> <meta name="generator" content="My Calendar for WordPress" /> <meta name="robots" content="noindex,nofollow" />'; if (mc_file_exists('css/mc-print.css')) { $stylesheet = mc_get_file('css/mc-print.css', 'url'); } else { $stylesheet = $url . "css/mc-print.css"; } echo "\n<!-- Copy mc-print.css to your theme directory if you wish to replace the default print styles -->\n<link rel='stylesheet' href='{$stylesheet}' type='text/css' media='screen,print' />\n</head>\n<body>\n"; echo my_calendar('print', 'calendar', $category, $time, $ltype, $lvalue, 'mc-print-view', '', '', null, null, '', ''); $return_url = get_option('mc_uri') != '' && !is_numeric(get_option('mc_uri')) ? get_option('mc_uri') : home_url(); $add = $_GET; unset($add['cid']); unset($add['feed']); $return_url = mc_build_url($add, array('feed', 'cid'), $return_url); echo "<p class='return'><a href='{$return_url}'>" . __('Return to site', 'my-calendar') . "</a></p>"; echo ' </body> </html>'; }
} ?> <?php for ($d = $start; $d <= $end; $d++) { if (!($i++ % 7)) { echo " <tr>\n"; } echo ' <td align="center"><div><b>'; if ($d < 1 or $d > $day_count) { echo "<span class='noneEmpty'></span>"; } else { $now = "{$y}-{$m}-" . sprintf("%02d", $d); if (is_array($fill) and in_array($now, $fill)) { echo CHtml::link($d, array('/site/news/', 'date' => $now)); } else { echo $d; } } echo "</b></div></td>\n"; if (!($i % 7)) { echo " </tr>\n"; } } ?> </table> <?php } my_calendar($arr);
function widget($args, $instance) { extract($args); $name = $format = 'mini'; if (!empty($instance)) { $the_title = apply_filters('widget_title', $instance['my_calendar_mini_title'], $instance, $args); $category = $instance['my_calendar_mini_category'] == '' ? 'all' : esc_attr($instance['my_calendar_mini_category']); $time = $instance['my_calendar_mini_time'] == '' ? 'month' : esc_attr($instance['my_calendar_mini_time']); $widget_link = !isset($instance['mc_link']) || $instance['mc_link'] == '' ? '' : esc_url($instance['mc_link']); $above = empty($instance['above']) ? 'none' : esc_attr($instance['above']); $below = empty($instance['below']) ? 'none' : esc_attr($instance['below']); $author = !isset($instance['author']) || $instance['author'] == '' ? null : esc_attr($instance['author']); $host = !isset($instance['host']) || $instance['host'] == '' ? null : esc_attr($instance['host']); } else { $the_title = $category = $time = $widget_link = $above = $below = ''; } $title = empty($the_title) ? __('Calendar', 'my-calendar') : $the_title; $title = $widget_link != '' ? "<a href='{$widget_link}'>{$title}</a>" : $title; $title = $title != '' ? $before_title . $title . $after_title : ''; $the_events = my_calendar($name, $format, $category, $time, '', '', 'jd-calendar', '', '', $author, $host, $above, $below); if ($the_events != '') { echo $before_widget . $title . $the_events . $after_widget; } }
function widget($args, $instance) { extract($args); if (!empty($instance)) { $the_title = apply_filters('widget_title', $instance['my_calendar_mini_title'], $instance, $args); $category = $instance['my_calendar_mini_category'] == '' ? 'all' : $instance['my_calendar_mini_category']; $time = $instance['my_calendar_mini_time'] == '' ? 'month' : $instance['my_calendar_mini_time']; $widget_link = !isset($instance['mc_link']) || $instance['mc_link'] == '' ? '' : esc_url($instance['mc_link']); $above = empty($instance['above']) ? 'none' : $instance['above']; $below = empty($instance['below']) ? 'none' : $instance['below']; $author = !isset($instance['author']) || $instance['author'] == '' ? null : $instance['author']; $host = !isset($instance['host']) || $instance['host'] == '' ? null : $instance['host']; $site = !isset($instance['site']) || $instance['site'] == '' ? false : $instance['site']; } else { $the_title = $category = $time = $widget_link = $above = $below = ''; } if ($the_title != '') { $title = $widget_link != '' ? "<a href='{$widget_link}'>{$the_title}</a>" : $the_title; $title = $title != '' ? $before_title . $title . $after_title : ''; } else { $title = ''; } $the_events = my_calendar('mini', 'mini', $category, $time, '', '', str_replace('my_calendar', 'mc', $args['widget_id']), '', '', $author, $host, $above, $below, false, false, false, 'widget', $site); if ($the_events != '') { echo $before_widget . $title . $the_events . $after_widget; } }
function my_calendar_print() { $url = plugin_dir_url(__FILE__); $time = isset($_GET['time']) ? $_GET['time'] : 'month'; $category = isset($_GET['mcat']) ? $_GET['mcat'] : ''; // these are sanitized elsewhere $ltype = isset($_GET['ltype']) ? $_GET['ltype'] : ''; $lvalue = isset($_GET['lvalue']) ? $_GET['lvalue'] : ''; header('Content-Type: ' . get_bloginfo('html_type') . '; charset=' . get_bloginfo('charset')); if (mc_file_exists('css/mc-print.css')) { $stylesheet = mc_get_file('css/mc-print.css', 'url'); } else { $stylesheet = $url . "css/mc-print.css"; } $rtl = is_rtl() ? 'rtl' : 'ltr'; $head = '<!DOCTYPE html> <html dir="' . $rtl . '" lang="' . get_bloginfo('language') . '"> <!--<![endif]--> <head> <meta charset="' . get_bloginfo('charset') . '" /> <meta name="viewport" content="width=device-width" /> <title>' . get_bloginfo('name') . ' - ' . __('Calendar: Print View', 'my-calendar') . '</title> <meta name="generator" content="My Calendar for WordPress" /> <meta name="robots" content="noindex,nofollow" /> <!-- Copy mc-print.css to your theme directory if you wish to replace the default print styles --> <link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen,print" /> </head> <body>'; echo $head; echo my_calendar('print', 'calendar', $category, $time, $ltype, $lvalue, 'mc-print-view', '', '', null, null, 'none', 'none'); $return_url = get_option('mc_uri') != '' && !is_numeric(get_option('mc_uri')) ? get_option('mc_uri') : home_url(); $return_url = apply_filters('mc_print_return_url', $return_url, $category, $time, $ltype, $lvalue); if (isset($_GET['href'])) { $ref_url = esc_url(urldecode($_GET['href'])); if ($ref_url) { $return_url = $ref_url; } } $add = array_map('esc_sql', $_GET); unset($add['cid']); unset($add['feed']); unset($add['href']); $return_url = mc_build_url($add, array('feed', 'cid', 'href'), $return_url); echo "<p class='return'><a href='{$return_url}'>" . __('Return to calendar', 'my-calendar') . "</a></p>"; echo ' </body> </html>'; }
<?php if (isset($_GET['date'])) { echo "выбрана дата " . $_GET['date']; } my_calendar(array(date("Y-m-d"))); function my_calendar($fill = array()) { $month_names = array("январь", "февраль", "март", "апрель", "май", "июнь", "июль", "август", "сентябрь", "октябрь", "ноябрь", "декабрь"); if (isset($_GET['y'])) { $y = $_GET['y']; } if (isset($_GET['m'])) { $m = $_GET['m']; } if (isset($_GET['date']) and strstr($_GET['date'], "-")) { list($y, $m) = explode("-", $_GET['date']); } if (!isset($y) or $y < 1970 or $y > 2037) { $y = date("Y"); } if (!isset($m) or $m < 1 or $m > 12) { $m = date("m"); } $month_stamp = mktime(0, 0, 0, $m, 1, $y); $day_count = date("t", $month_stamp); $weekday = date("w", $month_stamp); if ($weekday == 0) { $weekday = 7; } $start = -($weekday - 2);