function photoblog_sort_module($photos, $options = array())
{
    if (!isset($options['user'])) {
        if (login_checklogin()) {
            $options['user'] = $_SESSION['login']['id'];
        } else {
            throw new Exception('No user specified and not logged in.');
        }
    }
    $options['save_path'] = isset($options['save_path']) ? $options['save_path'] : '/fotoblogg/sortera/spara_sortering';
    $out = '<div class="photoblog_sort_module">' . "\n";
    $out .= 'Save path: ' . $options['save_path'];
    $out .= '<ul class="albums">' . "\n";
    $categories = photoblog_categories_fetch(array('user' => $options['user']));
    foreach ($categories as $category) {
        $out .= '<li id="photoblog_sort_album_' . $category['id'] . '"><pre>' . print_r($category, true) . '</pre></li>' . "\n";
    }
    $out .= '</ul>' . "\n";
    $out .= '<ul class="photos">';
    foreach ($photos as $photo) {
        $out .= '<li id="photoblog_sort_' . $photo['id'] . '"><img src="' . IMAGE_URL . 'photos/mini/' . floor($photo['id'] / 5000) . '/' . $photo['id'] . '.jpg" alt="Dra till en kategori..." /></li>' . "\n";
    }
    $out .= '</ul>' . "\n";
    $out .= '</div>' . "\n";
    return $out;
}
Exemple #2
0
    if ($photo) {
        $albumid = $photo['category'];
    }
}
if (isset($albumid) || isset($uri_parts[4]) && preg_match('/^[a-zA-Z0-9-_]+$/', $uri_parts[4])) {
    $albumname = $uri_parts[4];
    global $photoblog_user;
    $options = array();
    if (isset($albumid)) {
        $options['id'] = $albumid;
    } else {
        $options['handle'] = $albumname;
    }
    $options['user'] = $photoblog_user['id'];
    if ($albumname !== 'none') {
        $photoblog_album = photoblog_categories_fetch($options);
    } else {
        $photoblog_album = array(array('id' => 0, 'handle' => 'none', 'name' => 'Oalbumiserade foton'));
    }
    if (!$photoblog_album) {
        $out .= '<h2>Det här albumet finns visst inte...</h2>';
    } else {
        $options['category'] = $photoblog_album[0]['id'];
        unset($options['handle'], $options['id']);
        list($photos_sorted, $category) = photoblog_photos_fetch_sorted($options);
        $category = end($category);
        if ($photoblog_album[0]['id'] == 0) {
            $category = $photoblog_album[0];
        }
        $out .= '<h2>' . $category['name'] . ' <small style="font-size: 10px;"><a href="/fotoblogg/' . $photoblog_user['username'] . '">Tillbaka</a></small></h2>';
        $user_id = $photoblog_user['id'];
<?php

global $photoblog_user;
$photo_options = array('user' => $photoblog_user['id']);
$photoblog_albums = photoblog_categories_fetch($photo_options);
$username = $photoblog_user['username'];
$possessive = substr($username, -1, 1) == 's' ? $username : $username . 's';
$options['output'] .= sprintf('<h2><a href="/fotoblogg/%s/album">%s album</a></h2>', $username, $possessive);
foreach ($photoblog_albums as $photoblog_album) {
    if (strlen($photoblog_album['photos']) >= 1) {
        $photoblog_album['photos'] = explode(',', $photoblog_album['photos']);
        $options['output'] .= '<a class="photoblog_album_module_link" href="/fotoblogg/' . $photoblog_user['username'] . '/album/' . $photoblog_album['handle'] . '">';
        $options['output'] .= '<img src="http://images.hamsterpaj.net/photos/thumb/' . floor($photoblog_album['photos'][0] / 5000) . '/' . $photoblog_album['photos'][0] . '.jpg" />';
        $options['output'] .= '<h3>' . $photoblog_album['name'] . '</h3>';
        $options['output'] .= '</a><br style="clear: both;" />';
    }
}
Exemple #4
0
<?php

$ui_options['javascripts'][] = 'sorter.js';
$out .= '<div id="photoblog_sort">';
$out .= '<h1>Sortera dina bilder genom att dra och släppa bilderna dit du vill ha dem</h1>';
/*$out .= '<h2>Skapa kategori</h2>';
  $out .= '<p>~Skapa~</p>';*/
$options = array('user' => $_SESSION['login']['id']);
$photos = photoblog_photos_fetch($options);
$options['create_if_not_found'] = false;
$options['id_index'] = true;
$categories = photoblog_categories_fetch($options);
$albums = array();
foreach ($photos as $photo) {
    $albums[$photo['category']][] = '<li id="photo_' . $photo['id'] . '"><img src="' . IMAGE_URL . 'photos/mini/' . floor($photo['id'] / 5000) . '/' . $photo['id'] . '.jpg" title="' . $photo['username'] . '" /><br /><input type="checkbox" name="foo" value="' . $photo['id'] . '" /></li>';
}
foreach ($albums as $id => $album) {
    $out .= '<h2>' . (!strlen($categories[$id]['name']) ? 'Inget namn' : $categories[$id]['name']) . ' <!--<input type="text" value="Ändra namn eller nåt" />--></h2>';
    $out .= '<ul id="album_' . $id . '">';
    $out .= implode('', $album);
    $out .= '</ul>';
}
$out .= '<p><a class="photoblog_sort_save" href="#">Spara ändringar</a> | <a class="photoblog_sort_remove" href="#">Ta bort markerade</a></p>';
$out .= '</div>';
Exemple #5
0
function photoblog_migrate_sorting($options)
{
    /*
    	Note that this function does not care whether
    	it already has been migrated.
    */
    $user_id = $options['user'];
    if (!$user_id) {
        throw new Exception('Sorting order can only be migrated on one user at a time. Please specify a user ID.');
    }
    $log = '';
    $category_options = array('user' => $user_id);
    $categories = photoblog_categories_fetch($category_options);
    foreach ($categories as $category) {
        $photos = unserialize($category['sorted_photos']);
        $log .= '<h3>Doing ' . $category['name'] . '</h3>';
        $index = 0;
        foreach ($photos as $photo) {
            $query = 'UPDATE `user_photos`';
            $query .= ' SET `sort_index` = ' . $index;
            $query .= ' WHERE `id` = ' . (int) $photo;
            $query .= ' LIMIT 1';
            mysql_query($query) or report_sql_error($query, __FILE__, __LINE__);
            $log .= $query . '<br />';
            $index++;
        }
    }
}