Ejemplo n.º 1
0
 } else {
     if (isset($uri_parts[2]) && preg_match('/^[a-zA-Z0-9-_]+$/', $uri_parts[2])) {
         $options['username'] = $uri_parts[2];
         $photoblog_user = photoblog_fetch_active_user_data($options);
     } else {
         if (login_checklogin()) {
             $options['username'] = $_SESSION['login']['username'];
             $photoblog_user = photoblog_fetch_active_user_data($options);
         } else {
             throw new Exception('Njet, ogiltigt användarnamn!');
         }
     }
 }
 // This line has to be after photoblog_fetch_active_user_data since it use parameters for colors
 $ui_options['stylesheets'][] = 'photoblog_' . $photoblog_user['color_main'] . '_' . $photoblog_user['color_detail'] . '_.css';
 $photos_by_year = photoblog_dates_fetch(array('user' => $photoblog_user['id']));
 $month_table = array('01' => 'Januari', '02' => 'Februari', '03' => 'Mars', '04' => 'April', '05' => 'Maj', '06' => 'Juni', '07' => 'Juli', '08' => 'Augusti', '09' => 'September', '10' => 'Oktober', '11' => 'November', '12' => 'December');
 $out .= '<div id="photoblog_header">';
 $out .= '<div id="photoblog_select">';
 $select_year .= '<select id="photoblog_select_year">';
 $select_months = array();
 $highest_date = 0;
 foreach ($photos_by_year as $year => $photos_by_month) {
     $select_year .= '<option value="' . $year . '">' . $year . '</option>';
     $select_this_month = '<select style="display: none;" id="photoblog_select_month_' . $year . '">';
     foreach ($photos_by_month as $month => $photos_by_day) {
         $highest_date = max((int) ($year . $month), $highest_date);
         $select_this_month .= '<option value="' . $month . '">' . $month_table[$month] . '</option>';
     }
     $select_this_month .= '</select>';
     $select_months[] = $select_this_month;
Ejemplo n.º 2
0
function photoblog_calendar($user_id, $month, $year)
{
    $format_month = sprintf('%02s', $month);
    $options = array('user' => $user_id);
    $dates = photoblog_dates_fetch($options);
    $used_dates = $dates[$year][$format_month];
    $date = mktime(12, 0, 0, $month, 1, $year);
    $daysInMonth = date('t', $date);
    $dates_first = reset(end($dates));
    $dates_last = end(reset($dates));
    $prev_month = $month == 1 ? 12 : $month - 1;
    $prev_year = $prev_month == 12 ? $year - 1 : $year;
    $prev_has = $used_dates != $dates_first;
    $next_month = $month == 12 ? 1 : $month + 1;
    $next_year = $next_month == 1 ? $year + 1 : $year;
    $next_has = $used_dates != $dates_last;
    $prev_year_has = isset($dates[$year - 1]);
    $next_year_has = isset($dates[$year + 1]);
    $prev_year_month = $prev_year_has ? end(array_keys($dates[$year - 1])) : false;
    $next_year_month = $next_year_has ? reset(array_keys($dates[$year + 1])) : false;
    $offset = date('N', $date);
    $rows = 1;
    $out .= '<div id="photoblog_calendar_month" class="date-' . $year . $format_month . '">' . "\n";
    $out .= $prev_has ? sprintf('<a class="photoblog_calendar_date" href="#month-%s%02s">&laquo;</a>', $prev_year, $prev_month) . "\n" : '';
    $out .= '<span>' . date('F', $date) . ', ' . $year . '</span>' . "\n";
    $out .= $next_has ? sprintf('<a class="photoblog_calendar_date" href="#month-%s%02s">&raquo;</a>', $next_year, $next_month) . "\n" : '';
    $out .= '</div>' . "\n";
    $out .= '<table>' . "\n";
    $out .= '<tr><th>M</th><th>T</th><th>O</th><th>T</th><th>F</th><th>L</th><th>S</th></tr>' . "\n";
    $out .= '<tr>';
    for ($i = 1; $i < $offset; $i++) {
        $out .= '<td></td>' . "\n";
    }
    for ($day = 1; $day <= $daysInMonth; $day++) {
        $format_day = sprintf('%02s', $day);
        if (($day + $offset - 2) % 7 == 0 && $day != 1) {
            $out .= '</tr><tr>' . "\n";
            $rows++;
        }
        $out .= '<td>' . (isset($used_dates[$format_day]) ? '<a href="#day-' . $year . $format_month . $format_day . '">' . $day . '</a>' : $day) . '</td>' . "\n";
    }
    while ($day + $offset <= $rows * 7) {
        $out .= '<td></td>' . "\n";
        $day++;
    }
    $out .= '</tr>' . "\n";
    $out .= '</table>' . "\n";
    $out .= '<div id="photoblog_calendar_year">' . "\n";
    $out .= '<span class="photoblog_calendar_year_pre">' . ($prev_year_has ? sprintf('<a class="photoblog_calendar_date" href="#month-%s%s">%s</a>', $year - 1, $prev_year_month, $year - 1) : '') . '</span>';
    $out .= '<span class="photoblog_calendar_year_after">' . ($next_year_has ? sprintf('<a class="photoblog_calendar_date" href="#month-%s%s">%s</a>', $year + 1, $next_year_month, $year + 1) : '') . '</span>' . "\n";
    $out .= '</div>' . "\n";
    return $out;
}