/** * Returns the current url minus MultiView params * * @param bool $with_amp - adds ? or & at the end of the url * @return string */ public function get_clean_url($with_amp = false) { if (script_basename() == 'picture') { $url = duplicate_picture_url(array(), $this->data_url_params); } else { if (script_basename() == 'index') { $url = duplicate_index_url(array(), $this->data_url_params); } else { $url = get_query_string_diff($this->data_url_params); } } if ($with_amp) { $url .= strpos($url, '?') !== false ? '&' : '?'; } return $url; }
/** * Add main toolbar to current page * @trigger loc_after_page_header */ function admintools_add_public_controller() { global $MultiView, $conf, $template, $page, $user, $picture; if (script_basename() == 'picture' and empty($picture['current'])) { return; } $url_root = get_root_url(); $tpl_vars = array(); if ($MultiView->is_admin()) { // full options for admin $tpl_vars['U_SITE_ADMIN'] = $url_root . 'admin.php?page='; $tpl_vars['MULTIVIEW'] = $MultiView->get_data(); $tpl_vars['USER'] = $MultiView->get_user(); $tpl_vars['CURRENT_USERNAME'] = $user['id'] == $conf['guest_id'] ? l10n('guest') : $user['username']; $tpl_vars['DELETE_CACHE'] = isset($conf['multiview_invalidate_cache']); if (($admin_lang = $MultiView->get_user_language()) !== false) { include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; switch_lang_to($admin_lang); } } else { if ($conf['AdminTools']['public_quick_edit'] and script_basename() == 'picture' and $picture['current']['added_by'] == $user['id']) { // only "edit" button for photo owner } else { return; } } $tpl_vars['POSITION'] = $conf['AdminTools']['closed_position']; $tpl_vars['DEFAULT_OPEN'] = $conf['AdminTools']['default_open']; $tpl_vars['U_SELF'] = $MultiView->get_clean_url(true); // photo page if (script_basename() == 'picture') { $url_self = duplicate_picture_url(); $tpl_vars['IS_PICTURE'] = true; // admin can add to caddie and set representattive if ($MultiView->is_admin()) { $template->clear_assign(array('U_SET_AS_REPRESENTATIVE', 'U_PHOTO_ADMIN', 'U_CADDIE')); $template->set_prefilter('picture', 'admintools_remove_privacy'); $tpl_vars['U_CADDIE'] = add_url_params($url_self, array('action' => 'add_to_caddie')); $query = ' SELECT element_id FROM ' . CADDIE_TABLE . ' WHERE element_id = ' . $page['image_id'] . ' ;'; $tpl_vars['IS_IN_CADDIE'] = pwg_db_num_rows(pwg_query($query)) > 0; if (isset($page['category'])) { $tpl_vars['CATEGORY_ID'] = $page['category']['id']; $tpl_vars['U_SET_REPRESENTATIVE'] = add_url_params($url_self, array('action' => 'set_as_representative')); $tpl_vars['IS_REPRESENTATIVE'] = $page['category']['representative_picture_id'] == $page['image_id']; } $tpl_vars['U_ADMIN_EDIT'] = $url_root . 'admin.php?page=photo-' . $page['image_id'] . (isset($page['category']) ? '&cat_id=' . $page['category']['id'] : ''); } $tpl_vars['U_DELETE'] = add_url_params($url_self, array('delete' => '', 'pwg_token' => get_pwg_token())); // gets tags (full available list is loaded in ajax) include_once PHPWG_ROOT_PATH . 'admin/include/functions.php'; $query = ' SELECT id, name FROM ' . IMAGE_TAG_TABLE . ' AS it JOIN ' . TAGS_TABLE . ' AS t ON t.id = it.tag_id WHERE image_id = ' . $page['image_id'] . ' ;'; $tag_selection = get_taglist($query); $tpl_vars['QUICK_EDIT'] = array('img' => $picture['current']['derivatives']['square']->get_url(), 'name' => $picture['current']['name'], 'comment' => $picture['current']['comment'], 'author' => $picture['current']['author'], 'level' => $picture['current']['level'], 'date_creation' => substr($picture['current']['date_creation'], 0, 10), 'date_creation_time' => substr($picture['current']['date_creation'], 11, 5), 'tag_selection' => $tag_selection); } else { if ($MultiView->is_admin() and @$page['section'] == 'categories' and isset($page['category'])) { $url_self = duplicate_index_url(); $tpl_vars['IS_CATEGORY'] = true; $tpl_vars['CATEGORY_ID'] = $page['category']['id']; $template->clear_assign(array('U_EDIT', 'U_CADDIE')); $tpl_vars['U_ADMIN_EDIT'] = $url_root . 'admin.php?page=album-' . $page['category']['id']; if (!empty($page['items'])) { $tpl_vars['U_CADDIE'] = add_url_params($url_self, array('caddie' => 1)); } $tpl_vars['QUICK_EDIT'] = array('img' => null, 'name' => $page['category']['name'], 'comment' => $page['category']['comment']); if (!empty($page['category']['representative_picture_id'])) { $query = ' SELECT * FROM ' . IMAGES_TABLE . ' WHERE id = ' . $page['category']['representative_picture_id'] . ' ;'; $image_infos = pwg_db_fetch_assoc(pwg_query($query)); $tpl_vars['QUICK_EDIT']['img'] = DerivativeImage::get_one(IMG_SQUARE, $image_infos)->get_url(); } } } $template->assign(array('ADMINTOOLS_PATH' => './plugins/' . ADMINTOOLS_ID . '/', 'ato' => $tpl_vars)); $template->set_filename('ato_public_controller', realpath(ADMINTOOLS_PATH . 'template/public_controller.tpl')); $template->parse('ato_public_controller'); if ($MultiView->is_admin() && @$admin_lang !== false) { switch_lang_back(); } }
} // filesize if (!empty($picture['current']['filesize'])) { $infos['INFO_FILESIZE'] = l10n('%d Kb', $picture['current']['filesize']); } // number of visits $infos['INFO_VISITS'] = $picture['current']['hit']; // file $infos['INFO_FILE'] = $picture['current']['file']; $template->assign($infos); $template->assign('display_info', unserialize($conf['picture_informations'])); // related tags $tags = get_common_tags(array($page['image_id']), -1); if (count($tags)) { foreach ($tags as $tag) { $template->append('related_tags', array_merge($tag, array('URL' => make_index_url(array('tags' => array($tag))), 'U_TAG_IMAGE' => duplicate_picture_url(array('section' => 'tags', 'tags' => array($tag)))))); } } // related categories if (count($related_categories) == 1 and isset($page['category']) and $related_categories[0]['id'] == $page['category']['id']) { // no need to go to db, we have all the info $template->append('related_categories', get_cat_display_name($page['category']['upper_names'])); } else { // use only 1 sql query to get names for all related categories $ids = array(); foreach ($related_categories as $category) { // add all uppercats to $ids $ids = array_merge($ids, explode(',', $category['uppercats'])); } $ids = array_unique($ids); $query = '
$page['meta_robots']['noindex'] = 1; } elseif ('search' == $page['section']) { $page['meta_robots']['nofollow'] = 1; } if ($filter['enabled']) { $page['meta_robots']['noindex'] = 1; } // see if we need a redirect because of a permalink if ('categories' == $page['section'] and isset($page['category'])) { $need_redirect = false; if (empty($page['category']['permalink'])) { if ($conf['category_url_style'] == 'id-name' and @$page['hit_by']['cat_url_name'] !== str2url($page['category']['name'])) { $need_redirect = true; } } else { if ($page['category']['permalink'] !== @$page['hit_by']['cat_permalink']) { $need_redirect = true; } } if ($need_redirect) { $redirect_url = script_basename() == 'picture' ? duplicate_picture_url() : duplicate_index_url(); if (!headers_sent()) { // this is a permanent redirection set_status_header(301); redirect_http($redirect_url); } redirect($redirect_url); } unset($need_redirect, $page['hit_by']); } trigger_notify('loc_end_section_init');
SELECT image_id, COUNT(*) AS nb_comments FROM ' . COMMENTS_TABLE . ' WHERE validated = \'true\' AND image_id IN (' . implode(',', $selection) . ') 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;
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')); }
WHERE image_id = ' . $page['image_id'] . $validated_clause . ' ;'; $row = pwg_db_fetch_assoc(pwg_query($query)); // navigation bar creation if (!isset($page['start'])) { $page['start'] = 0; } $navigation_bar = create_navigation_bar(duplicate_picture_url(array(), array('start')), $row['nb_comments'], $page['start'], $conf['nb_comment_page'], true); $template->assign(array('COMMENT_COUNT' => $row['nb_comments'], 'navbar' => $navigation_bar)); if ($row['nb_comments'] > 0) { // comments order (get, session, conf) if (!empty($_GET['comments_order']) && in_array(strtoupper($_GET['comments_order']), array('ASC', 'DESC'))) { pwg_set_session_var('comments_order', $_GET['comments_order']); } $comments_order = pwg_get_session_var('comments_order', $conf['comments_order']); $template->assign(array('COMMENTS_ORDER_URL' => add_url_params(duplicate_picture_url(), array('comments_order' => $comments_order == 'ASC' ? 'DESC' : 'ASC')), 'COMMENTS_ORDER_TITLE' => $comments_order == 'ASC' ? l10n('Show latest comments first') : l10n('Show oldest comments first'))); $query = ' SELECT com.id, author, author_id, u.' . $conf['user_fields']['email'] . ' AS user_email, date, image_id, website_url, com.email, content, validated FROM ' . COMMENTS_TABLE . ' AS com LEFT JOIN ' . USERS_TABLE . ' AS u ON u.' . $conf['user_fields']['id'] . ' = author_id
function osm_duplicate_map_picture_url() { $map_url = duplicate_picture_url(); return add_url_params($map_url, array('map' => null)); }