Changeset 32183


Ignore:
Timestamp:
May 6, 2020, 11:10:47 PM (4 years ago)
Author:
ddtddt
Message:

[photos_from_one_year_ago]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/photos_from_one_year_ago/blockhome/main.inc.php

    r32155 r32183  
    77$page_save = $page;
    88$tpl_save = $template->get_template_vars('THUMBNAILS');
    9 $pfoyanip = (isset($conf['pfoya_nip'])) ? $conf['pfoya_nip'] : 6;
     9$pfoyanip = (isset($conf['pfoya_nip'])) ? $conf['pfoya_nip'] : 5;
     10$datepfoya = (isset($conf['pfoya_dateb'])) ? $conf['pfoya_dateb'] : "date_available";
     11$daydate= (isset($conf['pfoya_date'])) ? $conf['pfoya_date'] : date("Y-m-d", strtotime('-1 year'));
    1012
    1113if (script_basename() == 'picture'
     
    1820
    1921 $query = '
    20 SELECT DISTINCT image_id
    21     FROM ' . IMAGE_CATEGORY_TABLE . ' AS ic ';
    22 if (isset($page['category'])){ 
    23  $query .= 'INNER JOIN '.CATEGORIES_TABLE.' AS c ON ic.category_id = c.id ';
    24 }
     22SELECT DISTINCT(i.id)
     23  FROM '.IMAGES_TABLE.' AS i
     24    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id = ic.image_id
     25    INNER JOIN '.CATEGORIES_TABLE.' AS c ON ic.category_id = c.id ';
     26
    2527 $query .= 'WHERE ' . 
    2628      get_sql_condition_FandF(
     
    3234        '', true
    3335        );
     36  $query .= '
     37       and DATE ('.$datepfoya.') ="'.$daydate.'"';
     38
    3439if (isset($page['category'])){
    3540  $query .= '
     
    4146  ;';
    4247
    43 
    44 
    45   $img = query2array($query, null, 'image_id');
    46 
    47   if (empty($img))
    48   {
    49     $page['items'] = array();
    50   }
    51   else
    52   {
    53         $datepfoya = (isset($conf['pfoya_dateb'])) ? $conf['pfoya_dateb'] : "date_available";
    54         $daydate= (isset($conf['pfoya_date'])) ? $conf['pfoya_date'] : date("Y-m-d", strtotime('-1 year'));
    55     $query = 'SELECT id,date_available FROM ' . IMAGES_TABLE . ' AS img WHERE img.id IN (' . implode(',', $img) . ') and DATE('.$datepfoya.') ="'.$daydate.'"';
    56     $page['items'] = query2array($query, null, 'id');
    5748    $page['items'] = array_from_query($query, 'id');
    5849        $page['start'] = 0;
     50        $page['section'] = ' Photos_from_one_year_ago';
    5951        $page['nb_image_page']=$pfoyanip;
    60   }
     52
    6153
    6254
Note: See TracChangeset for help on using the changeset viewer.