Changeset 1820 for trunk/include


Ignore:
Timestamp:
Feb 15, 2007, 1:10:41 AM (18 years ago)
Author:
rvelices
Message:
  • feature 642: display both subcategory thumbnails and element thumbnails (if a

category has both) in the index page

flat category view

  • web service fixes for categories.getList
Location:
trunk/include
Files:
4 edited

Legend:

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

    r1722 r1820  
    182182  if ($conf['subcatify'])
    183183  {
    184     $template->set_filenames(
    185       array(
    186         'mainpage_categories' => 'mainpage_categories.tpl',
    187         )
    188       );
     184    $template->set_filename('mainpage_categories', 'mainpage_categories.tpl');
    189185
    190186    foreach ($categories as $category)
     
    232228  else
    233229  {
    234     $template->set_filenames( array( 'thumbnails' => 'thumbnails.tpl',));
     230    $template->set_filename( 'thumbnails', 'thumbnails.tpl');
    235231    // first line
    236232    $template->assign_block_vars('thumbnails.line', array());
     
    296292    }
    297293
    298     $template->assign_var_from_handle('THUMBNAILS', 'thumbnails');
     294    $template->assign_var_from_handle('CATEGORIES', 'thumbnails');
     295    unset( $template->_tpldata['thumbnails.'] );//maybe write a func for that
    299296  }
    300297}
  • trunk/include/functions_calendar.inc.php

    r1759 r1820  
    198198  if (script_basename() != 'picture') // basename without file extention
    199199  {
    200     $template->assign_block_vars('calendar', array());
    201 
    202200    if ($calendar->generate_category_content())
    203201    {
    204       unset(
    205         $page['thumbnails_include'],
    206         $page['items']
    207         );
    208 
     202      $page['items'] = array();
    209203      $must_show_list = false;
    210204    }
    211205
    212     $template->assign_block_vars( 'calendar.views', array() );
    213206    foreach ($styles as $style => $style_data)
    214207    {
     
    261254        .$fields[$page['chronology_field']]['label'].'</a>';
    262255    $calendar_title.= $calendar->get_display_name();
    263     //this should be an assign_block_vars, but I need to assign 'calendar'
    264     //above and at that point I don't have the title yet.
    265     $template->_tpldata['calendar.'][0]['TITLE'] = $calendar_title;
     256    $template->merge_block_vars('calendar',
     257        array(
     258          'TITLE' => $calendar_title
     259        )
     260      );
    266261  } // end category calling
    267262
     
    294289  '.$order_by;
    295290    }
    296 
    297291    $page['items']              = array_from_query($query, 'id');
    298     $page['thumbnails_include'] = 'include/category_default.inc.php';
    299292  }
    300293  pwg_debug('end initialize_calendar');
  • trunk/include/section_init.inc.php

    r1814 r1820  
    3434 * - $page['items']: ordered list of items to display
    3535 *
    36  * - $page['cat_nb_images']: number of items in the section (should be equal
    37  * to count($page['items']))
    38  *
    39  * - $page['thumbnails_include']: include page managing thumbnails to
    40  * display
    4136 */
    4237
     
    5146//   'action'   => 'fill_caddie'
    5247//   );
     48
     49$page['items'] = array();
    5350
    5451// some ISPs set PATH_INFO to empty string or to SCRIPT_FILENAME while in the
     
    365362          'forbidden_categories' => 'category_id',
    366363          'visible_categories' => 'category_id',
    367           'visible_images' => 'image_id'
     364          'visible_images' => 'id'
    368365        ),
    369366      'AND'
     
    396393        'title'             =>
    397394          get_cat_display_name($result['name'], '', false),
    398         'thumbnails_include' =>
    399           (($result['nb_images'] > 0) or (isset($page['flat'])))
    400           ? 'include/category_default.inc.php'
    401           : 'include/category_cats.inc.php'
    402395        )
    403396      );
     
    406399  {
    407400    $page['title'] = $lang['no_category'];
    408     $page['thumbnails_include'] =
    409       (isset($page['flat']))
    410           ? 'include/category_default.inc.php'
    411           : 'include/category_cats.inc.php';
    412401  }
    413402
     
    427416
    428417    if (isset($page['flat']))
    429     {
    430       // flat recent categories mode
    431         $query = '
    432 SELECT
    433   DISTINCT(ic.image_id)
    434 FROM '.IMAGES_TABLE.' AS i
    435        INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id = ic.image_id
    436        INNER JOIN '.CATEGORIES_TABLE.' AS c ON ic.category_id = c.id
    437 WHERE
    438   '.(isset($page['category']) ? '
    439   uppercats REGEXP \'(^|,)'.$page['category'].'(,|$)\'' : '1=1' ).'
    440 '.$forbidden.'
    441 ;';
    442 
    443       $where_sql = array_from_query($query, 'image_id');
    444       if (!empty($where_sql))
     418    {// flat categories mode
     419      if ( isset($page['category']) )
    445420      {
    446         $where_sql = 'image_id in ('.implode(',', $where_sql).')';
     421        $subcat_ids = get_subcat_ids( array($page['category']) );
     422        $where_sql = 'category_id IN ('.implode(',',$subcat_ids).')';
    447423      }
     424      else
     425      {
     426        $where_sql = '1=1';
     427      }
    448428    }
    449429    else
    450     {
    451       // Normal mode
     430    {// Normal mode
    452431      $where_sql = 'category_id = '.$page['category'];
    453432    }
    454433
    455     if (!empty($where_sql))
    456     {
    457       // Main query
    458       $query = '
     434    // Main query
     435    $query = '
    459436SELECT DISTINCT(image_id)
    460437  FROM '.IMAGE_CATEGORY_TABLE.'
     
    466443;';
    467444
    468       $page['items'] = array_from_query($query, 'image_id');
    469     }
    470     else
    471     {
    472       $page['items'] = array();
    473     }
     445    $page['items'] = array_from_query($query, 'image_id');
    474446  } //otherwise the calendar will requery all subitems
    475447}
     
    514486        'title' => $title,
    515487        'items' => array_values($items),
    516         'thumbnails_include' => 'include/category_default.inc.php',
    517488        )
    518489      );
     
    547518      array(
    548519        'title' => $lang['search_result'],
    549         'thumbnails_include' => 'include/category_default.inc.php',
    550520        )
    551521      );
     
    579549        'title' => $lang['favorites'],
    580550        'items' => array_from_query($query, 'image_id'),
    581         'thumbnails_include' => 'include/category_default.inc.php',
    582551        )
    583552      );
     
    604573                  .$lang['recent_pics_cat'].'</a>',
    605574        'items' => array_from_query($query, 'id'),
    606         'thumbnails_include' => 'include/category_default.inc.php',
    607575        )
    608576      );
     
    617585      array(
    618586        'title' => $lang['recent_cats_cat'],
    619         'thumbnails_include' => 'include/category_cats.inc.php',
    620587        )
    621588      );
     
    644611                  .$conf['top_number'].' '.$lang['most_visited_cat'].'</a>',
    645612        'items' => array_from_query($query, 'id'),
    646         'thumbnails_include' => 'include/category_default.inc.php',
    647613        )
    648614      );
     
    671637                  .$conf['top_number'].' '.$lang['best_rated_cat'].'</a>',
    672638        'items' => array_from_query($query, 'id'),
    673         'thumbnails_include' => 'include/category_default.inc.php',
    674639        )
    675640      );
     
    695660                    .$lang['random_cat'].'</a>',
    696661        'items' => array_from_query($query, 'id'),
    697         'thumbnails_include' => 'include/category_default.inc.php',
    698662        )
    699663      );
     
    710674  initialize_calendar();
    711675}
    712 
    713 $page['cat_nb_images'] = isset($page['items']) ? count($page['items']) : 0;
    714676
    715677if (script_basename() == 'picture'
  • trunk/include/ws_functions.inc.php

    r1816 r1820  
    406406function ws_categories_getList($params, &$service)
    407407{
    408   global $user;
     408  global $user,$conf;
    409409
    410410  $where = array();
    411   $where[]= 'user_id='.$user['id'];
    412   if ($params['cat_id']>0)
     411
     412  if (!$params['recursive'])
     413  {
     414    if ($params['cat_id']>0)
     415      $where[] = '(id_uppercat='.(int)($params['cat_id']).'
     416    OR id='.(int)($params['cat_id']).')';
     417    else
     418      $where[] = 'id_uppercat IS NULL';
     419  }
     420  else if ($params['cat_id']>0)
    413421  {
    414422    $where[] = 'uppercats REGEXP \'(^|,)'.
     
    417425  }
    418426
    419   if (!$params['recursive'])
    420   {
    421     if ($params['cat_id']>0)
    422       $where[] = 'id_uppercat='.(int)($params['cat_id']);
    423     else
    424       $where[] = 'id_uppercat IS NULL';
    425   }
    426 
    427427  if ($params['public'])
    428428  {
    429429    $where[] = 'status = "public"';
    430430    $where[] = 'visible = "true"';
     431    $where[]= 'user_id='.$conf['guest_id'];
    431432  }
    432433  else
    433434  {
    434435    $where[] = 'id NOT IN ('.$user['forbidden_categories'].')';
     436    $where[]= 'user_id='.$user['id'];
    435437  }
    436438
Note: See TracChangeset for help on using the changeset viewer.