예제 #1
0
SELECT
    c.*,
    user_representative_picture_id,
    nb_images,
    date_last,
    max_date_last,
    count_images,
    nb_categories,
    count_categories
  FROM ' . CATEGORIES_TABLE . ' c
    INNER JOIN ' . USER_CACHE_CATEGORIES_TABLE . ' ucc
    ON id = cat_id
    AND user_id = ' . $user['id'];
if ('recent_cats' == $page['section']) {
    $query .= '
  WHERE ' . get_recent_photos_sql('date_last');
} else {
    $query .= '
  WHERE id_uppercat ' . (!isset($page['category']) ? 'is NULL' : '= ' . $page['category']['id']);
}
$query .= '
      ' . get_sql_condition_FandF(array('visible_categories' => 'id'), 'AND');
if ('recent_cats' != $page['section']) {
    $query .= '
  ORDER BY rank';
}
$result = pwg_query($query);
$categories = array();
$category_ids = array();
$image_ids = array();
$user_representative_updates_for = array();
예제 #2
0
;';
                    $page = array_merge($page, array('items' => query2array($query, null, 'image_id')));
                    if (count($page['items']) > 0) {
                        $template->assign('favorite', array('U_FAVORITE' => add_url_params(make_index_url(array('section' => 'favorites')), array('action' => 'remove_all_from_favorites'))));
                    }
                }
            } else {
                if ($page['section'] == 'recent_pics') {
                    if (!isset($page['super_order_by'])) {
                        $conf['order_by'] = str_replace('ORDER BY ', 'ORDER BY date_available DESC,', $conf['order_by']);
                    }
                    $query = '
SELECT DISTINCT(id)
  FROM ' . IMAGES_TABLE . '
    INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS ic ON id = ic.image_id
  WHERE ' . get_recent_photos_sql('date_available') . '
  ' . $forbidden . $conf['order_by'] . '
;';
                    $page = array_merge($page, array('title' => '<a href="' . duplicate_index_url(array('start' => 0)) . '">' . l10n('Recent photos') . '</a>', 'items' => query2array($query, null, 'id')));
                } else {
                    if ($page['section'] == 'recent_cats') {
                        $page = array_merge($page, array('title' => l10n('Recent albums')));
                    } else {
                        if ($page['section'] == 'most_visited') {
                            $page['super_order_by'] = true;
                            $conf['order_by'] = ' ORDER BY hit DESC, id DESC';
                            $query = '
SELECT DISTINCT(id)
  FROM ' . IMAGES_TABLE . '
    INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' AS ic ON id = ic.image_id
  WHERE hit > 0