$tpl_var = array_merge($category, array('ID' => $category['id'], 'representative' => $representative_infos, 'TN_ALT' => strip_tags($category['name']), 'URL' => make_index_url(array('category' => $category)), 'CAPTION_NB_IMAGES' => get_display_images_count($category['nb_images'], $category['count_images'], $category['count_categories'], true, '<br>'), 'DESCRIPTION' => trigger_change('render_category_literal_description', trigger_change('render_category_description', @$category['comment'], 'subcatify_category_description')), 'NAME' => $name)); if ($conf['index_new_icon']) { $tpl_var['icon_ts'] = get_icon($category['max_date_last'], $category['is_child_date_last']); } if ($conf['display_fromto']) { if (isset($dates_of_category[$category['id']])) { $from = $dates_of_category[$category['id']]['from']; $to = $dates_of_category[$category['id']]['to']; if (!empty($from)) { $tpl_var['INFO_DATES'] = format_fromto($from, $to); } } } $tpl_thumbnails_var[] = $tpl_var; } // pagination $page['total_categories'] = count($tpl_thumbnails_var); $tpl_thumbnails_var_selection = array_slice($tpl_thumbnails_var, $page['startcat'], $conf['nb_categories_page']); $derivative_params = trigger_change('get_index_album_derivative_params', ImageStdParams::get_by_type(IMG_THUMB)); $tpl_thumbnails_var_selection = trigger_change('loc_end_index_category_thumbnails', $tpl_thumbnails_var_selection); $template->assign(array('maxRequests' => $conf['max_requests'], 'category_thumbnails' => $tpl_thumbnails_var_selection, 'derivative_params' => $derivative_params)); $template->assign_var_from_handle('CATEGORIES', 'index_category_thumbnails'); // navigation bar $page['cats_navigation_bar'] = array(); if ($page['total_categories'] > $conf['nb_categories_page']) { $page['cats_navigation_bar'] = create_navigation_bar(duplicate_index_url(array(), array('startcat')), $page['total_categories'], $page['startcat'], $conf['nb_categories_page'], true, 'startcat'); } $template->assign('cats_navbar', $page['cats_navigation_bar']); } pwg_debug('end include/category_cats.inc.php');
/** * Initialize _$page_ and _$template_ vars for calendar view. */ function initialize_calendar() { global $page, $conf, $user, $template, $persistent_cache, $filter; //------------------ initialize the condition on items to take into account --- $inner_sql = ' FROM ' . IMAGES_TABLE; if ($page['section'] == 'categories') { // we will regenerate the items by including subcats elements $page['items'] = array(); $inner_sql .= ' INNER JOIN ' . IMAGE_CATEGORY_TABLE . ' ON id = image_id'; if (isset($page['category'])) { $sub_ids = array_diff(get_subcat_ids(array($page['category']['id'])), explode(',', $user['forbidden_categories'])); if (empty($sub_ids)) { return; // nothing to do } $inner_sql .= ' WHERE category_id IN (' . implode(',', $sub_ids) . ')'; $inner_sql .= ' ' . get_sql_condition_FandF(array('visible_images' => 'id'), 'AND', false); } else { $inner_sql .= ' ' . get_sql_condition_FandF(array('forbidden_categories' => 'category_id', 'visible_categories' => 'category_id', 'visible_images' => 'id'), 'WHERE', true); } } else { if (empty($page['items'])) { return; // nothing to do } $inner_sql .= ' WHERE id IN (' . implode(',', $page['items']) . ')'; } //-------------------------------------- initialize the calendar parameters --- pwg_debug('start initialize_calendar'); $fields = array('created' => array('label' => l10n('Creation date')), 'posted' => array('label' => l10n('Post date'))); $styles = array('monthly' => array('include' => 'calendar_monthly.class.php', 'view_calendar' => true, 'classname' => 'CalendarMonthly'), 'weekly' => array('include' => 'calendar_weekly.class.php', 'view_calendar' => false, 'classname' => 'CalendarWeekly')); $views = array(CAL_VIEW_LIST, CAL_VIEW_CALENDAR); // Retrieve calendar field isset($fields[$page['chronology_field']]) or fatal_error('bad chronology field'); // Retrieve style if (!isset($styles[$page['chronology_style']])) { $page['chronology_style'] = 'monthly'; } $cal_style = $page['chronology_style']; $classname = $styles[$cal_style]['classname']; include PHPWG_ROOT_PATH . 'include/' . $styles[$cal_style]['include']; $calendar = new $classname(); // Retrieve view if (!isset($page['chronology_view']) or !in_array($page['chronology_view'], $views)) { $page['chronology_view'] = CAL_VIEW_LIST; } if (CAL_VIEW_CALENDAR == $page['chronology_view'] and !$styles[$cal_style]['view_calendar']) { $page['chronology_view'] = CAL_VIEW_LIST; } // perform a sanity check on $requested if (!isset($page['chronology_date'])) { $page['chronology_date'] = array(); } while (count($page['chronology_date']) > 3) { array_pop($page['chronology_date']); } $any_count = 0; for ($i = 0; $i < count($page['chronology_date']); $i++) { if ($page['chronology_date'][$i] == 'any') { if ($page['chronology_view'] == CAL_VIEW_CALENDAR) { // we dont allow any in calendar view while ($i < count($page['chronology_date'])) { array_pop($page['chronology_date']); } break; } $any_count++; } elseif ($page['chronology_date'][$i] == '') { while ($i < count($page['chronology_date'])) { array_pop($page['chronology_date']); } } else { $page['chronology_date'][$i] = (int) $page['chronology_date'][$i]; } } if ($any_count == 3) { array_pop($page['chronology_date']); } $calendar->initialize($inner_sql); //echo ('<pre>'. var_export($calendar, true) . '</pre>'); $must_show_list = true; // true until calendar generates its own display if (script_basename() != 'picture') { if ($calendar->generate_category_content()) { $page['items'] = array(); $must_show_list = false; } $page['comment'] = ''; $template->assign('FILE_CHRONOLOGY_VIEW', 'month_calendar.tpl'); foreach ($styles as $style => $style_data) { foreach ($views as $view) { if ($style_data['view_calendar'] or $view != CAL_VIEW_CALENDAR) { $selected = false; if ($style != $cal_style) { $chronology_date = array(); if (isset($page['chronology_date'][0])) { $chronology_date[] = $page['chronology_date'][0]; } } else { $chronology_date = $page['chronology_date']; } $url = duplicate_index_url(array('chronology_style' => $style, 'chronology_view' => $view, 'chronology_date' => $chronology_date)); if ($style == $cal_style and $view == $page['chronology_view']) { $selected = true; } $template->append('chronology_views', array('VALUE' => $url, 'CONTENT' => l10n('chronology_' . $style . '_' . $view), 'SELECTED' => $selected)); } } } $url = duplicate_index_url(array(), array('start', 'chronology_date')); $calendar_title = '<a href="' . $url . '">' . $fields[$page['chronology_field']]['label'] . '</a>'; $calendar_title .= $calendar->get_display_name(); $template->assign('chronology', array('TITLE' => $calendar_title)); } // end category calling if ($must_show_list) { if (isset($page['super_order_by'])) { $order_by = $conf['order_by']; } else { if (count($page['chronology_date']) == 0 or in_array('any', $page['chronology_date'])) { // selected period is very big so we show newest first $order = ' DESC, '; } else { // selected period is small (month,week) so we show oldest first $order = ' ASC, '; } $order_by = str_replace('ORDER BY ', 'ORDER BY ' . $calendar->date_field . $order, $conf['order_by']); } if ('categories' == $page['section'] && !isset($page['category']) && (count($page['chronology_date']) == 0 or $page['chronology_date'][0] == 'any' && count($page['chronology_date']) == 1)) { $cache_key = $persistent_cache->make_key($user['id'] . $user['cache_update_time'] . $calendar->date_field . $order_by); } if (!isset($cache_key) || !$persistent_cache->get($cache_key, $page['items'])) { $query = 'SELECT DISTINCT id ' . $calendar->inner_sql . ' ' . $calendar->get_date_where() . ' ' . $order_by; $page['items'] = array_from_query($query, 'id'); if (isset($cache_key)) { $persistent_cache->set($cache_key, $page['items']); } } } pwg_debug('end initialize_calendar'); }
} $name = render_element_name($row); $desc = render_element_description($row, 'main_page_element_description'); $tpl_var = array_merge($row, array('TN_ALT' => htmlspecialchars(strip_tags($name)), 'TN_TITLE' => get_thumbnail_title($row, $name, $desc), 'URL' => $url, 'DESCRIPTION' => $desc, 'src_image' => new SrcImage($row))); if ($conf['index_new_icon']) { $tpl_var['icon_ts'] = get_icon($row['date_available']); } if ($user['show_nb_hits']) { $tpl_var['NB_HITS'] = $row['hit']; } switch ($page['section']) { case 'best_rated': $name = '(' . $row['rating_score'] . ') ' . $name; break; case 'most_visited': if (!$user['show_nb_hits']) { $name = '(' . $row['hit'] . ') ' . $name; } break; } $tpl_var['NAME'] = $name; $tpl_thumbnails_var[] = $tpl_var; } $template->assign(array('derivative_params' => trigger_change('get_index_derivative_params', ImageStdParams::get_by_type(pwg_get_session_var('index_deriv', IMG_THUMB))), 'maxRequests' => $conf['max_requests'], 'SHOW_THUMBNAIL_CAPTION' => $conf['show_thumbnail_caption'])); $tpl_thumbnails_var = trigger_change('loc_end_index_thumbnails', $tpl_thumbnails_var, $pictures); $template->assign('thumbnails', $tpl_thumbnails_var); $template->assign_var_from_handle('THUMBNAILS', 'index_thumbnails'); unset($pictures, $selection, $tpl_thumbnails_var); $template->clear_assign('thumbnails'); pwg_debug('end include/category_default.inc.php');