Ejemplo n.º 1
0
function minical($cat_list = '')
{
    global $wpdb;
    // Deal with the week not starting on a monday
    if (get_option('start_of_week') == 0) {
        $name_days = array(1 => __('Su', 'calendar'), __('Mo', 'calendar'), __('Tu', 'calendar'), __('We', 'calendar'), __('Th', 'calendar'), __('Fr', 'calendar'), __('Sa', 'calendar'));
    } else {
        $name_days = array(1 => __('Mo', 'calendar'), __('Tu', 'calendar'), __('We', 'calendar'), __('Th', 'calendar'), __('Fr', 'calendar'), __('Sa', 'calendar'), __('Su', 'calendar'));
    }
    // Carry on with the script
    $name_months = array(1 => __('January', 'calendar'), __('February', 'calendar'), __('March', 'calendar'), __('April', 'calendar'), __('May', 'calendar'), __('June', 'calendar'), __('July', '\\
calendar'), __('August', 'calendar'), __('September', 'calendar'), __('October', 'calendar'), __('November', 'calendar'), __('December', 'calendar'));
    // If we don't pass arguments we want a calendar that is relevant to today
    if (empty($_GET['month']) || empty($_GET['yr'])) {
        $c_year = date("Y", ctwo());
        $c_month = date("m", ctwo());
        $c_day = date("d", ctwo());
    }
    // Years get funny if we exceed 3000, so we use this check
    if (isset($_GET['yr'])) {
        if ($_GET['yr'] <= 3000 && $_GET['yr'] >= 0 && (int) $_GET['yr'] != 0) {
            // This is just plain nasty and all because of permalinks
            // which are no longer used, this will be cleaned up soon
            if ($_GET['month'] == 'jan' || $_GET['month'] == 'feb' || $_GET['month'] == 'mar' || $_GET['month'] == 'apr' || $_GET['month'] == 'may' || $_GET['month'] == 'jun' || $_GET['month'] == 'jul' || $_GET['month'] == 'aug' || $_GET['month'] == 'sep' || $_GET['month'] == 'oct' || $_GET['month'] == 'nov' || $_GET['month'] == 'dec') {
                // Again nasty code to map permalinks into something
                // databases can understand. This will be cleaned up
                $c_year = $wpdb->prepare("%d", $_GET['yr']);
                if ($_GET['month'] == 'jan') {
                    $t_month = 1;
                } else {
                    if ($_GET['month'] == 'feb') {
                        $t_month = 2;
                    } else {
                        if ($_GET['month'] == 'mar') {
                            $t_month = 3;
                        } else {
                            if ($_GET['month'] == 'apr') {
                                $t_month = 4;
                            } else {
                                if ($_GET['month'] == 'may') {
                                    $t_month = 5;
                                } else {
                                    if ($_GET['month'] == 'jun') {
                                        $t_month = 6;
                                    } else {
                                        if ($_GET['month'] == 'jul') {
                                            $t_month = 7;
                                        } else {
                                            if ($_GET['month'] == 'aug') {
                                                $t_month = 8;
                                            } else {
                                                if ($_GET['month'] == 'sep') {
                                                    $t_month = 9;
                                                } else {
                                                    if ($_GET['month'] == 'oct') {
                                                        $t_month = 10;
                                                    } else {
                                                        if ($_GET['month'] == 'nov') {
                                                            $t_month = 11;
                                                        } else {
                                                            if ($_GET['month'] == 'dec') {
                                                                $t_month = 12;
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                $c_month = $t_month;
                $c_day = date("d", ctwo());
            } else {
                $c_year = date("Y", ctwo());
                $c_month = date("m", ctwo());
                $c_day = date("d", ctwo());
            }
        }
    } else {
        $c_year = date("Y", ctwo());
        $c_month = date("m", ctwo());
        $c_day = date("d", ctwo());
    }
    // Fix the days of the week if week start is not on a monday
    if (get_option('start_of_week') == 0) {
        $first_weekday = date("w", mktime(0, 0, 0, $c_month, 1, $c_year));
        $first_weekday = $first_weekday == 0 ? 1 : $first_weekday + 1;
    } else {
        $first_weekday = date("w", mktime(0, 0, 0, $c_month, 1, $c_year));
        $first_weekday = $first_weekday == 0 ? 7 : $first_weekday;
    }
    $days_in_month = date("t", mktime(0, 0, 0, $c_month, 1, $c_year));
    // Start the table and add the header and naviagtion
    $calendar_body = '';
    $calendar_body .= '<div style="width:100%;"><table cellspacing="1" cellpadding="0" class="calendar-table">
';
    // Add Saranac header
    $img_path = get_stylesheet_directory_uri() . "/images/Saranac-Cal-summer.png";
    $calendar_body .= '<tr>
                    <td colspan="7"><img src="' . $img_path . '"></td>
                    </tr>';
    // The header of the calendar table and the links. Note calls to link functions
    $calendar_body .= '<tr>
               <td colspan="7" class="calendar-heading" style="height:0;">
                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                            <td class="calendar-prev">' . prev_link($c_year, $c_month, true) . '</td>
                            <td class="calendar-month">' . $name_months[(int) $c_month] . ' ' . $c_year . '</td>
                            <td class="calendar-next">' . next_link($c_year, $c_month, true) . '</td>
                        </tr>
                    </table>
               </td>
</tr>
';
    // Print the headings of the days of the week
    $calendar_body .= '<tr>
';
    for ($i = 1; $i <= 7; $i++) {
        // Colours need to be different if the starting day of the week is different
        if (get_option('start_of_week') == 0) {
            $calendar_body .= '        <td class="' . ($i < 7 && $i > 1 ? 'normal-day-heading' : 'weekend-heading') . '" style="height:0;">' . $name_days[$i] . '</td>
';
        } else {
            $calendar_body .= '        <td class="' . ($i < 6 ? 'normal-day-heading' : 'weekend-heading') . '" style="height:0;">' . $name_days[$i] . '</td>
';
        }
    }
    $calendar_body .= '</tr>
';
    $go = FALSE;
    for ($i = 1; $i <= $days_in_month;) {
        $calendar_body .= '<tr>
';
        for ($ii = 1; $ii <= 7; $ii++) {
            if ($ii == $first_weekday && $i == 1) {
                $go = TRUE;
            } elseif ($i > $days_in_month) {
                $go = FALSE;
            }
            if ($go) {
                // Colours again, this time for the day numbers
                if (get_option('start_of_week') == 0) {
                    // This bit of code is for styles believe it or not.
                    $grabbed_events = grab_events($c_year, $c_month, $i, 'calendar', $cat_list);
                    $no_events_class = '';
                    if (!count($grabbed_events)) {
                        $no_events_class = ' no-events';
                    }
                    $calendar_body .= '        <td class="' . (date("Ymd", mktime(0, 0, 0, $c_month, $i, $c_year)) == date("Ymd", ctwo()) ? 'current-day' : 'day-with-date') . $no_events_class . '" style="height:0;"><span ' . ($ii < 7 && $ii > 1 ? '' : 'class="weekend"') . '>' . minical_draw_events($grabbed_events, $i++) . '</span></td>
';
                } else {
                    $grabbed_events = grab_events($c_year, $c_month, $i, 'calendar', $cat_list);
                    $no_events_class = '';
                    if (!count($grabbed_events)) {
                        $no_events_class = ' no-events';
                    }
                    $calendar_body .= '        <td class="' . (date("Ymd", mktime(0, 0, 0, $c_month, $i, $c_year)) == date("Ymd", ctwo()) ? 'current-day' : 'day-with-date') . $no_events_class . '" style="height:0;"><span ' . ($ii < 6 ? '' : 'class="weekend"') . '>' . minical_draw_events($grabbed_events, $i++) . '</span></td>
';
                }
            } else {
                $calendar_body .= '        <td class="day-without-date" style="height:0;">&nbsp;</td>
';
            }
        }
        $calendar_body .= '</tr>
';
    }
    $calendar_body .= '</table>
';
    // A little link to yours truly
    $link_approved = 'false';
    $link_approved_results = $wpdb->get_results("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='show_attribution_link'");
    foreach ($link_approved_results as $link_approved_item) {
        if ($link_approved_item->config_value == 'true') {
            $link_approved = 'true';
        }
    }
    if ($link_approved == 'true') {
        $linkback_url = '<div class="kjo-link" style="visibility:visible !important;display:block !important;"><p>' . __('Calendar by ', 'calendar') . '<a href="http://www.kieranoshea.com">Kieran O\'Shea</a></p></div>
';
    } else {
        $linkback_url = '';
    }
    $calendar_body .= $linkback_url;
    // Closing div
    $calendar_body .= '</div>
';
    // Phew! After that bit of string building, spit it all out.
    // The actual printing is done by the calling function.
    return $calendar_body;
}
Ejemplo n.º 2
0
&title=<?php 
echo the_title();
?>
'><img border='0' src='<?php 
echo theme_dir();
?>
img/delicious.png' width='16' height='16' hspace='1' alt='Del.icio.us'></a>
<a href='ymsgr:im?msg=ino bebin - <?php 
echo the_link();
?>
'><img border='0' src='<?php 
echo theme_dir();
?>
img/yahoo.gif' width='16' height='16' hspace='1'></a>
</span> <div class='link'> «<a href='<?php 
echo next_link();
?>
'>لینک بعدی</a> | <a href='index.php'>لینکدونی</a> | <a href='<?php 
echo prev_link();
?>
'>لینک قبلی</a> » </div>
	

	</div>
	<iframe name='contentframe' bordercolor='#ffffff' src='<?php 
echo the_link();
?>
' width='100%' height='95%' border='0' frameborder='0'></iframe>
</body>

</html>
Ejemplo n.º 3
0
            ?>
)</a></div>
		</a>			
		 </div>
<?php 
        }
        ?>

<div class="bottom">
				<?php 
        wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number'));
        ?>
				
				<?php 
        previous_link();
        next_link();
        ?>
	<br /><br />
</div>				
				
		</div>
		<?php 
    }
}
?>
		
         <?php 
edit_post_link(__('Edit this entry'));
?>
	</div>
Ejemplo n.º 4
0
function calendar()
{
    global $wpdb;
    // First things first, make sure calendar is up to date
    check_calendar();
    // Deal with the week not starting on a monday
    if (get_option('start_of_week') == 0) {
        $name_days = array(1 => __('Sunday', 'calendar'), __('Monday', 'calendar'), __('Tuesday', 'calendar'), __('Wednesday', 'calendar'), __('Thursday', 'calendar'), __('Friday', 'calendar'), __('Saturday', 'calendar'));
    } else {
        $name_days = array(1 => __('Monday', 'calendar'), __('Tuesday', 'calendar'), __('Wednesday', 'calendar'), __('Thursday', 'calendar'), __('Friday', 'calendar'), __('Saturday', 'calendar'), __('Sunday', 'calendar'));
    }
    // Carry on with the script
    $name_months = array(1 => __('January', 'calendar'), __('February', 'calendar'), __('March', 'calendar'), __('April', 'calendar'), __('May', 'calendar'), __('June', 'calendar'), __('July', 'calendar'), __('August', 'calendar'), __('September', 'calendar'), __('October', 'calendar'), __('November', 'calendar'), __('December', 'calendar'));
    // If we don't pass arguments we want a calendar that is relevant to today
    if (empty($_GET['month']) || empty($_GET['yr'])) {
        $c_year = date("Y");
        $c_month = date("m");
        $c_day = date("d");
    }
    // Years get funny if we exceed 3000, so we use this check
    if ($_GET['yr'] <= 3000 && $_GET['yr'] >= 0) {
        // This is just plain nasty and all because of permalinks
        // which are no longer used, this will be cleaned up soon
        if ($_GET['month'] == 'jan' || $_GET['month'] == 'feb' || $_GET['month'] == 'mar' || $_GET['month'] == 'apr' || $_GET['month'] == 'may' || $_GET['month'] == 'jun' || $_GET['month'] == 'jul' || $_GET['month'] == 'aug' || $_GET['month'] == 'sept' || $_GET['month'] == 'oct' || $_GET['month'] == 'nov' || $_GET['month'] == 'dec') {
            // Again nasty code to map permalinks into something
            // databases can understand. This will be cleaned up
            $c_year = mysql_escape_string($_GET['yr']);
            if ($_GET['month'] == 'jan') {
                $t_month = 1;
            } else {
                if ($_GET['month'] == 'feb') {
                    $t_month = 2;
                } else {
                    if ($_GET['month'] == 'mar') {
                        $t_month = 3;
                    } else {
                        if ($_GET['month'] == 'apr') {
                            $t_month = 4;
                        } else {
                            if ($_GET['month'] == 'may') {
                                $t_month = 5;
                            } else {
                                if ($_GET['month'] == 'jun') {
                                    $t_month = 6;
                                } else {
                                    if ($_GET['month'] == 'jul') {
                                        $t_month = 7;
                                    } else {
                                        if ($_GET['month'] == 'aug') {
                                            $t_month = 8;
                                        } else {
                                            if ($_GET['month'] == 'sept') {
                                                $t_month = 9;
                                            } else {
                                                if ($_GET['month'] == 'oct') {
                                                    $t_month = 10;
                                                } else {
                                                    if ($_GET['month'] == 'nov') {
                                                        $t_month = 11;
                                                    } else {
                                                        if ($_GET['month'] == 'dec') {
                                                            $t_month = 12;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            $c_month = $t_month;
            $c_day = date("d");
        } else {
            $c_year = date("Y");
            $c_month = date("m");
            $c_day = date("d");
        }
    } else {
        $c_year = date("Y");
        $c_month = date("m");
        $c_day = date("d");
    }
    // Fix the days of the week if week start is not on a monday
    if (get_option('start_of_week') == 0) {
        $first_weekday = date("w", mktime(0, 0, 0, $c_month, 1, $c_year));
        $first_weekday = $first_weekday == 0 ? 1 : $first_weekday + 1;
    } else {
        $first_weekday = date("w", mktime(0, 0, 0, $c_month, 1, $c_year));
        $first_weekday = $first_weekday == 0 ? 7 : $first_weekday;
    }
    $days_in_month = date("t", mktime(0, 0, 0, $c_month, 1, $c_year));
    // Start the table and add the header and naviagtion
    $calendar_body .= '
<table cellspacing="1" cellpadding="0" class="calendar-table">
';
    // We want to know if we should display the date switcher
    $date_switcher = $wpdb->get_var("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='display_jump'", 0, 0);
    if ($date_switcher == 'true') {
        $calendar_body .= '<tr>
        <td colspan="7" class="calendar-date-switcher">
            <form method="GET" action="' . $_SERVER['REQUEST_URI'] . '">
';
        $qsa = array();
        parse_str($_SERVER['QUERY_STRING'], $qsa);
        foreach ($qsa as $name => $argument) {
            if ($name != 'month' && $name != 'yr') {
                $calendar_body .= '<input type="hidden" name="' . $name . '" value="' . $argument . '" />
';
            }
        }
        function month_comparison($month)
        {
            $current_month = strtolower(date("M", time()));
            if (isset($_GET['yr']) && isset($_GET['month'])) {
                if ($month == $_GET['month']) {
                    return ' selected="selected"';
                }
            } elseif ($month == $current_month) {
                return ' selected="selected"';
            }
        }
        // We build the months in the switcher
        $calendar_body .= '
            ' . __('Month', 'calendar') . ': <select name="month" style="width:100px;">
            <option value="jan"' . month_comparison('jan') . '>' . __('January', 'calendar') . '</option>
            <option value="feb"' . month_comparison('feb') . '>' . __('February', 'calendar') . '</option>
            <option value="mar"' . month_comparison('mar') . '>' . __('March', 'calendar') . '</option>
            <option value="apr"' . month_comparison('apr') . '>' . __('April', 'calendar') . '</option>
            <option value="may"' . month_comparison('may') . '>' . __('May', 'calendar') . '</option>
            <option value="jun"' . month_comparison('jun') . '>' . __('June', 'calendar') . '</option>
            <option value="jul"' . month_comparison('jul') . '>' . __('July', 'calendar') . '</option> 
            <option value="aug"' . month_comparison('aug') . '>' . __('August', 'calendar') . '</option> 
            <option value="sept"' . month_comparison('sept') . '>' . __('September', 'calendar') . '</option> 
            <option value="oct"' . month_comparison('oct') . '>' . __('October', 'calendar') . '</option> 
            <option value="nov"' . month_comparison('nov') . '>' . __('November', 'calendar') . '</option> 
            <option value="dec"' . month_comparison('dec') . '>' . __('December', 'calendar') . '</option> 
            </select>
            ' . __('Year', 'calendar') . ': <select name="yr" style="width:60px;">
';
        // The year builder is string mania. If you can make sense of this,
        // you know your PHP!
        function year_comparison($year)
        {
            $current_year = strtolower(date("Y", time()));
            if (isset($_GET['yr']) && isset($_GET['month'])) {
                if ($year == $_GET['yr']) {
                    return ' selected="selected"';
                }
            } else {
                if ($year == $current_year) {
                    return ' selected="selected"';
                }
            }
        }
        $past = 30;
        $future = 30;
        $fut = 1;
        while ($past > 0) {
            $p .= '            <option value="';
            $p .= date("Y", time()) - $past;
            $p .= '"' . year_comparison(date("Y", time()) - $past) . '>';
            $p .= date("Y", time()) - $past . '</option>
';
            $past = $past - 1;
        }
        while ($fut < $future) {
            $f .= '            <option value="';
            $f .= date("Y", time()) + $fut;
            $f .= '"' . year_comparison(date("Y", time()) + $fut) . '>';
            $f .= date("Y", time()) + $fut . '</option>
';
            $fut = $fut + 1;
        }
        $calendar_body .= $p;
        $calendar_body .= '            <option value="' . date("Y", time()) . '"' . year_comparison(date("Y", time())) . '>' . date("Y", time()) . '</option>
';
        $calendar_body .= $f;
        $calendar_body .= '</select>
            <input type="submit" value="Go" />
            </form>
        </td>
</tr>
';
    }
    // The header of the calendar table and the links. Note calls to link functions
    $calendar_body .= '<tr>
                <td colspan="7" class="calendar-heading">
                    <table border="0" cellpadding="0" cellspacing="0" width="100%">
                    <tr>
                    <td class="calendar-prev">' . prev_link($c_year, $c_month) . '</td>
                    <td class="calendar-month">' . $name_months[(int) $c_month] . ' ' . $c_year . '</td>
                    <td class="calendar-next">' . next_link($c_year, $c_month) . '</td>
                    </tr>
                    </table>
                </td>
</tr>
';
    // Print the headings of the days of the week
    $calendar_body .= '<tr>
';
    for ($i = 1; $i <= 7; $i++) {
        // Colours need to be different if the starting day of the week is different
        if (get_option('start_of_week') == 0) {
            $calendar_body .= '        <td class="' . ($i < 7 && $i > 1 ? 'normal-day-heading' : 'weekend-heading') . '">' . $name_days[$i] . '</td>
';
        } else {
            $calendar_body .= '        <td class="' . ($i < 6 ? 'normal-day-heading' : 'weekend-heading') . '">' . $name_days[$i] . '</td>
';
        }
    }
    $calendar_body .= '</tr>
';
    for ($i = 1; $i <= $days_in_month;) {
        $calendar_body .= '<tr>
';
        for ($ii = 1; $ii <= 7; $ii++) {
            if ($ii == $first_weekday && $i == 1) {
                $go = TRUE;
            } elseif ($i > $days_in_month) {
                $go = FALSE;
            }
            if ($go) {
                // Colours again, this time for the day numbers
                if (get_option('start_of_week') == 0) {
                    // This bit of code is for styles believe it or not.
                    $grabbed_events = grab_events($c_year, $c_month, $i);
                    $no_events_class = '';
                    if (!count($grabbed_events)) {
                        $no_events_class = ' no-events';
                    }
                    $calendar_body .= '        <td class="' . (date("Ymd", mktime(0, 0, 0, $c_month, $i, $c_year)) == date("Ymd") ? 'current-day' : 'day-with-date') . $no_events_class . '"><span ' . ($ii < 7 && $ii > 1 ? '' : 'class="weekend"') . '>' . $i++ . '</span><span class="event">' . draw_events($grabbed_events) . '</span></td>
';
                } else {
                    $grabbed_events = grab_events($c_year, $c_month, $i);
                    $no_events_class = '';
                    if (!count($grabbed_events)) {
                        $no_events_class = ' no-events';
                    }
                    $calendar_body .= '        <td class="' . (date("Ymd", mktime(0, 0, 0, $c_month, $i, $c_year)) == date("Ymd") ? 'current-day' : 'day-with-date') . $no_events_class . '"><span ' . ($ii < 6 ? '' : 'class="weekend"') . '>' . $i++ . '</span><span class="event">' . draw_events($grabbed_events) . '</span></td>
';
                }
            } else {
                $calendar_body .= '        <td class="day-without-date">&nbsp;</td>
';
            }
        }
        $calendar_body .= '</tr>
';
    }
    $show_cat = $wpdb->get_var("SELECT config_value FROM " . WP_CALENDAR_CONFIG_TABLE . " WHERE config_item='enable_categories'", 0, 0);
    if ($show_cat == 'true') {
        $sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " ORDER BY category_name ASC";
        $cat_details = $wpdb->get_results($sql);
        $calendar_body .= '<tr><td colspan="7">
<table class="cat-key">
<tr><td colspan="2"><strong>' . __('Category Key', 'calendar') . '</strong></td></tr>
';
        foreach ($cat_details as $cat_detail) {
            $calendar_body .= '<tr><td style="background-color:' . $cat_detail->category_colour . '; width:20px; height:20px;"></td><td>' . $cat_detail->category_name . '</td></tr>';
        }
        $calendar_body .= '</table>
</td></tr>
';
    }
    $calendar_body .= '</table>
';
    // A little link to yours truely. See the README if you wish to remove this
    $calendar_body .= '<div class="kjo-link" style="visibility:visible;display:block;"><p>' . __('Calendar developed and supported by ', 'calendar') . '<a href="http://www.kieranoshea.com">Kieran O\'Shea</a></p></div>
';
    // Phew! After that bit of string building, spit it all out.
    // The actual printing is done by the calling function.
    return $calendar_body;
}