aboutsummaryrefslogtreecommitdiffstats
path: root/include
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
4 files changed, 36 insertions, 82 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 = '