Esempio n. 1
0
  WHERE id = ' . $_GET['image_id'] . '
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
$storage_category_id = null;
if (!empty($row['storage_category_id'])) {
    $storage_category_id = $row['storage_category_id'];
}
$image_file = $row['file'];
// +-----------------------------------------------------------------------+
// |                             template init                             |
// +-----------------------------------------------------------------------+
$template->set_filenames(array('picture_modify' => 'picture_modify.tpl'));
$admin_url_start = $admin_photo_base_url . '-properties';
$admin_url_start .= isset($_GET['cat_id']) ? '&cat_id=' . $_GET['cat_id'] : '';
$src_image = new SrcImage($row);
$template->assign(array('tag_selection' => $tag_selection, 'U_SYNC' => $admin_url_start . '&sync_metadata=1', 'U_DELETE' => $admin_url_start . '&delete=1&pwg_token=' . get_pwg_token(), 'PATH' => $row['path'], 'TN_SRC' => DerivativeImage::url(IMG_THUMB, $src_image), 'FILE_SRC' => DerivativeImage::url(IMG_LARGE, $src_image), 'NAME' => isset($_POST['name']) ? stripslashes($_POST['name']) : @$row['name'], 'TITLE' => render_element_name($row), 'DIMENSIONS' => @$row['width'] . ' * ' . @$row['height'], 'FILESIZE' => @$row['filesize'] . ' KB', 'REGISTRATION_DATE' => format_date($row['date_available']), 'AUTHOR' => htmlspecialchars(isset($_POST['author']) ? stripslashes($_POST['author']) : @$row['author']), 'DATE_CREATION' => $row['date_creation'], 'DESCRIPTION' => htmlspecialchars(isset($_POST['description']) ? stripslashes($_POST['description']) : @$row['comment']), 'F_ACTION' => get_root_url() . 'admin.php' . get_query_string_diff(array('sync_metadata'))));
$added_by = 'N/A';
$query = '
SELECT ' . $conf['user_fields']['username'] . ' AS username
  FROM ' . USERS_TABLE . '
  WHERE ' . $conf['user_fields']['id'] . ' = ' . $row['added_by'] . '
;';
$result = pwg_query($query);
while ($user_row = pwg_db_fetch_assoc($result)) {
    $row['added_by'] = $user_row['username'];
}
$intro_vars = array('file' => l10n('Original file : %s', $row['file']), 'add_date' => l10n('Posted %s on %s', time_since($row['date_available'], 'year'), format_date($row['date_available'], array('day', 'month', 'year'))), 'added_by' => l10n('Added by %s', $row['added_by']), 'size' => $row['width'] . '×' . $row['height'] . ' pixels, ' . sprintf('%.2f', $row['filesize'] / 1024) . 'MB', 'stats' => l10n('Visited %d times', $row['hit']), 'id' => l10n('Numeric identifier : %d', $row['id']));
if ($conf['rate'] and !empty($row['rating_score'])) {
    $query = '
SELECT
    COUNT(*)
Esempio n. 2
0
if (isset($_POST['submit'])) {
    check_pwg_token();
    $offsetX = trim($_POST['offsetX']);
    $offsetY = trim($_POST['offsetY']);
    if (strlen($offsetX) === 0 || strlen($offsetY) === 0 || !is_numeric($offsetX) || !is_numeric($offsetY)) {
        $page['errors'][] = 'Invalid offset value';
    }
    if (count($page['errors']) === 0) {
        $stereoTable = $prefixeTable . 'stereo';
        if (isset($picture['x'])) {
            $query = "UPDATE {$stereoTable}\n\t\t\t\tSET x={$offsetX}, y={$offsetY}\n\t\t\t\tWHERE media_id = {$id};";
        } else {
            $picture['x'] = $offsetX;
            $picture['y'] = $offsetY;
            $query = "INSERT INTO {$stereoTable} (media_id, x, y)\n\t\t\t\tVALUES ({$id}, {$offsetX}, {$offsetY})";
        }
        pwg_query($query);
        array_push($page['infos'], l10n('STEREO_EDIT_SUCCESS'));
    }
}
// needed for the photo tabsheet
$admin_photo_base_url = get_root_url() . 'admin.php?page=photo-' . $id;
$self_url = Stereo_get_admin_url($id);
include_once PHPWG_ROOT_PATH . 'admin/include/tabsheet.class.php';
$tabsheet = new tabsheet();
$tabsheet->set_id('photo');
$tabsheet->select('stereo');
$tabsheet->assign();
$template->assign(array('PWG_TOKEN' => get_pwg_token(), 'F_ACTION' => $self_url, 'TITLE' => render_element_name($picture), 'PICTURE' => Stereo_render_element_content('', $picture), 'OFFSET_X' => empty($picture['x']) ? 0 : $picture['x'], 'OFFSET_Y' => empty($picture['y']) ? 0 : $picture['y']));
$template->set_filename('plugin_admin_content', STEREO_PATH . 'admin.tpl');
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
Esempio n. 3
0
    }
    $query .= '
  ' . $conf['order_by'] . '
  LIMIT ' . $page['nb_images'] . ' OFFSET ' . $page['start'] . '
;';
    $result = pwg_query($query);
    while ($row = pwg_db_fetch_assoc($result)) {
        $element_ids[] = $row['id'];
        $src_image = new SrcImage($row);
        $query = '
SELECT
    id,
    name
  FROM ' . IMAGE_TAG_TABLE . ' AS it
    JOIN ' . TAGS_TABLE . ' AS t ON t.id = it.tag_id
  WHERE image_id = ' . $row['id'] . '
;';
        $tag_selection = get_taglist($query);
        $legend = render_element_name($row);
        if ($legend != get_name_from_file($row['file'])) {
            $legend .= ' (' . $row['file'] . ')';
        }
        $template->append('elements', array_merge($row, array('ID' => $row['id'], 'TN_SRC' => DerivativeImage::url(IMG_THUMB, $src_image), 'FILE_SRC' => DerivativeImage::url(IMG_LARGE, $src_image), 'LEGEND' => $legend, 'U_EDIT' => get_root_url() . 'admin.php?page=photo-' . $row['id'], 'NAME' => htmlspecialchars(@$row['name']), 'AUTHOR' => htmlspecialchars(@$row['author']), 'LEVEL' => !empty($row['level']) ? $row['level'] : '0', 'DESCRIPTION' => htmlspecialchars(@$row['comment']), 'DATE_CREATION' => $row['date_creation'], 'TAGS' => $tag_selection)));
    }
    $template->assign(array('ELEMENT_IDS' => implode(',', $element_ids), 'CACHE_KEYS' => get_admin_client_cache_keys(array('tags'))));
}
trigger_notify('loc_end_element_set_unit');
// +-----------------------------------------------------------------------+
// |                           sending html code                           |
// +-----------------------------------------------------------------------+
$template->assign_var_from_handle('ADMIN_CONTENT', 'batch_manager_unit');
Esempio n. 4
0
    if ($i == 'current') {
        $row['element_path'] = get_element_path($row);
        if ($row['src_image']->is_original()) {
            // we have a photo
            if ($user['enabled_high'] == 'true') {
                $row['element_url'] = $row['src_image']->get_url();
                $row['download_url'] = get_action_url($row['id'], 'e', true);
            }
        } else {
            // not a pic - need download link
            $row['download_url'] = $row['element_url'] = get_element_url($row);
        }
    }
    $row['url'] = duplicate_picture_url(array('image_id' => $row['id'], 'image_file' => $row['file']), array('start'));
    $picture[$i] = $row;
    $picture[$i]['TITLE'] = render_element_name($row);
    $picture[$i]['TITLE_ESC'] = str_replace('"', '"', $picture[$i]['TITLE']);
    if ('previous' == $i and $page['previous_item'] == $page['first_item']) {
        $picture['first'] = $picture[$i];
    }
    if ('next' == $i and $page['next_item'] == $page['last_item']) {
        $picture['last'] = $picture[$i];
    }
}
$slideshow_params = array();
$slideshow_url_params = array();
if (isset($_GET['slideshow'])) {
    $page['slideshow'] = true;
    $page['meta_robots'] = array('noindex' => 1, 'nofollow' => 1);
    $slideshow_params = decode_slideshow_params($_GET['slideshow']);
    $slideshow_url_params['slideshow'] = encode_slideshow_params($slideshow_params);
Esempio n. 5
0
  GROUP BY image_id
;';
        $nb_comments_of = query2array($query, 'image_id', 'nb_comments');
    }
}
// template thumbnail initialization
$template->set_filenames(array('index_thumbnails' => 'thumbnails.tpl'));
trigger_notify('loc_begin_index_thumbnails', $pictures);
$tpl_thumbnails_var = array();
foreach ($pictures as $row) {
    // link on picture.php page
    $url = duplicate_picture_url(array('image_id' => $row['id'], 'image_file' => $row['file']), array('start'));
    if (isset($nb_comments_of)) {
        $row['NB_COMMENTS'] = $row['nb_comments'] = (int) @$nb_comments_of[$row['id']];
    }
    $name = render_element_name($row);
    $desc = render_element_description($row, 'main_page_element_description');
    $tpl_var = array_merge($row, array('TN_ALT' => htmlspecialchars(strip_tags($name)), 'TN_TITLE' => get_thumbnail_title($row, $name, $desc), 'URL' => $url, 'DESCRIPTION' => $desc, 'src_image' => new SrcImage($row)));
    if ($conf['index_new_icon']) {
        $tpl_var['icon_ts'] = get_icon($row['date_available']);
    }
    if ($user['show_nb_hits']) {
        $tpl_var['NB_HITS'] = $row['hit'];
    }
    switch ($page['section']) {
        case 'best_rated':
            $name = '(' . $row['rating_score'] . ') ' . $name;
            break;
        case 'most_visited':
            if (!$user['show_nb_hits']) {
                $name = '(' . $row['hit'] . ') ' . $name;
Esempio n. 6
0
$query = 'SELECT * FROM ' . IMAGES_TABLE . ' WHERE id=' . $_GET['image_id'];
$row = pwg_db_fetch_assoc(pwg_query($query));
if (isset($_POST['submit'])) {
    foreach (ImageStdParams::get_defined_type_map() as $params) {
        if ($params->sizing->max_crop != 0) {
            delete_element_derivatives($row, $params->type);
        }
    }
    delete_element_derivatives($row, IMG_CUSTOM);
    $uid = '&b=' . time();
    $conf['question_mark_in_urls'] = $conf['php_extension_in_urls'] = true;
    if ($conf['derivative_url_style'] == 1) {
        $conf['derivative_url_style'] = 0;
        //auto
    }
} else {
    $uid = '';
}
$tpl_var = array('TITLE' => render_element_name($row), 'ALT' => $row['file'], 'U_IMG' => DerivativeImage::url(IMG_LARGE, $row));
if (!empty($row['coi'])) {
    $tpl_var['coi'] = array('l' => char_to_fraction($row['coi'][0]), 't' => char_to_fraction($row['coi'][1]), 'r' => char_to_fraction($row['coi'][2]), 'b' => char_to_fraction($row['coi'][3]));
}
foreach (ImageStdParams::get_defined_type_map() as $params) {
    if ($params->sizing->max_crop != 0) {
        $derivative = new DerivativeImage($params, new SrcImage($row));
        $template->append('cropped_derivatives', array('U_IMG' => $derivative->get_url() . $uid, 'HTM_SIZE' => $derivative->get_size_htm()));
    }
}
$template->assign($tpl_var);
$template->set_filename('picture_coi', 'picture_coi.tpl');
$template->assign_var_from_handle('ADMIN_CONTENT', 'picture_coi');
Esempio n. 7
0
function Fotorama_end_picture()
{
    global $template, $conf, $user, $page;
    if (Fotorama_is_replace_picture()) {
        $url_up = duplicate_index_url(array('start' => floor($page['current_rank'] / $page['nb_image_page']) * $page['nb_image_page']), array('start'));
        //slideshow end
        $template->assign(array('U_SLIDESHOW_STOP' => $url_up));
        $template->assign('replace_picture', true);
    }
    if (!$page['slideshow']) {
        return;
    }
    load_language('plugin.lang', FOTORAMA_PATH);
    $split_limit = 400;
    if ('mobile' == get_device()) {
        $split_limit /= 2;
    }
    $view_offset = null;
    if (count($page['items']) >= 1.2 * $split_limit) {
        $first = $split_limit * 0.2;
        $last = $split_limit - $first;
        $first = $page['current_rank'] - $first;
        if ($first < 0) {
            $first += count($page['items']);
        }
        $last = $page['current_rank'] + $last;
        if ($last >= count($page['items'])) {
            $last -= count($page['items']);
        }
        if ($first < $last) {
            $selection = array_slice($page['items'], $first, $last - $first);
            $view_borders = array(0, count($selection) - 1);
            $view_offset = array('from' => 0, 'offset' => $first);
        } else {
            $selection = array_slice($page['items'], 0, $last);
            $view_borders = array(count($selection), count($selection) - 1);
            $view_offset = array('from' => count($selection), 'offset' => $first - count($selection));
            $selection = array_merge($selection, array_slice($page['items'], $first));
        }
    } else {
        $selection = $page['items'];
        $view_borders = null;
    }
    $query = '
  SELECT *
    FROM ' . IMAGES_TABLE . '
    WHERE id IN (' . implode(',', $selection) . ')
    ORDER BY FIELD(id, ' . implode(',', $selection) . ')
  ;';
    $result = pwg_query($query);
    $current = $template->get_template_vars('current');
    if (isset($current['selected_derivative'])) {
        $type = $current['selected_derivative']->get_type();
    }
    $defined = ImageStdParams::get_defined_type_map();
    if (!isset($type) or !isset($defined[$type])) {
        $type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']);
    }
    $skip = -1;
    $big_type = $type;
    $next_type = $type;
    foreach (ImageStdParams::get_defined_type_map() as $def_type => $params) {
        if ($def_type == $type) {
            $skip = 2;
        }
        if ($skip >= 0) {
            $big_type = $def_type;
        }
        if ($skip >= 1 and $conf['Fotorama']['resize']) {
            $next_type = $def_type;
        }
        if ($skip == 0) {
            break;
        }
        $skip = $skip - 1;
    }
    $type = $next_type;
    // +1 size for inpage slideshow
    if ($conf['Fotorama']['only_fullscreen']) {
        $type = $big_type;
    }
    $type_params = ImageStdParams::get_by_type($type);
    $big_type_params = ImageStdParams::get_by_type($big_type);
    if ($conf['Fotorama']['nav'] == 'thumbs' or $conf['Fotorama']['fullscreen_nav'] == 'thumbs') {
        $has_thumbs = true;
    } else {
        $has_thumbs = false;
    }
    if ($has_thumbs) {
        if ($conf['Fotorama']['square_thumb']) {
            $thumb_params = ImageStdParams::get_custom($conf['Fotorama']['thumbheight'], $conf['Fotorama']['thumbheight'], 1, $conf['Fotorama']['thumbheight'], $conf['Fotorama']['thumbheight']);
        } else {
            $thumb_params = ImageStdParams::get_custom(9999, $conf['Fotorama']['thumbheight']);
        }
    }
    $picture = array();
    while ($row = pwg_db_fetch_assoc($result)) {
        $row['src_image'] = new SrcImage($row);
        $row['derivative'] = new DerivativeImage($type_params, $row['src_image']);
        $row['derivative_big'] = new DerivativeImage($big_type_params, $row['src_image']);
        if ($has_thumbs) {
            $row['derivative_thumb'] = new DerivativeImage($thumb_params, $row['src_image']);
        }
        $row['url'] = duplicate_picture_url(array('image_id' => $row['id'], 'image_file' => $row['file']), array('start'));
        $row['TITLE'] = render_element_name($row);
        $picture[] = $row;
    }
    $picture = trigger_change('fotorama_items', $picture, $selection);
    $template->assign(array('TOTAL_ITEMS' => count($page['items']), 'view_borders' => $view_borders, 'view_offset' => $view_offset, 'current_rank' => array_search($page['image_id'], $selection)));
    $template->assign('item_height', ImageStdParams::get_by_type($type)->max_height());
    $template->assign('items', $picture);
    $template->assign(array('Fotorama' => $conf['Fotorama']));
    $template->assign('Fotorama_has_thumbs', $has_thumbs);
    if (is_file('./themes/' . $user['theme'] . '/template/fotorama.tpl')) {
        $template->set_filenames(array('slideshow' => realpath('./themes/' . $user['theme'] . '/template/fotorama.tpl')));
    } else {
        $template->set_filenames(array('slideshow' => realpath(FOTORAMA_PATH . 'template/fotorama.tpl')));
    }
    $template->assign('FOTORAMA_CONTENT_PATH', realpath(FOTORAMA_PATH . 'template/fotorama-content.tpl'));
}
Esempio n. 8
0
    if (file_exists($file)) {
        array_push($videos, array('src' => embellish_url(get_gallery_home_url() . $parts['dirname'] . "/pwg_representative/" . $parts['filename'] . "." . $file_ext), 'ext' => vjs_get_mimetype_from_ext($file_ext)));
    }
}
//print_r($videos);
/* Try to find WebVTT */
$file = $parts['dirname'] . "/pwg_representative/" . $parts['filename'] . ".vtt";
file_exists($file) ? $subtitle = embellish_url(get_gallery_home_url() . $file) : ($subtitle = null);
/* Thumbnail videojs plugin */
$filematch = $parts['dirname'] . "/pwg_representative/" . $parts['filename'] . "-th_*";
$matches = glob($filematch);
$thumbnails = array();
$sort = array();
// A list of sort columns and their data to pass to array_multisort
if (is_array($matches) and !empty($matches)) {
    foreach ($matches as $filename) {
        $ext = explode("-th_", $filename);
        $second = explode(".", $ext[1]);
        // ./galleries/videos/pwg_representative/trailer_480p-th_0.jpg
        //echo "$filename second " . $second[0]. "\n";
        $thumbnails[] = array('second' => $second[0], 'source' => embellish_url(get_gallery_home_url() . $filename));
        $sort['second'][$second[0]] = $second[0];
    }
}
//print_r($thumbnails);
// Sort thumbnails by second
!empty($sort['second']) and array_multisort($sort['second'], SORT_ASC, $thumbnails);
$infos = array_merge(array('Poster' => $poster), array('Videos source' => count($videos)), array('videos' => $videos), array('Thumbnails' => count($thumbnails)), array('thumbnails' => $thumbnails), array('Subtitle' => $subtitle));
//print_r($infos);
$template->assign(array('PWG_TOKEN' => get_pwg_token(), 'F_ACTION' => $self_url, 'SYNC_URL' => $sync_url, 'DELETE_URL' => $delete_url, 'TN_SRC' => DerivativeImage::thumb_url($picture) . '?' . time(), 'TITLE' => render_element_name($picture), 'EXIF' => $exif, 'INFOS' => $infos));
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
Esempio n. 9
0
        $query .= '
    JOIN ' . IMAGE_CATEGORY_TABLE . ' ON id = image_id';
    }
    $query .= '
  WHERE id IN (' . implode(',', $page['cat_elements_id']) . ')';
    if ($is_category) {
        $query .= '
    AND category_id = ' . $_SESSION['bulk_manager_filter']['category'];
    }
    $query .= '
  ' . $conf['order_by'] . '
  LIMIT ' . $page['nb_images'] . ' OFFSET ' . $page['start'] . '
;';
    $result = pwg_query($query);
    $thumb_params = ImageStdParams::get_by_type(IMG_THUMB);
    // template thumbnail initialization
    while ($row = pwg_db_fetch_assoc($result)) {
        $nb_thumbs_page++;
        $src_image = new SrcImage($row);
        $ttitle = render_element_name($row);
        if ($ttitle != get_name_from_file($row['file'])) {
            $ttitle .= ' (' . $row['file'] . ')';
        }
        $template->append('thumbnails', array_merge($row, array('thumb' => new DerivativeImage($thumb_params, $src_image), 'TITLE' => $ttitle, 'FILE_SRC' => DerivativeImage::url(IMG_LARGE, $src_image), 'U_EDIT' => get_root_url() . 'admin.php?page=photo-' . $row['id'])));
    }
    $template->assign('thumb_params', $thumb_params);
}
$template->assign(array('nb_thumbs_page' => $nb_thumbs_page, 'nb_thumbs_set' => count($page['cat_elements_id']), 'CACHE_KEYS' => get_admin_client_cache_keys(array('tags', 'categories'))));
trigger_notify('loc_end_element_set_global');
//----------------------------------------------------------- sending html code
$template->assign_var_from_handle('ADMIN_CONTENT', 'batch_manager_global');
}
$local_conf = array();
$local_conf['contextmenu'] = 'false';
$local_conf['control'] = true;
$local_conf['img_popup'] = false;
$local_conf['popup'] = 2;
$local_conf['center_lat'] = $lat;
$local_conf['center_lng'] = $lon;
$local_conf['zoom'] = $zoom;
$local_conf['editor'] = true;
$pathurl = get_absolute_root_url() . "i.php?" . $picture['pathurl'];
$js_data = array(array($lat, $lon, null, $pathurl, null, null, null, null));
$js = osm_get_js($conf, $local_conf, $js_data);
// Fetch the template.
global $prefixeTable;
// Easy access
define('osm_place_table', $prefixeTable . 'osm_places');
// Save location, eg Place
$query = '
SELECT id, name, latitude, longitude
  FROM ' . osm_place_table . '
;';
$result = pwg_query($query);
// JS for the template
while ($row = pwg_db_fetch_assoc($result)) {
    $list_of_places[$row['id']] = [$row['name'], $row['latitude'], $row['longitude']];
    $available_places[$row['id']] = $row['name'];
}
$jsplaces = "\nvar arr_places = " . json_encode($list_of_places) . ";\n";
$template->assign(array('PWG_TOKEN' => get_pwg_token(), 'F_ACTION' => $self_url, 'TN_SRC' => DerivativeImage::thumb_url($picture) . '?' . time(), 'TITLE' => render_element_name($picture), 'OSM_PATH' => embellish_url(get_absolute_root_url() . OSM_PATH), 'OSM_JS' => $js, 'LAT' => $lat, 'LON' => $lon, 'AVAILABLE_PLACES' => $available_places, 'LIST_PLACES' => $jsplaces));
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
Esempio n. 11
0
    /* Update the database - No action done on the video */
    $rotation_code = pwg_image::get_rotation_code_from_angle($_POST['angle']);
    $query = "UPDATE " . IMAGES_TABLE . " SET rotation='" . $rotation_code . "', `date_metadata_update`=CURDATE() WHERE `id`=" . $_GET['image_id'] . ";";
    pwg_query($query);
    /* Retrieve direct information about picture */
    $query = "SELECT id,path,representative_ext FROM " . IMAGES_TABLE . " WHERE " . SQL_VIDEOS . " AND id = " . $_GET['image_id'] . ";";
    $row = pwg_db_fetch_assoc(pwg_query($query));
    /* Delete previous derivatives */
    delete_element_derivatives($row);
    array_push($page['infos'], l10n('The photo was updated'));
}
// +-----------------------------------------------------------------------+
// | Tabs                                                                  |
// +-----------------------------------------------------------------------+
$tabsheet = new tabsheet();
$tabsheet->set_id('photo');
$tabsheet->select('rotate');
$tabsheet->assign();
// +-----------------------------------------------------------------------+
// |                             template init                             |
// +-----------------------------------------------------------------------+
$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin_rotate.tpl'));
// Retrieve direct information about picture
$query = "SELECT * FROM " . IMAGES_TABLE . " WHERE " . SQL_VIDEOS . " AND id = " . $_GET['image_id'] . ";";
$row = pwg_db_fetch_assoc(pwg_query($query));
$angles = array(array('value' => 270, 'name' => l10n('90° right')), array('value' => 90, 'name' => l10n('90° left')), array('value' => 180, 'name' => l10n('180°')));
$template->assign(array('F_ACTION' => $self_url, 'TN_SRC' => DerivativeImage::thumb_url($row), 'TITLE' => render_element_name($row), 'angles' => $angles, 'angle_selected' => pwg_image::get_rotation_angle_from_code($row['rotation']), 'library' => pwg_image::get_library(), 'PWG_TOKEN' => get_pwg_token()));
// +-----------------------------------------------------------------------+
// | sending html code                                                     |
// +-----------------------------------------------------------------------+
$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');