// +-----------------------------------------------------------------------+ $template->set_filenames(array('element_set_ranks' => 'element_set_ranks.tpl')); $base_url = get_root_url() . 'admin.php'; $query = ' SELECT * FROM ' . CATEGORIES_TABLE . ' WHERE id = ' . $page['category_id'] . ' ;'; $category = pwg_db_fetch_assoc(pwg_query($query)); if ($category['image_order'] == 'rank ASC') { $image_order_choice = 'rank'; } elseif ($category['image_order'] != '') { $image_order_choice = 'user_define'; } // Navigation path $navigation = get_cat_display_name_cache($category['uppercats'], get_root_url() . 'admin.php?page=album-'); $template->assign(array('CATEGORIES_NAV' => $navigation, 'F_ACTION' => $base_url . get_query_string_diff(array()))); // +-----------------------------------------------------------------------+ // | thumbnails | // +-----------------------------------------------------------------------+ $query = ' SELECT id, file, path, representative_ext, width, height, rotation, name, rank FROM ' . IMAGES_TABLE . ' JOIN ' . IMAGE_CATEGORY_TABLE . ' ON image_id = id
/** * API method * Returns the list of categories as you can see them in administration * @param mixed[] $params * * Only admin can run this method and permissions are not taken into * account. */ function ws_categories_getAdminList($params, &$service) { $query = ' SELECT category_id, COUNT(*) AS counter FROM ' . IMAGE_CATEGORY_TABLE . ' GROUP BY category_id ;'; $nb_images_of = query2array($query, 'category_id', 'counter'); $query = ' SELECT id, name, comment, uppercats, global_rank, dir FROM ' . CATEGORIES_TABLE . ' ;'; $result = pwg_query($query); $cats = array(); while ($row = pwg_db_fetch_assoc($result)) { $id = $row['id']; $row['nb_images'] = isset($nb_images_of[$id]) ? $nb_images_of[$id] : 0; $row['name'] = strip_tags(trigger_change('render_category_name', $row['name'], 'ws_categories_getAdminList')); $row['fullname'] = strip_tags(get_cat_display_name_cache($row['uppercats'], null)); $row['comment'] = strip_tags(trigger_change('render_category_description', $row['comment'], 'ws_categories_getAdminList')); $cats[] = $row; } usort($cats, 'global_rank_compare'); return array('categories' => new PwgNamedArray($cats, 'category', array('id', 'nb_images', 'name', 'uppercats', 'global_rank'))); }
/** * Assign a template var useable with {html_options} from a list of categories * * @param array[] $categories (at least id,name,global_rank,uppercats for each) * @param int[] $selected ids of selected items * @param string $blockname variable name in template * @param bool $fullname full breadcrumb or not */ function display_select_categories($categories, $selecteds, $blockname, $fullname = true) { global $template; $tpl_cats = array(); foreach ($categories as $category) { if ($fullname) { $option = strip_tags(get_cat_display_name_cache($category['uppercats'], null)); } else { $option = str_repeat(' ', 3 * substr_count($category['global_rank'], '.')); $option .= '- '; $option .= strip_tags(trigger_change('render_category_name', $category['name'], 'display_select_categories')); } $tpl_cats[$category['id']] = $option; } $template->assign($blockname, $tpl_cats); $template->assign($blockname . '_selected', $selecteds); }
// +-----------------------------------------------------------------------+ $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/admin_config.tpl'); // +-----------------------------------------------------------------------+ // | form options | // +-----------------------------------------------------------------------+ $query = ' SELECT pm.*, uppercats FROM ' . PFEMAIL_MAILBOXES_TABLE . ' AS pm JOIN ' . CATEGORIES_TABLE . ' AS c ON c.id = category_id ORDER BY pm.id DESC ;'; $mailboxes = query2array($query); foreach ($mailboxes as $idx => $mailbox) { $mailboxes[$idx]['album'] = get_cat_display_name_cache($mailbox['uppercats'], null, false); $mailboxes[$idx]['data'] = json_encode($mailbox); } $template->assign(array('mailboxes' => $mailboxes, 'PWG_TOKEN' => get_pwg_token())); // list of albums $query = ' SELECT id,name,uppercats,global_rank FROM ' . CATEGORIES_TABLE . ' ;'; display_select_cat_wrapper($query, isset($category_options_selected) ? $category_options_selected : array(), 'category_options'); // groups $query = ' SELECT id FROM ' . GROUPS_TABLE . ' ;'; $group_ids = query2array($query, null, 'id');
'; if ($sort_by[0] == 'id' or $sort_by[0] == 'permalink') { $query .= ' ORDER BY ' . $sort_by[0]; } $categories = array(); $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { $row['name'] = get_cat_display_name_cache($row['uppercats']); $categories[] = $row; } if ($sort_by[0] == 'name') { usort($categories, 'global_rank_compare'); } $template->assign('permalinks', $categories); // --- generate display of old permalinks -------------------------------------- $sort_by = parse_sort_variables(array('cat_id', 'permalink', 'date_deleted', 'last_hit', 'hit'), null, 'dpsf', array('delete_permanent'), 'SORT_OLD_', '#old_permalinks'); $url_del_base = get_root_url() . 'admin.php?page=permalinks'; $query = 'SELECT * FROM ' . OLD_PERMALINKS_TABLE; if (count($sort_by)) { $query .= ' ORDER BY ' . $sort_by[0]; } $result = pwg_query($query); $deleted_permalinks = array(); while ($row = pwg_db_fetch_assoc($result)) { $row['name'] = get_cat_display_name_cache($row['cat_id']); $row['U_DELETE'] = add_url_params($url_del_base, array('delete_permanent' => $row['permalink'])); $deleted_permalinks[] = $row; } $template->assign('deleted_permalinks', $deleted_permalinks); $template->assign('U_HELP', get_root_url() . 'admin/popuphelp.php?page=permalinks'); $template->assign_var_from_handle('ADMIN_CONTENT', 'permalinks');
$template->assign('U_COI', get_root_url() . 'admin.php?page=picture_coi&image_id=' . $_GET['image_id']); } // image level options $selected_level = isset($_POST['level']) ? $_POST['level'] : $row['level']; $template->assign(array('level_options' => get_privacy_level_options(), 'level_options_selected' => array($selected_level))); // categories $query = ' SELECT category_id, uppercats FROM ' . IMAGE_CATEGORY_TABLE . ' AS ic INNER JOIN ' . CATEGORIES_TABLE . ' AS c ON c.id = ic.category_id WHERE image_id = ' . $_GET['image_id'] . ' ;'; $result = pwg_query($query); while ($row = pwg_db_fetch_assoc($result)) { $name = get_cat_display_name_cache($row['uppercats'], get_root_url() . 'admin.php?page=album-'); if ($row['category_id'] == $storage_category_id) { $template->assign('STORAGE_CATEGORY', $name); } else { $template->append('related_categories', $name); } } // jump to link // // 1. find all linked categories that are reachable for the current user. // 2. if a category is available in the URL, use it if reachable // 3. if URL category not available or reachable, use the first reachable // linked category // 4. if no category reachable, no jumpto link $query = ' SELECT category_id
} if (count($categories) > 0) { // Update filtered data if (function_exists('update_cats_with_filtered_data')) { update_cats_with_filtered_data($categories); } $template->set_filename('index_category_thumbnails', 'mainpage_categories.tpl'); trigger_notify('loc_begin_index_category_thumbnails', $categories); $tpl_thumbnails_var = array(); foreach ($categories as $category) { if (0 == $category['count_images']) { continue; } $category['name'] = trigger_change('render_category_name', $category['name'], 'subcatify_category_name'); if ($page['section'] == 'recent_cats') { $name = get_cat_display_name_cache($category['uppercats'], null); } else { $name = $category['name']; } $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); }
$result = pwg_query($query); $username_of = array(); while ($row = pwg_db_fetch_assoc($result)) { $username_of[$row['id']] = stripslashes($row['username']); } } if (count($category_ids) > 0) { $query = ' SELECT id, uppercats FROM ' . CATEGORIES_TABLE . ' WHERE id IN (' . implode(',', array_keys($category_ids)) . ') ;'; $uppercats_of = query2array($query, 'id', 'uppercats'); $name_of_category = array(); foreach ($uppercats_of as $category_id => $uppercats) { $name_of_category[$category_id] = get_cat_display_name_cache($uppercats); } } if (count($image_ids) > 0) { $query = ' SELECT id, IF(name IS NULL, file, name) AS label, filesize, file, path, representative_ext FROM ' . IMAGES_TABLE . ' WHERE id IN (' . implode(',', array_keys($image_ids)) . ') ;'; $image_infos = query2array($query, 'id');
} $query = ' SELECT id, uppercats, global_rank FROM ' . CATEGORIES_TABLE . ' WHERE id IN (' . implode(',', $cat_ids) . ') ;'; $result = pwg_query($query); $categories = array(); if (!empty($result)) { while ($row = pwg_db_fetch_assoc($result)) { $categories[] = $row; } } usort($categories, 'global_rank_compare'); foreach ($categories as $category) { $template->append('search_categories', get_cat_display_name_cache($category['uppercats'], null)); } } foreach (array('date_available', 'date_creation') as $datefield) { if ('date_available' == $datefield) { $lang_items = array('date' => l10n('posted on %s'), 'period' => l10n('posted between %s (%s) and %s (%s)'), 'after' => l10n('posted after %s (%s)'), 'before' => l10n('posted before %s (%s)')); } elseif ('date_creation' == $datefield) { $lang_items = array('date' => l10n('created on %s'), 'period' => l10n('created between %s (%s) and %s (%s)'), 'after' => l10n('created after %s (%s)'), 'before' => l10n('created before %s (%s)')); } $keys = array('date' => $datefield, 'after' => $datefield . '-after', 'before' => $datefield . '-before'); if (isset($search['fields'][$keys['date']])) { $template->assign(strtoupper($datefield), sprintf($lang_items['date'], format_date($search['fields'][$keys['date']]))); } elseif (isset($search['fields'][$keys['before']]) and isset($search['fields'][$keys['after']])) { $template->assign(strtoupper($datefield), sprintf($lang_items['period'], format_date($search['fields'][$keys['after']]['date']), inc_exc_str($search['fields'][$keys['after']]['inc']), format_date($search['fields'][$keys['before']]['date']), inc_exc_str($search['fields'][$keys['before']]['inc']))); } elseif (isset($search['fields'][$keys['before']])) { $template->assign(strtoupper($datefield), sprintf($lang_items['before'], format_date($search['fields'][$keys['before']]['date']), inc_exc_str($search['fields'][$keys['before']]['inc'])));
/** * Returns html description about recently published elements grouped by post date. * @todo clean up HTML output, currently messy and invalid ! * * @param array $date_detail returned value of get_recent_post_dates() * @return string */ function get_html_description_recent_post_date($date_detail, $auth_key = null) { global $conf; $add_url_params = array(); if (isset($auth_key)) { $add_url_params['auth'] = $auth_key; } $description = '<ul>'; $description .= '<li>' . l10n_dec('%d new photo', '%d new photos', $date_detail['nb_elements']) . ' (' . '<a href="' . add_url_params(make_index_url(array('section' => 'recent_pics')), $add_url_params) . '">' . l10n('Recent photos') . '</a>' . ')' . '</li><br>'; foreach ($date_detail['elements'] as $element) { $tn_src = DerivativeImage::thumb_url($element); $description .= '<a href="' . add_url_params(make_picture_url(array('image_id' => $element['id'], 'image_file' => $element['file'])), $add_url_params) . '"><img src="' . $tn_src . '"></a>'; } $description .= '...<br>'; $description .= '<li>' . l10n_dec('%d album updated', '%d albums updated', $date_detail['nb_cats']) . '</li>'; $description .= '<ul>'; foreach ($date_detail['categories'] as $cat) { $description .= '<li>' . get_cat_display_name_cache($cat['uppercats'], '', false, null, $auth_key) . ' (' . l10n_dec('%d new photo', '%d new photos', $cat['img_count']) . ')' . '</li>'; } $description .= '</ul>'; $description .= '</ul>'; return $description; }
INNER JOIN ' . GROUP_ACCESS_TABLE . ' AS ga ON ug.group_id = ga.group_id INNER JOIN ' . CATEGORIES_TABLE . ' AS c ON c.id = ga.cat_id WHERE ug.user_id = ' . $page['user'] . ' ;'; $result = pwg_query($query); if (pwg_db_num_rows($result) > 0) { $cats = array(); while ($row = pwg_db_fetch_assoc($result)) { $cats[] = $row; $group_authorized[] = $row['cat_id']; } usort($cats, 'global_rank_compare'); foreach ($cats as $category) { $template->append('categories_because_of_groups', get_cat_display_name_cache($category['uppercats'], null)); } } // only private categories are listed $query_true = ' SELECT id,name,uppercats,global_rank FROM ' . CATEGORIES_TABLE . ' INNER JOIN ' . USER_ACCESS_TABLE . ' ON cat_id = id WHERE status = \'private\' AND user_id = ' . $page['user']; if (count($group_authorized) > 0) { $query_true .= ' AND cat_id NOT IN (' . implode(',', $group_authorized) . ')'; } $query_true .= ' ;'; display_select_cat_wrapper($query_true, array(), 'category_option_true');