Skip to content

Commit

Permalink
URL rewriting: capable of fully working with urls without ?
Browse files Browse the repository at this point in the history
URL rewriting: works with image file instead of image id (change
make_picture_url to generate urls with file name instead of image id)

URL rewriting: completely works with category/best_rated and
picture/best_rated/534 (change 'category.php?' to 'category' in make_index_url
and 'picture.php?' to 'picture' in make_picture_url to see it)

fix: picture category display in upper bar

fix: function rate_picture variables and use of the new user type

fix: caddie icon appears now on category page

fix: admin element_set sql query was using storage_category_id column
(column has moved to #image_categories)

fix: replaced some old $_GET[xxx] with $page[xxx]

fix: pictures have metadata url (use ? parameter - might change later)

git-svn-id: http://piwigo.org/svn/trunk@1092 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
rvelices committed Mar 22, 2006
1 parent 3609c22 commit 0971ce4
Show file tree
Hide file tree
Showing 28 changed files with 372 additions and 309 deletions.
36 changes: 18 additions & 18 deletions admin/element_set_global.php
Expand Up @@ -28,9 +28,9 @@
/**
* Management of elements set. Elements can belong to a category or to the
* user caddie.
*
*
*/

if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
Expand Down Expand Up @@ -58,9 +58,9 @@ function get_elements_keywords($element_ids)
{
return array();
}

$keywords = array();

$query = '
SELECT keywords
FROM '.IMAGES_TABLE.'
Expand All @@ -84,7 +84,7 @@ function get_elements_keywords($element_ids)
if (isset($_POST['submit']))
{
$collection = array();

// echo '<pre>';
// print_r($_POST);
// echo '</pre>';
Expand Down Expand Up @@ -136,7 +136,7 @@ function get_elements_keywords($element_ids)
)
);
}

mass_inserts(
IMAGE_CATEGORY_TABLE,
array('image_id', 'category_id'),
Expand Down Expand Up @@ -170,7 +170,7 @@ function get_elements_keywords($element_ids)
array($_POST['dissociate']),
$destinations_of[ $_POST['dissociate'] ]
);

// Eventually, deletion of associations
$query = '
DELETE
Expand All @@ -185,7 +185,7 @@ function get_elements_keywords($element_ids)
// have deleted the link between C and 1, while it should be kept due to
// B. Who said "complicated"?
check_links();

update_category($associated_categories);
}

Expand All @@ -205,7 +205,7 @@ function get_elements_keywords($element_ids)
array_push($dbfields['update'], $formfield);
}
}

// updating elements is useful only if needed...
if (count($dbfields['update']) > 0 and count($collection) > 0)
{
Expand All @@ -220,7 +220,7 @@ function get_elements_keywords($element_ids)
{
$data = array();
$data['id'] = $row['id'];

if (!empty($_POST['add_keywords']))
{
$data['keywords'] =
Expand All @@ -241,7 +241,7 @@ function get_elements_keywords($element_ids)
{
$data['keywords'] = empty($row['keywords']) ? '' : $row['keywords'];
}

$data['keywords'] =
implode(
',',
Expand Down Expand Up @@ -287,7 +287,7 @@ function get_elements_keywords($element_ids)
.'-'.$_POST['date_creation_day']
;
}

array_push($datas, $data);
}
// echo '<pre>'; print_r($datas); echo '</pre>';
Expand All @@ -308,18 +308,18 @@ function get_elements_keywords($element_ids)
$template->assign_vars(
array(
'CATEGORIES_NAV'=>$page['title'],

'L_SUBMIT'=>$lang['submit'],

'U_COLS'=>$base_url.get_query_string_diff(array('cols')),
'U_DISPLAY'=>$base_url.get_query_string_diff(array('display')),

'U_UNIT_MODE'
=>
$base_url
.get_query_string_diff(array('mode','display'))
.'&amp;mode=unit',

'F_ACTION'=>$base_url.get_query_string_diff(array()),
)
);
Expand Down Expand Up @@ -379,7 +379,7 @@ function get_elements_keywords($element_ids)
WHERE ic.image_id IN ('.implode(',', $page['cat_elements_id']).')
AND ic.category_id = c.id
AND ic.image_id = i.id
AND ic.category_id != i.storage_category_id
AND ic.is_storage = \'false\'
;';
display_select_cat_wrapper($query, array(), $blockname, true);
}
Expand Down Expand Up @@ -484,7 +484,7 @@ function get_elements_keywords($element_ids)
while ($row = mysql_fetch_array($result))
{
$src = get_thumbnail_src($row['path'], @$row['tn_ext']);

$template->assign_block_vars(
'thumbnails.line.thumbnail',
array(
Expand All @@ -494,7 +494,7 @@ function get_elements_keywords($element_ids)
'TITLE' => 'TODO'
)
);

// create a new line ?
if (++$row_number == $page['cols'])
{
Expand Down
37 changes: 20 additions & 17 deletions admin/picture_modify.php
Expand Up @@ -127,7 +127,7 @@
and count($_POST['cat_dissociated']) > 0)
{
$datas = array();

foreach ($_POST['cat_dissociated'] as $category_id)
{
array_push(
Expand All @@ -138,7 +138,7 @@
)
);
}

mass_inserts(
IMAGE_CATEGORY_TABLE,
array('image_id', 'category_id'),
Expand Down Expand Up @@ -166,7 +166,7 @@
$destinations
);
}

$query = '
DELETE FROM '.IMAGE_CATEGORY_TABLE.'
WHERE image_id = '.$_GET['image_id'].'
Expand Down Expand Up @@ -213,6 +213,7 @@
$row = mysql_fetch_array(pwg_query($query));

$storage_category_id = $row['category_id'];
$image_file = $row['file'];

// Navigation path

Expand All @@ -236,34 +237,34 @@
'&amp;image_id='.$_GET['image_id'].
(isset($_GET['cat_id']) ? '&amp;cat_id='.$_GET['cat_id'] : '').
'&amp;sync_metadata=1',

'PATH'=>$row['path'],

'TN_SRC' => get_thumbnail_src($row['path'], @$row['tn_ext']),

'NAME' =>
isset($_POST['name']) ?
stripslashes($_POST['name']) : @$row['name'],

'DIMENSIONS' => @$row['width'].' * '.@$row['height'],

'FILESIZE' => @$row['filesize'].' KB',

'REGISTRATION_DATE' =>
format_date($row['date_available'], 'mysql_datetime', false),

'AUTHOR' => isset($_POST['author']) ? $_POST['author'] : @$row['author'],

'CREATION_DATE' => $date,

'KEYWORDS' =>
isset($_POST['keywords']) ?
stripslashes($_POST['keywords']) : @$row['keywords'],

'DESCRIPTION' =>
isset($_POST['description']) ?
stripslashes($_POST['description']) : @$row['comment'],

'F_ACTION' =>
PHPWG_ROOT_PATH.'admin.php'
.get_query_string_diff(array('sync_metadata'))
Expand Down Expand Up @@ -292,7 +293,7 @@
get_day_list('date_creation_day', $day);
get_month_list('date_creation_month', $month);
$template->assign_vars(array('DATE_CREATION_YEAR_VALUE' => $year));

$query = '
SELECT category_id, uppercats
FROM '.IMAGE_CATEGORY_TABLE.' AS ic
Expand All @@ -315,7 +316,7 @@
PHPWG_ROOT_PATH.'admin.php?page=cat_modify&amp;cat_id=',
false
);

if ($row['category_id'] == $storage_category_id)
{
$template->assign_vars(array('STORAGE_CATEGORY' => $name));
Expand Down Expand Up @@ -354,6 +355,7 @@
$url_img = make_picture_URL(
array(
'image_id' => $_GET['image_id'],
'image_file' => $image_file,
'category' => $_GET['cat_id'],
)
);
Expand All @@ -365,6 +367,7 @@
$url_img = make_picture_URL(
array(
'image_id' => $_GET['image_id'],
'image_file' => $image_file,
'category' => $category,
)
);
Expand All @@ -381,7 +384,7 @@
)
);
}

// associate to another category ?
$query = '
SELECT id,name,uppercats,global_rank
Expand Down
12 changes: 6 additions & 6 deletions admin/user_perm.php
Expand Up @@ -92,19 +92,19 @@
// an error (in SQL statement), so we need to know which categories are
// accesible
$authorized_ids = array();

$query = '
SELECT cat_id
FROM '.USER_ACCESS_TABLE.'
WHERE user_id = '.$page['user'].'
;';
$result = pwg_query($query);

while ($row = mysql_fetch_array($result))
{
array_push($authorized_ids, $row['cat_id']);
}

$inserts = array();
$to_autorize_ids = array_diff($private_uppercats, $authorized_ids);
foreach ($to_autorize_ids as $to_autorize_id)
Expand Down Expand Up @@ -137,7 +137,7 @@
),
'L_CAT_OPTIONS_TRUE'=>$lang['authorized'],
'L_CAT_OPTIONS_FALSE'=>$lang['forbidden'],

'F_ACTION' =>
PHPWG_ROOT_PATH.
'admin.php?page=user_perm'.
Expand Down Expand Up @@ -177,7 +177,7 @@
$template->assign_block_vars(
'groups.category',
array(
'NAME' => get_cat_display_name_cache($category['uppercats'], '', false)
'NAME' => get_cat_display_name_cache($category['uppercats'], null, false)
)
);
}
Expand All @@ -197,7 +197,7 @@
$query_true.= '
;';
display_select_cat_wrapper($query_true,array(),'category_option_true');

$result = pwg_query($query_true);
$authorized_ids = array();
while ($row = mysql_fetch_array($result))
Expand Down
26 changes: 16 additions & 10 deletions category.php
Expand Up @@ -45,8 +45,7 @@
session_unset();
session_destroy();
setcookie(session_name(),'',0, cookie_path() );
$url = 'category.php';
redirect( $url );
redirect( make_index_url() );
}

//---------------------------------------------- change of image display order
Expand Down Expand Up @@ -113,11 +112,7 @@
//-------------------------------------------------------------- category title
if (isset($page['category']))
{
$template_title = get_cat_display_name(
$page['cat_name'],
'category.php?/category/',
false
);
$template_title = get_cat_display_name( $page['cat_name'], '', false );
}
else
{
Expand Down Expand Up @@ -206,7 +201,7 @@
$template->assign_block_vars(
'search_rules',
array(
'URL' => PHPWG_ROOT_PATH.'/search_rules.php?search_id='.$page['search'],
'URL' => get_root_url().'search_rules.php?search_id='.$page['search'],
)
);
}
Expand Down Expand Up @@ -264,7 +259,7 @@
$template->assign_block_vars(
'special_cat',
array(
'URL' => PHPWG_ROOT_PATH.'random.php',
'URL' => get_root_url().'random.php',
'TITLE' => $lang['random_cat_hint'],
'NAME' => $lang['random_cat']
));
Expand Down Expand Up @@ -395,6 +390,17 @@
);
}

if (is_admin() and !empty($page['items']) )
{
$template->assign_block_vars(
'caddie',
array(
'URL' =>
add_url_param(duplicate_index_url(),'caddie=1')
)
);
}

//------------------------------------------------------ main part : thumbnails
if (isset($page['thumbnails_include']))
{
Expand Down Expand Up @@ -453,7 +459,7 @@
// upload a picture in the category
if ($page['cat_uploadable'])
{
$url = PHPWG_ROOT_PATH.'upload.php?cat='.$page['category'];
$url = get_root_url().'upload.php?cat='.$page['category'];
$template->assign_block_vars(
'upload',
array(
Expand Down

0 comments on commit 0971ce4

Please sign in to comment.