function process_GThumb($tpl_vars, $pictures) { global $template, $conf; $template->set_filename('index_thumbnails', realpath(GTHUMB_PATH . 'template/gthumb.tpl')); $template->assign('GThumb', $conf['GThumb']); $template->assign('GThumb_derivative_params', ImageStdParams::get_custom(9999, $conf['GThumb']['height'])); if ($conf['GThumb']['big_thumb'] and !empty($tpl_vars[0])) { $derivative_params = ImageStdParams::get_custom(9999, 2 * $conf['GThumb']['height'] + $conf['GThumb']['margin']); $template->assign('GThumb_big', new DerivativeImage($derivative_params, $tpl_vars[0]['src_image'])); } return $tpl_vars; }
function init($height) { $this->candidates = array(); foreach (ImageStdParams::get_defined_type_map() as $params) { if ($params->max_height() < $height || $params->sizing->max_crop) { continue; } if ($params->max_height() > 3 * $height) { break; } $this->candidates[] = $params; } $this->default = ImageStdParams::get_custom($height * 3, $height, 1, 0, $height); $this->height = $height; }
$watermark_changed = $watermark->file != $old_watermark->file || $watermark->xpos != $old_watermark->xpos || $watermark->ypos != $old_watermark->ypos || $watermark->xrepeat != $old_watermark->xrepeat || $watermark->yrepeat != $old_watermark->yrepeat || $watermark->opacity != $old_watermark->opacity; // save the new watermark configuration ImageStdParams::set_watermark($watermark); // do we have to regenerate the derivatives (and which types)? $changed_types = array(); foreach (ImageStdParams::get_defined_type_map() as $type => $params) { $old_use_watermark = $params->use_watermark; ImageStdParams::apply_global($params); $changed = $params->use_watermark != $old_use_watermark; if (!$changed and $params->use_watermark) { $changed = $watermark_changed; } if (!$changed and $params->use_watermark) { // if thresholds change and before/after the threshold is lower than the corresponding derivative side -> some derivatives might switch the watermark $changed |= $watermark->min_size[0] != $old_watermark->min_size[0] and ($watermark->min_size[0] < $params->max_width() or $old_watermark->min_size[0] < $params->max_width()); $changed |= $watermark->min_size[1] != $old_watermark->min_size[1] and ($watermark->min_size[1] < $params->max_height() or $old_watermark->min_size[1] < $params->max_height()); } if ($changed) { $params->last_mod_time = time(); $changed_types[] = $type; } } ImageStdParams::save(); if (count($changed_types)) { clear_derivative_cache($changed_types); } $page['infos'][] = l10n('Your configuration settings are saved'); } else { $template->assign('watermark', $pwatermark); $template->assign('ferrors', $errors); }
function pshare_section_init() { global $tokens, $page, $conf, $user, $template; if ($tokens[0] == 'pshare') { $page['section'] = 'pshare'; $page['title'] = l10n('Shared Picture'); if (!isset($tokens[1])) { die("missing key"); } if (!preg_match(PSHARE_KEY_PATTERN, $tokens[1])) { die("invalid key"); } $page['pshare_key'] = $tokens[1]; $query = ' SELECT *, NOW() AS dbnow FROM ' . PSHARE_KEYS_TABLE . ' WHERE uuid = \'' . $page['pshare_key'] . '\' ;'; $shares = query2array($query); if (count($shares) == 0) { die('unknown key'); } $share = $shares[0]; pshare_log($share['pshare_key_id'], 'visit'); // is the key still valid? if (strtotime($share['expire_on']) < strtotime($share['dbnow'])) { die('expired key'); } // if the user is permitted for this photo, let's redirect to // picture.php (with full details and actions) if (!is_a_guest() and pshare_is_photo_visible($share['image_id'])) { // find the first reachable category linked to the photo $query = ' SELECT category_id FROM ' . IMAGE_CATEGORY_TABLE . ' WHERE image_id = ' . $share['image_id'] . ' ;'; $authorizeds = array_diff(array_from_query($query, 'category_id'), explode(',', calculate_permissions($user['id'], $user['status']))); foreach ($authorizeds as $category_id) { $url = make_picture_url(array('image_id' => $share['image_id'], 'category' => get_cat_info($category_id))); if (function_exists('Fotorama_is_replace_picture') and Fotorama_is_replace_picture()) { $url .= '&slidestop'; } redirect($url); } redirect(make_picture_url(array('image_id' => $share['image_id']))); } $query = ' SELECT * FROM ' . IMAGES_TABLE . ' WHERE id = ' . $share['image_id'] . ' ;'; $rows = query2array($query); $image = $rows[0]; $src_image = new SrcImage($image); if (isset($tokens[2]) && 'download' == $tokens[2]) { $format_id = null; if (isset($tokens[3]) && preg_match('/^f(\\d+)$/', $tokens[3], $matches)) { $format_id = $matches[1]; $query = ' SELECT * FROM ' . IMAGE_FORMAT_TABLE . ' WHERE format_id = ' . $format_id . ' AND image_id = ' . $image['id'] . ' ;'; $formats = query2array($query); if (count($formats) == 0) { do_error(400, 'Invalid request - format'); } $format = $formats[0]; $file = original_to_format(get_element_path($image), $format['ext']); $image['file'] = get_filename_wo_extension($image['file']) . '.' . $format['ext']; } else { $file = $image['path']; } $gmt_mtime = gmdate('D, d M Y H:i:s', filemtime($file)) . ' GMT'; $http_headers = array('Content-Length: ' . @filesize($file), 'Last-Modified: ' . $gmt_mtime, 'Content-Type: ' . mime_content_type($file), 'Content-Disposition: attachment; filename="' . $image['file'] . '";', 'Content-Transfer-Encoding: binary'); foreach ($http_headers as $header) { header($header); } readfile($file); pshare_log($share['pshare_key_id'], 'download', $format_id); exit; } $template->set_filename('shared_picture', realpath(PSHARE_PATH . 'template/shared_picture.tpl')); $derivative = new DerivativeImage(ImageStdParams::get_by_type(IMG_MEDIUM), $src_image); $derivative_size = $derivative->get_size(); // a random string to avoid browser cache $rand = '&download=' . substr(md5(time()), 0, 6); $template->assign(array('SRC' => $derivative->get_url(), 'IMG_WIDTH' => $derivative_size[0], 'IMG_HEIGHT' => $derivative_size[1], 'DOWNLOAD_URL' => duplicate_index_url() . '/' . $page['pshare_key'] . '/download' . $rand)); // formats if (defined('IMAGE_FORMAT_TABLE')) { $query = ' SELECT * FROM ' . IMAGE_FORMAT_TABLE . ' WHERE image_id = ' . $share['image_id'] . ' ;'; $formats = query2array($query); if (!empty($formats)) { foreach ($formats as &$format) { $format['download_url'] = duplicate_index_url() . '/' . $page['pshare_key'] . '/download'; $format['download_url'] .= '/f' . $format['format_id'] . $rand; $format['filesize'] = sprintf('%.1fMB', $format['filesize'] / 1024); } } $template->assign('formats', $formats); } $template->parse('shared_picture'); $template->p(); exit; } }
function default_picture_content($content, $element_info) { global $conf; if (!empty($content)) { // someone hooked us - so we skip; return $content; } if (isset($_COOKIE['picture_deriv'])) { if (array_key_exists($_COOKIE['picture_deriv'], ImageStdParams::get_defined_type_map())) { pwg_set_session_var('picture_deriv', $_COOKIE['picture_deriv']); } setcookie('picture_deriv', false, 0, cookie_path()); } $deriv_type = pwg_get_session_var('picture_deriv', $conf['derivative_default_size']); $selected_derivative = $element_info['derivatives'][$deriv_type]; $unique_derivatives = array(); $show_original = isset($element_info['element_url']); $added = array(); foreach ($element_info['derivatives'] as $type => $derivative) { if ($type == IMG_SQUARE || $type == IMG_THUMB) { continue; } if (!array_key_exists($type, ImageStdParams::get_defined_type_map())) { continue; } $url = $derivative->get_url(); if (isset($added[$url])) { continue; } $added[$url] = 1; $show_original &= !$derivative->same_as_source(); $unique_derivatives[$type] = $derivative; } global $page, $template; if ($show_original) { $template->assign('U_ORIGINAL', $element_info['element_url']); } $template->append('current', array('selected_derivative' => $selected_derivative, 'unique_derivatives' => $unique_derivatives), true); $template->set_filenames(array('default_content' => 'picture_content.tpl')); $template->assign(array('ALT_IMG' => $element_info['file'], 'COOKIE_PATH' => cookie_path())); return $template->parse('default_content', true); }
file, path, representative_ext, width, height, rotation, name, rank FROM ' . IMAGES_TABLE . ' JOIN ' . IMAGE_CATEGORY_TABLE . ' ON image_id = id WHERE category_id = ' . $page['category_id'] . ' ORDER BY rank ;'; $result = pwg_query($query); if (pwg_db_num_rows($result) > 0) { // template thumbnail initialization $current_rank = 1; $derivativeParams = ImageStdParams::get_by_type(IMG_SQUARE); while ($row = pwg_db_fetch_assoc($result)) { $derivative = new DerivativeImage($derivativeParams, new SrcImage($row)); if (!empty($row['name'])) { $thumbnail_name = $row['name']; } else { $file_wo_ext = get_filename_wo_extension($row['file']); $thumbnail_name = str_replace('_', ' ', $file_wo_ext); } $current_rank++; $template->append('thumbnails', array('ID' => $row['id'], 'NAME' => $thumbnail_name, 'TN_SRC' => $derivative->get_url(), 'RANK' => $current_rank * 10, 'SIZE' => $derivative->get_size())); } } // image order management $sort_fields = array('' => '', 'file ASC' => l10n('File name, A → Z'), 'file DESC' => l10n('File name, Z → A'), 'name ASC' => l10n('Photo title, A → Z'), 'name DESC' => l10n('Photo title, Z → A'), 'date_creation DESC' => l10n('Date created, new → old'), 'date_creation ASC' => l10n('Date created, old → new'), 'date_available DESC' => l10n('Date posted, new → old'), 'date_available ASC' => l10n('Date posted, old → new'), 'rating_score DESC' => l10n('Rating score, high → low'), 'rating_score ASC' => l10n('Rating score, low → high'), 'hit DESC' => l10n('Visits, high → low'), 'hit ASC' => l10n('Visits, low → high'), 'id ASC' => l10n('Numeric identifier, 1 → 9'), 'id DESC' => l10n('Numeric identifier, 9 → 1'), 'rank ASC' => l10n('Manual sort order')); $template->assign('image_order_options', $sort_fields);
$key = get_ephemeral_key(2, $comment['image_id']); $tpl_comment['KEY'] = $key; $tpl_comment['IMAGE_ID'] = $comment['image_id']; $tpl_comment['CONTENT'] = $comment['content']; $tpl_comment['PWG_TOKEN'] = get_pwg_token(); $tpl_comment['U_CANCEL'] = $url_self; } } if (can_manage_comment('validate', $comment['author_id'])) { if ('true' != $comment['validated']) { $tpl_comment['U_VALIDATE'] = add_url_params($url_self, array('validate' => $comment['comment_id'], 'pwg_token' => get_pwg_token())); } } $template->append('comments', $tpl_comment); } } $derivative_params = trigger_change('get_comments_derivative_params', ImageStdParams::get_by_type(IMG_THUMB)); $template->assign('derivative_params', $derivative_params); // include menubar $themeconf = $template->get_template_vars('themeconf'); if (!isset($themeconf['hide_menu_on']) or !in_array('theCommentsPage', $themeconf['hide_menu_on'])) { include PHPWG_ROOT_PATH . 'include/menubar.inc.php'; } // +-----------------------------------------------------------------------+ // | html code display | // +-----------------------------------------------------------------------+ include PHPWG_ROOT_PATH . 'include/page_header.php'; trigger_notify('loc_end_comments'); flush_page_messages(); $template->pparse('comments'); include PHPWG_ROOT_PATH . 'include/page_tail.php';
return $d == 0 ? 0 : ($d < 0 ? -1 : 1); } function cv_compare($a, $b) { $d = $b['cv'] - $a['cv']; //desc return $d == 0 ? 0 : ($d < 0 ? -1 : 1); } function consensus_dev_compare($a, $b) { $d = $b['cd'] - $a['cd']; //desc return $d == 0 ? 0 : ($d < 0 ? -1 : 1); } function last_rate_compare($a, $b) { return -strcmp($a['last_date'], $b['last_date']); } $order_by_index = 4; if (isset($_GET['order_by']) and is_numeric($_GET['order_by'])) { $order_by_index = $_GET['order_by']; } $available_order_by = array(array(l10n('Average rate'), 'avg_compare'), array(l10n('Number of rates'), 'count_compare'), array(l10n('Variation'), 'cv_compare'), array(l10n('Consensus deviation'), 'consensus_dev_compare'), array(l10n('Last'), 'last_rate_compare')); for ($i = 0; $i < count($available_order_by); $i++) { $template->append('order_by_options', $available_order_by[$i][0]); } $template->assign('order_by_options_selected', array($order_by_index)); $x = uasort($by_user_ratings, $available_order_by[$order_by_index][1]); $template->assign(array('F_ACTION' => get_root_url() . 'admin.php', 'F_MIN_RATES' => $filter_min_rates, 'CONSENSUS_TOP_NUMBER' => $consensus_top_number, 'available_rates' => $conf['rate_items'], 'ratings' => $by_user_ratings, 'image_urls' => $image_urls, 'TN_WIDTH' => ImageStdParams::get_by_type(IMG_SQUARE)->sizing->ideal_size[0])); $template->set_filename('rating', 'rating_user.tpl'); $template->assign_var_from_handle('ADMIN_CONTENT', 'rating');
} } $enabled_by = array(); // keys ordered by all types foreach (ImageStdParams::get_all_types() as $type) { if (isset($enabled[$type])) { $enabled_by[$type] = $enabled[$type]; } } foreach (array_keys(ImageStdParams::$custom) as $custom) { if (isset($_POST['delete_custom_derivative_' . $custom])) { $changed_types[] = $custom; unset(ImageStdParams::$custom[$custom]); } } ImageStdParams::set_and_save($enabled_by); if (count($disabled) == 0) { $query = 'DELETE FROM ' . CONFIG_TABLE . ' WHERE param = \'disabled_derivatives\''; pwg_query($query); } else { conf_update_param('disabled_derivatives', addslashes(serialize($disabled))); } $conf['disabled_derivatives'] = serialize($disabled); if (count($changed_types)) { clear_derivative_cache($changed_types); } $page['infos'][] = l10n('Your configuration settings are saved'); } else { foreach ($original_fields as $field) { if (isset($_POST[$field])) { $template->append('sizes', array($field => $_POST[$field]), true);
// default L maxheight - 1 pixel // width if (!is_numeric($dbconf['upload_form_websize_maxwidth'])) { $dbconf['upload_form_websize_maxwidth'] = $medium_width_max; } if ($dbconf['upload_form_websize_maxwidth'] < $medium_width_min) { $dbconf['upload_form_websize_maxwidth'] = $medium_width_min; } if ($dbconf['upload_form_websize_maxwidth'] > $medium_width_max) { $dbconf['upload_form_websize_maxwidth'] = $medium_width_max; } // height if (!is_numeric($dbconf['upload_form_websize_maxheight'])) { $dbconf['upload_form_websize_maxheight'] = $medium_height_max; } if ($dbconf['upload_form_websize_maxheight'] < $medium_height_min) { $dbconf['upload_form_websize_maxheight'] = $medium_height_min; } if ($dbconf['upload_form_websize_maxheight'] > $medium_height_max) { $dbconf['upload_form_websize_maxheight'] = $medium_height_max; } $medium = new DerivativeParams(new SizingParams(array($dbconf['upload_form_websize_maxwidth'], $dbconf['upload_form_websize_maxheight']))); $types[IMG_MEDIUM] = $medium; } // // Save derivative new settings // ImageStdParams::set_and_save($types); pwg_query('DELETE FROM ' . CONFIG_TABLE . ' WHERE param = \'disabled_derivatives\''); clear_derivative_cache(); echo "\n" . $upgrade_description . "\n";
/** * Build 'type_map', 'all_type_map' and 'undefined_type_map'. */ private static function build_maps() { foreach (self::$type_map as $type => $params) { $params->type = $type; self::apply_global($params); } self::$all_type_map = self::$type_map; for ($i = 0; $i < count(self::$all_types); $i++) { $tocheck = self::$all_types[$i]; if (!isset(self::$type_map[$tocheck])) { for ($j = $i - 1; $j >= 0; $j--) { $target = self::$all_types[$j]; if (isset(self::$type_map[$target])) { self::$all_type_map[$tocheck] = self::$type_map[$target]; self::$undefined_type_map[$tocheck] = $target; break; } } } } }
$template->assign('CONTENT_DESCRIPTION', $page['comment']); } if (isset($page['category']['count_categories']) and $page['category']['count_categories'] == 0) { // count_categories might be computed by menubar - if the case unassign flat link if no sub albums $template->clear_assign('U_MODE_FLAT'); } //------------------------------------------------------ main part : thumbnails if (0 == $page['start'] and !isset($page['flat']) and !isset($page['chronology_field']) and ('recent_cats' == $page['section'] or 'categories' == $page['section']) and (!isset($page['category']['count_categories']) or $page['category']['count_categories'] > 0)) { include PHPWG_ROOT_PATH . 'include/category_cats.inc.php'; } if (!empty($page['items'])) { include PHPWG_ROOT_PATH . 'include/category_default.inc.php'; $url = add_url_params(duplicate_index_url(), array('display' => '')); $selected_type = $template->get_template_vars('derivative_params')->type; $template->clear_assign('derivative_params'); $type_map = ImageStdParams::get_defined_type_map(); unset($type_map[IMG_XXLARGE], $type_map[IMG_XLARGE]); foreach ($type_map as $params) { $template->append('image_derivatives', array('DISPLAY' => l10n($params->type), 'URL' => $url . $params->type, 'SELECTED' => $params->type == $selected_type ? true : false)); } } // slideshow // execute after init thumbs in order to have all picture informations if (!empty($page['cat_slideshow_url'])) { if (isset($_GET['slideshow'])) { redirect($page['cat_slideshow_url']); } elseif ($conf['index_slideshow_icon']) { $template->assign('U_SLIDESHOW', $page['cat_slideshow_url']); } } }
$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; } break; } $tpl_var['NAME'] = $name; $tpl_thumbnails_var[] = $tpl_var; } $template->assign(array('derivative_params' => trigger_change('get_index_derivative_params', ImageStdParams::get_by_type(pwg_get_session_var('index_deriv', IMG_THUMB))), 'maxRequests' => $conf['max_requests'], 'SHOW_THUMBNAIL_CAPTION' => $conf['show_thumbnail_caption'])); $tpl_thumbnails_var = trigger_change('loc_end_index_thumbnails', $tpl_thumbnails_var, $pictures); $template->assign('thumbnails', $tpl_thumbnails_var); $template->assign_var_from_handle('THUMBNAILS', 'index_thumbnails'); unset($pictures, $selection, $tpl_thumbnails_var); $template->clear_assign('thumbnails'); pwg_debug('end include/category_default.inc.php');
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')); }
$qlimit = min(5000, ceil(max($image_count / 500, $max_urls))); $query_model = 'SELECT * FROM ' . IMAGES_TABLE . ' WHERE id < start_id ORDER BY id DESC LIMIT ' . $qlimit; $urls = array(); do { $result = pwg_query(str_replace('start_id', $start_id, $query_model)); $is_last = pwg_db_num_rows($result) < $qlimit; while ($row = pwg_db_fetch_assoc($result)) { $start_id = $row['id']; $src_image = new SrcImage($row); if ($src_image->is_mimetype()) { continue; } if ($params['method'] == "slide" || $params['method'] == "square") { $derivative = new DerivativeImage(ImageStdParams::get_custom($params['height'], 9999), $src_image); } else { $derivative = new DerivativeImage(ImageStdParams::get_custom(9999, $params['height']), $src_image); } if (@filemtime($derivative->get_path()) === false) { $urls[] = $derivative->get_url() . $uid; } if (count($urls) >= $max_urls && !$is_last) { break; } } if ($is_last) { $start_id = 0; } } while (count($urls) < $max_urls && $start_id); $ret = array(); if ($start_id) { $ret['next_page'] = $start_id;
} $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
$representative_infos = $infos_of_image[$category['representative_picture_id']]; $tpl_var = array_merge($category, array('ID' => $category['id'], 'representative' => $representative_infos, 'TN_ALT' => strip_tags($category['name']), 'URL' => make_index_url(array('category' => $category)), 'CAPTION_NB_IMAGES' => get_display_images_count($category['nb_images'], $category['count_images'], $category['count_categories'], true, '<br>'), 'DESCRIPTION' => trigger_change('render_category_literal_description', trigger_change('render_category_description', @$category['comment'], 'subcatify_category_description')), 'NAME' => $name)); if ($conf['index_new_icon']) { $tpl_var['icon_ts'] = get_icon($category['max_date_last'], $category['is_child_date_last']); } if ($conf['display_fromto']) { if (isset($dates_of_category[$category['id']])) { $from = $dates_of_category[$category['id']]['from']; $to = $dates_of_category[$category['id']]['to']; if (!empty($from)) { $tpl_var['INFO_DATES'] = format_fromto($from, $to); } } } $tpl_thumbnails_var[] = $tpl_var; } // pagination $page['total_categories'] = count($tpl_thumbnails_var); $tpl_thumbnails_var_selection = array_slice($tpl_thumbnails_var, $page['startcat'], $conf['nb_categories_page']); $derivative_params = trigger_change('get_index_album_derivative_params', ImageStdParams::get_by_type(IMG_THUMB)); $tpl_thumbnails_var_selection = trigger_change('loc_end_index_category_thumbnails', $tpl_thumbnails_var_selection); $template->assign(array('maxRequests' => $conf['max_requests'], 'category_thumbnails' => $tpl_thumbnails_var_selection, 'derivative_params' => $derivative_params)); $template->assign_var_from_handle('CATEGORIES', 'index_category_thumbnails'); // navigation bar $page['cats_navigation_bar'] = array(); if ($page['total_categories'] > $conf['nb_categories_page']) { $page['cats_navigation_bar'] = create_navigation_bar(duplicate_index_url(array(), array('startcat')), $page['total_categories'], $page['startcat'], $conf['nb_categories_page'], true, 'startcat'); } $template->assign('cats_navbar', $page['cats_navigation_bar']); } pwg_debug('end include/category_cats.inc.php');
/** * Delete all derivative files for one or several types * * @param 'all'|int[] $types */ function clear_derivative_cache($types = 'all') { if ($types === 'all') { $types = ImageStdParams::get_all_types(); $types[] = IMG_CUSTOM; } elseif (!is_array($types)) { $types = array($types); } for ($i = 0; $i < count($types); $i++) { $type = $types[$i]; if ($type == IMG_CUSTOM) { $type = derivative_to_url($type) . '[a-zA-Z0-9]+'; } elseif (in_array($type, ImageStdParams::get_all_types())) { $type = derivative_to_url($type); } else { //assume a custom type $type = derivative_to_url(IMG_CUSTOM) . '_' . $type; } $types[$i] = $type; } $pattern = '#.*-'; if (count($types) > 1) { $pattern .= '(' . implode('|', $types) . ')'; } else { $pattern .= $types[0]; } $pattern .= '\\.[a-zA-Z0-9]{3,4}$#'; if ($contents = @opendir(PHPWG_ROOT_PATH . PWG_DERIVATIVE_DIR)) { while (($node = readdir($contents)) !== false) { if ($node != '.' and $node != '..' and is_dir(PHPWG_ROOT_PATH . PWG_DERIVATIVE_DIR . $node)) { clear_derivative_cache_rec(PHPWG_ROOT_PATH . PWG_DERIVATIVE_DIR . $node, $pattern); } } closedir($contents); } }
$my_conf = array_intersect_key($my_conf, $default_conf); conf_update_param('modus_theme', addslashes(serialize($my_conf))); global $page; $page['infos'][] = l10n('Information data registered in database'); } // *************** template init ******************** foreach ($text_values as $k) { $template->assign(strtoupper($k), $my_conf[$k]); } foreach ($bool_values as $k) { $template->assign(strtoupper($k), $my_conf[$k]); } // we don't use square thumbs if the thumb size is 0 $template->assign('use_album_square_thumbs', 0 != $my_conf['album_thumb_size']); if (0 == $my_conf['album_thumb_size']) { $template->assign('ALBUM_THUMB_SIZE', 250); } $available_derivatives = array(); foreach (array_keys(ImageStdParams::get_defined_type_map()) as $type) { $available_derivatives[$type] = l10n($type); } $available_skins = array(); $skin_dir = dirname(dirname(__FILE__)) . '/skins/'; $skin_suffix = '.inc.php'; foreach (glob($skin_dir . '*' . $skin_suffix) as $file) { $skin = substr($file, strlen($skin_dir), -strlen($skin_suffix)); $available_skins[$skin] = ucwords(str_replace('_', ' ', $skin)); } $template->assign(array('available_derivatives' => $available_derivatives, 'available_skins' => $available_skins)); $template->set_filename('modus_content', dirname(__FILE__) . '/modus_admin.tpl'); $template->assign_var_from_handle('ADMIN_CONTENT', 'modus_content');
/** * Build month calendar and assign the result in _$tpl_var_ * * @param array $tpl_var * @return bool */ protected function build_month_calendar(&$tpl_var) { global $page, $lang, $conf; $query = 'SELECT ' . pwg_db_get_dayofmonth($this->date_field) . ' as period, COUNT(DISTINCT id) as count'; $query .= $this->inner_sql; $query .= $this->get_date_where(); $query .= ' GROUP BY period ORDER BY period ASC'; $items = array(); $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { $d = (int) $row['period']; $items[$d] = array('nb_images' => $row['count']); } foreach ($items as $day => $data) { $page['chronology_date'][CDAY] = $day; $query = ' SELECT id, file,representative_ext,path,width,height,rotation, ' . pwg_db_get_dayofweek($this->date_field) . '-1 as dow'; $query .= $this->inner_sql; $query .= $this->get_date_where(); $query .= ' ORDER BY ' . DB_RANDOM_FUNCTION . '() LIMIT 1'; unset($page['chronology_date'][CDAY]); $row = pwg_db_fetch_assoc(pwg_query($query)); $derivative = new DerivativeImage(IMG_SQUARE, new SrcImage($row)); $items[$day]['derivative'] = $derivative; $items[$day]['file'] = $row['file']; $items[$day]['dow'] = $row['dow']; } if (!empty($items)) { list($known_day) = array_keys($items); $known_dow = $items[$known_day]['dow']; $first_day_dow = ($known_dow - ($known_day - 1)) % 7; if ($first_day_dow < 0) { $first_day_dow += 7; } //first_day_dow = week day corresponding to the first day of this month $wday_labels = $lang['day']; if ('monday' == $conf['week_starts_on']) { if ($first_day_dow == 0) { $first_day_dow = 6; } else { $first_day_dow -= 1; } $wday_labels[] = array_shift($wday_labels); } list($cell_width, $cell_height) = ImageStdParams::get_by_type(IMG_SQUARE)->sizing->ideal_size; $tpl_weeks = array(); $tpl_crt_week = array(); //fill the empty days in the week before first day of this month for ($i = 0; $i < $first_day_dow; $i++) { $tpl_crt_week[] = array(); } for ($day = 1; $day <= $this->get_all_days_in_month($page['chronology_date'][CYEAR], $page['chronology_date'][CMONTH]); $day++) { $dow = ($first_day_dow + $day - 1) % 7; if ($dow == 0 and $day != 1) { $tpl_weeks[] = $tpl_crt_week; // add finished week to week list $tpl_crt_week = array(); // start new week } if (!isset($items[$day])) { // empty day $tpl_crt_week[] = array('DAY' => $day); } else { $url = duplicate_index_url(array('chronology_date' => array($page['chronology_date'][CYEAR], $page['chronology_date'][CMONTH], $day))); $tpl_crt_week[] = array('DAY' => $day, 'DOW' => $dow, 'NB_ELEMENTS' => $items[$day]['nb_images'], 'IMAGE' => $items[$day]['derivative']->get_url(), 'U_IMG_LINK' => $url, 'IMAGE_ALT' => $items[$day]['file']); } } //fill the empty days in the week after the last day of this month while ($dow < 6) { $tpl_crt_week[] = array(); $dow++; } $tpl_weeks[] = $tpl_crt_week; $tpl_var['month_view'] = array('CELL_WIDTH' => $cell_width, 'CELL_HEIGHT' => $cell_height, 'wday_labels' => $wday_labels, 'weeks' => $tpl_weeks); } return true; }
/** * @return bool */ function will_watermark($out_size) { if ($this->use_watermark) { $min_size = ImageStdParams::get_watermark()->min_size; return $min_size[0] <= $out_size[0] || $min_size[1] <= $out_size[1]; } return false; }
function try_switch_source(DerivativeParams $params, $original_mtime) { global $page; if (!isset($page['original_size'])) { return false; } $original_size = $page['original_size']; if ($page['rotation_angle'] == 90 || $page['rotation_angle'] == 270) { $tmp = $original_size[0]; $original_size[0] = $original_size[1]; $original_size[1] = $tmp; } $dsize = $params->compute_final_size($original_size); $use_watermark = $params->use_watermark; if ($use_watermark) { $use_watermark = $params->will_watermark($dsize); } $candidates = array(); foreach (ImageStdParams::get_defined_type_map() as $candidate) { if ($candidate->type == $params->type) { continue; } if ($candidate->use_watermark != $use_watermark) { continue; } if ($candidate->max_width() < $params->max_width() || $candidate->max_height() < $params->max_height()) { continue; } $candidate_size = $candidate->compute_final_size($original_size); if ($dsize != $params->compute_final_size($candidate_size)) { continue; } if ($params->sizing->max_crop == 0) { if ($candidate->sizing->max_crop != 0) { continue; } } else { if ($use_watermark && $candidate->use_watermark) { continue; } //a square that requires watermark should not be generated from a larger derivative with watermark, because if the watermark is not centered on the large image, it will be cropped. if ($candidate->sizing->max_crop != 0) { continue; } // this could be optimized if ($candidate_size[0] < $params->sizing->min_size[0] || $candidate_size[1] < $params->sizing->min_size[1]) { continue; } } $candidates[] = $candidate; } foreach (array_reverse($candidates) as $candidate) { $candidate_path = $page['derivative_path']; $candidate_path = str_replace('-' . derivative_to_url($params->type), '-' . derivative_to_url($candidate->type), $candidate_path); $candidate_mtime = @filemtime($candidate_path); if ($candidate_mtime === false || $candidate_mtime < $original_mtime || $candidate_mtime < $candidate->last_mod_time) { continue; } $params->use_watermark = false; $params->sharpen = min(1, $params->sharpen); $page['src_path'] = $candidate_path; $page['src_url'] = $page['root_path'] . substr($candidate_path, strlen(PHPWG_ROOT_PATH)); $page['rotation_angle'] = 0; return true; } return false; }
/** * @todo : documentation of DerivativeImage::build */ private static function build($src, &$params, &$rel_path, &$rel_url, &$is_cached = null) { if ($src->has_size() && $params->is_identity($src->get_size())) { // the source image is smaller than what we should do - we do not upsample if (!$params->will_watermark($src->get_size()) && !$src->rotation) { // no watermark, no rotation required -> we will use the source image $params = null; $rel_path = $rel_url = $src->rel_path; return; } $defined_types = array_keys(ImageStdParams::get_defined_type_map()); for ($i = 0; $i < count($defined_types); $i++) { if ($defined_types[$i] == $params->type) { for ($i--; $i >= 0; $i--) { $smaller = ImageStdParams::get_by_type($defined_types[$i]); if ($smaller->sizing->max_crop == $params->sizing->max_crop && $smaller->is_identity($src->get_size())) { $params = $smaller; self::build($src, $params, $rel_path, $rel_url, $is_cached); return; } } break; } } } $tokens = array(); $tokens[] = substr($params->type, 0, 2); if ($params->type == IMG_CUSTOM) { $params->add_url_tokens($tokens); } $loc = $src->rel_path; if (substr_compare($loc, './', 0, 2) == 0) { $loc = substr($loc, 2); } elseif (substr_compare($loc, '../', 0, 3) == 0) { $loc = substr($loc, 3); } $loc = substr_replace($loc, '-' . implode('_', $tokens), strrpos($loc, '.'), 0); $rel_path = PWG_DERIVATIVE_DIR . $loc; global $conf; $url_style = $conf['derivative_url_style']; if (!$url_style) { $mtime = @filemtime(PHPWG_ROOT_PATH . $rel_path); if ($mtime === false or $mtime < $params->last_mod_time) { $is_cached = false; $url_style = 2; } else { $url_style = 1; } } if ($url_style == 2) { $rel_url = 'i'; if ($conf['php_extension_in_urls']) { $rel_url .= '.php'; } if ($conf['question_mark_in_urls']) { $rel_url .= '?'; } $rel_url .= '/' . $loc; } else { $rel_url = $rel_path; } }
/** * API method * Returns a list of missing derivatives (not generated yet) * @param mixed[] $params * @option string types (optional) * @option int[] ids * @option int max_urls * @option int prev_page (optional) */ function ws_getMissingDerivatives($params, &$service) { global $conf; if (empty($params['types'])) { $types = array_keys(ImageStdParams::get_defined_type_map()); } else { $types = array_intersect(array_keys(ImageStdParams::get_defined_type_map()), $params['types']); if (count($types) == 0) { return new PwgError(WS_ERR_INVALID_PARAM, "Invalid types"); } } $max_urls = $params['max_urls']; $query = 'SELECT MAX(id)+1, COUNT(*) FROM ' . IMAGES_TABLE . ';'; list($max_id, $image_count) = pwg_db_fetch_row(pwg_query($query)); if (0 == $image_count) { return array(); } $start_id = $params['prev_page']; if ($start_id <= 0) { $start_id = $max_id; } $uid = '&b=' . time(); $conf['question_mark_in_urls'] = $conf['php_extension_in_urls'] = true; $conf['derivative_url_style'] = 2; //script $qlimit = min(5000, ceil(max($image_count / 500, $max_urls / count($types)))); $where_clauses = ws_std_image_sql_filter($params, ''); $where_clauses[] = 'id<start_id'; if (!empty($params['ids'])) { $where_clauses[] = 'id IN (' . implode(',', $params['ids']) . ')'; } $query_model = ' SELECT id, path, representative_ext, width, height, rotation FROM ' . IMAGES_TABLE . ' WHERE ' . implode(' AND ', $where_clauses) . ' ORDER BY id DESC LIMIT ' . $qlimit . ' ;'; $urls = array(); do { $result = pwg_query(str_replace('start_id', $start_id, $query_model)); $is_last = pwg_db_num_rows($result) < $qlimit; while ($row = pwg_db_fetch_assoc($result)) { $start_id = $row['id']; $src_image = new SrcImage($row); if ($src_image->is_mimetype()) { continue; } foreach ($types as $type) { $derivative = new DerivativeImage($type, $src_image); if ($type != $derivative->get_type()) { continue; } if (@filemtime($derivative->get_path()) === false) { $urls[] = $derivative->get_url() . $uid; } } if (count($urls) >= $max_urls and !$is_last) { break; } } if ($is_last) { $start_id = 0; } } while (count($urls) < $max_urls and $start_id); $ret = array(); if ($start_id) { $ret['next_page'] = $start_id; } $ret['urls'] = $urls; return $ret; }
$query_model = 'SELECT * FROM ' . IMAGES_TABLE . ' WHERE id < start_id ORDER BY id DESC LIMIT ' . $qlimit; $urls = array(); do { $result = pwg_query(str_replace('start_id', $start_id, $query_model)); $is_last = pwg_db_num_rows($result) < $qlimit; while ($row = pwg_db_fetch_assoc($result)) { $start_id = $row['id']; $src_image = new SrcImage($row); if ($src_image->is_mimetype()) { continue; } $derivative = new DerivativeImage(ImageStdParams::get_custom(9999, $conf['GThumb']['height']), $src_image); if (@filemtime($derivative->get_path()) === false) { $urls[] = $derivative->get_url() . $uid; } if (count($urls) >= $max_urls && !$is_last) { break; } } if ($is_last) { $start_id = 0; } } while (count($urls) < $max_urls && $start_id); $ret = array(); if ($start_id) { $ret['next_page'] = $start_id; }
function modus_picture_content($content, $element_info) { global $conf, $picture, $template; if (!empty($content)) { // someone hooked us - so we skip; return $content; } $unique_derivatives = array(); $show_original = isset($element_info['element_url']); $added = array(); foreach ($element_info['derivatives'] as $type => $derivative) { if ($type == IMG_SQUARE || $type == IMG_THUMB) { continue; } if (!array_key_exists($type, ImageStdParams::get_defined_type_map())) { continue; } $url = $derivative->get_url(); if (isset($added[$url])) { continue; } $added[$url] = 1; $show_original &= !$derivative->same_as_source(); $unique_derivatives[$type] = $derivative; } if (isset($_COOKIE['picture_deriv'])) { // ignore persistence setcookie('picture_deriv', false, 0, cookie_path()); } $selected_derivative = null; if (isset($_COOKIE['phavsz'])) { $available_size = explode('x', $_COOKIE['phavsz']); } elseif (($caps = pwg_get_session_var('caps')) && $caps[0] > 1) { $available_size = array($caps[0] * $caps[1], $caps[0] * ($caps[2] - 100), $caps[0]); } if (isset($available_size)) { foreach ($unique_derivatives as $derivative) { $size = $derivative->get_size(); if (!$size) { break; } if ($size[0] <= $available_size[0] and $size[1] <= $available_size[1]) { $selected_derivative = $derivative; } else { if ($available_size[2] > 1 || !$selected_derivative) { $selected_derivative = $derivative; } break; } } if ($available_size[2] > 1 && $selected_derivative) { $ratio_w = $size[0] / $available_size[0]; $ratio_h = $size[1] / $available_size[1]; if ($ratio_w > 1 || $ratio_h > 1) { if ($ratio_w > $ratio_h) { $display_size = array($available_size[0] / $available_size[2], floor($size[1] / $ratio_w / $available_size[2])); } else { $display_size = array(floor($size[0] / $ratio_h / $available_size[2]), $available_size[1] / $available_size[2]); } } else { $display_size = array(round($size[0] / $available_size[2]), round($size[1] / $available_size[2])); } $template->assign(array('rvas_display_size' => $display_size, 'rvas_natural_size' => $size)); } if (isset($picture['next']) and $picture['next']['src_image']->is_original()) { $next_best = null; foreach ($picture['next']['derivatives'] as $derivative) { $size = $derivative->get_size(); if (!$size) { break; } if ($size[0] <= $available_size[0] and $size[1] <= $available_size[1]) { $next_best = $derivative; } else { if ($available_size[2] > 1 || !$next_best) { $next_best = $derivative; } break; } } if (isset($next_best)) { $template->assign('U_PREFETCH', $next_best->get_url()); } } } $as_pending = false; if (!$selected_derivative) { $as_pending = true; $selected_derivative = $element_info['derivatives'][pwg_get_session_var('picture_deriv', $conf['derivative_default_size'])]; } if ($show_original) { $template->assign('U_ORIGINAL', $element_info['element_url']); } $template->append('current', array('selected_derivative' => $selected_derivative, 'unique_derivatives' => $unique_derivatives), true); $template->set_filenames(array('default_content' => 'picture_content_asize.tpl')); $template->assign(array('ALT_IMG' => $element_info['file'], 'COOKIE_PATH' => cookie_path(), 'RVAS_PENDING' => $as_pending)); return $template->parse('default_content', true); }
$persistent_cache = new PersistentFileCache(); // Database connection try { pwg_db_connect($conf['db_host'], $conf['db_user'], $conf['db_password'], $conf['db_base']); } catch (Exception $e) { my_error(l10n($e->getMessage()), true); } pwg_db_check_charset(); load_conf_from_db(); $logger = new Logger(array('directory' => PHPWG_ROOT_PATH . $conf['data_location'] . $conf['log_dir'], 'severity' => $conf['log_level'], 'filename' => 'log_' . date('Y-m-d') . '_' . sha1(date('Y-m-d') . $conf['db_password']) . '.txt', 'globPattern' => 'log_*.txt', 'archiveDays' => $conf['log_archive_days'])); if (!$conf['check_upgrade_feed']) { if (!isset($conf['piwigo_db_version']) or $conf['piwigo_db_version'] != get_branch_from_version(PHPWG_VERSION)) { redirect(get_root_url() . 'upgrade.php'); } } ImageStdParams::load_from_db(); session_start(); load_plugins(); // users can have defined a custom order pattern, incompatible with GUI form if (isset($conf['order_by_custom'])) { $conf['order_by'] = $conf['order_by_custom']; } if (isset($conf['order_by_inside_category_custom'])) { $conf['order_by_inside_category'] = $conf['order_by_inside_category_custom']; } include PHPWG_ROOT_PATH . 'include/user.inc.php'; if (in_array(substr($user['language'], 0, 2), array('fr', 'it', 'de', 'es', 'pl', 'hu', 'ru', 'nl', 'tr', 'da'))) { define('PHPWG_DOMAIN', substr($user['language'], 0, 2) . '.piwigo.org'); } elseif ('zh_CN' == $user['language']) { define('PHPWG_DOMAIN', 'cn.piwigo.org'); } elseif ('pt_BR' == $user['language']) {
FileCombiner::clear_combined_files(); $persistent_cache->purge(true); break; case 'derivatives': clear_derivative_cache($_GET['type']); break; default: break; } // +-----------------------------------------------------------------------+ // | template init | // +-----------------------------------------------------------------------+ $template->set_filenames(array('maintenance' => 'maintenance.tpl')); $url_format = get_root_url() . 'admin.php?page=maintenance&action=%s&pwg_token=' . get_pwg_token(); $purge_urls[l10n('All')] = sprintf($url_format, 'derivatives') . '&type=all'; foreach (ImageStdParams::get_defined_type_map() as $params) { $purge_urls[l10n($params->type)] = sprintf($url_format, 'derivatives') . '&type=' . $params->type; } $purge_urls[l10n(IMG_CUSTOM)] = sprintf($url_format, 'derivatives') . '&type=' . IMG_CUSTOM; $template->assign(array('U_MAINT_CATEGORIES' => sprintf($url_format, 'categories'), 'U_MAINT_IMAGES' => sprintf($url_format, 'images'), 'U_MAINT_ORPHAN_TAGS' => sprintf($url_format, 'delete_orphan_tags'), 'U_MAINT_USER_CACHE' => sprintf($url_format, 'user_cache'), 'U_MAINT_HISTORY_DETAIL' => sprintf($url_format, 'history_detail'), 'U_MAINT_HISTORY_SUMMARY' => sprintf($url_format, 'history_summary'), 'U_MAINT_SESSIONS' => sprintf($url_format, 'sessions'), 'U_MAINT_FEEDS' => sprintf($url_format, 'feeds'), 'U_MAINT_DATABASE' => sprintf($url_format, 'database'), 'U_MAINT_C13Y' => sprintf($url_format, 'c13y'), 'U_MAINT_SEARCH' => sprintf($url_format, 'search'), 'U_MAINT_COMPILED_TEMPLATES' => sprintf($url_format, 'compiled-templates'), 'U_MAINT_DERIVATIVES' => sprintf($url_format, 'derivatives'), 'purge_derivatives' => $purge_urls, 'U_HELP' => get_root_url() . 'admin/popuphelp.php?page=maintenance')); if ($conf['gallery_locked']) { $template->assign(array('U_MAINT_UNLOCK_GALLERY' => sprintf($url_format, 'unlock_gallery'))); } else { $template->assign(array('U_MAINT_LOCK_GALLERY' => sprintf($url_format, 'lock_gallery'))); } // +-----------------------------------------------------------------------+ // | Define advanced features | // +-----------------------------------------------------------------------+ $advanced_features = array(); //$advanced_features is array of array composed of CAPTION & URL $advanced_features = trigger_change('get_admin_advanced_features_links', $advanced_features);
foreach (glob(PHPWG_ROOT_PATH . 'themes/default/watermarks/*.png') as $file) { $watermark_files[] = substr($file, strlen(PHPWG_ROOT_PATH)); } if (($glob = glob(PHPWG_ROOT_PATH . PWG_LOCAL_DIR . 'watermarks/*.png')) !== false) { foreach ($glob as $file) { $watermark_files[] = substr($file, strlen(PHPWG_ROOT_PATH)); } } $watermark_filemap = array('' => '---'); foreach ($watermark_files as $file) { $display = basename($file); $watermark_filemap[$file] = $display; } $template->assign('watermark_files', $watermark_filemap); if ($template->get_template_vars('watermark') === null) { $wm = ImageStdParams::get_watermark(); $position = 'custom'; if ($wm->xpos == 0 and $wm->ypos == 0) { $position = 'topleft'; } if ($wm->xpos == 100 and $wm->ypos == 0) { $position = 'topright'; } if ($wm->xpos == 50 and $wm->ypos == 50) { $position = 'middle'; } if ($wm->xpos == 0 and $wm->ypos == 100) { $position = 'bottomleft'; } if ($wm->xpos == 100 and $wm->ypos == 100) { $position = 'bottomright';
/** * The "define_derivative" function allows to define derivative from tpl file. * It assigns a DerivativeParams object to _name_ template variable. * * @param array $params * - name (required) * - type (optional) * - width (required if type is empty) * - height (required if type is empty) * - crop (optional, used if type is empty) * - min_height (optional, used with crop) * - min_height (optional, used with crop) * @param Smarty $smarty */ function func_define_derivative($params, $smarty) { !empty($params['name']) or fatal_error('define_derivative missing name'); if (isset($params['type'])) { $derivative = ImageStdParams::get_by_type($params['type']); $smarty->assign($params['name'], $derivative); return; } !empty($params['width']) or fatal_error('define_derivative missing width'); !empty($params['height']) or fatal_error('define_derivative missing height'); $w = intval($params['width']); $h = intval($params['height']); $crop = 0; $minw = null; $minh = null; if (isset($params['crop'])) { if (is_bool($params['crop'])) { $crop = $params['crop'] ? 1 : 0; } else { $crop = round($params['crop'] / 100, 2); } if ($crop) { $minw = empty($params['min_width']) ? $w : intval($params['min_width']); $minw <= $w or fatal_error('define_derivative invalid min_width'); $minh = empty($params['min_height']) ? $h : intval($params['min_height']); $minh <= $h or fatal_error('define_derivative invalid min_height'); } } $smarty->assign($params['name'], ImageStdParams::get_custom($w, $h, $crop, $minw, $minh)); }