<?php
/*
 * Gallery - a web based photo album viewer and editor
 * Copyright (C) 2000-2002 Bharat Mediratta
 * 
 * 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; either version 2 of the License, or (at
 * your option) any later version.
 * 
 * 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.
 */
?>
<?php
// Hack prevention.
if (!empty($HTTP_GET_VARS["GALLERY_BASEDIR"]) ||
		!empty($HTTP_POST_VARS["GALLERY_BASEDIR"]) ||
		!empty($HTTP_COOKIE_VARS["GALLERY_BASEDIR"])) {
	print "Security violation\n";
	exit;
}
?>
<?php require("./init.php"); ?>
<?php
// Hack check
if (!$gallery->user->canWriteToAlbum($gallery->album)) {
	exit;
}
?>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=EUC-JP">
  <title>アルバムのソート</title>
   
</head>
<body>

<?php
if ($gallery->session->albumName) {
	if ($confirm) {
		if (!strcmp($sort,"random")) {
			$gallery->album->shufflePhotos();
			$gallery->album->save();
			dismissAndReload();
			return;
		} else {
			$gallery->album->sortPhotos($sort,$order,true);
			$gallery->album->save();
			dismissAndReload();
			return;
		}
	} else {
?>

<center>
このアルバムのソート基準を下から選んで下さい
<br>
注意：この操作は戻せません
<br>
<br>

<p>
<?php
if ($gallery->album->getHighlight()) {
	print $gallery->album->getThumbnailTag($gallery->album->getHighlight());
}
?>
<br>
<?php echo $gallery->album->fields["caption"] ?>

<?php echo makeFormIntro("sort_album.php"); ?>
<table>
  <tr>
    <td><input checked type="radio" name="sort" value="upload">&nbsp;アップロード日付</td>
  </tr>
  <tr>
    <td><input type="radio" name="sort" value="itemCapture">&nbsp;撮影日付</td>
  </tr>
  <tr>
    <td><input type="radio" name="sort" value="filename">&nbsp;ファイル名</td>
  </tr>
  <tr>
    <td><input type="radio" name="sort" value="click">&nbsp;クリック数</td>
  </tr>
  <tr>
    <td><input type="radio" name="sort" value="caption">&nbsp;見出し</td>
  </tr>
  <tr>
    <td><input type="radio" name="sort" value="comment">&nbsp;コメント数</td>
  </tr>
  <tr>
    <td><input type="radio" name="sort" value="random">&nbsp;ランダム</td>
  </tr>
  <tr>
    <td align=center>
<select name="order">
  <option value="0">昇順</option>
  <option value="1">降順</option>
</select>
    </td>
  </tr>
</table>
<br>
<input type=submit name=confirm value="ソート">
<input type=submit value="Cancel" onclick='parent.close()'>
</form>
<?php
	}
} else {
	gallery_error("no album specified");
}
?>

</body>
</html>
