Skip to content

Commit

Permalink
feature 2564: redesign on photo administration screen.
Browse files Browse the repository at this point in the history
* one screen with several tabs (for now: properties + coi)

* double select boxes for album associations and representation have been
  converted to simple multiple select boxes with jQuery Chosen

* more details about the photo in an introduction text


git-svn-id: http://piwigo.org/svn/trunk@13077 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Feb 10, 2012
1 parent 62bfdd3 commit bea45c8
Show file tree
Hide file tree
Showing 17 changed files with 741 additions and 300 deletions.
13 changes: 13 additions & 0 deletions admin.php
Expand Up @@ -132,6 +132,18 @@
}
}

// ?page=photo-1234-properties is an clean alias of
// ?page=photo&image_id=1234&tab=properties
if (isset($_GET['page']) and preg_match('/^photo-(\d+)(?:-(.*))?$/', $_GET['page'], $matches))
{
$_GET['page'] = 'photo';
$_GET['image_id'] = $matches[1];
if (isset($matches[2]))
{
$_GET['tab'] = $matches[2];
}
}

if (isset($_GET['page'])
and preg_match('/^[a-z_]*$/', $_GET['page'])
and is_file(PHPWG_ROOT_PATH.'admin/'.$_GET['page'].'.php'))
Expand Down Expand Up @@ -236,6 +248,7 @@ function UC_name_compare($a, $b)
'album', // delete cat; public/private; lock/unlock, permissions
'cat_move', // ?only POST
'cat_options', // ?only POST; public/private; lock/unlock
'photo',
'picture_modify', // ?only POST; associate/dissociate
'user_perm',
'group_perm',
Expand Down
19 changes: 2 additions & 17 deletions admin/batch_manager_global.php
Expand Up @@ -179,20 +179,7 @@

if ('move' == $action)
{
// let's first break links with all albums but their "storage album"
$query = '
DELETE '.IMAGE_CATEGORY_TABLE.'.*
FROM '.IMAGE_CATEGORY_TABLE.'
JOIN '.IMAGES_TABLE.' ON image_id=id
WHERE id IN ('.implode(',', $collection).')
AND (storage_category_id IS NULL OR storage_category_id != category_id)
;';
pwg_query($query);

associate_images_to_categories(
$collection,
array($_POST['move'])
);
move_images_to_categories($collection, array($_POST['move']));

$_SESSION['page_infos'] = array(
l10n('Information data registered in database')
Expand Down Expand Up @@ -786,9 +773,7 @@
'TITLE' => $title,
'LEVEL' => $row['level'],
'FILE_SRC' => $row['path'],
'U_EDIT' =>
PHPWG_ROOT_PATH.'admin.php?page=picture_modify'.
'&image_id='.$row['id'],
'U_EDIT' => get_root_url().'admin.php?page=photo-'.$row['id'],
)
);
}
Expand Down
7 changes: 2 additions & 5 deletions admin/batch_manager_unit.php
Expand Up @@ -265,11 +265,8 @@
'ID' => $row['id'],
'TN_SRC' => $src,
'FILE_SRC' => $row['path'],
'LEGEND' => !empty($row['name']) ?
$row['name'] : get_name_from_file($row['file']),
'U_EDIT' =>
PHPWG_ROOT_PATH.'admin.php?page=picture_modify'.
'&image_id='.$row['id'],
'LEGEND' => render_element_name($row),
'U_EDIT' => get_root_url().'admin.php?page=photo-'.$row['id'],
'NAME' => !empty($row['name'])?$row['name']:'',
'AUTHOR' => !empty($row['author'])?htmlspecialchars($row['author']):'',
'LEVEL' => !empty($row['level'])?$row['level']:'0',
Expand Down
3 changes: 1 addition & 2 deletions admin/cat_modify.php
Expand Up @@ -343,8 +343,7 @@ function get_site_url($category_id)
;';
$row = pwg_db_fetch_assoc(pwg_query($query));
$src = DerivativeImage::thumb_url($row);
$url = get_root_url().'admin.php?page=picture_modify';
$url.= '&image_id='.$category['representative_picture_id'];
$url = get_root_url().'admin.php?page=photo-'.$category['representative_picture_id'];

$tpl_representant['picture'] =
array(
Expand Down
4 changes: 1 addition & 3 deletions admin/comments.php
Expand Up @@ -129,9 +129,7 @@
$template->append(
'comments',
array(
'U_PICTURE' =>
PHPWG_ROOT_PATH.'admin.php?page=picture_modify'.
'&image_id='.$row['image_id'],
'U_PICTURE' => get_root_url().'admin.php?page=photo-'.$row['image_id'],
'ID' => $row['id'],
'TN_SRC' => $thumb,
'AUTHOR' => trigger_event('render_comment_author', $author_name),
Expand Down
32 changes: 32 additions & 0 deletions admin/include/functions.php
Expand Up @@ -1530,6 +1530,37 @@ function associate_images_to_categories($images, $categories)
update_category($categories);
}

/**
* Disssociate images from all categories except their storage category and
* associate to new categories.
*
* @param array images
* @param array categories
* @return void
*/
function move_images_to_categories($images, $categories)
{
if (count($images) == 0)
{
return false;
}

// let's first break links with all albums but their "storage album"
$query = '
DELETE '.IMAGE_CATEGORY_TABLE.'.*
FROM '.IMAGE_CATEGORY_TABLE.'
JOIN '.IMAGES_TABLE.' ON image_id=id
WHERE id IN ('.implode(',', $images).')
AND (storage_category_id IS NULL OR storage_category_id != category_id)
;';
pwg_query($query);

if (is_array($categories) and count($categories) > 0)
{
associate_images_to_categories($images, $categories);
}
}

/**
* Associate images associated to a list of source categories to a list of
* destination categories.
Expand Down Expand Up @@ -1987,6 +2018,7 @@ function get_active_menu($menu_page)

switch ($menu_page)
{
case 'photo':
case 'photos_add':
case 'rating':
case 'tags':
Expand Down
5 changes: 1 addition & 4 deletions admin/include/photos_add_direct_process.inc.php
Expand Up @@ -215,10 +215,7 @@
// function get_image_name($name, $file) would be better
$thumbnail['title'] = get_name_from_file($image_infos['file']);

$thumbnail['link'] = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'
.'&image_id='.$image_id
.'&cat_id='.$category_id
;
$thumbnail['link'] = get_root_url().'admin.php?page=photo-'.$image_id.'&cat_id='.$category_id;

array_push($page['thumbnails'], $thumbnail);
}
Expand Down
86 changes: 86 additions & 0 deletions admin/photo.php
@@ -0,0 +1,86 @@
<?php
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2008-2012 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation |
// | |
// | This program is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA. |
// +-----------------------------------------------------------------------+

if( !defined("PHPWG_ROOT_PATH") )
{
die ("Hacking attempt!");
}

// +-----------------------------------------------------------------------+
// | Basic checks |
// +-----------------------------------------------------------------------+

check_status(ACCESS_ADMINISTRATOR);

check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
check_input_parameter('image_id', $_GET, false, PATTERN_ID);

$admin_photo_base_url = get_root_url().'admin.php?page=photo-'.$_GET['image_id'];

if (isset($_GET['cat_id']))
{
$query = '
SELECT *
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$_GET['cat_id'].'
;';
$category = pwg_db_fetch_assoc(pwg_query($query));
}

// +-----------------------------------------------------------------------+
// | Tabs |
// +-----------------------------------------------------------------------+

include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');

$page['tab'] = 'properties';

if (isset($_GET['tab']))
{
$page['tab'] = $_GET['tab'];
}

$tabsheet = new tabsheet();
$tabsheet->add('properties', l10n('Properties'), $admin_photo_base_url.'-properties');
$tabsheet->add('coi', l10n('Center of interest'), $admin_photo_base_url.'-coi');

$tabsheet->select($page['tab']);
$tabsheet->assign();

// +-----------------------------------------------------------------------+
// | Load the tab |
// +-----------------------------------------------------------------------+

if ('properties' == $page['tab'])
{
include(PHPWG_ROOT_PATH.'admin/picture_modify.php');
}
elseif ('coi' == $page['tab'])
{
include(PHPWG_ROOT_PATH.'admin/picture_coi.php');
}
else
{
include(PHPWG_ROOT_PATH.'admin/photo_'.$page['tab'].'.php');
}
?>
2 changes: 1 addition & 1 deletion admin/picture_coi.php
Expand Up @@ -78,9 +78,9 @@
}

$tpl_var = array(
'TITLE' => render_element_name($row),
'ALT' => $row['file'],
'U_IMG' => DerivativeImage::url(IMG_LARGE, $row),
'U_EDIT' => get_root_url().'admin.php?page=picture_modify&amp;image_id='.$_GET['image_id'],
);

if (!empty($row['coi']))
Expand Down

0 comments on commit bea45c8

Please sign in to comment.