diff --git a/admin/cat_list.php b/admin/cat_list.php index 7917b0a6a..2c659ee3f 100644 --- a/admin/cat_list.php +++ b/admin/cat_list.php @@ -173,7 +173,7 @@ if (isset($_GET['parent_id'])) $navigation.= $conf['level_separator']; $current_category = get_cat_info($_GET['parent_id']); - + $navigation.= get_cat_display_name( $current_category['name'], $base_url.'&parent_id=', @@ -194,7 +194,7 @@ if (isset($_GET['parent_id'])) $template->assign_vars(array( 'CATEGORIES_NAV'=>$navigation, 'F_ACTION'=>$form_action, - + 'L_ADD_VIRTUAL'=>$lang['cat_add'], 'L_SUBMIT'=>$lang['submit'], 'L_STORAGE'=>$lang['storage'], @@ -203,7 +203,7 @@ $template->assign_vars(array( 'L_EDIT'=>$lang['edit'], 'L_DELETE'=>$lang['delete'], )); - + $tpl = array('cat_first','cat_last'); // +-----------------------------------------------------------------------+ // | Categories display | @@ -256,10 +256,10 @@ foreach ($categories as $category) // TODO : not used anymore ? //$images_folder = PHPWG_ROOT_PATH.'template/'; //$images_folder.= $user['template'].'/admin/images'; - + $base_url = PHPWG_ROOT_PATH.'admin.php?page='; $cat_list_url = $base_url.'cat_list'; - + $self_url = $cat_list_url; if (isset($_GET['parent_id'])) { @@ -276,14 +276,15 @@ foreach ($categories as $category) 'U_JUMPTO' => make_index_url( array( 'category' => $category['id'], + 'cat_name' => $category['name'], ) ), - - 'U_CHILDREN' => $cat_list_url.'&parent_id='.$category['id'], + + 'U_CHILDREN' => $cat_list_url.'&parent_id='.$category['id'], 'U_EDIT' => $base_url.'cat_modify&cat_id='.$category['id'], ) ); - + if (empty($category['dir'])) { $template->assign_block_vars( @@ -293,7 +294,7 @@ foreach ($categories as $category) ) ); } - + if ($category['nb_images'] > 0) { $template->assign_block_vars( diff --git a/admin/cat_modify.php b/admin/cat_modify.php index 4f4617224..9bfa257dd 100644 --- a/admin/cat_modify.php +++ b/admin/cat_modify.php @@ -68,7 +68,7 @@ if (isset($_POST['submit'])) ), array($data) ); - + set_cat_visible(array($_GET['cat_id']), $_POST['visible']); set_cat_status(array($_GET['cat_id']), $_POST['status']); @@ -101,7 +101,7 @@ else if (isset($_POST['submitAdd'])) $_POST['virtual_name'], (0 == $_POST['parent'] ? null : $_POST['parent']) ); - + if (isset($output_create['error'])) { array_push($page['errors'], $output_create['error']); @@ -112,7 +112,7 @@ else if (isset($_POST['submitAdd'])) // // Add the information in the information list array_push($page['infos'], $output_create['info']); - + // Link the new category to the current category associate_categories_to_categories( array($_GET['cat_id']), @@ -184,7 +184,7 @@ $navigation = get_cat_display_name_cache( ); $form_action = PHPWG_ROOT_PATH.'admin.php?page=cat_modify&cat_id='.$_GET['cat_id']; -$status = ($category['status']=='public')?'STATUS_PUBLIC':'STATUS_PRIVATE'; +$status = ($category['status']=='public')?'STATUS_PUBLIC':'STATUS_PRIVATE'; $lock = ($category['visible']=='true')?'UNLOCKED':'LOCKED'; if ($category['commentable'] == 'true') @@ -208,7 +208,7 @@ else $base_url = PHPWG_ROOT_PATH.'admin.php?page='; $cat_list_url = $base_url.'cat_list'; - + $self_url = $cat_list_url; if (!empty($category['id_uppercat'])) { @@ -216,16 +216,16 @@ if (!empty($category['id_uppercat'])) } $template->assign_vars( - array( + array( 'CATEGORIES_NAV' => $navigation, 'CAT_NAME' => $category['name'], 'CAT_COMMENT' => $category['comment'], - + $status => 'checked="checked"', $lock => 'checked="checked"', $commentable => 'checked="checked"', $uploadable => 'checked="checked"', - + 'L_EDIT_NAME' => $lang['name'], 'L_STORAGE' => $lang['storage'], 'L_REMOTE_SITE' => $lang['remote_site'], @@ -244,12 +244,13 @@ $template->assign_vars( 'U_JUMPTO' => make_index_url( array( 'category' => $category['id'], + 'cat_name' => $category['name'], ) ), - + 'U_CHILDREN' => $cat_list_url.'&parent_id='.$category['id'], 'U_HELP' => PHPWG_ROOT_PATH.'/popuphelp.php?page=cat_modify', - + 'F_ACTION' => $form_action, ) ); @@ -295,7 +296,7 @@ SELECT tn_ext,path $src = get_thumbnail_src($row['path'], @$row['tn_ext']); $url = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'; $url.= '&image_id='.$category['representative_picture_id']; - + $template->assign_block_vars( 'representant.picture', array( @@ -349,7 +350,7 @@ else // the category can be moved in any category but in itself, in any // sub-category $unmovables = get_subcat_ids(array($category['id'])); - + $blockname = 'move.parent_option'; $template->assign_block_vars( @@ -361,13 +362,13 @@ else 'OPTION' => '------------' ) ); - + $query = ' SELECT id,name,uppercats,global_rank FROM '.CATEGORIES_TABLE.' WHERE id NOT IN ('.implode(',', $unmovables).') ;'; - + display_select_cat_wrapper( $query, empty($category['id_uppercat']) ? array() : array($category['id_uppercat']), diff --git a/include/category_subcats.inc.php b/include/category_subcats.inc.php index 57fe73cec..8deef5711 100644 --- a/include/category_subcats.inc.php +++ b/include/category_subcats.inc.php @@ -28,7 +28,7 @@ /** * This file is included by the main page to show thumbnails for a category * that have only subcategories - * + * */ $query = ' @@ -90,6 +90,12 @@ SELECT representative_picture_id } } + $comment = null; + if ( isset($row['comment']) ) + { + $comment = strip_tags( $row['comment'] ); + } + if (isset($image_id)) { array_push( @@ -99,7 +105,7 @@ SELECT representative_picture_id 'picture' => $image_id, 'name' => $row['name'], 'date_last' => @$row['date_last'], - 'comment' => @$row['comment'], + 'comment' => $comment, 'nb_images' => $row['nb_images'], ) ); @@ -111,7 +117,7 @@ SELECT representative_picture_id if (count($cat_thumbnails) > 0) { $images = array(); - + foreach ($cat_thumbnails as $item) { $images[$item['picture']] = ''; @@ -129,7 +135,7 @@ SELECT id, path, tn_ext } $template->assign_block_vars('categories', array()); - + foreach ($cat_thumbnails as $item) { $template->assign_block_vars( @@ -139,10 +145,11 @@ SELECT id, path, tn_ext 'ALT' => $item['name'], 'TITLE' => $lang['hint_category'], 'ICON' => get_icon(@$item['date_last']), - + 'URL' => make_index_url( array( 'category' => $item['category'], + 'cat_name' => $item['name'], ) ), 'NAME' => $item['name'], @@ -152,4 +159,4 @@ SELECT id, path, tn_ext ); } } -?> +?> \ No newline at end of file diff --git a/include/config_default.inc.php b/include/config_default.inc.php index 72363d85d..655b13d76 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -424,20 +424,29 @@ $conf['history_admin'] = false; // (depends on the server AcceptPathInfo directive configuration) $conf['question_mark_in_urls'] = true; -// picture_url_style : one of 'id' 'id-file' or 'file'. 'id-file' or 'file' -// mean that the file name (without extension will appear in the url). -// Note that one aditionnal sql query will occur if 'file' is choosen. -// Note that you might experience navigation issues if you choose 'file' -// and your file names are not unique -$conf['picture_url_style'] = 'id'; - - // php_extension_in_urls : if true, the urls generated for picture and // category will not contain the .php extension. This will work only if // .htaccess defines Options +MultiViews parameter or url rewriting rules // are active. $conf['php_extension_in_urls'] = true; +// category_url_style : one of 'id' (default) or 'id-name'. 'id-name' +// means that an simplified ascii represntation of the category name will +// appear in the url +$conf['category_url_style'] = 'id'; + +// picture_url_style : one of 'id' (default), 'id-file' or 'file'. 'id-file' +// or 'file' mean that the file name (without extension will appear in the +// url). Note that one aditionnal sql query will occur if 'file' is choosen. +// Note that you might experience navigation issues if you choose 'file' +// and your file names are not unique +$conf['picture_url_style'] = 'id'; + +// tag_url_style : one of 'id-tag' (default), 'id' or 'tag'. +// Note that if you choose 'tag' and the url (ascii) representation of your +// tags is not unique, all tags with the same url representation will be shown +$conf['tag_url_style'] = 'id-tag'; + // +-----------------------------------------------------------------------+ // | tags | // +-----------------------------------------------------------------------+ diff --git a/include/functions.inc.php b/include/functions.inc.php index d8b86743f..5a1245c4b 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -290,10 +290,10 @@ function str2url($str) $str = str_replace('¼', 'OE', $str); $str = str_replace('½', 'oe', $str); - $str = preg_replace('/[^a-z0-9_\s\'\:\/\[\]-]/','',strtolower($str)); - $str = preg_replace('/[\s\'\:\/\[\]-]+/',' ',trim($str)); + $str = preg_replace('/[^a-z0-9_\s\'\:\/\[\],-]/','',strtolower($str)); + $str = preg_replace('/[\s\'\:\/\[\],-]+/',' ',trim($str)); $res = str_replace(' ','_',$str); - + return $res; } diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php index 13c3dc206..b217f01d9 100644 --- a/include/functions_html.inc.php +++ b/include/functions_html.inc.php @@ -278,7 +278,14 @@ function get_cat_display_name($cat_informations, elseif ($url == '') { $output.= '$id) ).'">'; + $output.= ' href="' + .make_index_url( + array( + 'category'=>$id, + 'cat_name'=>$name + ) + ) + .'">'; $output.= $name.''; } else @@ -353,7 +360,14 @@ SELECT id,name { $output.= ' '.$name.''; + href="' + .make_index_url( + array( + 'category'=>$category_id, + 'cat_name'=>$name + ) + ) + .'">'.$name.''; } else { @@ -423,7 +437,12 @@ function get_html_menu_category($categories) } $menu.= '>'; - $url = make_index_url(array('category' => $category['id'])); + $url = make_index_url( + array( + 'category'=>$category['id'], + 'cat_name'=>$category['name'] + ) + ); $menu.= "\n".' $matches[1], - 'url_name' => isset($matches[2]) ? $matches[2] : '', - ) - ); - $i++; } - $next_token = $i; + + if ( empty($requested_tag_ids) && empty($requested_tag_url_names) ) + { + die('Fatal: at least one tag required'); + } + // tag infos + $query = ' +SELECT name, url_name, id + FROM '.TAGS_TABLE.' + WHERE '; + if ( !empty($requested_tag_ids) ) + { + $query.= 'id IN ('.implode(',', $requested_tag_ids ).')'; + } + if ( !empty($requested_tag_url_names) ) + { + if ( !empty($requested_tag_ids) ) + { + $query.= ' OR '; + } + $query.= 'url_name IN ('.implode(',', $requested_tag_url_names ).')'; + } + $result = pwg_query($query); + $tag_infos = array(); + while ($row = mysql_fetch_array($result)) + { + $tag_infos[ $row['id'] ] = $row; + array_push($page['tags'], $row );//we loose given tag order; is it important? + } + if ( empty($page['tags']) ) + { + die('Fatal: no existing tag'); + } } else if (0 === strpos($tokens[$next_token], 'fav')) { @@ -239,7 +264,7 @@ while (isset($tokens[$i])) $page['start'] = $matches[1]; } - if (preg_match('/^posted|created/', $tokens[$i] )) + if (preg_match('/^(posted|created)/', $tokens[$i] )) { $chronology_tokens = explode('-', $tokens[$i] ); @@ -359,7 +384,7 @@ else // permissions depends on category, so to only keep images that are // reachable to the connected user, we need to check category // associations - if (!empty($user['forbidden_categories']) and !empty($items) ) + if (!empty($items) ) { $query = ' SELECT image_id @@ -373,21 +398,6 @@ SELECT image_id ); } - // tag names - $query = ' -SELECT name, url_name, id - FROM '.TAGS_TABLE.' - WHERE id IN ('.implode(',', $page['tag_ids']).') -;'; - $result = pwg_query($query); - $tag_infos = array(); - - while ($row = mysql_fetch_array($result)) - { - $tag_infos[ $row['id'] ]['name'] = $row['name']; - $tag_infos[ $row['id'] ]['url_name'] = $row['url_name']; - } - $title = count($page['tags']) > 1 ? l10n('Tags') : l10n('Tag'); $title.= ' '; diff --git a/install/db/22-database.php b/install/db/22-database.php new file mode 100644 index 000000000..fcead3cf2 --- /dev/null +++ b/install/db/22-database.php @@ -0,0 +1,58 @@ + diff --git a/install/phpwebgallery_structure.sql b/install/phpwebgallery_structure.sql index 253157e79..dbc7b2335 100644 --- a/install/phpwebgallery_structure.sql +++ b/install/phpwebgallery_structure.sql @@ -140,7 +140,8 @@ DROP TABLE IF EXISTS `phpwebgallery_image_tag`; CREATE TABLE `phpwebgallery_image_tag` ( `image_id` mediumint(8) unsigned NOT NULL default '0', `tag_id` smallint(5) unsigned NOT NULL default '0', - PRIMARY KEY (`image_id`,`tag_id`) + PRIMARY KEY (`image_id`,`tag_id`), + KEY `image_tag_i1` (`tag_id`) ) TYPE=MyISAM; -- @@ -233,7 +234,8 @@ CREATE TABLE `phpwebgallery_tags` ( `id` smallint(5) unsigned NOT NULL auto_increment, `name` varchar(255) binary NOT NULL default '', `url_name` varchar(255) binary NOT NULL default '', - PRIMARY KEY (`id`) + PRIMARY KEY (`id`), + KEY `tags_i1` (`url_name`) ) TYPE=MyISAM; -- diff --git a/template/yoga/default-layout.css b/template/yoga/default-layout.css index d8f70bfb6..bcbfe81f2 100644 --- a/template/yoga/default-layout.css +++ b/template/yoga/default-layout.css @@ -188,11 +188,11 @@ FORM.properties SPAN.property { padding: 0 0.5em 0 0; } -FORM.properties .focus { +FORM .focus { background-color: whitesmoke; } -FORM.properties .nofocus { +FORM .nofocus { background-color: lightgrey; /* must be the same as input background-color */ } diff --git a/template/yoga/identification.tpl b/template/yoga/identification.tpl index 8f28ac224..1fd0e7619 100644 --- a/template/yoga/identification.tpl +++ b/template/yoga/identification.tpl @@ -20,27 +20,27 @@ -
+
{lang:Connection settings} - + - +