Changeset 32184 for extensions


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

[photos_from_one_year_ago]

File:
1 edited

Legend:

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

    r32155 r32184  
    6262  global $tokens, $page, $conf,$template;
    6363  $template->assign('PFOAYALINK',make_index_url(array('section' => 'photos_from_one_year_ago')));
     64 
     65  $datepfoya = (isset($conf['pfoya_dateb'])) ? $conf['pfoya_dateb'] : "date_available";
     66  $daydate= (isset($conf['pfoya_date'])) ? $conf['pfoya_date'] : date("Y-m-d", strtotime('-1 year'));
     67 
    6468  if (!in_array('photos_from_one_year_ago', $tokens))
    6569  {
     
    7478
    7579  $query = '
    76 SELECT DISTINCT image_id
    77     FROM ' . IMAGE_CATEGORY_TABLE . '
     80SELECT DISTINCT(i.id)
     81  FROM '.IMAGES_TABLE.' AS i
     82    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id = ic.image_id
     83    INNER JOIN '.CATEGORIES_TABLE.' AS c ON ic.category_id = c.id
    7884    WHERE ' . 
    7985      get_sql_condition_FandF(
     
    8490          ),
    8591        '', true
    86         )
    87     . '
    88 ;';
    89 
    90   $img = query2array($query, null, 'image_id');
    91 
    92   if (empty($img))
    93   {
    94     $page['items'] = array();
    95   }
    96   else
    97   {
    98         $datepfoya = (isset($conf['pfoya_dateb'])) ? $conf['pfoya_dateb'] : "date_available";
    99         $daydate= (isset($conf['pfoya_date'])) ? $conf['pfoya_date'] : date("Y-m-d", strtotime('-1 year'));
    100     $query = 'SELECT id,date_available FROM ' . IMAGES_TABLE . ' AS img WHERE img.id IN (' . implode(',', $img) . ') and DATE('.$datepfoya.') ="'.$daydate.'"';
     92        );
     93  $query .= '
     94       and DATE ('.$datepfoya.') ="'.$daydate.'";';
     95 
    10196    $page['items'] = query2array($query, null, 'id');
    102    
    103   add_event_handler('loc_end_index_thumbnails', 'add_nb_pfoya');
    104 }
    105 
    106 function add_nb_pfoya($tpl_thumbnails_var){
    107   global $template, $user, $selection;
    108 
    109   // unsed sort order
    110   $template->clear_assign('image_orders');
    111 
    112     $query = 'SELECT id, date_available FROM '.IMAGES_TABLE.' WHERE id IN ('.implode(',', $selection).');';
    113     $nb_download = query2array($query, 'id', 'date_available');
    114    
    115     foreach ($tpl_thumbnails_var as &$row)
    116     {
    117       $row['date_available'] = $nb_download[$row['id']];
    118     }
    119     unset($row);
    120  
    121 
    122   return $tpl_thumbnails_var;
    123 }
    12497 
    12598}
Note: See TracChangeset for help on using the changeset viewer.