Changeset 1648


Ignore:
Timestamp:
Dec 10, 2006, 11:48:32 PM (17 years ago)
Author:
rub
Message:

Feature Issue ID 0000601: Filter all public pages with only recent elements

It's a draft of the feature witch allows to show only recent elements.
Development are not finished.
Queries and special pages (best rates, tags, etc.) are not modified.
Only main php files about images and categories are ok.

Before to continue, I prefer to determinate a solution between modify cache implementation or hide counters.

Go to http://forum.phpwebgallery.net/viewtopic.php?pid=50015#p50015

Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/category_cats.inc.php

    r1643 r1648  
    5555  ON id = cat_id and user_id = '.$user['id'].'
    5656  WHERE id_uppercat '.
    57   (!isset($page['category']) ? 'is NULL' : '= '.$page['category']).'
     57  (!isset($page['category']) ? 'is NULL' : '= '.$page['category']);
     58  if ($page['filter_mode'])
     59  {
     60    $query.= '
     61    AND max_date_last > SUBDATE(
     62      CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
     63  }
     64  $query.= '
    5865  ORDER BY rank
    5966;';
     
    7885SELECT image_id
    7986  FROM '.CATEGORIES_TABLE.' AS c INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic
    80     ON ic.category_id = c.id
     87    ON ic.category_id = c.id';
     88    if ($page['filter_mode'])
     89    {
     90      $query.= '
     91    INNER JOIN '.IMAGES_TABLE.' AS i on ic.image_id = i.id ';
     92    }
     93    $query.= '
    8194  WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'
    82     AND c.id NOT IN ('.$user['forbidden_categories'].')
     95    AND c.id NOT IN ('.$user['forbidden_categories'].')';
     96    if ($page['filter_mode'])
     97    {
     98      $query.= '
     99    AND i.date_available  > SUBDATE(
     100      CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
     101    }
     102    $query.= '
    83103  ORDER BY RAND()
    84104  LIMIT 0,1
     
    94114    $query = '
    95115SELECT representative_picture_id
    96   FROM '.CATEGORIES_TABLE.'
     116  FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
     117  ON id = cat_id and user_id = '.$user['id'].'
    97118  WHERE uppercats REGEXP \'(^|,)'.$row['id'].'(,|$)\'
    98     AND id NOT IN ('.$user['forbidden_categories'].')
    99     AND representative_picture_id IS NOT NULL
     119    AND representative_picture_id IS NOT NULL';
     120    if ($page['filter_mode'])
     121    {
     122      $query.= '
     123      AND max_date_last > SUBDATE(
     124        CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
     125    }
     126    $query.= '
    100127  ORDER BY RAND()
    101128  LIMIT 0,1
  • trunk/include/category_default.inc.php

    r1596 r1648  
    4747SELECT *
    4848  FROM '.IMAGES_TABLE.'
    49   WHERE id IN ('.implode(',', $selection).')
    50 ;';
     49  WHERE id IN ('.implode(',', $selection).')';
     50  if ($page['filter_mode'])
     51  {
     52    $query.= '
     53    AND date_available  > SUBDATE(
     54      CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
     55  }
     56  $query.= ';';
    5157  $result = pwg_query($query);
    5258  while ($row = mysql_fetch_assoc($result))
  • trunk/include/functions_category.inc.php

    r1641 r1648  
    6868  FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
    6969  ON id = cat_id and user_id = '.$user['id'];
    70   if (!$user['expand'])
     70  if ($page['filter_mode'])
    7171  {
    7272    $query.= '
    73     WHERE (id_uppercat is NULL';
    74     if (isset($page['category']))
    75     {
    76       $query.= ' OR id_uppercat IN ('.$page['uppercats'].')';
    77     }
    78     $query.= ')';
     73where max_date_last > SUBDATE(
     74  CURRENT_DATE,INTERVAL '.$user['recent_period'].' DAY)';
     75  }
     76  else
     77  {
     78    // Always expand when filter_mode is activated
     79    if (!$user['expand'])
     80    {
     81      $query.= '
     82      WHERE (id_uppercat is NULL';
     83      if (isset($page['category']))
     84      {
     85        $query.= ' OR id_uppercat IN ('.$page['uppercats'].')';
     86      }
     87      $query.= ')';
     88    }
    7989  }
    8090  $query.= '
  • trunk/include/menubar.inc.php

    r1636 r1648  
    168168    'NAME' => $lang['random_cat']
    169169    ));
    170 // recent pics
    171 $template->assign_block_vars(
    172   'special_cat',
    173   array(
    174     'URL' => make_index_url(array('section' => 'recent_pics')),
    175     'TITLE' => $lang['recent_pics_cat_hint'],
    176     'NAME' => $lang['recent_pics_cat']
    177     ));
    178 // recent cats
    179 $template->assign_block_vars(
    180   'special_cat',
    181   array(
    182     'URL' => make_index_url(array('section' => 'recent_cats')),
    183     'TITLE' => $lang['recent_cats_cat_hint'],
    184     'NAME' => $lang['recent_cats_cat']
    185     ));
     170
     171// Not recent menu when filter is activated
     172if (!$page['filter_mode'])
     173{
     174  // recent pics
     175  $template->assign_block_vars(
     176    'special_cat',
     177    array(
     178      'URL' => make_index_url(array('section' => 'recent_pics')),
     179      'TITLE' => $lang['recent_pics_cat_hint'],
     180      'NAME' => $lang['recent_pics_cat']
     181      ));
     182  // recent cats
     183  $template->assign_block_vars(
     184    'special_cat',
     185    array(
     186      'URL' => make_index_url(array('section' => 'recent_cats')),
     187      'TITLE' => $lang['recent_cats_cat_hint'],
     188      'NAME' => $lang['recent_cats_cat']
     189      ));
     190}
    186191
    187192// calendar
  • trunk/index.php

    r1627 r1648  
    105105{
    106106  $template_title.= ' ['.$page['cat_nb_images'].']';
     107}
     108
     109if (isset($_GET['filter_mode']))
     110{
     111  $page['filter_mode'] = ($_GET['filter_mode'] == 'start');
     112  pwg_set_session_var('filter_mode', $page['filter_mode']);
     113}
     114else
     115{
     116  $page['filter_mode'] = pwg_get_session_var('filter_mode', false);
     117}
     118
     119if ($page['filter_mode'])
     120{
     121  $template->assign_block_vars(
     122    'stop_filter_mode',
     123    array(
     124      'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_mode' => 'stop'))
     125      )
     126    );
     127}
     128else
     129{
     130  $template->assign_block_vars(
     131    'start_filter_mode',
     132    array(
     133      'URL' => add_url_params(duplicate_index_url(array(), array('start')), array('filter_mode' => 'start'))
     134      )
     135    );
    107136}
    108137
  • trunk/language/en_UK.iso-8859-1/common.lang.php

    r1637 r1648  
    491491$lang['maxwidth'] = 'Maximum width of the pictures';
    492492$lang['maxwidth_error'] = 'Maximum width must be a number superior to 50';
     493$lang['start_filter_mode_hint'] = 'displays only recent elements';
     494$lang['stop_filter_mode_hint'] = 'return to display all elements';
    493495$lang['mode_created_hint'] = 'displays a calendar by creation date';
    494496$lang['mode_normal_hint'] = 'return to normal view mode';
  • trunk/language/fr_FR.iso-8859-1/common.lang.php

    r1637 r1648  
    492492$lang['maxwidth_error'] = 'La largeur des images doit être supérieure à 50';
    493493$lang['mode_created_hint'] = 'afficher un calendrier par date de création';
    494 $lang['mode_normal_hint'] = 'retourne à la vue normale';
     494$lang['start_filter_mode_hint'] = 'afficher que les éléments récents';
     495$lang['stop_filter_mode_hint'] = 'retourner à l\'affichage de tous les éléments';
     496$lang['mode_normal_hint'] = 'retourner à la vue normale';
    495497$lang['mode_posted_hint'] = 'afficher un calendrier par date d\'ajout';
    496498$lang['month'][10] = 'Octobre';
  • trunk/plugins/event_tracer

    • Property svn:ignore set to
      *.dat
  • trunk/template/yoga/index.tpl

    r1537 r1648  
    2727      <li><a href="{search_rules.URL}" style="border:none;" onclick="popuphelp(this.href); return false;" title="{lang:Search rules}"><img src="{pwg_root}{themeconf:icon_dir}/search_rules.png" class="button" alt="(?)"></a></li>
    2828      <!-- END search_rules -->
     29
     30      <!-- BEGIN start_filter_mode -->
     31      <li><a href="{start_filter_mode.URL}" title="{lang:start_filter_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/start_filter_mode.png" class="button" alt="{lang:start_filter_mode_hint}"></a></li>
     32      <!-- END start_filter_mode -->
     33      <!-- BEGIN stop_filter_mode -->
     34      <li><a href="{stop_filter_mode.URL}" title="{lang:stop_filter_mode_hint}"><img src="{pwg_root}{themeconf:icon_dir}/stop_filter_mode.png" class="button" alt="{lang:stop_filter_mode_hint}"></a></li>
     35      <!-- END stop_filter_mode -->
    2936
    3037      <!-- BEGIN mode_normal -->
Note: See TracChangeset for help on using the changeset viewer.