aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/category_cats.inc.php11
-rw-r--r--include/functions_calendar.inc.php19
-rw-r--r--include/section_init.inc.php68
-rw-r--r--include/ws_functions.inc.php20
-rw-r--r--index.php23
-rw-r--r--picture.php2
-rw-r--r--template/yoga/index.tpl2
7 files changed, 53 insertions, 92 deletions
diff --git a/include/category_cats.inc.php b/include/category_cats.inc.php
index 8f8f3ba50..cd54b760e 100644
--- a/include/category_cats.inc.php
+++ b/include/category_cats.inc.php
@@ -181,11 +181,7 @@ if (count($categories) > 0)
if ($conf['subcatify'])
{
- $template->set_filenames(
- array(
- 'mainpage_categories' => 'mainpage_categories.tpl',
- )
- );
+ $template->set_filename('mainpage_categories', 'mainpage_categories.tpl');
foreach ($categories as $category)
{
@@ -231,7 +227,7 @@ if (count($categories) > 0)
}
else
{
- $template->set_filenames( array( 'thumbnails' => 'thumbnails.tpl',));
+ $template->set_filename( 'thumbnails', 'thumbnails.tpl');
// first line
$template->assign_block_vars('thumbnails.line', array());
// current row displayed
@@ -295,7 +291,8 @@ if (count($categories) > 0)
$conf['level_separator']=$old_level_separator;
}
- $template->assign_var_from_handle('THUMBNAILS', 'thumbnails');
+ $template->assign_var_from_handle('CATEGORIES', 'thumbnails');
+ unset( $template->_tpldata['thumbnails.'] );//maybe write a func for that
}
}
?>
diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php
index 402002733..a29536c71 100644
--- a/include/functions_calendar.inc.php
+++ b/include/functions_calendar.inc.php
@@ -197,19 +197,12 @@ WHERE id IN (' . implode(',',$page['items']) .')';
$must_show_list = true; // true until calendar generates its own display
if (script_basename() != 'picture') // basename without file extention
{
- $template->assign_block_vars('calendar', array());
-
if ($calendar->generate_category_content())
{
- unset(
- $page['thumbnails_include'],
- $page['items']
- );
-
+ $page['items'] = array();
$must_show_list = false;
}
- $template->assign_block_vars( 'calendar.views', array() );
foreach ($styles as $style => $style_data)
{
foreach ($views as $view)
@@ -260,9 +253,11 @@ WHERE id IN (' . implode(',',$page['items']) .')';
$calendar_title = '<a href="'.$url.'">'
.$fields[$page['chronology_field']]['label'].'</a>';
$calendar_title.= $calendar->get_display_name();
- //this should be an assign_block_vars, but I need to assign 'calendar'
- //above and at that point I don't have the title yet.
- $template->_tpldata['calendar.'][0]['TITLE'] = $calendar_title;
+ $template->merge_block_vars('calendar',
+ array(
+ 'TITLE' => $calendar_title
+ )
+ );
} // end category calling
if ($must_show_list)
@@ -293,9 +288,7 @@ WHERE id IN (' . implode(',',$page['items']) .')';
$query .= '
'.$order_by;
}
-
$page['items'] = array_from_query($query, 'id');
- $page['thumbnails_include'] = 'include/category_default.inc.php';
}
pwg_debug('end initialize_calendar');
}
diff --git a/include/section_init.inc.php b/include/section_init.inc.php
index 0f44012de..21396955d 100644
--- a/include/section_init.inc.php
+++ b/include/section_init.inc.php
@@ -33,11 +33,6 @@
*
* - $page['items']: ordered list of items to display
*
- * - $page['cat_nb_images']: number of items in the section (should be equal
- * to count($page['items']))
- *
- * - $page['thumbnails_include']: include page managing thumbnails to
- * display
*/
// "index.php?/category/12-foo/start-24&action=fill_caddie" or
@@ -51,6 +46,8 @@
// 'action' => 'fill_caddie'
// );
+$page['items'] = array();
+
// some ISPs set PATH_INFO to empty string or to SCRIPT_FILENAME while in the
// default apache implementation it is not set
if ( $conf['question_mark_in_urls']==false and
@@ -364,7 +361,7 @@ $forbidden = get_sql_condition_FandF(
(
'forbidden_categories' => 'category_id',
'visible_categories' => 'category_id',
- 'visible_images' => 'image_id'
+ 'visible_images' => 'id'
),
'AND'
);
@@ -395,20 +392,12 @@ if ('categories' == $page['section'])
'uppercats' => $result['uppercats'],
'title' =>
get_cat_display_name($result['name'], '', false),
- 'thumbnails_include' =>
- (($result['nb_images'] > 0) or (isset($page['flat'])))
- ? 'include/category_default.inc.php'
- : 'include/category_cats.inc.php'
)
);
}
else
{
$page['title'] = $lang['no_category'];
- $page['thumbnails_include'] =
- (isset($page['flat']))
- ? 'include/category_default.inc.php'
- : 'include/category_cats.inc.php';
}
if
@@ -426,36 +415,24 @@ if ('categories' == $page['section'])
}
if (isset($page['flat']))
- {
- // flat recent categories mode
- $query = '
-SELECT
- DISTINCT(ic.image_id)
-FROM '.IMAGES_TABLE.' AS i
- INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON i.id = ic.image_id
- INNER JOIN '.CATEGORIES_TABLE.' AS c ON ic.category_id = c.id
-WHERE
- '.(isset($page['category']) ? '
- uppercats REGEXP \'(^|,)'.$page['category'].'(,|$)\'' : '1=1' ).'
-'.$forbidden.'
-;';
-
- $where_sql = array_from_query($query, 'image_id');
- if (!empty($where_sql))
+ {// flat categories mode
+ if ( isset($page['category']) )
+ {
+ $subcat_ids = get_subcat_ids( array($page['category']) );
+ $where_sql = 'category_id IN ('.implode(',',$subcat_ids).')';
+ }
+ else
{
- $where_sql = 'image_id in ('.implode(',', $where_sql).')';
+ $where_sql = '1=1';
}
}
else
- {
- // Normal mode
+ {// Normal mode
$where_sql = 'category_id = '.$page['category'];
}
- if (!empty($where_sql))
- {
- // Main query
- $query = '
+ // Main query
+ $query = '
SELECT DISTINCT(image_id)
FROM '.IMAGE_CATEGORY_TABLE.'
INNER JOIN '.IMAGES_TABLE.' ON id = image_id
@@ -465,12 +442,7 @@ SELECT DISTINCT(image_id)
'.$conf['order_by'].'
;';
- $page['items'] = array_from_query($query, 'image_id');
- }
- else
- {
- $page['items'] = array();
- }
+ $page['items'] = array_from_query($query, 'image_id');
} //otherwise the calendar will requery all subitems
}
// special sections
@@ -513,7 +485,6 @@ SELECT image_id
array(
'title' => $title,
'items' => array_values($items),
- 'thumbnails_include' => 'include/category_default.inc.php',
)
);
}
@@ -546,7 +517,6 @@ SELECT DISTINCT(id)
$page,
array(
'title' => $lang['search_result'],
- 'thumbnails_include' => 'include/category_default.inc.php',
)
);
}
@@ -578,7 +548,6 @@ SELECT image_id
array(
'title' => $lang['favorites'],
'items' => array_from_query($query, 'image_id'),
- 'thumbnails_include' => 'include/category_default.inc.php',
)
);
}
@@ -603,7 +572,6 @@ SELECT DISTINCT(id)
'title' => '<a href="'.duplicate_index_url().'">'
.$lang['recent_pics_cat'].'</a>',
'items' => array_from_query($query, 'id'),
- 'thumbnails_include' => 'include/category_default.inc.php',
)
);
}
@@ -616,7 +584,6 @@ SELECT DISTINCT(id)
$page,
array(
'title' => $lang['recent_cats_cat'],
- 'thumbnails_include' => 'include/category_cats.inc.php',
)
);
}
@@ -643,7 +610,6 @@ SELECT DISTINCT(id)
'title' => '<a href="'.duplicate_index_url().'">'
.$conf['top_number'].' '.$lang['most_visited_cat'].'</a>',
'items' => array_from_query($query, 'id'),
- 'thumbnails_include' => 'include/category_default.inc.php',
)
);
}
@@ -670,7 +636,6 @@ SELECT DISTINCT(id)
'title' => '<a href="'.duplicate_index_url().'">'
.$conf['top_number'].' '.$lang['best_rated_cat'].'</a>',
'items' => array_from_query($query, 'id'),
- 'thumbnails_include' => 'include/category_default.inc.php',
)
);
}
@@ -694,7 +659,6 @@ SELECT DISTINCT(id)
'title' => '<a href="'.duplicate_index_url().'">'
.$lang['random_cat'].'</a>',
'items' => array_from_query($query, 'id'),
- 'thumbnails_include' => 'include/category_default.inc.php',
)
);
}
@@ -710,8 +674,6 @@ if (isset($page['chronology_field']))
initialize_calendar();
}
-$page['cat_nb_images'] = isset($page['items']) ? count($page['items']) : 0;
-
if (script_basename() == 'picture'
and !isset($page['image_id']) )
{
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index dca9740d1..1c71a6900 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -405,33 +405,35 @@ LIMIT '.$params['per_page']*$params['page'].','.$params['per_page'];
*/
function ws_categories_getList($params, &$service)
{
- global $user;
+ global $user,$conf;
$where = array();
- $where[]= 'user_id='.$user['id'];
- if ($params['cat_id']>0)
- {
- $where[] = 'uppercats REGEXP \'(^|,)'.
- (int)($params['cat_id'])
- .'(,|$)\'';
- }
if (!$params['recursive'])
{
if ($params['cat_id']>0)
- $where[] = 'id_uppercat='.(int)($params['cat_id']);
+ $where[] = '(id_uppercat='.(int)($params['cat_id']).'
+ OR id='.(int)($params['cat_id']).')';
else
$where[] = 'id_uppercat IS NULL';
}
+ else if ($params['cat_id']>0)
+ {
+ $where[] = 'uppercats REGEXP \'(^|,)'.
+ (int)($params['cat_id'])
+ .'(,|$)\'';
+ }
if ($params['public'])
{
$where[] = 'status = "public"';
$where[] = 'visible = "true"';
+ $where[]= 'user_id='.$conf['guest_id'];
}
else
{
$where[] = 'id NOT IN ('.$user['forbidden_categories'].')';
+ $where[]= 'user_id='.$user['id'];
}
$query = '
diff --git a/index.php b/index.php
index 24dbc20e3..e138e4681 100644
--- a/index.php
+++ b/index.php
@@ -68,12 +68,11 @@ if (isset($page['category']))
check_restrictions($page['category']);
}
-if (isset($page['cat_nb_images'])
- and $page['cat_nb_images'] > $user['nb_image_page'])
+if ( count($page['items']) > $user['nb_image_page'])
{
$page['navigation_bar'] = create_navigation_bar(
duplicate_index_url(array(), array('start')),
- $page['cat_nb_images'],
+ count($page['items']),
$page['start'],
$user['nb_image_page'],
true
@@ -101,9 +100,9 @@ $page['body_id'] = 'theCategoryPage';
$template->set_filenames( array('index'=>'index.tpl') );
//-------------------------------------------------------------- category title
$template_title = $page['title'];
-if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0)
+if ( count($page['items']) > 0)
{
- $template_title.= ' ['.$page['cat_nb_images'].']';
+ $template_title.= ' ['.count($page['items']).']';
}
if (isset($page['flat']) or isset($page['chronology_field']))
@@ -241,9 +240,17 @@ if ( $page['section']=='search' and $page['start']==0 )
}
//------------------------------------------------------ main part : thumbnails
-if (isset($page['thumbnails_include']))
+if ( 0==$page['start']
+ and !isset($page['flat'])
+ and !isset($page['chronology_field'])
+ and ('recent_cats'==$page['section'] or 'categories'==$page['section'])
+ )
{
- include(PHPWG_ROOT_PATH.$page['thumbnails_include']);
+ include(PHPWG_ROOT_PATH.'include/category_cats.inc.php');
+}
+if ( !empty($page['items']) )
+{
+ include(PHPWG_ROOT_PATH.'include/category_default.inc.php');
}
//------------------------------------------------------- category informations
@@ -258,7 +265,7 @@ if ($page['navigation_bar'] != '')
);
}
-if (isset($page['cat_nb_images']) and $page['cat_nb_images'] > 0
+if ( count($page['items']) > 0
and $page['section'] != 'most_visited'
and $page['section'] != 'best_rated')
{
diff --git a/picture.php b/picture.php
index e033fca7c..2abb4bc5d 100644
--- a/picture.php
+++ b/picture.php
@@ -453,7 +453,7 @@ if ( isset( $_GET['slideshow'] ) )
}
$title = $picture['current']['name'];
-$title_nb = ($page['current_rank'] + 1).'/'.$page['cat_nb_images'];
+$title_nb = ($page['current_rank'] + 1).'/'.count($page['items']);
// metadata
$url_metadata = duplicate_picture_url();
diff --git a/template/yoga/index.tpl b/template/yoga/index.tpl
index c5ae1fbea..0e0a1d1af 100644
--- a/template/yoga/index.tpl
+++ b/template/yoga/index.tpl
@@ -81,8 +81,8 @@
<!-- END calendar -->
{MONTH_CALENDAR}
-{THUMBNAILS}
{CATEGORIES}
+{THUMBNAILS}
<!-- BEGIN cat_infos -->
<!-- BEGIN navigation -->