Example #1
0
    if ($i == 1) {
        $class = ' class="first-image"';
    } elseif ($i == $count) {
        $class = ' class="last-image"';
    }
    $out .= '<dd' . $class . '><a title="' . $photo['date'] . '" ' . ($is_first ? 'class="photoblog_active"' : '') . ' href="#image-' . $photo['id'] . '"><img src="' . IMAGE_URL . 'photos/mini/' . floor($photo['id'] / 5000) . '/' . $photo['id'] . '.jpg" title="' . $photo['username'] . '" /></a></dd>';
    $is_first = false;
}
$out .= '<dt id="photoblog_nextmonth"><a title="N&auml;sta m&aring;nad" href="#next-month">N&auml;sta m&aring;nad</a></dt>';
$out .= '</dl>';
$out .= '</div>';
$out .= '</div>';
$out .= '</div>';
$out .= '<div id="photoblog_image">';
$first_photo = $photos[0];
$out .= '<p><img src="http://images.hamsterpaj.net/photos/full/' . floor($first_photo['id'] / 5000) . '/' . $first_photo['id'] . '.jpg" alt="" /></p>';
$out .= '</div>';
$out .= '<div id="photoblog_description">';
$out .= '<div id="photoblog_description_text">';
$out .= '<p>Jag tänkte att jag skulle kunna äta upp dig.';
$out .= '<br />';
$out .= '<br />';
$out .= 'Not.</p>';
$out .= '</div>';
$out .= '</div>';
// Some test-data
$comment1 = array('user_id' => 625058, 'username' => 'Lef', 'comment' => 'Din mamma är så fet!');
$comment2 = array('user_id' => 3, 'answer' => 'Jag bryr mig <del>inte</del> visst! Det gör ont när du säger sånt...', 'username' => 'Johan', 'comment' => 'Din med! :( ');
$comments = array($comment1, $comment2);
$out .= photoblog_comments_form($options);
$out .= photoblog_comments_list($comments);
Example #2
0
function photoblog_viewer($options)
{
    global $photoblog_user;
    $ret = '';
    $options['include_dates'] = isset($options['include_dates']) ? $options['include_dates'] : true;
    $options['load_first'] = isset($options['load_first']) ? $options['load_first'] : false;
    $options['album_view'] = (bool) $options['album_view'];
    $active_photo = isset($options['active_id']) && $options['active_id'] ? $options['active_id'] : false;
    $user_id = $options['user_id'];
    if ($active_photo) {
        $current_photo = end(photoblog_photos_fetch(array('id' => $active_photo, 'user' => $user_id)));
        // something went wrong, photo doesn't exists, not the $user_id's, so go with plain old normal view
        if (!$current_photo) {
            $active_photo = false;
        } else {
            $options['date'] = date('Ym', strtotime($current_photo['date']));
        }
    }
    $photo_options = array('user' => $user_id);
    if (isset($options['date'])) {
        $photo_options['month'] = $options['date'];
    }
    if (isset($options['category'])) {
        $photo_options['category'] = $options['category'];
    }
    $date = isset($options['date']) ? $options['date'] : date('Ym', time());
    define('PHOTOBLOG_CURRENT_YEAR', substr($date, 0, 4));
    define('PHOTOBLOG_CURRENT_MONTH', substr($date, 4, 2));
    define('PHOTOBLOG_CURRENT_USER', $user_id);
    $photos = !isset($options['photos']) ? photoblog_photos_fetch($photo_options) : $options['photos'];
    $ret .= '<!--[if lte IE 7]>';
    $ret .= '<div class="photoblog_ie_warning">';
    $ret .= '<p>Tjena! Som du kanske har märkt så fungerar fotobloggen inte så överdrivet bra med den versionen av Internet Explorer du kör nu! :( Det beror på att det är en dålig webbläsare för oss som gör hemsidor. Men! Du kan alltid uppgradera till en bättre webbläsare, till exempel <a href="http://www.firefox.com/">Firefox</a>, <a href="http://www.apple.com/safari/">Safari</a>, <a href="http://www.google.com/chrome">Google Chrome</a>, <a href="http://www.opera.com/">Opera</a> eller så kan du <a href="http://www.microsoft.com/windows/internet-explorer/">uppgradera till senaste versionen av Internet Explorer</a>. Om du gör något av detta så vinner du en internet!</p>';
    $ret .= '</div>';
    $ret .= '<![endif]-->';
    $is_album = isset($options['is_album']) && $options['is_album'];
    $ret .= '<div id="photoblog_thumbs">';
    $ret .= '<div id="photoblog_thumbs_container">';
    $ret .= '<div id="photoblog_thumbs_inner">';
    $ret .= '<dl>';
    if ($is_album) {
        list($html, $current_photo) = photoblog_viewer_albums_list($options);
        $ret .= $html;
    } else {
        $ret .= '<dt id="photoblog_prevmonth"><a id="prevmonth" title="F&ouml;reg&aring;ende m&aring;nad" href="#prev-month">F&ouml;reg&aring;ende m&aring;nad</a></dt>';
        $is_first = true;
        $last_day = array('date' => null, 'formatted' => null);
        if (!count($photos)) {
            $ret .= '<dt>Här var det tomt...</dt>';
        }
        $photos_last_index = count($photos) - 1;
        foreach ($photos as $key => $photo) {
            if ($options['include_dates'] && $last_day['date'] != $photo['date']) {
                $last_day['date'] = $photo['date'];
                $last_day['formatted'] = date('j/n', strtotime($photo['date']));
                $ret .= '<dt>' . $last_day['formatted'] . '</dt>';
            }
            $class = ' class="';
            if ($key == 0) {
                $class .= 'first-image ';
            }
            if ($key == $photos_last_index) {
                $class .= 'last-image ';
            }
            $class .= '"';
            if ($active_photo) {
                $is_current = $active_photo == $photo['id'];
            } else {
                $is_current = $options['load_first'] ? $key == 0 : $key == $photos_last_index;
            }
            $ret .= '<dd' . $class . '><a title="' . $photo['date'] . '" ' . ($is_current ? 'class="photoblog_active"' : '') . ' href="#image-' . $photo['id'] . '"><img src="' . IMAGE_URL . 'photos/mini/' . floor($photo['id'] / 5000) . '/' . $photo['id'] . '.jpg" title="' . $photo['username'] . '" /></a></dd>';
        }
        if (!$active_photo) {
            $current_photo = $options['load_first'] ? $photos[0] : $photos[$photos_last_index];
        } else {
            foreach ($photos as $photo) {
                if ($photo['id'] == $active_photo) {
                    $current_photo = $photo;
                    break;
                }
            }
        }
        $ret .= '<dt id="photoblog_nextmonth"><a id="nextmonth" title="N&auml;sta m&aring;nad" href="#next-month">N&auml;sta m&aring;nad</a></dt>';
    }
    $ret .= '</dl>';
    $ret .= '</div>';
    $ret .= '</div>';
    // Scroller, JS added at domready.
    $ret .= '<div id="photoblog_thumbs_scroller_outer"><div id="photoblog_thumbs_scroller" class="ui-slider">
					<div class="ui-slider-handle" style="width: 100%;" id="photoblog_thumbs_handle"></div>
				    </div></div>';
    $ret .= '</div>';
    $ret .= '<div id="photoblog_image">';
    $ret .= '<p><img src="' . IMAGE_URL . 'photos/full/' . floor($current_photo['id'] / 5000) . '/' . $current_photo['id'] . '.jpg" alt="" /></p>';
    $ret .= '</div>';
    $ret .= '<div id="photoblog_description">';
    if ($current_photo) {
        $ret .= '<div id="photoblog_description_report">';
        $ret .= sprintf('<a class="report_abuse" href="/hamsterpaj/abuse.php?report_type=photo&reference_id=%d">Rapportera bilden</a>', $current_photo['id']);
        $ret .= '</div>';
    }
    $ret .= '<div id="photoblog_description_text">';
    $ret .= $current_photo['description'];
    $ret .= '</div>';
    if (login_checklogin() && $_SESSION['login']['id'] == $user_id) {
        $ret .= '<div id="photoblog_edit">';
        $ret .= '<form action="/ajax_gateways/photoblog.json.php?action=photo_edit" method="post">';
        $ret .= '<a href="#photoblog_edit_actions">Ändra din söta bild?</a>';
        $ret .= '<div style="display: none" id="photoblog_edit_do">';
        $ret .= '<h3>Ändringar <small><a href="/fotoblogg/ordna">(Du kanske vill sortera dina bilder?)</a></small></h3>';
        $ret .= '<input type="hidden" value="' . $current_photo['id'] . '" name="edit_id" />';
        $ret .= '<p id="photoblog_edit_description"><textarea rows="5" cols="50" name="edit_description">' . $current_photo['description'] . '</textarea></p>';
        $ret .= '<div id="photoblog_edit_date"><h4>Datum</h4>';
        $ret .= '<p><input type="text" name="edit_date" value="' . $current_photo['date'] . '" /></p></div>';
        $ret .= '<p id="photoblog_edit_save"><input type="submit" value="Spara dina ändringar" name="edit_submit" /> <input type="submit" name="edit_delete" value="Ta bort bilden" /></p>';
        $ret .= '</div>';
        $ret .= '</form>';
        $ret .= '</div>';
    }
    $ret .= '</div>';
    $ret .= '<script type="text/javascript">';
    $ret .= 'hp.photoblog.current_user = {';
    $ret .= 'id: ' . $user_id;
    $ret .= ', date: ' . $date;
    $ret .= ', album_view: ' . (int) ($options['album_view'] || $options['is_album']);
    $ret .= '};';
    $ret .= 'hp.photoblog.view.current_id = ' . ($current_photo['id'] ? $current_photo['id'] : '0') . ';';
    $ret .= '</script>';
    if ($current_photo) {
        $comments = photoblog_comments_fetch(array('photo_id' => $current_photo['id']));
        $comment_options = array('my_blog' => $_SESSION['login']['id'] == $photoblog_user['id']);
        $ret .= photoblog_comments_form($photo_options);
        $ret .= photoblog_comments_list($comments, $comment_options);
    } else {
        $ret .= '<p>Här var det jättetomt! Vänd tillbaka!</p>';
    }
    return $ret;
}